diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000000..6fb5f5e10e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,69 @@ +name: Bug report +description: Report a bug with the twilio-python helper library. +title: "[BUG] Describe the issue briefly" +labels: "type: bug" +body: + - type: markdown + attributes: + value: | + Thank you for reporting a bug in the twilio-python helper library. Please provide the details below to help us investigate and resolve the issue. + + - type: textarea + attributes: + label: Describe the bug + description: Provide a clear and concise description of the issue. + placeholder: A clear and concise description of the bug. + validations: + required: true + + - type: textarea + attributes: + label: Code snippet + description: Provide the code snippet that reproduces the issue. + placeholder: "```\n// Code snippet here\n```" + validations: + required: true + + - type: textarea + attributes: + label: Actual behavior + description: Describe what actually happened. + placeholder: A description of the actual behavior. + validations: + required: true + + - type: textarea + attributes: + label: Expected behavior + description: Describe what you expected to happen. + placeholder: A description of the expected outcome. + validations: + required: true + + - type: input + attributes: + label: twilio-python version + description: Specify the version of the twilio-python helper library you are using. + placeholder: e.g., 9.4.1 + validations: + required: true + + - type: input + attributes: + label: Python version + description: Specify the version of Python you are using. + placeholder: e.g., 3.9.1 + validations: + required: true + + - type: textarea + attributes: + label: Logs or error messages + description: Provide relevant logs or error messages (if any). + placeholder: "Error: Something went wrong..." + + - type: textarea + attributes: + label: Additional context + description: Add any other context about the problem here. + placeholder: Any additional diff --git a/.github/workflows/test-and-deploy.yml b/.github/workflows/test-and-deploy.yml index 9fdcf4c752..db745daca2 100644 --- a/.github/workflows/test-and-deploy.yml +++ b/.github/workflows/test-and-deploy.yml @@ -17,7 +17,7 @@ jobs: timeout-minutes: 20 strategy: matrix: - python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11', '3.12' ] + python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ] steps: - name: Checkout twilio-python uses: actions/checkout@v3 @@ -47,6 +47,7 @@ jobs: TWILIO_FROM_NUMBER: ${{ secrets.TWILIO_FROM_NUMBER }} TWILIO_TO_NUMBER: ${{ secrets.TWILIO_TO_NUMBER }} TWILIO_AUTH_TOKEN: ${{ secrets.TWILIO_AUTH_TOKEN }} + ASSISTANT_ID: ${{ secrets.ASSISTANT_ID }} run: make cluster-test - name: Verify docs generation diff --git a/CHANGES.md b/CHANGES.md index d5fbaebfcc..a9321f3330 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,490 @@ twilio-python Changelog Here you can see the full list of changes between each twilio-python release. +[2025-05-05] Version 9.6.0 +-------------------------- +**Library - Fix** +- [PR #848](https://github.com/twilio/twilio-python/pull/848): Timezone changes in token_auth_strategy.py. Thanks to [@Pablo2113](https://github.com/Pablo2113)! +- [PR #853](https://github.com/twilio/twilio-python/pull/853): Fix deprecated/invalid config in `setup.cfg`. Thanks to [@abravalheri](https://github.com/abravalheri)! + +**Library - Chore** +- [PR #858](https://github.com/twilio/twilio-python/pull/858): fix oauth examples. Thanks to [@tiwarishubham635](https://github.com/tiwarishubham635)! + +**Library - Docs** +- [PR #855](https://github.com/twilio/twilio-python/pull/855): update pagination usage in README.md. Thanks to [@manisha1997](https://github.com/manisha1997)! + +**Api** +- Add `response_key` for `Usage Triggers` fetch endpoint. + +**Flex** +- Add Update Interaction API +- Adding `webhook_ttid` as optional parameter in Interactions API + +**Serverless** +- Add node22 as a valid Build runtime +- Add node20 as a valid Build runtime + +**Video** +- removed `transcribe_participants_on_connect` and `transcriptions_configuration` from the room resource **(breaking change)** +- Added `transcribe_participants_on_connect` and `transcriptions_configuration` to the room resource + + +[2025-04-07] Version 9.5.2 +-------------------------- +**Studio** +- Add documentation for parent_step_sid field in Step resource + + +[2025-03-20] Version 9.5.1 +-------------------------- +**Accounts** +- Update Safelist API docs as part of prefix supoort + +**Flex** +- Removing `first_name`, `last_name`, and `friendly_name` from the Flex User API + +**Messaging** +- Add missing tests under transaction/phone_numbers and transaction/short_code + + +[2025-03-11] Version 9.5.0 +-------------------------- +**Library - Feature** +- [PR #850](https://github.com/twilio/twilio-python/pull/850): Update UPGRADE.md. Thanks to [@manisha1997](https://github.com/manisha1997)! + +**Library - Fix** +- [PR #847](https://github.com/twilio/twilio-python/pull/847): AssistantsBase import. Thanks to [@sbansla](https://github.com/sbansla)! + +**Api** +- Add the missing `emergency_enabled` field for `Address Service` endpoints + +**Messaging** +- Add missing enums for A2P and TF + +**Numbers** +- add missing enum values to hosted_number_order_status + +**Twiml** +- Convert Twiml Attribute `speechModel` of type enum to string **(breaking change)** + + +[2025-02-20] Version 9.4.6 +-------------------------- +**Library - Chore** +- [PR #842](https://github.com/twilio/twilio-python/pull/842): issue 841. Thanks to [@manisha1997](https://github.com/manisha1997)! + +**Flex** +- Adding Digital Transfers APIs under v1/Interactions + +**Numbers** +- Convert webhook_type to ienum type in v1/Porting/Configuration/Webhook/{webhook_type} + +**Trusthub** +- Changing TrustHub SupportingDocument status enum from lowercase to uppercase since kyc-orch returns status capitalized and rest proxy requires strict casing + + +[2025-02-11] Version 9.4.5 +-------------------------- +**Api** +- Change downstream url and change media type for file `base/api/v2010/validation_request.json`. + +**Intelligence** +- Add json_results for Generative JSON operator results + +**Messaging** +- Add DestinationAlphaSender API to support Country-Specific Alpha Senders + +**Video** +- Change codec type from enum to case-insensitive enum in recording and room_recording apis + + +[2025-01-28] Version 9.4.4 +-------------------------- +**Library - Fix** +- [PR #822](https://github.com/twilio/twilio-python/pull/822): Fix for 10 vulnerabilities. Thanks to [@twilio-product-security](https://github.com/twilio-product-security)! + +**Library - Chore** +- [PR #834](https://github.com/twilio/twilio-python/pull/834): update httpclient. Thanks to [@manisha1997](https://github.com/manisha1997)! +- [PR #837](https://github.com/twilio/twilio-python/pull/837): enable newer versions of aiohttp-retry. Thanks to [@tiwarishubham635](https://github.com/tiwarishubham635)! +- [PR #833](https://github.com/twilio/twilio-python/pull/833): created bug report issue template. Thanks to [@sbansla](https://github.com/sbansla)! + +**Api** +- Add open-api file tag to `conference/call recordings` and `recording_transcriptions`. + +**Events** +- Add support for subaccount subscriptions (beta) + +**Insights** +- add new region to conference APIs + +**Lookups** +- Add new `parnter_sub_id` query parameter to the lookup request + + +[2025-01-13] Version 9.4.3 +-------------------------- +**Messaging** +- Adds validity period Default value in service resource documentation + + +[2025-01-09] Version 9.4.2 +-------------------------- +**Library - Chore** +- [PR #832](https://github.com/twilio/twilio-python/pull/832): remove test for 3.7. Thanks to [@tiwarishubham635](https://github.com/tiwarishubham635)! + +**Numbers** +- Change beta feature flag to use v2/BulkHostedNumberOrders + + +[2024-12-13] Version 9.4.1 +-------------------------- +**Library - Fix** +- [PR #827](https://github.com/twilio/twilio-python/pull/827): Fixing init file for preview iam domain. Thanks to [@AsabuHere](https://github.com/AsabuHere)! + +**Library - Chore** +- [PR #826](https://github.com/twilio/twilio-python/pull/826): fix orgs api changes. Thanks to [@tiwarishubham635](https://github.com/tiwarishubham635)! + + +[2024-12-12] Version 9.4.0 +-------------------------- +**Library - Feature** +- [PR #825](https://github.com/twilio/twilio-python/pull/825): Docs update and examples for organization api uptake and public oauth. Thanks to [@AsabuHere](https://github.com/AsabuHere)! +- [PR #815](https://github.com/twilio/twilio-python/pull/815): Organizations Api uptake for twilio-python. Thanks to [@AsabuHere](https://github.com/AsabuHere)! + + +[2024-12-05] Version 9.3.8 +-------------------------- +**Api** +- Add optional parameter `intelligence_service` to `transcription` +- Updated `phone_number_sid` to be populated for sip trunking terminating calls. + +**Numbers** +- Add Update Hosted Number Order V2 API endpoint +- Update Port in docs + +**Twiml** +- Add optional parameter `intelligence_service` to `` +- Add support for new `` and `` noun +- Add `events` attribute to `` verb + + +[2024-11-15] Version 9.3.7 +-------------------------- +**Library - Chore** +- [PR #819](https://github.com/twilio/twilio-python/pull/819): use older verison of aiohttp_retry. Thanks to [@sbansla](https://github.com/sbansla)! + +**Api** +- Added `ivr-virtual-agent-custom-voices` and `ivr-virtual-agent-genai` to `usage_record` API. +- Add open-api file tag to realtime_transcriptions + +**Taskrouter** +- Add `api-tag` property to workers reservation +- Add `api-tag` property to task reservation + + +[2024-10-25] Version 9.3.6 +-------------------------- +**Library - Chore** +- [PR #818](https://github.com/twilio/twilio-python/pull/818): removing unavailable references from init files. Thanks to [@tiwarishubham635](https://github.com/tiwarishubham635)! + + +[2024-10-24] Version 9.3.5 +-------------------------- +**Conversations** +- Expose ConversationWithParticipants resource that allows creating a conversation with participants + + +[2024-10-17] Version 9.3.4 +-------------------------- +**Api** +- Add response key `country` to fetch AvailablePhoneNumber resource by specific country. + +**Messaging** +- Make library and doc public for requestManagedCert Endpoint + + +[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** +- 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** +- [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** +- 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** +- [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** +- Deprecate account flag api.twilio-intelligence.v2 + + +[2024-06-27] Version 9.2.2 +-------------------------- +**Api** +- Add `transcription` resource + +**Flex** +- Changed mount name for flex_team v2 api + +**Intelligence** +- Add `X-Rate-Limit-Limit`, `X-Rate-Limit-Remaining`, and `X-Rate-Limit-Config` as Response Headers to Operator resources + +**Numbers** +- Added include_constraints query parameter to the Regulations API + +**Twiml** +- Add support for `` noun + + +[2024-06-21] Version 9.2.1 +-------------------------- +**Api** +- Add beta feature request managed cert + + +[2024-06-18] Version 9.2.0 +-------------------------- +**Library - Chore** +- [PR #796](https://github.com/twilio/twilio-python/pull/796): adding contentType in post and put. Thanks to [@tiwarishubham635](https://github.com/tiwarishubham635)! + +**Events** +- Add `status` and `documentation_url` to Event Types + +**Lookups** +- Removed unused `fraud` lookups in V1 only to facilitate rest proxy migration + +**Numbers** +- Add date_created field to the Get Port In Request API +- Rename the `status_last_time_updated_timestamp` field to `last_updated` in the Get Port In Phone Number API **(breaking change)** +- Add Rejection reason and rejection reason code to the Get Port In Phone Number API +- Remove the carrier information from the Portability API + +**Proxy** +- Change property `type` from enum to ienum + +**Trusthub** +- Add skipMessagingUseCase field in compliance_tollfree_inquiry. + + +[2024-06-06] Version 9.1.1 +-------------------------- +**Api** +- Mark MaxPrice as obsolete + +**Lookups** +- Update examples for `phone_number_quality_score` + +**Messaging** +- List tollfree verifications on parent account and all sub-accounts + + +[2024-05-24] Version 9.1.0 +-------------------------- +**Library - Chore** +- [PR #789](https://github.com/twilio/twilio-python/pull/789): [Snyk] Security upgrade aiohttp from 3.8.6 to 3.9.4. Thanks to [@twilio-product-security](https://github.com/twilio-product-security)! + +**Library - Fix** +- [PR #716](https://github.com/twilio/twilio-python/pull/716): Connection pool is full, discarding connection. Thanks to [@lightiverson](https://github.com/lightiverson)! + +**Api** +- Add ie1 as supported region for UserDefinedMessage and UserDefinedMessageSubscription. + +**Flex** +- Adding validated field to `plugin_versions` +- Corrected the data type for `runtime_domain`, `call_recording_webhook_url`, `crm_callback_url`, `crm_fallback_url`, `flex_url` in Flex Configuration +- Making `routing` optional in Create Interactions endpoint + +**Intelligence** +- Expose operator authoring apis to public visibility +- Deleted `language_code` parameter from updating service in v2 **(breaking change)** +- Add read_only_attached_operator_sids to v2 services + +**Numbers** +- Add API endpoint for GET Porting Webhook Configurations By Account SID +- Remove bulk portability api under version `/v1`. **(breaking change)** +- Removed porting_port_in_fetch.json files and move the content into porting_port_in.json files +- Add API endpoint to deleting Webhook Configurations +- Add Get Phone Number by Port in request SID and Phone Number SID api +- Add Create Porting webhook configuration API +- Added bundle_sid and losing_carrier_information fields to Create PortInRequest api to support Japan porting + +**Taskrouter** +- Add back `routing_target` property to tasks +- Add back `ignore_capacity` property to tasks +- Removing `routing_target` property to tasks due to revert +- Removing `ignore_capacity` property to tasks due to revert +- Add `routing_target` property to tasks +- Add `ignore_capacity` property to tasks + +**Trusthub** +- Add new field errors to bundle as part of public API response in customer_profile.json and trust_product.json **(breaking change)** +- Add themeSetId field in compliance_tollfree_inquiry. + +**Verify** +- Update `friendly_name` description on service docs + + +[2024-04-18] Version 9.0.5 +-------------------------- +**Library - Chore** +- [PR #742](https://github.com/twilio/twilio-python/pull/742): [Snyk] Fix for 3 vulnerabilities. Thanks to [@twilio-product-security](https://github.com/twilio-product-security)! + +**Flex** +- Add header `ui_version` to `web_channels` API + +**Messaging** +- Redeploy after failed pipeline + +**Numbers** +- Add Delete Port In request phone number api and Add Delete Port In request api + + +[2024-04-04] Version 9.0.4 +-------------------------- +**Api** +- Correct conference filtering by date_created and date_updated documentation, clarifying that times are UTC. + +**Flex** +- Remove optional parameter from `plugins` and it to `plugin_versions` + +**Lookups** +- Add new `pre_fill` package to the lookup response + +**Messaging** +- Cleanup api.messaging.next-gen from Messaging Services endpoints +- Readd Sending-Window after fixing test failure + +**Verify** +- Add `whatsapp.msg_service_sid` and `whatsapp.from` parameters to create, update, get and list of services endpoints + +**Voice** +- Correct conference filtering by date_created and date_updated documentation, clarifying that times are UTC. + +**Twiml** +- Add new `token_type` value `payment-method` for `Pay` verb + + +[2024-04-01] Version 9.0.3 +-------------------------- +**Api** +- Add property `queue_time` to conference participant resource +- Update RiskCheck documentation +- Correct call filtering by start and end time documentation, clarifying that times are UTC. + +**Flex** +- Adding optional parameter to `plugins` + +**Media** +- Remove API: MediaProcessor + +**Messaging** +- Remove Sending-Window due to test failure +- Add Sending-Window as a response property to Messaging Services, gated by a beta feature flag + +**Numbers** +- Correct valid_until_date field to be visible in Bundles resource +- Adding port_in_status field to the Port In resource and phone_number_status and sid fields to the Port In Phone Number resource + +**Oauth** +- Modified token endpoint response +- Added refresh_token and scope as optional parameter to token endpoint + +**Trusthub** +- Add update inquiry endpoint in compliance_registration. +- Add new field in themeSetId in compliance_registration. + +**Voice** +- Correct call filtering by start and end time documentation, clarifying that times are UTC. + +**Twiml** +- Add support for new Google voices (Q1 2024) for `Say` verb - gu-IN voices +- Add support for new Amazon Polly and Google voices (Q1 2024) for `Say` verb - Niamh (en-IE) and Sofie (da-DK) voices + + [2024-03-15] Version 9.0.2 -------------------------- **Oauth** diff --git a/README.md b/README.md index 50cc5509e1..e6382a5242 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,13 @@ After a brief delay, you will receive the text message on your phone. > **Warning** > It's okay to hardcode your credentials when testing locally, but you should use environment variables to keep them secret before committing any code or deploying to production. Check out [How to Set Environment Variables](https://www.twilio.com/blog/2017/01/how-to-set-environment-variables.html) for more information. +## OAuth Feature for Twilio APIs +We are introducing Client Credentials Flow-based OAuth 2.0 authentication. This feature is currently in beta and its implementation is subject to change. + +API examples [here](https://github.com/twilio/twilio-python/blob/main/examples/public_oauth.py) + +Organisation API examples [here](https://github.com/twilio/twilio-python/blob/main/examples/organization_api.py) + ## Use the helper library ### API Credentials @@ -128,7 +135,9 @@ client = Client() ### Specify Region and/or Edge -To take advantage of Twilio's [Global Infrastructure](https://www.twilio.com/docs/global-infrastructure), specify the target Region and/or Edge for the client: +To take advantage of Twilio's [Global Infrastructure](https://www.twilio.com/docs/global-infrastructure), specify the target Region and Edge for the client: + +> **Note:** When specifying a `region` parameter for a helper library client, be sure to also specify the `edge` parameter. For backward compatibility purposes, specifying a `region` without specifying an `edge` will result in requests being routed to US1. ```python from twilio.rest import Client @@ -184,6 +193,8 @@ The library automatically handles paging for you. Collections, such as `calls` a `list` eagerly fetches all records and returns them as a list, whereas `stream` returns an iterator and lazily retrieves pages of records as you iterate over the collection. You can also page manually using the `page` method. +`page_size` as a parameter is used to tell how many records should we get in every page and `limit` parameter is used to limit the max number of records we want to fetch. + #### Use the `list` method ```python @@ -197,6 +208,21 @@ for sms in client.messages.list(): print(sms.to) ``` +```python +client.messages.list(limit=20, page_size=20) +``` +This will make 1 call that will fetch 20 records from backend service. + +```python +client.messages.list(limit=20, page_size=10) +``` +This will make 2 calls that will fetch 10 records each from backend service. + +```python +client.messages.list(limit=20, page_size=100) +``` +This will make 1 call which will fetch 100 records but user will get only 20 records. + ### Asynchronous API Requests By default, the Twilio Client will make synchronous requests to the Twilio API. To allow for asynchronous, non-blocking requests, we've included an optional asynchronous HTTP client. When used with the Client and the accompanying `*_async` methods, requests made to the Twilio API will be performed asynchronously. diff --git a/docs/conf.py b/docs/conf.py index 405c2e99af..017b358093 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)} diff --git a/examples/organization_api.py b/examples/organization_api.py new file mode 100644 index 0000000000..0d653c12a4 --- /dev/null +++ b/examples/organization_api.py @@ -0,0 +1,32 @@ +import os + +from twilio.rest import Client +from twilio.credential.orgs_credential_provider import OrgsCredentialProvider + +ACCOUNT_SID = os.environ.get("TWILIO_ACCOUNT_SID") +API_KEY = os.environ.get("TWILIO_API_KEY") +API_SECRET = os.environ.get("TWILIO_API_SECRET") + +CLIENT_ID = os.environ.get("TWILIO_CLIENT_ID") +CLIENT_SECRET = os.environ.get("CLIENT_SECRET") +ORGS_SID = os.environ.get("ORGS_SID") + + +def example(): + """ + Some example usage of using organization resources + """ + client = Client( + account_sid=ACCOUNT_SID, + credential_provider=OrgsCredentialProvider(CLIENT_ID, CLIENT_SECRET), + ) + + accounts = client.preview_iam.organization( + organization_sid=ORGS_SID + ).accounts.stream() + for record in accounts: + print(record) + + +if __name__ == "__main__": + example() diff --git a/examples/public_oauth.py b/examples/public_oauth.py new file mode 100644 index 0000000000..41eb589c37 --- /dev/null +++ b/examples/public_oauth.py @@ -0,0 +1,31 @@ +import os + +from twilio.rest import Client +from twilio.credential.client_credential_provider import ClientCredentialProvider + +ACCOUNT_SID = os.environ.get("TWILIO_ACCOUNT_SID") +API_KEY = os.environ.get("TWILIO_API_KEY") +API_SECRET = os.environ.get("TWILIO_API_SECRET") +FROM_NUMBER = os.environ.get("TWILIO_FROM_NUMBER") +TO_NUMBER = os.environ.get("TWILIO_TO_NUMBER") + +CLIENT_ID = os.environ.get("TWILIO_CLIENT_ID") +CLIENT_SECRET = os.environ.get("CLIENT_SECRET") + + +def example(): + """ + Some example usage of message resources. + """ + client = Client( + account_sid=ACCOUNT_SID, + credential_provider=ClientCredentialProvider(CLIENT_ID, CLIENT_SECRET), + ) + + msg = client.messages.create( + to=self.to_number, from_=self.from_number, body="hello world" + ) + + +if __name__ == "__main__": + example() diff --git a/requirements.txt b/requirements.txt index f2b815e854..7bc9e41806 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,8 @@ pygments>=2.7.4 # not directly required, pinned by Snyk to avoid a vulnerability -requests>=2.0.0 +requests>=2.32.2 PyJWT>=2.0.0, <3.0.0 -aiohttp>=3.9.0 -aiohttp-retry>=2.8.3 +aiohttp>=3.10.2 +aiohttp-retry==2.8.3 +certifi>=2023.7.22 # not directly required, pinned by Snyk to avoid a vulnerability +urllib3>=2.2.2 # not directly required, pinned by Snyk to avoid a vulnerability +zipp>=3.19.1 # not directly required, pinned by Snyk to avoid a vulnerability diff --git a/setup.cfg b/setup.cfg index c8673986ed..4c18756789 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,7 +2,8 @@ universal = 1 [metadata] -description-file = README.md +long_description = file: README.md +license = MIT [flake8] exclude = ./twilio/rest,./twilio/twiml,./tests/integration diff --git a/setup.py b/setup.py index 625c210413..b0ea12a364 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ setup( name="twilio", - version="9.0.2", + version="9.6.0", description="Twilio API client and TwiML generator", author="Twilio", help_center="https://www.twilio.com/help/contact", diff --git a/tests/cluster/test_cluster.py b/tests/cluster/test_cluster.py index 556fa8da75..0c18428d15 100644 --- a/tests/cluster/test_cluster.py +++ b/tests/cluster/test_cluster.py @@ -12,6 +12,7 @@ def setUp(self): self.api_key = os.environ["TWILIO_API_KEY"] self.api_secret = os.environ["TWILIO_API_SECRET"] self.account_sid = os.environ["TWILIO_ACCOUNT_SID"] + self.assistant_id = os.environ["ASSISTANT_ID"] self.client = Client( username=self.api_key, password=self.api_secret, @@ -65,6 +66,11 @@ def test_list_available_numbers(self): self.assertIsNotNone(toll_free_numbers) self.assertEqual(len(toll_free_numbers), 2) + def test_fetch_assistant(self): + assistant = self.client.assistants.v1.assistants(self.assistant_id).fetch() + self.assertIsNotNone(assistant) + self.assertEqual(assistant.account_sid, self.account_sid) + def test_calling_twiml_string(self): call = self.client.calls.create( to=self.to_number, from_=self.from_number, twiml=str(self.voice_twiml) diff --git a/tests/unit/http/test_async_http_client.py b/tests/unit/http/test_async_http_client.py index df43606843..23df35dc02 100644 --- a/tests/unit/http/test_async_http_client.py +++ b/tests/unit/http/test_async_http_client.py @@ -10,10 +10,11 @@ class MockResponse(object): A mock of the aiohttp.ClientResponse class """ - def __init__(self, text, status): + def __init__(self, text, status, method="GET"): self._text = text self.status = status self.headers = {} + self.method = method async def text(self): return self._text diff --git a/twilio/__init__.py b/twilio/__init__.py index 698515090a..128c99df6b 100644 --- a/twilio/__init__.py +++ b/twilio/__init__.py @@ -1,2 +1,2 @@ -__version_info__ = ("9", "0", "2") +__version_info__ = ("9", "6", "0") __version__ = ".".join(__version_info__) diff --git a/twilio/auth_strategy/__init__.py b/twilio/auth_strategy/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/twilio/auth_strategy/auth_strategy.py b/twilio/auth_strategy/auth_strategy.py new file mode 100644 index 0000000000..223cbff08f --- /dev/null +++ b/twilio/auth_strategy/auth_strategy.py @@ -0,0 +1,19 @@ +from twilio.auth_strategy.auth_type import AuthType +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 + + @abstractmethod + def get_auth_string(self) -> str: + """Return the authentication string.""" + + @abstractmethod + def requires_authentication(self) -> bool: + """Return True if authentication is required, else False.""" diff --git a/twilio/auth_strategy/auth_type.py b/twilio/auth_strategy/auth_type.py new file mode 100644 index 0000000000..61886f925d --- /dev/null +++ b/twilio/auth_strategy/auth_type.py @@ -0,0 +1,12 @@ +from enum import Enum + + +class AuthType(Enum): + ORGS_TOKEN = "orgs_stoken" + NO_AUTH = "noauth" + BASIC = "basic" + API_KEY = "api_key" + CLIENT_CREDENTIALS = "client_credentials" + + def __str__(self): + return self.value diff --git a/twilio/auth_strategy/no_auth_strategy.py b/twilio/auth_strategy/no_auth_strategy.py new file mode 100644 index 0000000000..a5bfd6d27f --- /dev/null +++ b/twilio/auth_strategy/no_auth_strategy.py @@ -0,0 +1,13 @@ +from auth_type import AuthType +from twilio.auth_strategy.auth_strategy import AuthStrategy + + +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 diff --git a/twilio/auth_strategy/token_auth_strategy.py b/twilio/auth_strategy/token_auth_strategy.py new file mode 100644 index 0000000000..33a8d385cb --- /dev/null +++ b/twilio/auth_strategy/token_auth_strategy.py @@ -0,0 +1,55 @@ +import jwt +import threading +import logging +from datetime import datetime, timezone + +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.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: + self.fetch_token() + 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.logger.info("New token fetched for accessing organization API") + self.token = self.token_manager.fetch_access_token() + + def is_token_expired(self, token): + 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 by using time-zone + return datetime.fromtimestamp(exp, tz=timezone.utc) < datetime.now( + timezone.utc + ) + + except jwt.DecodeError: + return True # Token is invalid + except Exception as e: + print(f"An error occurred: {e}") + return True diff --git a/twilio/base/client_base.py b/twilio/base/client_base.py index c9e0f9c487..b16f85bf5b 100644 --- a/twilio/base/client_base.py +++ b/twilio/base/client_base.py @@ -4,10 +4,10 @@ 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.credential.credential_provider import CredentialProvider class ClientBase(object): @@ -23,6 +23,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 +36,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 +51,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 """ @@ -85,15 +87,27 @@ def request( :returns: Response from the Twilio API """ - auth = self.get_auth(auth) headers = self.get_headers(method, headers) - uri = self.get_hostname(uri) + if self.credential_provider: + + auth_strategy = self.credential_provider.to_auth_strategy() + headers["Authorization"] = auth_strategy.get_auth_string() + elif self.username is not None and self.password is not None: + auth = self.get_auth(auth) + else: + auth = None + + if method == "DELETE": + del headers["Accept"] + + uri = self.get_hostname(uri) + filtered_data = self.copy_non_none_values(data) return self.http_client.request( method, uri, params=params, - data=data, + data=filtered_data, headers=headers, auth=auth, timeout=timeout, @@ -132,21 +146,44 @@ async def request_async( "http_client must be asynchronous to support async API requests" ) - auth = self.get_auth(auth) headers = self.get_headers(method, headers) - uri = self.get_hostname(uri) + if method == "DELETE": + del headers["Accept"] + + if self.credential_provider: + auth_strategy = self.credential_provider.to_auth_strategy() + headers["Authorization"] = auth_strategy.get_auth_string() + 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) + filtered_data = self.copy_non_none_values(data) return await self.http_client.request( method, uri, params=params, - data=data, + data=filtered_data, headers=headers, auth=auth, timeout=timeout, allow_redirects=allow_redirects, ) + def copy_non_none_values(self, data): + if isinstance(data, dict): + return { + k: self.copy_non_none_values(v) + for k, v in data.items() + if v is not None + } + elif isinstance(data, list): + return [ + self.copy_non_none_values(item) for item in data if item is not None + ] + return data + def get_auth(self, auth: Optional[Tuple[str, str]]) -> Tuple[str, str]: """ Get the request authentication object @@ -184,7 +221,7 @@ def get_headers( # Types, encodings, etc. headers["Accept-Charset"] = "utf-8" - if method == "POST" and "Content-Type" not in headers: + if (method == "POST" or method == "PUT") and ("Content-Type" not in headers): headers["Content-Type"] = "application/x-www-form-urlencoded" if "Accept" not in headers: headers["Accept"] = "application/json" diff --git a/twilio/base/page.py b/twilio/base/page.py index 2238528da9..b5b2da7b26 100644 --- a/twilio/base/page.py +++ b/twilio/base/page.py @@ -77,6 +77,8 @@ def load_page(self, payload: Dict[str, Any]): key = keys - self.META_KEYS if len(key) == 1: return payload[key.pop()] + if "Resources" in payload: + return payload["Resources"] raise TwilioException("Page Records can not be deserialized") diff --git a/twilio/base/version.py b/twilio/base/version.py index 64cc601faa..ed7e86f499 100644 --- a/twilio/base/version.py +++ b/twilio/base/version.py @@ -164,7 +164,6 @@ async def fetch_async( timeout=timeout, allow_redirects=allow_redirects, ) - return self._parse_fetch(method, uri, response) def _parse_update(self, method: str, uri: str, response: Response) -> Any: @@ -461,7 +460,6 @@ def create( timeout=timeout, allow_redirects=allow_redirects, ) - return self._parse_create(method, uri, response) async def create_async( @@ -488,5 +486,4 @@ async def create_async( timeout=timeout, allow_redirects=allow_redirects, ) - return self._parse_create(method, uri, response) diff --git a/twilio/credential/__init__.py b/twilio/credential/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/twilio/credential/client_credential_provider.py b/twilio/credential/client_credential_provider.py new file mode 100644 index 0000000000..656d446395 --- /dev/null +++ b/twilio/credential/client_credential_provider.py @@ -0,0 +1,28 @@ +from twilio.http.client_token_manager import ClientTokenManager +from twilio.base.exceptions import TwilioException +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 ClientCredentialProvider(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("Client id and Client secret are mandatory") + + self.grant_type = "client_credentials" + 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 = ClientTokenManager( + self.grant_type, self.client_id, self.client_secret + ) + if self.auth_strategy is None: + self.auth_strategy = TokenAuthStrategy(self.token_manager) + return self.auth_strategy diff --git a/twilio/credential/credential_provider.py b/twilio/credential/credential_provider.py new file mode 100644 index 0000000000..72aafeed47 --- /dev/null +++ b/twilio/credential/credential_provider.py @@ -0,0 +1,13 @@ +from twilio.auth_strategy.auth_type 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/orgs_credential_provider.py b/twilio/credential/orgs_credential_provider.py new file mode 100644 index 0000000000..e623f52322 --- /dev/null +++ b/twilio/credential/orgs_credential_provider.py @@ -0,0 +1,28 @@ +from twilio.http.orgs_token_manager import OrgTokenManager +from twilio.base.exceptions import TwilioException +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): + 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("Client id and Client secret are mandatory") + + self.grant_type = "client_credentials" + 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 + ) + if self.auth_strategy is None: + self.auth_strategy = TokenAuthStrategy(self.token_manager) + return self.auth_strategy diff --git a/twilio/http/client_token_manager.py b/twilio/http/client_token_manager.py new file mode 100644 index 0000000000..d65acb2ba2 --- /dev/null +++ b/twilio/http/client_token_manager.py @@ -0,0 +1,41 @@ +from twilio.http.token_manager import TokenManager +from twilio.rest import Client + + +class ClientTokenManager(TokenManager): + """ + Client Token Manager + """ + + def __init__( + self, + grant_type: str, + client_id: str, + client_secret: str, + code: str = None, + redirect_uri: str = None, + audience: str = None, + refreshToken: str = None, + scope: str = None, + ): + self.grant_type = grant_type + self.client_id = client_id + self.client_secret = client_secret + self.code = code + self.redirect_uri = redirect_uri + self.audience = audience + self.refreshToken = refreshToken + self.scope = scope + self.client = Client() + + def fetch_access_token(self): + token_instance = self.client.preview_iam.v1.token.create( + grant_type=self.grant_type, + client_id=self.client_id, + client_secret=self.client_secret, + code=self.code, + redirect_uri=self.redirect_uri, + audience=self.audience, + scope=self.scope, + ) + return token_instance.access_token diff --git a/twilio/http/http_client.py b/twilio/http/http_client.py index 7a1715ad49..2f2d363535 100644 --- a/twilio/http/http_client.py +++ b/twilio/http/http_client.py @@ -1,3 +1,4 @@ +import os import logging from typing import Dict, Optional, Tuple @@ -39,7 +40,10 @@ def __init__( self.session = Session() if pool_connections else None if self.session and max_retries is not None: self.session.mount("https://", HTTPAdapter(max_retries=max_retries)) - + elif self.session is not None: + self.session.mount( + "https://", HTTPAdapter(pool_maxsize=min(32, os.cpu_count() + 4)) + ) self.request_hooks = request_hooks or hooks.default_hooks() self.proxy = proxy if proxy else {} @@ -84,10 +88,11 @@ def request( } if headers and headers.get("Content-Type") == "application/json": kwargs["json"] = data + elif headers and headers.get("Content-Type") == "application/scim+json": + kwargs["json"] = data else: kwargs["data"] = data self.log_request(kwargs) - self._test_only_last_response = None session = self.session or Session() request = Request(**kwargs) @@ -98,12 +103,11 @@ def request( settings = session.merge_environment_settings( prepped_request.url, self.proxy, None, None, None ) - response = session.send( prepped_request, allow_redirects=allow_redirects, timeout=timeout, - **settings + **settings, ) self.log_response(response.status_code, response) diff --git a/twilio/http/orgs_token_manager.py b/twilio/http/orgs_token_manager.py new file mode 100644 index 0000000000..767ed270af --- /dev/null +++ b/twilio/http/orgs_token_manager.py @@ -0,0 +1,41 @@ +from twilio.http.token_manager import TokenManager +from twilio.rest import Client + + +class OrgTokenManager(TokenManager): + """ + Orgs Token Manager + """ + + def __init__( + self, + grant_type: str, + client_id: str, + client_secret: str, + code: str = None, + redirect_uri: str = None, + audience: str = None, + refreshToken: str = None, + scope: str = None, + ): + self.grant_type = grant_type + self.client_id = client_id + self.client_secret = client_secret + self.code = code + self.redirect_uri = redirect_uri + self.audience = audience + self.refreshToken = refreshToken + self.scope = scope + self.client = Client() + + def fetch_access_token(self): + token_instance = self.client.preview_iam.v1.token.create( + grant_type=self.grant_type, + client_id=self.client_id, + client_secret=self.client_secret, + code=self.code, + redirect_uri=self.redirect_uri, + audience=self.audience, + scope=self.scope, + ) + return token_instance.access_token diff --git a/twilio/http/token_manager.py b/twilio/http/token_manager.py new file mode 100644 index 0000000000..28cc731019 --- /dev/null +++ b/twilio/http/token_manager.py @@ -0,0 +1,7 @@ +from twilio.base.version import Version + + +class TokenManager: + + def fetch_access_token(self, version: Version): + pass diff --git a/twilio/rest/__init__.py b/twilio/rest/__init__.py index 254d920786..dc7741180b 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 @@ -23,12 +24,14 @@ 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.iam import Iam from twilio.rest.insights import Insights from twilio.rest.intelligence import Intelligence from twilio.rest.ip_messaging import IpMessaging + from twilio.rest.knowledge import Knowledge from twilio.rest.lookups import Lookups - from twilio.rest.media import Media - from twilio.rest.preview_messaging import PreviewMessaging + from twilio.rest.marketplace import Marketplace from twilio.rest.messaging import Messaging from twilio.rest.microvisor import Microvisor from twilio.rest.monitor import Monitor @@ -95,6 +98,7 @@ def __init__( environment=None, edge=None, user_agent_extensions=None, + credential_provider=None, ): """ Initializes the Twilio Client @@ -120,11 +124,13 @@ def __init__( environment, edge, user_agent_extensions, + credential_provider, ) # 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 @@ -132,12 +138,14 @@ 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._iam: Optional["Iam"] = None self._insights: Optional["Insights"] = None self._intelligence: Optional["Intelligence"] = None self._ip_messaging: Optional["IpMessaging"] = None + self._knowledge: Optional["Knowledge"] = None self._lookups: Optional["Lookups"] = None - self._media: Optional["Media"] = None - self._preview_messaging: Optional["PreviewMessaging"] = None + self._marketplace: Optional["Marketplace"] = None self._messaging: Optional["Messaging"] = None self._microvisor: Optional["Microvisor"] = None self._monitor: Optional["Monitor"] = None @@ -186,6 +194,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": """ @@ -277,6 +298,32 @@ 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 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": """ @@ -316,6 +363,19 @@ def ip_messaging(self) -> "IpMessaging": self._ip_messaging = IpMessaging(self) return self._ip_messaging + @property + def knowledge(self) -> "Knowledge": + """ + Access the Knowledge Twilio Domain + + :returns: Knowledge Twilio Domain + """ + if self._knowledge is None: + from twilio.rest.knowledge import Knowledge + + self._knowledge = Knowledge(self) + return self._knowledge + @property def lookups(self) -> "Lookups": """ @@ -330,30 +390,17 @@ def lookups(self) -> "Lookups": return self._lookups @property - def media(self) -> "Media": - """ - Access the Media Twilio Domain - - :returns: Media Twilio Domain - """ - if self._media is None: - from twilio.rest.media import Media - - self._media = Media(self) - return self._media - - @property - def preview_messaging(self) -> "PreviewMessaging": + def marketplace(self) -> "Marketplace": """ - Access the PreviewMessaging Twilio Domain + Access the Marketplace Twilio Domain - :returns: PreviewMessaging Twilio Domain + :returns: Marketplace Twilio Domain """ - if self._preview_messaging is None: - from twilio.rest.preview_messaging import PreviewMessaging + if self._marketplace is None: + from twilio.rest.marketplace import Marketplace - self._preview_messaging = PreviewMessaging(self) - return self._preview_messaging + self._marketplace = Marketplace(self) + return self._marketplace @property def messaging(self) -> "Messaging": diff --git a/twilio/rest/accounts/v1/__init__.py b/twilio/rest/accounts/v1/__init__.py index 142d5c7a96..6f5012d0fa 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/auth_token_promotion.py b/twilio/rest/accounts/v1/auth_token_promotion.py index 7ab6c3f39d..8580538a9b 100644 --- a/twilio/rest/accounts/v1/auth_token_promotion.py +++ b/twilio/rest/accounts/v1/auth_token_promotion.py @@ -106,12 +106,14 @@ def update(self) -> AuthTokenPromotionInstance: :returns: The updated AuthTokenPromotionInstance """ + data = values.of({}) + headers = values.of({}) + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AuthTokenPromotionInstance(self._version, payload) @@ -123,12 +125,14 @@ async def update_async(self) -> AuthTokenPromotionInstance: :returns: The updated AuthTokenPromotionInstance """ + data = values.of({}) + headers = values.of({}) + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AuthTokenPromotionInstance(self._version, payload) diff --git a/twilio/rest/accounts/v1/bulk_consents.py b/twilio/rest/accounts/v1/bulk_consents.py new file mode 100644 index 0000000000..3e4564386b --- /dev/null +++ b/twilio/rest/accounts/v1/bulk_consents.py @@ -0,0 +1,114 @@ +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"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = self._version.create( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return 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"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return 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 0000000000..17b6da33f3 --- /dev/null +++ b/twilio/rest/accounts/v1/bulk_contacts.py @@ -0,0 +1,114 @@ +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"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = self._version.create( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return 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"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return BulkContactsInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/accounts/v1/credential/aws.py b/twilio/rest/accounts/v1/credential/aws.py index ab75620920..ba5335accd 100644 --- a/twilio/rest/accounts/v1/credential/aws.py +++ b/twilio/rest/accounts/v1/credential/aws.py @@ -164,10 +164,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -176,9 +176,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> AwsInstance: @@ -189,10 +191,11 @@ def fetch(self) -> AwsInstance: :returns: The fetched AwsInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return AwsInstance( self._version, @@ -208,9 +211,12 @@ async def fetch_async(self) -> AwsInstance: :returns: The fetched AwsInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return AwsInstance( @@ -227,16 +233,20 @@ def update(self, friendly_name: Union[str, object] = values.unset) -> AwsInstanc :returns: The updated AwsInstance """ + data = values.of( { "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AwsInstance(self._version, payload, sid=self._solution["sid"]) @@ -251,16 +261,20 @@ async def update_async( :returns: The updated AwsInstance """ + data = values.of( { "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AwsInstance(self._version, payload, sid=self._solution["sid"]) @@ -330,11 +344,14 @@ def create( "AccountSid": account_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AwsInstance(self._version, payload) @@ -362,11 +379,14 @@ async def create_async( "AccountSid": account_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AwsInstance(self._version, payload) @@ -498,7 +518,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return AwsPage(self._version, response) async def page_async( @@ -525,8 +551,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return AwsPage(self._version, response) diff --git a/twilio/rest/accounts/v1/credential/public_key.py b/twilio/rest/accounts/v1/credential/public_key.py index 09018d1d26..c2b4f9bbee 100644 --- a/twilio/rest/accounts/v1/credential/public_key.py +++ b/twilio/rest/accounts/v1/credential/public_key.py @@ -166,10 +166,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -178,9 +178,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> PublicKeyInstance: @@ -191,10 +193,11 @@ def fetch(self) -> PublicKeyInstance: :returns: The fetched PublicKeyInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return PublicKeyInstance( self._version, @@ -210,9 +213,12 @@ async def fetch_async(self) -> PublicKeyInstance: :returns: The fetched PublicKeyInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return PublicKeyInstance( @@ -231,16 +237,20 @@ def update( :returns: The updated PublicKeyInstance """ + data = values.of( { "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return PublicKeyInstance(self._version, payload, sid=self._solution["sid"]) @@ -255,16 +265,20 @@ async def update_async( :returns: The updated PublicKeyInstance """ + data = values.of( { "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return PublicKeyInstance(self._version, payload, sid=self._solution["sid"]) @@ -334,11 +348,14 @@ def create( "AccountSid": account_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return PublicKeyInstance(self._version, payload) @@ -366,11 +383,14 @@ async def create_async( "AccountSid": account_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return PublicKeyInstance(self._version, payload) @@ -502,7 +522,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return PublicKeyPage(self._version, response) async def page_async( @@ -529,8 +555,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return PublicKeyPage(self._version, response) diff --git a/twilio/rest/accounts/v1/safelist.py b/twilio/rest/accounts/v1/safelist.py index ce5672caed..be8fe416af 100644 --- a/twilio/rest/accounts/v1/safelist.py +++ b/twilio/rest/accounts/v1/safelist.py @@ -23,7 +23,7 @@ class SafelistInstance(InstanceResource): """ :ivar sid: The unique string that we created to identify the SafeList resource. - :ivar phone_number: The phone number in SafeList. + :ivar phone_number: The phone number or phone number 1k prefix in SafeList. """ def __init__(self, version: Version, payload: Dict[str, Any]): @@ -59,7 +59,7 @@ def create(self, phone_number: str) -> SafelistInstance: """ Create the SafelistInstance - :param phone_number: The phone number to be added in SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). + :param phone_number: The phone number or phone number 1k prefix to be added in SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). :returns: The created SafelistInstance """ @@ -69,11 +69,14 @@ def create(self, phone_number: str) -> SafelistInstance: "PhoneNumber": phone_number, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SafelistInstance(self._version, payload) @@ -82,7 +85,7 @@ async def create_async(self, phone_number: str) -> SafelistInstance: """ Asynchronously create the SafelistInstance - :param phone_number: The phone number to be added in SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). + :param phone_number: The phone number or phone number 1k prefix to be added in SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). :returns: The created SafelistInstance """ @@ -92,11 +95,14 @@ async def create_async(self, phone_number: str) -> SafelistInstance: "PhoneNumber": phone_number, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SafelistInstance(self._version, payload) @@ -105,16 +111,19 @@ def delete(self, phone_number: Union[str, object] = values.unset) -> bool: """ Asynchronously delete the SafelistInstance - :param phone_number: The phone number to be removed from SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). + :param phone_number: The phone number or phone number 1k prefix to be removed from SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). :returns: True if delete succeeds, False otherwise """ + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) params = values.of( { "PhoneNumber": phone_number, } ) - return self._version.delete(method="DELETE", uri=self._uri, params=params) + return self._version.delete( + method="DELETE", uri=self._uri, headers=headers, params=params + ) async def delete_async( self, phone_number: Union[str, object] = values.unset @@ -122,9 +131,10 @@ async def delete_async( """ Asynchronously delete the SafelistInstance - :param phone_number: The phone number to be removed from SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). + :param phone_number: The phone number or phone number 1k prefix to be removed from SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). :returns: True if delete succeeds, False otherwise """ + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) params = values.of( { @@ -132,7 +142,7 @@ async def delete_async( } ) return await self._version.delete_async( - method="DELETE", uri=self._uri, params=params + method="DELETE", uri=self._uri, headers=headers, params=params ) def fetch( @@ -141,9 +151,12 @@ def fetch( """ Asynchronously fetch the SafelistInstance - :param phone_number: The phone number to be fetched from SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). + :param phone_number: The phone number or phone number 1k prefix to be fetched from SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). :returns: The fetched SafelistInstance """ + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" params = values.of( { @@ -151,7 +164,9 @@ def fetch( } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=params) + payload = self._version.fetch( + method="GET", uri=self._uri, headers=headers, params=params + ) return SafelistInstance(self._version, payload) @@ -161,9 +176,12 @@ async def fetch_async( """ Asynchronously fetch the SafelistInstance - :param phone_number: The phone number to be fetched from SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). + :param phone_number: The phone number or phone number 1k prefix to be fetched from SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). :returns: The fetched SafelistInstance """ + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" params = values.of( { @@ -172,7 +190,7 @@ async def fetch_async( ) payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=params + method="GET", uri=self._uri, headers=headers, params=params ) return SafelistInstance(self._version, payload) diff --git a/twilio/rest/accounts/v1/secondary_auth_token.py b/twilio/rest/accounts/v1/secondary_auth_token.py index 3735dd876a..f5e2b5c1a3 100644 --- a/twilio/rest/accounts/v1/secondary_auth_token.py +++ b/twilio/rest/accounts/v1/secondary_auth_token.py @@ -152,10 +152,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -164,9 +164,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def __repr__(self) -> str: diff --git a/twilio/rest/api/v2010/account/__init__.py b/twilio/rest/api/v2010/account/__init__.py index adf2458f2a..7c7e2c1069 100644 --- a/twilio/rest/api/v2010/account/__init__.py +++ b/twilio/rest/api/v2010/account/__init__.py @@ -398,10 +398,11 @@ def fetch(self) -> AccountInstance: :returns: The fetched AccountInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return AccountInstance( self._version, @@ -417,9 +418,12 @@ async def fetch_async(self) -> AccountInstance: :returns: The fetched AccountInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return AccountInstance( @@ -441,17 +445,21 @@ def update( :returns: The updated AccountInstance """ + data = values.of( { "FriendlyName": friendly_name, "Status": status, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AccountInstance(self._version, payload, sid=self._solution["sid"]) @@ -469,17 +477,21 @@ async def update_async( :returns: The updated AccountInstance """ + data = values.of( { "FriendlyName": friendly_name, "Status": status, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AccountInstance(self._version, payload, sid=self._solution["sid"]) @@ -830,11 +842,14 @@ def create( "FriendlyName": friendly_name, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AccountInstance(self._version, payload) @@ -855,11 +870,14 @@ async def create_async( "FriendlyName": friendly_name, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AccountInstance(self._version, payload) @@ -1021,7 +1039,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return AccountPage(self._version, response) async def page_async( @@ -1054,8 +1078,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return AccountPage(self._version, response) diff --git a/twilio/rest/api/v2010/account/address/__init__.py b/twilio/rest/api/v2010/account/address/__init__.py index fd77747102..77fc702ccc 100644 --- a/twilio/rest/api/v2010/account/address/__init__.py +++ b/twilio/rest/api/v2010/account/address/__init__.py @@ -148,7 +148,7 @@ def update( """ Update the AddressInstance - :param friendly_name: A descriptive string that you create to describe the address. It can be up to 64 characters long. + :param friendly_name: A descriptive string that you create to describe the new address. It can be up to 64 characters long for Regulatory Compliance addresses and 32 characters long for Emergency addresses. :param customer_name: The name to associate with the address. :param street: The number and street address of the address. :param city: The city of the address. @@ -187,7 +187,7 @@ async def update_async( """ Asynchronous coroutine to update the AddressInstance - :param friendly_name: A descriptive string that you create to describe the address. It can be up to 64 characters long. + :param friendly_name: A descriptive string that you create to describe the new address. It can be up to 64 characters long for Regulatory Compliance addresses and 32 characters long for Emergency addresses. :param customer_name: The name to associate with the address. :param street: The number and street address of the address. :param city: The city of the address. @@ -258,10 +258,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -270,9 +270,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> AddressInstance: @@ -283,10 +285,11 @@ def fetch(self) -> AddressInstance: :returns: The fetched AddressInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return AddressInstance( self._version, @@ -303,9 +306,12 @@ async def fetch_async(self) -> AddressInstance: :returns: The fetched AddressInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return AddressInstance( @@ -330,7 +336,7 @@ def update( """ Update the AddressInstance - :param friendly_name: A descriptive string that you create to describe the address. It can be up to 64 characters long. + :param friendly_name: A descriptive string that you create to describe the new address. It can be up to 64 characters long for Regulatory Compliance addresses and 32 characters long for Emergency addresses. :param customer_name: The name to associate with the address. :param street: The number and street address of the address. :param city: The city of the address. @@ -342,6 +348,7 @@ def update( :returns: The updated AddressInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -355,11 +362,14 @@ def update( "StreetSecondary": street_secondary, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AddressInstance( @@ -384,7 +394,7 @@ async def update_async( """ Asynchronous coroutine to update the AddressInstance - :param friendly_name: A descriptive string that you create to describe the address. It can be up to 64 characters long. + :param friendly_name: A descriptive string that you create to describe the new address. It can be up to 64 characters long for Regulatory Compliance addresses and 32 characters long for Emergency addresses. :param customer_name: The name to associate with the address. :param street: The number and street address of the address. :param city: The city of the address. @@ -396,6 +406,7 @@ async def update_async( :returns: The updated AddressInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -409,11 +420,14 @@ async def update_async( "StreetSecondary": street_secondary, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AddressInstance( @@ -529,11 +543,14 @@ def create( "StreetSecondary": street_secondary, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AddressInstance( @@ -584,11 +601,14 @@ async def create_async( "StreetSecondary": street_secondary, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AddressInstance( @@ -599,6 +619,7 @@ def stream( self, customer_name: Union[str, object] = values.unset, friendly_name: Union[str, object] = values.unset, + emergency_enabled: Union[bool, object] = values.unset, iso_country: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, @@ -611,6 +632,7 @@ def stream( :param str customer_name: The `customer_name` of the Address resources to read. :param str friendly_name: The string that identifies the Address resources to read. + :param bool emergency_enabled: Whether the address can be associated to a number for emergency calling. :param str iso_country: The ISO country code of the Address resources to read. :param limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit @@ -625,6 +647,7 @@ def stream( page = self.page( customer_name=customer_name, friendly_name=friendly_name, + emergency_enabled=emergency_enabled, iso_country=iso_country, page_size=limits["page_size"], ) @@ -635,6 +658,7 @@ async def stream_async( self, customer_name: Union[str, object] = values.unset, friendly_name: Union[str, object] = values.unset, + emergency_enabled: Union[bool, object] = values.unset, iso_country: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, @@ -647,6 +671,7 @@ async def stream_async( :param str customer_name: The `customer_name` of the Address resources to read. :param str friendly_name: The string that identifies the Address resources to read. + :param bool emergency_enabled: Whether the address can be associated to a number for emergency calling. :param str iso_country: The ISO country code of the Address resources to read. :param limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit @@ -661,6 +686,7 @@ async def stream_async( page = await self.page_async( customer_name=customer_name, friendly_name=friendly_name, + emergency_enabled=emergency_enabled, iso_country=iso_country, page_size=limits["page_size"], ) @@ -671,6 +697,7 @@ def list( self, customer_name: Union[str, object] = values.unset, friendly_name: Union[str, object] = values.unset, + emergency_enabled: Union[bool, object] = values.unset, iso_country: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, @@ -682,6 +709,7 @@ def list( :param str customer_name: The `customer_name` of the Address resources to read. :param str friendly_name: The string that identifies the Address resources to read. + :param bool emergency_enabled: Whether the address can be associated to a number for emergency calling. :param str iso_country: The ISO country code of the Address resources to read. :param limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit @@ -696,6 +724,7 @@ def list( self.stream( customer_name=customer_name, friendly_name=friendly_name, + emergency_enabled=emergency_enabled, iso_country=iso_country, limit=limit, page_size=page_size, @@ -706,6 +735,7 @@ async def list_async( self, customer_name: Union[str, object] = values.unset, friendly_name: Union[str, object] = values.unset, + emergency_enabled: Union[bool, object] = values.unset, iso_country: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, @@ -717,6 +747,7 @@ async def list_async( :param str customer_name: The `customer_name` of the Address resources to read. :param str friendly_name: The string that identifies the Address resources to read. + :param bool emergency_enabled: Whether the address can be associated to a number for emergency calling. :param str iso_country: The ISO country code of the Address resources to read. :param limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit @@ -732,6 +763,7 @@ async def list_async( async for record in await self.stream_async( customer_name=customer_name, friendly_name=friendly_name, + emergency_enabled=emergency_enabled, iso_country=iso_country, limit=limit, page_size=page_size, @@ -742,6 +774,7 @@ def page( self, customer_name: Union[str, object] = values.unset, friendly_name: Union[str, object] = values.unset, + emergency_enabled: Union[bool, object] = values.unset, iso_country: Union[str, object] = values.unset, page_token: Union[str, object] = values.unset, page_number: Union[int, object] = values.unset, @@ -753,6 +786,7 @@ def page( :param customer_name: The `customer_name` of the Address resources to read. :param friendly_name: The string that identifies the Address resources to read. + :param emergency_enabled: Whether the address can be associated to a number for emergency calling. :param iso_country: The ISO country code of the Address resources to read. :param page_token: PageToken provided by the API :param page_number: Page Number, this value is simply for client state @@ -764,6 +798,7 @@ def page( { "CustomerName": customer_name, "FriendlyName": friendly_name, + "EmergencyEnabled": serialize.boolean_to_string(emergency_enabled), "IsoCountry": iso_country, "PageToken": page_token, "Page": page_number, @@ -771,13 +806,20 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return AddressPage(self._version, response, self._solution) async def page_async( self, customer_name: Union[str, object] = values.unset, friendly_name: Union[str, object] = values.unset, + emergency_enabled: Union[bool, object] = values.unset, iso_country: Union[str, object] = values.unset, page_token: Union[str, object] = values.unset, page_number: Union[int, object] = values.unset, @@ -789,6 +831,7 @@ async def page_async( :param customer_name: The `customer_name` of the Address resources to read. :param friendly_name: The string that identifies the Address resources to read. + :param emergency_enabled: Whether the address can be associated to a number for emergency calling. :param iso_country: The ISO country code of the Address resources to read. :param page_token: PageToken provided by the API :param page_number: Page Number, this value is simply for client state @@ -800,6 +843,7 @@ async def page_async( { "CustomerName": customer_name, "FriendlyName": friendly_name, + "EmergencyEnabled": serialize.boolean_to_string(emergency_enabled), "IsoCountry": iso_country, "PageToken": page_token, "Page": page_number, @@ -807,8 +851,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return AddressPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/address/dependent_phone_number.py b/twilio/rest/api/v2010/account/address/dependent_phone_number.py index 738f9baffd..504e69bc92 100644 --- a/twilio/rest/api/v2010/account/address/dependent_phone_number.py +++ b/twilio/rest/api/v2010/account/address/dependent_phone_number.py @@ -299,7 +299,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return DependentPhoneNumberPage(self._version, response, self._solution) async def page_async( @@ -326,8 +332,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return DependentPhoneNumberPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/application.py b/twilio/rest/api/v2010/account/application.py index a3b11f0282..555ab72b4a 100644 --- a/twilio/rest/api/v2010/account/application.py +++ b/twilio/rest/api/v2010/account/application.py @@ -306,10 +306,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -318,9 +318,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> ApplicationInstance: @@ -331,10 +333,11 @@ def fetch(self) -> ApplicationInstance: :returns: The fetched ApplicationInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ApplicationInstance( self._version, @@ -351,9 +354,12 @@ async def fetch_async(self) -> ApplicationInstance: :returns: The fetched ApplicationInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ApplicationInstance( @@ -404,6 +410,7 @@ def update( :returns: The updated ApplicationInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -428,11 +435,14 @@ def update( ), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ApplicationInstance( @@ -483,6 +493,7 @@ async def update_async( :returns: The updated ApplicationInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -507,11 +518,14 @@ async def update_async( ), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ApplicationInstance( @@ -636,11 +650,14 @@ def create( ), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ApplicationInstance( @@ -713,11 +730,14 @@ async def create_async( ), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ApplicationInstance( @@ -866,7 +886,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ApplicationPage(self._version, response, self._solution) async def page_async( @@ -896,8 +922,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ApplicationPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/authorized_connect_app.py b/twilio/rest/api/v2010/account/authorized_connect_app.py index 9359545cdb..cceb694c10 100644 --- a/twilio/rest/api/v2010/account/authorized_connect_app.py +++ b/twilio/rest/api/v2010/account/authorized_connect_app.py @@ -145,10 +145,11 @@ def fetch(self) -> AuthorizedConnectAppInstance: :returns: The fetched AuthorizedConnectAppInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return AuthorizedConnectAppInstance( self._version, @@ -165,9 +166,12 @@ async def fetch_async(self) -> AuthorizedConnectAppInstance: :returns: The fetched AuthorizedConnectAppInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return AuthorizedConnectAppInstance( @@ -355,7 +359,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return AuthorizedConnectAppPage(self._version, response, self._solution) async def page_async( @@ -382,8 +392,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return AuthorizedConnectAppPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/available_phone_number_country/__init__.py b/twilio/rest/api/v2010/account/available_phone_number_country/__init__.py index 14fcfc28df..fc2a6f0600 100644 --- a/twilio/rest/api/v2010/account/available_phone_number_country/__init__.py +++ b/twilio/rest/api/v2010/account/available_phone_number_country/__init__.py @@ -204,10 +204,11 @@ def fetch(self) -> AvailablePhoneNumberCountryInstance: :returns: The fetched AvailablePhoneNumberCountryInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return AvailablePhoneNumberCountryInstance( self._version, @@ -224,9 +225,12 @@ async def fetch_async(self) -> AvailablePhoneNumberCountryInstance: :returns: The fetched AvailablePhoneNumberCountryInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return AvailablePhoneNumberCountryInstance( @@ -509,7 +513,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return AvailablePhoneNumberCountryPage(self._version, response, self._solution) async def page_async( @@ -536,8 +546,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return AvailablePhoneNumberCountryPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/available_phone_number_country/local.py b/twilio/rest/api/v2010/account/available_phone_number_country/local.py index 43118d9f72..4f0b2e7991 100644 --- a/twilio/rest/api/v2010/account/available_phone_number_country/local.py +++ b/twilio/rest/api/v2010/account/available_phone_number_country/local.py @@ -529,7 +529,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return LocalPage(self._version, response, self._solution) async def page_async( @@ -616,8 +622,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return LocalPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/available_phone_number_country/machine_to_machine.py b/twilio/rest/api/v2010/account/available_phone_number_country/machine_to_machine.py index ee94aa944e..5695c917c3 100644 --- a/twilio/rest/api/v2010/account/available_phone_number_country/machine_to_machine.py +++ b/twilio/rest/api/v2010/account/available_phone_number_country/machine_to_machine.py @@ -529,7 +529,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return MachineToMachinePage(self._version, response, self._solution) async def page_async( @@ -616,8 +622,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return MachineToMachinePage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/available_phone_number_country/mobile.py b/twilio/rest/api/v2010/account/available_phone_number_country/mobile.py index 622d2b8597..2382155ee5 100644 --- a/twilio/rest/api/v2010/account/available_phone_number_country/mobile.py +++ b/twilio/rest/api/v2010/account/available_phone_number_country/mobile.py @@ -529,7 +529,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return MobilePage(self._version, response, self._solution) async def page_async( @@ -616,8 +622,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return MobilePage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/available_phone_number_country/national.py b/twilio/rest/api/v2010/account/available_phone_number_country/national.py index d0f3a63dda..a5e926425a 100644 --- a/twilio/rest/api/v2010/account/available_phone_number_country/national.py +++ b/twilio/rest/api/v2010/account/available_phone_number_country/national.py @@ -529,7 +529,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return NationalPage(self._version, response, self._solution) async def page_async( @@ -616,8 +622,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return NationalPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/available_phone_number_country/shared_cost.py b/twilio/rest/api/v2010/account/available_phone_number_country/shared_cost.py index 7b5b9b11c8..3a9c02bab4 100644 --- a/twilio/rest/api/v2010/account/available_phone_number_country/shared_cost.py +++ b/twilio/rest/api/v2010/account/available_phone_number_country/shared_cost.py @@ -529,7 +529,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return SharedCostPage(self._version, response, self._solution) async def page_async( @@ -616,8 +622,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return SharedCostPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/available_phone_number_country/toll_free.py b/twilio/rest/api/v2010/account/available_phone_number_country/toll_free.py index 4368018001..de4a2d9885 100644 --- a/twilio/rest/api/v2010/account/available_phone_number_country/toll_free.py +++ b/twilio/rest/api/v2010/account/available_phone_number_country/toll_free.py @@ -529,7 +529,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return TollFreePage(self._version, response, self._solution) async def page_async( @@ -616,8 +622,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return TollFreePage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/available_phone_number_country/voip.py b/twilio/rest/api/v2010/account/available_phone_number_country/voip.py index e0615d5a6e..9ebfae5396 100644 --- a/twilio/rest/api/v2010/account/available_phone_number_country/voip.py +++ b/twilio/rest/api/v2010/account/available_phone_number_country/voip.py @@ -529,7 +529,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return VoipPage(self._version, response, self._solution) async def page_async( @@ -616,8 +622,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return VoipPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/balance.py b/twilio/rest/api/v2010/account/balance.py index 0e90cdaae0..66bb91e9f9 100644 --- a/twilio/rest/api/v2010/account/balance.py +++ b/twilio/rest/api/v2010/account/balance.py @@ -13,6 +13,7 @@ """ 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 @@ -72,8 +73,11 @@ def fetch(self) -> BalanceInstance: :returns: The fetched BalanceInstance """ + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - payload = self._version.fetch(method="GET", uri=self._uri) + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return BalanceInstance( self._version, payload, account_sid=self._solution["account_sid"] @@ -86,8 +90,13 @@ async def fetch_async(self) -> BalanceInstance: :returns: The fetched BalanceInstance """ + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" - payload = await self._version.fetch_async(method="GET", uri=self._uri) + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) return BalanceInstance( self._version, payload, account_sid=self._solution["account_sid"] diff --git a/twilio/rest/api/v2010/account/call/__init__.py b/twilio/rest/api/v2010/account/call/__init__.py index b218709a2d..f7756c40ec 100644 --- a/twilio/rest/api/v2010/account/call/__init__.py +++ b/twilio/rest/api/v2010/account/call/__init__.py @@ -26,6 +26,7 @@ from twilio.rest.api.v2010.account.call.recording import RecordingList from twilio.rest.api.v2010.account.call.siprec import SiprecList from twilio.rest.api.v2010.account.call.stream import StreamList +from twilio.rest.api.v2010.account.call.transcription import TranscriptionList from twilio.rest.api.v2010.account.call.user_defined_message import ( UserDefinedMessageList, ) @@ -52,8 +53,8 @@ class UpdateStatus(object): """ :ivar sid: The unique string that we created to identify this Call resource. - :ivar date_created: The date and time in GMT that this 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 this resource was last updated, specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. + :ivar date_created: The date and time in UTC that this resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. + :ivar date_updated: The date and time in UTC that this resource was last updated, specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. :ivar parent_call_sid: The SID that identifies the call that created this leg. :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created this Call resource. :ivar to: The phone number, SIP address, Client identifier or SIM SID that received this call. Phone numbers are in [E.164](https://www.twilio.com/docs/glossary/what-e164) format (e.g., +16175551212). SIP addresses are formatted as `name@company.com`. Client identifiers are formatted `client:name`. SIM SIDs are formatted as `sim:sid`. @@ -62,10 +63,10 @@ class UpdateStatus(object): :ivar from_formatted: The calling phone number, SIP address, or Client identifier formatted for display. Non-North American phone numbers are in [E.164](https://www.twilio.com/docs/glossary/what-e164) format (e.g., +442071838750). :ivar phone_number_sid: If the call was inbound, this is the SID of the IncomingPhoneNumber resource that received the call. If the call was outbound, it is the SID of the OutgoingCallerId resource from which the call was placed. :ivar status: - :ivar start_time: The start time of the call, given as GMT in [RFC 2822](https://www.php.net/manual/en/class.datetime.php#datetime.constants.rfc2822) format. Empty if the call has not yet been dialed. - :ivar end_time: The time the call ended, given as GMT in [RFC 2822](https://www.php.net/manual/en/class.datetime.php#datetime.constants.rfc2822) format. Empty if the call did not complete successfully. + :ivar start_time: The start time of the call, given as UTC in [RFC 2822](https://www.php.net/manual/en/class.datetime.php#datetime.constants.rfc2822) format. Empty if the call has not yet been dialed. + :ivar end_time: The time the call ended, given as UTC in [RFC 2822](https://www.php.net/manual/en/class.datetime.php#datetime.constants.rfc2822) format. Empty if the call did not complete successfully. :ivar duration: The length of the call in seconds. This value is empty for busy, failed, unanswered, or ongoing calls. - :ivar price: The charge for this call, in the currency associated with the account. Populated after the call is completed. May not be immediately available. + :ivar price: The charge for this call, in the currency associated with the account. Populated after the call is completed. May not be immediately available. The price associated with a call only reflects the charge for connectivity. Charges for other call-related features such as Answering Machine Detection, Text-To-Speech, and SIP REFER are not included in this value. :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`). Always capitalized for calls. :ivar direction: A string describing the direction of the call. Can be: `inbound` for inbound calls, `outbound-api` for calls initiated via the REST API or `outbound-dial` for calls initiated by a `` verb. Using [Elastic SIP Trunking](https://www.twilio.com/docs/sip-trunking), the values can be [`trunking-terminating`](https://www.twilio.com/docs/sip-trunking#termination) for outgoing calls from your communications infrastructure to the PSTN or [`trunking-originating`](https://www.twilio.com/docs/sip-trunking#origination) for incoming calls to your communications infrastructure from the PSTN. :ivar answered_by: Either `human` or `machine` if this call was initiated with answering machine detection. Empty otherwise. @@ -303,6 +304,13 @@ def streams(self) -> StreamList: """ return self._proxy.streams + @property + def transcriptions(self) -> TranscriptionList: + """ + Access the transcriptions + """ + return self._proxy.transcriptions + @property def user_defined_messages(self) -> UserDefinedMessageList: """ @@ -352,6 +360,7 @@ def __init__(self, version: Version, account_sid: str, sid: str): self._recordings: Optional[RecordingList] = None self._siprec: Optional[SiprecList] = None self._streams: Optional[StreamList] = None + self._transcriptions: Optional[TranscriptionList] = None self._user_defined_messages: Optional[UserDefinedMessageList] = None self._user_defined_message_subscriptions: Optional[ UserDefinedMessageSubscriptionList @@ -364,10 +373,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -376,9 +385,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> CallInstance: @@ -389,10 +400,11 @@ def fetch(self) -> CallInstance: :returns: The fetched CallInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return CallInstance( self._version, @@ -409,9 +421,12 @@ async def fetch_async(self) -> CallInstance: :returns: The fetched CallInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return CallInstance( @@ -448,6 +463,7 @@ def update( :returns: The updated CallInstance """ + data = values.of( { "Url": url, @@ -461,11 +477,14 @@ def update( "TimeLimit": time_limit, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CallInstance( @@ -502,6 +521,7 @@ async def update_async( :returns: The updated CallInstance """ + data = values.of( { "Url": url, @@ -515,11 +535,14 @@ async def update_async( "TimeLimit": time_limit, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CallInstance( @@ -607,6 +630,19 @@ def streams(self) -> StreamList: ) return self._streams + @property + def transcriptions(self) -> TranscriptionList: + """ + Access the transcriptions + """ + if self._transcriptions is None: + self._transcriptions = TranscriptionList( + self._version, + self._solution["account_sid"], + self._solution["sid"], + ) + return self._transcriptions + @property def user_defined_messages(self) -> UserDefinedMessageList: """ @@ -733,7 +769,7 @@ def create( :param status_callback: The URL we should call using the `status_callback_method` to send status information to your application. If no `status_callback_event` is specified, we will send the `completed` status. If an `application_sid` parameter is present, this parameter is ignored. URLs must contain a valid hostname (underscores are not permitted). :param status_callback_event: The call progress events that we will send to the `status_callback` URL. Can be: `initiated`, `ringing`, `answered`, and `completed`. If no event is specified, we send the `completed` status. If you want to receive multiple events, specify each one in a separate `status_callback_event` parameter. See the code sample for [monitoring call progress](https://www.twilio.com/docs/voice/api/call-resource?code-sample=code-create-a-call-resource-and-specify-a-statuscallbackevent&code-sdk-version=json). If an `application_sid` is present, this parameter is ignored. :param status_callback_method: The HTTP method we should use when calling the `status_callback` URL. Can be: `GET` or `POST` and the default is `POST`. If an `application_sid` parameter is present, this parameter is ignored. - :param send_digits: A string of keys to dial after connecting to the number, maximum of 32 digits. Valid digits in the string include: any digit (`0`-`9`), '`#`', '`*`' and '`w`', to insert a half second pause. For example, if you connected to a company phone number and wanted to pause for one second, and then dial extension 1234 followed by the pound key, the value of this parameter would be `ww1234#`. Remember to URL-encode this string, since the '`#`' character has special meaning in a URL. If both `SendDigits` and `MachineDetection` parameters are provided, then `MachineDetection` will be ignored. + :param send_digits: The string of keys to dial after connecting to the number, with a maximum length of 32 digits. Valid digits in the string include any digit (`0`-`9`), '`A`', '`B`', '`C`', '`D`', '`#`', and '`*`'. You can also use '`w`' to insert a half-second pause and '`W`' to insert a one-second pause. For example, to pause for one second after connecting and then dial extension 1234 followed by the # key, set this parameter to `W1234#`. Be sure to URL-encode this string because the '`#`' character has special meaning in a URL. If both `SendDigits` and `MachineDetection` parameters are provided, then `MachineDetection` will be ignored. :param timeout: The integer number of seconds that we should allow the phone to ring before assuming there is no answer. The default is `60` seconds and the maximum is `600` seconds. For some call flows, we will add a 5-second buffer to the timeout value you provide. For this reason, a timeout value of 10 seconds could result in an actual timeout closer to 15 seconds. You can set this to a short time, such as `15` seconds, to hang up before reaching an answering machine or voicemail. :param record: Whether to record the call. Can be `true` to record the phone call, or `false` to not. The default is `false`. The `recording_url` is sent to the `status_callback` URL. :param recording_channels: The number of channels in the final recording. Can be: `mono` or `dual`. The default is `mono`. `mono` records both legs of the call in a single channel of the recording file. `dual` records each leg to a separate channel of the recording file. The first channel of a dual-channel recording contains the parent call and the second channel contains the child call. @@ -807,11 +843,14 @@ def create( "ApplicationSid": application_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CallInstance( @@ -867,7 +906,7 @@ async def create_async( :param status_callback: The URL we should call using the `status_callback_method` to send status information to your application. If no `status_callback_event` is specified, we will send the `completed` status. If an `application_sid` parameter is present, this parameter is ignored. URLs must contain a valid hostname (underscores are not permitted). :param status_callback_event: The call progress events that we will send to the `status_callback` URL. Can be: `initiated`, `ringing`, `answered`, and `completed`. If no event is specified, we send the `completed` status. If you want to receive multiple events, specify each one in a separate `status_callback_event` parameter. See the code sample for [monitoring call progress](https://www.twilio.com/docs/voice/api/call-resource?code-sample=code-create-a-call-resource-and-specify-a-statuscallbackevent&code-sdk-version=json). If an `application_sid` is present, this parameter is ignored. :param status_callback_method: The HTTP method we should use when calling the `status_callback` URL. Can be: `GET` or `POST` and the default is `POST`. If an `application_sid` parameter is present, this parameter is ignored. - :param send_digits: A string of keys to dial after connecting to the number, maximum of 32 digits. Valid digits in the string include: any digit (`0`-`9`), '`#`', '`*`' and '`w`', to insert a half second pause. For example, if you connected to a company phone number and wanted to pause for one second, and then dial extension 1234 followed by the pound key, the value of this parameter would be `ww1234#`. Remember to URL-encode this string, since the '`#`' character has special meaning in a URL. If both `SendDigits` and `MachineDetection` parameters are provided, then `MachineDetection` will be ignored. + :param send_digits: The string of keys to dial after connecting to the number, with a maximum length of 32 digits. Valid digits in the string include any digit (`0`-`9`), '`A`', '`B`', '`C`', '`D`', '`#`', and '`*`'. You can also use '`w`' to insert a half-second pause and '`W`' to insert a one-second pause. For example, to pause for one second after connecting and then dial extension 1234 followed by the # key, set this parameter to `W1234#`. Be sure to URL-encode this string because the '`#`' character has special meaning in a URL. If both `SendDigits` and `MachineDetection` parameters are provided, then `MachineDetection` will be ignored. :param timeout: The integer number of seconds that we should allow the phone to ring before assuming there is no answer. The default is `60` seconds and the maximum is `600` seconds. For some call flows, we will add a 5-second buffer to the timeout value you provide. For this reason, a timeout value of 10 seconds could result in an actual timeout closer to 15 seconds. You can set this to a short time, such as `15` seconds, to hang up before reaching an answering machine or voicemail. :param record: Whether to record the call. Can be `true` to record the phone call, or `false` to not. The default is `false`. The `recording_url` is sent to the `status_callback` URL. :param recording_channels: The number of channels in the final recording. Can be: `mono` or `dual`. The default is `mono`. `mono` records both legs of the call in a single channel of the recording file. `dual` records each leg to a separate channel of the recording file. The first channel of a dual-channel recording contains the parent call and the second channel contains the child call. @@ -941,11 +980,14 @@ async def create_async( "ApplicationSid": application_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CallInstance( @@ -977,12 +1019,12 @@ def stream( :param str from_: Only include calls from this phone number, SIP address, Client identifier or SIM SID. :param str parent_call_sid: Only include calls spawned by calls with this SID. :param "CallInstance.Status" status: The status of the calls to include. Can be: `queued`, `ringing`, `in-progress`, `canceled`, `completed`, `failed`, `busy`, or `no-answer`. - :param datetime start_time: Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. - :param datetime start_time_before: Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. - :param datetime start_time_after: Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. - :param datetime end_time: Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. - :param datetime end_time_before: Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. - :param datetime end_time_after: Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. + :param datetime start_time: Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. + :param datetime start_time_before: Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. + :param datetime start_time_after: Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. + :param datetime end_time: Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. + :param datetime end_time_before: Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. + :param datetime end_time_after: Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. :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 @@ -1034,12 +1076,12 @@ async def stream_async( :param str from_: Only include calls from this phone number, SIP address, Client identifier or SIM SID. :param str parent_call_sid: Only include calls spawned by calls with this SID. :param "CallInstance.Status" status: The status of the calls to include. Can be: `queued`, `ringing`, `in-progress`, `canceled`, `completed`, `failed`, `busy`, or `no-answer`. - :param datetime start_time: Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. - :param datetime start_time_before: Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. - :param datetime start_time_after: Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. - :param datetime end_time: Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. - :param datetime end_time_before: Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. - :param datetime end_time_after: Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. + :param datetime start_time: Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. + :param datetime start_time_before: Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. + :param datetime start_time_after: Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. + :param datetime end_time: Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. + :param datetime end_time_before: Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. + :param datetime end_time_after: Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. :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 @@ -1090,12 +1132,12 @@ def list( :param str from_: Only include calls from this phone number, SIP address, Client identifier or SIM SID. :param str parent_call_sid: Only include calls spawned by calls with this SID. :param "CallInstance.Status" status: The status of the calls to include. Can be: `queued`, `ringing`, `in-progress`, `canceled`, `completed`, `failed`, `busy`, or `no-answer`. - :param datetime start_time: Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. - :param datetime start_time_before: Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. - :param datetime start_time_after: Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. - :param datetime end_time: Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. - :param datetime end_time_before: Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. - :param datetime end_time_after: Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. + :param datetime start_time: Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. + :param datetime start_time_before: Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. + :param datetime start_time_after: Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. + :param datetime end_time: Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. + :param datetime end_time_before: Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. + :param datetime end_time_after: Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. :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 @@ -1146,12 +1188,12 @@ async def list_async( :param str from_: Only include calls from this phone number, SIP address, Client identifier or SIM SID. :param str parent_call_sid: Only include calls spawned by calls with this SID. :param "CallInstance.Status" status: The status of the calls to include. Can be: `queued`, `ringing`, `in-progress`, `canceled`, `completed`, `failed`, `busy`, or `no-answer`. - :param datetime start_time: Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. - :param datetime start_time_before: Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. - :param datetime start_time_after: Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. - :param datetime end_time: Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. - :param datetime end_time_before: Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. - :param datetime end_time_after: Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. + :param datetime start_time: Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. + :param datetime start_time_before: Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. + :param datetime start_time_after: Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. + :param datetime end_time: Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. + :param datetime end_time_before: Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. + :param datetime end_time_after: Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. :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 @@ -1203,12 +1245,12 @@ def page( :param from_: Only include calls from this phone number, SIP address, Client identifier or SIM SID. :param parent_call_sid: Only include calls spawned by calls with this SID. :param status: The status of the calls to include. Can be: `queued`, `ringing`, `in-progress`, `canceled`, `completed`, `failed`, `busy`, or `no-answer`. - :param start_time: Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. - :param start_time_before: Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. - :param start_time_after: Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. - :param end_time: Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. - :param end_time_before: Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. - :param end_time_after: Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. + :param start_time: Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. + :param start_time_before: Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. + :param start_time_after: Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. + :param end_time: Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. + :param end_time_before: Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. + :param end_time_after: Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. :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 @@ -1233,7 +1275,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return CallPage(self._version, response, self._solution) async def page_async( @@ -1260,12 +1308,12 @@ async def page_async( :param from_: Only include calls from this phone number, SIP address, Client identifier or SIM SID. :param parent_call_sid: Only include calls spawned by calls with this SID. :param status: The status of the calls to include. Can be: `queued`, `ringing`, `in-progress`, `canceled`, `completed`, `failed`, `busy`, or `no-answer`. - :param start_time: Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. - :param start_time_before: Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. - :param start_time_after: Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. - :param end_time: Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. - :param end_time_before: Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. - :param end_time_after: Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. + :param start_time: Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. + :param start_time_before: Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. + :param start_time_after: Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date. + :param end_time: Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. + :param end_time_before: Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. + :param end_time_after: Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date. :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 @@ -1290,8 +1338,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return CallPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/call/event.py b/twilio/rest/api/v2010/account/call/event.py index 7993dd00a0..80eb8aa8ba 100644 --- a/twilio/rest/api/v2010/account/call/event.py +++ b/twilio/rest/api/v2010/account/call/event.py @@ -223,7 +223,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return EventPage(self._version, response, self._solution) async def page_async( @@ -250,8 +256,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return EventPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/call/notification.py b/twilio/rest/api/v2010/account/call/notification.py index 44291b8448..fd9e8c0d00 100644 --- a/twilio/rest/api/v2010/account/call/notification.py +++ b/twilio/rest/api/v2010/account/call/notification.py @@ -162,10 +162,11 @@ def fetch(self) -> NotificationInstance: :returns: The fetched NotificationInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return NotificationInstance( self._version, @@ -183,9 +184,12 @@ async def fetch_async(self) -> NotificationInstance: :returns: The fetched NotificationInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return NotificationInstance( @@ -445,7 +449,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return NotificationPage(self._version, response, self._solution) async def page_async( @@ -484,8 +494,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return NotificationPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/call/payment.py b/twilio/rest/api/v2010/account/call/payment.py index d6252f5277..0f91860987 100644 --- a/twilio/rest/api/v2010/account/call/payment.py +++ b/twilio/rest/api/v2010/account/call/payment.py @@ -47,6 +47,7 @@ class Status(object): class TokenType(object): ONE_TIME = "one-time" REUSABLE = "reusable" + PAYMENT_METHOD = "payment-method" """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Payments resource. @@ -202,6 +203,7 @@ def update( :returns: The updated PaymentInstance """ + data = values.of( { "IdempotencyKey": idempotency_key, @@ -210,11 +212,14 @@ def update( "Status": status, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return PaymentInstance( @@ -242,6 +247,7 @@ async def update_async( :returns: The updated PaymentInstance """ + data = values.of( { "IdempotencyKey": idempotency_key, @@ -250,11 +256,14 @@ async def update_async( "Status": status, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return PaymentInstance( @@ -361,11 +370,14 @@ def create( "ValidCardTypes": valid_card_types, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return PaymentInstance( @@ -439,11 +451,14 @@ async def create_async( "ValidCardTypes": valid_card_types, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return PaymentInstance( diff --git a/twilio/rest/api/v2010/account/call/recording.py b/twilio/rest/api/v2010/account/call/recording.py index b9653c4b5b..5b93ec6c95 100644 --- a/twilio/rest/api/v2010/account/call/recording.py +++ b/twilio/rest/api/v2010/account/call/recording.py @@ -237,10 +237,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -249,9 +249,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> RecordingInstance: @@ -262,10 +264,11 @@ def fetch(self) -> RecordingInstance: :returns: The fetched RecordingInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return RecordingInstance( self._version, @@ -283,9 +286,12 @@ async def fetch_async(self) -> RecordingInstance: :returns: The fetched RecordingInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return RecordingInstance( @@ -309,17 +315,21 @@ def update( :returns: The updated RecordingInstance """ + data = values.of( { "Status": status, "PauseBehavior": pause_behavior, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RecordingInstance( @@ -343,17 +353,21 @@ async def update_async( :returns: The updated RecordingInstance """ + data = values.of( { "Status": status, "PauseBehavior": pause_behavior, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RecordingInstance( @@ -454,11 +468,14 @@ def create( "RecordingTrack": recording_track, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RecordingInstance( @@ -502,11 +519,14 @@ async def create_async( "RecordingTrack": recording_track, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RecordingInstance( @@ -692,7 +712,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return RecordingPage(self._version, response, self._solution) async def page_async( @@ -728,8 +754,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return RecordingPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/call/siprec.py b/twilio/rest/api/v2010/account/call/siprec.py index bcb537071f..d808331c64 100644 --- a/twilio/rest/api/v2010/account/call/siprec.py +++ b/twilio/rest/api/v2010/account/call/siprec.py @@ -156,16 +156,20 @@ def update(self, status: "SiprecInstance.UpdateStatus") -> SiprecInstance: :returns: The updated SiprecInstance """ + data = values.of( { "Status": status, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SiprecInstance( @@ -186,16 +190,20 @@ async def update_async( :returns: The updated SiprecInstance """ + data = values.of( { "Status": status, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SiprecInstance( @@ -861,11 +869,14 @@ def create( "Parameter99.Value": parameter99_value, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SiprecInstance( @@ -1498,11 +1509,14 @@ async def create_async( "Parameter99.Value": parameter99_value, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SiprecInstance( diff --git a/twilio/rest/api/v2010/account/call/stream.py b/twilio/rest/api/v2010/account/call/stream.py index a46d8f9757..1a506e6684 100644 --- a/twilio/rest/api/v2010/account/call/stream.py +++ b/twilio/rest/api/v2010/account/call/stream.py @@ -39,7 +39,7 @@ class UpdateStatus(object): :ivar sid: The SID of the Stream resource. :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created this Stream resource. :ivar call_sid: The SID of the [Call](https://www.twilio.com/docs/voice/api/call-resource) the Stream resource is associated with. - :ivar name: The user-specified name of this Stream, if one was given when the Stream was created. This may be used to stop the Stream. + :ivar name: The user-specified name of this Stream, if one was given when the Stream was created. This can be used to stop the Stream. :ivar status: :ivar date_updated: The date and time in GMT that this resource was last updated, specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. :ivar uri: The URI of the resource, relative to `https://api.twilio.com`. @@ -134,7 +134,7 @@ def __init__(self, version: Version, account_sid: str, call_sid: str, sid: str): :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 this Stream resource. :param call_sid: The SID of the [Call](https://www.twilio.com/docs/voice/api/call-resource) the Stream resource is associated with. - :param sid: The SID of the Stream resource, or the `name` used when creating the resource + :param sid: The SID or the `name` of the Stream resource to be stopped """ super().__init__(version) @@ -158,16 +158,20 @@ def update(self, status: "StreamInstance.UpdateStatus") -> StreamInstance: :returns: The updated StreamInstance """ + data = values.of( { "Status": status, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return StreamInstance( @@ -188,16 +192,20 @@ async def update_async( :returns: The updated StreamInstance """ + data = values.of( { "Status": status, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return StreamInstance( @@ -449,11 +457,11 @@ def create( """ Create the StreamInstance - :param url: Relative or absolute url where WebSocket connection will be established. - :param name: The user-specified name of this Stream, if one was given when the Stream was created. This may be used to stop the Stream. + :param url: Relative or absolute URL where WebSocket connection will be established. + :param name: The user-specified name of this Stream, if one was given when the Stream was created. This can be used to stop the Stream. :param track: - :param status_callback: Absolute URL of the status callback. - :param status_callback_method: The http method for the status_callback (one of GET, POST). + :param status_callback: Absolute URL to which Twilio sends status callback HTTP requests. + :param status_callback_method: The HTTP method Twilio uses when sending `status_callback` requests. Possible values are `GET` and `POST`. Default is `POST`. :param parameter1_name: Parameter name :param parameter1_value: Parameter value :param parameter2_name: Parameter name @@ -863,11 +871,14 @@ def create( "Parameter99.Value": parameter99_value, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return StreamInstance( @@ -1086,11 +1097,11 @@ async def create_async( """ Asynchronously create the StreamInstance - :param url: Relative or absolute url where WebSocket connection will be established. - :param name: The user-specified name of this Stream, if one was given when the Stream was created. This may be used to stop the Stream. + :param url: Relative or absolute URL where WebSocket connection will be established. + :param name: The user-specified name of this Stream, if one was given when the Stream was created. This can be used to stop the Stream. :param track: - :param status_callback: Absolute URL of the status callback. - :param status_callback_method: The http method for the status_callback (one of GET, POST). + :param status_callback: Absolute URL to which Twilio sends status callback HTTP requests. + :param status_callback_method: The HTTP method Twilio uses when sending `status_callback` requests. Possible values are `GET` and `POST`. Default is `POST`. :param parameter1_name: Parameter name :param parameter1_value: Parameter value :param parameter2_name: Parameter name @@ -1500,11 +1511,14 @@ async def create_async( "Parameter99.Value": parameter99_value, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return StreamInstance( @@ -1518,7 +1532,7 @@ def get(self, sid: str) -> StreamContext: """ Constructs a StreamContext - :param sid: The SID of the Stream resource, or the `name` used when creating the resource + :param sid: The SID or the `name` of the Stream resource to be stopped """ return StreamContext( self._version, @@ -1531,7 +1545,7 @@ def __call__(self, sid: str) -> StreamContext: """ Constructs a StreamContext - :param sid: The SID of the Stream resource, or the `name` used when creating the resource + :param sid: The SID or the `name` of the Stream resource to be stopped """ return StreamContext( self._version, diff --git a/twilio/rest/api/v2010/account/call/transcription.py b/twilio/rest/api/v2010/account/call/transcription.py new file mode 100644 index 0000000000..50389f3e68 --- /dev/null +++ b/twilio/rest/api/v2010/account/call/transcription.py @@ -0,0 +1,439 @@ +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 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 TranscriptionInstance(InstanceResource): + + class Status(object): + IN_PROGRESS = "in-progress" + STOPPED = "stopped" + + class Track(object): + INBOUND_TRACK = "inbound_track" + OUTBOUND_TRACK = "outbound_track" + BOTH_TRACKS = "both_tracks" + + class UpdateStatus(object): + STOPPED = "stopped" + + """ + :ivar sid: The SID of the Transcription resource. + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created this Transcription resource. + :ivar call_sid: The SID of the [Call](https://www.twilio.com/docs/voice/api/call-resource) the Transcription resource is associated with. + :ivar name: The user-specified name of this Transcription, if one was given when the Transcription was created. This may be used to stop the Transcription. + :ivar status: + :ivar date_updated: The date and time in GMT that this resource was last updated, specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. + :ivar uri: + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + account_sid: str, + call_sid: str, + sid: Optional[str] = None, + ): + super().__init__(version) + + self.sid: Optional[str] = payload.get("sid") + self.account_sid: Optional[str] = payload.get("account_sid") + self.call_sid: Optional[str] = payload.get("call_sid") + self.name: Optional[str] = payload.get("name") + self.status: Optional["TranscriptionInstance.Status"] = payload.get("status") + self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime( + payload.get("date_updated") + ) + self.uri: Optional[str] = payload.get("uri") + + self._solution = { + "account_sid": account_sid, + "call_sid": call_sid, + "sid": sid or self.sid, + } + self._context: Optional[TranscriptionContext] = None + + @property + def _proxy(self) -> "TranscriptionContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: TranscriptionContext for this TranscriptionInstance + """ + if self._context is None: + self._context = TranscriptionContext( + self._version, + account_sid=self._solution["account_sid"], + call_sid=self._solution["call_sid"], + sid=self._solution["sid"], + ) + return self._context + + def update( + self, status: "TranscriptionInstance.UpdateStatus" + ) -> "TranscriptionInstance": + """ + Update the TranscriptionInstance + + :param status: + + :returns: The updated TranscriptionInstance + """ + return self._proxy.update( + status=status, + ) + + async def update_async( + self, status: "TranscriptionInstance.UpdateStatus" + ) -> "TranscriptionInstance": + """ + Asynchronous coroutine to update the TranscriptionInstance + + :param status: + + :returns: The updated TranscriptionInstance + """ + return await self._proxy.update_async( + status=status, + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class TranscriptionContext(InstanceContext): + + def __init__(self, version: Version, account_sid: str, call_sid: str, sid: str): + """ + Initialize the TranscriptionContext + + :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 this Transcription resource. + :param call_sid: The SID of the [Call](https://www.twilio.com/docs/voice/api/call-resource) the Transcription resource is associated with. + :param sid: The SID of the Transcription resource, or the `name` used when creating the resource + """ + super().__init__(version) + + # Path Solution + self._solution = { + "account_sid": account_sid, + "call_sid": call_sid, + "sid": sid, + } + self._uri = ( + "/Accounts/{account_sid}/Calls/{call_sid}/Transcriptions/{sid}.json".format( + **self._solution + ) + ) + + def update( + self, status: "TranscriptionInstance.UpdateStatus" + ) -> TranscriptionInstance: + """ + Update the TranscriptionInstance + + :param status: + + :returns: The updated TranscriptionInstance + """ + + data = values.of( + { + "Status": status, + } + ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = self._version.update( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return TranscriptionInstance( + self._version, + payload, + account_sid=self._solution["account_sid"], + call_sid=self._solution["call_sid"], + sid=self._solution["sid"], + ) + + async def update_async( + self, status: "TranscriptionInstance.UpdateStatus" + ) -> TranscriptionInstance: + """ + Asynchronous coroutine to update the TranscriptionInstance + + :param status: + + :returns: The updated TranscriptionInstance + """ + + data = values.of( + { + "Status": status, + } + ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = await self._version.update_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return TranscriptionInstance( + self._version, + payload, + account_sid=self._solution["account_sid"], + call_sid=self._solution["call_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 TranscriptionList(ListResource): + + def __init__(self, version: Version, account_sid: str, call_sid: str): + """ + Initialize the TranscriptionList + + :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 this Transcription resource. + :param call_sid: The SID of the [Call](https://www.twilio.com/docs/voice/api/call-resource) the Transcription resource is associated with. + + """ + super().__init__(version) + + # Path Solution + self._solution = { + "account_sid": account_sid, + "call_sid": call_sid, + } + self._uri = ( + "/Accounts/{account_sid}/Calls/{call_sid}/Transcriptions.json".format( + **self._solution + ) + ) + + def create( + self, + name: Union[str, object] = values.unset, + track: Union["TranscriptionInstance.Track", object] = values.unset, + status_callback_url: Union[str, object] = values.unset, + status_callback_method: Union[str, object] = values.unset, + inbound_track_label: Union[str, object] = values.unset, + outbound_track_label: Union[str, object] = values.unset, + partial_results: Union[bool, object] = values.unset, + language_code: Union[str, object] = values.unset, + transcription_engine: Union[str, object] = values.unset, + profanity_filter: Union[bool, object] = values.unset, + speech_model: Union[str, object] = values.unset, + hints: Union[str, object] = values.unset, + enable_automatic_punctuation: Union[bool, object] = values.unset, + intelligence_service: Union[str, object] = values.unset, + ) -> TranscriptionInstance: + """ + Create the TranscriptionInstance + + :param name: The user-specified name of this Transcription, if one was given when the Transcription was created. This may be used to stop the Transcription. + :param track: + :param status_callback_url: Absolute URL of the status callback. + :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 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, 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, 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 add punctuation to recognition result + :param intelligence_service: The SID or unique name of the [Voice Intelligence Service](https://www.twilio.com/docs/voice/intelligence/api/service-resource) for persisting transcripts and running post-call Language Operators . + + :returns: The created TranscriptionInstance + """ + + data = values.of( + { + "Name": name, + "Track": track, + "StatusCallbackUrl": status_callback_url, + "StatusCallbackMethod": status_callback_method, + "InboundTrackLabel": inbound_track_label, + "OutboundTrackLabel": outbound_track_label, + "PartialResults": serialize.boolean_to_string(partial_results), + "LanguageCode": language_code, + "TranscriptionEngine": transcription_engine, + "ProfanityFilter": serialize.boolean_to_string(profanity_filter), + "SpeechModel": speech_model, + "Hints": hints, + "EnableAutomaticPunctuation": serialize.boolean_to_string( + enable_automatic_punctuation + ), + "IntelligenceService": intelligence_service, + } + ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = self._version.create( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return TranscriptionInstance( + self._version, + payload, + account_sid=self._solution["account_sid"], + call_sid=self._solution["call_sid"], + ) + + async def create_async( + self, + name: Union[str, object] = values.unset, + track: Union["TranscriptionInstance.Track", object] = values.unset, + status_callback_url: Union[str, object] = values.unset, + status_callback_method: Union[str, object] = values.unset, + inbound_track_label: Union[str, object] = values.unset, + outbound_track_label: Union[str, object] = values.unset, + partial_results: Union[bool, object] = values.unset, + language_code: Union[str, object] = values.unset, + transcription_engine: Union[str, object] = values.unset, + profanity_filter: Union[bool, object] = values.unset, + speech_model: Union[str, object] = values.unset, + hints: Union[str, object] = values.unset, + enable_automatic_punctuation: Union[bool, object] = values.unset, + intelligence_service: Union[str, object] = values.unset, + ) -> TranscriptionInstance: + """ + Asynchronously create the TranscriptionInstance + + :param name: The user-specified name of this Transcription, if one was given when the Transcription was created. This may be used to stop the Transcription. + :param track: + :param status_callback_url: Absolute URL of the status callback. + :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 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, 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, 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 add punctuation to recognition result + :param intelligence_service: The SID or unique name of the [Voice Intelligence Service](https://www.twilio.com/docs/voice/intelligence/api/service-resource) for persisting transcripts and running post-call Language Operators . + + :returns: The created TranscriptionInstance + """ + + data = values.of( + { + "Name": name, + "Track": track, + "StatusCallbackUrl": status_callback_url, + "StatusCallbackMethod": status_callback_method, + "InboundTrackLabel": inbound_track_label, + "OutboundTrackLabel": outbound_track_label, + "PartialResults": serialize.boolean_to_string(partial_results), + "LanguageCode": language_code, + "TranscriptionEngine": transcription_engine, + "ProfanityFilter": serialize.boolean_to_string(profanity_filter), + "SpeechModel": speech_model, + "Hints": hints, + "EnableAutomaticPunctuation": serialize.boolean_to_string( + enable_automatic_punctuation + ), + "IntelligenceService": intelligence_service, + } + ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return TranscriptionInstance( + self._version, + payload, + account_sid=self._solution["account_sid"], + call_sid=self._solution["call_sid"], + ) + + def get(self, sid: str) -> TranscriptionContext: + """ + Constructs a TranscriptionContext + + :param sid: The SID of the Transcription resource, or the `name` used when creating the resource + """ + return TranscriptionContext( + self._version, + account_sid=self._solution["account_sid"], + call_sid=self._solution["call_sid"], + sid=sid, + ) + + def __call__(self, sid: str) -> TranscriptionContext: + """ + Constructs a TranscriptionContext + + :param sid: The SID of the Transcription resource, or the `name` used when creating the resource + """ + return TranscriptionContext( + self._version, + account_sid=self._solution["account_sid"], + call_sid=self._solution["call_sid"], + sid=sid, + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/api/v2010/account/call/user_defined_message.py b/twilio/rest/api/v2010/account/call/user_defined_message.py index 0e9d1f0490..bc66f8b8e1 100644 --- a/twilio/rest/api/v2010/account/call/user_defined_message.py +++ b/twilio/rest/api/v2010/account/call/user_defined_message.py @@ -98,11 +98,14 @@ def create( "IdempotencyKey": idempotency_key, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return UserDefinedMessageInstance( @@ -130,11 +133,14 @@ async def create_async( "IdempotencyKey": idempotency_key, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return UserDefinedMessageInstance( diff --git a/twilio/rest/api/v2010/account/call/user_defined_message_subscription.py b/twilio/rest/api/v2010/account/call/user_defined_message_subscription.py index a0b7c18339..66923d4b79 100644 --- a/twilio/rest/api/v2010/account/call/user_defined_message_subscription.py +++ b/twilio/rest/api/v2010/account/call/user_defined_message_subscription.py @@ -132,10 +132,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -144,9 +144,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def __repr__(self) -> str: @@ -206,11 +208,14 @@ def create( "Method": method, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return UserDefinedMessageSubscriptionInstance( @@ -243,11 +248,14 @@ async def create_async( "Method": method, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return UserDefinedMessageSubscriptionInstance( diff --git a/twilio/rest/api/v2010/account/conference/__init__.py b/twilio/rest/api/v2010/account/conference/__init__.py index fff75dea5d..672d9d0fea 100644 --- a/twilio/rest/api/v2010/account/conference/__init__.py +++ b/twilio/rest/api/v2010/account/conference/__init__.py @@ -47,12 +47,12 @@ class UpdateStatus(object): """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created this Conference resource. - :ivar date_created: The date and time in GMT that this 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 this resource was last updated, specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. + :ivar date_created: The date and time in UTC that this resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. + :ivar date_updated: The date and time in UTC that this resource was last updated, specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. :ivar api_version: The API version used to create this conference. - :ivar friendly_name: A string that you assigned to describe this conference room. Maxiumum length is 128 characters. - :ivar region: A string that represents the Twilio Region where the conference audio was mixed. May be `us1`, `ie1`, `de1`, `sg1`, `br1`, `au1`, and `jp1`. Basic conference audio will always be mixed in `us1`. Global Conference audio will be mixed nearest to the majority of participants. - :ivar sid: The unique string that that we created to identify this Conference resource. + :ivar friendly_name: A string that you assigned to describe this conference room. Maximum length is 128 characters. + :ivar region: A string that represents the Twilio Region where the conference audio was mixed. May be `us1`, `us2`, `ie1`, `de1`, `sg1`, `br1`, `au1`, and `jp1`. Basic conference audio will always be mixed in `us1`. Global Conference audio will be mixed nearest to the majority of participants. + :ivar sid: The unique, Twilio-provided string used to identify this Conference resource. :ivar status: :ivar uri: The URI of this resource, relative to `https://api.twilio.com`. :ivar subresource_uris: A list of related resources identified by their URIs relative to `https://api.twilio.com`. @@ -230,10 +230,11 @@ def fetch(self) -> ConferenceInstance: :returns: The fetched ConferenceInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ConferenceInstance( self._version, @@ -250,9 +251,12 @@ async def fetch_async(self) -> ConferenceInstance: :returns: The fetched ConferenceInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ConferenceInstance( @@ -277,6 +281,7 @@ def update( :returns: The updated ConferenceInstance """ + data = values.of( { "Status": status, @@ -284,11 +289,14 @@ def update( "AnnounceMethod": announce_method, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ConferenceInstance( @@ -313,6 +321,7 @@ async def update_async( :returns: The updated ConferenceInstance """ + data = values.of( { "Status": status, @@ -320,11 +329,14 @@ async def update_async( "AnnounceMethod": announce_method, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ConferenceInstance( @@ -428,12 +440,12 @@ def stream( is reached. The results are returned as a generator, so this operation is memory efficient. - :param date date_created: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`. - :param date date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`. - :param date date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`. - :param date date_updated: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`. - :param date date_updated_before: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`. - :param date date_updated_after: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`. + :param date date_created: Only include conferences that were created on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read conferences that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read conferences that were created on or after midnight of this date. + :param date date_created_before: Only include conferences that were created on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read conferences that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read conferences that were created on or after midnight of this date. + :param date date_created_after: Only include conferences that were created on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read conferences that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read conferences that were created on or after midnight of this date. + :param date date_updated: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. + :param date date_updated_before: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. + :param date date_updated_after: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param str friendly_name: The string that identifies the Conference resources to read. :param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. :param limit: Upper limit for the number of records to return. stream() @@ -479,12 +491,12 @@ async def stream_async( is reached. The results are returned as a generator, so this operation is memory efficient. - :param date date_created: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`. - :param date date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`. - :param date date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`. - :param date date_updated: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`. - :param date date_updated_before: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`. - :param date date_updated_after: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`. + :param date date_created: Only include conferences that were created on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read conferences that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read conferences that were created on or after midnight of this date. + :param date date_created_before: Only include conferences that were created on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read conferences that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read conferences that were created on or after midnight of this date. + :param date date_created_after: Only include conferences that were created on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read conferences that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read conferences that were created on or after midnight of this date. + :param date date_updated: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. + :param date date_updated_before: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. + :param date date_updated_after: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param str friendly_name: The string that identifies the Conference resources to read. :param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. :param limit: Upper limit for the number of records to return. stream() @@ -529,12 +541,12 @@ def list( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param date date_created: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`. - :param date date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`. - :param date date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`. - :param date date_updated: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`. - :param date date_updated_before: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`. - :param date date_updated_after: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`. + :param date date_created: Only include conferences that were created on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read conferences that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read conferences that were created on or after midnight of this date. + :param date date_created_before: Only include conferences that were created on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read conferences that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read conferences that were created on or after midnight of this date. + :param date date_created_after: Only include conferences that were created on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read conferences that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read conferences that were created on or after midnight of this date. + :param date date_updated: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. + :param date date_updated_before: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. + :param date date_updated_after: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param str friendly_name: The string that identifies the Conference resources to read. :param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. :param limit: Upper limit for the number of records to return. list() guarantees @@ -579,12 +591,12 @@ async def list_async( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param date date_created: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`. - :param date date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`. - :param date date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`. - :param date date_updated: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`. - :param date date_updated_before: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`. - :param date date_updated_after: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`. + :param date date_created: Only include conferences that were created on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read conferences that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read conferences that were created on or after midnight of this date. + :param date date_created_before: Only include conferences that were created on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read conferences that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read conferences that were created on or after midnight of this date. + :param date date_created_after: Only include conferences that were created on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read conferences that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read conferences that were created on or after midnight of this date. + :param date date_updated: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. + :param date date_updated_before: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. + :param date date_updated_after: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param str friendly_name: The string that identifies the Conference resources to read. :param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. :param limit: Upper limit for the number of records to return. list() guarantees @@ -630,12 +642,12 @@ def page( Retrieve a single page of ConferenceInstance records from the API. Request is executed immediately - :param date_created: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`. - :param date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`. - :param date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`. - :param date_updated: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`. - :param date_updated_before: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`. - :param date_updated_after: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`. + :param date_created: Only include conferences that were created on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read conferences that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read conferences that were created on or after midnight of this date. + :param date_created_before: Only include conferences that were created on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read conferences that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read conferences that were created on or after midnight of this date. + :param date_created_after: Only include conferences that were created on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read conferences that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read conferences that were created on or after midnight of this date. + :param date_updated: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. + :param date_updated_before: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. + :param date_updated_after: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param friendly_name: The string that identifies the Conference resources to read. :param status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. :param page_token: PageToken provided by the API @@ -660,7 +672,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ConferencePage(self._version, response, self._solution) async def page_async( @@ -681,12 +699,12 @@ async def page_async( Asynchronously retrieve a single page of ConferenceInstance records from the API. Request is executed immediately - :param date_created: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`. - :param date_created_before: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`. - :param date_created_after: The `date_created` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that started on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that started on or after midnight on a date, use `>=YYYY-MM-DD`. - :param date_updated: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`. - :param date_updated_before: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`. - :param date_updated_after: The `date_updated` value, specified as `YYYY-MM-DD`, of the resources to read. To read conferences that were last updated on or before midnight on a date, use `<=YYYY-MM-DD`, and to specify conferences that were last updated on or after midnight on a given date, use `>=YYYY-MM-DD`. + :param date_created: Only include conferences that were created on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read conferences that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read conferences that were created on or after midnight of this date. + :param date_created_before: Only include conferences that were created on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read conferences that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read conferences that were created on or after midnight of this date. + :param date_created_after: Only include conferences that were created on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were created on this date. You can also specify an inequality, such as `DateCreated<=YYYY-MM-DD`, to read conferences that were created on or before midnight of this date, and `DateCreated>=YYYY-MM-DD` to read conferences that were created on or after midnight of this date. + :param date_updated: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. + :param date_updated_before: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. + :param date_updated_after: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param friendly_name: The string that identifies the Conference resources to read. :param status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. :param page_token: PageToken provided by the API @@ -711,8 +729,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ConferencePage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/conference/participant.py b/twilio/rest/api/v2010/account/conference/participant.py index 1f3fffd8a4..3c49e5387c 100644 --- a/twilio/rest/api/v2010/account/conference/participant.py +++ b/twilio/rest/api/v2010/account/conference/participant.py @@ -46,6 +46,7 @@ class Status(object): :ivar hold: Whether the participant is on hold. Can be `true` or `false`. :ivar start_conference_on_enter: Whether the conference starts when the participant joins the conference, if it has not already started. Can be: `true` or `false` and the default is `true`. If `false` and the conference has not started, the participant is muted and hears background music until another participant starts the conference. :ivar status: + :ivar queue_time: The wait time in milliseconds before participant's call is placed. Only available in the response to a create participant request. :ivar uri: The URI of the resource, relative to `https://api.twilio.com`. """ @@ -80,6 +81,7 @@ def __init__( "start_conference_on_enter" ) self.status: Optional["ParticipantInstance.Status"] = payload.get("status") + self.queue_time: Optional[str] = payload.get("queue_time") self.uri: Optional[str] = payload.get("uri") self._solution = { @@ -166,7 +168,7 @@ def update( :param hold_method: The HTTP method we should use to call `hold_url`. Can be: `GET` or `POST` and the default is `GET`. :param announce_url: The URL we call using the `announce_method` for an announcement to the participant. The URL may return an MP3 file, a WAV file, or a TwiML document that contains ``, ``, ``, or `` verbs. :param announce_method: The HTTP method we should use to call `announce_url`. Can be: `GET` or `POST` and defaults to `POST`. - :param wait_url: The URL we call using the `wait_method` for the music to play while participants are waiting for the conference to start. The URL may return an MP3 file, a WAV file, or a TwiML document that contains ``, ``, ``, or `` verbs. The default value is the URL of our standard hold music. [Learn more about hold music](https://www.twilio.com/labs/twimlets/holdmusic). + :param wait_url: The URL that Twilio calls using the `wait_method` before the conference has started. The URL may return an MP3 file, a WAV file, or a TwiML document. The default value is the URL of our standard hold music. If you do not want anything to play while waiting for the conference to start, specify an empty string by setting `wait_url` to `''`. For more details on the allowable verbs within the `waitUrl`, see the `waitUrl` attribute in the [ TwiML instruction](https://www.twilio.com/docs/voice/twiml/conference#attributes-waiturl). :param wait_method: The HTTP method we should use to call `wait_url`. Can be `GET` or `POST` and the default is `POST`. When using a static audio file, this should be `GET` so that we can cache the file. :param beep_on_exit: Whether to play a notification beep to the conference when the participant exits. Can be: `true` or `false`. :param end_conference_on_exit: Whether to end the conference when the participant leaves. Can be: `true` or `false` and defaults to `false`. @@ -214,7 +216,7 @@ async def update_async( :param hold_method: The HTTP method we should use to call `hold_url`. Can be: `GET` or `POST` and the default is `GET`. :param announce_url: The URL we call using the `announce_method` for an announcement to the participant. The URL may return an MP3 file, a WAV file, or a TwiML document that contains ``, ``, ``, or `` verbs. :param announce_method: The HTTP method we should use to call `announce_url`. Can be: `GET` or `POST` and defaults to `POST`. - :param wait_url: The URL we call using the `wait_method` for the music to play while participants are waiting for the conference to start. The URL may return an MP3 file, a WAV file, or a TwiML document that contains ``, ``, ``, or `` verbs. The default value is the URL of our standard hold music. [Learn more about hold music](https://www.twilio.com/labs/twimlets/holdmusic). + :param wait_url: The URL that Twilio calls using the `wait_method` before the conference has started. The URL may return an MP3 file, a WAV file, or a TwiML document. The default value is the URL of our standard hold music. If you do not want anything to play while waiting for the conference to start, specify an empty string by setting `wait_url` to `''`. For more details on the allowable verbs within the `waitUrl`, see the `waitUrl` attribute in the [ TwiML instruction](https://www.twilio.com/docs/voice/twiml/conference#attributes-waiturl). :param wait_method: The HTTP method we should use to call `wait_url`. Can be `GET` or `POST` and the default is `POST`. When using a static audio file, this should be `GET` so that we can cache the file. :param beep_on_exit: Whether to play a notification beep to the conference when the participant exits. Can be: `true` or `false`. :param end_conference_on_exit: Whether to end the conference when the participant leaves. Can be: `true` or `false` and defaults to `false`. @@ -280,10 +282,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -292,9 +294,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> ParticipantInstance: @@ -305,10 +309,11 @@ def fetch(self) -> ParticipantInstance: :returns: The fetched ParticipantInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ParticipantInstance( self._version, @@ -326,9 +331,12 @@ async def fetch_async(self) -> ParticipantInstance: :returns: The fetched ParticipantInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ParticipantInstance( @@ -363,7 +371,7 @@ def update( :param hold_method: The HTTP method we should use to call `hold_url`. Can be: `GET` or `POST` and the default is `GET`. :param announce_url: The URL we call using the `announce_method` for an announcement to the participant. The URL may return an MP3 file, a WAV file, or a TwiML document that contains ``, ``, ``, or `` verbs. :param announce_method: The HTTP method we should use to call `announce_url`. Can be: `GET` or `POST` and defaults to `POST`. - :param wait_url: The URL we call using the `wait_method` for the music to play while participants are waiting for the conference to start. The URL may return an MP3 file, a WAV file, or a TwiML document that contains ``, ``, ``, or `` verbs. The default value is the URL of our standard hold music. [Learn more about hold music](https://www.twilio.com/labs/twimlets/holdmusic). + :param wait_url: The URL that Twilio calls using the `wait_method` before the conference has started. The URL may return an MP3 file, a WAV file, or a TwiML document. The default value is the URL of our standard hold music. If you do not want anything to play while waiting for the conference to start, specify an empty string by setting `wait_url` to `''`. For more details on the allowable verbs within the `waitUrl`, see the `waitUrl` attribute in the [ TwiML instruction](https://www.twilio.com/docs/voice/twiml/conference#attributes-waiturl). :param wait_method: The HTTP method we should use to call `wait_url`. Can be `GET` or `POST` and the default is `POST`. When using a static audio file, this should be `GET` so that we can cache the file. :param beep_on_exit: Whether to play a notification beep to the conference when the participant exits. Can be: `true` or `false`. :param end_conference_on_exit: Whether to end the conference when the participant leaves. Can be: `true` or `false` and defaults to `false`. @@ -372,6 +380,7 @@ def update( :returns: The updated ParticipantInstance """ + data = values.of( { "Muted": serialize.boolean_to_string(muted), @@ -390,11 +399,14 @@ def update( "CallSidToCoach": call_sid_to_coach, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ParticipantInstance( @@ -429,7 +441,7 @@ async def update_async( :param hold_method: The HTTP method we should use to call `hold_url`. Can be: `GET` or `POST` and the default is `GET`. :param announce_url: The URL we call using the `announce_method` for an announcement to the participant. The URL may return an MP3 file, a WAV file, or a TwiML document that contains ``, ``, ``, or `` verbs. :param announce_method: The HTTP method we should use to call `announce_url`. Can be: `GET` or `POST` and defaults to `POST`. - :param wait_url: The URL we call using the `wait_method` for the music to play while participants are waiting for the conference to start. The URL may return an MP3 file, a WAV file, or a TwiML document that contains ``, ``, ``, or `` verbs. The default value is the URL of our standard hold music. [Learn more about hold music](https://www.twilio.com/labs/twimlets/holdmusic). + :param wait_url: The URL that Twilio calls using the `wait_method` before the conference has started. The URL may return an MP3 file, a WAV file, or a TwiML document. The default value is the URL of our standard hold music. If you do not want anything to play while waiting for the conference to start, specify an empty string by setting `wait_url` to `''`. For more details on the allowable verbs within the `waitUrl`, see the `waitUrl` attribute in the [ TwiML instruction](https://www.twilio.com/docs/voice/twiml/conference#attributes-waiturl). :param wait_method: The HTTP method we should use to call `wait_url`. Can be `GET` or `POST` and the default is `POST`. When using a static audio file, this should be `GET` so that we can cache the file. :param beep_on_exit: Whether to play a notification beep to the conference when the participant exits. Can be: `true` or `false`. :param end_conference_on_exit: Whether to end the conference when the participant leaves. Can be: `true` or `false` and defaults to `false`. @@ -438,6 +450,7 @@ async def update_async( :returns: The updated ParticipantInstance """ + data = values.of( { "Muted": serialize.boolean_to_string(muted), @@ -456,11 +469,14 @@ async def update_async( "CallSidToCoach": call_sid_to_coach, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ParticipantInstance( @@ -595,7 +611,7 @@ def create( :param beep: Whether to play a notification beep to the conference when the participant joins. Can be: `true`, `false`, `onEnter`, or `onExit`. The default value is `true`. :param start_conference_on_enter: Whether to start the conference when the participant joins, if it has not already started. Can be: `true` or `false` and the default is `true`. If `false` and the conference has not started, the participant is muted and hears background music until another participant starts the conference. :param end_conference_on_exit: Whether to end the conference when the participant leaves. Can be: `true` or `false` and defaults to `false`. - :param wait_url: The URL we should call using the `wait_method` for the music to play while participants are waiting for the conference to start. The default value is the URL of our standard hold music. [Learn more about hold music](https://www.twilio.com/labs/twimlets/holdmusic). + :param wait_url: The URL that Twilio calls using the `wait_method` before the conference has started. The URL may return an MP3 file, a WAV file, or a TwiML document. The default value is the URL of our standard hold music. If you do not want anything to play while waiting for the conference to start, specify an empty string by setting `wait_url` to `''`. For more details on the allowable verbs within the `waitUrl`, see the `waitUrl` attribute in the [ TwiML instruction](https://www.twilio.com/docs/voice/twiml/conference#attributes-waiturl). :param wait_method: The HTTP method we should use to call `wait_url`. Can be `GET` or `POST` and the default is `POST`. When using a static audio file, this should be `GET` so that we can cache the file. :param early_media: Whether to allow an agent to hear the state of the outbound call, including ringing or disconnect messages. Can be: `true` or `false` and defaults to `true`. :param max_participants: The maximum number of participants in the conference. Can be a positive integer from `2` to `250`. The default value is `250`. @@ -609,7 +625,7 @@ def create( :param recording_status_callback_method: The HTTP method we should use when we call `recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. :param sip_auth_username: The SIP username used for authentication. :param sip_auth_password: The SIP password for authentication. - :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. + :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `us2`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. :param conference_recording_status_callback: The URL we should call using the `conference_recording_status_callback_method` when the conference recording is available. :param conference_recording_status_callback_method: The HTTP method we should use to call `conference_recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. :param recording_status_callback_event: The recording state changes that should generate a call to `recording_status_callback`. Can be: `started`, `in-progress`, `paused`, `resumed`, `stopped`, `completed`, `failed`, and `absent`. Separate multiple values with a space, ex: `'in-progress completed failed'`. @@ -699,11 +715,14 @@ def create( "CallToken": call_token, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ParticipantInstance( @@ -781,7 +800,7 @@ async def create_async( :param beep: Whether to play a notification beep to the conference when the participant joins. Can be: `true`, `false`, `onEnter`, or `onExit`. The default value is `true`. :param start_conference_on_enter: Whether to start the conference when the participant joins, if it has not already started. Can be: `true` or `false` and the default is `true`. If `false` and the conference has not started, the participant is muted and hears background music until another participant starts the conference. :param end_conference_on_exit: Whether to end the conference when the participant leaves. Can be: `true` or `false` and defaults to `false`. - :param wait_url: The URL we should call using the `wait_method` for the music to play while participants are waiting for the conference to start. The default value is the URL of our standard hold music. [Learn more about hold music](https://www.twilio.com/labs/twimlets/holdmusic). + :param wait_url: The URL that Twilio calls using the `wait_method` before the conference has started. The URL may return an MP3 file, a WAV file, or a TwiML document. The default value is the URL of our standard hold music. If you do not want anything to play while waiting for the conference to start, specify an empty string by setting `wait_url` to `''`. For more details on the allowable verbs within the `waitUrl`, see the `waitUrl` attribute in the [ TwiML instruction](https://www.twilio.com/docs/voice/twiml/conference#attributes-waiturl). :param wait_method: The HTTP method we should use to call `wait_url`. Can be `GET` or `POST` and the default is `POST`. When using a static audio file, this should be `GET` so that we can cache the file. :param early_media: Whether to allow an agent to hear the state of the outbound call, including ringing or disconnect messages. Can be: `true` or `false` and defaults to `true`. :param max_participants: The maximum number of participants in the conference. Can be a positive integer from `2` to `250`. The default value is `250`. @@ -795,7 +814,7 @@ async def create_async( :param recording_status_callback_method: The HTTP method we should use when we call `recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. :param sip_auth_username: The SIP username used for authentication. :param sip_auth_password: The SIP password for authentication. - :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. + :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `us2`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. :param conference_recording_status_callback: The URL we should call using the `conference_recording_status_callback_method` when the conference recording is available. :param conference_recording_status_callback_method: The HTTP method we should use to call `conference_recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. :param recording_status_callback_event: The recording state changes that should generate a call to `recording_status_callback`. Can be: `started`, `in-progress`, `paused`, `resumed`, `stopped`, `completed`, `failed`, and `absent`. Separate multiple values with a space, ex: `'in-progress completed failed'`. @@ -885,11 +904,14 @@ async def create_async( "CallToken": call_token, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ParticipantInstance( @@ -1069,7 +1091,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ParticipantPage(self._version, response, self._solution) async def page_async( @@ -1105,8 +1133,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ParticipantPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/conference/recording.py b/twilio/rest/api/v2010/account/conference/recording.py index dfb1d406ee..12008ed37f 100644 --- a/twilio/rest/api/v2010/account/conference/recording.py +++ b/twilio/rest/api/v2010/account/conference/recording.py @@ -235,10 +235,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -247,9 +247,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> RecordingInstance: @@ -260,10 +262,11 @@ def fetch(self) -> RecordingInstance: :returns: The fetched RecordingInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return RecordingInstance( self._version, @@ -281,9 +284,12 @@ async def fetch_async(self) -> RecordingInstance: :returns: The fetched RecordingInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return RecordingInstance( @@ -307,17 +313,21 @@ def update( :returns: The updated RecordingInstance """ + data = values.of( { "Status": status, "PauseBehavior": pause_behavior, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RecordingInstance( @@ -341,17 +351,21 @@ async def update_async( :returns: The updated RecordingInstance """ + data = values.of( { "Status": status, "PauseBehavior": pause_behavior, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RecordingInstance( @@ -594,7 +608,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return RecordingPage(self._version, response, self._solution) async def page_async( @@ -630,8 +650,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return RecordingPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/connect_app.py b/twilio/rest/api/v2010/account/connect_app.py index 722e4e9b3e..689a2b184a 100644 --- a/twilio/rest/api/v2010/account/connect_app.py +++ b/twilio/rest/api/v2010/account/connect_app.py @@ -242,10 +242,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -254,9 +254,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> ConnectAppInstance: @@ -267,10 +269,11 @@ def fetch(self) -> ConnectAppInstance: :returns: The fetched ConnectAppInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ConnectAppInstance( self._version, @@ -287,9 +290,12 @@ async def fetch_async(self) -> ConnectAppInstance: :returns: The fetched ConnectAppInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ConnectAppInstance( @@ -326,6 +332,7 @@ def update( :returns: The updated ConnectAppInstance """ + data = values.of( { "AuthorizeRedirectUrl": authorize_redirect_url, @@ -338,11 +345,14 @@ def update( "Permissions": serialize.map(permissions, lambda e: e), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ConnectAppInstance( @@ -379,6 +389,7 @@ async def update_async( :returns: The updated ConnectAppInstance """ + data = values.of( { "AuthorizeRedirectUrl": authorize_redirect_url, @@ -391,11 +402,14 @@ async def update_async( "Permissions": serialize.map(permissions, lambda e: e), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ConnectAppInstance( @@ -581,7 +595,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ConnectAppPage(self._version, response, self._solution) async def page_async( @@ -608,8 +628,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ConnectAppPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/incoming_phone_number/__init__.py b/twilio/rest/api/v2010/account/incoming_phone_number/__init__.py index 6fa4748b60..c7c1eebcfd 100644 --- a/twilio/rest/api/v2010/account/incoming_phone_number/__init__.py +++ b/twilio/rest/api/v2010/account/incoming_phone_number/__init__.py @@ -424,10 +424,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -436,9 +436,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> IncomingPhoneNumberInstance: @@ -449,10 +451,11 @@ def fetch(self) -> IncomingPhoneNumberInstance: :returns: The fetched IncomingPhoneNumberInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return IncomingPhoneNumberInstance( self._version, @@ -469,9 +472,12 @@ async def fetch_async(self) -> IncomingPhoneNumberInstance: :returns: The fetched IncomingPhoneNumberInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return IncomingPhoneNumberInstance( @@ -540,6 +546,7 @@ def update( :returns: The updated IncomingPhoneNumberInstance """ + data = values.of( { "AccountSid": account_sid, @@ -569,11 +576,14 @@ def update( "BundleSid": bundle_sid, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return IncomingPhoneNumberInstance( @@ -642,6 +652,7 @@ async def update_async( :returns: The updated IncomingPhoneNumberInstance """ + data = values.of( { "AccountSid": account_sid, @@ -671,11 +682,14 @@ async def update_async( "BundleSid": bundle_sid, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return IncomingPhoneNumberInstance( @@ -845,11 +859,14 @@ def create( "AreaCode": area_code, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return IncomingPhoneNumberInstance( @@ -948,11 +965,14 @@ async def create_async( "AreaCode": area_code, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return IncomingPhoneNumberInstance( @@ -1150,7 +1170,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return IncomingPhoneNumberPage(self._version, response, self._solution) async def page_async( @@ -1189,8 +1215,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return IncomingPhoneNumberPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/incoming_phone_number/assigned_add_on/__init__.py b/twilio/rest/api/v2010/account/incoming_phone_number/assigned_add_on/__init__.py index 12c6f961e4..52fe2a52af 100644 --- a/twilio/rest/api/v2010/account/incoming_phone_number/assigned_add_on/__init__.py +++ b/twilio/rest/api/v2010/account/incoming_phone_number/assigned_add_on/__init__.py @@ -177,10 +177,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -189,9 +189,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> AssignedAddOnInstance: @@ -202,10 +204,11 @@ def fetch(self) -> AssignedAddOnInstance: :returns: The fetched AssignedAddOnInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return AssignedAddOnInstance( self._version, @@ -223,9 +226,12 @@ async def fetch_async(self) -> AssignedAddOnInstance: :returns: The fetched AssignedAddOnInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return AssignedAddOnInstance( @@ -320,11 +326,14 @@ def create(self, installed_add_on_sid: str) -> AssignedAddOnInstance: "InstalledAddOnSid": installed_add_on_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AssignedAddOnInstance( @@ -348,11 +357,14 @@ async def create_async(self, installed_add_on_sid: str) -> AssignedAddOnInstance "InstalledAddOnSid": installed_add_on_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AssignedAddOnInstance( @@ -489,7 +501,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return AssignedAddOnPage(self._version, response, self._solution) async def page_async( @@ -516,8 +534,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return AssignedAddOnPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/incoming_phone_number/assigned_add_on/assigned_add_on_extension.py b/twilio/rest/api/v2010/account/incoming_phone_number/assigned_add_on/assigned_add_on_extension.py index 18504cafd8..1a7d9cdc34 100644 --- a/twilio/rest/api/v2010/account/incoming_phone_number/assigned_add_on/assigned_add_on_extension.py +++ b/twilio/rest/api/v2010/account/incoming_phone_number/assigned_add_on/assigned_add_on_extension.py @@ -149,10 +149,11 @@ def fetch(self) -> AssignedAddOnExtensionInstance: :returns: The fetched AssignedAddOnExtensionInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return AssignedAddOnExtensionInstance( self._version, @@ -171,9 +172,12 @@ async def fetch_async(self) -> AssignedAddOnExtensionInstance: :returns: The fetched AssignedAddOnExtensionInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return AssignedAddOnExtensionInstance( @@ -377,7 +381,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return AssignedAddOnExtensionPage(self._version, response, self._solution) async def page_async( @@ -404,8 +414,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return AssignedAddOnExtensionPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/incoming_phone_number/local.py b/twilio/rest/api/v2010/account/incoming_phone_number/local.py index 4548720329..af67fb0a2d 100644 --- a/twilio/rest/api/v2010/account/incoming_phone_number/local.py +++ b/twilio/rest/api/v2010/account/incoming_phone_number/local.py @@ -279,11 +279,14 @@ def create( "BundleSid": bundle_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return LocalInstance( @@ -377,11 +380,14 @@ async def create_async( "BundleSid": bundle_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return LocalInstance( @@ -579,7 +585,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return LocalPage(self._version, response, self._solution) async def page_async( @@ -618,8 +630,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return LocalPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/incoming_phone_number/mobile.py b/twilio/rest/api/v2010/account/incoming_phone_number/mobile.py index 6147d4bfe7..27fc8a0e9f 100644 --- a/twilio/rest/api/v2010/account/incoming_phone_number/mobile.py +++ b/twilio/rest/api/v2010/account/incoming_phone_number/mobile.py @@ -281,11 +281,14 @@ def create( "BundleSid": bundle_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return MobileInstance( @@ -381,11 +384,14 @@ async def create_async( "BundleSid": bundle_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return MobileInstance( @@ -583,7 +589,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return MobilePage(self._version, response, self._solution) async def page_async( @@ -622,8 +634,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return MobilePage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/incoming_phone_number/toll_free.py b/twilio/rest/api/v2010/account/incoming_phone_number/toll_free.py index 806b7c0500..86290ff9b2 100644 --- a/twilio/rest/api/v2010/account/incoming_phone_number/toll_free.py +++ b/twilio/rest/api/v2010/account/incoming_phone_number/toll_free.py @@ -281,11 +281,14 @@ def create( "BundleSid": bundle_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TollFreeInstance( @@ -381,11 +384,14 @@ async def create_async( "BundleSid": bundle_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TollFreeInstance( @@ -583,7 +589,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return TollFreePage(self._version, response, self._solution) async def page_async( @@ -622,8 +634,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return TollFreePage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/key.py b/twilio/rest/api/v2010/account/key.py index 68a9feb0e1..8b18dbd4ba 100644 --- a/twilio/rest/api/v2010/account/key.py +++ b/twilio/rest/api/v2010/account/key.py @@ -168,10 +168,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -180,9 +180,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> KeyInstance: @@ -193,10 +195,11 @@ def fetch(self) -> KeyInstance: :returns: The fetched KeyInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return KeyInstance( self._version, @@ -213,9 +216,12 @@ async def fetch_async(self) -> KeyInstance: :returns: The fetched KeyInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return KeyInstance( @@ -233,16 +239,20 @@ def update(self, friendly_name: Union[str, object] = values.unset) -> KeyInstanc :returns: The updated KeyInstance """ + data = values.of( { "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return KeyInstance( @@ -262,16 +272,20 @@ async def update_async( :returns: The updated KeyInstance """ + data = values.of( { "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return KeyInstance( @@ -457,7 +471,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return KeyPage(self._version, response, self._solution) async def page_async( @@ -484,8 +504,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return KeyPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/message/__init__.py b/twilio/rest/api/v2010/account/message/__init__.py index 972d80b172..d5369d11ce 100644 --- a/twilio/rest/api/v2010/account/message/__init__.py +++ b/twilio/rest/api/v2010/account/message/__init__.py @@ -62,6 +62,9 @@ class Status(object): PARTIALLY_DELIVERED = "partially_delivered" CANCELED = "canceled" + class TrafficType(object): + FREE = "free" + class UpdateStatus(object): CANCELED = "canceled" @@ -73,16 +76,16 @@ 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. :ivar status: - :ivar messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) associated with the Message resource. The value is `null` if a Messaging Service was not used. + :ivar messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) associated with the Message resource. A unique default value is assigned if a Messaging Service is not used. :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` @@ -275,10 +278,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -287,9 +290,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> MessageInstance: @@ -300,10 +305,11 @@ def fetch(self) -> MessageInstance: :returns: The fetched MessageInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return MessageInstance( self._version, @@ -320,9 +326,12 @@ async def fetch_async(self) -> MessageInstance: :returns: The fetched MessageInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return MessageInstance( @@ -345,17 +354,21 @@ def update( :returns: The updated MessageInstance """ + data = values.of( { "Body": body, "Status": status, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return MessageInstance( @@ -378,17 +391,21 @@ async def update_async( :returns: The updated MessageInstance """ + data = values.of( { "Body": body, "Status": status, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return MessageInstance( @@ -491,6 +508,7 @@ def create( ] = values.unset, smart_encoded: Union[bool, object] = values.unset, persistent_action: Union[List[str], object] = values.unset, + traffic_type: Union["MessageInstance.TrafficType", object] = values.unset, shorten_urls: Union[bool, object] = values.unset, schedule_type: Union["MessageInstance.ScheduleType", object] = values.unset, send_at: Union[datetime, object] = values.unset, @@ -509,15 +527,16 @@ def create( :param to: The recipient's phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format (for SMS/MMS) or [channel address](https://www.twilio.com/docs/messaging/channels), e.g. `whatsapp:+15552229999`. :param status_callback: The URL of the endpoint to which Twilio sends [Message status callback requests](https://www.twilio.com/docs/sms/api/message-resource#twilios-request-to-the-statuscallback-url). URL must contain a valid hostname and underscores are not allowed. If you include this parameter with the `messaging_service_sid`, Twilio uses this URL instead of the Status Callback URL of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource). :param application_sid: The SID of the associated [TwiML Application](https://www.twilio.com/docs/usage/api/applications). [Message status callback requests](https://www.twilio.com/docs/sms/api/message-resource#twilios-request-to-the-statuscallback-url) are sent to the TwiML App's `message_status_callback` URL. Note that the `status_callback` parameter of a request takes priority over the `application_sid` parameter; if both are included `application_sid` is ignored. - :param max_price: [DEPRECATED] This parameter will no longer have any effect as of 2024-06-03. + :param max_price: [OBSOLETE] This parameter will no longer have any effect as of 2024-06-03. :param provide_feedback: Boolean indicating whether or not you intend to provide delivery confirmation feedback to Twilio (used in conjunction with the [Message Feedback subresource](https://www.twilio.com/docs/sms/api/message-feedback-resource)). Default value is `false`. :param attempt: Total number of attempts made (including this request) to send the message regardless of the provider used - :param validity_period: The maximum length in seconds that the Message can remain in Twilio's outgoing message queue. If a queued Message exceeds the `validity_period`, the Message is not sent. Accepted values are integers from `1` to `14400`. Default value is `14400`. A `validity_period` greater than `5` is recommended. [Learn more about the validity period](https://www.twilio.com/blog/take-more-control-of-outbound-messages-using-validity-period-html) + :param validity_period: The maximum length in seconds that the Message can remain in Twilio's outgoing message queue. If a queued Message exceeds the `validity_period`, the Message is not sent. Accepted values are integers from `1` to `36000`. Default value is `36000`. A `validity_period` greater than `5` is recommended. [Learn more about the validity period](https://www.twilio.com/blog/take-more-control-of-outbound-messages-using-validity-period-html) :param force_delivery: Reserved :param content_retention: :param address_retention: :param smart_encoded: Whether to detect Unicode characters that have a similar GSM-7 character and replace them. Can be: `true` or `false`. :param persistent_action: Rich actions for non-SMS/MMS channels. Used for [sending location in WhatsApp messages](https://www.twilio.com/docs/whatsapp/message-features#location-messages-with-whatsapp). + :param traffic_type: :param shorten_urls: For Messaging Services with [Link Shortening configured](https://www.twilio.com/docs/messaging/features/link-shortening) only: A Boolean indicating whether or not Twilio should shorten links in the `body` of the Message. Default value is `false`. If `true`, the `messaging_service_sid` parameter must also be provided. :param schedule_type: :param send_at: The time that Twilio will send the message. Must be in ISO 8601 format. @@ -547,6 +566,7 @@ def create( "AddressRetention": address_retention, "SmartEncoded": serialize.boolean_to_string(smart_encoded), "PersistentAction": serialize.map(persistent_action, lambda e: e), + "TrafficType": traffic_type, "ShortenUrls": serialize.boolean_to_string(shorten_urls), "ScheduleType": schedule_type, "SendAt": serialize.iso8601_datetime(send_at), @@ -560,11 +580,14 @@ def create( "ContentSid": content_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return MessageInstance( @@ -589,6 +612,7 @@ async def create_async( ] = values.unset, smart_encoded: Union[bool, object] = values.unset, persistent_action: Union[List[str], object] = values.unset, + traffic_type: Union["MessageInstance.TrafficType", object] = values.unset, shorten_urls: Union[bool, object] = values.unset, schedule_type: Union["MessageInstance.ScheduleType", object] = values.unset, send_at: Union[datetime, object] = values.unset, @@ -607,15 +631,16 @@ async def create_async( :param to: The recipient's phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format (for SMS/MMS) or [channel address](https://www.twilio.com/docs/messaging/channels), e.g. `whatsapp:+15552229999`. :param status_callback: The URL of the endpoint to which Twilio sends [Message status callback requests](https://www.twilio.com/docs/sms/api/message-resource#twilios-request-to-the-statuscallback-url). URL must contain a valid hostname and underscores are not allowed. If you include this parameter with the `messaging_service_sid`, Twilio uses this URL instead of the Status Callback URL of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource). :param application_sid: The SID of the associated [TwiML Application](https://www.twilio.com/docs/usage/api/applications). [Message status callback requests](https://www.twilio.com/docs/sms/api/message-resource#twilios-request-to-the-statuscallback-url) are sent to the TwiML App's `message_status_callback` URL. Note that the `status_callback` parameter of a request takes priority over the `application_sid` parameter; if both are included `application_sid` is ignored. - :param max_price: [DEPRECATED] This parameter will no longer have any effect as of 2024-06-03. + :param max_price: [OBSOLETE] This parameter will no longer have any effect as of 2024-06-03. :param provide_feedback: Boolean indicating whether or not you intend to provide delivery confirmation feedback to Twilio (used in conjunction with the [Message Feedback subresource](https://www.twilio.com/docs/sms/api/message-feedback-resource)). Default value is `false`. :param attempt: Total number of attempts made (including this request) to send the message regardless of the provider used - :param validity_period: The maximum length in seconds that the Message can remain in Twilio's outgoing message queue. If a queued Message exceeds the `validity_period`, the Message is not sent. Accepted values are integers from `1` to `14400`. Default value is `14400`. A `validity_period` greater than `5` is recommended. [Learn more about the validity period](https://www.twilio.com/blog/take-more-control-of-outbound-messages-using-validity-period-html) + :param validity_period: The maximum length in seconds that the Message can remain in Twilio's outgoing message queue. If a queued Message exceeds the `validity_period`, the Message is not sent. Accepted values are integers from `1` to `36000`. Default value is `36000`. A `validity_period` greater than `5` is recommended. [Learn more about the validity period](https://www.twilio.com/blog/take-more-control-of-outbound-messages-using-validity-period-html) :param force_delivery: Reserved :param content_retention: :param address_retention: :param smart_encoded: Whether to detect Unicode characters that have a similar GSM-7 character and replace them. Can be: `true` or `false`. :param persistent_action: Rich actions for non-SMS/MMS channels. Used for [sending location in WhatsApp messages](https://www.twilio.com/docs/whatsapp/message-features#location-messages-with-whatsapp). + :param traffic_type: :param shorten_urls: For Messaging Services with [Link Shortening configured](https://www.twilio.com/docs/messaging/features/link-shortening) only: A Boolean indicating whether or not Twilio should shorten links in the `body` of the Message. Default value is `false`. If `true`, the `messaging_service_sid` parameter must also be provided. :param schedule_type: :param send_at: The time that Twilio will send the message. Must be in ISO 8601 format. @@ -645,6 +670,7 @@ async def create_async( "AddressRetention": address_retention, "SmartEncoded": serialize.boolean_to_string(smart_encoded), "PersistentAction": serialize.map(persistent_action, lambda e: e), + "TrafficType": traffic_type, "ShortenUrls": serialize.boolean_to_string(shorten_urls), "ScheduleType": schedule_type, "SendAt": serialize.iso8601_datetime(send_at), @@ -658,11 +684,14 @@ async def create_async( "ContentSid": content_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return MessageInstance( @@ -875,7 +904,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return MessagePage(self._version, response, self._solution) async def page_async( @@ -917,8 +952,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return MessagePage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/message/feedback.py b/twilio/rest/api/v2010/account/message/feedback.py index 2ccce06a54..cda2de2ff6 100644 --- a/twilio/rest/api/v2010/account/message/feedback.py +++ b/twilio/rest/api/v2010/account/message/feedback.py @@ -111,11 +111,14 @@ def create( "Outcome": outcome, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return FeedbackInstance( @@ -141,11 +144,14 @@ async def create_async( "Outcome": outcome, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return FeedbackInstance( diff --git a/twilio/rest/api/v2010/account/message/media.py b/twilio/rest/api/v2010/account/message/media.py index 4068d0c35d..b5d2926d12 100644 --- a/twilio/rest/api/v2010/account/message/media.py +++ b/twilio/rest/api/v2010/account/message/media.py @@ -157,10 +157,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -169,9 +169,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> MediaInstance: @@ -182,10 +184,11 @@ def fetch(self) -> MediaInstance: :returns: The fetched MediaInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return MediaInstance( self._version, @@ -203,9 +206,12 @@ async def fetch_async(self) -> MediaInstance: :returns: The fetched MediaInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return MediaInstance( @@ -448,7 +454,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return MediaPage(self._version, response, self._solution) async def page_async( @@ -484,8 +496,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return MediaPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/new_key.py b/twilio/rest/api/v2010/account/new_key.py index 015249ddf8..ba811ec14f 100644 --- a/twilio/rest/api/v2010/account/new_key.py +++ b/twilio/rest/api/v2010/account/new_key.py @@ -91,11 +91,14 @@ def create( "FriendlyName": friendly_name, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return NewKeyInstance( @@ -118,11 +121,14 @@ async def create_async( "FriendlyName": friendly_name, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return NewKeyInstance( diff --git a/twilio/rest/api/v2010/account/new_signing_key.py b/twilio/rest/api/v2010/account/new_signing_key.py index 6bfa32324b..95341d31cb 100644 --- a/twilio/rest/api/v2010/account/new_signing_key.py +++ b/twilio/rest/api/v2010/account/new_signing_key.py @@ -91,11 +91,14 @@ def create( "FriendlyName": friendly_name, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return NewSigningKeyInstance( @@ -118,11 +121,14 @@ async def create_async( "FriendlyName": friendly_name, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return NewSigningKeyInstance( diff --git a/twilio/rest/api/v2010/account/notification.py b/twilio/rest/api/v2010/account/notification.py index 0a2e13da35..cd35efeabf 100644 --- a/twilio/rest/api/v2010/account/notification.py +++ b/twilio/rest/api/v2010/account/notification.py @@ -155,10 +155,11 @@ def fetch(self) -> NotificationInstance: :returns: The fetched NotificationInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return NotificationInstance( self._version, @@ -175,9 +176,12 @@ async def fetch_async(self) -> NotificationInstance: :returns: The fetched NotificationInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return NotificationInstance( @@ -429,7 +433,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return NotificationPage(self._version, response, self._solution) async def page_async( @@ -468,8 +478,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return NotificationPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/outgoing_caller_id.py b/twilio/rest/api/v2010/account/outgoing_caller_id.py index 65ddfa1cdb..eeb9954c75 100644 --- a/twilio/rest/api/v2010/account/outgoing_caller_id.py +++ b/twilio/rest/api/v2010/account/outgoing_caller_id.py @@ -178,10 +178,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -190,9 +190,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> OutgoingCallerIdInstance: @@ -203,10 +205,11 @@ def fetch(self) -> OutgoingCallerIdInstance: :returns: The fetched OutgoingCallerIdInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return OutgoingCallerIdInstance( self._version, @@ -223,9 +226,12 @@ async def fetch_async(self) -> OutgoingCallerIdInstance: :returns: The fetched OutgoingCallerIdInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return OutgoingCallerIdInstance( @@ -245,16 +251,20 @@ def update( :returns: The updated OutgoingCallerIdInstance """ + data = values.of( { "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return OutgoingCallerIdInstance( @@ -274,16 +284,20 @@ async def update_async( :returns: The updated OutgoingCallerIdInstance """ + data = values.of( { "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return OutgoingCallerIdInstance( @@ -505,7 +519,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return OutgoingCallerIdPage(self._version, response, self._solution) async def page_async( @@ -538,8 +558,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return OutgoingCallerIdPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/queue/__init__.py b/twilio/rest/api/v2010/account/queue/__init__.py index 4e6c87baa9..e76fda1259 100644 --- a/twilio/rest/api/v2010/account/queue/__init__.py +++ b/twilio/rest/api/v2010/account/queue/__init__.py @@ -202,10 +202,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -214,9 +214,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> QueueInstance: @@ -227,10 +229,11 @@ def fetch(self) -> QueueInstance: :returns: The fetched QueueInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return QueueInstance( self._version, @@ -247,9 +250,12 @@ async def fetch_async(self) -> QueueInstance: :returns: The fetched QueueInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return QueueInstance( @@ -272,17 +278,21 @@ def update( :returns: The updated QueueInstance """ + data = values.of( { "FriendlyName": friendly_name, "MaxSize": max_size, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return QueueInstance( @@ -305,17 +315,21 @@ async def update_async( :returns: The updated QueueInstance """ + data = values.of( { "FriendlyName": friendly_name, "MaxSize": max_size, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return QueueInstance( @@ -405,11 +419,14 @@ def create( "MaxSize": max_size, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return QueueInstance( @@ -434,11 +451,14 @@ async def create_async( "MaxSize": max_size, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return QueueInstance( @@ -572,7 +592,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return QueuePage(self._version, response, self._solution) async def page_async( @@ -599,8 +625,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return QueuePage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/queue/member.py b/twilio/rest/api/v2010/account/queue/member.py index bf092ff283..30ff4abbc7 100644 --- a/twilio/rest/api/v2010/account/queue/member.py +++ b/twilio/rest/api/v2010/account/queue/member.py @@ -170,10 +170,11 @@ def fetch(self) -> MemberInstance: :returns: The fetched MemberInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return MemberInstance( self._version, @@ -191,9 +192,12 @@ async def fetch_async(self) -> MemberInstance: :returns: The fetched MemberInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return MemberInstance( @@ -215,17 +219,21 @@ def update( :returns: The updated MemberInstance """ + data = values.of( { "Url": url, "Method": method, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return MemberInstance( @@ -247,17 +255,21 @@ async def update_async( :returns: The updated MemberInstance """ + data = values.of( { "Url": url, "Method": method, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return MemberInstance( @@ -451,7 +463,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return MemberPage(self._version, response, self._solution) async def page_async( @@ -478,8 +496,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return MemberPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/recording/__init__.py b/twilio/rest/api/v2010/account/recording/__init__.py index bc1ddccb76..ab5c1c8b7b 100644 --- a/twilio/rest/api/v2010/account/recording/__init__.py +++ b/twilio/rest/api/v2010/account/recording/__init__.py @@ -57,7 +57,7 @@ class Status(object): :ivar price: The one-time cost of creating the recording in the `price_unit` currency. :ivar price_unit: The currency used in the `price` property. Example: `USD`. :ivar status: - :ivar channels: The number of channels in the final recording file. Can be: `1` or `2`. You can split a call with two legs into two separate recording channels if you record using [TwiML Dial](https://www.twilio.com/docs/voice/twiml/dial#record) or the [Outbound Rest API](https://www.twilio.com/docs/voice/make-calls#manage-your-outbound-call). + :ivar channels: The number of channels in the final recording file. Can be: `1` or `2`. :ivar source: :ivar error_code: The error code that describes why the recording is `absent`. The error code is described in our [Error Dictionary](https://www.twilio.com/docs/api/errors). This value is null if the recording `status` is not `absent`. :ivar uri: The URI of the resource, relative to `https://api.twilio.com`. @@ -228,10 +228,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -240,9 +240,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch( @@ -262,7 +264,13 @@ def fetch( } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=data) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) return RecordingInstance( self._version, @@ -288,8 +296,12 @@ async def fetch_async( } ) + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return RecordingInstance( @@ -595,7 +607,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return RecordingPage(self._version, response, self._solution) async def page_async( @@ -640,8 +658,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return RecordingPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/recording/add_on_result/__init__.py b/twilio/rest/api/v2010/account/recording/add_on_result/__init__.py index af1e75f4c6..95296f3cc4 100644 --- a/twilio/rest/api/v2010/account/recording/add_on_result/__init__.py +++ b/twilio/rest/api/v2010/account/recording/add_on_result/__init__.py @@ -190,10 +190,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -202,9 +202,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> AddOnResultInstance: @@ -215,10 +217,11 @@ def fetch(self) -> AddOnResultInstance: :returns: The fetched AddOnResultInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return AddOnResultInstance( self._version, @@ -236,9 +239,12 @@ async def fetch_async(self) -> AddOnResultInstance: :returns: The fetched AddOnResultInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return AddOnResultInstance( @@ -446,7 +452,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return AddOnResultPage(self._version, response, self._solution) async def page_async( @@ -473,8 +485,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return AddOnResultPage(self._version, response, self._solution) 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 91% 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 1dc26e1d7b..08e6ea2109 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 @@ -179,10 +189,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -191,9 +201,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> PayloadInstance: @@ -204,10 +216,11 @@ def fetch(self) -> PayloadInstance: :returns: The fetched PayloadInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return PayloadInstance( self._version, @@ -226,9 +239,12 @@ async def fetch_async(self) -> PayloadInstance: :returns: The fetched PayloadInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return PayloadInstance( @@ -240,6 +256,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 @@ -432,7 +463,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return PayloadPage(self._version, response, self._solution) async def page_async( @@ -459,8 +496,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return PayloadPage(self._version, response, self._solution) 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 0000000000..48567badca --- /dev/null +++ b/twilio/rest/api/v2010/account/recording/add_on_result/payload/data.py @@ -0,0 +1,247 @@ +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 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 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 + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + 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 + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + 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/api/v2010/account/recording/transcription.py b/twilio/rest/api/v2010/account/recording/transcription.py index bb6e0e405a..472f5b2bff 100644 --- a/twilio/rest/api/v2010/account/recording/transcription.py +++ b/twilio/rest/api/v2010/account/recording/transcription.py @@ -175,10 +175,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -187,9 +187,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> TranscriptionInstance: @@ -200,10 +202,11 @@ def fetch(self) -> TranscriptionInstance: :returns: The fetched TranscriptionInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return TranscriptionInstance( self._version, @@ -221,9 +224,12 @@ async def fetch_async(self) -> TranscriptionInstance: :returns: The fetched TranscriptionInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return TranscriptionInstance( @@ -417,7 +423,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return TranscriptionPage(self._version, response, self._solution) async def page_async( @@ -444,8 +456,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return TranscriptionPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/short_code.py b/twilio/rest/api/v2010/account/short_code.py index 2af049a20b..eae35c4aa5 100644 --- a/twilio/rest/api/v2010/account/short_code.py +++ b/twilio/rest/api/v2010/account/short_code.py @@ -203,10 +203,11 @@ def fetch(self) -> ShortCodeInstance: :returns: The fetched ShortCodeInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ShortCodeInstance( self._version, @@ -223,9 +224,12 @@ async def fetch_async(self) -> ShortCodeInstance: :returns: The fetched ShortCodeInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ShortCodeInstance( @@ -256,6 +260,7 @@ def update( :returns: The updated ShortCodeInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -266,11 +271,14 @@ def update( "SmsFallbackMethod": sms_fallback_method, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ShortCodeInstance( @@ -301,6 +309,7 @@ async def update_async( :returns: The updated ShortCodeInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -311,11 +320,14 @@ async def update_async( "SmsFallbackMethod": sms_fallback_method, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ShortCodeInstance( @@ -537,7 +549,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ShortCodePage(self._version, response, self._solution) async def page_async( @@ -570,8 +588,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ShortCodePage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/signing_key.py b/twilio/rest/api/v2010/account/signing_key.py index 6ddc7b92b0..8e33f218f5 100644 --- a/twilio/rest/api/v2010/account/signing_key.py +++ b/twilio/rest/api/v2010/account/signing_key.py @@ -172,10 +172,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -184,9 +184,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> SigningKeyInstance: @@ -197,10 +199,11 @@ def fetch(self) -> SigningKeyInstance: :returns: The fetched SigningKeyInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return SigningKeyInstance( self._version, @@ -217,9 +220,12 @@ async def fetch_async(self) -> SigningKeyInstance: :returns: The fetched SigningKeyInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return SigningKeyInstance( @@ -239,16 +245,20 @@ def update( :returns: The updated SigningKeyInstance """ + data = values.of( { "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SigningKeyInstance( @@ -268,16 +278,20 @@ async def update_async( :returns: The updated SigningKeyInstance """ + data = values.of( { "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SigningKeyInstance( @@ -463,7 +477,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return SigningKeyPage(self._version, response, self._solution) async def page_async( @@ -490,8 +510,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return SigningKeyPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/sip/credential_list/__init__.py b/twilio/rest/api/v2010/account/sip/credential_list/__init__.py index 634500f8cf..d1be747b6d 100644 --- a/twilio/rest/api/v2010/account/sip/credential_list/__init__.py +++ b/twilio/rest/api/v2010/account/sip/credential_list/__init__.py @@ -186,10 +186,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -198,9 +198,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> CredentialListInstance: @@ -211,10 +213,11 @@ def fetch(self) -> CredentialListInstance: :returns: The fetched CredentialListInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return CredentialListInstance( self._version, @@ -231,9 +234,12 @@ async def fetch_async(self) -> CredentialListInstance: :returns: The fetched CredentialListInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return CredentialListInstance( @@ -251,16 +257,20 @@ def update(self, friendly_name: str) -> CredentialListInstance: :returns: The updated CredentialListInstance """ + data = values.of( { "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CredentialListInstance( @@ -278,16 +288,20 @@ async def update_async(self, friendly_name: str) -> CredentialListInstance: :returns: The updated CredentialListInstance """ + data = values.of( { "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CredentialListInstance( @@ -375,11 +389,14 @@ def create(self, friendly_name: str) -> CredentialListInstance: "FriendlyName": friendly_name, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CredentialListInstance( @@ -400,11 +417,14 @@ async def create_async(self, friendly_name: str) -> CredentialListInstance: "FriendlyName": friendly_name, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CredentialListInstance( @@ -538,7 +558,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return CredentialListPage(self._version, response, self._solution) async def page_async( @@ -565,8 +591,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return CredentialListPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/sip/credential_list/credential.py b/twilio/rest/api/v2010/account/sip/credential_list/credential.py index 3d2c24b999..9c52a110e0 100644 --- a/twilio/rest/api/v2010/account/sip/credential_list/credential.py +++ b/twilio/rest/api/v2010/account/sip/credential_list/credential.py @@ -185,10 +185,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -197,9 +197,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> CredentialInstance: @@ -210,10 +212,11 @@ def fetch(self) -> CredentialInstance: :returns: The fetched CredentialInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return CredentialInstance( self._version, @@ -231,9 +234,12 @@ async def fetch_async(self) -> CredentialInstance: :returns: The fetched CredentialInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return CredentialInstance( @@ -252,16 +258,20 @@ def update(self, password: Union[str, object] = values.unset) -> CredentialInsta :returns: The updated CredentialInstance """ + data = values.of( { "Password": password, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CredentialInstance( @@ -282,16 +292,20 @@ async def update_async( :returns: The updated CredentialInstance """ + data = values.of( { "Password": password, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CredentialInstance( @@ -374,11 +388,14 @@ def create(self, username: str, password: str) -> CredentialInstance: "Password": password, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CredentialInstance( @@ -404,11 +421,14 @@ async def create_async(self, username: str, password: str) -> CredentialInstance "Password": password, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CredentialInstance( @@ -545,7 +565,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return CredentialPage(self._version, response, self._solution) async def page_async( @@ -572,8 +598,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return CredentialPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/sip/domain/__init__.py b/twilio/rest/api/v2010/account/sip/domain/__init__.py index b469628388..0a45e68273 100644 --- a/twilio/rest/api/v2010/account/sip/domain/__init__.py +++ b/twilio/rest/api/v2010/account/sip/domain/__init__.py @@ -322,10 +322,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -334,9 +334,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> DomainInstance: @@ -347,10 +349,11 @@ def fetch(self) -> DomainInstance: :returns: The fetched DomainInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return DomainInstance( self._version, @@ -367,9 +370,12 @@ async def fetch_async(self) -> DomainInstance: :returns: The fetched DomainInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return DomainInstance( @@ -414,6 +420,7 @@ def update( :returns: The updated DomainInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -433,11 +440,14 @@ def update( "EmergencyCallerSid": emergency_caller_sid, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return DomainInstance( @@ -482,6 +492,7 @@ async def update_async( :returns: The updated DomainInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -501,11 +512,14 @@ async def update_async( "EmergencyCallerSid": emergency_caller_sid, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return DomainInstance( @@ -658,11 +672,14 @@ def create( "EmergencyCallerSid": emergency_caller_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return DomainInstance( @@ -724,11 +741,14 @@ async def create_async( "EmergencyCallerSid": emergency_caller_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return DomainInstance( @@ -862,7 +882,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return DomainPage(self._version, response, self._solution) async def page_async( @@ -889,8 +915,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return DomainPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/sip/domain/auth_types/auth_type_calls/auth_calls_credential_list_mapping.py b/twilio/rest/api/v2010/account/sip/domain/auth_types/auth_type_calls/auth_calls_credential_list_mapping.py index 81bb5b0b0c..4839f17d48 100644 --- a/twilio/rest/api/v2010/account/sip/domain/auth_types/auth_type_calls/auth_calls_credential_list_mapping.py +++ b/twilio/rest/api/v2010/account/sip/domain/auth_types/auth_type_calls/auth_calls_credential_list_mapping.py @@ -153,10 +153,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -165,9 +165,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> AuthCallsCredentialListMappingInstance: @@ -178,10 +180,11 @@ def fetch(self) -> AuthCallsCredentialListMappingInstance: :returns: The fetched AuthCallsCredentialListMappingInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return AuthCallsCredentialListMappingInstance( self._version, @@ -199,9 +202,12 @@ async def fetch_async(self) -> AuthCallsCredentialListMappingInstance: :returns: The fetched AuthCallsCredentialListMappingInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return AuthCallsCredentialListMappingInstance( @@ -288,11 +294,14 @@ def create( "CredentialListSid": credential_list_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AuthCallsCredentialListMappingInstance( @@ -318,11 +327,14 @@ async def create_async( "CredentialListSid": credential_list_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AuthCallsCredentialListMappingInstance( @@ -459,7 +471,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return AuthCallsCredentialListMappingPage( self._version, response, self._solution ) @@ -488,8 +506,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return AuthCallsCredentialListMappingPage( self._version, response, self._solution diff --git a/twilio/rest/api/v2010/account/sip/domain/auth_types/auth_type_calls/auth_calls_ip_access_control_list_mapping.py b/twilio/rest/api/v2010/account/sip/domain/auth_types/auth_type_calls/auth_calls_ip_access_control_list_mapping.py index a690ef4b10..198f4fc406 100644 --- a/twilio/rest/api/v2010/account/sip/domain/auth_types/auth_type_calls/auth_calls_ip_access_control_list_mapping.py +++ b/twilio/rest/api/v2010/account/sip/domain/auth_types/auth_type_calls/auth_calls_ip_access_control_list_mapping.py @@ -155,10 +155,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -167,9 +167,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> AuthCallsIpAccessControlListMappingInstance: @@ -180,10 +182,11 @@ def fetch(self) -> AuthCallsIpAccessControlListMappingInstance: :returns: The fetched AuthCallsIpAccessControlListMappingInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return AuthCallsIpAccessControlListMappingInstance( self._version, @@ -201,9 +204,12 @@ async def fetch_async(self) -> AuthCallsIpAccessControlListMappingInstance: :returns: The fetched AuthCallsIpAccessControlListMappingInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return AuthCallsIpAccessControlListMappingInstance( @@ -292,11 +298,14 @@ def create( "IpAccessControlListSid": ip_access_control_list_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AuthCallsIpAccessControlListMappingInstance( @@ -322,11 +331,14 @@ async def create_async( "IpAccessControlListSid": ip_access_control_list_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AuthCallsIpAccessControlListMappingInstance( @@ -463,7 +475,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return AuthCallsIpAccessControlListMappingPage( self._version, response, self._solution ) @@ -492,8 +510,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return AuthCallsIpAccessControlListMappingPage( self._version, response, self._solution diff --git a/twilio/rest/api/v2010/account/sip/domain/auth_types/auth_type_registrations/auth_registrations_credential_list_mapping.py b/twilio/rest/api/v2010/account/sip/domain/auth_types/auth_type_registrations/auth_registrations_credential_list_mapping.py index 2b03bb2998..e4b1bf0d23 100644 --- a/twilio/rest/api/v2010/account/sip/domain/auth_types/auth_type_registrations/auth_registrations_credential_list_mapping.py +++ b/twilio/rest/api/v2010/account/sip/domain/auth_types/auth_type_registrations/auth_registrations_credential_list_mapping.py @@ -153,10 +153,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -165,9 +165,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> AuthRegistrationsCredentialListMappingInstance: @@ -178,10 +180,11 @@ def fetch(self) -> AuthRegistrationsCredentialListMappingInstance: :returns: The fetched AuthRegistrationsCredentialListMappingInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return AuthRegistrationsCredentialListMappingInstance( self._version, @@ -199,9 +202,12 @@ async def fetch_async(self) -> AuthRegistrationsCredentialListMappingInstance: :returns: The fetched AuthRegistrationsCredentialListMappingInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return AuthRegistrationsCredentialListMappingInstance( @@ -288,11 +294,14 @@ def create( "CredentialListSid": credential_list_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AuthRegistrationsCredentialListMappingInstance( @@ -318,11 +327,14 @@ async def create_async( "CredentialListSid": credential_list_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AuthRegistrationsCredentialListMappingInstance( @@ -459,7 +471,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return AuthRegistrationsCredentialListMappingPage( self._version, response, self._solution ) @@ -488,8 +506,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return AuthRegistrationsCredentialListMappingPage( self._version, response, self._solution diff --git a/twilio/rest/api/v2010/account/sip/domain/credential_list_mapping.py b/twilio/rest/api/v2010/account/sip/domain/credential_list_mapping.py index f7838bfc59..b520f4813a 100644 --- a/twilio/rest/api/v2010/account/sip/domain/credential_list_mapping.py +++ b/twilio/rest/api/v2010/account/sip/domain/credential_list_mapping.py @@ -155,10 +155,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -167,9 +167,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> CredentialListMappingInstance: @@ -180,10 +182,11 @@ def fetch(self) -> CredentialListMappingInstance: :returns: The fetched CredentialListMappingInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return CredentialListMappingInstance( self._version, @@ -201,9 +204,12 @@ async def fetch_async(self) -> CredentialListMappingInstance: :returns: The fetched CredentialListMappingInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return CredentialListMappingInstance( @@ -284,11 +290,14 @@ def create(self, credential_list_sid: str) -> CredentialListMappingInstance: "CredentialListSid": credential_list_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CredentialListMappingInstance( @@ -314,11 +323,14 @@ async def create_async( "CredentialListSid": credential_list_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CredentialListMappingInstance( @@ -455,7 +467,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return CredentialListMappingPage(self._version, response, self._solution) async def page_async( @@ -482,8 +500,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return CredentialListMappingPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/sip/domain/ip_access_control_list_mapping.py b/twilio/rest/api/v2010/account/sip/domain/ip_access_control_list_mapping.py index c619be386f..4dfecfe826 100644 --- a/twilio/rest/api/v2010/account/sip/domain/ip_access_control_list_mapping.py +++ b/twilio/rest/api/v2010/account/sip/domain/ip_access_control_list_mapping.py @@ -157,10 +157,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -169,9 +169,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> IpAccessControlListMappingInstance: @@ -182,10 +184,11 @@ def fetch(self) -> IpAccessControlListMappingInstance: :returns: The fetched IpAccessControlListMappingInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return IpAccessControlListMappingInstance( self._version, @@ -203,9 +206,12 @@ async def fetch_async(self) -> IpAccessControlListMappingInstance: :returns: The fetched IpAccessControlListMappingInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return IpAccessControlListMappingInstance( @@ -290,11 +296,14 @@ def create( "IpAccessControlListSid": ip_access_control_list_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return IpAccessControlListMappingInstance( @@ -320,11 +329,14 @@ async def create_async( "IpAccessControlListSid": ip_access_control_list_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return IpAccessControlListMappingInstance( @@ -461,7 +473,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return IpAccessControlListMappingPage(self._version, response, self._solution) async def page_async( @@ -488,8 +506,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return IpAccessControlListMappingPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/sip/ip_access_control_list/__init__.py b/twilio/rest/api/v2010/account/sip/ip_access_control_list/__init__.py index 7c2fd8214a..afa504c208 100644 --- a/twilio/rest/api/v2010/account/sip/ip_access_control_list/__init__.py +++ b/twilio/rest/api/v2010/account/sip/ip_access_control_list/__init__.py @@ -190,10 +190,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -202,9 +202,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> IpAccessControlListInstance: @@ -215,10 +217,11 @@ def fetch(self) -> IpAccessControlListInstance: :returns: The fetched IpAccessControlListInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return IpAccessControlListInstance( self._version, @@ -235,9 +238,12 @@ async def fetch_async(self) -> IpAccessControlListInstance: :returns: The fetched IpAccessControlListInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return IpAccessControlListInstance( @@ -255,16 +261,20 @@ def update(self, friendly_name: str) -> IpAccessControlListInstance: :returns: The updated IpAccessControlListInstance """ + data = values.of( { "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return IpAccessControlListInstance( @@ -282,16 +292,20 @@ async def update_async(self, friendly_name: str) -> IpAccessControlListInstance: :returns: The updated IpAccessControlListInstance """ + data = values.of( { "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return IpAccessControlListInstance( @@ -379,11 +393,14 @@ def create(self, friendly_name: str) -> IpAccessControlListInstance: "FriendlyName": friendly_name, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return IpAccessControlListInstance( @@ -404,11 +421,14 @@ async def create_async(self, friendly_name: str) -> IpAccessControlListInstance: "FriendlyName": friendly_name, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return IpAccessControlListInstance( @@ -542,7 +562,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return IpAccessControlListPage(self._version, response, self._solution) async def page_async( @@ -569,8 +595,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return IpAccessControlListPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/sip/ip_access_control_list/ip_address.py b/twilio/rest/api/v2010/account/sip/ip_access_control_list/ip_address.py index 251bae9655..ca2f82eacc 100644 --- a/twilio/rest/api/v2010/account/sip/ip_access_control_list/ip_address.py +++ b/twilio/rest/api/v2010/account/sip/ip_access_control_list/ip_address.py @@ -211,10 +211,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -223,9 +223,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> IpAddressInstance: @@ -236,10 +238,11 @@ def fetch(self) -> IpAddressInstance: :returns: The fetched IpAddressInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return IpAddressInstance( self._version, @@ -257,9 +260,12 @@ async def fetch_async(self) -> IpAddressInstance: :returns: The fetched IpAddressInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return IpAddressInstance( @@ -285,6 +291,7 @@ def update( :returns: The updated IpAddressInstance """ + data = values.of( { "IpAddress": ip_address, @@ -292,11 +299,14 @@ def update( "CidrPrefixLength": cidr_prefix_length, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return IpAddressInstance( @@ -322,6 +332,7 @@ async def update_async( :returns: The updated IpAddressInstance """ + data = values.of( { "IpAddress": ip_address, @@ -329,11 +340,14 @@ async def update_async( "CidrPrefixLength": cidr_prefix_length, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return IpAddressInstance( @@ -425,11 +439,14 @@ def create( "CidrPrefixLength": cidr_prefix_length, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return IpAddressInstance( @@ -462,11 +479,14 @@ async def create_async( "CidrPrefixLength": cidr_prefix_length, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return IpAddressInstance( @@ -603,7 +623,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return IpAddressPage(self._version, response, self._solution) async def page_async( @@ -630,8 +656,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return IpAddressPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/token.py b/twilio/rest/api/v2010/account/token.py index ec5acac97f..fa43360fb1 100644 --- a/twilio/rest/api/v2010/account/token.py +++ b/twilio/rest/api/v2010/account/token.py @@ -93,11 +93,14 @@ def create(self, ttl: Union[int, object] = values.unset) -> TokenInstance: "Ttl": ttl, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TokenInstance( @@ -120,11 +123,14 @@ async def create_async( "Ttl": ttl, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TokenInstance( diff --git a/twilio/rest/api/v2010/account/transcription.py b/twilio/rest/api/v2010/account/transcription.py index a77bc42fb4..386ff9ee74 100644 --- a/twilio/rest/api/v2010/account/transcription.py +++ b/twilio/rest/api/v2010/account/transcription.py @@ -168,10 +168,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -180,9 +180,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> TranscriptionInstance: @@ -193,10 +195,11 @@ def fetch(self) -> TranscriptionInstance: :returns: The fetched TranscriptionInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return TranscriptionInstance( self._version, @@ -213,9 +216,12 @@ async def fetch_async(self) -> TranscriptionInstance: :returns: The fetched TranscriptionInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return TranscriptionInstance( @@ -403,7 +409,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return TranscriptionPage(self._version, response, self._solution) async def page_async( @@ -430,8 +442,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return TranscriptionPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/usage/record/__init__.py b/twilio/rest/api/v2010/account/usage/record/__init__.py index 0afc8e3472..1798eb4079 100644 --- a/twilio/rest/api/v2010/account/usage/record/__init__.py +++ b/twilio/rest/api/v2010/account/usage/record/__init__.py @@ -80,6 +80,8 @@ class Category(object): GROUP_ROOMS_PARTICIPANT_MINUTES = "group-rooms-participant-minutes" GROUP_ROOMS_RECORDED_MINUTES = "group-rooms-recorded-minutes" IMP_V1_USAGE = "imp-v1-usage" + IVR_VIRTUAL_AGENT_CUSTOM_VOICES = "ivr-virtual-agent-custom-voices" + IVR_VIRTUAL_AGENT_GENAI = "ivr-virtual-agent-genai" LOOKUPS = "lookups" MARKETPLACE = "marketplace" MARKETPLACE_ALGORITHMIA_NAMED_ENTITY_RECOGNITION = ( @@ -653,7 +655,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return RecordPage(self._version, response, self._solution) async def page_async( @@ -692,8 +700,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return RecordPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/usage/record/all_time.py b/twilio/rest/api/v2010/account/usage/record/all_time.py index 7c0b6f5ce4..56145d98a9 100644 --- a/twilio/rest/api/v2010/account/usage/record/all_time.py +++ b/twilio/rest/api/v2010/account/usage/record/all_time.py @@ -72,6 +72,8 @@ class Category(object): GROUP_ROOMS_PARTICIPANT_MINUTES = "group-rooms-participant-minutes" GROUP_ROOMS_RECORDED_MINUTES = "group-rooms-recorded-minutes" IMP_V1_USAGE = "imp-v1-usage" + IVR_VIRTUAL_AGENT_CUSTOM_VOICES = "ivr-virtual-agent-custom-voices" + IVR_VIRTUAL_AGENT_GENAI = "ivr-virtual-agent-genai" LOOKUPS = "lookups" MARKETPLACE = "marketplace" MARKETPLACE_ALGORITHMIA_NAMED_ENTITY_RECOGNITION = ( @@ -636,7 +638,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return AllTimePage(self._version, response, self._solution) async def page_async( @@ -675,8 +683,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return AllTimePage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/usage/record/daily.py b/twilio/rest/api/v2010/account/usage/record/daily.py index a0acd62b2a..49058b8ea2 100644 --- a/twilio/rest/api/v2010/account/usage/record/daily.py +++ b/twilio/rest/api/v2010/account/usage/record/daily.py @@ -72,6 +72,8 @@ class Category(object): GROUP_ROOMS_PARTICIPANT_MINUTES = "group-rooms-participant-minutes" GROUP_ROOMS_RECORDED_MINUTES = "group-rooms-recorded-minutes" IMP_V1_USAGE = "imp-v1-usage" + IVR_VIRTUAL_AGENT_CUSTOM_VOICES = "ivr-virtual-agent-custom-voices" + IVR_VIRTUAL_AGENT_GENAI = "ivr-virtual-agent-genai" LOOKUPS = "lookups" MARKETPLACE = "marketplace" MARKETPLACE_ALGORITHMIA_NAMED_ENTITY_RECOGNITION = ( @@ -636,7 +638,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return DailyPage(self._version, response, self._solution) async def page_async( @@ -675,8 +683,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return DailyPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/usage/record/last_month.py b/twilio/rest/api/v2010/account/usage/record/last_month.py index 21fa1e1b61..acd98874ca 100644 --- a/twilio/rest/api/v2010/account/usage/record/last_month.py +++ b/twilio/rest/api/v2010/account/usage/record/last_month.py @@ -72,6 +72,8 @@ class Category(object): GROUP_ROOMS_PARTICIPANT_MINUTES = "group-rooms-participant-minutes" GROUP_ROOMS_RECORDED_MINUTES = "group-rooms-recorded-minutes" IMP_V1_USAGE = "imp-v1-usage" + IVR_VIRTUAL_AGENT_CUSTOM_VOICES = "ivr-virtual-agent-custom-voices" + IVR_VIRTUAL_AGENT_GENAI = "ivr-virtual-agent-genai" LOOKUPS = "lookups" MARKETPLACE = "marketplace" MARKETPLACE_ALGORITHMIA_NAMED_ENTITY_RECOGNITION = ( @@ -636,7 +638,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return LastMonthPage(self._version, response, self._solution) async def page_async( @@ -675,8 +683,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return LastMonthPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/usage/record/monthly.py b/twilio/rest/api/v2010/account/usage/record/monthly.py index 0eff14396a..3258e5f4fe 100644 --- a/twilio/rest/api/v2010/account/usage/record/monthly.py +++ b/twilio/rest/api/v2010/account/usage/record/monthly.py @@ -72,6 +72,8 @@ class Category(object): GROUP_ROOMS_PARTICIPANT_MINUTES = "group-rooms-participant-minutes" GROUP_ROOMS_RECORDED_MINUTES = "group-rooms-recorded-minutes" IMP_V1_USAGE = "imp-v1-usage" + IVR_VIRTUAL_AGENT_CUSTOM_VOICES = "ivr-virtual-agent-custom-voices" + IVR_VIRTUAL_AGENT_GENAI = "ivr-virtual-agent-genai" LOOKUPS = "lookups" MARKETPLACE = "marketplace" MARKETPLACE_ALGORITHMIA_NAMED_ENTITY_RECOGNITION = ( @@ -636,7 +638,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return MonthlyPage(self._version, response, self._solution) async def page_async( @@ -675,8 +683,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return MonthlyPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/usage/record/this_month.py b/twilio/rest/api/v2010/account/usage/record/this_month.py index 646b4a49d5..cf120b91d3 100644 --- a/twilio/rest/api/v2010/account/usage/record/this_month.py +++ b/twilio/rest/api/v2010/account/usage/record/this_month.py @@ -72,6 +72,8 @@ class Category(object): GROUP_ROOMS_PARTICIPANT_MINUTES = "group-rooms-participant-minutes" GROUP_ROOMS_RECORDED_MINUTES = "group-rooms-recorded-minutes" IMP_V1_USAGE = "imp-v1-usage" + IVR_VIRTUAL_AGENT_CUSTOM_VOICES = "ivr-virtual-agent-custom-voices" + IVR_VIRTUAL_AGENT_GENAI = "ivr-virtual-agent-genai" LOOKUPS = "lookups" MARKETPLACE = "marketplace" MARKETPLACE_ALGORITHMIA_NAMED_ENTITY_RECOGNITION = ( @@ -636,7 +638,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ThisMonthPage(self._version, response, self._solution) async def page_async( @@ -675,8 +683,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ThisMonthPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/usage/record/today.py b/twilio/rest/api/v2010/account/usage/record/today.py index 30de9d4cb7..b2387c95b4 100644 --- a/twilio/rest/api/v2010/account/usage/record/today.py +++ b/twilio/rest/api/v2010/account/usage/record/today.py @@ -72,6 +72,8 @@ class Category(object): GROUP_ROOMS_PARTICIPANT_MINUTES = "group-rooms-participant-minutes" GROUP_ROOMS_RECORDED_MINUTES = "group-rooms-recorded-minutes" IMP_V1_USAGE = "imp-v1-usage" + IVR_VIRTUAL_AGENT_CUSTOM_VOICES = "ivr-virtual-agent-custom-voices" + IVR_VIRTUAL_AGENT_GENAI = "ivr-virtual-agent-genai" LOOKUPS = "lookups" MARKETPLACE = "marketplace" MARKETPLACE_ALGORITHMIA_NAMED_ENTITY_RECOGNITION = ( @@ -636,7 +638,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return TodayPage(self._version, response, self._solution) async def page_async( @@ -675,8 +683,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return TodayPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/usage/record/yearly.py b/twilio/rest/api/v2010/account/usage/record/yearly.py index fbe9dd1f6f..490b317e72 100644 --- a/twilio/rest/api/v2010/account/usage/record/yearly.py +++ b/twilio/rest/api/v2010/account/usage/record/yearly.py @@ -72,6 +72,8 @@ class Category(object): GROUP_ROOMS_PARTICIPANT_MINUTES = "group-rooms-participant-minutes" GROUP_ROOMS_RECORDED_MINUTES = "group-rooms-recorded-minutes" IMP_V1_USAGE = "imp-v1-usage" + IVR_VIRTUAL_AGENT_CUSTOM_VOICES = "ivr-virtual-agent-custom-voices" + IVR_VIRTUAL_AGENT_GENAI = "ivr-virtual-agent-genai" LOOKUPS = "lookups" MARKETPLACE = "marketplace" MARKETPLACE_ALGORITHMIA_NAMED_ENTITY_RECOGNITION = ( @@ -636,7 +638,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return YearlyPage(self._version, response, self._solution) async def page_async( @@ -675,8 +683,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return YearlyPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/usage/record/yesterday.py b/twilio/rest/api/v2010/account/usage/record/yesterday.py index db5f9eb472..da5c9dc180 100644 --- a/twilio/rest/api/v2010/account/usage/record/yesterday.py +++ b/twilio/rest/api/v2010/account/usage/record/yesterday.py @@ -72,6 +72,8 @@ class Category(object): GROUP_ROOMS_PARTICIPANT_MINUTES = "group-rooms-participant-minutes" GROUP_ROOMS_RECORDED_MINUTES = "group-rooms-recorded-minutes" IMP_V1_USAGE = "imp-v1-usage" + IVR_VIRTUAL_AGENT_CUSTOM_VOICES = "ivr-virtual-agent-custom-voices" + IVR_VIRTUAL_AGENT_GENAI = "ivr-virtual-agent-genai" LOOKUPS = "lookups" MARKETPLACE = "marketplace" MARKETPLACE_ALGORITHMIA_NAMED_ENTITY_RECOGNITION = ( @@ -636,7 +638,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return YesterdayPage(self._version, response, self._solution) async def page_async( @@ -675,8 +683,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return YesterdayPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/usage/trigger.py b/twilio/rest/api/v2010/account/usage/trigger.py index 66e86602af..08ac52f605 100644 --- a/twilio/rest/api/v2010/account/usage/trigger.py +++ b/twilio/rest/api/v2010/account/usage/trigger.py @@ -83,6 +83,8 @@ class UsageCategory(object): GROUP_ROOMS_PARTICIPANT_MINUTES = "group-rooms-participant-minutes" GROUP_ROOMS_RECORDED_MINUTES = "group-rooms-recorded-minutes" IMP_V1_USAGE = "imp-v1-usage" + IVR_VIRTUAL_AGENT_CUSTOM_VOICES = "ivr-virtual-agent-custom-voices" + IVR_VIRTUAL_AGENT_GENAI = "ivr-virtual-agent-genai" LOOKUPS = "lookups" MARKETPLACE = "marketplace" MARKETPLACE_ALGORITHMIA_NAMED_ENTITY_RECOGNITION = ( @@ -551,10 +553,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -563,9 +565,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> TriggerInstance: @@ -576,10 +580,11 @@ def fetch(self) -> TriggerInstance: :returns: The fetched TriggerInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return TriggerInstance( self._version, @@ -596,9 +601,12 @@ async def fetch_async(self) -> TriggerInstance: :returns: The fetched TriggerInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return TriggerInstance( @@ -623,6 +631,7 @@ def update( :returns: The updated TriggerInstance """ + data = values.of( { "CallbackMethod": callback_method, @@ -630,11 +639,14 @@ def update( "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TriggerInstance( @@ -659,6 +671,7 @@ async def update_async( :returns: The updated TriggerInstance """ + data = values.of( { "CallbackMethod": callback_method, @@ -666,11 +679,14 @@ async def update_async( "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TriggerInstance( @@ -766,11 +782,14 @@ def create( "TriggerBy": trigger_by, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TriggerInstance( @@ -812,11 +831,14 @@ async def create_async( "TriggerBy": trigger_by, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TriggerInstance( @@ -999,7 +1021,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return TriggerPage(self._version, response, self._solution) async def page_async( @@ -1035,8 +1063,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return TriggerPage(self._version, response, self._solution) diff --git a/twilio/rest/api/v2010/account/validation_request.py b/twilio/rest/api/v2010/account/validation_request.py index a949df2d0a..d92f840e68 100644 --- a/twilio/rest/api/v2010/account/validation_request.py +++ b/twilio/rest/api/v2010/account/validation_request.py @@ -104,11 +104,14 @@ def create( "StatusCallbackMethod": status_callback_method, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ValidationRequestInstance( @@ -147,11 +150,14 @@ async def create_async( "StatusCallbackMethod": status_callback_method, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ValidationRequestInstance( diff --git a/twilio/rest/preview_messaging/PreviewMessagingBase.py b/twilio/rest/assistants/AssistantsBase.py similarity index 72% rename from twilio/rest/preview_messaging/PreviewMessagingBase.py rename to twilio/rest/assistants/AssistantsBase.py index 12b19f4cf1..a9c9e9afcd 100644 --- a/twilio/rest/preview_messaging/PreviewMessagingBase.py +++ b/twilio/rest/assistants/AssistantsBase.py @@ -13,24 +13,24 @@ from twilio.base.domain import Domain from twilio.rest import Client -from twilio.rest.preview_messaging.v1 import V1 +from twilio.rest.assistants.v1 import V1 -class PreviewMessagingBase(Domain): +class AssistantsBase(Domain): def __init__(self, twilio: Client): """ - Initialize the PreviewMessaging Domain + Initialize the Assistants Domain - :returns: Domain for PreviewMessaging + :returns: Domain for Assistants """ - super().__init__(twilio, "https://preview.messaging.twilio.com") + super().__init__(twilio, "https://assistants.twilio.com") self._v1: Optional[V1] = None @property def v1(self) -> V1: """ - :returns: Versions v1 of PreviewMessaging + :returns: Versions v1 of Assistants """ if self._v1 is None: self._v1 = V1(self) @@ -41,4 +41,4 @@ def __repr__(self) -> str: Provide a friendly representation :returns: Machine friendly representation """ - return "" + return "" diff --git a/twilio/rest/assistants/__init__.py b/twilio/rest/assistants/__init__.py new file mode 100644 index 0000000000..889daf9d29 --- /dev/null +++ b/twilio/rest/assistants/__init__.py @@ -0,0 +1,56 @@ +from warnings import warn + +from twilio.rest.assistants.AssistantsBase import AssistantsBase +from twilio.rest.assistants.v1.assistant import AssistantList +from twilio.rest.assistants.v1.knowledge import KnowledgeList +from twilio.rest.assistants.v1.policy import PolicyList +from twilio.rest.assistants.v1.session import SessionList +from twilio.rest.assistants.v1.tool import ToolList + + +class Assistants(AssistantsBase): + + @property + def assistants(self) -> AssistantList: + warn( + "assistants is deprecated. Use v1.assistants instead.", + DeprecationWarning, + stacklevel=2, + ) + return self.v1.assistants + + @property + def knowledge(self) -> KnowledgeList: + warn( + "knowledge is deprecated. Use v1.knowledge instead.", + DeprecationWarning, + stacklevel=2, + ) + return self.v1.knowledge + + @property + def policies(self) -> PolicyList: + warn( + "policies is deprecated. Use v1.policies instead.", + DeprecationWarning, + stacklevel=2, + ) + return self.v1.policies + + @property + def sessions(self) -> SessionList: + warn( + "sessions is deprecated. Use v1.sessions instead.", + DeprecationWarning, + stacklevel=2, + ) + return self.v1.sessions + + @property + def tools(self) -> ToolList: + warn( + "tools is deprecated. Use v1.tools instead.", + DeprecationWarning, + stacklevel=2, + ) + return self.v1.tools diff --git a/twilio/rest/assistants/v1/__init__.py b/twilio/rest/assistants/v1/__init__.py new file mode 100644 index 0000000000..546ad14554 --- /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 0000000000..8ab22a5dcf --- /dev/null +++ b/twilio/rest/assistants/v1/assistant/__init__.py @@ -0,0 +1,1036 @@ +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.assistants_knowledge import ( + AssistantsKnowledgeList, +) +from twilio.rest.assistants.v1.assistant.assistants_tool import AssistantsToolList +from twilio.rest.assistants.v1.assistant.feedback import FeedbackList +from twilio.rest.assistants.v1.assistant.message import MessageList + + +class AssistantInstance(InstanceResource): + + class AssistantsV1ServiceCreateAssistantRequest(object): + """ + :ivar customer_ai: + :ivar name: The name of the assistant. + :ivar owner: The owner/company of the assistant. + :ivar personality_prompt: The personality prompt to be used for assistant. + :ivar segment_credential: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.customer_ai: Optional[AssistantList.AssistantsV1ServiceCustomerAi] = ( + payload.get("customer_ai") + ) + self.name: Optional[str] = payload.get("name") + self.owner: Optional[str] = payload.get("owner") + self.personality_prompt: Optional[str] = payload.get("personality_prompt") + self.segment_credential: Optional[ + AssistantList.AssistantsV1ServiceSegmentCredential + ] = payload.get("segment_credential") + + def to_dict(self): + return { + "customer_ai": ( + self.customer_ai.to_dict() if self.customer_ai is not None else None + ), + "name": self.name, + "owner": self.owner, + "personality_prompt": self.personality_prompt, + "segment_credential": ( + self.segment_credential.to_dict() + if self.segment_credential is not None + else None + ), + } + + class AssistantsV1ServiceCustomerAi(object): + """ + :ivar perception_engine_enabled: True if the perception engine is enabled. + :ivar personalization_engine_enabled: True if the personalization engine is enabled. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.perception_engine_enabled: Optional[bool] = payload.get( + "perception_engine_enabled" + ) + self.personalization_engine_enabled: Optional[bool] = payload.get( + "personalization_engine_enabled" + ) + + def to_dict(self): + return { + "perception_engine_enabled": self.perception_engine_enabled, + "personalization_engine_enabled": self.personalization_engine_enabled, + } + + class AssistantsV1ServiceSegmentCredential(object): + """ + :ivar profile_api_key: The profile API key. + :ivar space_id: The space ID. + :ivar write_key: The write key. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.profile_api_key: Optional[str] = payload.get("profile_api_key") + self.space_id: Optional[str] = payload.get("space_id") + self.write_key: Optional[str] = payload.get("write_key") + + def to_dict(self): + return { + "profile_api_key": self.profile_api_key, + "space_id": self.space_id, + "write_key": self.write_key, + } + + class AssistantsV1ServiceUpdateAssistantRequest(object): + """ + :ivar customer_ai: + :ivar name: The name of the assistant. + :ivar owner: The owner/company of the assistant. + :ivar personality_prompt: The personality prompt to be used for assistant. + :ivar segment_credential: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.customer_ai: Optional[AssistantList.AssistantsV1ServiceCustomerAi] = ( + payload.get("customer_ai") + ) + self.name: Optional[str] = payload.get("name") + self.owner: Optional[str] = payload.get("owner") + self.personality_prompt: Optional[str] = payload.get("personality_prompt") + self.segment_credential: Optional[ + AssistantList.AssistantsV1ServiceSegmentCredential + ] = payload.get("segment_credential") + + def to_dict(self): + return { + "customer_ai": ( + self.customer_ai.to_dict() if self.customer_ai is not None else None + ), + "name": self.name, + "owner": self.owner, + "personality_prompt": self.personality_prompt, + "segment_credential": ( + self.segment_credential.to_dict() + if self.segment_credential is not None + else None + ), + } + + """ + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Assistant resource. + :ivar customer_ai: The Personalization and Perception Engine settings. + :ivar id: The Assistant ID. + :ivar model: The default model used by the assistant. + :ivar name: The name of the assistant. + :ivar owner: The owner/company of the assistant. + :ivar url: The url of the assistant resource. + :ivar personality_prompt: The personality prompt to be used for assistant. + :ivar date_created: The date and time in GMT when the Assistant was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + :ivar date_updated: The date and time in GMT when the Assistant was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + :ivar knowledge: The list of knowledge sources associated with the assistant. + :ivar tools: The list of tools associated with the assistant. + """ + + def __init__( + self, version: Version, payload: Dict[str, Any], id: Optional[str] = None + ): + super().__init__(version) + + self.account_sid: Optional[str] = payload.get("account_sid") + self.customer_ai: Optional[Dict[str, object]] = payload.get("customer_ai") + self.id: Optional[str] = payload.get("id") + self.model: Optional[str] = payload.get("model") + self.name: Optional[str] = payload.get("name") + self.owner: Optional[str] = payload.get("owner") + self.url: Optional[str] = payload.get("url") + self.personality_prompt: Optional[str] = payload.get("personality_prompt") + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_created") + ) + self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_updated") + ) + self.knowledge: Optional[List[str]] = payload.get("knowledge") + self.tools: Optional[List[str]] = payload.get("tools") + + self._solution = { + "id": id or self.id, + } + self._context: Optional[AssistantContext] = None + + @property + def _proxy(self) -> "AssistantContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: AssistantContext for this AssistantInstance + """ + if self._context is None: + self._context = AssistantContext( + self._version, + id=self._solution["id"], + ) + return self._context + + def delete(self) -> bool: + """ + Deletes the AssistantInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._proxy.delete() + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the AssistantInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._proxy.delete_async() + + def 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 assistants_knowledge(self) -> AssistantsKnowledgeList: + """ + Access the assistants_knowledge + """ + return self._proxy.assistants_knowledge + + @property + def assistants_tools(self) -> AssistantsToolList: + """ + Access the assistants_tools + """ + return self._proxy.assistants_tools + + @property + def feedbacks(self) -> FeedbackList: + """ + Access the feedbacks + """ + return self._proxy.feedbacks + + @property + def messages(self) -> MessageList: + """ + Access the messages + """ + return self._proxy.messages + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class AssistantContext(InstanceContext): + + class AssistantsV1ServiceCreateAssistantRequest(object): + """ + :ivar customer_ai: + :ivar name: The name of the assistant. + :ivar owner: The owner/company of the assistant. + :ivar personality_prompt: The personality prompt to be used for assistant. + :ivar segment_credential: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.customer_ai: Optional[AssistantList.AssistantsV1ServiceCustomerAi] = ( + payload.get("customer_ai") + ) + self.name: Optional[str] = payload.get("name") + self.owner: Optional[str] = payload.get("owner") + self.personality_prompt: Optional[str] = payload.get("personality_prompt") + self.segment_credential: Optional[ + AssistantList.AssistantsV1ServiceSegmentCredential + ] = payload.get("segment_credential") + + def to_dict(self): + return { + "customer_ai": ( + self.customer_ai.to_dict() if self.customer_ai is not None else None + ), + "name": self.name, + "owner": self.owner, + "personality_prompt": self.personality_prompt, + "segment_credential": ( + self.segment_credential.to_dict() + if self.segment_credential is not None + else None + ), + } + + class AssistantsV1ServiceCustomerAi(object): + """ + :ivar perception_engine_enabled: True if the perception engine is enabled. + :ivar personalization_engine_enabled: True if the personalization engine is enabled. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.perception_engine_enabled: Optional[bool] = payload.get( + "perception_engine_enabled" + ) + self.personalization_engine_enabled: Optional[bool] = payload.get( + "personalization_engine_enabled" + ) + + def to_dict(self): + return { + "perception_engine_enabled": self.perception_engine_enabled, + "personalization_engine_enabled": self.personalization_engine_enabled, + } + + class AssistantsV1ServiceSegmentCredential(object): + """ + :ivar profile_api_key: The profile API key. + :ivar space_id: The space ID. + :ivar write_key: The write key. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.profile_api_key: Optional[str] = payload.get("profile_api_key") + self.space_id: Optional[str] = payload.get("space_id") + self.write_key: Optional[str] = payload.get("write_key") + + def to_dict(self): + return { + "profile_api_key": self.profile_api_key, + "space_id": self.space_id, + "write_key": self.write_key, + } + + class AssistantsV1ServiceUpdateAssistantRequest(object): + """ + :ivar customer_ai: + :ivar name: The name of the assistant. + :ivar owner: The owner/company of the assistant. + :ivar personality_prompt: The personality prompt to be used for assistant. + :ivar segment_credential: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.customer_ai: Optional[AssistantList.AssistantsV1ServiceCustomerAi] = ( + payload.get("customer_ai") + ) + self.name: Optional[str] = payload.get("name") + self.owner: Optional[str] = payload.get("owner") + self.personality_prompt: Optional[str] = payload.get("personality_prompt") + self.segment_credential: Optional[ + AssistantList.AssistantsV1ServiceSegmentCredential + ] = payload.get("segment_credential") + + def to_dict(self): + return { + "customer_ai": ( + self.customer_ai.to_dict() if self.customer_ai is not None else None + ), + "name": self.name, + "owner": self.owner, + "personality_prompt": self.personality_prompt, + "segment_credential": ( + self.segment_credential.to_dict() + if self.segment_credential is not None + else None + ), + } + + def __init__(self, version: Version, id: str): + """ + Initialize the AssistantContext + + :param version: Version that contains the resource + :param id: + """ + super().__init__(version) + + # Path Solution + self._solution = { + "id": id, + } + self._uri = "/Assistants/{id}".format(**self._solution) + + self._assistants_knowledge: Optional[AssistantsKnowledgeList] = None + self._assistants_tools: Optional[AssistantsToolList] = None + self._feedbacks: Optional[FeedbackList] = None + self._messages: Optional[MessageList] = None + + def delete(self) -> bool: + """ + Deletes the AssistantInstance + + + :returns: True if delete succeeds, False otherwise + """ + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the AssistantInstance + + + :returns: True if delete succeeds, False otherwise + """ + + headers = values.of({}) + + return await self._version.delete_async( + method="DELETE", uri=self._uri, headers=headers + ) + + def fetch(self) -> AssistantInstance: + """ + Fetch the AssistantInstance + + + :returns: The fetched AssistantInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + 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 + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + 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 = assistants_v1_service_update_assistant_request.to_dict() + + headers = values.of({}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + payload = self._version.update( + method="PUT", uri=self._uri, data=data, headers=headers + ) + + return 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 = assistants_v1_service_update_assistant_request.to_dict() + + headers = values.of({}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + payload = await self._version.update_async( + method="PUT", uri=self._uri, data=data, headers=headers + ) + + return 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: + """ + Access the feedbacks + """ + if self._feedbacks is None: + self._feedbacks = FeedbackList( + self._version, + self._solution["id"], + ) + return self._feedbacks + + @property + def messages(self) -> MessageList: + """ + Access the messages + """ + if self._messages is None: + self._messages = MessageList( + self._version, + self._solution["id"], + ) + return self._messages + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class AssistantPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> AssistantInstance: + """ + Build an instance of AssistantInstance + + :param payload: Payload response from the API + """ + return AssistantInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class AssistantList(ListResource): + + class AssistantsV1ServiceCreateAssistantRequest(object): + """ + :ivar customer_ai: + :ivar name: The name of the assistant. + :ivar owner: The owner/company of the assistant. + :ivar personality_prompt: The personality prompt to be used for assistant. + :ivar segment_credential: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.customer_ai: Optional[AssistantList.AssistantsV1ServiceCustomerAi] = ( + payload.get("customer_ai") + ) + self.name: Optional[str] = payload.get("name") + self.owner: Optional[str] = payload.get("owner") + self.personality_prompt: Optional[str] = payload.get("personality_prompt") + self.segment_credential: Optional[ + AssistantList.AssistantsV1ServiceSegmentCredential + ] = payload.get("segment_credential") + + def to_dict(self): + return { + "customer_ai": ( + self.customer_ai.to_dict() if self.customer_ai is not None else None + ), + "name": self.name, + "owner": self.owner, + "personality_prompt": self.personality_prompt, + "segment_credential": ( + self.segment_credential.to_dict() + if self.segment_credential is not None + else None + ), + } + + class AssistantsV1ServiceCustomerAi(object): + """ + :ivar perception_engine_enabled: True if the perception engine is enabled. + :ivar personalization_engine_enabled: True if the personalization engine is enabled. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.perception_engine_enabled: Optional[bool] = payload.get( + "perception_engine_enabled" + ) + self.personalization_engine_enabled: Optional[bool] = payload.get( + "personalization_engine_enabled" + ) + + def to_dict(self): + return { + "perception_engine_enabled": self.perception_engine_enabled, + "personalization_engine_enabled": self.personalization_engine_enabled, + } + + class AssistantsV1ServiceSegmentCredential(object): + """ + :ivar profile_api_key: The profile API key. + :ivar space_id: The space ID. + :ivar write_key: The write key. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.profile_api_key: Optional[str] = payload.get("profile_api_key") + self.space_id: Optional[str] = payload.get("space_id") + self.write_key: Optional[str] = payload.get("write_key") + + def to_dict(self): + return { + "profile_api_key": self.profile_api_key, + "space_id": self.space_id, + "write_key": self.write_key, + } + + class AssistantsV1ServiceUpdateAssistantRequest(object): + """ + :ivar customer_ai: + :ivar name: The name of the assistant. + :ivar owner: The owner/company of the assistant. + :ivar personality_prompt: The personality prompt to be used for assistant. + :ivar segment_credential: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.customer_ai: Optional[AssistantList.AssistantsV1ServiceCustomerAi] = ( + payload.get("customer_ai") + ) + self.name: Optional[str] = payload.get("name") + self.owner: Optional[str] = payload.get("owner") + self.personality_prompt: Optional[str] = payload.get("personality_prompt") + self.segment_credential: Optional[ + AssistantList.AssistantsV1ServiceSegmentCredential + ] = payload.get("segment_credential") + + def to_dict(self): + return { + "customer_ai": ( + self.customer_ai.to_dict() if self.customer_ai is not None else None + ), + "name": self.name, + "owner": self.owner, + "personality_prompt": self.personality_prompt, + "segment_credential": ( + self.segment_credential.to_dict() + if self.segment_credential is not None + else None + ), + } + + def __init__(self, version: Version): + """ + Initialize the AssistantList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/Assistants" + + def create( + self, + assistants_v1_service_create_assistant_request: AssistantsV1ServiceCreateAssistantRequest, + ) -> 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" + + headers["Accept"] = "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" + + headers["Accept"] = "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, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return AssistantPage(self._version, response) + + async def page_async( + self, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> AssistantPage: + """ + Asynchronously retrieve a single page of AssistantInstance records from the API. + Request is executed immediately + + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: Page of AssistantInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + return AssistantPage(self._version, response) + + def 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/preview/sync/service/sync_list/__init__.py b/twilio/rest/assistants/v1/assistant/assistants_knowledge.py similarity index 53% rename from twilio/rest/preview/sync/service/sync_list/__init__.py rename to twilio/rest/assistants/v1/assistant/assistants_knowledge.py index fcd2f28ffe..681d71789b 100644 --- a/twilio/rest/preview/sync/service/sync_list/__init__.py +++ b/twilio/rest/assistants/v1/assistant/assistants_knowledge.py @@ -4,7 +4,7 @@ | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - Twilio - Preview + Twilio - Assistants This is the public Twilio REST API. NOTE: This class is auto generated by OpenAPI Generator. @@ -20,121 +20,107 @@ from twilio.base.list_resource import ListResource from twilio.base.version import Version from twilio.base.page import Page -from twilio.rest.preview.sync.service.sync_list.sync_list_item import SyncListItemList -from twilio.rest.preview.sync.service.sync_list.sync_list_permission import ( - SyncListPermissionList, -) -class SyncListInstance(InstanceResource): +class AssistantsKnowledgeInstance(InstanceResource): """ - :ivar sid: - :ivar unique_name: - :ivar account_sid: - :ivar service_sid: - :ivar url: - :ivar links: - :ivar revision: - :ivar date_created: - :ivar date_updated: - :ivar created_by: + :ivar description: The type of knowledge source. + :ivar id: The description of knowledge. + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Knowledge resource. + :ivar knowledge_source_details: The details of the knowledge source based on the type. + :ivar name: The name of the knowledge source. + :ivar status: The status of processing the knowledge source ('QUEUED', 'PROCESSING', 'COMPLETED', 'FAILED') + :ivar type: The type of knowledge source ('Web', 'Database', 'Text', 'File') + :ivar url: The url of the knowledge resource. + :ivar embedding_model: The embedding model to be used for the knowledge source. + :ivar date_created: The date and time in GMT when the Knowledge was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + :ivar date_updated: The date and time in GMT when the Knowledge was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. """ def __init__( self, version: Version, payload: Dict[str, Any], - service_sid: str, - sid: Optional[str] = None, + assistant_id: str, + id: Optional[str] = None, ): super().__init__(version) - self.sid: Optional[str] = payload.get("sid") - self.unique_name: Optional[str] = payload.get("unique_name") + self.description: Optional[str] = payload.get("description") + self.id: Optional[str] = payload.get("id") self.account_sid: Optional[str] = payload.get("account_sid") - self.service_sid: Optional[str] = payload.get("service_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.links: Optional[Dict[str, object]] = payload.get("links") - self.revision: Optional[str] = payload.get("revision") + self.embedding_model: Optional[str] = payload.get("embedding_model") self.date_created: Optional[datetime] = deserialize.iso8601_datetime( payload.get("date_created") ) self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( payload.get("date_updated") ) - self.created_by: Optional[str] = payload.get("created_by") self._solution = { - "service_sid": service_sid, - "sid": sid or self.sid, + "assistant_id": assistant_id, + "id": id or self.id, } - self._context: Optional[SyncListContext] = None + self._context: Optional[AssistantsKnowledgeContext] = None @property - def _proxy(self) -> "SyncListContext": + 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: SyncListContext for this SyncListInstance + :returns: AssistantsKnowledgeContext for this AssistantsKnowledgeInstance """ if self._context is None: - self._context = SyncListContext( + self._context = AssistantsKnowledgeContext( self._version, - service_sid=self._solution["service_sid"], - sid=self._solution["sid"], + assistant_id=self._solution["assistant_id"], + id=self._solution["id"], ) return self._context - def delete(self) -> bool: + def create(self) -> "AssistantsKnowledgeInstance": """ - Deletes the SyncListInstance + Create the AssistantsKnowledgeInstance - :returns: True if delete succeeds, False otherwise + :returns: The created AssistantsKnowledgeInstance """ - return self._proxy.delete() + return self._proxy.create() - async def delete_async(self) -> bool: + async def create_async(self) -> "AssistantsKnowledgeInstance": """ - Asynchronous coroutine that deletes the SyncListInstance + Asynchronous coroutine to create the AssistantsKnowledgeInstance - :returns: True if delete succeeds, False otherwise + :returns: The created AssistantsKnowledgeInstance """ - return await self._proxy.delete_async() + return await self._proxy.create_async() - def fetch(self) -> "SyncListInstance": + def delete(self) -> bool: """ - Fetch the SyncListInstance - + Deletes the AssistantsKnowledgeInstance - :returns: The fetched SyncListInstance - """ - return self._proxy.fetch() - async def fetch_async(self) -> "SyncListInstance": + :returns: True if delete succeeds, False otherwise """ - Asynchronous coroutine to fetch the SyncListInstance - + return self._proxy.delete() - :returns: The fetched SyncListInstance + async def delete_async(self) -> bool: """ - return await self._proxy.fetch_async() + Asynchronous coroutine that deletes the AssistantsKnowledgeInstance - @property - def sync_list_items(self) -> SyncListItemList: - """ - Access the sync_list_items - """ - return self._proxy.sync_list_items - @property - def sync_list_permissions(self) -> SyncListPermissionList: - """ - Access the sync_list_permissions + :returns: True if delete succeeds, False otherwise """ - return self._proxy.sync_list_permissions + return await self._proxy.delete_async() def __repr__(self) -> str: """ @@ -143,120 +129,91 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) - return "".format(context) + return "".format(context) -class SyncListContext(InstanceContext): +class AssistantsKnowledgeContext(InstanceContext): - def __init__(self, version: Version, service_sid: str, sid: str): + def __init__(self, version: Version, assistant_id: str, id: str): """ - Initialize the SyncListContext + Initialize the AssistantsKnowledgeContext :param version: Version that contains the resource - :param service_sid: - :param sid: + :param assistant_id: The assistant ID. + :param id: The knowledge ID. """ super().__init__(version) # Path Solution self._solution = { - "service_sid": service_sid, - "sid": sid, + "assistant_id": assistant_id, + "id": id, } - self._uri = "/Services/{service_sid}/Lists/{sid}".format(**self._solution) + self._uri = "/Assistants/{assistant_id}/Knowledge/{id}".format(**self._solution) - self._sync_list_items: Optional[SyncListItemList] = None - self._sync_list_permissions: Optional[SyncListPermissionList] = None - - def delete(self) -> bool: + def create(self) -> AssistantsKnowledgeInstance: """ - Deletes the SyncListInstance + Create the AssistantsKnowledgeInstance - :returns: True if delete succeeds, False otherwise + :returns: The created AssistantsKnowledgeInstance """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + data = values.of({}) - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the SyncListInstance + payload = self._version.create(method="POST", uri=self._uri, data=data) - - :returns: True if delete succeeds, False otherwise - """ - return await self._version.delete_async( - method="DELETE", - uri=self._uri, + return AssistantsKnowledgeInstance( + self._version, + payload, + assistant_id=self._solution["assistant_id"], + id=self._solution["id"], ) - def fetch(self) -> SyncListInstance: + async def create_async(self) -> AssistantsKnowledgeInstance: """ - Fetch the SyncListInstance + Asynchronous coroutine to create the AssistantsKnowledgeInstance - :returns: The fetched SyncListInstance + :returns: The created AssistantsKnowledgeInstance """ + data = values.of({}) - payload = self._version.fetch( - method="GET", - uri=self._uri, + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data ) - return SyncListInstance( + return AssistantsKnowledgeInstance( self._version, payload, - service_sid=self._solution["service_sid"], - sid=self._solution["sid"], + assistant_id=self._solution["assistant_id"], + id=self._solution["id"], ) - async def fetch_async(self) -> SyncListInstance: + def delete(self) -> bool: """ - Asynchronous coroutine to fetch the SyncListInstance + Deletes the AssistantsKnowledgeInstance - :returns: The fetched SyncListInstance + :returns: True if delete succeeds, False otherwise """ - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) + headers = values.of({}) - return SyncListInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - sid=self._solution["sid"], - ) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) - @property - def sync_list_items(self) -> SyncListItemList: - """ - Access the sync_list_items + async def delete_async(self) -> bool: """ - if self._sync_list_items is None: - self._sync_list_items = SyncListItemList( - self._version, - self._solution["service_sid"], - self._solution["sid"], - ) - return self._sync_list_items + Asynchronous coroutine that deletes the AssistantsKnowledgeInstance - @property - def sync_list_permissions(self) -> SyncListPermissionList: - """ - Access the sync_list_permissions + + :returns: True if delete succeeds, False otherwise """ - if self._sync_list_permissions is None: - self._sync_list_permissions = SyncListPermissionList( - self._version, - self._solution["service_sid"], - self._solution["sid"], - ) - return self._sync_list_permissions + + headers = values.of({}) + + return await self._version.delete_async( + method="DELETE", uri=self._uri, headers=headers + ) def __repr__(self) -> str: """ @@ -265,19 +222,19 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) - return "".format(context) + return "".format(context) -class SyncListPage(Page): +class AssistantsKnowledgePage(Page): - def get_instance(self, payload: Dict[str, Any]) -> SyncListInstance: + def get_instance(self, payload: Dict[str, Any]) -> AssistantsKnowledgeInstance: """ - Build an instance of SyncListInstance + Build an instance of AssistantsKnowledgeInstance :param payload: Payload response from the API """ - return SyncListInstance( - self._version, payload, service_sid=self._solution["service_sid"] + return AssistantsKnowledgeInstance( + self._version, payload, assistant_id=self._solution["assistant_id"] ) def __repr__(self) -> str: @@ -286,88 +243,68 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ - return "" + return "" -class SyncListList(ListResource): +class AssistantsKnowledgeList(ListResource): - def __init__(self, version: Version, service_sid: str): + def __init__(self, version: Version, assistant_id: str): """ - Initialize the SyncListList + Initialize the AssistantsKnowledgeList :param version: Version that contains the resource - :param service_sid: + :param assistant_id: The assistant ID. """ super().__init__(version) # Path Solution self._solution = { - "service_sid": service_sid, + "assistant_id": assistant_id, } - self._uri = "/Services/{service_sid}/Lists".format(**self._solution) + self._uri = "/Assistants/{assistant_id}/Knowledge".format(**self._solution) - def create( - self, unique_name: Union[str, object] = values.unset - ) -> SyncListInstance: + def create(self) -> AssistantsKnowledgeInstance: """ - Create the SyncListInstance + Create the AssistantsKnowledgeInstance - :param unique_name: - :returns: The created SyncListInstance + :returns: The created AssistantsKnowledgeInstance """ - data = values.of( - { - "UniqueName": unique_name, - } - ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) + payload = self._version.create(method="POST", uri=self._uri, headers=headers) - return SyncListInstance( - self._version, payload, service_sid=self._solution["service_sid"] + return AssistantsKnowledgeInstance( + self._version, payload, assistant_id=self._solution["assistant_id"] ) - async def create_async( - self, unique_name: Union[str, object] = values.unset - ) -> SyncListInstance: + async def create_async(self) -> AssistantsKnowledgeInstance: """ - Asynchronously create the SyncListInstance + Asynchronously create the AssistantsKnowledgeInstance - :param unique_name: - :returns: The created SyncListInstance + :returns: The created AssistantsKnowledgeInstance """ - data = values.of( - { - "UniqueName": unique_name, - } - ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, headers=headers ) - return SyncListInstance( - self._version, payload, service_sid=self._solution["service_sid"] + return AssistantsKnowledgeInstance( + self._version, payload, assistant_id=self._solution["assistant_id"] ) def stream( self, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> Iterator[SyncListInstance]: + ) -> Iterator[AssistantsKnowledgeInstance]: """ - Streams SyncListInstance records from the API as a generator stream. + 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. @@ -390,9 +327,9 @@ async def stream_async( self, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> AsyncIterator[SyncListInstance]: + ) -> AsyncIterator[AssistantsKnowledgeInstance]: """ - Asynchronously streams SyncListInstance records from the API as a generator stream. + 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. @@ -415,9 +352,9 @@ def list( self, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> List[SyncListInstance]: + ) -> List[AssistantsKnowledgeInstance]: """ - Lists SyncListInstance records from the API as a list. + Lists AssistantsKnowledgeInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @@ -441,9 +378,9 @@ async def list_async( self, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> List[SyncListInstance]: + ) -> List[AssistantsKnowledgeInstance]: """ - Asynchronously lists SyncListInstance records from the API as a list. + 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. @@ -469,16 +406,16 @@ def page( page_token: Union[str, object] = values.unset, page_number: Union[int, object] = values.unset, page_size: Union[int, object] = values.unset, - ) -> SyncListPage: + ) -> AssistantsKnowledgePage: """ - Retrieve a single page of SyncListInstance records from the API. + 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 SyncListInstance + :returns: Page of AssistantsKnowledgeInstance """ data = values.of( { @@ -488,24 +425,30 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) - return SyncListPage(self._version, response, self._solution) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return AssistantsKnowledgePage(self._version, response, self._solution) async def page_async( self, page_token: Union[str, object] = values.unset, page_number: Union[int, object] = values.unset, page_size: Union[int, object] = values.unset, - ) -> SyncListPage: + ) -> AssistantsKnowledgePage: """ - Asynchronously retrieve a single page of SyncListInstance records from the API. + 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 SyncListInstance + :returns: Page of AssistantsKnowledgeInstance """ data = values.of( { @@ -515,53 +458,57 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) - return SyncListPage(self._version, response, self._solution) + return AssistantsKnowledgePage(self._version, response, self._solution) - def get_page(self, target_url: str) -> SyncListPage: + def get_page(self, target_url: str) -> AssistantsKnowledgePage: """ - Retrieve a specific page of SyncListInstance records from the API. + 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 SyncListInstance + :returns: Page of AssistantsKnowledgeInstance """ response = self._version.domain.twilio.request("GET", target_url) - return SyncListPage(self._version, response, self._solution) + return AssistantsKnowledgePage(self._version, response, self._solution) - async def get_page_async(self, target_url: str) -> SyncListPage: + async def get_page_async(self, target_url: str) -> AssistantsKnowledgePage: """ - Asynchronously retrieve a specific page of SyncListInstance records from the API. + 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 SyncListInstance + :returns: Page of AssistantsKnowledgeInstance """ response = await self._version.domain.twilio.request_async("GET", target_url) - return SyncListPage(self._version, response, self._solution) + return AssistantsKnowledgePage(self._version, response, self._solution) - def get(self, sid: str) -> SyncListContext: + def get(self, id: str) -> AssistantsKnowledgeContext: """ - Constructs a SyncListContext + Constructs a AssistantsKnowledgeContext - :param sid: + :param id: The knowledge ID. """ - return SyncListContext( - self._version, service_sid=self._solution["service_sid"], sid=sid + return AssistantsKnowledgeContext( + self._version, assistant_id=self._solution["assistant_id"], id=id ) - def __call__(self, sid: str) -> SyncListContext: + def __call__(self, id: str) -> AssistantsKnowledgeContext: """ - Constructs a SyncListContext + Constructs a AssistantsKnowledgeContext - :param sid: + :param id: The knowledge ID. """ - return SyncListContext( - self._version, service_sid=self._solution["service_sid"], sid=sid + return AssistantsKnowledgeContext( + self._version, assistant_id=self._solution["assistant_id"], id=id ) def __repr__(self) -> str: @@ -570,4 +517,4 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ - return "" + return "" diff --git a/twilio/rest/preview/sync/service/sync_map/__init__.py b/twilio/rest/assistants/v1/assistant/assistants_tool.py similarity index 55% rename from twilio/rest/preview/sync/service/sync_map/__init__.py rename to twilio/rest/assistants/v1/assistant/assistants_tool.py index 1d79936240..ed02410d3c 100644 --- a/twilio/rest/preview/sync/service/sync_map/__init__.py +++ b/twilio/rest/assistants/v1/assistant/assistants_tool.py @@ -4,7 +4,7 @@ | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - Twilio - Preview + Twilio - Assistants This is the public Twilio REST API. NOTE: This class is auto generated by OpenAPI Generator. @@ -20,121 +20,105 @@ from twilio.base.list_resource import ListResource from twilio.base.version import Version from twilio.base.page import Page -from twilio.rest.preview.sync.service.sync_map.sync_map_item import SyncMapItemList -from twilio.rest.preview.sync.service.sync_map.sync_map_permission import ( - SyncMapPermissionList, -) -class SyncMapInstance(InstanceResource): +class AssistantsToolInstance(InstanceResource): """ - :ivar sid: - :ivar unique_name: - :ivar account_sid: - :ivar service_sid: - :ivar url: - :ivar links: - :ivar revision: - :ivar date_created: - :ivar date_updated: - :ivar created_by: + :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], - service_sid: str, - sid: Optional[str] = None, + assistant_id: str, + id: Optional[str] = None, ): super().__init__(version) - self.sid: Optional[str] = payload.get("sid") - self.unique_name: Optional[str] = payload.get("unique_name") self.account_sid: Optional[str] = payload.get("account_sid") - self.service_sid: Optional[str] = payload.get("service_sid") + self.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.links: Optional[Dict[str, object]] = payload.get("links") - self.revision: Optional[str] = payload.get("revision") self.date_created: Optional[datetime] = deserialize.iso8601_datetime( payload.get("date_created") ) self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( payload.get("date_updated") ) - self.created_by: Optional[str] = payload.get("created_by") self._solution = { - "service_sid": service_sid, - "sid": sid or self.sid, + "assistant_id": assistant_id, + "id": id or self.id, } - self._context: Optional[SyncMapContext] = None + self._context: Optional[AssistantsToolContext] = None @property - def _proxy(self) -> "SyncMapContext": + 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: SyncMapContext for this SyncMapInstance + :returns: AssistantsToolContext for this AssistantsToolInstance """ if self._context is None: - self._context = SyncMapContext( + self._context = AssistantsToolContext( self._version, - service_sid=self._solution["service_sid"], - sid=self._solution["sid"], + assistant_id=self._solution["assistant_id"], + id=self._solution["id"], ) return self._context - def delete(self) -> bool: + def create(self) -> "AssistantsToolInstance": """ - Deletes the SyncMapInstance + Create the AssistantsToolInstance - :returns: True if delete succeeds, False otherwise + :returns: The created AssistantsToolInstance """ - return self._proxy.delete() + return self._proxy.create() - async def delete_async(self) -> bool: + async def create_async(self) -> "AssistantsToolInstance": """ - Asynchronous coroutine that deletes the SyncMapInstance + Asynchronous coroutine to create the AssistantsToolInstance - :returns: True if delete succeeds, False otherwise + :returns: The created AssistantsToolInstance """ - return await self._proxy.delete_async() + return await self._proxy.create_async() - def fetch(self) -> "SyncMapInstance": + def delete(self) -> bool: """ - Fetch the SyncMapInstance + Deletes the AssistantsToolInstance - :returns: The fetched SyncMapInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "SyncMapInstance": + :returns: True if delete succeeds, False otherwise """ - Asynchronous coroutine to fetch the SyncMapInstance - + return self._proxy.delete() - :returns: The fetched SyncMapInstance + async def delete_async(self) -> bool: """ - return await self._proxy.fetch_async() + Asynchronous coroutine that deletes the AssistantsToolInstance - @property - def sync_map_items(self) -> SyncMapItemList: - """ - Access the sync_map_items - """ - return self._proxy.sync_map_items - @property - def sync_map_permissions(self) -> SyncMapPermissionList: - """ - Access the sync_map_permissions + :returns: True if delete succeeds, False otherwise """ - return self._proxy.sync_map_permissions + return await self._proxy.delete_async() def __repr__(self) -> str: """ @@ -143,120 +127,91 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) - return "".format(context) + return "".format(context) -class SyncMapContext(InstanceContext): +class AssistantsToolContext(InstanceContext): - def __init__(self, version: Version, service_sid: str, sid: str): + def __init__(self, version: Version, assistant_id: str, id: str): """ - Initialize the SyncMapContext + Initialize the AssistantsToolContext :param version: Version that contains the resource - :param service_sid: - :param sid: + :param assistant_id: The assistant ID. + :param id: The tool ID. """ super().__init__(version) # Path Solution self._solution = { - "service_sid": service_sid, - "sid": sid, + "assistant_id": assistant_id, + "id": id, } - self._uri = "/Services/{service_sid}/Maps/{sid}".format(**self._solution) + self._uri = "/Assistants/{assistant_id}/Tools/{id}".format(**self._solution) - self._sync_map_items: Optional[SyncMapItemList] = None - self._sync_map_permissions: Optional[SyncMapPermissionList] = None - - def delete(self) -> bool: + def create(self) -> AssistantsToolInstance: """ - Deletes the SyncMapInstance + Create the AssistantsToolInstance - :returns: True if delete succeeds, False otherwise + :returns: The created AssistantsToolInstance """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + data = values.of({}) - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the SyncMapInstance + payload = self._version.create(method="POST", uri=self._uri, data=data) - - :returns: True if delete succeeds, False otherwise - """ - return await self._version.delete_async( - method="DELETE", - uri=self._uri, + return AssistantsToolInstance( + self._version, + payload, + assistant_id=self._solution["assistant_id"], + id=self._solution["id"], ) - def fetch(self) -> SyncMapInstance: + async def create_async(self) -> AssistantsToolInstance: """ - Fetch the SyncMapInstance + Asynchronous coroutine to create the AssistantsToolInstance - :returns: The fetched SyncMapInstance + :returns: The created AssistantsToolInstance """ + data = values.of({}) - payload = self._version.fetch( - method="GET", - uri=self._uri, + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data ) - return SyncMapInstance( + return AssistantsToolInstance( self._version, payload, - service_sid=self._solution["service_sid"], - sid=self._solution["sid"], + assistant_id=self._solution["assistant_id"], + id=self._solution["id"], ) - async def fetch_async(self) -> SyncMapInstance: + def delete(self) -> bool: """ - Asynchronous coroutine to fetch the SyncMapInstance + Deletes the AssistantsToolInstance - :returns: The fetched SyncMapInstance + :returns: True if delete succeeds, False otherwise """ - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) + headers = values.of({}) - return SyncMapInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - sid=self._solution["sid"], - ) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) - @property - def sync_map_items(self) -> SyncMapItemList: - """ - Access the sync_map_items + async def delete_async(self) -> bool: """ - if self._sync_map_items is None: - self._sync_map_items = SyncMapItemList( - self._version, - self._solution["service_sid"], - self._solution["sid"], - ) - return self._sync_map_items + Asynchronous coroutine that deletes the AssistantsToolInstance - @property - def sync_map_permissions(self) -> SyncMapPermissionList: - """ - Access the sync_map_permissions + + :returns: True if delete succeeds, False otherwise """ - if self._sync_map_permissions is None: - self._sync_map_permissions = SyncMapPermissionList( - self._version, - self._solution["service_sid"], - self._solution["sid"], - ) - return self._sync_map_permissions + + headers = values.of({}) + + return await self._version.delete_async( + method="DELETE", uri=self._uri, headers=headers + ) def __repr__(self) -> str: """ @@ -265,19 +220,19 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) - return "".format(context) + return "".format(context) -class SyncMapPage(Page): +class AssistantsToolPage(Page): - def get_instance(self, payload: Dict[str, Any]) -> SyncMapInstance: + def get_instance(self, payload: Dict[str, Any]) -> AssistantsToolInstance: """ - Build an instance of SyncMapInstance + Build an instance of AssistantsToolInstance :param payload: Payload response from the API """ - return SyncMapInstance( - self._version, payload, service_sid=self._solution["service_sid"] + return AssistantsToolInstance( + self._version, payload, assistant_id=self._solution["assistant_id"] ) def __repr__(self) -> str: @@ -286,86 +241,68 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ - return "" + return "" -class SyncMapList(ListResource): +class AssistantsToolList(ListResource): - def __init__(self, version: Version, service_sid: str): + def __init__(self, version: Version, assistant_id: str): """ - Initialize the SyncMapList + Initialize the AssistantsToolList :param version: Version that contains the resource - :param service_sid: + :param assistant_id: The assistant ID. """ super().__init__(version) # Path Solution self._solution = { - "service_sid": service_sid, + "assistant_id": assistant_id, } - self._uri = "/Services/{service_sid}/Maps".format(**self._solution) + self._uri = "/Assistants/{assistant_id}/Tools".format(**self._solution) - def create(self, unique_name: Union[str, object] = values.unset) -> SyncMapInstance: + def create(self) -> AssistantsToolInstance: """ - Create the SyncMapInstance + Create the AssistantsToolInstance - :param unique_name: - :returns: The created SyncMapInstance + :returns: The created AssistantsToolInstance """ - data = values.of( - { - "UniqueName": unique_name, - } - ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) + payload = self._version.create(method="POST", uri=self._uri, headers=headers) - return SyncMapInstance( - self._version, payload, service_sid=self._solution["service_sid"] + return AssistantsToolInstance( + self._version, payload, assistant_id=self._solution["assistant_id"] ) - async def create_async( - self, unique_name: Union[str, object] = values.unset - ) -> SyncMapInstance: + async def create_async(self) -> AssistantsToolInstance: """ - Asynchronously create the SyncMapInstance + Asynchronously create the AssistantsToolInstance - :param unique_name: - :returns: The created SyncMapInstance + :returns: The created AssistantsToolInstance """ - data = values.of( - { - "UniqueName": unique_name, - } - ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, headers=headers ) - return SyncMapInstance( - self._version, payload, service_sid=self._solution["service_sid"] + return AssistantsToolInstance( + self._version, payload, assistant_id=self._solution["assistant_id"] ) def stream( self, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> Iterator[SyncMapInstance]: + ) -> Iterator[AssistantsToolInstance]: """ - Streams SyncMapInstance records from the API as a generator stream. + 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. @@ -388,9 +325,9 @@ async def stream_async( self, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> AsyncIterator[SyncMapInstance]: + ) -> AsyncIterator[AssistantsToolInstance]: """ - Asynchronously streams SyncMapInstance records from the API as a generator stream. + 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. @@ -413,9 +350,9 @@ def list( self, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> List[SyncMapInstance]: + ) -> List[AssistantsToolInstance]: """ - Lists SyncMapInstance records from the API as a list. + Lists AssistantsToolInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @@ -439,9 +376,9 @@ async def list_async( self, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> List[SyncMapInstance]: + ) -> List[AssistantsToolInstance]: """ - Asynchronously lists SyncMapInstance records from the API as a list. + 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. @@ -467,16 +404,16 @@ def page( page_token: Union[str, object] = values.unset, page_number: Union[int, object] = values.unset, page_size: Union[int, object] = values.unset, - ) -> SyncMapPage: + ) -> AssistantsToolPage: """ - Retrieve a single page of SyncMapInstance records from the API. + 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 SyncMapInstance + :returns: Page of AssistantsToolInstance """ data = values.of( { @@ -486,24 +423,30 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) - return SyncMapPage(self._version, response, self._solution) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return AssistantsToolPage(self._version, response, self._solution) async def page_async( self, page_token: Union[str, object] = values.unset, page_number: Union[int, object] = values.unset, page_size: Union[int, object] = values.unset, - ) -> SyncMapPage: + ) -> AssistantsToolPage: """ - Asynchronously retrieve a single page of SyncMapInstance records from the API. + 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 SyncMapInstance + :returns: Page of AssistantsToolInstance """ data = values.of( { @@ -513,53 +456,57 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) - return SyncMapPage(self._version, response, self._solution) + return AssistantsToolPage(self._version, response, self._solution) - def get_page(self, target_url: str) -> SyncMapPage: + def get_page(self, target_url: str) -> AssistantsToolPage: """ - Retrieve a specific page of SyncMapInstance records from the API. + 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 SyncMapInstance + :returns: Page of AssistantsToolInstance """ response = self._version.domain.twilio.request("GET", target_url) - return SyncMapPage(self._version, response, self._solution) + return AssistantsToolPage(self._version, response, self._solution) - async def get_page_async(self, target_url: str) -> SyncMapPage: + async def get_page_async(self, target_url: str) -> AssistantsToolPage: """ - Asynchronously retrieve a specific page of SyncMapInstance records from the API. + 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 SyncMapInstance + :returns: Page of AssistantsToolInstance """ response = await self._version.domain.twilio.request_async("GET", target_url) - return SyncMapPage(self._version, response, self._solution) + return AssistantsToolPage(self._version, response, self._solution) - def get(self, sid: str) -> SyncMapContext: + def get(self, id: str) -> AssistantsToolContext: """ - Constructs a SyncMapContext + Constructs a AssistantsToolContext - :param sid: + :param id: The tool ID. """ - return SyncMapContext( - self._version, service_sid=self._solution["service_sid"], sid=sid + return AssistantsToolContext( + self._version, assistant_id=self._solution["assistant_id"], id=id ) - def __call__(self, sid: str) -> SyncMapContext: + def __call__(self, id: str) -> AssistantsToolContext: """ - Constructs a SyncMapContext + Constructs a AssistantsToolContext - :param sid: + :param id: The tool ID. """ - return SyncMapContext( - self._version, service_sid=self._solution["service_sid"], sid=sid + return AssistantsToolContext( + self._version, assistant_id=self._solution["assistant_id"], id=id ) def __repr__(self) -> str: @@ -568,4 +515,4 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ - return "" + return "" diff --git a/twilio/rest/assistants/v1/assistant/feedback.py b/twilio/rest/assistants/v1/assistant/feedback.py new file mode 100644 index 0000000000..77c6d405f4 --- /dev/null +++ b/twilio/rest/assistants/v1/assistant/feedback.py @@ -0,0 +1,404 @@ +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): + + class AssistantsV1ServiceCreateFeedbackRequest(object): + """ + :ivar message_id: The message ID. + :ivar score: The score to be given(0-1). + :ivar session_id: The Session ID. + :ivar text: The text to be given as feedback. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.message_id: Optional[str] = payload.get("message_id") + self.score: Optional[float] = payload.get("score") + self.session_id: Optional[str] = payload.get("session_id") + self.text: Optional[str] = payload.get("text") + + def to_dict(self): + return { + "message_id": self.message_id, + "score": self.score, + "session_id": self.session_id, + "text": self.text, + } + + """ + :ivar assistant_id: The Assistant ID. + :ivar id: The Feedback ID. + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Feedback. + :ivar user_sid: The SID of the User created the Feedback. + :ivar message_id: The Message ID. + :ivar score: The Score to provide as Feedback (0-1) + :ivar session_id: The Session ID. + :ivar text: The text to be given as feedback. + :ivar date_created: The date and time in GMT when the Feedback was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + :ivar date_updated: The date and time in GMT when the Feedback was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + """ + + def __init__(self, version: Version, payload: Dict[str, Any], id: str): + super().__init__(version) + + self.assistant_id: Optional[str] = payload.get("assistant_id") + self.id: Optional[str] = payload.get("id") + self.account_sid: Optional[str] = payload.get("account_sid") + self.user_sid: Optional[str] = payload.get("user_sid") + self.message_id: Optional[str] = payload.get("message_id") + self.score: Optional[float] = payload.get("score") + self.session_id: Optional[str] = payload.get("session_id") + self.text: Optional[str] = payload.get("text") + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_created") + ) + self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_updated") + ) + + self._solution = { + "id": id, + } + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class FeedbackPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> FeedbackInstance: + """ + Build an instance of FeedbackInstance + + :param payload: Payload response from the API + """ + return FeedbackInstance(self._version, payload, id=self._solution["id"]) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class FeedbackList(ListResource): + + class AssistantsV1ServiceCreateFeedbackRequest(object): + """ + :ivar message_id: The message ID. + :ivar score: The score to be given(0-1). + :ivar session_id: The Session ID. + :ivar text: The text to be given as feedback. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.message_id: Optional[str] = payload.get("message_id") + self.score: Optional[float] = payload.get("score") + self.session_id: Optional[str] = payload.get("session_id") + self.text: Optional[str] = payload.get("text") + + def to_dict(self): + return { + "message_id": self.message_id, + "score": self.score, + "session_id": self.session_id, + "text": self.text, + } + + def __init__(self, version: Version, id: str): + """ + Initialize the FeedbackList + + :param version: Version that contains the resource + :param id: The assistant ID. + + """ + super().__init__(version) + + # Path Solution + self._solution = { + "id": id, + } + self._uri = "/Assistants/{id}/Feedbacks".format(**self._solution) + + def create( + self, + assistants_v1_service_create_feedback_request: AssistantsV1ServiceCreateFeedbackRequest, + ) -> 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" + + headers["Accept"] = "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" + + headers["Accept"] = "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, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return FeedbackPage(self._version, response, self._solution) + + async def page_async( + self, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> FeedbackPage: + """ + Asynchronously retrieve a single page of FeedbackInstance records from the API. + Request is executed immediately + + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: Page of FeedbackInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + return FeedbackPage(self._version, response, 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/assistant/message.py b/twilio/rest/assistants/v1/assistant/message.py new file mode 100644 index 0000000000..11d73776b7 --- /dev/null +++ b/twilio/rest/assistants/v1/assistant/message.py @@ -0,0 +1,186 @@ +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): + + class AssistantsV1ServiceAssistantSendMessageRequest(object): + """ + :ivar identity: The unique identity of user for the session. + :ivar session_id: The unique name for the session. + :ivar body: The query to ask the assistant. + :ivar webhook: The webhook url to call after the assistant has generated a response or report an error. + :ivar mode: one of the modes 'chat', 'email' or 'voice' + """ + + def __init__(self, payload: Dict[str, Any]): + + self.identity: Optional[str] = payload.get("identity") + self.session_id: Optional[str] = payload.get("session_id") + self.body: Optional[str] = payload.get("body") + self.webhook: Optional[str] = payload.get("webhook") + self.mode: Optional[str] = payload.get("mode") + + def to_dict(self): + return { + "identity": self.identity, + "session_id": self.session_id, + "body": self.body, + "webhook": self.webhook, + "mode": self.mode, + } + + """ + :ivar status: success or failure based on whether the request successfully generated a response. + :ivar flagged: If successful, this property will denote whether the response was flagged or not. + :ivar aborted: This property will denote whether the request was aborted or not. + :ivar session_id: The unique name for the session. + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that sent the Message. + :ivar body: If successful, the body of the generated response + :ivar error: The error message if generation was not successful + """ + + def __init__(self, version: Version, payload: Dict[str, Any], id: str): + super().__init__(version) + + self.status: Optional[str] = payload.get("status") + self.flagged: Optional[bool] = payload.get("flagged") + self.aborted: Optional[bool] = payload.get("aborted") + self.session_id: Optional[str] = payload.get("session_id") + self.account_sid: Optional[str] = payload.get("account_sid") + self.body: Optional[str] = payload.get("body") + self.error: Optional[str] = payload.get("error") + + self._solution = { + "id": id, + } + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class MessageList(ListResource): + + class AssistantsV1ServiceAssistantSendMessageRequest(object): + """ + :ivar identity: The unique identity of user for the session. + :ivar session_id: The unique name for the session. + :ivar body: The query to ask the assistant. + :ivar webhook: The webhook url to call after the assistant has generated a response or report an error. + :ivar mode: one of the modes 'chat', 'email' or 'voice' + """ + + def __init__(self, payload: Dict[str, Any]): + + self.identity: Optional[str] = payload.get("identity") + self.session_id: Optional[str] = payload.get("session_id") + self.body: Optional[str] = payload.get("body") + self.webhook: Optional[str] = payload.get("webhook") + self.mode: Optional[str] = payload.get("mode") + + def to_dict(self): + return { + "identity": self.identity, + "session_id": self.session_id, + "body": self.body, + "webhook": self.webhook, + "mode": self.mode, + } + + def __init__(self, version: Version, id: str): + """ + Initialize the MessageList + + :param version: Version that contains the resource + :param id: the Assistant ID. + + """ + super().__init__(version) + + # Path Solution + self._solution = { + "id": id, + } + self._uri = "/Assistants/{id}/Messages".format(**self._solution) + + def create( + self, + assistants_v1_service_assistant_send_message_request: AssistantsV1ServiceAssistantSendMessageRequest, + ) -> 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" + + headers["Accept"] = "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" + + headers["Accept"] = "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 new file mode 100644 index 0000000000..7d616f8682 --- /dev/null +++ b/twilio/rest/assistants/v1/knowledge/__init__.py @@ -0,0 +1,962 @@ +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 +from twilio.rest.assistants.v1.knowledge.knowledge_status import KnowledgeStatusList + + +class KnowledgeInstance(InstanceResource): + + class AssistantsV1ServiceCreateKnowledgeRequest(object): + """ + :ivar assistant_id: The Assistant ID. + :ivar description: The description of the knowledge source. + :ivar knowledge_source_details: The details of the knowledge source based on the type. + :ivar name: The name of the tool. + :ivar policy: + :ivar type: The type of the knowledge source. + :ivar embedding_model: The embedding model to be used for the knowledge source. It's required for 'Database' type but disallowed for other types. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.assistant_id: Optional[str] = payload.get("assistant_id") + self.description: Optional[str] = payload.get("description") + self.knowledge_source_details: Optional[Dict[str, object]] = payload.get( + "knowledge_source_details" + ) + self.name: Optional[str] = payload.get("name") + self.policy: Optional[ + KnowledgeList.AssistantsV1ServiceCreatePolicyRequest + ] = payload.get("policy") + self.type: Optional[str] = payload.get("type") + self.embedding_model: Optional[str] = payload.get("embedding_model") + + def to_dict(self): + return { + "assistant_id": self.assistant_id, + "description": self.description, + "knowledge_source_details": self.knowledge_source_details, + "name": self.name, + "policy": self.policy.to_dict() if self.policy is not None else None, + "type": self.type, + "embedding_model": self.embedding_model, + } + + class AssistantsV1ServiceCreatePolicyRequest(object): + """ + :ivar description: The description of the policy. + :ivar id: The Policy ID. + :ivar name: The name of the policy. + :ivar policy_details: + :ivar type: The description of the policy. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.description: Optional[str] = payload.get("description") + self.id: Optional[str] = payload.get("id") + self.name: Optional[str] = payload.get("name") + self.policy_details: Optional[Dict[str, object]] = payload.get( + "policy_details" + ) + self.type: Optional[str] = payload.get("type") + + def to_dict(self): + return { + "description": self.description, + "id": self.id, + "name": self.name, + "policy_details": self.policy_details, + "type": self.type, + } + + class AssistantsV1ServiceUpdateKnowledgeRequest(object): + """ + :ivar description: The description of the knowledge source. + :ivar knowledge_source_details: The details of the knowledge source based on the type. + :ivar name: The name of the knowledge source. + :ivar policy: + :ivar type: The description of the knowledge source. + :ivar embedding_model: The embedding model to be used for the knowledge source. It's only applicable to 'Database' type. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.description: Optional[str] = payload.get("description") + self.knowledge_source_details: Optional[Dict[str, object]] = payload.get( + "knowledge_source_details" + ) + self.name: Optional[str] = payload.get("name") + self.policy: Optional[ + KnowledgeList.AssistantsV1ServiceCreatePolicyRequest + ] = payload.get("policy") + self.type: Optional[str] = payload.get("type") + self.embedding_model: Optional[str] = payload.get("embedding_model") + + def to_dict(self): + return { + "description": self.description, + "knowledge_source_details": self.knowledge_source_details, + "name": self.name, + "policy": self.policy.to_dict() if self.policy is not None else None, + "type": self.type, + "embedding_model": self.embedding_model, + } + + """ + :ivar description: The type of knowledge source. + :ivar id: The description of knowledge. + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Knowledge resource. + :ivar knowledge_source_details: The details of the knowledge source based on the type. + :ivar name: The name of the knowledge source. + :ivar status: The status of processing the knowledge source ('QUEUED', 'PROCESSING', 'COMPLETED', 'FAILED') + :ivar type: The type of knowledge source ('Web', 'Database', 'Text', 'File') + :ivar url: The url of the knowledge resource. + :ivar embedding_model: The embedding model to be used for the knowledge source. + :ivar date_created: The date and time in GMT when the Knowledge was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + :ivar date_updated: The date and time in GMT when the Knowledge was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + """ + + def __init__( + self, version: Version, payload: Dict[str, Any], id: Optional[str] = None + ): + super().__init__(version) + + self.description: Optional[str] = payload.get("description") + self.id: Optional[str] = payload.get("id") + self.account_sid: Optional[str] = payload.get("account_sid") + self.knowledge_source_details: Optional[Dict[str, object]] = payload.get( + "knowledge_source_details" + ) + self.name: Optional[str] = payload.get("name") + self.status: Optional[str] = payload.get("status") + self.type: Optional[str] = payload.get("type") + self.url: Optional[str] = payload.get("url") + self.embedding_model: Optional[str] = payload.get("embedding_model") + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_created") + ) + self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_updated") + ) + + self._solution = { + "id": id or self.id, + } + self._context: Optional[KnowledgeContext] = None + + @property + def _proxy(self) -> "KnowledgeContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: KnowledgeContext for this KnowledgeInstance + """ + if self._context is None: + self._context = KnowledgeContext( + self._version, + id=self._solution["id"], + ) + return self._context + + def delete(self) -> bool: + """ + Deletes the KnowledgeInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._proxy.delete() + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the KnowledgeInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._proxy.delete_async() + + def 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 + + @property + def knowledge_status(self) -> KnowledgeStatusList: + """ + Access the knowledge_status + """ + return self._proxy.knowledge_status + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class KnowledgeContext(InstanceContext): + + class AssistantsV1ServiceCreateKnowledgeRequest(object): + """ + :ivar assistant_id: The Assistant ID. + :ivar description: The description of the knowledge source. + :ivar knowledge_source_details: The details of the knowledge source based on the type. + :ivar name: The name of the tool. + :ivar policy: + :ivar type: The type of the knowledge source. + :ivar embedding_model: The embedding model to be used for the knowledge source. It's required for 'Database' type but disallowed for other types. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.assistant_id: Optional[str] = payload.get("assistant_id") + self.description: Optional[str] = payload.get("description") + self.knowledge_source_details: Optional[Dict[str, object]] = payload.get( + "knowledge_source_details" + ) + self.name: Optional[str] = payload.get("name") + self.policy: Optional[ + KnowledgeList.AssistantsV1ServiceCreatePolicyRequest + ] = payload.get("policy") + self.type: Optional[str] = payload.get("type") + self.embedding_model: Optional[str] = payload.get("embedding_model") + + def to_dict(self): + return { + "assistant_id": self.assistant_id, + "description": self.description, + "knowledge_source_details": self.knowledge_source_details, + "name": self.name, + "policy": self.policy.to_dict() if self.policy is not None else None, + "type": self.type, + "embedding_model": self.embedding_model, + } + + class AssistantsV1ServiceCreatePolicyRequest(object): + """ + :ivar description: The description of the policy. + :ivar id: The Policy ID. + :ivar name: The name of the policy. + :ivar policy_details: + :ivar type: The description of the policy. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.description: Optional[str] = payload.get("description") + self.id: Optional[str] = payload.get("id") + self.name: Optional[str] = payload.get("name") + self.policy_details: Optional[Dict[str, object]] = payload.get( + "policy_details" + ) + self.type: Optional[str] = payload.get("type") + + def to_dict(self): + return { + "description": self.description, + "id": self.id, + "name": self.name, + "policy_details": self.policy_details, + "type": self.type, + } + + class AssistantsV1ServiceUpdateKnowledgeRequest(object): + """ + :ivar description: The description of the knowledge source. + :ivar knowledge_source_details: The details of the knowledge source based on the type. + :ivar name: The name of the knowledge source. + :ivar policy: + :ivar type: The description of the knowledge source. + :ivar embedding_model: The embedding model to be used for the knowledge source. It's only applicable to 'Database' type. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.description: Optional[str] = payload.get("description") + self.knowledge_source_details: Optional[Dict[str, object]] = payload.get( + "knowledge_source_details" + ) + self.name: Optional[str] = payload.get("name") + self.policy: Optional[ + KnowledgeList.AssistantsV1ServiceCreatePolicyRequest + ] = payload.get("policy") + self.type: Optional[str] = payload.get("type") + self.embedding_model: Optional[str] = payload.get("embedding_model") + + def to_dict(self): + return { + "description": self.description, + "knowledge_source_details": self.knowledge_source_details, + "name": self.name, + "policy": self.policy.to_dict() if self.policy is not None else None, + "type": self.type, + "embedding_model": self.embedding_model, + } + + def __init__(self, version: Version, id: str): + """ + Initialize the KnowledgeContext + + :param version: Version that contains the resource + :param id: + """ + super().__init__(version) + + # Path Solution + self._solution = { + "id": id, + } + self._uri = "/Knowledge/{id}".format(**self._solution) + + self._chunks: Optional[ChunkList] = None + self._knowledge_status: Optional[KnowledgeStatusList] = None + + def delete(self) -> bool: + """ + Deletes the KnowledgeInstance + + + :returns: True if delete succeeds, False otherwise + """ + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the KnowledgeInstance + + + :returns: True if delete succeeds, False otherwise + """ + + headers = values.of({}) + + return await self._version.delete_async( + method="DELETE", uri=self._uri, headers=headers + ) + + def fetch(self) -> KnowledgeInstance: + """ + Fetch the KnowledgeInstance + + + :returns: The fetched KnowledgeInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return KnowledgeInstance( + self._version, + payload, + id=self._solution["id"], + ) + + async def fetch_async(self) -> KnowledgeInstance: + """ + Asynchronous coroutine to fetch the KnowledgeInstance + + + :returns: The fetched KnowledgeInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + return KnowledgeInstance( + self._version, + payload, + id=self._solution["id"], + ) + + def update( + self, + 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 = assistants_v1_service_update_knowledge_request.to_dict() + + headers = values.of({}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + payload = self._version.update( + method="PUT", uri=self._uri, data=data, headers=headers + ) + + return KnowledgeInstance(self._version, payload, id=self._solution["id"]) + + async def update_async( + self, + 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 = assistants_v1_service_update_knowledge_request.to_dict() + + headers = values.of({}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + payload = await self._version.update_async( + method="PUT", uri=self._uri, data=data, headers=headers + ) + + return KnowledgeInstance(self._version, payload, id=self._solution["id"]) + + @property + def chunks(self) -> ChunkList: + """ + Access the chunks + """ + if self._chunks is None: + self._chunks = ChunkList( + self._version, + self._solution["id"], + ) + return self._chunks + + @property + def knowledge_status(self) -> KnowledgeStatusList: + """ + Access the knowledge_status + """ + if self._knowledge_status is None: + self._knowledge_status = KnowledgeStatusList( + self._version, + self._solution["id"], + ) + return self._knowledge_status + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class KnowledgePage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> KnowledgeInstance: + """ + Build an instance of KnowledgeInstance + + :param payload: Payload response from the API + """ + return KnowledgeInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class KnowledgeList(ListResource): + + class AssistantsV1ServiceCreateKnowledgeRequest(object): + """ + :ivar assistant_id: The Assistant ID. + :ivar description: The description of the knowledge source. + :ivar knowledge_source_details: The details of the knowledge source based on the type. + :ivar name: The name of the tool. + :ivar policy: + :ivar type: The type of the knowledge source. + :ivar embedding_model: The embedding model to be used for the knowledge source. It's required for 'Database' type but disallowed for other types. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.assistant_id: Optional[str] = payload.get("assistant_id") + self.description: Optional[str] = payload.get("description") + self.knowledge_source_details: Optional[Dict[str, object]] = payload.get( + "knowledge_source_details" + ) + self.name: Optional[str] = payload.get("name") + self.policy: Optional[ + KnowledgeList.AssistantsV1ServiceCreatePolicyRequest + ] = payload.get("policy") + self.type: Optional[str] = payload.get("type") + self.embedding_model: Optional[str] = payload.get("embedding_model") + + def to_dict(self): + return { + "assistant_id": self.assistant_id, + "description": self.description, + "knowledge_source_details": self.knowledge_source_details, + "name": self.name, + "policy": self.policy.to_dict() if self.policy is not None else None, + "type": self.type, + "embedding_model": self.embedding_model, + } + + class AssistantsV1ServiceCreatePolicyRequest(object): + """ + :ivar description: The description of the policy. + :ivar id: The Policy ID. + :ivar name: The name of the policy. + :ivar policy_details: + :ivar type: The description of the policy. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.description: Optional[str] = payload.get("description") + self.id: Optional[str] = payload.get("id") + self.name: Optional[str] = payload.get("name") + self.policy_details: Optional[Dict[str, object]] = payload.get( + "policy_details" + ) + self.type: Optional[str] = payload.get("type") + + def to_dict(self): + return { + "description": self.description, + "id": self.id, + "name": self.name, + "policy_details": self.policy_details, + "type": self.type, + } + + class AssistantsV1ServiceUpdateKnowledgeRequest(object): + """ + :ivar description: The description of the knowledge source. + :ivar knowledge_source_details: The details of the knowledge source based on the type. + :ivar name: The name of the knowledge source. + :ivar policy: + :ivar type: The description of the knowledge source. + :ivar embedding_model: The embedding model to be used for the knowledge source. It's only applicable to 'Database' type. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.description: Optional[str] = payload.get("description") + self.knowledge_source_details: Optional[Dict[str, object]] = payload.get( + "knowledge_source_details" + ) + self.name: Optional[str] = payload.get("name") + self.policy: Optional[ + KnowledgeList.AssistantsV1ServiceCreatePolicyRequest + ] = payload.get("policy") + self.type: Optional[str] = payload.get("type") + self.embedding_model: Optional[str] = payload.get("embedding_model") + + def to_dict(self): + return { + "description": self.description, + "knowledge_source_details": self.knowledge_source_details, + "name": self.name, + "policy": self.policy.to_dict() if self.policy is not None else None, + "type": self.type, + "embedding_model": self.embedding_model, + } + + def __init__(self, version: Version): + """ + Initialize the KnowledgeList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/Knowledge" + + def create( + self, + assistants_v1_service_create_knowledge_request: AssistantsV1ServiceCreateKnowledgeRequest, + ) -> 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" + + headers["Accept"] = "application/json" + + payload = self._version.create( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return KnowledgeInstance(self._version, payload) + + async def create_async( + self, + 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" + + headers["Accept"] = "application/json" + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return KnowledgeInstance(self._version, payload) + + def stream( + self, + 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, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return KnowledgePage(self._version, response) + + async def page_async( + self, + assistant_id: Union[str, object] = values.unset, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> KnowledgePage: + """ + Asynchronously retrieve a single page of KnowledgeInstance records from the API. + Request is executed immediately + + :param assistant_id: + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: Page of KnowledgeInstance + """ + data = values.of( + { + "AssistantId": assistant_id, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + return KnowledgePage(self._version, response) + + def 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 0000000000..be90a7626e --- /dev/null +++ b/twilio/rest/assistants/v1/knowledge/chunk.py @@ -0,0 +1,297 @@ +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, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return ChunkPage(self._version, response, self._solution) + + async def page_async( + self, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> ChunkPage: + """ + Asynchronously retrieve a single page of ChunkInstance records from the API. + Request is executed immediately + + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: Page of ChunkInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + return ChunkPage(self._version, response, self._solution) + + def get_page(self, target_url: str) -> ChunkPage: + """ + Retrieve a specific page of ChunkInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of ChunkInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return ChunkPage(self._version, response, self._solution) + + async def get_page_async(self, target_url: str) -> ChunkPage: + """ + Asynchronously retrieve a specific page of ChunkInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of ChunkInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return ChunkPage(self._version, response, self._solution) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/assistants/v1/knowledge/knowledge_status.py b/twilio/rest/assistants/v1/knowledge/knowledge_status.py new file mode 100644 index 0000000000..fedbcaad25 --- /dev/null +++ b/twilio/rest/assistants/v1/knowledge/knowledge_status.py @@ -0,0 +1,196 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Assistants + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from datetime import datetime +from typing import Any, Dict, Optional +from twilio.base import deserialize, values +from twilio.base.instance_context import InstanceContext +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + + +class KnowledgeStatusInstance(InstanceResource): + """ + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Knowledge resource. + :ivar status: The status of processing the knowledge source ('QUEUED', 'PROCESSING', 'COMPLETED', 'FAILED') + :ivar last_status: The last status of processing the knowledge source ('QUEUED', 'PROCESSING', 'COMPLETED', 'FAILED') + :ivar date_updated: The date and time in GMT when the Knowledge was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + """ + + def __init__(self, version: Version, payload: Dict[str, Any], id: str): + super().__init__(version) + + self.account_sid: Optional[str] = payload.get("account_sid") + self.status: Optional[str] = payload.get("status") + self.last_status: Optional[str] = payload.get("last_status") + self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_updated") + ) + + self._solution = { + "id": id, + } + self._context: Optional[KnowledgeStatusContext] = None + + @property + def _proxy(self) -> "KnowledgeStatusContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: KnowledgeStatusContext for this KnowledgeStatusInstance + """ + if self._context is None: + self._context = KnowledgeStatusContext( + self._version, + id=self._solution["id"], + ) + return self._context + + def fetch(self) -> "KnowledgeStatusInstance": + """ + Fetch the KnowledgeStatusInstance + + + :returns: The fetched KnowledgeStatusInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "KnowledgeStatusInstance": + """ + Asynchronous coroutine to fetch the KnowledgeStatusInstance + + + :returns: The fetched KnowledgeStatusInstance + """ + return await self._proxy.fetch_async() + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class KnowledgeStatusContext(InstanceContext): + + def __init__(self, version: Version, id: str): + """ + Initialize the KnowledgeStatusContext + + :param version: Version that contains the resource + :param id: the Knowledge ID. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "id": id, + } + self._uri = "/Knowledge/{id}/Status".format(**self._solution) + + def fetch(self) -> KnowledgeStatusInstance: + """ + Fetch the KnowledgeStatusInstance + + + :returns: The fetched KnowledgeStatusInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return KnowledgeStatusInstance( + self._version, + payload, + id=self._solution["id"], + ) + + async def fetch_async(self) -> KnowledgeStatusInstance: + """ + Asynchronous coroutine to fetch the KnowledgeStatusInstance + + + :returns: The fetched KnowledgeStatusInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + return KnowledgeStatusInstance( + self._version, + payload, + id=self._solution["id"], + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class KnowledgeStatusList(ListResource): + + def __init__(self, version: Version, id: str): + """ + Initialize the KnowledgeStatusList + + :param version: Version that contains the resource + :param id: the Knowledge ID. + + """ + super().__init__(version) + + # Path Solution + self._solution = { + "id": id, + } + + def get(self) -> KnowledgeStatusContext: + """ + Constructs a KnowledgeStatusContext + + """ + return KnowledgeStatusContext(self._version, id=self._solution["id"]) + + def __call__(self) -> KnowledgeStatusContext: + """ + Constructs a KnowledgeStatusContext + + """ + return KnowledgeStatusContext(self._version, id=self._solution["id"]) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/assistants/v1/policy.py b/twilio/rest/assistants/v1/policy.py new file mode 100644 index 0000000000..63854fb82b --- /dev/null +++ b/twilio/rest/assistants/v1/policy.py @@ -0,0 +1,332 @@ +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, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return PolicyPage(self._version, response) + + async def page_async( + self, + tool_id: Union[str, object] = values.unset, + knowledge_id: Union[str, object] = values.unset, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> PolicyPage: + """ + Asynchronously retrieve a single page of PolicyInstance records from the API. + Request is executed immediately + + :param tool_id: The tool ID. + :param knowledge_id: The knowledge ID. + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: Page of PolicyInstance + """ + data = values.of( + { + "ToolId": tool_id, + "KnowledgeId": knowledge_id, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + return PolicyPage(self._version, response) + + def 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 0000000000..3f0054ea55 --- /dev/null +++ b/twilio/rest/assistants/v1/session/__init__.py @@ -0,0 +1,439 @@ +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 + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + 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 + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + 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, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return SessionPage(self._version, response) + + async def page_async( + self, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> SessionPage: + """ + Asynchronously retrieve a single page of SessionInstance records from the API. + Request is executed immediately + + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: Page of SessionInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + return SessionPage(self._version, response) + + def 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 0000000000..a7ea5ca213 --- /dev/null +++ b/twilio/rest/assistants/v1/session/message.py @@ -0,0 +1,309 @@ +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, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return MessagePage(self._version, response, self._solution) + + async def page_async( + self, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> MessagePage: + """ + Asynchronously retrieve a single page of MessageInstance records from the API. + Request is executed immediately + + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: Page of MessageInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + return MessagePage(self._version, response, 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 0000000000..648faca599 --- /dev/null +++ b/twilio/rest/assistants/v1/tool.py @@ -0,0 +1,916 @@ +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): + + class AssistantsV1ServiceCreatePolicyRequest(object): + """ + :ivar description: The description of the policy. + :ivar id: The Policy ID. + :ivar name: The name of the policy. + :ivar policy_details: + :ivar type: The description of the policy. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.description: Optional[str] = payload.get("description") + self.id: Optional[str] = payload.get("id") + self.name: Optional[str] = payload.get("name") + self.policy_details: Optional[Dict[str, object]] = payload.get( + "policy_details" + ) + self.type: Optional[str] = payload.get("type") + + def to_dict(self): + return { + "description": self.description, + "id": self.id, + "name": self.name, + "policy_details": self.policy_details, + "type": self.type, + } + + class AssistantsV1ServiceCreateToolRequest(object): + """ + :ivar assistant_id: The Assistant ID. + :ivar description: The description of the tool. + :ivar enabled: True if the tool is enabled. + :ivar meta: The metadata related to method, url, input_schema to used with the Tool. + :ivar name: The name of the tool. + :ivar policy: + :ivar type: The description of the tool. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.assistant_id: Optional[str] = payload.get("assistant_id") + self.description: Optional[str] = payload.get("description") + self.enabled: Optional[bool] = payload.get("enabled") + self.meta: Optional[Dict[str, object]] = payload.get("meta") + self.name: Optional[str] = payload.get("name") + self.policy: Optional[ToolList.AssistantsV1ServiceCreatePolicyRequest] = ( + payload.get("policy") + ) + self.type: Optional[str] = payload.get("type") + + def to_dict(self): + return { + "assistant_id": self.assistant_id, + "description": self.description, + "enabled": self.enabled, + "meta": self.meta, + "name": self.name, + "policy": self.policy.to_dict() if self.policy is not None else None, + "type": self.type, + } + + class AssistantsV1ServiceUpdateToolRequest(object): + """ + :ivar assistant_id: The Assistant ID. + :ivar description: The description of the tool. + :ivar enabled: True if the tool is enabled. + :ivar meta: The metadata related to method, url, input_schema to used with the Tool. + :ivar name: The name of the tool. + :ivar policy: + :ivar type: The type of the tool. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.assistant_id: Optional[str] = payload.get("assistant_id") + self.description: Optional[str] = payload.get("description") + self.enabled: Optional[bool] = payload.get("enabled") + self.meta: Optional[Dict[str, object]] = payload.get("meta") + self.name: Optional[str] = payload.get("name") + self.policy: Optional[ToolList.AssistantsV1ServiceCreatePolicyRequest] = ( + payload.get("policy") + ) + self.type: Optional[str] = payload.get("type") + + def to_dict(self): + return { + "assistant_id": self.assistant_id, + "description": self.description, + "enabled": self.enabled, + "meta": self.meta, + "name": self.name, + "policy": self.policy.to_dict() if self.policy is not None else None, + "type": self.type, + } + + """ + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Tool resource. + :ivar description: The description of the tool. + :ivar enabled: True if the tool is enabled. + :ivar id: The tool ID. + :ivar meta: The metadata related to method, url, input_schema to used with the Tool. + :ivar name: The name of the tool. + :ivar requires_auth: The authentication requirement for the tool. + :ivar type: The type of the tool. ('WEBHOOK') + :ivar url: The url of the tool resource. + :ivar date_created: The date and time in GMT when the Tool was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + :ivar date_updated: The date and time in GMT when the Tool was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + :ivar policies: The Policies associated with the tool. + """ + + def __init__( + self, version: Version, payload: Dict[str, Any], id: Optional[str] = None + ): + super().__init__(version) + + self.account_sid: Optional[str] = payload.get("account_sid") + self.description: Optional[str] = payload.get("description") + self.enabled: Optional[bool] = payload.get("enabled") + self.id: Optional[str] = payload.get("id") + self.meta: Optional[Dict[str, object]] = payload.get("meta") + self.name: Optional[str] = payload.get("name") + self.requires_auth: Optional[bool] = payload.get("requires_auth") + self.type: Optional[str] = payload.get("type") + self.url: Optional[str] = payload.get("url") + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_created") + ) + self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_updated") + ) + self.policies: Optional[List[str]] = payload.get("policies") + + self._solution = { + "id": id or self.id, + } + self._context: Optional[ToolContext] = None + + @property + def _proxy(self) -> "ToolContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: ToolContext for this ToolInstance + """ + if self._context is None: + self._context = ToolContext( + self._version, + id=self._solution["id"], + ) + return self._context + + def delete(self) -> bool: + """ + Deletes the ToolInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._proxy.delete() + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the ToolInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._proxy.delete_async() + + def 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[ + 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): + + class AssistantsV1ServiceCreatePolicyRequest(object): + """ + :ivar description: The description of the policy. + :ivar id: The Policy ID. + :ivar name: The name of the policy. + :ivar policy_details: + :ivar type: The description of the policy. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.description: Optional[str] = payload.get("description") + self.id: Optional[str] = payload.get("id") + self.name: Optional[str] = payload.get("name") + self.policy_details: Optional[Dict[str, object]] = payload.get( + "policy_details" + ) + self.type: Optional[str] = payload.get("type") + + def to_dict(self): + return { + "description": self.description, + "id": self.id, + "name": self.name, + "policy_details": self.policy_details, + "type": self.type, + } + + class AssistantsV1ServiceCreateToolRequest(object): + """ + :ivar assistant_id: The Assistant ID. + :ivar description: The description of the tool. + :ivar enabled: True if the tool is enabled. + :ivar meta: The metadata related to method, url, input_schema to used with the Tool. + :ivar name: The name of the tool. + :ivar policy: + :ivar type: The description of the tool. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.assistant_id: Optional[str] = payload.get("assistant_id") + self.description: Optional[str] = payload.get("description") + self.enabled: Optional[bool] = payload.get("enabled") + self.meta: Optional[Dict[str, object]] = payload.get("meta") + self.name: Optional[str] = payload.get("name") + self.policy: Optional[ToolList.AssistantsV1ServiceCreatePolicyRequest] = ( + payload.get("policy") + ) + self.type: Optional[str] = payload.get("type") + + def to_dict(self): + return { + "assistant_id": self.assistant_id, + "description": self.description, + "enabled": self.enabled, + "meta": self.meta, + "name": self.name, + "policy": self.policy.to_dict() if self.policy is not None else None, + "type": self.type, + } + + class AssistantsV1ServiceUpdateToolRequest(object): + """ + :ivar assistant_id: The Assistant ID. + :ivar description: The description of the tool. + :ivar enabled: True if the tool is enabled. + :ivar meta: The metadata related to method, url, input_schema to used with the Tool. + :ivar name: The name of the tool. + :ivar policy: + :ivar type: The type of the tool. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.assistant_id: Optional[str] = payload.get("assistant_id") + self.description: Optional[str] = payload.get("description") + self.enabled: Optional[bool] = payload.get("enabled") + self.meta: Optional[Dict[str, object]] = payload.get("meta") + self.name: Optional[str] = payload.get("name") + self.policy: Optional[ToolList.AssistantsV1ServiceCreatePolicyRequest] = ( + payload.get("policy") + ) + self.type: Optional[str] = payload.get("type") + + def to_dict(self): + return { + "assistant_id": self.assistant_id, + "description": self.description, + "enabled": self.enabled, + "meta": self.meta, + "name": self.name, + "policy": self.policy.to_dict() if self.policy is not None else None, + "type": self.type, + } + + def __init__(self, version: Version, id: str): + """ + Initialize the ToolContext + + :param version: Version that contains the resource + :param id: + """ + super().__init__(version) + + # Path Solution + self._solution = { + "id": id, + } + self._uri = "/Tools/{id}".format(**self._solution) + + def delete(self) -> bool: + """ + Deletes the ToolInstance + + + :returns: True if delete succeeds, False otherwise + """ + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the ToolInstance + + + :returns: True if delete succeeds, False otherwise + """ + + headers = values.of({}) + + return await self._version.delete_async( + method="DELETE", uri=self._uri, headers=headers + ) + + def fetch(self) -> ToolInstance: + """ + Fetch the ToolInstance + + + :returns: The fetched ToolInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + 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 + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + return ToolInstance( + self._version, + payload, + id=self._solution["id"], + ) + + 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 = assistants_v1_service_update_tool_request.to_dict() + + headers = values.of({}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + payload = self._version.update( + method="PUT", uri=self._uri, data=data, headers=headers + ) + + return 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 = assistants_v1_service_update_tool_request.to_dict() + + headers = values.of({}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + payload = await self._version.update_async( + method="PUT", uri=self._uri, data=data, headers=headers + ) + + return 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() if self.policy is not None else None, + "type": self.type, + } + + class AssistantsV1ServiceUpdateToolRequest(object): + """ + :ivar assistant_id: The Assistant ID. + :ivar description: The description of the tool. + :ivar enabled: True if the tool is enabled. + :ivar meta: The metadata related to method, url, input_schema to used with the Tool. + :ivar name: The name of the tool. + :ivar policy: + :ivar type: The type of the tool. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.assistant_id: Optional[str] = payload.get("assistant_id") + self.description: Optional[str] = payload.get("description") + self.enabled: Optional[bool] = payload.get("enabled") + self.meta: Optional[Dict[str, object]] = payload.get("meta") + self.name: Optional[str] = payload.get("name") + self.policy: Optional[ToolList.AssistantsV1ServiceCreatePolicyRequest] = ( + payload.get("policy") + ) + self.type: Optional[str] = payload.get("type") + + def to_dict(self): + return { + "assistant_id": self.assistant_id, + "description": self.description, + "enabled": self.enabled, + "meta": self.meta, + "name": self.name, + "policy": self.policy.to_dict() if self.policy is not None else None, + "type": self.type, + } + + def __init__(self, version: Version): + """ + Initialize the ToolList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/Tools" + + def create( + self, + assistants_v1_service_create_tool_request: AssistantsV1ServiceCreateToolRequest, + ) -> 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" + + headers["Accept"] = "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" + + headers["Accept"] = "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, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return ToolPage(self._version, response) + + async def page_async( + self, + assistant_id: Union[str, object] = values.unset, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> ToolPage: + """ + Asynchronously retrieve a single page of ToolInstance records from the API. + Request is executed immediately + + :param assistant_id: + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: Page of ToolInstance + """ + data = values.of( + { + "AssistantId": assistant_id, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + return ToolPage(self._version, response) + + def 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/autopilot/__init__.py b/twilio/rest/autopilot/__init__.py deleted file mode 100644 index f382325023..0000000000 --- a/twilio/rest/autopilot/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -from warnings import warn - -from twilio.rest.autopilot.AutopilotBase import AutopilotBase -from twilio.rest.autopilot.v1.assistant import AssistantList -from twilio.rest.autopilot.v1.restore_assistant import RestoreAssistantList - - -class Autopilot(AutopilotBase): - @property - def assistants(self) -> AssistantList: - warn( - "assistants is deprecated. Use v1.assistants instead.", - DeprecationWarning, - stacklevel=2, - ) - return self.v1.assistants - - @property - def restore_assistant(self) -> RestoreAssistantList: - warn( - "restore_assistant is deprecated. Use v1.restore_assistant instead.", - DeprecationWarning, - stacklevel=2, - ) - return self.v1.restore_assistant diff --git a/twilio/rest/bulkexports/v1/export/__init__.py b/twilio/rest/bulkexports/v1/export/__init__.py index c5c11df086..0ebf3a451b 100644 --- a/twilio/rest/bulkexports/v1/export/__init__.py +++ b/twilio/rest/bulkexports/v1/export/__init__.py @@ -13,6 +13,7 @@ """ 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 @@ -132,10 +133,11 @@ def fetch(self) -> ExportInstance: :returns: The fetched ExportInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ExportInstance( self._version, @@ -151,9 +153,12 @@ async def fetch_async(self) -> ExportInstance: :returns: The fetched ExportInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ExportInstance( diff --git a/twilio/rest/bulkexports/v1/export/day.py b/twilio/rest/bulkexports/v1/export/day.py index fcbc56e979..f4b2a0650f 100644 --- a/twilio/rest/bulkexports/v1/export/day.py +++ b/twilio/rest/bulkexports/v1/export/day.py @@ -124,10 +124,11 @@ def fetch(self) -> DayInstance: :returns: The fetched DayInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return DayInstance( self._version, @@ -144,9 +145,12 @@ async def fetch_async(self) -> DayInstance: :returns: The fetched DayInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return DayInstance( @@ -332,7 +336,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return DayPage(self._version, response, self._solution) async def page_async( @@ -359,8 +369,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return DayPage(self._version, response, self._solution) diff --git a/twilio/rest/bulkexports/v1/export/export_custom_job.py b/twilio/rest/bulkexports/v1/export/export_custom_job.py index 758398eba3..72d0e9b328 100644 --- a/twilio/rest/bulkexports/v1/export/export_custom_job.py +++ b/twilio/rest/bulkexports/v1/export/export_custom_job.py @@ -138,11 +138,14 @@ def create( "Email": email, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ExportCustomJobInstance( @@ -181,11 +184,14 @@ async def create_async( "Email": email, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ExportCustomJobInstance( @@ -319,7 +325,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ExportCustomJobPage(self._version, response, self._solution) async def page_async( @@ -346,8 +358,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ExportCustomJobPage(self._version, response, self._solution) diff --git a/twilio/rest/bulkexports/v1/export/job.py b/twilio/rest/bulkexports/v1/export/job.py index 48b2df1ab3..5358ffa83a 100644 --- a/twilio/rest/bulkexports/v1/export/job.py +++ b/twilio/rest/bulkexports/v1/export/job.py @@ -13,6 +13,7 @@ """ 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 @@ -145,10 +146,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -157,9 +158,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> JobInstance: @@ -170,10 +173,11 @@ def fetch(self) -> JobInstance: :returns: The fetched JobInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return JobInstance( self._version, @@ -189,9 +193,12 @@ async def fetch_async(self) -> JobInstance: :returns: The fetched JobInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return JobInstance( diff --git a/twilio/rest/bulkexports/v1/export_configuration.py b/twilio/rest/bulkexports/v1/export_configuration.py index c6629d21cf..207642769b 100644 --- a/twilio/rest/bulkexports/v1/export_configuration.py +++ b/twilio/rest/bulkexports/v1/export_configuration.py @@ -158,10 +158,11 @@ def fetch(self) -> ExportConfigurationInstance: :returns: The fetched ExportConfigurationInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ExportConfigurationInstance( self._version, @@ -177,9 +178,12 @@ async def fetch_async(self) -> ExportConfigurationInstance: :returns: The fetched ExportConfigurationInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ExportConfigurationInstance( @@ -203,6 +207,7 @@ def update( :returns: The updated ExportConfigurationInstance """ + data = values.of( { "Enabled": serialize.boolean_to_string(enabled), @@ -210,11 +215,14 @@ def update( "WebhookMethod": webhook_method, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ExportConfigurationInstance( @@ -236,6 +244,7 @@ async def update_async( :returns: The updated ExportConfigurationInstance """ + data = values.of( { "Enabled": serialize.boolean_to_string(enabled), @@ -243,11 +252,14 @@ async def update_async( "WebhookMethod": webhook_method, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ExportConfigurationInstance( diff --git a/twilio/rest/chat/v1/credential.py b/twilio/rest/chat/v1/credential.py index 68ec9f4b46..3bd48b1144 100644 --- a/twilio/rest/chat/v1/credential.py +++ b/twilio/rest/chat/v1/credential.py @@ -208,10 +208,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -220,9 +220,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> CredentialInstance: @@ -233,10 +235,11 @@ def fetch(self) -> CredentialInstance: :returns: The fetched CredentialInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return CredentialInstance( self._version, @@ -252,9 +255,12 @@ async def fetch_async(self) -> CredentialInstance: :returns: The fetched CredentialInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return CredentialInstance( @@ -284,6 +290,7 @@ def update( :returns: The updated CredentialInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -294,11 +301,14 @@ def update( "Secret": secret, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CredentialInstance(self._version, payload, sid=self._solution["sid"]) @@ -324,6 +334,7 @@ async def update_async( :returns: The updated CredentialInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -334,11 +345,14 @@ async def update_async( "Secret": secret, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CredentialInstance(self._version, payload, sid=self._solution["sid"]) @@ -420,11 +434,14 @@ def create( "Secret": secret, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CredentialInstance(self._version, payload) @@ -464,11 +481,14 @@ async def create_async( "Secret": secret, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CredentialInstance(self._version, payload) @@ -600,7 +620,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return CredentialPage(self._version, response) async def page_async( @@ -627,8 +653,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return CredentialPage(self._version, response) diff --git a/twilio/rest/chat/v1/service/__init__.py b/twilio/rest/chat/v1/service/__init__.py index 1e2a5884a7..26fde4025b 100644 --- a/twilio/rest/chat/v1/service/__init__.py +++ b/twilio/rest/chat/v1/service/__init__.py @@ -554,10 +554,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -566,9 +566,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> ServiceInstance: @@ -579,10 +581,11 @@ def fetch(self) -> ServiceInstance: :returns: The fetched ServiceInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ServiceInstance( self._version, @@ -598,9 +601,12 @@ async def fetch_async(self) -> ServiceInstance: :returns: The fetched ServiceInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ServiceInstance( @@ -726,6 +732,7 @@ def update( :returns: The updated ServiceInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -794,11 +801,14 @@ def update( "Limits.UserChannels": limits_user_channels, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload, sid=self._solution["sid"]) @@ -920,6 +930,7 @@ async def update_async( :returns: The updated ServiceInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -988,11 +999,14 @@ async def update_async( "Limits.UserChannels": limits_user_channels, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload, sid=self._solution["sid"]) @@ -1089,11 +1103,14 @@ def create(self, friendly_name: str) -> ServiceInstance: "FriendlyName": friendly_name, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload) @@ -1112,11 +1129,14 @@ async def create_async(self, friendly_name: str) -> ServiceInstance: "FriendlyName": friendly_name, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload) @@ -1248,7 +1268,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ServicePage(self._version, response) async def page_async( @@ -1275,8 +1301,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ServicePage(self._version, response) diff --git a/twilio/rest/chat/v1/service/channel/__init__.py b/twilio/rest/chat/v1/service/channel/__init__.py index 1585613948..ffe42c0b5d 100644 --- a/twilio/rest/chat/v1/service/channel/__init__.py +++ b/twilio/rest/chat/v1/service/channel/__init__.py @@ -241,10 +241,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -253,9 +253,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> ChannelInstance: @@ -266,10 +268,11 @@ def fetch(self) -> ChannelInstance: :returns: The fetched ChannelInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ChannelInstance( self._version, @@ -286,9 +289,12 @@ async def fetch_async(self) -> ChannelInstance: :returns: The fetched ChannelInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ChannelInstance( @@ -313,6 +319,7 @@ def update( :returns: The updated ChannelInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -320,11 +327,14 @@ def update( "Attributes": attributes, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ChannelInstance( @@ -349,6 +359,7 @@ async def update_async( :returns: The updated ChannelInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -356,11 +367,14 @@ async def update_async( "Attributes": attributes, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ChannelInstance( @@ -484,11 +498,14 @@ def create( "Type": type, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ChannelInstance( @@ -521,11 +538,14 @@ async def create_async( "Type": type, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ChannelInstance( @@ -672,7 +692,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ChannelPage(self._version, response, self._solution) async def page_async( @@ -702,8 +728,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ChannelPage(self._version, response, self._solution) diff --git a/twilio/rest/chat/v1/service/channel/invite.py b/twilio/rest/chat/v1/service/channel/invite.py index 6beccffae4..e5cd4ebe36 100644 --- a/twilio/rest/chat/v1/service/channel/invite.py +++ b/twilio/rest/chat/v1/service/channel/invite.py @@ -163,10 +163,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -175,9 +175,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> InviteInstance: @@ -188,10 +190,11 @@ def fetch(self) -> InviteInstance: :returns: The fetched InviteInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return InviteInstance( self._version, @@ -209,9 +212,12 @@ async def fetch_async(self) -> InviteInstance: :returns: The fetched InviteInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return InviteInstance( @@ -296,11 +302,14 @@ def create( "RoleSid": role_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return InviteInstance( @@ -328,11 +337,14 @@ async def create_async( "RoleSid": role_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return InviteInstance( @@ -482,7 +494,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return InvitePage(self._version, response, self._solution) async def page_async( @@ -512,8 +530,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return InvitePage(self._version, response, self._solution) diff --git a/twilio/rest/chat/v1/service/channel/member.py b/twilio/rest/chat/v1/service/channel/member.py index f0cd21448f..1262703ddc 100644 --- a/twilio/rest/chat/v1/service/channel/member.py +++ b/twilio/rest/chat/v1/service/channel/member.py @@ -205,10 +205,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -217,9 +217,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> MemberInstance: @@ -230,10 +232,11 @@ def fetch(self) -> MemberInstance: :returns: The fetched MemberInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return MemberInstance( self._version, @@ -251,9 +254,12 @@ async def fetch_async(self) -> MemberInstance: :returns: The fetched MemberInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return MemberInstance( @@ -277,17 +283,21 @@ def update( :returns: The updated MemberInstance """ + data = values.of( { "RoleSid": role_sid, "LastConsumedMessageIndex": last_consumed_message_index, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return MemberInstance( @@ -311,17 +321,21 @@ async def update_async( :returns: The updated MemberInstance """ + data = values.of( { "RoleSid": role_sid, "LastConsumedMessageIndex": last_consumed_message_index, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return MemberInstance( @@ -406,11 +420,14 @@ def create( "RoleSid": role_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return MemberInstance( @@ -438,11 +455,14 @@ async def create_async( "RoleSid": role_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return MemberInstance( @@ -592,7 +612,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return MemberPage(self._version, response, self._solution) async def page_async( @@ -622,8 +648,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return MemberPage(self._version, response, self._solution) diff --git a/twilio/rest/chat/v1/service/channel/message.py b/twilio/rest/chat/v1/service/channel/message.py index f524c92387..e7cfc9217d 100644 --- a/twilio/rest/chat/v1/service/channel/message.py +++ b/twilio/rest/chat/v1/service/channel/message.py @@ -210,10 +210,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -222,9 +222,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> MessageInstance: @@ -235,10 +237,11 @@ def fetch(self) -> MessageInstance: :returns: The fetched MessageInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return MessageInstance( self._version, @@ -256,9 +259,12 @@ async def fetch_async(self) -> MessageInstance: :returns: The fetched MessageInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return MessageInstance( @@ -282,17 +288,21 @@ def update( :returns: The updated MessageInstance """ + data = values.of( { "Body": body, "Attributes": attributes, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return MessageInstance( @@ -316,17 +326,21 @@ async def update_async( :returns: The updated MessageInstance """ + data = values.of( { "Body": body, "Attributes": attributes, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return MessageInstance( @@ -416,11 +430,14 @@ def create( "Attributes": attributes, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return MessageInstance( @@ -453,11 +470,14 @@ async def create_async( "Attributes": attributes, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return MessageInstance( @@ -607,7 +627,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return MessagePage(self._version, response, self._solution) async def page_async( @@ -637,8 +663,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return MessagePage(self._version, response, self._solution) diff --git a/twilio/rest/chat/v1/service/role.py b/twilio/rest/chat/v1/service/role.py index 1913986a4a..d81cbd55ac 100644 --- a/twilio/rest/chat/v1/service/role.py +++ b/twilio/rest/chat/v1/service/role.py @@ -181,10 +181,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -193,9 +193,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> RoleInstance: @@ -206,10 +208,11 @@ def fetch(self) -> RoleInstance: :returns: The fetched RoleInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return RoleInstance( self._version, @@ -226,9 +229,12 @@ async def fetch_async(self) -> RoleInstance: :returns: The fetched RoleInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return RoleInstance( @@ -246,16 +252,20 @@ def update(self, permission: List[str]) -> RoleInstance: :returns: The updated RoleInstance """ + data = values.of( { "Permission": serialize.map(permission, lambda e: e), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RoleInstance( @@ -273,16 +283,20 @@ async def update_async(self, permission: List[str]) -> RoleInstance: :returns: The updated RoleInstance """ + data = values.of( { "Permission": serialize.map(permission, lambda e: e), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RoleInstance( @@ -361,11 +375,14 @@ def create( "Permission": serialize.map(permission, lambda e: e), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RoleInstance( @@ -392,11 +409,14 @@ async def create_async( "Permission": serialize.map(permission, lambda e: e), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RoleInstance( @@ -530,7 +550,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return RolePage(self._version, response, self._solution) async def page_async( @@ -557,8 +583,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return RolePage(self._version, response, self._solution) diff --git a/twilio/rest/chat/v1/service/user/__init__.py b/twilio/rest/chat/v1/service/user/__init__.py index b06509668a..c6b900957c 100644 --- a/twilio/rest/chat/v1/service/user/__init__.py +++ b/twilio/rest/chat/v1/service/user/__init__.py @@ -216,10 +216,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -228,9 +228,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> UserInstance: @@ -241,10 +243,11 @@ def fetch(self) -> UserInstance: :returns: The fetched UserInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return UserInstance( self._version, @@ -261,9 +264,12 @@ async def fetch_async(self) -> UserInstance: :returns: The fetched UserInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return UserInstance( @@ -288,6 +294,7 @@ def update( :returns: The updated UserInstance """ + data = values.of( { "RoleSid": role_sid, @@ -295,11 +302,14 @@ def update( "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return UserInstance( @@ -324,6 +334,7 @@ async def update_async( :returns: The updated UserInstance """ + data = values.of( { "RoleSid": role_sid, @@ -331,11 +342,14 @@ async def update_async( "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return UserInstance( @@ -433,11 +447,14 @@ def create( "FriendlyName": friendly_name, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return UserInstance( @@ -470,11 +487,14 @@ async def create_async( "FriendlyName": friendly_name, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return UserInstance( @@ -608,7 +628,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return UserPage(self._version, response, self._solution) async def page_async( @@ -635,8 +661,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return UserPage(self._version, response, self._solution) diff --git a/twilio/rest/chat/v1/service/user/user_channel.py b/twilio/rest/chat/v1/service/user/user_channel.py index 01e639ceab..b7f35aa9ef 100644 --- a/twilio/rest/chat/v1/service/user/user_channel.py +++ b/twilio/rest/chat/v1/service/user/user_channel.py @@ -247,7 +247,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return UserChannelPage(self._version, response, self._solution) async def page_async( @@ -274,8 +280,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return UserChannelPage(self._version, response, self._solution) diff --git a/twilio/rest/chat/v2/credential.py b/twilio/rest/chat/v2/credential.py index 8011ed0e1f..5479abeca0 100644 --- a/twilio/rest/chat/v2/credential.py +++ b/twilio/rest/chat/v2/credential.py @@ -208,10 +208,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -220,9 +220,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> CredentialInstance: @@ -233,10 +235,11 @@ def fetch(self) -> CredentialInstance: :returns: The fetched CredentialInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return CredentialInstance( self._version, @@ -252,9 +255,12 @@ async def fetch_async(self) -> CredentialInstance: :returns: The fetched CredentialInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return CredentialInstance( @@ -284,6 +290,7 @@ def update( :returns: The updated CredentialInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -294,11 +301,14 @@ def update( "Secret": secret, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CredentialInstance(self._version, payload, sid=self._solution["sid"]) @@ -324,6 +334,7 @@ async def update_async( :returns: The updated CredentialInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -334,11 +345,14 @@ async def update_async( "Secret": secret, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CredentialInstance(self._version, payload, sid=self._solution["sid"]) @@ -420,11 +434,14 @@ def create( "Secret": secret, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CredentialInstance(self._version, payload) @@ -464,11 +481,14 @@ async def create_async( "Secret": secret, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CredentialInstance(self._version, payload) @@ -600,7 +620,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return CredentialPage(self._version, response) async def page_async( @@ -627,8 +653,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return CredentialPage(self._version, response) diff --git a/twilio/rest/chat/v2/service/__init__.py b/twilio/rest/chat/v2/service/__init__.py index f6fa9e2c49..90a6c6cdba 100644 --- a/twilio/rest/chat/v2/service/__init__.py +++ b/twilio/rest/chat/v2/service/__init__.py @@ -437,10 +437,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -449,9 +449,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> ServiceInstance: @@ -462,10 +464,11 @@ def fetch(self) -> ServiceInstance: :returns: The fetched ServiceInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ServiceInstance( self._version, @@ -481,9 +484,12 @@ async def fetch_async(self) -> ServiceInstance: :returns: The fetched ServiceInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ServiceInstance( @@ -565,6 +571,7 @@ def update( :returns: The updated ServiceInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -614,11 +621,14 @@ def update( ), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload, sid=self._solution["sid"]) @@ -696,6 +706,7 @@ async def update_async( :returns: The updated ServiceInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -745,11 +756,14 @@ async def update_async( ), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload, sid=self._solution["sid"]) @@ -858,11 +872,14 @@ def create(self, friendly_name: str) -> ServiceInstance: "FriendlyName": friendly_name, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload) @@ -881,11 +898,14 @@ async def create_async(self, friendly_name: str) -> ServiceInstance: "FriendlyName": friendly_name, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload) @@ -1017,7 +1037,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ServicePage(self._version, response) async def page_async( @@ -1044,8 +1070,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ServicePage(self._version, response) diff --git a/twilio/rest/chat/v2/service/binding.py b/twilio/rest/chat/v2/service/binding.py index 2f960c5135..125f4b9368 100644 --- a/twilio/rest/chat/v2/service/binding.py +++ b/twilio/rest/chat/v2/service/binding.py @@ -166,10 +166,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -178,9 +178,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> BindingInstance: @@ -191,10 +193,11 @@ def fetch(self) -> BindingInstance: :returns: The fetched BindingInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return BindingInstance( self._version, @@ -211,9 +214,12 @@ async def fetch_async(self) -> BindingInstance: :returns: The fetched BindingInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return BindingInstance( @@ -429,7 +435,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return BindingPage(self._version, response, self._solution) async def page_async( @@ -462,8 +474,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return BindingPage(self._version, response, self._solution) diff --git a/twilio/rest/chat/v2/service/channel/__init__.py b/twilio/rest/chat/v2/service/channel/__init__.py index 2b49faf266..36d08a3896 100644 --- a/twilio/rest/chat/v2/service/channel/__init__.py +++ b/twilio/rest/chat/v2/service/channel/__init__.py @@ -310,6 +310,8 @@ def delete( } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async( @@ -331,6 +333,8 @@ async def delete_async( } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -343,10 +347,11 @@ def fetch(self) -> ChannelInstance: :returns: The fetched ChannelInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ChannelInstance( self._version, @@ -363,9 +368,12 @@ async def fetch_async(self) -> ChannelInstance: :returns: The fetched ChannelInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ChannelInstance( @@ -400,6 +408,7 @@ def update( :returns: The updated ChannelInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -410,11 +419,20 @@ def update( "CreatedBy": created_by, } ) - headers = values.of( - { - "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, - } - ) + headers = values.of({}) + + if not ( + x_twilio_webhook_enabled is values.unset + or ( + isinstance(x_twilio_webhook_enabled, str) + and not x_twilio_webhook_enabled + ) + ): + headers["X-Twilio-Webhook-Enabled"] = x_twilio_webhook_enabled + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( method="POST", uri=self._uri, data=data, headers=headers @@ -452,6 +470,7 @@ async def update_async( :returns: The updated ChannelInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -462,11 +481,20 @@ async def update_async( "CreatedBy": created_by, } ) - headers = values.of( - { - "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, - } - ) + headers = values.of({}) + + if not ( + x_twilio_webhook_enabled is values.unset + or ( + isinstance(x_twilio_webhook_enabled, str) + and not x_twilio_webhook_enabled + ) + ): + headers["X-Twilio-Webhook-Enabled"] = x_twilio_webhook_enabled + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( method="POST", uri=self._uri, data=data, headers=headers @@ -622,9 +650,14 @@ def create( headers = values.of( { "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = self._version.create( method="POST", uri=self._uri, data=data, headers=headers ) @@ -675,9 +708,14 @@ async def create_async( headers = values.of( { "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = await self._version.create_async( method="POST", uri=self._uri, data=data, headers=headers ) @@ -826,7 +864,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ChannelPage(self._version, response, self._solution) async def page_async( @@ -856,8 +900,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ChannelPage(self._version, response, self._solution) diff --git a/twilio/rest/chat/v2/service/channel/invite.py b/twilio/rest/chat/v2/service/channel/invite.py index 2c7333786d..7c7f9f6211 100644 --- a/twilio/rest/chat/v2/service/channel/invite.py +++ b/twilio/rest/chat/v2/service/channel/invite.py @@ -163,10 +163,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -175,9 +175,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> InviteInstance: @@ -188,10 +190,11 @@ def fetch(self) -> InviteInstance: :returns: The fetched InviteInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return InviteInstance( self._version, @@ -209,9 +212,12 @@ async def fetch_async(self) -> InviteInstance: :returns: The fetched InviteInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return InviteInstance( @@ -296,11 +302,14 @@ def create( "RoleSid": role_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return InviteInstance( @@ -328,11 +337,14 @@ async def create_async( "RoleSid": role_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return InviteInstance( @@ -482,7 +494,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return InvitePage(self._version, response, self._solution) async def page_async( @@ -512,8 +530,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return InvitePage(self._version, response, self._solution) diff --git a/twilio/rest/chat/v2/service/channel/member.py b/twilio/rest/chat/v2/service/channel/member.py index c71d3e3457..f07cb21891 100644 --- a/twilio/rest/chat/v2/service/channel/member.py +++ b/twilio/rest/chat/v2/service/channel/member.py @@ -274,6 +274,8 @@ def delete( } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async( @@ -295,6 +297,8 @@ async def delete_async( } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -307,10 +311,11 @@ def fetch(self) -> MemberInstance: :returns: The fetched MemberInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return MemberInstance( self._version, @@ -328,9 +333,12 @@ async def fetch_async(self) -> MemberInstance: :returns: The fetched MemberInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return MemberInstance( @@ -366,6 +374,7 @@ def update( :returns: The updated MemberInstance """ + data = values.of( { "RoleSid": role_sid, @@ -378,11 +387,20 @@ def update( "Attributes": attributes, } ) - headers = values.of( - { - "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, - } - ) + headers = values.of({}) + + if not ( + x_twilio_webhook_enabled is values.unset + or ( + isinstance(x_twilio_webhook_enabled, str) + and not x_twilio_webhook_enabled + ) + ): + headers["X-Twilio-Webhook-Enabled"] = x_twilio_webhook_enabled + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( method="POST", uri=self._uri, data=data, headers=headers @@ -421,6 +439,7 @@ async def update_async( :returns: The updated MemberInstance """ + data = values.of( { "RoleSid": role_sid, @@ -433,11 +452,20 @@ async def update_async( "Attributes": attributes, } ) - headers = values.of( - { - "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, - } - ) + headers = values.of({}) + + if not ( + x_twilio_webhook_enabled is values.unset + or ( + isinstance(x_twilio_webhook_enabled, str) + and not x_twilio_webhook_enabled + ) + ): + headers["X-Twilio-Webhook-Enabled"] = x_twilio_webhook_enabled + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( method="POST", uri=self._uri, data=data, headers=headers @@ -551,9 +579,14 @@ def create( headers = values.of( { "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = self._version.create( method="POST", uri=self._uri, data=data, headers=headers ) @@ -609,9 +642,14 @@ async def create_async( headers = values.of( { "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = await self._version.create_async( method="POST", uri=self._uri, data=data, headers=headers ) @@ -763,7 +801,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return MemberPage(self._version, response, self._solution) async def page_async( @@ -793,8 +837,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return MemberPage(self._version, response, self._solution) diff --git a/twilio/rest/chat/v2/service/channel/message.py b/twilio/rest/chat/v2/service/channel/message.py index e98f526c74..d0bf2e5ac7 100644 --- a/twilio/rest/chat/v2/service/channel/message.py +++ b/twilio/rest/chat/v2/service/channel/message.py @@ -282,6 +282,8 @@ def delete( } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async( @@ -303,6 +305,8 @@ async def delete_async( } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -315,10 +319,11 @@ def fetch(self) -> MessageInstance: :returns: The fetched MessageInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return MessageInstance( self._version, @@ -336,9 +341,12 @@ async def fetch_async(self) -> MessageInstance: :returns: The fetched MessageInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return MessageInstance( @@ -374,6 +382,7 @@ def update( :returns: The updated MessageInstance """ + data = values.of( { "Body": body, @@ -384,11 +393,20 @@ def update( "From": from_, } ) - headers = values.of( - { - "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, - } - ) + headers = values.of({}) + + if not ( + x_twilio_webhook_enabled is values.unset + or ( + isinstance(x_twilio_webhook_enabled, str) + and not x_twilio_webhook_enabled + ) + ): + headers["X-Twilio-Webhook-Enabled"] = x_twilio_webhook_enabled + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( method="POST", uri=self._uri, data=data, headers=headers @@ -427,6 +445,7 @@ async def update_async( :returns: The updated MessageInstance """ + data = values.of( { "Body": body, @@ -437,11 +456,20 @@ async def update_async( "From": from_, } ) - headers = values.of( - { - "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, - } - ) + headers = values.of({}) + + if not ( + x_twilio_webhook_enabled is values.unset + or ( + isinstance(x_twilio_webhook_enabled, str) + and not x_twilio_webhook_enabled + ) + ): + headers["X-Twilio-Webhook-Enabled"] = x_twilio_webhook_enabled + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( method="POST", uri=self._uri, data=data, headers=headers @@ -553,9 +581,14 @@ def create( headers = values.of( { "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = self._version.create( method="POST", uri=self._uri, data=data, headers=headers ) @@ -609,9 +642,14 @@ async def create_async( headers = values.of( { "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = await self._version.create_async( method="POST", uri=self._uri, data=data, headers=headers ) @@ -763,7 +801,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return MessagePage(self._version, response, self._solution) async def page_async( @@ -793,8 +837,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return MessagePage(self._version, response, self._solution) diff --git a/twilio/rest/chat/v2/service/channel/webhook.py b/twilio/rest/chat/v2/service/channel/webhook.py index ca738bac4a..3e31df4288 100644 --- a/twilio/rest/chat/v2/service/channel/webhook.py +++ b/twilio/rest/chat/v2/service/channel/webhook.py @@ -231,10 +231,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -243,9 +243,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> WebhookInstance: @@ -256,10 +258,11 @@ def fetch(self) -> WebhookInstance: :returns: The fetched WebhookInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return WebhookInstance( self._version, @@ -277,9 +280,12 @@ async def fetch_async(self) -> WebhookInstance: :returns: The fetched WebhookInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return WebhookInstance( @@ -311,6 +317,7 @@ def update( :returns: The updated WebhookInstance """ + data = values.of( { "Configuration.Url": configuration_url, @@ -325,11 +332,14 @@ def update( "Configuration.RetryCount": configuration_retry_count, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WebhookInstance( @@ -361,6 +371,7 @@ async def update_async( :returns: The updated WebhookInstance """ + data = values.of( { "Configuration.Url": configuration_url, @@ -375,11 +386,14 @@ async def update_async( "Configuration.RetryCount": configuration_retry_count, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WebhookInstance( @@ -485,11 +499,14 @@ def create( "Configuration.RetryCount": configuration_retry_count, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WebhookInstance( @@ -538,11 +555,14 @@ async def create_async( "Configuration.RetryCount": configuration_retry_count, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WebhookInstance( @@ -679,7 +699,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return WebhookPage(self._version, response, self._solution) async def page_async( @@ -706,8 +732,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return WebhookPage(self._version, response, self._solution) diff --git a/twilio/rest/chat/v2/service/role.py b/twilio/rest/chat/v2/service/role.py index 5bb373c9a2..fef06436d0 100644 --- a/twilio/rest/chat/v2/service/role.py +++ b/twilio/rest/chat/v2/service/role.py @@ -181,10 +181,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -193,9 +193,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> RoleInstance: @@ -206,10 +208,11 @@ def fetch(self) -> RoleInstance: :returns: The fetched RoleInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return RoleInstance( self._version, @@ -226,9 +229,12 @@ async def fetch_async(self) -> RoleInstance: :returns: The fetched RoleInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return RoleInstance( @@ -246,16 +252,20 @@ def update(self, permission: List[str]) -> RoleInstance: :returns: The updated RoleInstance """ + data = values.of( { "Permission": serialize.map(permission, lambda e: e), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RoleInstance( @@ -273,16 +283,20 @@ async def update_async(self, permission: List[str]) -> RoleInstance: :returns: The updated RoleInstance """ + data = values.of( { "Permission": serialize.map(permission, lambda e: e), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RoleInstance( @@ -361,11 +375,14 @@ def create( "Permission": serialize.map(permission, lambda e: e), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RoleInstance( @@ -392,11 +409,14 @@ async def create_async( "Permission": serialize.map(permission, lambda e: e), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RoleInstance( @@ -530,7 +550,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return RolePage(self._version, response, self._solution) async def page_async( @@ -557,8 +583,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return RolePage(self._version, response, self._solution) diff --git a/twilio/rest/chat/v2/service/user/__init__.py b/twilio/rest/chat/v2/service/user/__init__.py index 2c4ac5a3bd..9fbde6feda 100644 --- a/twilio/rest/chat/v2/service/user/__init__.py +++ b/twilio/rest/chat/v2/service/user/__init__.py @@ -240,10 +240,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -252,9 +252,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> UserInstance: @@ -265,10 +267,11 @@ def fetch(self) -> UserInstance: :returns: The fetched UserInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return UserInstance( self._version, @@ -285,9 +288,12 @@ async def fetch_async(self) -> UserInstance: :returns: The fetched UserInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return UserInstance( @@ -316,6 +322,7 @@ def update( :returns: The updated UserInstance """ + data = values.of( { "RoleSid": role_sid, @@ -323,11 +330,20 @@ def update( "FriendlyName": friendly_name, } ) - headers = values.of( - { - "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, - } - ) + headers = values.of({}) + + if not ( + x_twilio_webhook_enabled is values.unset + or ( + isinstance(x_twilio_webhook_enabled, str) + and not x_twilio_webhook_enabled + ) + ): + headers["X-Twilio-Webhook-Enabled"] = x_twilio_webhook_enabled + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( method="POST", uri=self._uri, data=data, headers=headers @@ -359,6 +375,7 @@ async def update_async( :returns: The updated UserInstance """ + data = values.of( { "RoleSid": role_sid, @@ -366,11 +383,20 @@ async def update_async( "FriendlyName": friendly_name, } ) - headers = values.of( - { - "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, - } - ) + headers = values.of({}) + + if not ( + x_twilio_webhook_enabled is values.unset + or ( + isinstance(x_twilio_webhook_enabled, str) + and not x_twilio_webhook_enabled + ) + ): + headers["X-Twilio-Webhook-Enabled"] = x_twilio_webhook_enabled + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( method="POST", uri=self._uri, data=data, headers=headers @@ -491,9 +517,14 @@ def create( headers = values.of( { "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = self._version.create( method="POST", uri=self._uri, data=data, headers=headers ) @@ -535,9 +566,14 @@ async def create_async( headers = values.of( { "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = await self._version.create_async( method="POST", uri=self._uri, data=data, headers=headers ) @@ -673,7 +709,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return UserPage(self._version, response, self._solution) async def page_async( @@ -700,8 +742,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return UserPage(self._version, response, self._solution) diff --git a/twilio/rest/chat/v2/service/user/user_binding.py b/twilio/rest/chat/v2/service/user/user_binding.py index 4170c74fb6..8d79c551af 100644 --- a/twilio/rest/chat/v2/service/user/user_binding.py +++ b/twilio/rest/chat/v2/service/user/user_binding.py @@ -173,10 +173,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -185,9 +185,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> UserBindingInstance: @@ -198,10 +200,11 @@ def fetch(self) -> UserBindingInstance: :returns: The fetched UserBindingInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return UserBindingInstance( self._version, @@ -219,9 +222,12 @@ async def fetch_async(self) -> UserBindingInstance: :returns: The fetched UserBindingInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return UserBindingInstance( @@ -440,7 +446,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return UserBindingPage(self._version, response, self._solution) async def page_async( @@ -472,8 +484,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return UserBindingPage(self._version, response, self._solution) diff --git a/twilio/rest/chat/v2/service/user/user_channel.py b/twilio/rest/chat/v2/service/user/user_channel.py index 1fd25254a5..9fab357368 100644 --- a/twilio/rest/chat/v2/service/user/user_channel.py +++ b/twilio/rest/chat/v2/service/user/user_channel.py @@ -259,6 +259,8 @@ def delete( } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async( @@ -280,6 +282,8 @@ async def delete_async( } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -292,10 +296,11 @@ def fetch(self) -> UserChannelInstance: :returns: The fetched UserChannelInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return UserChannelInstance( self._version, @@ -313,9 +318,12 @@ async def fetch_async(self) -> UserChannelInstance: :returns: The fetched UserChannelInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return UserChannelInstance( @@ -343,6 +351,7 @@ def update( :returns: The updated UserChannelInstance """ + data = values.of( { "NotificationLevel": notification_level, @@ -352,11 +361,14 @@ def update( ), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return UserChannelInstance( @@ -384,6 +396,7 @@ async def update_async( :returns: The updated UserChannelInstance """ + data = values.of( { "NotificationLevel": notification_level, @@ -393,11 +406,14 @@ async def update_async( ), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return UserChannelInstance( @@ -591,7 +607,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return UserChannelPage(self._version, response, self._solution) async def page_async( @@ -618,8 +640,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return UserChannelPage(self._version, response, self._solution) diff --git a/twilio/rest/chat/v3/channel.py b/twilio/rest/chat/v3/channel.py index e9d10b55bf..4682838fba 100644 --- a/twilio/rest/chat/v3/channel.py +++ b/twilio/rest/chat/v3/channel.py @@ -194,17 +194,27 @@ def update( :returns: The updated ChannelInstance """ + data = values.of( { "Type": type, "MessagingServiceSid": messaging_service_sid, } ) - headers = values.of( - { - "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, - } - ) + headers = values.of({}) + + if not ( + x_twilio_webhook_enabled is values.unset + or ( + isinstance(x_twilio_webhook_enabled, str) + and not x_twilio_webhook_enabled + ) + ): + headers["X-Twilio-Webhook-Enabled"] = x_twilio_webhook_enabled + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( method="POST", uri=self._uri, data=data, headers=headers @@ -234,17 +244,27 @@ async def update_async( :returns: The updated ChannelInstance """ + data = values.of( { "Type": type, "MessagingServiceSid": messaging_service_sid, } ) - headers = values.of( - { - "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, - } - ) + headers = values.of({}) + + if not ( + x_twilio_webhook_enabled is values.unset + or ( + isinstance(x_twilio_webhook_enabled, str) + and not x_twilio_webhook_enabled + ) + ): + headers["X-Twilio-Webhook-Enabled"] = x_twilio_webhook_enabled + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( method="POST", uri=self._uri, data=data, headers=headers diff --git a/twilio/rest/content/ContentBase.py b/twilio/rest/content/ContentBase.py index a8511f9fff..8a1ccd5d94 100644 --- a/twilio/rest/content/ContentBase.py +++ b/twilio/rest/content/ContentBase.py @@ -14,6 +14,7 @@ from twilio.base.domain import Domain from twilio.rest import Client from twilio.rest.content.v1 import V1 +from twilio.rest.content.v2 import V2 class ContentBase(Domain): @@ -26,6 +27,7 @@ def __init__(self, twilio: Client): """ super().__init__(twilio, "https://content.twilio.com") self._v1: Optional[V1] = None + self._v2: Optional[V2] = None @property def v1(self) -> V1: @@ -36,6 +38,15 @@ def v1(self) -> V1: self._v1 = V1(self) return self._v1 + @property + def v2(self) -> V2: + """ + :returns: Versions v2 of Content + """ + if self._v2 is None: + self._v2 = V2(self) + return self._v2 + def __repr__(self) -> str: """ Provide a friendly representation diff --git a/twilio/rest/content/v1/content/__init__.py b/twilio/rest/content/v1/content/__init__.py index bdc1102ca4..6223e940b3 100644 --- a/twilio/rest/content/v1/content/__init__.py +++ b/twilio/rest/content/v1/content/__init__.py @@ -26,135 +26,1583 @@ class ContentInstance(InstanceResource): - class AuthenticationActionType(object): - COPY_CODE = "COPY_CODE" + class AuthenticationAction(object): + """ + :ivar type: + :ivar copy_code_text: + """ - class CallToActionActionType(object): - URL = "URL" - PHONE_NUMBER = "PHONE_NUMBER" + def __init__(self, payload: Dict[str, Any]): - class CardActionType(object): - URL = "URL" - PHONE_NUMBER = "PHONE_NUMBER" - QUICK_REPLY = "QUICK_REPLY" + self.type: Optional["ContentInstance.AuthenticationActionType"] = ( + payload.get("type") + ) + self.copy_code_text: Optional[str] = payload.get("copy_code_text") - class QuickReplyActionType(object): - QUICK_REPLY = "QUICK_REPLY" + def to_dict(self): + return { + "type": self.type, + "copy_code_text": self.copy_code_text, + } - """ - :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 sid: The unique string that that we created to identify the Content resource. - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/usage/api/account) that created Content resource. - :ivar friendly_name: A string name used to describe the Content resource. Not visible to the end recipient. - :ivar language: Two-letter (ISO 639-1) language code (e.g., en) identifying the language the Content resource is in. - :ivar variables: Defines the default placeholder values for variables included in the Content resource. e.g. {\"1\": \"Customer_Name\"}. - :ivar types: The [Content types](https://www.twilio.com/docs/content-api/content-types-overview) (e.g. twilio/text) for this Content resource. - :ivar url: The URL of the resource, relative to `https://content.twilio.com`. - :ivar links: A list of links related to the Content resource, such as approval_fetch and approval_create - """ + class CallToActionAction(object): + """ + :ivar type: + :ivar title: + :ivar url: + :ivar phone: + :ivar code: + """ - def __init__( - self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None - ): - super().__init__(version) + def __init__(self, payload: Dict[str, Any]): - 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.sid: Optional[str] = payload.get("sid") - self.account_sid: Optional[str] = payload.get("account_sid") - self.friendly_name: Optional[str] = payload.get("friendly_name") - self.language: Optional[str] = payload.get("language") - self.variables: Optional[Dict[str, object]] = payload.get("variables") - self.types: Optional[Dict[str, object]] = payload.get("types") - self.url: Optional[str] = payload.get("url") - self.links: Optional[Dict[str, object]] = payload.get("links") + self.type: Optional["ContentInstance.CallToActionActionType"] = 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.code: Optional[str] = payload.get("code") - self._solution = { - "sid": sid or self.sid, - } - self._context: Optional[ContentContext] = None + def to_dict(self): + return { + "type": self.type, + "title": self.title, + "url": self.url, + "phone": self.phone, + "code": self.code, + } - @property - def _proxy(self) -> "ContentContext": + class CardAction(object): + """ + :ivar type: + :ivar title: + :ivar url: + :ivar phone: + :ivar id: + :ivar code: """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - :returns: ContentContext for this ContentInstance + def __init__(self, payload: Dict[str, Any]): + + self.type: Optional["ContentInstance.CardActionType"] = 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") + self.code: Optional[str] = payload.get("code") + + def to_dict(self): + return { + "type": self.type, + "title": self.title, + "url": self.url, + "phone": self.phone, + "id": self.id, + "code": self.code, + } + + class CarouselAction(object): """ - if self._context is None: - self._context = ContentContext( - self._version, - sid=self._solution["sid"], + :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" ) - return self._context + 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 delete(self) -> bool: + 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: """ - Deletes the ContentInstance + def __init__(self, payload: Dict[str, Any]): - :returns: True if delete succeeds, False otherwise + 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] + if self.actions is not None + else None + ), + } + + class CatalogItem(object): + """ + :ivar id: + :ivar section_title: + :ivar name: + :ivar media_url: + :ivar price: + :ivar description: """ - return self._proxy.delete() - async def delete_async(self) -> bool: + def __init__(self, payload: Dict[str, Any]): + + self.id: Optional[str] = payload.get("id") + self.section_title: Optional[str] = payload.get("section_title") + self.name: Optional[str] = payload.get("name") + self.media_url: Optional[str] = payload.get("media_url") + self.price: Optional[float] = payload.get("price") + self.description: Optional[str] = payload.get("description") + + def to_dict(self): + return { + "id": self.id, + "section_title": self.section_title, + "name": self.name, + "media_url": self.media_url, + "price": self.price, + "description": self.description, + } + + class ContentCreateRequest(object): + """ + :ivar friendly_name: User defined name of the content + :ivar variables: Key value pairs of variable name to value + :ivar language: Language code for the content + :ivar types: """ - Asynchronous coroutine that deletes the ContentInstance + def __init__(self, payload: Dict[str, Any]): - :returns: True if delete succeeds, False otherwise + self.friendly_name: Optional[str] = payload.get("friendly_name") + self.variables: Optional[dict[str, str]] = payload.get("variables") + self.language: Optional[str] = payload.get("language") + self.types: Optional[ContentList.Types] = payload.get("types") + + def to_dict(self): + return { + "friendly_name": self.friendly_name, + "variables": self.variables, + "language": self.language, + "types": self.types.to_dict() if self.types is not None else None, + } + + 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] + if self.layout is not None + else None + ), + } + + class FlowsPageComponent(object): + """ + :ivar label: + :ivar type: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.label: Optional[str] = payload.get("label") + self.type: Optional[str] = payload.get("type") + + def to_dict(self): + return { + "label": self.label, + "type": self.type, + } + + class ListItem(object): + """ + :ivar id: + :ivar item: + :ivar description: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.id: Optional[str] = payload.get("id") + self.item: Optional[str] = payload.get("item") + self.description: Optional[str] = payload.get("description") + + def to_dict(self): + return { + "id": self.id, + "item": self.item, + "description": self.description, + } + + class QuickReplyAction(object): + """ + :ivar type: + :ivar title: + :ivar id: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.type: Optional["ContentInstance.QuickReplyActionType"] = payload.get( + "type" + ) + self.title: Optional[str] = payload.get("title") + self.id: Optional[str] = payload.get("id") + + def to_dict(self): + return { + "type": self.type, + "title": self.title, + "id": self.id, + } + + class TwilioCallToAction(object): + """ + :ivar body: + :ivar actions: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.body: Optional[str] = payload.get("body") + self.actions: Optional[List[ContentList.CallToActionAction]] = payload.get( + "actions" + ) + + def to_dict(self): + return { + "body": self.body, + "actions": ( + [actions.to_dict() for actions in self.actions] + if self.actions is not None + else None + ), + } + + class TwilioCard(object): + """ + :ivar title: + :ivar subtitle: + :ivar media: + :ivar actions: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.title: Optional[str] = payload.get("title") + self.subtitle: Optional[str] = payload.get("subtitle") + self.media: Optional[List[str]] = payload.get("media") + self.actions: Optional[List[ContentList.CardAction]] = payload.get( + "actions" + ) + + def to_dict(self): + return { + "title": self.title, + "subtitle": self.subtitle, + "media": self.media, + "actions": ( + [actions.to_dict() for actions in self.actions] + if self.actions is not None + else None + ), + } + + 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] + if self.cards is not None + else None + ), + } + + class TwilioCatalog(object): + """ + :ivar title: + :ivar body: + :ivar subtitle: + :ivar id: + :ivar items: + :ivar dynamic_items: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.title: Optional[str] = payload.get("title") + self.body: Optional[str] = payload.get("body") + self.subtitle: Optional[str] = payload.get("subtitle") + self.id: Optional[str] = payload.get("id") + self.items: Optional[List[ContentList.CatalogItem]] = payload.get("items") + self.dynamic_items: Optional[str] = payload.get("dynamic_items") + + def to_dict(self): + return { + "title": self.title, + "body": self.body, + "subtitle": self.subtitle, + "id": self.id, + "items": ( + [items.to_dict() for items in self.items] + if self.items is not None + else None + ), + "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] + if self.pages is not None + else None + ), + "type": self.type, + } + + class TwilioListPicker(object): + """ + :ivar body: + :ivar button: + :ivar items: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.body: Optional[str] = payload.get("body") + self.button: Optional[str] = payload.get("button") + self.items: Optional[List[ContentList.ListItem]] = payload.get("items") + + def to_dict(self): + return { + "body": self.body, + "button": self.button, + "items": ( + [items.to_dict() for items in self.items] + if self.items is not None + else None + ), + } + + class TwilioLocation(object): + """ + :ivar latitude: + :ivar longitude: + :ivar label: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.latitude: Optional[float] = payload.get("latitude") + self.longitude: Optional[float] = payload.get("longitude") + self.label: Optional[str] = payload.get("label") + + def to_dict(self): + return { + "latitude": self.latitude, + "longitude": self.longitude, + "label": self.label, + } + + class TwilioMedia(object): + """ + :ivar body: + :ivar media: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.body: Optional[str] = payload.get("body") + self.media: Optional[List[str]] = payload.get("media") + + def to_dict(self): + return { + "body": self.body, + "media": self.media, + } + + class TwilioQuickReply(object): + """ + :ivar body: + :ivar actions: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.body: Optional[str] = payload.get("body") + self.actions: Optional[List[ContentList.QuickReplyAction]] = payload.get( + "actions" + ) + + def to_dict(self): + return { + "body": self.body, + "actions": ( + [actions.to_dict() for actions in self.actions] + if self.actions is not None + else None + ), + } + + class TwilioSchedule(object): + """ + :ivar id: + :ivar title: + :ivar time_slots: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.id: Optional[str] = payload.get("id") + self.title: Optional[str] = payload.get("title") + self.time_slots: Optional[str] = payload.get("time_slots") + + def to_dict(self): + return { + "id": self.id, + "title": self.title, + "time_slots": self.time_slots, + } + + class TwilioText(object): + """ + :ivar body: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.body: Optional[str] = payload.get("body") + + def to_dict(self): + return { + "body": self.body, + } + + class Types(object): + """ + :ivar twilio_text: + :ivar twilio_media: + :ivar twilio_location: + :ivar twilio_list_picker: + :ivar twilio_call_to_action: + :ivar twilio_quick_reply: + :ivar twilio_card: + :ivar twilio_catalog: + :ivar twilio_carousel: + :ivar twilio_flows: + :ivar twilio_schedule: + :ivar whatsapp_card: + :ivar whatsapp_authentication: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.twilio_text: Optional[ContentList.TwilioText] = payload.get( + "twilio_text" + ) + self.twilio_media: Optional[ContentList.TwilioMedia] = payload.get( + "twilio_media" + ) + self.twilio_location: Optional[ContentList.TwilioLocation] = payload.get( + "twilio_location" + ) + self.twilio_list_picker: Optional[ContentList.TwilioListPicker] = ( + payload.get("twilio_list_picker") + ) + self.twilio_call_to_action: Optional[ContentList.TwilioCallToAction] = ( + payload.get("twilio_call_to_action") + ) + self.twilio_quick_reply: Optional[ContentList.TwilioQuickReply] = ( + payload.get("twilio_quick_reply") + ) + self.twilio_card: Optional[ContentList.TwilioCard] = payload.get( + "twilio_card" + ) + self.twilio_catalog: Optional[ContentList.TwilioCatalog] = payload.get( + "twilio_catalog" + ) + self.twilio_carousel: Optional[ContentList.TwilioCarousel] = payload.get( + "twilio_carousel" + ) + self.twilio_flows: Optional[ContentList.TwilioFlows] = payload.get( + "twilio_flows" + ) + self.twilio_schedule: Optional[ContentList.TwilioSchedule] = payload.get( + "twilio_schedule" + ) + self.whatsapp_card: Optional[ContentList.WhatsappCard] = payload.get( + "whatsapp_card" + ) + self.whatsapp_authentication: Optional[ + ContentList.WhatsappAuthentication + ] = payload.get("whatsapp_authentication") + + def to_dict(self): + return { + "twilio_text": ( + self.twilio_text.to_dict() if self.twilio_text is not None else None + ), + "twilio_media": ( + self.twilio_media.to_dict() + if self.twilio_media is not None + else None + ), + "twilio_location": ( + self.twilio_location.to_dict() + if self.twilio_location is not None + else None + ), + "twilio_list_picker": ( + self.twilio_list_picker.to_dict() + if self.twilio_list_picker is not None + else None + ), + "twilio_call_to_action": ( + self.twilio_call_to_action.to_dict() + if self.twilio_call_to_action is not None + else None + ), + "twilio_quick_reply": ( + self.twilio_quick_reply.to_dict() + if self.twilio_quick_reply is not None + else None + ), + "twilio_card": ( + self.twilio_card.to_dict() if self.twilio_card is not None else None + ), + "twilio_catalog": ( + self.twilio_catalog.to_dict() + if self.twilio_catalog is not None + else None + ), + "twilio_carousel": ( + self.twilio_carousel.to_dict() + if self.twilio_carousel is not None + else None + ), + "twilio_flows": ( + self.twilio_flows.to_dict() + if self.twilio_flows is not None + else None + ), + "twilio_schedule": ( + self.twilio_schedule.to_dict() + if self.twilio_schedule is not None + else None + ), + "whatsapp_card": ( + self.whatsapp_card.to_dict() + if self.whatsapp_card is not None + else None + ), + "whatsapp_authentication": ( + self.whatsapp_authentication.to_dict() + if self.whatsapp_authentication is not None + else None + ), + } + + class WhatsappAuthentication(object): + """ + :ivar add_security_recommendation: + :ivar code_expiration_minutes: + :ivar actions: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.add_security_recommendation: Optional[bool] = payload.get( + "add_security_recommendation" + ) + self.code_expiration_minutes: Optional[float] = payload.get( + "code_expiration_minutes" + ) + self.actions: Optional[List[ContentList.AuthenticationAction]] = ( + payload.get("actions") + ) + + def to_dict(self): + return { + "add_security_recommendation": self.add_security_recommendation, + "code_expiration_minutes": self.code_expiration_minutes, + "actions": ( + [actions.to_dict() for actions in self.actions] + if self.actions is not None + else None + ), + } + + class WhatsappCard(object): + """ + :ivar body: + :ivar footer: + :ivar media: + :ivar header_text: + :ivar actions: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.body: Optional[str] = payload.get("body") + self.footer: Optional[str] = payload.get("footer") + self.media: Optional[List[str]] = payload.get("media") + self.header_text: Optional[str] = payload.get("header_text") + self.actions: Optional[List[ContentList.CardAction]] = payload.get( + "actions" + ) + + def to_dict(self): + return { + "body": self.body, + "footer": self.footer, + "media": self.media, + "header_text": self.header_text, + "actions": ( + [actions.to_dict() for actions in self.actions] + if self.actions is not None + else None + ), + } + + class AuthenticationActionType(object): + COPY_CODE = "COPY_CODE" + + class CallToActionActionType(object): + URL = "URL" + PHONE_NUMBER = "PHONE_NUMBER" + COPY_CODE = "COPY_CODE" + VOICE_CALL = "VOICE_CALL" + VOICE_CALL_REQUEST = "VOICE_CALL_REQUEST" + + 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" + PHONE_NUMBER = "PHONE_NUMBER" + QUICK_REPLY = "QUICK_REPLY" + + class QuickReplyActionType(object): + QUICK_REPLY = "QUICK_REPLY" + + """ + :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 sid: The unique string that that we created to identify the Content resource. + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/usage/api/account) that created Content resource. + :ivar friendly_name: A string name used to describe the Content resource. Not visible to the end recipient. + :ivar language: Two-letter (ISO 639-1) language code (e.g., en) identifying the language the Content resource is in. + :ivar variables: Defines the default placeholder values for variables included in the Content resource. e.g. {\"1\": \"Customer_Name\"}. + :ivar types: The [Content types](https://www.twilio.com/docs/content-api/content-types-overview) (e.g. twilio/text) for this Content resource. + :ivar url: The URL of the resource, relative to `https://content.twilio.com`. + :ivar links: A list of links related to the Content resource, such as approval_fetch and approval_create + """ + + def __init__( + self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None + ): + super().__init__(version) + + 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.sid: Optional[str] = payload.get("sid") + self.account_sid: Optional[str] = payload.get("account_sid") + self.friendly_name: Optional[str] = payload.get("friendly_name") + self.language: Optional[str] = payload.get("language") + self.variables: Optional[Dict[str, object]] = payload.get("variables") + self.types: Optional[Dict[str, object]] = payload.get("types") + self.url: Optional[str] = payload.get("url") + self.links: Optional[Dict[str, object]] = payload.get("links") + + self._solution = { + "sid": sid or self.sid, + } + self._context: Optional[ContentContext] = None + + @property + def _proxy(self) -> "ContentContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: ContentContext for this ContentInstance + """ + if self._context is None: + self._context = ContentContext( + self._version, + sid=self._solution["sid"], + ) + return self._context + + def delete(self) -> bool: + """ + Deletes the ContentInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._proxy.delete() + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the ContentInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._proxy.delete_async() + + def fetch(self) -> "ContentInstance": + """ + Fetch the ContentInstance + + + :returns: The fetched ContentInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "ContentInstance": + """ + Asynchronous coroutine to fetch the ContentInstance + + + :returns: The fetched ContentInstance + """ + return await self._proxy.fetch_async() + + @property + def approval_create(self) -> ApprovalCreateList: + """ + Access the approval_create + """ + return self._proxy.approval_create + + @property + def approval_fetch(self) -> ApprovalFetchList: + """ + Access the approval_fetch + """ + return self._proxy.approval_fetch + + 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 ContentContext(InstanceContext): + + class AuthenticationAction(object): + """ + :ivar type: + :ivar copy_code_text: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.type: Optional["ContentInstance.AuthenticationActionType"] = ( + payload.get("type") + ) + self.copy_code_text: Optional[str] = payload.get("copy_code_text") + + def to_dict(self): + return { + "type": self.type, + "copy_code_text": self.copy_code_text, + } + + class CallToActionAction(object): + """ + :ivar type: + :ivar title: + :ivar url: + :ivar phone: + :ivar code: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.type: Optional["ContentInstance.CallToActionActionType"] = 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.code: Optional[str] = payload.get("code") + + def to_dict(self): + return { + "type": self.type, + "title": self.title, + "url": self.url, + "phone": self.phone, + "code": self.code, + } + + class CardAction(object): + """ + :ivar type: + :ivar title: + :ivar url: + :ivar phone: + :ivar id: + :ivar code: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.type: Optional["ContentInstance.CardActionType"] = 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") + self.code: Optional[str] = payload.get("code") + + def to_dict(self): + return { + "type": self.type, + "title": self.title, + "url": self.url, + "phone": self.phone, + "id": self.id, + "code": self.code, + } + + 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] + if self.actions is not None + else None + ), + } + + class CatalogItem(object): + """ + :ivar id: + :ivar section_title: + :ivar name: + :ivar media_url: + :ivar price: + :ivar description: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.id: Optional[str] = payload.get("id") + self.section_title: Optional[str] = payload.get("section_title") + self.name: Optional[str] = payload.get("name") + self.media_url: Optional[str] = payload.get("media_url") + self.price: Optional[float] = payload.get("price") + self.description: Optional[str] = payload.get("description") + + def to_dict(self): + return { + "id": self.id, + "section_title": self.section_title, + "name": self.name, + "media_url": self.media_url, + "price": self.price, + "description": self.description, + } + + class ContentCreateRequest(object): + """ + :ivar friendly_name: User defined name of the content + :ivar variables: Key value pairs of variable name to value + :ivar language: Language code for the content + :ivar types: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.friendly_name: Optional[str] = payload.get("friendly_name") + self.variables: Optional[dict[str, str]] = payload.get("variables") + self.language: Optional[str] = payload.get("language") + self.types: Optional[ContentList.Types] = payload.get("types") + + def to_dict(self): + return { + "friendly_name": self.friendly_name, + "variables": self.variables, + "language": self.language, + "types": self.types.to_dict() if self.types is not None else None, + } + + 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] + if self.layout is not None + else None + ), + } + + class FlowsPageComponent(object): + """ + :ivar label: + :ivar type: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.label: Optional[str] = payload.get("label") + self.type: Optional[str] = payload.get("type") + + def to_dict(self): + return { + "label": self.label, + "type": self.type, + } + + class ListItem(object): + """ + :ivar id: + :ivar item: + :ivar description: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.id: Optional[str] = payload.get("id") + self.item: Optional[str] = payload.get("item") + self.description: Optional[str] = payload.get("description") + + def to_dict(self): + return { + "id": self.id, + "item": self.item, + "description": self.description, + } + + class QuickReplyAction(object): + """ + :ivar type: + :ivar title: + :ivar id: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.type: Optional["ContentInstance.QuickReplyActionType"] = payload.get( + "type" + ) + self.title: Optional[str] = payload.get("title") + self.id: Optional[str] = payload.get("id") + + def to_dict(self): + return { + "type": self.type, + "title": self.title, + "id": self.id, + } + + class TwilioCallToAction(object): + """ + :ivar body: + :ivar actions: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.body: Optional[str] = payload.get("body") + self.actions: Optional[List[ContentList.CallToActionAction]] = payload.get( + "actions" + ) + + def to_dict(self): + return { + "body": self.body, + "actions": ( + [actions.to_dict() for actions in self.actions] + if self.actions is not None + else None + ), + } + + class TwilioCard(object): + """ + :ivar title: + :ivar subtitle: + :ivar media: + :ivar actions: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.title: Optional[str] = payload.get("title") + self.subtitle: Optional[str] = payload.get("subtitle") + self.media: Optional[List[str]] = payload.get("media") + self.actions: Optional[List[ContentList.CardAction]] = payload.get( + "actions" + ) + + def to_dict(self): + return { + "title": self.title, + "subtitle": self.subtitle, + "media": self.media, + "actions": ( + [actions.to_dict() for actions in self.actions] + if self.actions is not None + else None + ), + } + + 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] + if self.cards is not None + else None + ), + } + + class TwilioCatalog(object): + """ + :ivar title: + :ivar body: + :ivar subtitle: + :ivar id: + :ivar items: + :ivar dynamic_items: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.title: Optional[str] = payload.get("title") + self.body: Optional[str] = payload.get("body") + self.subtitle: Optional[str] = payload.get("subtitle") + self.id: Optional[str] = payload.get("id") + self.items: Optional[List[ContentList.CatalogItem]] = payload.get("items") + self.dynamic_items: Optional[str] = payload.get("dynamic_items") + + def to_dict(self): + return { + "title": self.title, + "body": self.body, + "subtitle": self.subtitle, + "id": self.id, + "items": ( + [items.to_dict() for items in self.items] + if self.items is not None + else None + ), + "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] + if self.pages is not None + else None + ), + "type": self.type, + } + + class TwilioListPicker(object): + """ + :ivar body: + :ivar button: + :ivar items: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.body: Optional[str] = payload.get("body") + self.button: Optional[str] = payload.get("button") + self.items: Optional[List[ContentList.ListItem]] = payload.get("items") + + def to_dict(self): + return { + "body": self.body, + "button": self.button, + "items": ( + [items.to_dict() for items in self.items] + if self.items is not None + else None + ), + } + + class TwilioLocation(object): + """ + :ivar latitude: + :ivar longitude: + :ivar label: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.latitude: Optional[float] = payload.get("latitude") + self.longitude: Optional[float] = payload.get("longitude") + self.label: Optional[str] = payload.get("label") + + def to_dict(self): + return { + "latitude": self.latitude, + "longitude": self.longitude, + "label": self.label, + } + + class TwilioMedia(object): + """ + :ivar body: + :ivar media: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.body: Optional[str] = payload.get("body") + self.media: Optional[List[str]] = payload.get("media") + + def to_dict(self): + return { + "body": self.body, + "media": self.media, + } + + class TwilioQuickReply(object): + """ + :ivar body: + :ivar actions: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.body: Optional[str] = payload.get("body") + self.actions: Optional[List[ContentList.QuickReplyAction]] = payload.get( + "actions" + ) + + def to_dict(self): + return { + "body": self.body, + "actions": ( + [actions.to_dict() for actions in self.actions] + if self.actions is not None + else None + ), + } + + class TwilioSchedule(object): + """ + :ivar id: + :ivar title: + :ivar time_slots: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.id: Optional[str] = payload.get("id") + self.title: Optional[str] = payload.get("title") + self.time_slots: Optional[str] = payload.get("time_slots") + + def to_dict(self): + return { + "id": self.id, + "title": self.title, + "time_slots": self.time_slots, + } + + class TwilioText(object): + """ + :ivar body: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.body: Optional[str] = payload.get("body") + + def to_dict(self): + return { + "body": self.body, + } + + class Types(object): + """ + :ivar twilio_text: + :ivar twilio_media: + :ivar twilio_location: + :ivar twilio_list_picker: + :ivar twilio_call_to_action: + :ivar twilio_quick_reply: + :ivar twilio_card: + :ivar twilio_catalog: + :ivar twilio_carousel: + :ivar twilio_flows: + :ivar twilio_schedule: + :ivar whatsapp_card: + :ivar whatsapp_authentication: """ - return await self._proxy.delete_async() - def fetch(self) -> "ContentInstance": - """ - Fetch the ContentInstance + def __init__(self, payload: Dict[str, Any]): + + self.twilio_text: Optional[ContentList.TwilioText] = payload.get( + "twilio_text" + ) + self.twilio_media: Optional[ContentList.TwilioMedia] = payload.get( + "twilio_media" + ) + self.twilio_location: Optional[ContentList.TwilioLocation] = payload.get( + "twilio_location" + ) + self.twilio_list_picker: Optional[ContentList.TwilioListPicker] = ( + payload.get("twilio_list_picker") + ) + self.twilio_call_to_action: Optional[ContentList.TwilioCallToAction] = ( + payload.get("twilio_call_to_action") + ) + self.twilio_quick_reply: Optional[ContentList.TwilioQuickReply] = ( + payload.get("twilio_quick_reply") + ) + self.twilio_card: Optional[ContentList.TwilioCard] = payload.get( + "twilio_card" + ) + self.twilio_catalog: Optional[ContentList.TwilioCatalog] = payload.get( + "twilio_catalog" + ) + self.twilio_carousel: Optional[ContentList.TwilioCarousel] = payload.get( + "twilio_carousel" + ) + self.twilio_flows: Optional[ContentList.TwilioFlows] = payload.get( + "twilio_flows" + ) + self.twilio_schedule: Optional[ContentList.TwilioSchedule] = payload.get( + "twilio_schedule" + ) + self.whatsapp_card: Optional[ContentList.WhatsappCard] = payload.get( + "whatsapp_card" + ) + self.whatsapp_authentication: Optional[ + ContentList.WhatsappAuthentication + ] = payload.get("whatsapp_authentication") + def to_dict(self): + return { + "twilio_text": ( + self.twilio_text.to_dict() if self.twilio_text is not None else None + ), + "twilio_media": ( + self.twilio_media.to_dict() + if self.twilio_media is not None + else None + ), + "twilio_location": ( + self.twilio_location.to_dict() + if self.twilio_location is not None + else None + ), + "twilio_list_picker": ( + self.twilio_list_picker.to_dict() + if self.twilio_list_picker is not None + else None + ), + "twilio_call_to_action": ( + self.twilio_call_to_action.to_dict() + if self.twilio_call_to_action is not None + else None + ), + "twilio_quick_reply": ( + self.twilio_quick_reply.to_dict() + if self.twilio_quick_reply is not None + else None + ), + "twilio_card": ( + self.twilio_card.to_dict() if self.twilio_card is not None else None + ), + "twilio_catalog": ( + self.twilio_catalog.to_dict() + if self.twilio_catalog is not None + else None + ), + "twilio_carousel": ( + self.twilio_carousel.to_dict() + if self.twilio_carousel is not None + else None + ), + "twilio_flows": ( + self.twilio_flows.to_dict() + if self.twilio_flows is not None + else None + ), + "twilio_schedule": ( + self.twilio_schedule.to_dict() + if self.twilio_schedule is not None + else None + ), + "whatsapp_card": ( + self.whatsapp_card.to_dict() + if self.whatsapp_card is not None + else None + ), + "whatsapp_authentication": ( + self.whatsapp_authentication.to_dict() + if self.whatsapp_authentication is not None + else None + ), + } - :returns: The fetched ContentInstance + class WhatsappAuthentication(object): """ - return self._proxy.fetch() - - async def fetch_async(self) -> "ContentInstance": + :ivar add_security_recommendation: + :ivar code_expiration_minutes: + :ivar actions: """ - Asynchronous coroutine to fetch the ContentInstance + def __init__(self, payload: Dict[str, Any]): - :returns: The fetched ContentInstance - """ - return await self._proxy.fetch_async() + self.add_security_recommendation: Optional[bool] = payload.get( + "add_security_recommendation" + ) + self.code_expiration_minutes: Optional[float] = payload.get( + "code_expiration_minutes" + ) + self.actions: Optional[List[ContentList.AuthenticationAction]] = ( + payload.get("actions") + ) - @property - def approval_create(self) -> ApprovalCreateList: - """ - Access the approval_create - """ - return self._proxy.approval_create + def to_dict(self): + return { + "add_security_recommendation": self.add_security_recommendation, + "code_expiration_minutes": self.code_expiration_minutes, + "actions": ( + [actions.to_dict() for actions in self.actions] + if self.actions is not None + else None + ), + } - @property - def approval_fetch(self) -> ApprovalFetchList: - """ - Access the approval_fetch + class WhatsappCard(object): """ - return self._proxy.approval_fetch - - def __repr__(self) -> str: + :ivar body: + :ivar footer: + :ivar media: + :ivar header_text: + :ivar actions: """ - Provide a friendly representation - :returns: Machine friendly representation - """ - context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) - return "".format(context) + def __init__(self, payload: Dict[str, Any]): + self.body: Optional[str] = payload.get("body") + self.footer: Optional[str] = payload.get("footer") + self.media: Optional[List[str]] = payload.get("media") + self.header_text: Optional[str] = payload.get("header_text") + self.actions: Optional[List[ContentList.CardAction]] = payload.get( + "actions" + ) -class ContentContext(InstanceContext): + def to_dict(self): + return { + "body": self.body, + "footer": self.footer, + "media": self.media, + "header_text": self.header_text, + "actions": ( + [actions.to_dict() for actions in self.actions] + if self.actions is not None + else None + ), + } def __init__(self, version: Version, sid: str): """ @@ -181,10 +1629,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -193,9 +1641,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> ContentInstance: @@ -206,10 +1656,11 @@ def fetch(self) -> ContentInstance: :returns: The fetched ContentInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ContentInstance( self._version, @@ -225,9 +1676,12 @@ async def fetch_async(self) -> ContentInstance: :returns: The fetched ContentInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ContentInstance( @@ -297,7 +1751,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") @@ -306,7 +1760,7 @@ def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): def to_dict(self): return { - "type": self.type.to_dict(), + "type": self.type, "copy_code_text": self.copy_code_text, } @@ -316,10 +1770,10 @@ class CallToActionAction(object): :ivar title: :ivar url: :ivar phone: - :ivar id: + :ivar code: """ - 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" @@ -327,15 +1781,15 @@ def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): 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 { - "type": self.type.to_dict(), + "type": self.type, "title": self.title, "url": self.url, "phone": self.phone, - "id": self.id, + "code": self.code, } class CardAction(object): @@ -345,25 +1799,85 @@ class CardAction(object): :ivar url: :ivar phone: :ivar id: + :ivar code: """ - 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") 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 { + "type": self.type, + "title": self.title, + "url": self.url, + "phone": self.phone, + "id": self.id, + "code": self.code, + } + + 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.to_dict(), + "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] + if self.actions is not None + else None + ), + } + class CatalogItem(object): """ :ivar id: @@ -374,7 +1888,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 +1915,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") @@ -413,7 +1927,56 @@ def to_dict(self): "friendly_name": self.friendly_name, "variables": self.variables, "language": self.language, - "types": self.types.to_dict(), + "types": self.types.to_dict() if self.types is not None else None, + } + + 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] + if self.layout is not None + else None + ), + } + + class FlowsPageComponent(object): + """ + :ivar label: + :ivar type: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.label: Optional[str] = payload.get("label") + self.type: Optional[str] = payload.get("type") + + def to_dict(self): + return { + "label": self.label, + "type": self.type, } class ListItem(object): @@ -423,7 +1986,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 +2006,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" @@ -453,7 +2016,7 @@ def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): def to_dict(self): return { - "type": self.type.to_dict(), + "type": self.type, "title": self.title, "id": self.id, } @@ -464,7 +2027,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( @@ -474,7 +2037,11 @@ def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): def to_dict(self): return { "body": self.body, - "actions": [actions.to_dict() for actions in self.actions], + "actions": ( + [actions.to_dict() for actions in self.actions] + if self.actions is not None + else None + ), } class TwilioCard(object): @@ -485,7 +2052,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") @@ -499,7 +2066,32 @@ def to_dict(self): "title": self.title, "subtitle": self.subtitle, "media": self.media, - "actions": [actions.to_dict() for actions in self.actions], + "actions": ( + [actions.to_dict() for actions in self.actions] + if self.actions is not None + else None + ), + } + + 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] + if self.cards is not None + else None + ), } class TwilioCatalog(object): @@ -512,7 +2104,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") @@ -527,10 +2119,47 @@ def to_dict(self): "body": self.body, "subtitle": self.subtitle, "id": self.id, - "items": [items.to_dict() for items in self.items], + "items": ( + [items.to_dict() for items in self.items] + if self.items is not None + else None + ), "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] + if self.pages is not None + else None + ), + "type": self.type, + } + class TwilioListPicker(object): """ :ivar body: @@ -538,7 +2167,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") @@ -548,7 +2177,11 @@ def to_dict(self): return { "body": self.body, "button": self.button, - "items": [items.to_dict() for items in self.items], + "items": ( + [items.to_dict() for items in self.items] + if self.items is not None + else None + ), } class TwilioLocation(object): @@ -558,7 +2191,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 +2210,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 +2227,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( @@ -604,7 +2237,31 @@ def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): def to_dict(self): return { "body": self.body, - "actions": [actions.to_dict() for actions in self.actions], + "actions": ( + [actions.to_dict() for actions in self.actions] + if self.actions is not None + else None + ), + } + + class TwilioSchedule(object): + """ + :ivar id: + :ivar title: + :ivar time_slots: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.id: Optional[str] = payload.get("id") + self.title: Optional[str] = payload.get("title") + self.time_slots: Optional[str] = payload.get("time_slots") + + def to_dict(self): + return { + "id": self.id, + "title": self.title, + "time_slots": self.time_slots, } class TwilioText(object): @@ -612,7 +2269,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 +2288,14 @@ class Types(object): :ivar twilio_quick_reply: :ivar twilio_card: :ivar twilio_catalog: + :ivar twilio_carousel: + :ivar twilio_flows: + :ivar twilio_schedule: :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 +2321,15 @@ 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.twilio_flows: Optional[ContentList.TwilioFlows] = payload.get( + "twilio_flows" + ) + self.twilio_schedule: Optional[ContentList.TwilioSchedule] = payload.get( + "twilio_schedule" + ) self.whatsapp_card: Optional[ContentList.WhatsappCard] = payload.get( "whatsapp_card" ) @@ -670,16 +2339,67 @@ def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): def to_dict(self): return { - "twilio_text": self.twilio_text.to_dict(), - "twilio_media": self.twilio_media.to_dict(), - "twilio_location": self.twilio_location.to_dict(), - "twilio_list_picker": self.twilio_list_picker.to_dict(), - "twilio_call_to_action": self.twilio_call_to_action.to_dict(), - "twilio_quick_reply": self.twilio_quick_reply.to_dict(), - "twilio_card": self.twilio_card.to_dict(), - "twilio_catalog": self.twilio_catalog.to_dict(), - "whatsapp_card": self.whatsapp_card.to_dict(), - "whatsapp_authentication": self.whatsapp_authentication.to_dict(), + "twilio_text": ( + self.twilio_text.to_dict() if self.twilio_text is not None else None + ), + "twilio_media": ( + self.twilio_media.to_dict() + if self.twilio_media is not None + else None + ), + "twilio_location": ( + self.twilio_location.to_dict() + if self.twilio_location is not None + else None + ), + "twilio_list_picker": ( + self.twilio_list_picker.to_dict() + if self.twilio_list_picker is not None + else None + ), + "twilio_call_to_action": ( + self.twilio_call_to_action.to_dict() + if self.twilio_call_to_action is not None + else None + ), + "twilio_quick_reply": ( + self.twilio_quick_reply.to_dict() + if self.twilio_quick_reply is not None + else None + ), + "twilio_card": ( + self.twilio_card.to_dict() if self.twilio_card is not None else None + ), + "twilio_catalog": ( + self.twilio_catalog.to_dict() + if self.twilio_catalog is not None + else None + ), + "twilio_carousel": ( + self.twilio_carousel.to_dict() + if self.twilio_carousel is not None + else None + ), + "twilio_flows": ( + self.twilio_flows.to_dict() + if self.twilio_flows is not None + else None + ), + "twilio_schedule": ( + self.twilio_schedule.to_dict() + if self.twilio_schedule is not None + else None + ), + "whatsapp_card": ( + self.whatsapp_card.to_dict() + if self.whatsapp_card is not None + else None + ), + "whatsapp_authentication": ( + self.whatsapp_authentication.to_dict() + if self.whatsapp_authentication is not None + else None + ), } class WhatsappAuthentication(object): @@ -689,7 +2409,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" @@ -705,7 +2425,11 @@ def to_dict(self): return { "add_security_recommendation": self.add_security_recommendation, "code_expiration_minutes": self.code_expiration_minutes, - "actions": [actions.to_dict() for actions in self.actions], + "actions": ( + [actions.to_dict() for actions in self.actions] + if self.actions is not None + else None + ), } class WhatsappCard(object): @@ -717,7 +2441,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") @@ -733,7 +2457,11 @@ def to_dict(self): "footer": self.footer, "media": self.media, "header_text": self.header_text, - "actions": [actions.to_dict() for actions in self.actions], + "actions": ( + [actions.to_dict() for actions in self.actions] + if self.actions is not None + else None + ), } def __init__(self, version: Version): @@ -757,7 +2485,12 @@ def create(self, content_create_request: ContentCreateRequest) -> ContentInstanc """ data = content_create_request.to_dict() - headers = {"Content-Type": "application/json"} + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + payload = self._version.create( method="POST", uri=self._uri, data=data, headers=headers ) @@ -774,9 +2507,13 @@ async def create_async( :returns: The created ContentInstance """ - data = content_create_request.to_dict() - headers = {"Content-Type": "application/json"} + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" payload = await self._version.create_async( method="POST", uri=self._uri, data=data, headers=headers @@ -911,7 +2648,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ContentPage(self._version, response) async def page_async( @@ -938,8 +2681,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ContentPage(self._version, response) diff --git a/twilio/rest/content/v1/content/approval_create.py b/twilio/rest/content/v1/content/approval_create.py index 63a4474306..9f34064e35 100644 --- a/twilio/rest/content/v1/content/approval_create.py +++ b/twilio/rest/content/v1/content/approval_create.py @@ -13,6 +13,7 @@ """ 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 @@ -20,16 +21,34 @@ class ApprovalCreateInstance(InstanceResource): + + class ContentApprovalRequest(object): + """ + :ivar name: Name of the template. + :ivar category: A WhatsApp recognized template category. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.name: Optional[str] = payload.get("name") + self.category: Optional[str] = payload.get("category") + + def to_dict(self): + return { + "name": self.name, + "category": self.category, + } + """ - :ivar name: - :ivar category: - :ivar content_type: - :ivar status: - :ivar rejection_reason: - :ivar allow_category_change: + :ivar name: + :ivar category: + :ivar content_type: + :ivar status: + :ivar rejection_reason: + :ivar allow_category_change: """ - def __init__(self, version: Version, payload: Dict[str, Any], sid: str): + def __init__(self, version: Version, payload: Dict[str, Any], content_sid: str): super().__init__(version) self.name: Optional[str] = payload.get("name") @@ -42,7 +61,7 @@ def __init__(self, version: Version, payload: Dict[str, Any], sid: str): ) self._solution = { - "sid": sid, + "content_sid": content_sid, } def __repr__(self) -> str: @@ -63,7 +82,7 @@ class ContentApprovalRequest(object): :ivar category: A WhatsApp recognized template category. """ - def __init__(self, payload: Dict[str, Any], sid: str): + def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") self.category: Optional[str] = payload.get("category") @@ -74,21 +93,23 @@ def to_dict(self): "category": self.category, } - def __init__(self, version: Version, sid: str): + def __init__(self, version: Version, content_sid: str): """ Initialize the ApprovalCreateList :param version: Version that contains the resource - :param sid: + :param content_sid: """ super().__init__(version) # Path Solution self._solution = { - "sid": sid, + "content_sid": content_sid, } - self._uri = "/Content/{sid}/ApprovalRequests/whatsapp".format(**self._solution) + self._uri = "/Content/{content_sid}/ApprovalRequests/whatsapp".format( + **self._solution + ) def create( self, content_approval_request: ContentApprovalRequest @@ -102,12 +123,19 @@ def create( """ data = content_approval_request.to_dict() - headers = {"Content-Type": "application/json"} + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + payload = self._version.create( method="POST", uri=self._uri, data=data, headers=headers ) - return ApprovalCreateInstance(self._version, payload, sid=self._solution["sid"]) + return ApprovalCreateInstance( + self._version, payload, content_sid=self._solution["content_sid"] + ) async def create_async( self, content_approval_request: ContentApprovalRequest @@ -119,15 +147,21 @@ async def create_async( :returns: The created ApprovalCreateInstance """ - data = content_approval_request.to_dict() - headers = {"Content-Type": "application/json"} + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" payload = await self._version.create_async( method="POST", uri=self._uri, data=data, headers=headers ) - return ApprovalCreateInstance(self._version, payload, sid=self._solution["sid"]) + return ApprovalCreateInstance( + self._version, payload, content_sid=self._solution["content_sid"] + ) def __repr__(self) -> str: """ diff --git a/twilio/rest/content/v1/content/approval_fetch.py b/twilio/rest/content/v1/content/approval_fetch.py index f35ef6a48f..d3d00e5058 100644 --- a/twilio/rest/content/v1/content/approval_fetch.py +++ b/twilio/rest/content/v1/content/approval_fetch.py @@ -13,6 +13,7 @@ """ 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 @@ -108,10 +109,11 @@ def fetch(self) -> ApprovalFetchInstance: :returns: The fetched ApprovalFetchInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ApprovalFetchInstance( self._version, @@ -127,9 +129,12 @@ async def fetch_async(self) -> ApprovalFetchInstance: :returns: The fetched ApprovalFetchInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ApprovalFetchInstance( diff --git a/twilio/rest/content/v1/content_and_approvals.py b/twilio/rest/content/v1/content_and_approvals.py index de40cfc172..c2a210665d 100644 --- a/twilio/rest/content/v1/content_and_approvals.py +++ b/twilio/rest/content/v1/content_and_approvals.py @@ -223,7 +223,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ContentAndApprovalsPage(self._version, response) async def page_async( @@ -250,8 +256,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ContentAndApprovalsPage(self._version, response) diff --git a/twilio/rest/content/v1/legacy_content.py b/twilio/rest/content/v1/legacy_content.py index cfb4ac698d..d32778e748 100644 --- a/twilio/rest/content/v1/legacy_content.py +++ b/twilio/rest/content/v1/legacy_content.py @@ -225,7 +225,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return LegacyContentPage(self._version, response) async def page_async( @@ -252,8 +258,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return LegacyContentPage(self._version, response) diff --git a/twilio/rest/content/v2/__init__.py b/twilio/rest/content/v2/__init__.py new file mode 100644 index 0000000000..ca6d8bcd74 --- /dev/null +++ b/twilio/rest/content/v2/__init__.py @@ -0,0 +1,51 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Content + 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.content.v2.content import ContentList +from twilio.rest.content.v2.content_and_approvals import ContentAndApprovalsList + + +class V2(Version): + + def __init__(self, domain: Domain): + """ + Initialize the V2 version of Content + + :param domain: The Twilio.content domain + """ + super().__init__(domain, "v2") + self._contents: Optional[ContentList] = None + self._content_and_approvals: Optional[ContentAndApprovalsList] = None + + @property + def contents(self) -> ContentList: + if self._contents is None: + self._contents = ContentList(self) + return self._contents + + @property + def content_and_approvals(self) -> ContentAndApprovalsList: + if self._content_and_approvals is None: + self._content_and_approvals = ContentAndApprovalsList(self) + return self._content_and_approvals + + def __repr__(self) -> str: + """ + Provide a friendly representation + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/content/v2/content.py b/twilio/rest/content/v2/content.py new file mode 100644 index 0000000000..c2e2db7d8c --- /dev/null +++ b/twilio/rest/content/v2/content.py @@ -0,0 +1,464 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Content + 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_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version +from twilio.base.page import Page + + +class ContentInstance(InstanceResource): + """ + :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 sid: The unique string that that we created to identify the Content resource. + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/usage/api/account) that created Content resource. + :ivar friendly_name: A string name used to describe the Content resource. Not visible to the end recipient. + :ivar language: Two-letter (ISO 639-1) language code (e.g., en) identifying the language the Content resource is in. + :ivar variables: Defines the default placeholder values for variables included in the Content resource. e.g. {\"1\": \"Customer_Name\"}. + :ivar types: The [Content types](https://www.twilio.com/docs/content/content-types-overview) (e.g. twilio/text) for this Content resource. + :ivar url: The URL of the resource, relative to `https://content.twilio.com`. + :ivar links: A list of links related to the Content resource, such as approval_fetch and approval_create + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + 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.sid: Optional[str] = payload.get("sid") + self.account_sid: Optional[str] = payload.get("account_sid") + self.friendly_name: Optional[str] = payload.get("friendly_name") + self.language: Optional[str] = payload.get("language") + self.variables: Optional[Dict[str, object]] = payload.get("variables") + self.types: Optional[Dict[str, object]] = payload.get("types") + self.url: Optional[str] = payload.get("url") + self.links: Optional[Dict[str, object]] = payload.get("links") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class ContentPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> ContentInstance: + """ + Build an instance of ContentInstance + + :param payload: Payload response from the API + """ + return ContentInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class ContentList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the ContentList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/Content" + + def stream( + self, + sort_by_date: Union[str, object] = values.unset, + sort_by_content_name: Union[str, object] = values.unset, + date_created_after: Union[datetime, object] = values.unset, + date_created_before: Union[datetime, object] = values.unset, + content_name: Union[str, object] = values.unset, + content: Union[str, object] = values.unset, + language: Union[List[str], object] = values.unset, + content_type: Union[List[str], object] = values.unset, + channel_eligibility: Union[List[str], object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[ContentInstance]: + """ + Streams ContentInstance 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 sort_by_date: Whether to sort by ascending or descending date updated + :param str sort_by_content_name: Whether to sort by ascending or descending content name + :param datetime date_created_after: Filter by >=[date-time] + :param datetime date_created_before: Filter by <=[date-time] + :param str content_name: Filter by Regex Pattern in content name + :param str content: Filter by Regex Pattern in template content + :param List[str] language: Filter by array of valid language(s) + :param List[str] content_type: Filter by array of contentType(s) + :param List[str] channel_eligibility: Filter by array of ChannelEligibility(s), where ChannelEligibility=: + :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( + sort_by_date=sort_by_date, + sort_by_content_name=sort_by_content_name, + date_created_after=date_created_after, + date_created_before=date_created_before, + content_name=content_name, + content=content, + language=language, + content_type=content_type, + channel_eligibility=channel_eligibility, + page_size=limits["page_size"], + ) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + sort_by_date: Union[str, object] = values.unset, + sort_by_content_name: Union[str, object] = values.unset, + date_created_after: Union[datetime, object] = values.unset, + date_created_before: Union[datetime, object] = values.unset, + content_name: Union[str, object] = values.unset, + content: Union[str, object] = values.unset, + language: Union[List[str], object] = values.unset, + content_type: Union[List[str], object] = values.unset, + channel_eligibility: Union[List[str], object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[ContentInstance]: + """ + Asynchronously streams ContentInstance 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 sort_by_date: Whether to sort by ascending or descending date updated + :param str sort_by_content_name: Whether to sort by ascending or descending content name + :param datetime date_created_after: Filter by >=[date-time] + :param datetime date_created_before: Filter by <=[date-time] + :param str content_name: Filter by Regex Pattern in content name + :param str content: Filter by Regex Pattern in template content + :param List[str] language: Filter by array of valid language(s) + :param List[str] content_type: Filter by array of contentType(s) + :param List[str] channel_eligibility: Filter by array of ChannelEligibility(s), where ChannelEligibility=: + :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( + sort_by_date=sort_by_date, + sort_by_content_name=sort_by_content_name, + date_created_after=date_created_after, + date_created_before=date_created_before, + content_name=content_name, + content=content, + language=language, + content_type=content_type, + channel_eligibility=channel_eligibility, + page_size=limits["page_size"], + ) + + return self._version.stream_async(page, limits["limit"]) + + def list( + self, + sort_by_date: Union[str, object] = values.unset, + sort_by_content_name: Union[str, object] = values.unset, + date_created_after: Union[datetime, object] = values.unset, + date_created_before: Union[datetime, object] = values.unset, + content_name: Union[str, object] = values.unset, + content: Union[str, object] = values.unset, + language: Union[List[str], object] = values.unset, + content_type: Union[List[str], object] = values.unset, + channel_eligibility: Union[List[str], object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[ContentInstance]: + """ + Lists ContentInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str sort_by_date: Whether to sort by ascending or descending date updated + :param str sort_by_content_name: Whether to sort by ascending or descending content name + :param datetime date_created_after: Filter by >=[date-time] + :param datetime date_created_before: Filter by <=[date-time] + :param str content_name: Filter by Regex Pattern in content name + :param str content: Filter by Regex Pattern in template content + :param List[str] language: Filter by array of valid language(s) + :param List[str] content_type: Filter by array of contentType(s) + :param List[str] channel_eligibility: Filter by array of ChannelEligibility(s), where ChannelEligibility=: + :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( + sort_by_date=sort_by_date, + sort_by_content_name=sort_by_content_name, + date_created_after=date_created_after, + date_created_before=date_created_before, + content_name=content_name, + content=content, + language=language, + content_type=content_type, + channel_eligibility=channel_eligibility, + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + sort_by_date: Union[str, object] = values.unset, + sort_by_content_name: Union[str, object] = values.unset, + date_created_after: Union[datetime, object] = values.unset, + date_created_before: Union[datetime, object] = values.unset, + content_name: Union[str, object] = values.unset, + content: Union[str, object] = values.unset, + language: Union[List[str], object] = values.unset, + content_type: Union[List[str], object] = values.unset, + channel_eligibility: Union[List[str], object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[ContentInstance]: + """ + Asynchronously lists ContentInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str sort_by_date: Whether to sort by ascending or descending date updated + :param str sort_by_content_name: Whether to sort by ascending or descending content name + :param datetime date_created_after: Filter by >=[date-time] + :param datetime date_created_before: Filter by <=[date-time] + :param str content_name: Filter by Regex Pattern in content name + :param str content: Filter by Regex Pattern in template content + :param List[str] language: Filter by array of valid language(s) + :param List[str] content_type: Filter by array of contentType(s) + :param List[str] channel_eligibility: Filter by array of ChannelEligibility(s), where ChannelEligibility=: + :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( + sort_by_date=sort_by_date, + sort_by_content_name=sort_by_content_name, + date_created_after=date_created_after, + date_created_before=date_created_before, + content_name=content_name, + content=content, + language=language, + content_type=content_type, + channel_eligibility=channel_eligibility, + limit=limit, + page_size=page_size, + ) + ] + + def page( + self, + sort_by_date: Union[str, object] = values.unset, + sort_by_content_name: Union[str, object] = values.unset, + date_created_after: Union[datetime, object] = values.unset, + date_created_before: Union[datetime, object] = values.unset, + content_name: Union[str, object] = values.unset, + content: Union[str, object] = values.unset, + language: Union[List[str], object] = values.unset, + content_type: Union[List[str], object] = values.unset, + channel_eligibility: Union[List[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, + ) -> ContentPage: + """ + Retrieve a single page of ContentInstance records from the API. + Request is executed immediately + + :param sort_by_date: Whether to sort by ascending or descending date updated + :param sort_by_content_name: Whether to sort by ascending or descending content name + :param date_created_after: Filter by >=[date-time] + :param date_created_before: Filter by <=[date-time] + :param content_name: Filter by Regex Pattern in content name + :param content: Filter by Regex Pattern in template content + :param language: Filter by array of valid language(s) + :param content_type: Filter by array of contentType(s) + :param channel_eligibility: Filter by array of ChannelEligibility(s), where ChannelEligibility=: + :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 ContentInstance + """ + data = values.of( + { + "SortByDate": sort_by_date, + "SortByContentName": sort_by_content_name, + "DateCreatedAfter": serialize.iso8601_datetime(date_created_after), + "DateCreatedBefore": serialize.iso8601_datetime(date_created_before), + "ContentName": content_name, + "Content": content, + "Language": serialize.map(language, lambda e: e), + "ContentType": serialize.map(content_type, lambda e: e), + "ChannelEligibility": serialize.map(channel_eligibility, lambda e: e), + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return ContentPage(self._version, response) + + async def page_async( + self, + sort_by_date: Union[str, object] = values.unset, + sort_by_content_name: Union[str, object] = values.unset, + date_created_after: Union[datetime, object] = values.unset, + date_created_before: Union[datetime, object] = values.unset, + content_name: Union[str, object] = values.unset, + content: Union[str, object] = values.unset, + language: Union[List[str], object] = values.unset, + content_type: Union[List[str], object] = values.unset, + channel_eligibility: Union[List[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, + ) -> ContentPage: + """ + Asynchronously retrieve a single page of ContentInstance records from the API. + Request is executed immediately + + :param sort_by_date: Whether to sort by ascending or descending date updated + :param sort_by_content_name: Whether to sort by ascending or descending content name + :param date_created_after: Filter by >=[date-time] + :param date_created_before: Filter by <=[date-time] + :param content_name: Filter by Regex Pattern in content name + :param content: Filter by Regex Pattern in template content + :param language: Filter by array of valid language(s) + :param content_type: Filter by array of contentType(s) + :param channel_eligibility: Filter by array of ChannelEligibility(s), where ChannelEligibility=: + :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 ContentInstance + """ + data = values.of( + { + "SortByDate": sort_by_date, + "SortByContentName": sort_by_content_name, + "DateCreatedAfter": serialize.iso8601_datetime(date_created_after), + "DateCreatedBefore": serialize.iso8601_datetime(date_created_before), + "ContentName": content_name, + "Content": content, + "Language": serialize.map(language, lambda e: e), + "ContentType": serialize.map(content_type, lambda e: e), + "ChannelEligibility": serialize.map(channel_eligibility, lambda e: e), + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + return ContentPage(self._version, response) + + def get_page(self, target_url: str) -> ContentPage: + """ + Retrieve a specific page of ContentInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of ContentInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return ContentPage(self._version, response) + + async def get_page_async(self, target_url: str) -> ContentPage: + """ + Asynchronously retrieve a specific page of ContentInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of ContentInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return ContentPage(self._version, response) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/content/v2/content_and_approvals.py b/twilio/rest/content/v2/content_and_approvals.py new file mode 100644 index 0000000000..823bcfe083 --- /dev/null +++ b/twilio/rest/content/v2/content_and_approvals.py @@ -0,0 +1,464 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Content + 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_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version +from twilio.base.page import Page + + +class ContentAndApprovalsInstance(InstanceResource): + """ + :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 sid: The unique string that that we created to identify the Content resource. + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/usage/api/account) that created Content resource. + :ivar friendly_name: A string name used to describe the Content resource. Not visible to the end recipient. + :ivar language: Two-letter (ISO 639-1) language code (e.g., en) identifying the language the Content resource is in. + :ivar variables: Defines the default placeholder values for variables included in the Content resource. e.g. {\"1\": \"Customer_Name\"}. + :ivar types: The [Content types](https://www.twilio.com/docs/content/content-types-overview) (e.g. twilio/text) for this Content resource. + :ivar approval_requests: The submitted information and approval request status of the Content resource. + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + 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.sid: Optional[str] = payload.get("sid") + self.account_sid: Optional[str] = payload.get("account_sid") + self.friendly_name: Optional[str] = payload.get("friendly_name") + self.language: Optional[str] = payload.get("language") + self.variables: Optional[Dict[str, object]] = payload.get("variables") + self.types: Optional[Dict[str, object]] = payload.get("types") + self.approval_requests: Optional[Dict[str, object]] = payload.get( + "approval_requests" + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class ContentAndApprovalsPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> ContentAndApprovalsInstance: + """ + Build an instance of ContentAndApprovalsInstance + + :param payload: Payload response from the API + """ + return ContentAndApprovalsInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class ContentAndApprovalsList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the ContentAndApprovalsList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/ContentAndApprovals" + + def stream( + self, + sort_by_date: Union[str, object] = values.unset, + sort_by_content_name: Union[str, object] = values.unset, + date_created_after: Union[datetime, object] = values.unset, + date_created_before: Union[datetime, object] = values.unset, + content_name: Union[str, object] = values.unset, + content: Union[str, object] = values.unset, + language: Union[List[str], object] = values.unset, + content_type: Union[List[str], object] = values.unset, + channel_eligibility: Union[List[str], object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[ContentAndApprovalsInstance]: + """ + Streams ContentAndApprovalsInstance 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 sort_by_date: Whether to sort by ascending or descending date updated + :param str sort_by_content_name: Whether to sort by ascending or descending content name + :param datetime date_created_after: Filter by >=[date-time] + :param datetime date_created_before: Filter by <=[date-time] + :param str content_name: Filter by Regex Pattern in content name + :param str content: Filter by Regex Pattern in template content + :param List[str] language: Filter by array of valid language(s) + :param List[str] content_type: Filter by array of contentType(s) + :param List[str] channel_eligibility: Filter by array of ChannelEligibility(s), where ChannelEligibility=: + :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( + sort_by_date=sort_by_date, + sort_by_content_name=sort_by_content_name, + date_created_after=date_created_after, + date_created_before=date_created_before, + content_name=content_name, + content=content, + language=language, + content_type=content_type, + channel_eligibility=channel_eligibility, + page_size=limits["page_size"], + ) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + sort_by_date: Union[str, object] = values.unset, + sort_by_content_name: Union[str, object] = values.unset, + date_created_after: Union[datetime, object] = values.unset, + date_created_before: Union[datetime, object] = values.unset, + content_name: Union[str, object] = values.unset, + content: Union[str, object] = values.unset, + language: Union[List[str], object] = values.unset, + content_type: Union[List[str], object] = values.unset, + channel_eligibility: Union[List[str], object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[ContentAndApprovalsInstance]: + """ + Asynchronously streams ContentAndApprovalsInstance 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 sort_by_date: Whether to sort by ascending or descending date updated + :param str sort_by_content_name: Whether to sort by ascending or descending content name + :param datetime date_created_after: Filter by >=[date-time] + :param datetime date_created_before: Filter by <=[date-time] + :param str content_name: Filter by Regex Pattern in content name + :param str content: Filter by Regex Pattern in template content + :param List[str] language: Filter by array of valid language(s) + :param List[str] content_type: Filter by array of contentType(s) + :param List[str] channel_eligibility: Filter by array of ChannelEligibility(s), where ChannelEligibility=: + :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( + sort_by_date=sort_by_date, + sort_by_content_name=sort_by_content_name, + date_created_after=date_created_after, + date_created_before=date_created_before, + content_name=content_name, + content=content, + language=language, + content_type=content_type, + channel_eligibility=channel_eligibility, + page_size=limits["page_size"], + ) + + return self._version.stream_async(page, limits["limit"]) + + def list( + self, + sort_by_date: Union[str, object] = values.unset, + sort_by_content_name: Union[str, object] = values.unset, + date_created_after: Union[datetime, object] = values.unset, + date_created_before: Union[datetime, object] = values.unset, + content_name: Union[str, object] = values.unset, + content: Union[str, object] = values.unset, + language: Union[List[str], object] = values.unset, + content_type: Union[List[str], object] = values.unset, + channel_eligibility: Union[List[str], object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[ContentAndApprovalsInstance]: + """ + Lists ContentAndApprovalsInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str sort_by_date: Whether to sort by ascending or descending date updated + :param str sort_by_content_name: Whether to sort by ascending or descending content name + :param datetime date_created_after: Filter by >=[date-time] + :param datetime date_created_before: Filter by <=[date-time] + :param str content_name: Filter by Regex Pattern in content name + :param str content: Filter by Regex Pattern in template content + :param List[str] language: Filter by array of valid language(s) + :param List[str] content_type: Filter by array of contentType(s) + :param List[str] channel_eligibility: Filter by array of ChannelEligibility(s), where ChannelEligibility=: + :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( + sort_by_date=sort_by_date, + sort_by_content_name=sort_by_content_name, + date_created_after=date_created_after, + date_created_before=date_created_before, + content_name=content_name, + content=content, + language=language, + content_type=content_type, + channel_eligibility=channel_eligibility, + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + sort_by_date: Union[str, object] = values.unset, + sort_by_content_name: Union[str, object] = values.unset, + date_created_after: Union[datetime, object] = values.unset, + date_created_before: Union[datetime, object] = values.unset, + content_name: Union[str, object] = values.unset, + content: Union[str, object] = values.unset, + language: Union[List[str], object] = values.unset, + content_type: Union[List[str], object] = values.unset, + channel_eligibility: Union[List[str], object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[ContentAndApprovalsInstance]: + """ + Asynchronously lists ContentAndApprovalsInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str sort_by_date: Whether to sort by ascending or descending date updated + :param str sort_by_content_name: Whether to sort by ascending or descending content name + :param datetime date_created_after: Filter by >=[date-time] + :param datetime date_created_before: Filter by <=[date-time] + :param str content_name: Filter by Regex Pattern in content name + :param str content: Filter by Regex Pattern in template content + :param List[str] language: Filter by array of valid language(s) + :param List[str] content_type: Filter by array of contentType(s) + :param List[str] channel_eligibility: Filter by array of ChannelEligibility(s), where ChannelEligibility=: + :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( + sort_by_date=sort_by_date, + sort_by_content_name=sort_by_content_name, + date_created_after=date_created_after, + date_created_before=date_created_before, + content_name=content_name, + content=content, + language=language, + content_type=content_type, + channel_eligibility=channel_eligibility, + limit=limit, + page_size=page_size, + ) + ] + + def page( + self, + sort_by_date: Union[str, object] = values.unset, + sort_by_content_name: Union[str, object] = values.unset, + date_created_after: Union[datetime, object] = values.unset, + date_created_before: Union[datetime, object] = values.unset, + content_name: Union[str, object] = values.unset, + content: Union[str, object] = values.unset, + language: Union[List[str], object] = values.unset, + content_type: Union[List[str], object] = values.unset, + channel_eligibility: Union[List[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, + ) -> ContentAndApprovalsPage: + """ + Retrieve a single page of ContentAndApprovalsInstance records from the API. + Request is executed immediately + + :param sort_by_date: Whether to sort by ascending or descending date updated + :param sort_by_content_name: Whether to sort by ascending or descending content name + :param date_created_after: Filter by >=[date-time] + :param date_created_before: Filter by <=[date-time] + :param content_name: Filter by Regex Pattern in content name + :param content: Filter by Regex Pattern in template content + :param language: Filter by array of valid language(s) + :param content_type: Filter by array of contentType(s) + :param channel_eligibility: Filter by array of ChannelEligibility(s), where ChannelEligibility=: + :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 ContentAndApprovalsInstance + """ + data = values.of( + { + "SortByDate": sort_by_date, + "SortByContentName": sort_by_content_name, + "DateCreatedAfter": serialize.iso8601_datetime(date_created_after), + "DateCreatedBefore": serialize.iso8601_datetime(date_created_before), + "ContentName": content_name, + "Content": content, + "Language": serialize.map(language, lambda e: e), + "ContentType": serialize.map(content_type, lambda e: e), + "ChannelEligibility": serialize.map(channel_eligibility, lambda e: e), + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return ContentAndApprovalsPage(self._version, response) + + async def page_async( + self, + sort_by_date: Union[str, object] = values.unset, + sort_by_content_name: Union[str, object] = values.unset, + date_created_after: Union[datetime, object] = values.unset, + date_created_before: Union[datetime, object] = values.unset, + content_name: Union[str, object] = values.unset, + content: Union[str, object] = values.unset, + language: Union[List[str], object] = values.unset, + content_type: Union[List[str], object] = values.unset, + channel_eligibility: Union[List[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, + ) -> ContentAndApprovalsPage: + """ + Asynchronously retrieve a single page of ContentAndApprovalsInstance records from the API. + Request is executed immediately + + :param sort_by_date: Whether to sort by ascending or descending date updated + :param sort_by_content_name: Whether to sort by ascending or descending content name + :param date_created_after: Filter by >=[date-time] + :param date_created_before: Filter by <=[date-time] + :param content_name: Filter by Regex Pattern in content name + :param content: Filter by Regex Pattern in template content + :param language: Filter by array of valid language(s) + :param content_type: Filter by array of contentType(s) + :param channel_eligibility: Filter by array of ChannelEligibility(s), where ChannelEligibility=: + :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 ContentAndApprovalsInstance + """ + data = values.of( + { + "SortByDate": sort_by_date, + "SortByContentName": sort_by_content_name, + "DateCreatedAfter": serialize.iso8601_datetime(date_created_after), + "DateCreatedBefore": serialize.iso8601_datetime(date_created_before), + "ContentName": content_name, + "Content": content, + "Language": serialize.map(language, lambda e: e), + "ContentType": serialize.map(content_type, lambda e: e), + "ChannelEligibility": serialize.map(channel_eligibility, lambda e: e), + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + return ContentAndApprovalsPage(self._version, response) + + def get_page(self, target_url: str) -> ContentAndApprovalsPage: + """ + Retrieve a specific page of ContentAndApprovalsInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of ContentAndApprovalsInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return ContentAndApprovalsPage(self._version, response) + + async def get_page_async(self, target_url: str) -> ContentAndApprovalsPage: + """ + Asynchronously retrieve a specific page of ContentAndApprovalsInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of ContentAndApprovalsInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return ContentAndApprovalsPage(self._version, response) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/conversations/v1/__init__.py b/twilio/rest/conversations/v1/__init__.py index 3296ba2b46..1ec6c22a7b 100644 --- a/twilio/rest/conversations/v1/__init__.py +++ b/twilio/rest/conversations/v1/__init__.py @@ -18,6 +18,9 @@ from twilio.rest.conversations.v1.address_configuration import AddressConfigurationList from twilio.rest.conversations.v1.configuration import ConfigurationList from twilio.rest.conversations.v1.conversation import ConversationList +from twilio.rest.conversations.v1.conversation_with_participants import ( + ConversationWithParticipantsList, +) from twilio.rest.conversations.v1.credential import CredentialList from twilio.rest.conversations.v1.participant_conversation import ( ParticipantConversationList, @@ -39,6 +42,9 @@ def __init__(self, domain: Domain): self._address_configurations: Optional[AddressConfigurationList] = None self._configuration: Optional[ConfigurationList] = None self._conversations: Optional[ConversationList] = None + self._conversation_with_participants: Optional[ + ConversationWithParticipantsList + ] = None self._credentials: Optional[CredentialList] = None self._participant_conversations: Optional[ParticipantConversationList] = None self._roles: Optional[RoleList] = None @@ -63,6 +69,14 @@ def conversations(self) -> ConversationList: self._conversations = ConversationList(self) return self._conversations + @property + def conversation_with_participants(self) -> ConversationWithParticipantsList: + if self._conversation_with_participants is None: + self._conversation_with_participants = ConversationWithParticipantsList( + self + ) + return self._conversation_with_participants + @property def credentials(self) -> CredentialList: if self._credentials is None: diff --git a/twilio/rest/conversations/v1/address_configuration.py b/twilio/rest/conversations/v1/address_configuration.py index 86cdb08066..c12e3c7170 100644 --- a/twilio/rest/conversations/v1/address_configuration.py +++ b/twilio/rest/conversations/v1/address_configuration.py @@ -39,6 +39,9 @@ class Type(object): MESSENGER = "messenger" GBM = "gbm" EMAIL = "email" + RCS = "rcs" + APPLE = "apple" + CHAT = "chat" """ :ivar sid: A 34 character string that uniquely identifies this resource. @@ -251,10 +254,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -263,9 +266,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> AddressConfigurationInstance: @@ -276,10 +281,11 @@ def fetch(self) -> AddressConfigurationInstance: :returns: The fetched AddressConfigurationInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return AddressConfigurationInstance( self._version, @@ -295,9 +301,12 @@ async def fetch_async(self) -> AddressConfigurationInstance: :returns: The fetched AddressConfigurationInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return AddressConfigurationInstance( @@ -337,6 +346,7 @@ def update( :returns: The updated AddressConfigurationInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -354,11 +364,14 @@ def update( "AutoCreation.StudioRetryCount": auto_creation_studio_retry_count, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AddressConfigurationInstance( @@ -396,6 +409,7 @@ async def update_async( :returns: The updated AddressConfigurationInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -413,11 +427,14 @@ async def update_async( "AutoCreation.StudioRetryCount": auto_creation_studio_retry_count, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AddressConfigurationInstance( @@ -526,11 +543,14 @@ def create( "AddressCountry": address_country, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AddressConfigurationInstance(self._version, payload) @@ -593,11 +613,14 @@ async def create_async( "AddressCountry": address_country, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AddressConfigurationInstance(self._version, payload) @@ -742,7 +765,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return AddressConfigurationPage(self._version, response) async def page_async( @@ -772,8 +801,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return AddressConfigurationPage(self._version, response) diff --git a/twilio/rest/conversations/v1/configuration/__init__.py b/twilio/rest/conversations/v1/configuration/__init__.py index 46f511aa1e..584082353f 100644 --- a/twilio/rest/conversations/v1/configuration/__init__.py +++ b/twilio/rest/conversations/v1/configuration/__init__.py @@ -162,10 +162,11 @@ def fetch(self) -> ConfigurationInstance: :returns: The fetched ConfigurationInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ConfigurationInstance( self._version, @@ -180,9 +181,12 @@ async def fetch_async(self) -> ConfigurationInstance: :returns: The fetched ConfigurationInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ConfigurationInstance( @@ -207,6 +211,7 @@ def update( :returns: The updated ConfigurationInstance """ + data = values.of( { "DefaultChatServiceSid": default_chat_service_sid, @@ -215,11 +220,14 @@ def update( "DefaultClosedTimer": default_closed_timer, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ConfigurationInstance(self._version, payload) @@ -241,6 +249,7 @@ async def update_async( :returns: The updated ConfigurationInstance """ + data = values.of( { "DefaultChatServiceSid": default_chat_service_sid, @@ -249,11 +258,14 @@ async def update_async( "DefaultClosedTimer": default_closed_timer, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ConfigurationInstance(self._version, payload) diff --git a/twilio/rest/conversations/v1/configuration/webhook.py b/twilio/rest/conversations/v1/configuration/webhook.py index 4ece54232c..f471c879ab 100644 --- a/twilio/rest/conversations/v1/configuration/webhook.py +++ b/twilio/rest/conversations/v1/configuration/webhook.py @@ -33,7 +33,7 @@ class Target(object): """ :ivar account_sid: The unique ID of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this conversation. :ivar method: - :ivar filters: The list of webhook event triggers that are enabled for this Service: `onMessageAdded`, `onMessageUpdated`, `onMessageRemoved`, `onConversationUpdated`, `onConversationRemoved`, `onParticipantAdded`, `onParticipantUpdated`, `onParticipantRemoved` + :ivar filters: The list of webhook event triggers that are enabled for this Service: `onMessageAdded`, `onMessageUpdated`, `onMessageRemoved`, `onMessageAdd`, `onMessageUpdate`, `onMessageRemove`, `onConversationUpdated`, `onConversationRemoved`, `onConversationAdd`, `onConversationAdded`, `onConversationRemove`, `onConversationUpdate`, `onConversationStateUpdated`, `onParticipantAdded`, `onParticipantUpdated`, `onParticipantRemoved`, `onParticipantAdd`, `onParticipantRemove`, `onParticipantUpdate`, `onDeliveryUpdated`, `onUserAdded`, `onUserUpdate`, `onUserUpdated` :ivar pre_webhook_url: The absolute url the pre-event webhook request should be sent to. :ivar post_webhook_url: The absolute url the post-event webhook request should be sent to. :ivar target: @@ -97,7 +97,7 @@ def update( Update the WebhookInstance :param method: The HTTP method to be used when sending a webhook request. - :param filters: The list of webhook event triggers that are enabled for this Service: `onMessageAdded`, `onMessageUpdated`, `onMessageRemoved`, `onConversationUpdated`, `onConversationRemoved`, `onParticipantAdded`, `onParticipantUpdated`, `onParticipantRemoved` + :param filters: The list of webhook event triggers that are enabled for this Service: `onMessageAdded`, `onMessageUpdated`, `onMessageRemoved`, `onMessageAdd`, `onMessageUpdate`, `onMessageRemove`, `onConversationUpdated`, `onConversationRemoved`, `onConversationAdd`, `onConversationAdded`, `onConversationRemove`, `onConversationUpdate`, `onConversationStateUpdated`, `onParticipantAdded`, `onParticipantUpdated`, `onParticipantRemoved`, `onParticipantAdd`, `onParticipantRemove`, `onParticipantUpdate`, `onDeliveryUpdated`, `onUserAdded`, `onUserUpdate`, `onUserUpdated` :param pre_webhook_url: The absolute url the pre-event webhook request should be sent to. :param post_webhook_url: The absolute url the post-event webhook request should be sent to. :param target: @@ -124,7 +124,7 @@ async def update_async( Asynchronous coroutine to update the WebhookInstance :param method: The HTTP method to be used when sending a webhook request. - :param filters: The list of webhook event triggers that are enabled for this Service: `onMessageAdded`, `onMessageUpdated`, `onMessageRemoved`, `onConversationUpdated`, `onConversationRemoved`, `onParticipantAdded`, `onParticipantUpdated`, `onParticipantRemoved` + :param filters: The list of webhook event triggers that are enabled for this Service: `onMessageAdded`, `onMessageUpdated`, `onMessageRemoved`, `onMessageAdd`, `onMessageUpdate`, `onMessageRemove`, `onConversationUpdated`, `onConversationRemoved`, `onConversationAdd`, `onConversationAdded`, `onConversationRemove`, `onConversationUpdate`, `onConversationStateUpdated`, `onParticipantAdded`, `onParticipantUpdated`, `onParticipantRemoved`, `onParticipantAdd`, `onParticipantRemove`, `onParticipantUpdate`, `onDeliveryUpdated`, `onUserAdded`, `onUserUpdate`, `onUserUpdated` :param pre_webhook_url: The absolute url the pre-event webhook request should be sent to. :param post_webhook_url: The absolute url the post-event webhook request should be sent to. :param target: @@ -169,10 +169,11 @@ def fetch(self) -> WebhookInstance: :returns: The fetched WebhookInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return WebhookInstance( self._version, @@ -187,9 +188,12 @@ async def fetch_async(self) -> WebhookInstance: :returns: The fetched WebhookInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return WebhookInstance( @@ -209,13 +213,14 @@ def update( Update the WebhookInstance :param method: The HTTP method to be used when sending a webhook request. - :param filters: The list of webhook event triggers that are enabled for this Service: `onMessageAdded`, `onMessageUpdated`, `onMessageRemoved`, `onConversationUpdated`, `onConversationRemoved`, `onParticipantAdded`, `onParticipantUpdated`, `onParticipantRemoved` + :param filters: The list of webhook event triggers that are enabled for this Service: `onMessageAdded`, `onMessageUpdated`, `onMessageRemoved`, `onMessageAdd`, `onMessageUpdate`, `onMessageRemove`, `onConversationUpdated`, `onConversationRemoved`, `onConversationAdd`, `onConversationAdded`, `onConversationRemove`, `onConversationUpdate`, `onConversationStateUpdated`, `onParticipantAdded`, `onParticipantUpdated`, `onParticipantRemoved`, `onParticipantAdd`, `onParticipantRemove`, `onParticipantUpdate`, `onDeliveryUpdated`, `onUserAdded`, `onUserUpdate`, `onUserUpdated` :param pre_webhook_url: The absolute url the pre-event webhook request should be sent to. :param post_webhook_url: The absolute url the post-event webhook request should be sent to. :param target: :returns: The updated WebhookInstance """ + data = values.of( { "Method": method, @@ -225,11 +230,14 @@ def update( "Target": target, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WebhookInstance(self._version, payload) @@ -246,13 +254,14 @@ async def update_async( Asynchronous coroutine to update the WebhookInstance :param method: The HTTP method to be used when sending a webhook request. - :param filters: The list of webhook event triggers that are enabled for this Service: `onMessageAdded`, `onMessageUpdated`, `onMessageRemoved`, `onConversationUpdated`, `onConversationRemoved`, `onParticipantAdded`, `onParticipantUpdated`, `onParticipantRemoved` + :param filters: The list of webhook event triggers that are enabled for this Service: `onMessageAdded`, `onMessageUpdated`, `onMessageRemoved`, `onMessageAdd`, `onMessageUpdate`, `onMessageRemove`, `onConversationUpdated`, `onConversationRemoved`, `onConversationAdd`, `onConversationAdded`, `onConversationRemove`, `onConversationUpdate`, `onConversationStateUpdated`, `onParticipantAdded`, `onParticipantUpdated`, `onParticipantRemoved`, `onParticipantAdd`, `onParticipantRemove`, `onParticipantUpdate`, `onDeliveryUpdated`, `onUserAdded`, `onUserUpdate`, `onUserUpdated` :param pre_webhook_url: The absolute url the pre-event webhook request should be sent to. :param post_webhook_url: The absolute url the post-event webhook request should be sent to. :param target: :returns: The updated WebhookInstance """ + data = values.of( { "Method": method, @@ -262,11 +271,14 @@ async def update_async( "Target": target, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WebhookInstance(self._version, payload) diff --git a/twilio/rest/conversations/v1/conversation/__init__.py b/twilio/rest/conversations/v1/conversation/__init__.py index bdb4bda324..d1f08cc2d8 100644 --- a/twilio/rest/conversations/v1/conversation/__init__.py +++ b/twilio/rest/conversations/v1/conversation/__init__.py @@ -320,6 +320,8 @@ def delete( } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async( @@ -341,6 +343,8 @@ async def delete_async( } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -353,10 +357,11 @@ def fetch(self) -> ConversationInstance: :returns: The fetched ConversationInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ConversationInstance( self._version, @@ -372,9 +377,12 @@ async def fetch_async(self) -> ConversationInstance: :returns: The fetched ConversationInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ConversationInstance( @@ -418,6 +426,7 @@ def update( :returns: The updated ConversationInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -433,11 +442,20 @@ def update( "Bindings.Email.Name": bindings_email_name, } ) - headers = values.of( - { - "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, - } - ) + headers = values.of({}) + + if not ( + x_twilio_webhook_enabled is values.unset + or ( + isinstance(x_twilio_webhook_enabled, str) + and not x_twilio_webhook_enabled + ) + ): + headers["X-Twilio-Webhook-Enabled"] = x_twilio_webhook_enabled + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( method="POST", uri=self._uri, data=data, headers=headers @@ -480,6 +498,7 @@ async def update_async( :returns: The updated ConversationInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -495,11 +514,20 @@ async def update_async( "Bindings.Email.Name": bindings_email_name, } ) - headers = values.of( - { - "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, - } - ) + headers = values.of({}) + + if not ( + x_twilio_webhook_enabled is values.unset + or ( + isinstance(x_twilio_webhook_enabled, str) + and not x_twilio_webhook_enabled + ) + ): + headers["X-Twilio-Webhook-Enabled"] = x_twilio_webhook_enabled + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( method="POST", uri=self._uri, data=data, headers=headers @@ -639,9 +667,14 @@ def create( headers = values.of( { "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = self._version.create( method="POST", uri=self._uri, data=data, headers=headers ) @@ -702,9 +735,14 @@ async def create_async( headers = values.of( { "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = await self._version.create_async( method="POST", uri=self._uri, data=data, headers=headers ) @@ -725,8 +763,8 @@ def stream( is reached. The results are returned as a generator, so this operation is memory efficient. - :param str start_date: Start date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the start time of the date is used (YYYY-MM-DDT00:00:00Z). Can be combined with other filters. - :param str end_date: End date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the end time of the date is used (YYYY-MM-DDT23:59:59Z). Can be combined with other filters. + :param str start_date: Specifies the beginning of the date range for filtering Conversations based on their creation date. Conversations that were created on or after this date will be included in the results. The date must be in ISO8601 format, specifically starting at the beginning of the specified date (YYYY-MM-DDT00:00:00Z), for precise filtering. This parameter can be combined with other filters. If this filter is used, the returned list is sorted by latest conversation creation date in descending order. + :param str end_date: Defines the end of the date range for filtering conversations by their creation date. Only conversations that were created on or before this date will appear in the results. The date must be in ISO8601 format, specifically capturing up to the end of the specified date (YYYY-MM-DDT23:59:59Z), to ensure that conversations from the entire end day are included. This parameter can be combined with other filters. If this filter is used, the returned list is sorted by latest conversation creation date in descending order. :param "ConversationInstance.State" state: State for sorting and filtering list of Conversations. Can be `active`, `inactive` or `closed` :param limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit @@ -761,8 +799,8 @@ async def stream_async( is reached. The results are returned as a generator, so this operation is memory efficient. - :param str start_date: Start date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the start time of the date is used (YYYY-MM-DDT00:00:00Z). Can be combined with other filters. - :param str end_date: End date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the end time of the date is used (YYYY-MM-DDT23:59:59Z). Can be combined with other filters. + :param str start_date: Specifies the beginning of the date range for filtering Conversations based on their creation date. Conversations that were created on or after this date will be included in the results. The date must be in ISO8601 format, specifically starting at the beginning of the specified date (YYYY-MM-DDT00:00:00Z), for precise filtering. This parameter can be combined with other filters. If this filter is used, the returned list is sorted by latest conversation creation date in descending order. + :param str end_date: Defines the end of the date range for filtering conversations by their creation date. Only conversations that were created on or before this date will appear in the results. The date must be in ISO8601 format, specifically capturing up to the end of the specified date (YYYY-MM-DDT23:59:59Z), to ensure that conversations from the entire end day are included. This parameter can be combined with other filters. If this filter is used, the returned list is sorted by latest conversation creation date in descending order. :param "ConversationInstance.State" state: State for sorting and filtering list of Conversations. Can be `active`, `inactive` or `closed` :param limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit @@ -796,8 +834,8 @@ def list( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param str start_date: Start date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the start time of the date is used (YYYY-MM-DDT00:00:00Z). Can be combined with other filters. - :param str end_date: End date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the end time of the date is used (YYYY-MM-DDT23:59:59Z). Can be combined with other filters. + :param str start_date: Specifies the beginning of the date range for filtering Conversations based on their creation date. Conversations that were created on or after this date will be included in the results. The date must be in ISO8601 format, specifically starting at the beginning of the specified date (YYYY-MM-DDT00:00:00Z), for precise filtering. This parameter can be combined with other filters. If this filter is used, the returned list is sorted by latest conversation creation date in descending order. + :param str end_date: Defines the end of the date range for filtering conversations by their creation date. Only conversations that were created on or before this date will appear in the results. The date must be in ISO8601 format, specifically capturing up to the end of the specified date (YYYY-MM-DDT23:59:59Z), to ensure that conversations from the entire end day are included. This parameter can be combined with other filters. If this filter is used, the returned list is sorted by latest conversation creation date in descending order. :param "ConversationInstance.State" state: State for sorting and filtering list of Conversations. Can be `active`, `inactive` or `closed` :param limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit @@ -831,8 +869,8 @@ async def list_async( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param str start_date: Start date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the start time of the date is used (YYYY-MM-DDT00:00:00Z). Can be combined with other filters. - :param str end_date: End date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the end time of the date is used (YYYY-MM-DDT23:59:59Z). Can be combined with other filters. + :param str start_date: Specifies the beginning of the date range for filtering Conversations based on their creation date. Conversations that were created on or after this date will be included in the results. The date must be in ISO8601 format, specifically starting at the beginning of the specified date (YYYY-MM-DDT00:00:00Z), for precise filtering. This parameter can be combined with other filters. If this filter is used, the returned list is sorted by latest conversation creation date in descending order. + :param str end_date: Defines the end of the date range for filtering conversations by their creation date. Only conversations that were created on or before this date will appear in the results. The date must be in ISO8601 format, specifically capturing up to the end of the specified date (YYYY-MM-DDT23:59:59Z), to ensure that conversations from the entire end day are included. This parameter can be combined with other filters. If this filter is used, the returned list is sorted by latest conversation creation date in descending order. :param "ConversationInstance.State" state: State for sorting and filtering list of Conversations. Can be `active`, `inactive` or `closed` :param limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit @@ -867,8 +905,8 @@ def page( Retrieve a single page of ConversationInstance records from the API. Request is executed immediately - :param start_date: Start date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the start time of the date is used (YYYY-MM-DDT00:00:00Z). Can be combined with other filters. - :param end_date: End date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the end time of the date is used (YYYY-MM-DDT23:59:59Z). Can be combined with other filters. + :param start_date: Specifies the beginning of the date range for filtering Conversations based on their creation date. Conversations that were created on or after this date will be included in the results. The date must be in ISO8601 format, specifically starting at the beginning of the specified date (YYYY-MM-DDT00:00:00Z), for precise filtering. This parameter can be combined with other filters. If this filter is used, the returned list is sorted by latest conversation creation date in descending order. + :param end_date: Defines the end of the date range for filtering conversations by their creation date. Only conversations that were created on or before this date will appear in the results. The date must be in ISO8601 format, specifically capturing up to the end of the specified date (YYYY-MM-DDT23:59:59Z), to ensure that conversations from the entire end day are included. This parameter can be combined with other filters. If this filter is used, the returned list is sorted by latest conversation creation date in descending order. :param state: State for sorting and filtering list of Conversations. Can be `active`, `inactive` or `closed` :param page_token: PageToken provided by the API :param page_number: Page Number, this value is simply for client state @@ -887,7 +925,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ConversationPage(self._version, response) async def page_async( @@ -903,8 +947,8 @@ async def page_async( Asynchronously retrieve a single page of ConversationInstance records from the API. Request is executed immediately - :param start_date: Start date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the start time of the date is used (YYYY-MM-DDT00:00:00Z). Can be combined with other filters. - :param end_date: End date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the end time of the date is used (YYYY-MM-DDT23:59:59Z). Can be combined with other filters. + :param start_date: Specifies the beginning of the date range for filtering Conversations based on their creation date. Conversations that were created on or after this date will be included in the results. The date must be in ISO8601 format, specifically starting at the beginning of the specified date (YYYY-MM-DDT00:00:00Z), for precise filtering. This parameter can be combined with other filters. If this filter is used, the returned list is sorted by latest conversation creation date in descending order. + :param end_date: Defines the end of the date range for filtering conversations by their creation date. Only conversations that were created on or before this date will appear in the results. The date must be in ISO8601 format, specifically capturing up to the end of the specified date (YYYY-MM-DDT23:59:59Z), to ensure that conversations from the entire end day are included. This parameter can be combined with other filters. If this filter is used, the returned list is sorted by latest conversation creation date in descending order. :param state: State for sorting and filtering list of Conversations. Can be `active`, `inactive` or `closed` :param page_token: PageToken provided by the API :param page_number: Page Number, this value is simply for client state @@ -923,8 +967,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ConversationPage(self._version, response) diff --git a/twilio/rest/conversations/v1/conversation/message/__init__.py b/twilio/rest/conversations/v1/conversation/message/__init__.py index e3e9dea1b2..04e7fdf252 100644 --- a/twilio/rest/conversations/v1/conversation/message/__init__.py +++ b/twilio/rest/conversations/v1/conversation/message/__init__.py @@ -285,6 +285,8 @@ def delete( } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async( @@ -306,6 +308,8 @@ async def delete_async( } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -318,10 +322,11 @@ def fetch(self) -> MessageInstance: :returns: The fetched MessageInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return MessageInstance( self._version, @@ -338,9 +343,12 @@ async def fetch_async(self) -> MessageInstance: :returns: The fetched MessageInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return MessageInstance( @@ -375,6 +383,7 @@ def update( :returns: The updated MessageInstance """ + data = values.of( { "Author": author, @@ -385,11 +394,20 @@ def update( "Subject": subject, } ) - headers = values.of( - { - "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, - } - ) + headers = values.of({}) + + if not ( + x_twilio_webhook_enabled is values.unset + or ( + isinstance(x_twilio_webhook_enabled, str) + and not x_twilio_webhook_enabled + ) + ): + headers["X-Twilio-Webhook-Enabled"] = x_twilio_webhook_enabled + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( method="POST", uri=self._uri, data=data, headers=headers @@ -427,6 +445,7 @@ async def update_async( :returns: The updated MessageInstance """ + data = values.of( { "Author": author, @@ -437,11 +456,20 @@ async def update_async( "Subject": subject, } ) - headers = values.of( - { - "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, - } - ) + headers = values.of({}) + + if not ( + x_twilio_webhook_enabled is values.unset + or ( + isinstance(x_twilio_webhook_enabled, str) + and not x_twilio_webhook_enabled + ) + ): + headers["X-Twilio-Webhook-Enabled"] = x_twilio_webhook_enabled + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( method="POST", uri=self._uri, data=data, headers=headers @@ -566,9 +594,14 @@ def create( headers = values.of( { "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = self._version.create( method="POST", uri=self._uri, data=data, headers=headers ) @@ -625,9 +658,14 @@ async def create_async( headers = values.of( { "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = await self._version.create_async( method="POST", uri=self._uri, data=data, headers=headers ) @@ -776,7 +814,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return MessagePage(self._version, response, self._solution) async def page_async( @@ -806,8 +850,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return MessagePage(self._version, response, self._solution) diff --git a/twilio/rest/conversations/v1/conversation/message/delivery_receipt.py b/twilio/rest/conversations/v1/conversation/message/delivery_receipt.py index 16af7892e9..2ed297e059 100644 --- a/twilio/rest/conversations/v1/conversation/message/delivery_receipt.py +++ b/twilio/rest/conversations/v1/conversation/message/delivery_receipt.py @@ -158,10 +158,11 @@ def fetch(self) -> DeliveryReceiptInstance: :returns: The fetched DeliveryReceiptInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return DeliveryReceiptInstance( self._version, @@ -179,9 +180,12 @@ async def fetch_async(self) -> DeliveryReceiptInstance: :returns: The fetched DeliveryReceiptInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return DeliveryReceiptInstance( @@ -377,7 +381,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return DeliveryReceiptPage(self._version, response, self._solution) async def page_async( @@ -404,8 +414,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return DeliveryReceiptPage(self._version, response, self._solution) diff --git a/twilio/rest/conversations/v1/conversation/participant.py b/twilio/rest/conversations/v1/conversation/participant.py index 499bdbf30a..deb652641a 100644 --- a/twilio/rest/conversations/v1/conversation/participant.py +++ b/twilio/rest/conversations/v1/conversation/participant.py @@ -285,6 +285,8 @@ def delete( } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async( @@ -306,6 +308,8 @@ async def delete_async( } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -318,10 +322,11 @@ def fetch(self) -> ParticipantInstance: :returns: The fetched ParticipantInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ParticipantInstance( self._version, @@ -338,9 +343,12 @@ async def fetch_async(self) -> ParticipantInstance: :returns: The fetched ParticipantInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ParticipantInstance( @@ -381,6 +389,7 @@ def update( :returns: The updated ParticipantInstance """ + data = values.of( { "DateCreated": serialize.iso8601_datetime(date_created), @@ -394,11 +403,20 @@ def update( "LastReadTimestamp": last_read_timestamp, } ) - headers = values.of( - { - "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, - } - ) + headers = values.of({}) + + if not ( + x_twilio_webhook_enabled is values.unset + or ( + isinstance(x_twilio_webhook_enabled, str) + and not x_twilio_webhook_enabled + ) + ): + headers["X-Twilio-Webhook-Enabled"] = x_twilio_webhook_enabled + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( method="POST", uri=self._uri, data=data, headers=headers @@ -442,6 +460,7 @@ async def update_async( :returns: The updated ParticipantInstance """ + data = values.of( { "DateCreated": serialize.iso8601_datetime(date_created), @@ -455,11 +474,20 @@ async def update_async( "LastReadTimestamp": last_read_timestamp, } ) - headers = values.of( - { - "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, - } - ) + headers = values.of({}) + + if not ( + x_twilio_webhook_enabled is values.unset + or ( + isinstance(x_twilio_webhook_enabled, str) + and not x_twilio_webhook_enabled + ) + ): + headers["X-Twilio-Webhook-Enabled"] = x_twilio_webhook_enabled + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( method="POST", uri=self._uri, data=data, headers=headers @@ -568,9 +596,14 @@ def create( headers = values.of( { "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = self._version.create( method="POST", uri=self._uri, data=data, headers=headers ) @@ -624,9 +657,14 @@ async def create_async( headers = values.of( { "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = await self._version.create_async( method="POST", uri=self._uri, data=data, headers=headers ) @@ -762,7 +800,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ParticipantPage(self._version, response, self._solution) async def page_async( @@ -789,8 +833,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ParticipantPage(self._version, response, self._solution) diff --git a/twilio/rest/conversations/v1/conversation/webhook.py b/twilio/rest/conversations/v1/conversation/webhook.py index 623887986c..837f88c26f 100644 --- a/twilio/rest/conversations/v1/conversation/webhook.py +++ b/twilio/rest/conversations/v1/conversation/webhook.py @@ -216,10 +216,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -228,9 +228,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> WebhookInstance: @@ -241,10 +243,11 @@ def fetch(self) -> WebhookInstance: :returns: The fetched WebhookInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return WebhookInstance( self._version, @@ -261,9 +264,12 @@ async def fetch_async(self) -> WebhookInstance: :returns: The fetched WebhookInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return WebhookInstance( @@ -292,6 +298,7 @@ def update( :returns: The updated WebhookInstance """ + data = values.of( { "Configuration.Url": configuration_url, @@ -305,11 +312,14 @@ def update( "Configuration.FlowSid": configuration_flow_sid, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WebhookInstance( @@ -338,6 +348,7 @@ async def update_async( :returns: The updated WebhookInstance """ + data = values.of( { "Configuration.Url": configuration_url, @@ -351,11 +362,14 @@ async def update_async( "Configuration.FlowSid": configuration_flow_sid, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WebhookInstance( @@ -455,11 +469,14 @@ def create( "Configuration.ReplayAfter": configuration_replay_after, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WebhookInstance( @@ -505,11 +522,14 @@ async def create_async( "Configuration.ReplayAfter": configuration_replay_after, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WebhookInstance( @@ -643,7 +663,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return WebhookPage(self._version, response, self._solution) async def page_async( @@ -670,8 +696,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return WebhookPage(self._version, response, self._solution) diff --git a/twilio/rest/conversations/v1/conversation_with_participants.py b/twilio/rest/conversations/v1/conversation_with_participants.py new file mode 100644 index 0000000000..a818a29ca4 --- /dev/null +++ b/twilio/rest/conversations/v1/conversation_with_participants.py @@ -0,0 +1,251 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Conversations + 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 +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 ConversationWithParticipantsInstance(InstanceResource): + + class State(object): + INACTIVE = "inactive" + ACTIVE = "active" + CLOSED = "closed" + + class WebhookEnabledType(object): + TRUE = "true" + FALSE = "false" + + """ + :ivar account_sid: The unique ID of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this conversation. + :ivar chat_service_sid: The unique ID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) this conversation belongs to. + :ivar messaging_service_sid: The unique ID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) this conversation belongs to. + :ivar sid: A 34 character string that uniquely identifies this resource. + :ivar friendly_name: The human-readable name of this conversation, limited to 256 characters. Optional. + :ivar unique_name: An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource's `sid` in the URL. + :ivar attributes: An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \"{}\" will be returned. + :ivar state: + :ivar date_created: The date that this resource was created. + :ivar date_updated: The date that this resource was last updated. + :ivar timers: Timer date values representing state update for this conversation. + :ivar links: Contains absolute URLs to access the [participants](https://www.twilio.com/docs/conversations/api/conversation-participant-resource), [messages](https://www.twilio.com/docs/conversations/api/conversation-message-resource) and [webhooks](https://www.twilio.com/docs/conversations/api/conversation-scoped-webhook-resource) of this conversation. + :ivar bindings: + :ivar url: An absolute API resource URL for this conversation. + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.account_sid: Optional[str] = payload.get("account_sid") + self.chat_service_sid: Optional[str] = payload.get("chat_service_sid") + self.messaging_service_sid: Optional[str] = payload.get("messaging_service_sid") + self.sid: Optional[str] = payload.get("sid") + self.friendly_name: Optional[str] = payload.get("friendly_name") + self.unique_name: Optional[str] = payload.get("unique_name") + self.attributes: Optional[str] = payload.get("attributes") + self.state: Optional["ConversationWithParticipantsInstance.State"] = ( + payload.get("state") + ) + 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.timers: Optional[Dict[str, object]] = payload.get("timers") + self.links: Optional[Dict[str, object]] = payload.get("links") + self.bindings: Optional[Dict[str, object]] = payload.get("bindings") + self.url: Optional[str] = payload.get("url") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class ConversationWithParticipantsList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the ConversationWithParticipantsList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/ConversationWithParticipants" + + def create( + self, + x_twilio_webhook_enabled: Union[ + "ConversationWithParticipantsInstance.WebhookEnabledType", object + ] = values.unset, + friendly_name: Union[str, object] = values.unset, + unique_name: Union[str, object] = values.unset, + date_created: Union[datetime, object] = values.unset, + date_updated: Union[datetime, object] = values.unset, + messaging_service_sid: Union[str, object] = values.unset, + attributes: Union[str, object] = values.unset, + state: Union[ + "ConversationWithParticipantsInstance.State", object + ] = values.unset, + timers_inactive: Union[str, object] = values.unset, + timers_closed: Union[str, object] = values.unset, + bindings_email_address: Union[str, object] = values.unset, + bindings_email_name: Union[str, object] = values.unset, + participant: Union[List[str], object] = values.unset, + ) -> ConversationWithParticipantsInstance: + """ + Create the ConversationWithParticipantsInstance + + :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header + :param friendly_name: The human-readable name of this conversation, limited to 256 characters. Optional. + :param unique_name: An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource's `sid` in the URL. + :param date_created: The date that this resource was created. + :param date_updated: The date that this resource was last updated. + :param messaging_service_sid: The unique ID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) this conversation belongs to. + :param attributes: An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. + :param state: + :param timers_inactive: ISO8601 duration when conversation will be switched to `inactive` state. Minimum value for this timer is 1 minute. + :param timers_closed: ISO8601 duration when conversation will be switched to `closed` state. Minimum value for this timer is 10 minutes. + :param bindings_email_address: The default email address that will be used when sending outbound emails in this conversation. + :param bindings_email_name: The default name that will be used when sending outbound emails in this conversation. + :param participant: The participant to be added to the conversation in JSON format. The JSON object attributes are as parameters in [Participant Resource](https://www.twilio.com/docs/conversations/api/conversation-participant-resource). The maximum number of participants that can be added in a single request is 10. + + :returns: The created ConversationWithParticipantsInstance + """ + + data = values.of( + { + "FriendlyName": friendly_name, + "UniqueName": unique_name, + "DateCreated": serialize.iso8601_datetime(date_created), + "DateUpdated": serialize.iso8601_datetime(date_updated), + "MessagingServiceSid": messaging_service_sid, + "Attributes": attributes, + "State": state, + "Timers.Inactive": timers_inactive, + "Timers.Closed": timers_closed, + "Bindings.Email.Address": bindings_email_address, + "Bindings.Email.Name": bindings_email_name, + "Participant": serialize.map(participant, lambda e: e), + } + ) + headers = values.of( + { + "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, + "Content-Type": "application/x-www-form-urlencoded", + } + ) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = self._version.create( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return ConversationWithParticipantsInstance(self._version, payload) + + async def create_async( + self, + x_twilio_webhook_enabled: Union[ + "ConversationWithParticipantsInstance.WebhookEnabledType", object + ] = values.unset, + friendly_name: Union[str, object] = values.unset, + unique_name: Union[str, object] = values.unset, + date_created: Union[datetime, object] = values.unset, + date_updated: Union[datetime, object] = values.unset, + messaging_service_sid: Union[str, object] = values.unset, + attributes: Union[str, object] = values.unset, + state: Union[ + "ConversationWithParticipantsInstance.State", object + ] = values.unset, + timers_inactive: Union[str, object] = values.unset, + timers_closed: Union[str, object] = values.unset, + bindings_email_address: Union[str, object] = values.unset, + bindings_email_name: Union[str, object] = values.unset, + participant: Union[List[str], object] = values.unset, + ) -> ConversationWithParticipantsInstance: + """ + Asynchronously create the ConversationWithParticipantsInstance + + :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header + :param friendly_name: The human-readable name of this conversation, limited to 256 characters. Optional. + :param unique_name: An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource's `sid` in the URL. + :param date_created: The date that this resource was created. + :param date_updated: The date that this resource was last updated. + :param messaging_service_sid: The unique ID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) this conversation belongs to. + :param attributes: An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. + :param state: + :param timers_inactive: ISO8601 duration when conversation will be switched to `inactive` state. Minimum value for this timer is 1 minute. + :param timers_closed: ISO8601 duration when conversation will be switched to `closed` state. Minimum value for this timer is 10 minutes. + :param bindings_email_address: The default email address that will be used when sending outbound emails in this conversation. + :param bindings_email_name: The default name that will be used when sending outbound emails in this conversation. + :param participant: The participant to be added to the conversation in JSON format. The JSON object attributes are as parameters in [Participant Resource](https://www.twilio.com/docs/conversations/api/conversation-participant-resource). The maximum number of participants that can be added in a single request is 10. + + :returns: The created ConversationWithParticipantsInstance + """ + + data = values.of( + { + "FriendlyName": friendly_name, + "UniqueName": unique_name, + "DateCreated": serialize.iso8601_datetime(date_created), + "DateUpdated": serialize.iso8601_datetime(date_updated), + "MessagingServiceSid": messaging_service_sid, + "Attributes": attributes, + "State": state, + "Timers.Inactive": timers_inactive, + "Timers.Closed": timers_closed, + "Bindings.Email.Address": bindings_email_address, + "Bindings.Email.Name": bindings_email_name, + "Participant": serialize.map(participant, lambda e: e), + } + ) + headers = values.of( + { + "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, + "Content-Type": "application/x-www-form-urlencoded", + } + ) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return ConversationWithParticipantsInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/conversations/v1/credential.py b/twilio/rest/conversations/v1/credential.py index 120710f7e8..f382458ba7 100644 --- a/twilio/rest/conversations/v1/credential.py +++ b/twilio/rest/conversations/v1/credential.py @@ -214,10 +214,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -226,9 +226,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> CredentialInstance: @@ -239,10 +241,11 @@ def fetch(self) -> CredentialInstance: :returns: The fetched CredentialInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return CredentialInstance( self._version, @@ -258,9 +261,12 @@ async def fetch_async(self) -> CredentialInstance: :returns: The fetched CredentialInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return CredentialInstance( @@ -292,6 +298,7 @@ def update( :returns: The updated CredentialInstance """ + data = values.of( { "Type": type, @@ -303,11 +310,14 @@ def update( "Secret": secret, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CredentialInstance(self._version, payload, sid=self._solution["sid"]) @@ -335,6 +345,7 @@ async def update_async( :returns: The updated CredentialInstance """ + data = values.of( { "Type": type, @@ -346,11 +357,14 @@ async def update_async( "Secret": secret, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CredentialInstance(self._version, payload, sid=self._solution["sid"]) @@ -432,11 +446,14 @@ def create( "Secret": secret, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CredentialInstance(self._version, payload) @@ -476,11 +493,14 @@ async def create_async( "Secret": secret, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CredentialInstance(self._version, payload) @@ -612,7 +632,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return CredentialPage(self._version, response) async def page_async( @@ -639,8 +665,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return CredentialPage(self._version, response) diff --git a/twilio/rest/conversations/v1/participant_conversation.py b/twilio/rest/conversations/v1/participant_conversation.py index 7413047152..0938bd5421 100644 --- a/twilio/rest/conversations/v1/participant_conversation.py +++ b/twilio/rest/conversations/v1/participant_conversation.py @@ -285,7 +285,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ParticipantConversationPage(self._version, response) async def page_async( @@ -318,8 +324,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ParticipantConversationPage(self._version, response) diff --git a/twilio/rest/conversations/v1/role.py b/twilio/rest/conversations/v1/role.py index b5d4d2c6db..229e9b7dd4 100644 --- a/twilio/rest/conversations/v1/role.py +++ b/twilio/rest/conversations/v1/role.py @@ -173,10 +173,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -185,9 +185,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> RoleInstance: @@ -198,10 +200,11 @@ def fetch(self) -> RoleInstance: :returns: The fetched RoleInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return RoleInstance( self._version, @@ -217,9 +220,12 @@ async def fetch_async(self) -> RoleInstance: :returns: The fetched RoleInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return RoleInstance( @@ -236,16 +242,20 @@ def update(self, permission: List[str]) -> RoleInstance: :returns: The updated RoleInstance """ + data = values.of( { "Permission": serialize.map(permission, lambda e: e), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RoleInstance(self._version, payload, sid=self._solution["sid"]) @@ -258,16 +268,20 @@ async def update_async(self, permission: List[str]) -> RoleInstance: :returns: The updated RoleInstance """ + data = values.of( { "Permission": serialize.map(permission, lambda e: e), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RoleInstance(self._version, payload, sid=self._solution["sid"]) @@ -334,11 +348,14 @@ def create( "Permission": serialize.map(permission, lambda e: e), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RoleInstance(self._version, payload) @@ -363,11 +380,14 @@ async def create_async( "Permission": serialize.map(permission, lambda e: e), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RoleInstance(self._version, payload) @@ -499,7 +519,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return RolePage(self._version, response) async def page_async( @@ -526,8 +552,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return RolePage(self._version, response) diff --git a/twilio/rest/conversations/v1/service/__init__.py b/twilio/rest/conversations/v1/service/__init__.py index 2a9f12090b..3b92c87934 100644 --- a/twilio/rest/conversations/v1/service/__init__.py +++ b/twilio/rest/conversations/v1/service/__init__.py @@ -23,6 +23,9 @@ from twilio.rest.conversations.v1.service.binding import BindingList from twilio.rest.conversations.v1.service.configuration import ConfigurationList from twilio.rest.conversations.v1.service.conversation import ConversationList +from twilio.rest.conversations.v1.service.conversation_with_participants import ( + ConversationWithParticipantsList, +) from twilio.rest.conversations.v1.service.participant_conversation import ( ParticipantConversationList, ) @@ -135,6 +138,13 @@ def conversations(self) -> ConversationList: """ return self._proxy.conversations + @property + def conversation_with_participants(self) -> ConversationWithParticipantsList: + """ + Access the conversation_with_participants + """ + return self._proxy.conversation_with_participants + @property def participant_conversations(self) -> ParticipantConversationList: """ @@ -186,6 +196,9 @@ def __init__(self, version: Version, sid: str): self._bindings: Optional[BindingList] = None self._configuration: Optional[ConfigurationList] = None self._conversations: Optional[ConversationList] = None + self._conversation_with_participants: Optional[ + ConversationWithParticipantsList + ] = None self._participant_conversations: Optional[ParticipantConversationList] = None self._roles: Optional[RoleList] = None self._users: Optional[UserList] = None @@ -197,10 +210,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -209,9 +222,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> ServiceInstance: @@ -222,10 +237,11 @@ def fetch(self) -> ServiceInstance: :returns: The fetched ServiceInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ServiceInstance( self._version, @@ -241,9 +257,12 @@ async def fetch_async(self) -> ServiceInstance: :returns: The fetched ServiceInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ServiceInstance( @@ -288,6 +307,18 @@ def conversations(self) -> ConversationList: ) return self._conversations + @property + def conversation_with_participants(self) -> ConversationWithParticipantsList: + """ + Access the conversation_with_participants + """ + if self._conversation_with_participants is None: + self._conversation_with_participants = ConversationWithParticipantsList( + self._version, + self._solution["sid"], + ) + return self._conversation_with_participants + @property def participant_conversations(self) -> ParticipantConversationList: """ @@ -380,11 +411,14 @@ def create(self, friendly_name: str) -> ServiceInstance: "FriendlyName": friendly_name, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload) @@ -403,11 +437,14 @@ async def create_async(self, friendly_name: str) -> ServiceInstance: "FriendlyName": friendly_name, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload) @@ -539,7 +576,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ServicePage(self._version, response) async def page_async( @@ -566,8 +609,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ServicePage(self._version, response) diff --git a/twilio/rest/conversations/v1/service/binding.py b/twilio/rest/conversations/v1/service/binding.py index 6e66844490..363dab91d0 100644 --- a/twilio/rest/conversations/v1/service/binding.py +++ b/twilio/rest/conversations/v1/service/binding.py @@ -166,10 +166,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -178,9 +178,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> BindingInstance: @@ -191,10 +193,11 @@ def fetch(self) -> BindingInstance: :returns: The fetched BindingInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return BindingInstance( self._version, @@ -211,9 +214,12 @@ async def fetch_async(self) -> BindingInstance: :returns: The fetched BindingInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return BindingInstance( @@ -429,7 +435,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return BindingPage(self._version, response, self._solution) async def page_async( @@ -462,8 +474,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return BindingPage(self._version, response, self._solution) diff --git a/twilio/rest/conversations/v1/service/configuration/__init__.py b/twilio/rest/conversations/v1/service/configuration/__init__.py index 9ca23a435f..e37c8888c8 100644 --- a/twilio/rest/conversations/v1/service/configuration/__init__.py +++ b/twilio/rest/conversations/v1/service/configuration/__init__.py @@ -178,10 +178,11 @@ def fetch(self) -> ConfigurationInstance: :returns: The fetched ConfigurationInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ConfigurationInstance( self._version, @@ -197,9 +198,12 @@ async def fetch_async(self) -> ConfigurationInstance: :returns: The fetched ConfigurationInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ConfigurationInstance( @@ -225,6 +229,7 @@ def update( :returns: The updated ConfigurationInstance """ + data = values.of( { "DefaultConversationCreatorRoleSid": default_conversation_creator_role_sid, @@ -235,11 +240,14 @@ def update( ), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ConfigurationInstance( @@ -263,6 +271,7 @@ async def update_async( :returns: The updated ConfigurationInstance """ + data = values.of( { "DefaultConversationCreatorRoleSid": default_conversation_creator_role_sid, @@ -273,11 +282,14 @@ async def update_async( ), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ConfigurationInstance( diff --git a/twilio/rest/conversations/v1/service/configuration/notification.py b/twilio/rest/conversations/v1/service/configuration/notification.py index 2dee2d4d29..6aced28115 100644 --- a/twilio/rest/conversations/v1/service/configuration/notification.py +++ b/twilio/rest/conversations/v1/service/configuration/notification.py @@ -225,10 +225,11 @@ def fetch(self) -> NotificationInstance: :returns: The fetched NotificationInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return NotificationInstance( self._version, @@ -244,9 +245,12 @@ async def fetch_async(self) -> NotificationInstance: :returns: The fetched NotificationInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return NotificationInstance( @@ -290,6 +294,7 @@ def update( :returns: The updated NotificationInstance """ + data = values.of( { "LogEnabled": serialize.boolean_to_string(log_enabled), @@ -315,11 +320,14 @@ def update( "NewMessage.WithMedia.Template": new_message_with_media_template, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return NotificationInstance( @@ -361,6 +369,7 @@ async def update_async( :returns: The updated NotificationInstance """ + data = values.of( { "LogEnabled": serialize.boolean_to_string(log_enabled), @@ -386,11 +395,14 @@ async def update_async( "NewMessage.WithMedia.Template": new_message_with_media_template, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return NotificationInstance( diff --git a/twilio/rest/conversations/v1/service/configuration/webhook.py b/twilio/rest/conversations/v1/service/configuration/webhook.py index aa4015361f..706f410550 100644 --- a/twilio/rest/conversations/v1/service/configuration/webhook.py +++ b/twilio/rest/conversations/v1/service/configuration/webhook.py @@ -172,10 +172,11 @@ def fetch(self) -> WebhookInstance: :returns: The fetched WebhookInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return WebhookInstance( self._version, @@ -191,9 +192,12 @@ async def fetch_async(self) -> WebhookInstance: :returns: The fetched WebhookInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return WebhookInstance( @@ -219,6 +223,7 @@ def update( :returns: The updated WebhookInstance """ + data = values.of( { "PreWebhookUrl": pre_webhook_url, @@ -227,11 +232,14 @@ def update( "Method": method, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WebhookInstance( @@ -255,6 +263,7 @@ async def update_async( :returns: The updated WebhookInstance """ + data = values.of( { "PreWebhookUrl": pre_webhook_url, @@ -263,11 +272,14 @@ async def update_async( "Method": method, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WebhookInstance( diff --git a/twilio/rest/conversations/v1/service/conversation/__init__.py b/twilio/rest/conversations/v1/service/conversation/__init__.py index c347977a40..0f28c4dfe2 100644 --- a/twilio/rest/conversations/v1/service/conversation/__init__.py +++ b/twilio/rest/conversations/v1/service/conversation/__init__.py @@ -332,6 +332,8 @@ def delete( } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async( @@ -353,6 +355,8 @@ async def delete_async( } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -365,10 +369,11 @@ def fetch(self) -> ConversationInstance: :returns: The fetched ConversationInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ConversationInstance( self._version, @@ -385,9 +390,12 @@ async def fetch_async(self) -> ConversationInstance: :returns: The fetched ConversationInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ConversationInstance( @@ -432,6 +440,7 @@ def update( :returns: The updated ConversationInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -447,11 +456,20 @@ def update( "Bindings.Email.Name": bindings_email_name, } ) - headers = values.of( - { - "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, - } - ) + headers = values.of({}) + + if not ( + x_twilio_webhook_enabled is values.unset + or ( + isinstance(x_twilio_webhook_enabled, str) + and not x_twilio_webhook_enabled + ) + ): + headers["X-Twilio-Webhook-Enabled"] = x_twilio_webhook_enabled + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( method="POST", uri=self._uri, data=data, headers=headers @@ -499,6 +517,7 @@ async def update_async( :returns: The updated ConversationInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -514,11 +533,20 @@ async def update_async( "Bindings.Email.Name": bindings_email_name, } ) - headers = values.of( - { - "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, - } - ) + headers = values.of({}) + + if not ( + x_twilio_webhook_enabled is values.unset + or ( + isinstance(x_twilio_webhook_enabled, str) + and not x_twilio_webhook_enabled + ) + ): + headers["X-Twilio-Webhook-Enabled"] = x_twilio_webhook_enabled + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( method="POST", uri=self._uri, data=data, headers=headers @@ -675,9 +703,14 @@ def create( headers = values.of( { "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = self._version.create( method="POST", uri=self._uri, data=data, headers=headers ) @@ -740,9 +773,14 @@ async def create_async( headers = values.of( { "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = await self._version.create_async( method="POST", uri=self._uri, data=data, headers=headers ) @@ -765,8 +803,8 @@ def stream( is reached. The results are returned as a generator, so this operation is memory efficient. - :param str start_date: Start date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the start time of the date is used (YYYY-MM-DDT00:00:00Z). Can be combined with other filters. - :param str end_date: End date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the end time of the date is used (YYYY-MM-DDT23:59:59Z). Can be combined with other filters. + :param str start_date: Specifies the beginning of the date range for filtering Conversations based on their creation date. Conversations that were created on or after this date will be included in the results. The date must be in ISO8601 format, specifically starting at the beginning of the specified date (YYYY-MM-DDT00:00:00Z), for precise filtering. This parameter can be combined with other filters. If this filter is used, the returned list is sorted by latest conversation creation date in descending order. + :param str end_date: Defines the end of the date range for filtering conversations by their creation date. Only conversations that were created on or before this date will appear in the results. The date must be in ISO8601 format, specifically capturing up to the end of the specified date (YYYY-MM-DDT23:59:59Z), to ensure that conversations from the entire end day are included. This parameter can be combined with other filters. If this filter is used, the returned list is sorted by latest conversation creation date in descending order. :param "ConversationInstance.State" state: State for sorting and filtering list of Conversations. Can be `active`, `inactive` or `closed` :param limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit @@ -801,8 +839,8 @@ async def stream_async( is reached. The results are returned as a generator, so this operation is memory efficient. - :param str start_date: Start date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the start time of the date is used (YYYY-MM-DDT00:00:00Z). Can be combined with other filters. - :param str end_date: End date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the end time of the date is used (YYYY-MM-DDT23:59:59Z). Can be combined with other filters. + :param str start_date: Specifies the beginning of the date range for filtering Conversations based on their creation date. Conversations that were created on or after this date will be included in the results. The date must be in ISO8601 format, specifically starting at the beginning of the specified date (YYYY-MM-DDT00:00:00Z), for precise filtering. This parameter can be combined with other filters. If this filter is used, the returned list is sorted by latest conversation creation date in descending order. + :param str end_date: Defines the end of the date range for filtering conversations by their creation date. Only conversations that were created on or before this date will appear in the results. The date must be in ISO8601 format, specifically capturing up to the end of the specified date (YYYY-MM-DDT23:59:59Z), to ensure that conversations from the entire end day are included. This parameter can be combined with other filters. If this filter is used, the returned list is sorted by latest conversation creation date in descending order. :param "ConversationInstance.State" state: State for sorting and filtering list of Conversations. Can be `active`, `inactive` or `closed` :param limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit @@ -836,8 +874,8 @@ def list( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param str start_date: Start date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the start time of the date is used (YYYY-MM-DDT00:00:00Z). Can be combined with other filters. - :param str end_date: End date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the end time of the date is used (YYYY-MM-DDT23:59:59Z). Can be combined with other filters. + :param str start_date: Specifies the beginning of the date range for filtering Conversations based on their creation date. Conversations that were created on or after this date will be included in the results. The date must be in ISO8601 format, specifically starting at the beginning of the specified date (YYYY-MM-DDT00:00:00Z), for precise filtering. This parameter can be combined with other filters. If this filter is used, the returned list is sorted by latest conversation creation date in descending order. + :param str end_date: Defines the end of the date range for filtering conversations by their creation date. Only conversations that were created on or before this date will appear in the results. The date must be in ISO8601 format, specifically capturing up to the end of the specified date (YYYY-MM-DDT23:59:59Z), to ensure that conversations from the entire end day are included. This parameter can be combined with other filters. If this filter is used, the returned list is sorted by latest conversation creation date in descending order. :param "ConversationInstance.State" state: State for sorting and filtering list of Conversations. Can be `active`, `inactive` or `closed` :param limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit @@ -871,8 +909,8 @@ async def list_async( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param str start_date: Start date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the start time of the date is used (YYYY-MM-DDT00:00:00Z). Can be combined with other filters. - :param str end_date: End date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the end time of the date is used (YYYY-MM-DDT23:59:59Z). Can be combined with other filters. + :param str start_date: Specifies the beginning of the date range for filtering Conversations based on their creation date. Conversations that were created on or after this date will be included in the results. The date must be in ISO8601 format, specifically starting at the beginning of the specified date (YYYY-MM-DDT00:00:00Z), for precise filtering. This parameter can be combined with other filters. If this filter is used, the returned list is sorted by latest conversation creation date in descending order. + :param str end_date: Defines the end of the date range for filtering conversations by their creation date. Only conversations that were created on or before this date will appear in the results. The date must be in ISO8601 format, specifically capturing up to the end of the specified date (YYYY-MM-DDT23:59:59Z), to ensure that conversations from the entire end day are included. This parameter can be combined with other filters. If this filter is used, the returned list is sorted by latest conversation creation date in descending order. :param "ConversationInstance.State" state: State for sorting and filtering list of Conversations. Can be `active`, `inactive` or `closed` :param limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit @@ -907,8 +945,8 @@ def page( Retrieve a single page of ConversationInstance records from the API. Request is executed immediately - :param start_date: Start date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the start time of the date is used (YYYY-MM-DDT00:00:00Z). Can be combined with other filters. - :param end_date: End date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the end time of the date is used (YYYY-MM-DDT23:59:59Z). Can be combined with other filters. + :param start_date: Specifies the beginning of the date range for filtering Conversations based on their creation date. Conversations that were created on or after this date will be included in the results. The date must be in ISO8601 format, specifically starting at the beginning of the specified date (YYYY-MM-DDT00:00:00Z), for precise filtering. This parameter can be combined with other filters. If this filter is used, the returned list is sorted by latest conversation creation date in descending order. + :param end_date: Defines the end of the date range for filtering conversations by their creation date. Only conversations that were created on or before this date will appear in the results. The date must be in ISO8601 format, specifically capturing up to the end of the specified date (YYYY-MM-DDT23:59:59Z), to ensure that conversations from the entire end day are included. This parameter can be combined with other filters. If this filter is used, the returned list is sorted by latest conversation creation date in descending order. :param state: State for sorting and filtering list of Conversations. Can be `active`, `inactive` or `closed` :param page_token: PageToken provided by the API :param page_number: Page Number, this value is simply for client state @@ -927,7 +965,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ConversationPage(self._version, response, self._solution) async def page_async( @@ -943,8 +987,8 @@ async def page_async( Asynchronously retrieve a single page of ConversationInstance records from the API. Request is executed immediately - :param start_date: Start date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the start time of the date is used (YYYY-MM-DDT00:00:00Z). Can be combined with other filters. - :param end_date: End date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the end time of the date is used (YYYY-MM-DDT23:59:59Z). Can be combined with other filters. + :param start_date: Specifies the beginning of the date range for filtering Conversations based on their creation date. Conversations that were created on or after this date will be included in the results. The date must be in ISO8601 format, specifically starting at the beginning of the specified date (YYYY-MM-DDT00:00:00Z), for precise filtering. This parameter can be combined with other filters. If this filter is used, the returned list is sorted by latest conversation creation date in descending order. + :param end_date: Defines the end of the date range for filtering conversations by their creation date. Only conversations that were created on or before this date will appear in the results. The date must be in ISO8601 format, specifically capturing up to the end of the specified date (YYYY-MM-DDT23:59:59Z), to ensure that conversations from the entire end day are included. This parameter can be combined with other filters. If this filter is used, the returned list is sorted by latest conversation creation date in descending order. :param state: State for sorting and filtering list of Conversations. Can be `active`, `inactive` or `closed` :param page_token: PageToken provided by the API :param page_number: Page Number, this value is simply for client state @@ -963,8 +1007,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ConversationPage(self._version, response, self._solution) diff --git a/twilio/rest/conversations/v1/service/conversation/message/__init__.py b/twilio/rest/conversations/v1/service/conversation/message/__init__.py index 753df18352..c4123afd34 100644 --- a/twilio/rest/conversations/v1/service/conversation/message/__init__.py +++ b/twilio/rest/conversations/v1/service/conversation/message/__init__.py @@ -294,6 +294,8 @@ def delete( } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async( @@ -315,6 +317,8 @@ async def delete_async( } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -327,10 +331,11 @@ def fetch(self) -> MessageInstance: :returns: The fetched MessageInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return MessageInstance( self._version, @@ -348,9 +353,12 @@ async def fetch_async(self) -> MessageInstance: :returns: The fetched MessageInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return MessageInstance( @@ -386,6 +394,7 @@ def update( :returns: The updated MessageInstance """ + data = values.of( { "Author": author, @@ -396,11 +405,20 @@ def update( "Subject": subject, } ) - headers = values.of( - { - "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, - } - ) + headers = values.of({}) + + if not ( + x_twilio_webhook_enabled is values.unset + or ( + isinstance(x_twilio_webhook_enabled, str) + and not x_twilio_webhook_enabled + ) + ): + headers["X-Twilio-Webhook-Enabled"] = x_twilio_webhook_enabled + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( method="POST", uri=self._uri, data=data, headers=headers @@ -439,6 +457,7 @@ async def update_async( :returns: The updated MessageInstance """ + data = values.of( { "Author": author, @@ -449,11 +468,20 @@ async def update_async( "Subject": subject, } ) - headers = values.of( - { - "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, - } - ) + headers = values.of({}) + + if not ( + x_twilio_webhook_enabled is values.unset + or ( + isinstance(x_twilio_webhook_enabled, str) + and not x_twilio_webhook_enabled + ) + ): + headers["X-Twilio-Webhook-Enabled"] = x_twilio_webhook_enabled + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( method="POST", uri=self._uri, data=data, headers=headers @@ -585,9 +613,14 @@ def create( headers = values.of( { "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = self._version.create( method="POST", uri=self._uri, data=data, headers=headers ) @@ -647,9 +680,14 @@ async def create_async( headers = values.of( { "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = await self._version.create_async( method="POST", uri=self._uri, data=data, headers=headers ) @@ -801,7 +839,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return MessagePage(self._version, response, self._solution) async def page_async( @@ -831,8 +875,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return MessagePage(self._version, response, self._solution) diff --git a/twilio/rest/conversations/v1/service/conversation/message/delivery_receipt.py b/twilio/rest/conversations/v1/service/conversation/message/delivery_receipt.py index b9bf8a70c8..939b631271 100644 --- a/twilio/rest/conversations/v1/service/conversation/message/delivery_receipt.py +++ b/twilio/rest/conversations/v1/service/conversation/message/delivery_receipt.py @@ -170,10 +170,11 @@ def fetch(self) -> DeliveryReceiptInstance: :returns: The fetched DeliveryReceiptInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return DeliveryReceiptInstance( self._version, @@ -192,9 +193,12 @@ async def fetch_async(self) -> DeliveryReceiptInstance: :returns: The fetched DeliveryReceiptInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return DeliveryReceiptInstance( @@ -398,7 +402,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return DeliveryReceiptPage(self._version, response, self._solution) async def page_async( @@ -425,8 +435,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return DeliveryReceiptPage(self._version, response, self._solution) diff --git a/twilio/rest/conversations/v1/service/conversation/participant.py b/twilio/rest/conversations/v1/service/conversation/participant.py index 6f6eee61e7..03a3cead7e 100644 --- a/twilio/rest/conversations/v1/service/conversation/participant.py +++ b/twilio/rest/conversations/v1/service/conversation/participant.py @@ -294,6 +294,8 @@ def delete( } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async( @@ -315,6 +317,8 @@ async def delete_async( } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -327,10 +331,11 @@ def fetch(self) -> ParticipantInstance: :returns: The fetched ParticipantInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ParticipantInstance( self._version, @@ -348,9 +353,12 @@ async def fetch_async(self) -> ParticipantInstance: :returns: The fetched ParticipantInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ParticipantInstance( @@ -392,6 +400,7 @@ def update( :returns: The updated ParticipantInstance """ + data = values.of( { "DateCreated": serialize.iso8601_datetime(date_created), @@ -405,11 +414,20 @@ def update( "LastReadTimestamp": last_read_timestamp, } ) - headers = values.of( - { - "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, - } - ) + headers = values.of({}) + + if not ( + x_twilio_webhook_enabled is values.unset + or ( + isinstance(x_twilio_webhook_enabled, str) + and not x_twilio_webhook_enabled + ) + ): + headers["X-Twilio-Webhook-Enabled"] = x_twilio_webhook_enabled + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( method="POST", uri=self._uri, data=data, headers=headers @@ -454,6 +472,7 @@ async def update_async( :returns: The updated ParticipantInstance """ + data = values.of( { "DateCreated": serialize.iso8601_datetime(date_created), @@ -467,11 +486,20 @@ async def update_async( "LastReadTimestamp": last_read_timestamp, } ) - headers = values.of( - { - "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, - } - ) + headers = values.of({}) + + if not ( + x_twilio_webhook_enabled is values.unset + or ( + isinstance(x_twilio_webhook_enabled, str) + and not x_twilio_webhook_enabled + ) + ): + headers["X-Twilio-Webhook-Enabled"] = x_twilio_webhook_enabled + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( method="POST", uri=self._uri, data=data, headers=headers @@ -586,9 +614,14 @@ def create( headers = values.of( { "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = self._version.create( method="POST", uri=self._uri, data=data, headers=headers ) @@ -645,9 +678,14 @@ async def create_async( headers = values.of( { "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = await self._version.create_async( method="POST", uri=self._uri, data=data, headers=headers ) @@ -786,7 +824,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ParticipantPage(self._version, response, self._solution) async def page_async( @@ -813,8 +857,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ParticipantPage(self._version, response, self._solution) diff --git a/twilio/rest/conversations/v1/service/conversation/webhook.py b/twilio/rest/conversations/v1/service/conversation/webhook.py index 83b267406e..08ec93ce4e 100644 --- a/twilio/rest/conversations/v1/service/conversation/webhook.py +++ b/twilio/rest/conversations/v1/service/conversation/webhook.py @@ -225,10 +225,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -237,9 +237,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> WebhookInstance: @@ -250,10 +252,11 @@ def fetch(self) -> WebhookInstance: :returns: The fetched WebhookInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return WebhookInstance( self._version, @@ -271,9 +274,12 @@ async def fetch_async(self) -> WebhookInstance: :returns: The fetched WebhookInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return WebhookInstance( @@ -303,6 +309,7 @@ def update( :returns: The updated WebhookInstance """ + data = values.of( { "Configuration.Url": configuration_url, @@ -316,11 +323,14 @@ def update( "Configuration.FlowSid": configuration_flow_sid, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WebhookInstance( @@ -350,6 +360,7 @@ async def update_async( :returns: The updated WebhookInstance """ + data = values.of( { "Configuration.Url": configuration_url, @@ -363,11 +374,14 @@ async def update_async( "Configuration.FlowSid": configuration_flow_sid, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WebhookInstance( @@ -473,11 +487,14 @@ def create( "Configuration.ReplayAfter": configuration_replay_after, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WebhookInstance( @@ -526,11 +543,14 @@ async def create_async( "Configuration.ReplayAfter": configuration_replay_after, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WebhookInstance( @@ -667,7 +687,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return WebhookPage(self._version, response, self._solution) async def page_async( @@ -694,8 +720,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return WebhookPage(self._version, response, self._solution) diff --git a/twilio/rest/conversations/v1/service/conversation_with_participants.py b/twilio/rest/conversations/v1/service/conversation_with_participants.py new file mode 100644 index 0000000000..ff82a8ce35 --- /dev/null +++ b/twilio/rest/conversations/v1/service/conversation_with_participants.py @@ -0,0 +1,272 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Conversations + 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 +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 ConversationWithParticipantsInstance(InstanceResource): + + class State(object): + INACTIVE = "inactive" + ACTIVE = "active" + CLOSED = "closed" + + class WebhookEnabledType(object): + TRUE = "true" + FALSE = "false" + + """ + :ivar account_sid: The unique ID of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this conversation. + :ivar chat_service_sid: The unique ID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) this conversation belongs to. + :ivar messaging_service_sid: The unique ID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) this conversation belongs to. + :ivar sid: A 34 character string that uniquely identifies this resource. + :ivar friendly_name: The human-readable name of this conversation, limited to 256 characters. Optional. + :ivar unique_name: An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource's `sid` in the URL. + :ivar attributes: An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \"{}\" will be returned. + :ivar state: + :ivar date_created: The date that this resource was created. + :ivar date_updated: The date that this resource was last updated. + :ivar timers: Timer date values representing state update for this conversation. + :ivar links: Contains absolute URLs to access the [participants](https://www.twilio.com/docs/conversations/api/conversation-participant-resource), [messages](https://www.twilio.com/docs/conversations/api/conversation-message-resource) and [webhooks](https://www.twilio.com/docs/conversations/api/conversation-scoped-webhook-resource) of this conversation. + :ivar bindings: + :ivar url: An absolute API resource URL for this conversation. + """ + + def __init__( + self, version: Version, payload: Dict[str, Any], chat_service_sid: str + ): + super().__init__(version) + + self.account_sid: Optional[str] = payload.get("account_sid") + self.chat_service_sid: Optional[str] = payload.get("chat_service_sid") + self.messaging_service_sid: Optional[str] = payload.get("messaging_service_sid") + self.sid: Optional[str] = payload.get("sid") + self.friendly_name: Optional[str] = payload.get("friendly_name") + self.unique_name: Optional[str] = payload.get("unique_name") + self.attributes: Optional[str] = payload.get("attributes") + self.state: Optional["ConversationWithParticipantsInstance.State"] = ( + payload.get("state") + ) + 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.timers: Optional[Dict[str, object]] = payload.get("timers") + self.links: Optional[Dict[str, object]] = payload.get("links") + self.bindings: Optional[Dict[str, object]] = payload.get("bindings") + self.url: Optional[str] = payload.get("url") + + self._solution = { + "chat_service_sid": chat_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 ConversationWithParticipantsList(ListResource): + + def __init__(self, version: Version, chat_service_sid: str): + """ + Initialize the ConversationWithParticipantsList + + :param version: Version that contains the resource + :param chat_service_sid: The SID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) the Conversation resource is associated with. + + """ + super().__init__(version) + + # Path Solution + self._solution = { + "chat_service_sid": chat_service_sid, + } + self._uri = "/Services/{chat_service_sid}/ConversationWithParticipants".format( + **self._solution + ) + + def create( + self, + x_twilio_webhook_enabled: Union[ + "ConversationWithParticipantsInstance.WebhookEnabledType", object + ] = values.unset, + friendly_name: Union[str, object] = values.unset, + unique_name: Union[str, object] = values.unset, + date_created: Union[datetime, object] = values.unset, + date_updated: Union[datetime, object] = values.unset, + messaging_service_sid: Union[str, object] = values.unset, + attributes: Union[str, object] = values.unset, + state: Union[ + "ConversationWithParticipantsInstance.State", object + ] = values.unset, + timers_inactive: Union[str, object] = values.unset, + timers_closed: Union[str, object] = values.unset, + bindings_email_address: Union[str, object] = values.unset, + bindings_email_name: Union[str, object] = values.unset, + participant: Union[List[str], object] = values.unset, + ) -> ConversationWithParticipantsInstance: + """ + Create the ConversationWithParticipantsInstance + + :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header + :param friendly_name: The human-readable name of this conversation, limited to 256 characters. Optional. + :param unique_name: An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource's `sid` in the URL. + :param date_created: The date that this resource was created. + :param date_updated: The date that this resource was last updated. + :param messaging_service_sid: The unique ID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) this conversation belongs to. + :param attributes: An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. + :param state: + :param timers_inactive: ISO8601 duration when conversation will be switched to `inactive` state. Minimum value for this timer is 1 minute. + :param timers_closed: ISO8601 duration when conversation will be switched to `closed` state. Minimum value for this timer is 10 minutes. + :param bindings_email_address: The default email address that will be used when sending outbound emails in this conversation. + :param bindings_email_name: The default name that will be used when sending outbound emails in this conversation. + :param participant: The participant to be added to the conversation in JSON format. The JSON object attributes are as parameters in [Participant Resource](https://www.twilio.com/docs/conversations/api/conversation-participant-resource). The maximum number of participants that can be added in a single request is 10. + + :returns: The created ConversationWithParticipantsInstance + """ + + data = values.of( + { + "FriendlyName": friendly_name, + "UniqueName": unique_name, + "DateCreated": serialize.iso8601_datetime(date_created), + "DateUpdated": serialize.iso8601_datetime(date_updated), + "MessagingServiceSid": messaging_service_sid, + "Attributes": attributes, + "State": state, + "Timers.Inactive": timers_inactive, + "Timers.Closed": timers_closed, + "Bindings.Email.Address": bindings_email_address, + "Bindings.Email.Name": bindings_email_name, + "Participant": serialize.map(participant, lambda e: e), + } + ) + headers = values.of( + { + "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, + "Content-Type": "application/x-www-form-urlencoded", + } + ) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = self._version.create( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return ConversationWithParticipantsInstance( + self._version, payload, chat_service_sid=self._solution["chat_service_sid"] + ) + + async def create_async( + self, + x_twilio_webhook_enabled: Union[ + "ConversationWithParticipantsInstance.WebhookEnabledType", object + ] = values.unset, + friendly_name: Union[str, object] = values.unset, + unique_name: Union[str, object] = values.unset, + date_created: Union[datetime, object] = values.unset, + date_updated: Union[datetime, object] = values.unset, + messaging_service_sid: Union[str, object] = values.unset, + attributes: Union[str, object] = values.unset, + state: Union[ + "ConversationWithParticipantsInstance.State", object + ] = values.unset, + timers_inactive: Union[str, object] = values.unset, + timers_closed: Union[str, object] = values.unset, + bindings_email_address: Union[str, object] = values.unset, + bindings_email_name: Union[str, object] = values.unset, + participant: Union[List[str], object] = values.unset, + ) -> ConversationWithParticipantsInstance: + """ + Asynchronously create the ConversationWithParticipantsInstance + + :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header + :param friendly_name: The human-readable name of this conversation, limited to 256 characters. Optional. + :param unique_name: An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource's `sid` in the URL. + :param date_created: The date that this resource was created. + :param date_updated: The date that this resource was last updated. + :param messaging_service_sid: The unique ID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) this conversation belongs to. + :param attributes: An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. + :param state: + :param timers_inactive: ISO8601 duration when conversation will be switched to `inactive` state. Minimum value for this timer is 1 minute. + :param timers_closed: ISO8601 duration when conversation will be switched to `closed` state. Minimum value for this timer is 10 minutes. + :param bindings_email_address: The default email address that will be used when sending outbound emails in this conversation. + :param bindings_email_name: The default name that will be used when sending outbound emails in this conversation. + :param participant: The participant to be added to the conversation in JSON format. The JSON object attributes are as parameters in [Participant Resource](https://www.twilio.com/docs/conversations/api/conversation-participant-resource). The maximum number of participants that can be added in a single request is 10. + + :returns: The created ConversationWithParticipantsInstance + """ + + data = values.of( + { + "FriendlyName": friendly_name, + "UniqueName": unique_name, + "DateCreated": serialize.iso8601_datetime(date_created), + "DateUpdated": serialize.iso8601_datetime(date_updated), + "MessagingServiceSid": messaging_service_sid, + "Attributes": attributes, + "State": state, + "Timers.Inactive": timers_inactive, + "Timers.Closed": timers_closed, + "Bindings.Email.Address": bindings_email_address, + "Bindings.Email.Name": bindings_email_name, + "Participant": serialize.map(participant, lambda e: e), + } + ) + headers = values.of( + { + "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, + "Content-Type": "application/x-www-form-urlencoded", + } + ) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return ConversationWithParticipantsInstance( + self._version, payload, chat_service_sid=self._solution["chat_service_sid"] + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/conversations/v1/service/participant_conversation.py b/twilio/rest/conversations/v1/service/participant_conversation.py index 2c3bebcc1e..8ec561a7d9 100644 --- a/twilio/rest/conversations/v1/service/participant_conversation.py +++ b/twilio/rest/conversations/v1/service/participant_conversation.py @@ -302,7 +302,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ParticipantConversationPage(self._version, response, self._solution) async def page_async( @@ -335,8 +341,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ParticipantConversationPage(self._version, response, self._solution) diff --git a/twilio/rest/conversations/v1/service/role.py b/twilio/rest/conversations/v1/service/role.py index 3c0a0fc909..0884fb008b 100644 --- a/twilio/rest/conversations/v1/service/role.py +++ b/twilio/rest/conversations/v1/service/role.py @@ -181,10 +181,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -193,9 +193,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> RoleInstance: @@ -206,10 +208,11 @@ def fetch(self) -> RoleInstance: :returns: The fetched RoleInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return RoleInstance( self._version, @@ -226,9 +229,12 @@ async def fetch_async(self) -> RoleInstance: :returns: The fetched RoleInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return RoleInstance( @@ -246,16 +252,20 @@ def update(self, permission: List[str]) -> RoleInstance: :returns: The updated RoleInstance """ + data = values.of( { "Permission": serialize.map(permission, lambda e: e), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RoleInstance( @@ -273,16 +283,20 @@ async def update_async(self, permission: List[str]) -> RoleInstance: :returns: The updated RoleInstance """ + data = values.of( { "Permission": serialize.map(permission, lambda e: e), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RoleInstance( @@ -361,11 +375,14 @@ def create( "Permission": serialize.map(permission, lambda e: e), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RoleInstance( @@ -392,11 +409,14 @@ async def create_async( "Permission": serialize.map(permission, lambda e: e), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RoleInstance( @@ -530,7 +550,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return RolePage(self._version, response, self._solution) async def page_async( @@ -557,8 +583,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return RolePage(self._version, response, self._solution) diff --git a/twilio/rest/conversations/v1/service/user/__init__.py b/twilio/rest/conversations/v1/service/user/__init__.py index 37a8d2e4fb..b8cda74c8c 100644 --- a/twilio/rest/conversations/v1/service/user/__init__.py +++ b/twilio/rest/conversations/v1/service/user/__init__.py @@ -257,6 +257,8 @@ def delete( } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async( @@ -278,6 +280,8 @@ async def delete_async( } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -290,10 +294,11 @@ def fetch(self) -> UserInstance: :returns: The fetched UserInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return UserInstance( self._version, @@ -310,9 +315,12 @@ async def fetch_async(self) -> UserInstance: :returns: The fetched UserInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return UserInstance( @@ -341,6 +349,7 @@ def update( :returns: The updated UserInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -348,11 +357,20 @@ def update( "RoleSid": role_sid, } ) - headers = values.of( - { - "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, - } - ) + headers = values.of({}) + + if not ( + x_twilio_webhook_enabled is values.unset + or ( + isinstance(x_twilio_webhook_enabled, str) + and not x_twilio_webhook_enabled + ) + ): + headers["X-Twilio-Webhook-Enabled"] = x_twilio_webhook_enabled + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( method="POST", uri=self._uri, data=data, headers=headers @@ -384,6 +402,7 @@ async def update_async( :returns: The updated UserInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -391,11 +410,20 @@ async def update_async( "RoleSid": role_sid, } ) - headers = values.of( - { - "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, - } - ) + headers = values.of({}) + + if not ( + x_twilio_webhook_enabled is values.unset + or ( + isinstance(x_twilio_webhook_enabled, str) + and not x_twilio_webhook_enabled + ) + ): + headers["X-Twilio-Webhook-Enabled"] = x_twilio_webhook_enabled + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( method="POST", uri=self._uri, data=data, headers=headers @@ -503,9 +531,14 @@ def create( headers = values.of( { "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = self._version.create( method="POST", uri=self._uri, data=data, headers=headers ) @@ -547,9 +580,14 @@ async def create_async( headers = values.of( { "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = await self._version.create_async( method="POST", uri=self._uri, data=data, headers=headers ) @@ -685,7 +723,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return UserPage(self._version, response, self._solution) async def page_async( @@ -712,8 +756,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return UserPage(self._version, response, self._solution) diff --git a/twilio/rest/conversations/v1/service/user/user_conversation.py b/twilio/rest/conversations/v1/service/user/user_conversation.py index 7a836505b9..4f1727f8e8 100644 --- a/twilio/rest/conversations/v1/service/user/user_conversation.py +++ b/twilio/rest/conversations/v1/service/user/user_conversation.py @@ -247,10 +247,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -259,9 +259,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> UserConversationInstance: @@ -272,10 +274,11 @@ def fetch(self) -> UserConversationInstance: :returns: The fetched UserConversationInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return UserConversationInstance( self._version, @@ -293,9 +296,12 @@ async def fetch_async(self) -> UserConversationInstance: :returns: The fetched UserConversationInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return UserConversationInstance( @@ -323,6 +329,7 @@ def update( :returns: The updated UserConversationInstance """ + data = values.of( { "NotificationLevel": notification_level, @@ -330,11 +337,14 @@ def update( "LastReadMessageIndex": last_read_message_index, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return UserConversationInstance( @@ -362,6 +372,7 @@ async def update_async( :returns: The updated UserConversationInstance """ + data = values.of( { "NotificationLevel": notification_level, @@ -369,11 +380,14 @@ async def update_async( "LastReadMessageIndex": last_read_message_index, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return UserConversationInstance( @@ -569,7 +583,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return UserConversationPage(self._version, response, self._solution) async def page_async( @@ -596,8 +616,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return UserConversationPage(self._version, response, self._solution) diff --git a/twilio/rest/conversations/v1/user/__init__.py b/twilio/rest/conversations/v1/user/__init__.py index d8017c5102..fe5d12f095 100644 --- a/twilio/rest/conversations/v1/user/__init__.py +++ b/twilio/rest/conversations/v1/user/__init__.py @@ -247,6 +247,8 @@ def delete( } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async( @@ -268,6 +270,8 @@ async def delete_async( } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -280,10 +284,11 @@ def fetch(self) -> UserInstance: :returns: The fetched UserInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return UserInstance( self._version, @@ -299,9 +304,12 @@ async def fetch_async(self) -> UserInstance: :returns: The fetched UserInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return UserInstance( @@ -329,6 +337,7 @@ def update( :returns: The updated UserInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -336,11 +345,20 @@ def update( "RoleSid": role_sid, } ) - headers = values.of( - { - "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, - } - ) + headers = values.of({}) + + if not ( + x_twilio_webhook_enabled is values.unset + or ( + isinstance(x_twilio_webhook_enabled, str) + and not x_twilio_webhook_enabled + ) + ): + headers["X-Twilio-Webhook-Enabled"] = x_twilio_webhook_enabled + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( method="POST", uri=self._uri, data=data, headers=headers @@ -367,6 +385,7 @@ async def update_async( :returns: The updated UserInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -374,11 +393,20 @@ async def update_async( "RoleSid": role_sid, } ) - headers = values.of( - { - "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, - } - ) + headers = values.of({}) + + if not ( + x_twilio_webhook_enabled is values.unset + or ( + isinstance(x_twilio_webhook_enabled, str) + and not x_twilio_webhook_enabled + ) + ): + headers["X-Twilio-Webhook-Enabled"] = x_twilio_webhook_enabled + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( method="POST", uri=self._uri, data=data, headers=headers @@ -473,9 +501,14 @@ def create( headers = values.of( { "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = self._version.create( method="POST", uri=self._uri, data=data, headers=headers ) @@ -515,9 +548,14 @@ async def create_async( headers = values.of( { "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = await self._version.create_async( method="POST", uri=self._uri, data=data, headers=headers ) @@ -651,7 +689,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return UserPage(self._version, response) async def page_async( @@ -678,8 +722,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return UserPage(self._version, response) diff --git a/twilio/rest/conversations/v1/user/user_conversation.py b/twilio/rest/conversations/v1/user/user_conversation.py index e162441151..16ce2c2418 100644 --- a/twilio/rest/conversations/v1/user/user_conversation.py +++ b/twilio/rest/conversations/v1/user/user_conversation.py @@ -236,10 +236,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -248,9 +248,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> UserConversationInstance: @@ -261,10 +263,11 @@ def fetch(self) -> UserConversationInstance: :returns: The fetched UserConversationInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return UserConversationInstance( self._version, @@ -281,9 +284,12 @@ async def fetch_async(self) -> UserConversationInstance: :returns: The fetched UserConversationInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return UserConversationInstance( @@ -310,6 +316,7 @@ def update( :returns: The updated UserConversationInstance """ + data = values.of( { "NotificationLevel": notification_level, @@ -317,11 +324,14 @@ def update( "LastReadMessageIndex": last_read_message_index, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return UserConversationInstance( @@ -348,6 +358,7 @@ async def update_async( :returns: The updated UserConversationInstance """ + data = values.of( { "NotificationLevel": notification_level, @@ -355,11 +366,14 @@ async def update_async( "LastReadMessageIndex": last_read_message_index, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return UserConversationInstance( @@ -545,7 +559,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return UserConversationPage(self._version, response, self._solution) async def page_async( @@ -572,8 +592,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return UserConversationPage(self._version, response, self._solution) diff --git a/twilio/rest/events/v1/event_type.py b/twilio/rest/events/v1/event_type.py index 7215df8f24..7eaaeb03ba 100644 --- a/twilio/rest/events/v1/event_type.py +++ b/twilio/rest/events/v1/event_type.py @@ -29,6 +29,8 @@ class EventTypeInstance(InstanceResource): :ivar date_created: The date that this Event Type was created, given in ISO 8601 format. :ivar date_updated: The date that this Event Type was updated, given in ISO 8601 format. :ivar description: A human readable description for this Event Type. + :ivar status: A string that describes how this Event Type can be used. For example: `available`, `deprecated`, `restricted`, `discontinued`. When the status is `available`, the Event Type can be used normally. + :ivar documentation_url: The URL to the documentation or to the most relevant Twilio Changelog entry of this Event Type. :ivar url: The URL of this resource. :ivar links: """ @@ -47,6 +49,8 @@ def __init__( payload.get("date_updated") ) self.description: Optional[str] = payload.get("description") + self.status: Optional[str] = payload.get("status") + self.documentation_url: Optional[str] = payload.get("documentation_url") self.url: Optional[str] = payload.get("url") self.links: Optional[Dict[str, object]] = payload.get("links") @@ -123,10 +127,11 @@ def fetch(self) -> EventTypeInstance: :returns: The fetched EventTypeInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return EventTypeInstance( self._version, @@ -142,9 +147,12 @@ async def fetch_async(self) -> EventTypeInstance: :returns: The fetched EventTypeInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return EventTypeInstance( @@ -335,7 +343,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return EventTypePage(self._version, response) async def page_async( @@ -365,8 +379,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return EventTypePage(self._version, response) diff --git a/twilio/rest/events/v1/schema/__init__.py b/twilio/rest/events/v1/schema/__init__.py index c3b6593c03..2c7ffa6b28 100644 --- a/twilio/rest/events/v1/schema/__init__.py +++ b/twilio/rest/events/v1/schema/__init__.py @@ -14,7 +14,7 @@ from datetime import datetime from typing import Any, Dict, Optional -from twilio.base import deserialize +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 @@ -129,10 +129,11 @@ def fetch(self) -> SchemaInstance: :returns: The fetched SchemaInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return SchemaInstance( self._version, @@ -148,9 +149,12 @@ async def fetch_async(self) -> SchemaInstance: :returns: The fetched SchemaInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return SchemaInstance( diff --git a/twilio/rest/events/v1/schema/schema_version.py b/twilio/rest/events/v1/schema/schema_version.py index 3557cb2935..be000b9c0b 100644 --- a/twilio/rest/events/v1/schema/schema_version.py +++ b/twilio/rest/events/v1/schema/schema_version.py @@ -127,10 +127,11 @@ def fetch(self) -> SchemaVersionInstance: :returns: The fetched SchemaVersionInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return SchemaVersionInstance( self._version, @@ -147,9 +148,12 @@ async def fetch_async(self) -> SchemaVersionInstance: :returns: The fetched SchemaVersionInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return SchemaVersionInstance( @@ -333,7 +337,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return SchemaVersionPage(self._version, response, self._solution) async def page_async( @@ -360,8 +370,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return SchemaVersionPage(self._version, response, self._solution) diff --git a/twilio/rest/events/v1/sink/__init__.py b/twilio/rest/events/v1/sink/__init__.py index b09b5edec3..3771f83bbc 100644 --- a/twilio/rest/events/v1/sink/__init__.py +++ b/twilio/rest/events/v1/sink/__init__.py @@ -30,6 +30,7 @@ class SinkType(object): KINESIS = "kinesis" WEBHOOK = "webhook" SEGMENT = "segment" + EMAIL = "email" class Status(object): INITIALIZED = "initialized" @@ -201,10 +202,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -213,9 +214,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> SinkInstance: @@ -226,10 +229,11 @@ def fetch(self) -> SinkInstance: :returns: The fetched SinkInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return SinkInstance( self._version, @@ -245,9 +249,12 @@ async def fetch_async(self) -> SinkInstance: :returns: The fetched SinkInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return SinkInstance( @@ -264,16 +271,20 @@ def update(self, description: str) -> SinkInstance: :returns: The updated SinkInstance """ + data = values.of( { "Description": description, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SinkInstance(self._version, payload, sid=self._solution["sid"]) @@ -286,16 +297,20 @@ async def update_async(self, description: str) -> SinkInstance: :returns: The updated SinkInstance """ + data = values.of( { "Description": description, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SinkInstance(self._version, payload, sid=self._solution["sid"]) @@ -389,11 +404,14 @@ def create( "SinkType": sink_type, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SinkInstance(self._version, payload) @@ -421,11 +439,14 @@ async def create_async( "SinkType": sink_type, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SinkInstance(self._version, payload) @@ -585,7 +606,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return SinkPage(self._version, response) async def page_async( @@ -618,8 +645,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return SinkPage(self._version, response) diff --git a/twilio/rest/events/v1/sink/sink_test.py b/twilio/rest/events/v1/sink/sink_test.py index adf04f582d..566106efca 100644 --- a/twilio/rest/events/v1/sink/sink_test.py +++ b/twilio/rest/events/v1/sink/sink_test.py @@ -13,6 +13,7 @@ """ 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 @@ -69,10 +70,11 @@ def create(self) -> SinkTestInstance: :returns: The created SinkTestInstance """ - payload = self._version.create( - method="POST", - uri=self._uri, - ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + payload = self._version.create(method="POST", uri=self._uri, headers=headers) return SinkTestInstance(self._version, payload, sid=self._solution["sid"]) @@ -84,9 +86,12 @@ async def create_async(self) -> SinkTestInstance: :returns: The created SinkTestInstance """ + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + payload = await self._version.create_async( - method="POST", - uri=self._uri, + method="POST", uri=self._uri, headers=headers ) return SinkTestInstance(self._version, payload, sid=self._solution["sid"]) diff --git a/twilio/rest/events/v1/sink/sink_validate.py b/twilio/rest/events/v1/sink/sink_validate.py index 4c24dd76b3..53eef814c0 100644 --- a/twilio/rest/events/v1/sink/sink_validate.py +++ b/twilio/rest/events/v1/sink/sink_validate.py @@ -76,11 +76,14 @@ def create(self, test_id: str) -> SinkValidateInstance: "TestId": test_id, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SinkValidateInstance(self._version, payload, sid=self._solution["sid"]) @@ -99,11 +102,14 @@ async def create_async(self, test_id: str) -> SinkValidateInstance: "TestId": test_id, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SinkValidateInstance(self._version, payload, sid=self._solution["sid"]) diff --git a/twilio/rest/events/v1/subscription/__init__.py b/twilio/rest/events/v1/subscription/__init__.py index 666b26aa70..e77cf10b51 100644 --- a/twilio/rest/events/v1/subscription/__init__.py +++ b/twilio/rest/events/v1/subscription/__init__.py @@ -33,6 +33,7 @@ class SubscriptionInstance(InstanceResource): :ivar sink_sid: The SID of the sink that events selected by this subscription should be sent to. Sink must be active for the subscription to be created. :ivar url: The URL of this resource. :ivar links: Contains a dictionary of URL links to nested resources of this Subscription. + :ivar receive_events_from_subaccounts: Receive events from all children accounts in the parent account subscription. """ def __init__( @@ -52,6 +53,9 @@ def __init__( self.sink_sid: Optional[str] = payload.get("sink_sid") self.url: Optional[str] = payload.get("url") self.links: Optional[Dict[str, object]] = payload.get("links") + self.receive_events_from_subaccounts: Optional[bool] = payload.get( + "receive_events_from_subaccounts" + ) self._solution = { "sid": sid or self.sid, @@ -113,36 +117,42 @@ def update( self, description: Union[str, object] = values.unset, sink_sid: Union[str, object] = values.unset, + receive_events_from_subaccounts: Union[bool, object] = values.unset, ) -> "SubscriptionInstance": """ Update the SubscriptionInstance :param description: A human readable description for the Subscription. :param sink_sid: The SID of the sink that events selected by this subscription should be sent to. Sink must be active for the subscription to be created. + :param receive_events_from_subaccounts: Receive events from all children accounts in the parent account subscription. :returns: The updated SubscriptionInstance """ return self._proxy.update( description=description, sink_sid=sink_sid, + receive_events_from_subaccounts=receive_events_from_subaccounts, ) async def update_async( self, description: Union[str, object] = values.unset, sink_sid: Union[str, object] = values.unset, + receive_events_from_subaccounts: Union[bool, object] = values.unset, ) -> "SubscriptionInstance": """ Asynchronous coroutine to update the SubscriptionInstance :param description: A human readable description for the Subscription. :param sink_sid: The SID of the sink that events selected by this subscription should be sent to. Sink must be active for the subscription to be created. + :param receive_events_from_subaccounts: Receive events from all children accounts in the parent account subscription. :returns: The updated SubscriptionInstance """ return await self._proxy.update_async( description=description, sink_sid=sink_sid, + receive_events_from_subaccounts=receive_events_from_subaccounts, ) @property @@ -188,10 +198,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -200,9 +210,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> SubscriptionInstance: @@ -213,10 +225,11 @@ def fetch(self) -> SubscriptionInstance: :returns: The fetched SubscriptionInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return SubscriptionInstance( self._version, @@ -232,9 +245,12 @@ async def fetch_async(self) -> SubscriptionInstance: :returns: The fetched SubscriptionInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return SubscriptionInstance( @@ -247,26 +263,35 @@ def update( self, description: Union[str, object] = values.unset, sink_sid: Union[str, object] = values.unset, + receive_events_from_subaccounts: Union[bool, object] = values.unset, ) -> SubscriptionInstance: """ Update the SubscriptionInstance :param description: A human readable description for the Subscription. :param sink_sid: The SID of the sink that events selected by this subscription should be sent to. Sink must be active for the subscription to be created. + :param receive_events_from_subaccounts: Receive events from all children accounts in the parent account subscription. :returns: The updated SubscriptionInstance """ + data = values.of( { "Description": description, "SinkSid": sink_sid, + "ReceiveEventsFromSubaccounts": serialize.boolean_to_string( + receive_events_from_subaccounts + ), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SubscriptionInstance(self._version, payload, sid=self._solution["sid"]) @@ -275,26 +300,35 @@ async def update_async( self, description: Union[str, object] = values.unset, sink_sid: Union[str, object] = values.unset, + receive_events_from_subaccounts: Union[bool, object] = values.unset, ) -> SubscriptionInstance: """ Asynchronous coroutine to update the SubscriptionInstance :param description: A human readable description for the Subscription. :param sink_sid: The SID of the sink that events selected by this subscription should be sent to. Sink must be active for the subscription to be created. + :param receive_events_from_subaccounts: Receive events from all children accounts in the parent account subscription. :returns: The updated SubscriptionInstance """ + data = values.of( { "Description": description, "SinkSid": sink_sid, + "ReceiveEventsFromSubaccounts": serialize.boolean_to_string( + receive_events_from_subaccounts + ), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SubscriptionInstance(self._version, payload, sid=self._solution["sid"]) @@ -354,7 +388,11 @@ def __init__(self, version: Version): self._uri = "/Subscriptions" def create( - self, description: str, sink_sid: str, types: List[object] + self, + description: str, + sink_sid: str, + types: List[object], + receive_events_from_subaccounts: Union[bool, object] = values.unset, ) -> SubscriptionInstance: """ Create the SubscriptionInstance @@ -362,6 +400,7 @@ def create( :param description: A human readable description for the Subscription **This value should not contain PII.** :param sink_sid: The SID of the sink that events selected by this subscription should be sent to. Sink must be active for the subscription to be created. :param types: An array of objects containing the subscribed Event Types + :param receive_events_from_subaccounts: Receive events from all children accounts in the parent account subscription. :returns: The created SubscriptionInstance """ @@ -371,19 +410,29 @@ def create( "Description": description, "SinkSid": sink_sid, "Types": serialize.map(types, lambda e: serialize.object(e)), + "ReceiveEventsFromSubaccounts": serialize.boolean_to_string( + receive_events_from_subaccounts + ), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SubscriptionInstance(self._version, payload) async def create_async( - self, description: str, sink_sid: str, types: List[object] + self, + description: str, + sink_sid: str, + types: List[object], + receive_events_from_subaccounts: Union[bool, object] = values.unset, ) -> SubscriptionInstance: """ Asynchronously create the SubscriptionInstance @@ -391,6 +440,7 @@ async def create_async( :param description: A human readable description for the Subscription **This value should not contain PII.** :param sink_sid: The SID of the sink that events selected by this subscription should be sent to. Sink must be active for the subscription to be created. :param types: An array of objects containing the subscribed Event Types + :param receive_events_from_subaccounts: Receive events from all children accounts in the parent account subscription. :returns: The created SubscriptionInstance """ @@ -400,13 +450,19 @@ async def create_async( "Description": description, "SinkSid": sink_sid, "Types": serialize.map(types, lambda e: serialize.object(e)), + "ReceiveEventsFromSubaccounts": serialize.boolean_to_string( + receive_events_from_subaccounts + ), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SubscriptionInstance(self._version, payload) @@ -551,7 +607,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return SubscriptionPage(self._version, response) async def page_async( @@ -581,8 +643,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return SubscriptionPage(self._version, response) diff --git a/twilio/rest/events/v1/subscription/subscribed_event.py b/twilio/rest/events/v1/subscription/subscribed_event.py index 80c9ce1494..dae60ac206 100644 --- a/twilio/rest/events/v1/subscription/subscribed_event.py +++ b/twilio/rest/events/v1/subscription/subscribed_event.py @@ -171,10 +171,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -183,9 +183,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> SubscribedEventInstance: @@ -196,10 +198,11 @@ def fetch(self) -> SubscribedEventInstance: :returns: The fetched SubscribedEventInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return SubscribedEventInstance( self._version, @@ -216,9 +219,12 @@ async def fetch_async(self) -> SubscribedEventInstance: :returns: The fetched SubscribedEventInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return SubscribedEventInstance( @@ -238,16 +244,20 @@ def update( :returns: The updated SubscribedEventInstance """ + data = values.of( { "SchemaVersion": schema_version, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SubscribedEventInstance( @@ -267,16 +277,20 @@ async def update_async( :returns: The updated SubscribedEventInstance """ + data = values.of( { "SchemaVersion": schema_version, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SubscribedEventInstance( @@ -355,11 +369,14 @@ def create( "SchemaVersion": schema_version, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SubscribedEventInstance( @@ -384,11 +401,14 @@ async def create_async( "SchemaVersion": schema_version, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SubscribedEventInstance( @@ -522,7 +542,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return SubscribedEventPage(self._version, response, self._solution) async def page_async( @@ -549,8 +575,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return SubscribedEventPage(self._version, response, self._solution) diff --git a/twilio/rest/flex_api/v1/assessments.py b/twilio/rest/flex_api/v1/assessments.py index 23648b1041..130514b295 100644 --- a/twilio/rest/flex_api/v1/assessments.py +++ b/twilio/rest/flex_api/v1/assessments.py @@ -176,6 +176,7 @@ def update( :returns: The updated AssessmentsInstance """ + data = values.of( { "Offset": offset, @@ -183,11 +184,17 @@ def update( "AnswerId": answer_id, } ) - headers = values.of( - { - "Authorization": authorization, - } - ) + headers = values.of({}) + + if not ( + authorization is values.unset + or (isinstance(authorization, str) and not authorization) + ): + headers["Authorization"] = authorization + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( method="POST", uri=self._uri, data=data, headers=headers @@ -214,6 +221,7 @@ async def update_async( :returns: The updated AssessmentsInstance """ + data = values.of( { "Offset": offset, @@ -221,11 +229,17 @@ async def update_async( "AnswerId": answer_id, } ) - headers = values.of( - { - "Authorization": authorization, - } - ) + headers = values.of({}) + + if not ( + authorization is values.unset + or (isinstance(authorization, str) and not authorization) + ): + headers["Authorization"] = authorization + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( method="POST", uri=self._uri, data=data, headers=headers @@ -326,9 +340,14 @@ def create( headers = values.of( { "Authorization": authorization, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = self._version.create( method="POST", uri=self._uri, data=data, headers=headers ) @@ -384,9 +403,14 @@ async def create_async( headers = values.of( { "Authorization": authorization, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = await self._version.create_async( method="POST", uri=self._uri, data=data, headers=headers ) @@ -554,7 +578,18 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of( + { + "Authorization": authorization, + "Content-Type": "application/x-www-form-urlencoded", + } + ) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return AssessmentsPage(self._version, response) async def page_async( @@ -587,8 +622,17 @@ async def page_async( } ) + headers = values.of( + { + "Authorization": authorization, + "Content-Type": "application/x-www-form-urlencoded", + } + ) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return AssessmentsPage(self._version, response) diff --git a/twilio/rest/flex_api/v1/channel.py b/twilio/rest/flex_api/v1/channel.py index f362d5b01b..aa98ff8d31 100644 --- a/twilio/rest/flex_api/v1/channel.py +++ b/twilio/rest/flex_api/v1/channel.py @@ -142,10 +142,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -154,9 +154,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> ChannelInstance: @@ -167,10 +169,11 @@ def fetch(self) -> ChannelInstance: :returns: The fetched ChannelInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ChannelInstance( self._version, @@ -186,9 +189,12 @@ async def fetch_async(self) -> ChannelInstance: :returns: The fetched ChannelInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ChannelInstance( @@ -283,11 +289,14 @@ def create( "LongLived": serialize.boolean_to_string(long_lived), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ChannelInstance(self._version, payload) @@ -336,11 +345,14 @@ async def create_async( "LongLived": serialize.boolean_to_string(long_lived), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ChannelInstance(self._version, payload) @@ -472,7 +484,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ChannelPage(self._version, response) async def page_async( @@ -499,8 +517,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ChannelPage(self._version, response) diff --git a/twilio/rest/flex_api/v1/configuration.py b/twilio/rest/flex_api/v1/configuration.py index bec7034cfe..28a66be036 100644 --- a/twilio/rest/flex_api/v1/configuration.py +++ b/twilio/rest/flex_api/v1/configuration.py @@ -304,7 +304,13 @@ def fetch( } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=data) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) return ConfigurationInstance( self._version, @@ -328,8 +334,12 @@ async def fetch_async( } ) + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ConfigurationInstance( @@ -347,12 +357,13 @@ def update( :returns: The updated ConfigurationInstance """ - data = values.of({}) - headers = values.of( - { - "body": body, - } - ) + data = body.to_dict() + + headers = values.of({}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" payload = self._version.update( method="POST", uri=self._uri, data=data, headers=headers @@ -370,12 +381,13 @@ async def update_async( :returns: The updated ConfigurationInstance """ - data = values.of({}) - headers = values.of( - { - "body": body, - } - ) + data = body.to_dict() + + headers = values.of({}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" payload = await self._version.update_async( method="POST", uri=self._uri, data=data, headers=headers diff --git a/twilio/rest/flex_api/v1/flex_flow.py b/twilio/rest/flex_api/v1/flex_flow.py index b11482937e..0ae2634666 100644 --- a/twilio/rest/flex_api/v1/flex_flow.py +++ b/twilio/rest/flex_api/v1/flex_flow.py @@ -302,10 +302,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -314,9 +314,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> FlexFlowInstance: @@ -327,10 +329,11 @@ def fetch(self) -> FlexFlowInstance: :returns: The fetched FlexFlowInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return FlexFlowInstance( self._version, @@ -346,9 +349,12 @@ async def fetch_async(self) -> FlexFlowInstance: :returns: The fetched FlexFlowInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return FlexFlowInstance( @@ -402,6 +408,7 @@ def update( :returns: The updated FlexFlowInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -425,11 +432,14 @@ def update( "Integration.RetryCount": integration_retry_count, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return FlexFlowInstance(self._version, payload, sid=self._solution["sid"]) @@ -479,6 +489,7 @@ async def update_async( :returns: The updated FlexFlowInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -502,11 +513,14 @@ async def update_async( "Integration.RetryCount": integration_retry_count, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return FlexFlowInstance(self._version, payload, sid=self._solution["sid"]) @@ -622,11 +636,14 @@ def create( "Integration.RetryCount": integration_retry_count, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return FlexFlowInstance(self._version, payload) @@ -700,11 +717,14 @@ async def create_async( "Integration.RetryCount": integration_retry_count, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return FlexFlowInstance(self._version, payload) @@ -851,7 +871,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return FlexFlowPage(self._version, response) async def page_async( @@ -881,8 +907,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return FlexFlowPage(self._version, response) diff --git a/twilio/rest/flex_api/v1/insights_assessments_comment.py b/twilio/rest/flex_api/v1/insights_assessments_comment.py index eed32fefbc..2b6c79343b 100644 --- a/twilio/rest/flex_api/v1/insights_assessments_comment.py +++ b/twilio/rest/flex_api/v1/insights_assessments_comment.py @@ -134,9 +134,14 @@ def create( headers = values.of( { "Authorization": authorization, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = self._version.create( method="POST", uri=self._uri, data=data, headers=headers ) @@ -180,9 +185,14 @@ async def create_async( headers = values.of( { "Authorization": authorization, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = await self._version.create_async( method="POST", uri=self._uri, data=data, headers=headers ) @@ -365,7 +375,18 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of( + { + "Authorization": authorization, + "Content-Type": "application/x-www-form-urlencoded", + } + ) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return InsightsAssessmentsCommentPage(self._version, response) async def page_async( @@ -401,8 +422,17 @@ async def page_async( } ) + headers = values.of( + { + "Authorization": authorization, + "Content-Type": "application/x-www-form-urlencoded", + } + ) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return InsightsAssessmentsCommentPage(self._version, response) diff --git a/twilio/rest/flex_api/v1/insights_conversations.py b/twilio/rest/flex_api/v1/insights_conversations.py index d08608c7e4..efdcea203e 100644 --- a/twilio/rest/flex_api/v1/insights_conversations.py +++ b/twilio/rest/flex_api/v1/insights_conversations.py @@ -242,7 +242,18 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of( + { + "Authorization": authorization, + "Content-Type": "application/x-www-form-urlencoded", + } + ) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return InsightsConversationsPage(self._version, response) async def page_async( @@ -275,8 +286,17 @@ async def page_async( } ) + headers = values.of( + { + "Authorization": authorization, + "Content-Type": "application/x-www-form-urlencoded", + } + ) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return InsightsConversationsPage(self._version, response) diff --git a/twilio/rest/flex_api/v1/insights_questionnaires.py b/twilio/rest/flex_api/v1/insights_questionnaires.py index 807f129955..d21aff8242 100644 --- a/twilio/rest/flex_api/v1/insights_questionnaires.py +++ b/twilio/rest/flex_api/v1/insights_questionnaires.py @@ -221,6 +221,8 @@ def delete(self, authorization: Union[str, object] = values.unset) -> bool: } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async( @@ -239,6 +241,8 @@ async def delete_async( } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -260,7 +264,13 @@ def fetch( } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=data) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) return InsightsQuestionnairesInstance( self._version, @@ -285,8 +295,12 @@ async def fetch_async( } ) + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return InsightsQuestionnairesInstance( @@ -314,6 +328,7 @@ def update( :returns: The updated InsightsQuestionnairesInstance """ + data = values.of( { "Active": serialize.boolean_to_string(active), @@ -322,11 +337,17 @@ def update( "QuestionSids": serialize.map(question_sids, lambda e: e), } ) - headers = values.of( - { - "Authorization": authorization, - } - ) + headers = values.of({}) + + if not ( + authorization is values.unset + or (isinstance(authorization, str) and not authorization) + ): + headers["Authorization"] = authorization + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( method="POST", uri=self._uri, data=data, headers=headers @@ -357,6 +378,7 @@ async def update_async( :returns: The updated InsightsQuestionnairesInstance """ + data = values.of( { "Active": serialize.boolean_to_string(active), @@ -365,11 +387,17 @@ async def update_async( "QuestionSids": serialize.map(question_sids, lambda e: e), } ) - headers = values.of( - { - "Authorization": authorization, - } - ) + headers = values.of({}) + + if not ( + authorization is values.unset + or (isinstance(authorization, str) and not authorization) + ): + headers["Authorization"] = authorization + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( method="POST", uri=self._uri, data=data, headers=headers @@ -454,9 +482,14 @@ def create( headers = values.of( { "Authorization": authorization, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = self._version.create( method="POST", uri=self._uri, data=data, headers=headers ) @@ -494,9 +527,14 @@ async def create_async( headers = values.of( { "Authorization": authorization, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = await self._version.create_async( method="POST", uri=self._uri, data=data, headers=headers ) @@ -664,7 +702,18 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of( + { + "Authorization": authorization, + "Content-Type": "application/x-www-form-urlencoded", + } + ) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return InsightsQuestionnairesPage(self._version, response) async def page_async( @@ -697,8 +746,17 @@ async def page_async( } ) + headers = values.of( + { + "Authorization": authorization, + "Content-Type": "application/x-www-form-urlencoded", + } + ) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return InsightsQuestionnairesPage(self._version, response) diff --git a/twilio/rest/flex_api/v1/insights_questionnaires_category.py b/twilio/rest/flex_api/v1/insights_questionnaires_category.py index 28057dbc00..817a4753f9 100644 --- a/twilio/rest/flex_api/v1/insights_questionnaires_category.py +++ b/twilio/rest/flex_api/v1/insights_questionnaires_category.py @@ -165,6 +165,8 @@ def delete(self, authorization: Union[str, object] = values.unset) -> bool: } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async( @@ -183,6 +185,8 @@ async def delete_async( } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -198,16 +202,23 @@ def update( :returns: The updated InsightsQuestionnairesCategoryInstance """ + data = values.of( { "Name": name, } ) - headers = values.of( - { - "Authorization": authorization, - } - ) + headers = values.of({}) + + if not ( + authorization is values.unset + or (isinstance(authorization, str) and not authorization) + ): + headers["Authorization"] = authorization + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( method="POST", uri=self._uri, data=data, headers=headers @@ -228,16 +239,23 @@ async def update_async( :returns: The updated InsightsQuestionnairesCategoryInstance """ + data = values.of( { "Name": name, } ) - headers = values.of( - { - "Authorization": authorization, - } - ) + headers = values.of({}) + + if not ( + authorization is values.unset + or (isinstance(authorization, str) and not authorization) + ): + headers["Authorization"] = authorization + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( method="POST", uri=self._uri, data=data, headers=headers @@ -313,9 +331,14 @@ def create( headers = values.of( { "Authorization": authorization, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = self._version.create( method="POST", uri=self._uri, data=data, headers=headers ) @@ -342,9 +365,14 @@ async def create_async( headers = values.of( { "Authorization": authorization, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = await self._version.create_async( method="POST", uri=self._uri, data=data, headers=headers ) @@ -493,7 +521,18 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of( + { + "Authorization": authorization, + "Content-Type": "application/x-www-form-urlencoded", + } + ) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return InsightsQuestionnairesCategoryPage(self._version, response) async def page_async( @@ -523,8 +562,17 @@ async def page_async( } ) + headers = values.of( + { + "Authorization": authorization, + "Content-Type": "application/x-www-form-urlencoded", + } + ) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return InsightsQuestionnairesCategoryPage(self._version, response) diff --git a/twilio/rest/flex_api/v1/insights_questionnaires_question.py b/twilio/rest/flex_api/v1/insights_questionnaires_question.py index e4f2f4a4f0..33e2304599 100644 --- a/twilio/rest/flex_api/v1/insights_questionnaires_question.py +++ b/twilio/rest/flex_api/v1/insights_questionnaires_question.py @@ -205,6 +205,8 @@ def delete(self, authorization: Union[str, object] = values.unset) -> bool: } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async( @@ -223,6 +225,8 @@ async def delete_async( } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -248,6 +252,7 @@ def update( :returns: The updated InsightsQuestionnairesQuestionInstance """ + data = values.of( { "AllowNa": serialize.boolean_to_string(allow_na), @@ -257,11 +262,17 @@ def update( "AnswerSetId": answer_set_id, } ) - headers = values.of( - { - "Authorization": authorization, - } - ) + headers = values.of({}) + + if not ( + authorization is values.unset + or (isinstance(authorization, str) and not authorization) + ): + headers["Authorization"] = authorization + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( method="POST", uri=self._uri, data=data, headers=headers @@ -292,6 +303,7 @@ async def update_async( :returns: The updated InsightsQuestionnairesQuestionInstance """ + data = values.of( { "AllowNa": serialize.boolean_to_string(allow_na), @@ -301,11 +313,17 @@ async def update_async( "AnswerSetId": answer_set_id, } ) - headers = values.of( - { - "Authorization": authorization, - } - ) + headers = values.of({}) + + if not ( + authorization is values.unset + or (isinstance(authorization, str) and not authorization) + ): + headers["Authorization"] = authorization + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( method="POST", uri=self._uri, data=data, headers=headers @@ -395,9 +413,14 @@ def create( headers = values.of( { "Authorization": authorization, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = self._version.create( method="POST", uri=self._uri, data=data, headers=headers ) @@ -438,9 +461,14 @@ async def create_async( headers = values.of( { "Authorization": authorization, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = await self._version.create_async( method="POST", uri=self._uri, data=data, headers=headers ) @@ -608,7 +636,18 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of( + { + "Authorization": authorization, + "Content-Type": "application/x-www-form-urlencoded", + } + ) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return InsightsQuestionnairesQuestionPage(self._version, response) async def page_async( @@ -641,8 +680,17 @@ async def page_async( } ) + headers = values.of( + { + "Authorization": authorization, + "Content-Type": "application/x-www-form-urlencoded", + } + ) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return InsightsQuestionnairesQuestionPage(self._version, response) diff --git a/twilio/rest/flex_api/v1/insights_segments.py b/twilio/rest/flex_api/v1/insights_segments.py index 2d509802a9..7c98e81cff 100644 --- a/twilio/rest/flex_api/v1/insights_segments.py +++ b/twilio/rest/flex_api/v1/insights_segments.py @@ -301,7 +301,18 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of( + { + "Authorization": authorization, + "Content-Type": "application/x-www-form-urlencoded", + } + ) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return InsightsSegmentsPage(self._version, response) async def page_async( @@ -337,8 +348,17 @@ async def page_async( } ) + headers = values.of( + { + "Authorization": authorization, + "Content-Type": "application/x-www-form-urlencoded", + } + ) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return InsightsSegmentsPage(self._version, response) diff --git a/twilio/rest/flex_api/v1/insights_settings_answer_sets.py b/twilio/rest/flex_api/v1/insights_settings_answer_sets.py index 767737da67..9b0e89e938 100644 --- a/twilio/rest/flex_api/v1/insights_settings_answer_sets.py +++ b/twilio/rest/flex_api/v1/insights_settings_answer_sets.py @@ -75,9 +75,12 @@ def fetch( headers = values.of( { "Authorization": authorization, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Accept"] = "application/json" + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return InsightsSettingsAnswerSetsInstance(self._version, payload) @@ -94,9 +97,12 @@ async def fetch_async( headers = values.of( { "Authorization": authorization, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( method="GET", uri=self._uri, headers=headers ) diff --git a/twilio/rest/flex_api/v1/insights_settings_comment.py b/twilio/rest/flex_api/v1/insights_settings_comment.py index 5d41e8d3b3..18733a4957 100644 --- a/twilio/rest/flex_api/v1/insights_settings_comment.py +++ b/twilio/rest/flex_api/v1/insights_settings_comment.py @@ -69,9 +69,12 @@ def fetch( headers = values.of( { "Authorization": authorization, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Accept"] = "application/json" + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return InsightsSettingsCommentInstance(self._version, payload) @@ -88,9 +91,12 @@ async def fetch_async( headers = values.of( { "Authorization": authorization, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( method="GET", uri=self._uri, headers=headers ) diff --git a/twilio/rest/flex_api/v1/insights_user_roles.py b/twilio/rest/flex_api/v1/insights_user_roles.py index 9dbea5fa3b..19cb10b8e4 100644 --- a/twilio/rest/flex_api/v1/insights_user_roles.py +++ b/twilio/rest/flex_api/v1/insights_user_roles.py @@ -115,7 +115,13 @@ def fetch( } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=data) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) return InsightsUserRolesInstance( self._version, @@ -139,8 +145,12 @@ async def fetch_async( } ) + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return InsightsUserRolesInstance( diff --git a/twilio/rest/flex_api/v1/interaction/__init__.py b/twilio/rest/flex_api/v1/interaction/__init__.py index 992cc9b015..653938f28d 100644 --- a/twilio/rest/flex_api/v1/interaction/__init__.py +++ b/twilio/rest/flex_api/v1/interaction/__init__.py @@ -32,6 +32,7 @@ class InteractionInstance(InstanceResource): :ivar url: :ivar links: :ivar interaction_context_sid: + :ivar webhook_ttid: """ def __init__( @@ -47,6 +48,7 @@ def __init__( self.interaction_context_sid: Optional[str] = payload.get( "interaction_context_sid" ) + self.webhook_ttid: Optional[str] = payload.get("webhook_ttid") self._solution = { "sid": sid or self.sid, @@ -86,6 +88,34 @@ async def fetch_async(self) -> "InteractionInstance": """ return await self._proxy.fetch_async() + def update( + self, webhook_ttid: Union[str, object] = values.unset + ) -> "InteractionInstance": + """ + Update the InteractionInstance + + :param webhook_ttid: The unique identifier for Interaction level webhook + + :returns: The updated InteractionInstance + """ + return self._proxy.update( + webhook_ttid=webhook_ttid, + ) + + async def update_async( + self, webhook_ttid: Union[str, object] = values.unset + ) -> "InteractionInstance": + """ + Asynchronous coroutine to update the InteractionInstance + + :param webhook_ttid: The unique identifier for Interaction level webhook + + :returns: The updated InteractionInstance + """ + return await self._proxy.update_async( + webhook_ttid=webhook_ttid, + ) + @property def channels(self) -> InteractionChannelList: """ @@ -130,10 +160,11 @@ def fetch(self) -> InteractionInstance: :returns: The fetched InteractionInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return InteractionInstance( self._version, @@ -149,9 +180,12 @@ async def fetch_async(self) -> InteractionInstance: :returns: The fetched InteractionInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return InteractionInstance( @@ -160,6 +194,62 @@ async def fetch_async(self) -> InteractionInstance: sid=self._solution["sid"], ) + def update( + self, webhook_ttid: Union[str, object] = values.unset + ) -> InteractionInstance: + """ + Update the InteractionInstance + + :param webhook_ttid: The unique identifier for Interaction level webhook + + :returns: The updated InteractionInstance + """ + + data = values.of( + { + "WebhookTtid": webhook_ttid, + } + ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = self._version.update( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return InteractionInstance(self._version, payload, sid=self._solution["sid"]) + + async def update_async( + self, webhook_ttid: Union[str, object] = values.unset + ) -> InteractionInstance: + """ + Asynchronous coroutine to update the InteractionInstance + + :param webhook_ttid: The unique identifier for Interaction level webhook + + :returns: The updated InteractionInstance + """ + + data = values.of( + { + "WebhookTtid": webhook_ttid, + } + ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = await self._version.update_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return InteractionInstance(self._version, payload, sid=self._solution["sid"]) + @property def channels(self) -> InteractionChannelList: """ @@ -198,8 +288,9 @@ def __init__(self, version: Version): def create( self, channel: object, - routing: object, + routing: Union[object, object] = values.unset, interaction_context_sid: Union[str, object] = values.unset, + webhook_ttid: Union[str, object] = values.unset, ) -> InteractionInstance: """ Create the InteractionInstance @@ -207,6 +298,7 @@ def create( :param channel: The Interaction's channel. :param routing: The Interaction's routing logic. :param interaction_context_sid: The Interaction context sid is used for adding a context lookup sid + :param webhook_ttid: The unique identifier for Interaction level webhook :returns: The created InteractionInstance """ @@ -216,13 +308,17 @@ def create( "Channel": serialize.object(channel), "Routing": serialize.object(routing), "InteractionContextSid": interaction_context_sid, + "WebhookTtid": webhook_ttid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return InteractionInstance(self._version, payload) @@ -230,8 +326,9 @@ def create( async def create_async( self, channel: object, - routing: object, + routing: Union[object, object] = values.unset, interaction_context_sid: Union[str, object] = values.unset, + webhook_ttid: Union[str, object] = values.unset, ) -> InteractionInstance: """ Asynchronously create the InteractionInstance @@ -239,6 +336,7 @@ async def create_async( :param channel: The Interaction's channel. :param routing: The Interaction's routing logic. :param interaction_context_sid: The Interaction context sid is used for adding a context lookup sid + :param webhook_ttid: The unique identifier for Interaction level webhook :returns: The created InteractionInstance """ @@ -248,13 +346,17 @@ async def create_async( "Channel": serialize.object(channel), "Routing": serialize.object(routing), "InteractionContextSid": interaction_context_sid, + "WebhookTtid": webhook_ttid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return InteractionInstance(self._version, payload) diff --git a/twilio/rest/flex_api/v1/interaction/interaction_channel/__init__.py b/twilio/rest/flex_api/v1/interaction/interaction_channel/__init__.py index a26dc0425e..b029104c8d 100644 --- a/twilio/rest/flex_api/v1/interaction/interaction_channel/__init__.py +++ b/twilio/rest/flex_api/v1/interaction/interaction_channel/__init__.py @@ -25,6 +25,9 @@ from twilio.rest.flex_api.v1.interaction.interaction_channel.interaction_channel_participant import ( InteractionChannelParticipantList, ) +from twilio.rest.flex_api.v1.interaction.interaction_channel.interaction_transfer import ( + InteractionTransferList, +) class InteractionChannelInstance(InstanceResource): @@ -171,6 +174,13 @@ def participants(self) -> InteractionChannelParticipantList: """ return self._proxy.participants + @property + def transfers(self) -> InteractionTransferList: + """ + Access the transfers + """ + return self._proxy.transfers + def __repr__(self) -> str: """ Provide a friendly representation @@ -204,6 +214,7 @@ def __init__(self, version: Version, interaction_sid: str, sid: str): self._invites: Optional[InteractionChannelInviteList] = None self._participants: Optional[InteractionChannelParticipantList] = None + self._transfers: Optional[InteractionTransferList] = None def fetch(self) -> InteractionChannelInstance: """ @@ -213,10 +224,11 @@ def fetch(self) -> InteractionChannelInstance: :returns: The fetched InteractionChannelInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return InteractionChannelInstance( self._version, @@ -233,9 +245,12 @@ async def fetch_async(self) -> InteractionChannelInstance: :returns: The fetched InteractionChannelInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return InteractionChannelInstance( @@ -258,17 +273,21 @@ def update( :returns: The updated InteractionChannelInstance """ + data = values.of( { "Status": status, "Routing": serialize.object(routing), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return InteractionChannelInstance( @@ -291,17 +310,21 @@ async def update_async( :returns: The updated InteractionChannelInstance """ + data = values.of( { "Status": status, "Routing": serialize.object(routing), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return InteractionChannelInstance( @@ -337,6 +360,19 @@ def participants(self) -> InteractionChannelParticipantList: ) return self._participants + @property + def transfers(self) -> InteractionTransferList: + """ + Access the transfers + """ + if self._transfers is None: + self._transfers = InteractionTransferList( + self._version, + self._solution["interaction_sid"], + self._solution["sid"], + ) + return self._transfers + def __repr__(self) -> str: """ Provide a friendly representation @@ -513,7 +549,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return InteractionChannelPage(self._version, response, self._solution) async def page_async( @@ -540,8 +582,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return InteractionChannelPage(self._version, response, self._solution) diff --git a/twilio/rest/flex_api/v1/interaction/interaction_channel/interaction_channel_invite.py b/twilio/rest/flex_api/v1/interaction/interaction_channel/interaction_channel_invite.py index 5292297b98..a81acd4fc4 100644 --- a/twilio/rest/flex_api/v1/interaction/interaction_channel/interaction_channel_invite.py +++ b/twilio/rest/flex_api/v1/interaction/interaction_channel/interaction_channel_invite.py @@ -122,11 +122,14 @@ def create(self, routing: object) -> InteractionChannelInviteInstance: "Routing": serialize.object(routing), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return InteractionChannelInviteInstance( @@ -150,11 +153,14 @@ async def create_async(self, routing: object) -> InteractionChannelInviteInstanc "Routing": serialize.object(routing), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return InteractionChannelInviteInstance( @@ -291,7 +297,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return InteractionChannelInvitePage(self._version, response, self._solution) async def page_async( @@ -318,8 +330,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return InteractionChannelInvitePage(self._version, response, self._solution) diff --git a/twilio/rest/flex_api/v1/interaction/interaction_channel/interaction_channel_participant.py b/twilio/rest/flex_api/v1/interaction/interaction_channel/interaction_channel_participant.py index ba9f80f9a3..53d2d40dbf 100644 --- a/twilio/rest/flex_api/v1/interaction/interaction_channel/interaction_channel_participant.py +++ b/twilio/rest/flex_api/v1/interaction/interaction_channel/interaction_channel_participant.py @@ -163,16 +163,20 @@ def update( :returns: The updated InteractionChannelParticipantInstance """ + data = values.of( { "Status": status, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return InteractionChannelParticipantInstance( @@ -193,16 +197,20 @@ async def update_async( :returns: The updated InteractionChannelParticipantInstance """ + data = values.of( { "Status": status, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return InteractionChannelParticipantInstance( @@ -296,11 +304,14 @@ def create( "RoutingProperties": serialize.object(routing_properties), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return InteractionChannelParticipantInstance( @@ -333,11 +344,14 @@ async def create_async( "RoutingProperties": serialize.object(routing_properties), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return InteractionChannelParticipantInstance( @@ -474,7 +488,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return InteractionChannelParticipantPage( self._version, response, self._solution ) @@ -503,8 +523,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return InteractionChannelParticipantPage( self._version, response, self._solution diff --git a/twilio/rest/flex_api/v1/interaction/interaction_channel/interaction_transfer.py b/twilio/rest/flex_api/v1/interaction/interaction_channel/interaction_transfer.py new file mode 100644 index 0000000000..04a5afacdb --- /dev/null +++ b/twilio/rest/flex_api/v1/interaction/interaction_channel/interaction_transfer.py @@ -0,0 +1,423 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Flex + 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, 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 InteractionTransferInstance(InstanceResource): + + class TransferStatus(object): + ACTIVE = "active" + FAILED = "failed" + COMPLETED = "completed" + + class TransferType(object): + WARM = "warm" + COLD = "cold" + EXTERNAL = "external" + + """ + :ivar sid: The unique string created by Twilio to identify an Interaction Transfer resource. + :ivar instance_sid: The SID of the Instance associated with the Transfer. + :ivar account_sid: The SID of the Account that created the Transfer. + :ivar interaction_sid: The Interaction Sid for this channel. + :ivar channel_sid: The Channel Sid for this Transfer. + :ivar execution_sid: The Execution SID associated with the Transfer. + :ivar type: + :ivar status: + :ivar _from: The SID of the Participant initiating the Transfer. + :ivar to: The SID of the Participant receiving the Transfer. + :ivar note_sid: The SID of the Note associated with the Transfer. + :ivar summary_sid: The SID of the Summary associated with the Transfer. + :ivar date_created: The date and time when the Transfer was created. + :ivar date_updated: The date and time when the Transfer was last updated. + :ivar url: + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + interaction_sid: str, + channel_sid: str, + sid: Optional[str] = None, + ): + super().__init__(version) + + self.sid: Optional[str] = payload.get("sid") + self.instance_sid: Optional[str] = payload.get("instance_sid") + self.account_sid: Optional[str] = payload.get("account_sid") + self.interaction_sid: Optional[str] = payload.get("interaction_sid") + self.channel_sid: Optional[str] = payload.get("channel_sid") + self.execution_sid: Optional[str] = payload.get("execution_sid") + self.type: Optional["InteractionTransferInstance.TransferType"] = payload.get( + "type" + ) + self.status: Optional["InteractionTransferInstance.TransferStatus"] = ( + payload.get("status") + ) + self._from: Optional[str] = payload.get("from") + self.to: Optional[str] = payload.get("to") + self.note_sid: Optional[str] = payload.get("note_sid") + self.summary_sid: Optional[str] = payload.get("summary_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.url: Optional[str] = payload.get("url") + + self._solution = { + "interaction_sid": interaction_sid, + "channel_sid": channel_sid, + "sid": sid or self.sid, + } + self._context: Optional[InteractionTransferContext] = None + + @property + def _proxy(self) -> "InteractionTransferContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: InteractionTransferContext for this InteractionTransferInstance + """ + if self._context is None: + self._context = InteractionTransferContext( + self._version, + interaction_sid=self._solution["interaction_sid"], + channel_sid=self._solution["channel_sid"], + sid=self._solution["sid"], + ) + return self._context + + def fetch(self) -> "InteractionTransferInstance": + """ + Fetch the InteractionTransferInstance + + + :returns: The fetched InteractionTransferInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "InteractionTransferInstance": + """ + Asynchronous coroutine to fetch the InteractionTransferInstance + + + :returns: The fetched InteractionTransferInstance + """ + return await self._proxy.fetch_async() + + def update( + self, body: Union[object, object] = values.unset + ) -> "InteractionTransferInstance": + """ + Update the InteractionTransferInstance + + :param body: + + :returns: The updated InteractionTransferInstance + """ + return self._proxy.update( + body=body, + ) + + async def update_async( + self, body: Union[object, object] = values.unset + ) -> "InteractionTransferInstance": + """ + Asynchronous coroutine to update the InteractionTransferInstance + + :param body: + + :returns: The updated InteractionTransferInstance + """ + return await self._proxy.update_async( + body=body, + ) + + 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 InteractionTransferContext(InstanceContext): + + def __init__( + self, version: Version, interaction_sid: str, channel_sid: str, sid: str + ): + """ + Initialize the InteractionTransferContext + + :param version: Version that contains the resource + :param interaction_sid: The Interaction Sid for this channel. + :param channel_sid: The Channel Sid for this Transfer. + :param sid: The unique string created by Twilio to identify a Transfer resource. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "interaction_sid": interaction_sid, + "channel_sid": channel_sid, + "sid": sid, + } + self._uri = "/Interactions/{interaction_sid}/Channels/{channel_sid}/Transfers/{sid}".format( + **self._solution + ) + + def fetch(self) -> InteractionTransferInstance: + """ + Fetch the InteractionTransferInstance + + + :returns: The fetched InteractionTransferInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return InteractionTransferInstance( + self._version, + payload, + interaction_sid=self._solution["interaction_sid"], + channel_sid=self._solution["channel_sid"], + sid=self._solution["sid"], + ) + + async def fetch_async(self) -> InteractionTransferInstance: + """ + Asynchronous coroutine to fetch the InteractionTransferInstance + + + :returns: The fetched InteractionTransferInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + return InteractionTransferInstance( + self._version, + payload, + interaction_sid=self._solution["interaction_sid"], + channel_sid=self._solution["channel_sid"], + sid=self._solution["sid"], + ) + + def update( + self, body: Union[object, object] = values.unset + ) -> InteractionTransferInstance: + """ + Update the InteractionTransferInstance + + :param body: + + :returns: The updated InteractionTransferInstance + """ + data = body.to_dict() + + headers = values.of({}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + payload = self._version.update( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return InteractionTransferInstance( + self._version, + payload, + interaction_sid=self._solution["interaction_sid"], + channel_sid=self._solution["channel_sid"], + sid=self._solution["sid"], + ) + + async def update_async( + self, body: Union[object, object] = values.unset + ) -> InteractionTransferInstance: + """ + Asynchronous coroutine to update the InteractionTransferInstance + + :param body: + + :returns: The updated InteractionTransferInstance + """ + data = body.to_dict() + + headers = values.of({}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + payload = await self._version.update_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return InteractionTransferInstance( + self._version, + payload, + interaction_sid=self._solution["interaction_sid"], + channel_sid=self._solution["channel_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 InteractionTransferList(ListResource): + + def __init__(self, version: Version, interaction_sid: str, channel_sid: str): + """ + Initialize the InteractionTransferList + + :param version: Version that contains the resource + :param interaction_sid: The Interaction Sid for the Interaction + :param channel_sid: The Channel Sid for the Channel. + + """ + super().__init__(version) + + # Path Solution + self._solution = { + "interaction_sid": interaction_sid, + "channel_sid": channel_sid, + } + self._uri = ( + "/Interactions/{interaction_sid}/Channels/{channel_sid}/Transfers".format( + **self._solution + ) + ) + + def create( + self, body: Union[object, object] = values.unset + ) -> InteractionTransferInstance: + """ + Create the InteractionTransferInstance + + :param body: + + :returns: The created InteractionTransferInstance + """ + data = body.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + payload = self._version.create( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return InteractionTransferInstance( + self._version, + payload, + interaction_sid=self._solution["interaction_sid"], + channel_sid=self._solution["channel_sid"], + ) + + async def create_async( + self, body: Union[object, object] = values.unset + ) -> InteractionTransferInstance: + """ + Asynchronously create the InteractionTransferInstance + + :param body: + + :returns: The created InteractionTransferInstance + """ + data = body.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return InteractionTransferInstance( + self._version, + payload, + interaction_sid=self._solution["interaction_sid"], + channel_sid=self._solution["channel_sid"], + ) + + def get(self, sid: str) -> InteractionTransferContext: + """ + Constructs a InteractionTransferContext + + :param sid: The unique string created by Twilio to identify a Transfer resource. + """ + return InteractionTransferContext( + self._version, + interaction_sid=self._solution["interaction_sid"], + channel_sid=self._solution["channel_sid"], + sid=sid, + ) + + def __call__(self, sid: str) -> InteractionTransferContext: + """ + Constructs a InteractionTransferContext + + :param sid: The unique string created by Twilio to identify a Transfer resource. + """ + return InteractionTransferContext( + self._version, + interaction_sid=self._solution["interaction_sid"], + channel_sid=self._solution["channel_sid"], + sid=sid, + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/flex_api/v1/plugin/__init__.py b/twilio/rest/flex_api/v1/plugin/__init__.py index 09244d42de..2415c42710 100644 --- a/twilio/rest/flex_api/v1/plugin/__init__.py +++ b/twilio/rest/flex_api/v1/plugin/__init__.py @@ -198,7 +198,13 @@ def fetch(self, flex_metadata: Union[str, object] = values.unset) -> PluginInsta } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=data) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) return PluginInstance( self._version, @@ -223,8 +229,12 @@ async def fetch_async( } ) + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return PluginInstance( @@ -248,17 +258,24 @@ def update( :returns: The updated PluginInstance """ + data = values.of( { "FriendlyName": friendly_name, "Description": description, } ) - headers = values.of( - { - "Flex-Metadata": flex_metadata, - } - ) + headers = values.of({}) + + if not ( + flex_metadata is values.unset + or (isinstance(flex_metadata, str) and not flex_metadata) + ): + headers["Flex-Metadata"] = flex_metadata + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( method="POST", uri=self._uri, data=data, headers=headers @@ -281,17 +298,24 @@ async def update_async( :returns: The updated PluginInstance """ + data = values.of( { "FriendlyName": friendly_name, "Description": description, } ) - headers = values.of( - { - "Flex-Metadata": flex_metadata, - } - ) + headers = values.of({}) + + if not ( + flex_metadata is values.unset + or (isinstance(flex_metadata, str) and not flex_metadata) + ): + headers["Flex-Metadata"] = flex_metadata + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( method="POST", uri=self._uri, data=data, headers=headers @@ -381,9 +405,14 @@ def create( headers = values.of( { "Flex-Metadata": flex_metadata, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = self._version.create( method="POST", uri=self._uri, data=data, headers=headers ) @@ -418,9 +447,14 @@ async def create_async( headers = values.of( { "Flex-Metadata": flex_metadata, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = await self._version.create_async( method="POST", uri=self._uri, data=data, headers=headers ) @@ -569,7 +603,18 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of( + { + "Flex-Metadata": flex_metadata, + "Content-Type": "application/x-www-form-urlencoded", + } + ) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return PluginPage(self._version, response) async def page_async( @@ -599,8 +644,17 @@ async def page_async( } ) + headers = values.of( + { + "Flex-Metadata": flex_metadata, + "Content-Type": "application/x-www-form-urlencoded", + } + ) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return PluginPage(self._version, response) diff --git a/twilio/rest/flex_api/v1/plugin/plugin_versions.py b/twilio/rest/flex_api/v1/plugin/plugin_versions.py index 6f492dbad6..4d66ef572b 100644 --- a/twilio/rest/flex_api/v1/plugin/plugin_versions.py +++ b/twilio/rest/flex_api/v1/plugin/plugin_versions.py @@ -30,8 +30,9 @@ class PluginVersionsInstance(InstanceResource): :ivar version: The unique version of this Flex Plugin Version. :ivar plugin_url: The URL of where the Flex Plugin Version JavaScript bundle is hosted on. :ivar changelog: A changelog that describes the changes this Flex Plugin Version brings. - :ivar private: Whether to inject credentials while accessing this Plugin Version. The default value is false. + :ivar private: Whether the Flex Plugin Version is validated. The default value is false. :ivar archived: Whether the Flex Plugin Version is archived. The default value is false. + :ivar validated: :ivar date_created: The date and time in GMT when the Flex Plugin Version was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. :ivar url: The absolute URL of the Flex Plugin Version resource. """ @@ -53,6 +54,7 @@ def __init__( self.changelog: Optional[str] = payload.get("changelog") self.private: Optional[bool] = payload.get("private") self.archived: Optional[bool] = payload.get("archived") + self.validated: Optional[bool] = payload.get("validated") self.date_created: Optional[datetime] = deserialize.iso8601_datetime( payload.get("date_created") ) @@ -156,7 +158,13 @@ def fetch( } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=data) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) return PluginVersionsInstance( self._version, @@ -182,8 +190,12 @@ async def fetch_async( } ) + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return PluginVersionsInstance( @@ -251,6 +263,8 @@ def create( flex_metadata: Union[str, object] = values.unset, changelog: Union[str, object] = values.unset, private: Union[bool, object] = values.unset, + cli_version: Union[str, object] = values.unset, + validate_status: Union[str, object] = values.unset, ) -> PluginVersionsInstance: """ Create the PluginVersionsInstance @@ -260,6 +274,8 @@ def create( :param flex_metadata: The Flex-Metadata HTTP request header :param changelog: The changelog of the Flex Plugin Version. :param private: Whether this Flex Plugin Version requires authorization. + :param cli_version: The version of Flex Plugins CLI used to create this plugin + :param validate_status: The validation status of the plugin, indicating whether it has been validated :returns: The created PluginVersionsInstance """ @@ -270,14 +286,21 @@ def create( "PluginUrl": plugin_url, "Changelog": changelog, "Private": serialize.boolean_to_string(private), + "CliVersion": cli_version, + "ValidateStatus": validate_status, } ) headers = values.of( { "Flex-Metadata": flex_metadata, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = self._version.create( method="POST", uri=self._uri, data=data, headers=headers ) @@ -293,6 +316,8 @@ async def create_async( flex_metadata: Union[str, object] = values.unset, changelog: Union[str, object] = values.unset, private: Union[bool, object] = values.unset, + cli_version: Union[str, object] = values.unset, + validate_status: Union[str, object] = values.unset, ) -> PluginVersionsInstance: """ Asynchronously create the PluginVersionsInstance @@ -302,6 +327,8 @@ async def create_async( :param flex_metadata: The Flex-Metadata HTTP request header :param changelog: The changelog of the Flex Plugin Version. :param private: Whether this Flex Plugin Version requires authorization. + :param cli_version: The version of Flex Plugins CLI used to create this plugin + :param validate_status: The validation status of the plugin, indicating whether it has been validated :returns: The created PluginVersionsInstance """ @@ -312,14 +339,21 @@ async def create_async( "PluginUrl": plugin_url, "Changelog": changelog, "Private": serialize.boolean_to_string(private), + "CliVersion": cli_version, + "ValidateStatus": validate_status, } ) headers = values.of( { "Flex-Metadata": flex_metadata, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = await self._version.create_async( method="POST", uri=self._uri, data=data, headers=headers ) @@ -470,7 +504,18 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of( + { + "Flex-Metadata": flex_metadata, + "Content-Type": "application/x-www-form-urlencoded", + } + ) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return PluginVersionsPage(self._version, response, self._solution) async def page_async( @@ -500,8 +545,17 @@ async def page_async( } ) + headers = values.of( + { + "Flex-Metadata": flex_metadata, + "Content-Type": "application/x-www-form-urlencoded", + } + ) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return PluginVersionsPage(self._version, response, self._solution) diff --git a/twilio/rest/flex_api/v1/plugin_archive.py b/twilio/rest/flex_api/v1/plugin_archive.py index 68f9bce384..e7f526a919 100644 --- a/twilio/rest/flex_api/v1/plugin_archive.py +++ b/twilio/rest/flex_api/v1/plugin_archive.py @@ -138,12 +138,17 @@ def update( :returns: The updated PluginArchiveInstance """ + data = values.of({}) - headers = values.of( - { - "Flex-Metadata": flex_metadata, - } - ) + headers = values.of({}) + + if not ( + flex_metadata is values.unset + or (isinstance(flex_metadata, str) and not flex_metadata) + ): + headers["Flex-Metadata"] = flex_metadata + + headers["Accept"] = "application/json" payload = self._version.update( method="POST", uri=self._uri, data=data, headers=headers @@ -161,12 +166,17 @@ async def update_async( :returns: The updated PluginArchiveInstance """ + data = values.of({}) - headers = values.of( - { - "Flex-Metadata": flex_metadata, - } - ) + headers = values.of({}) + + if not ( + flex_metadata is values.unset + or (isinstance(flex_metadata, str) and not flex_metadata) + ): + headers["Flex-Metadata"] = flex_metadata + + headers["Accept"] = "application/json" payload = await self._version.update_async( method="POST", uri=self._uri, data=data, headers=headers diff --git a/twilio/rest/flex_api/v1/plugin_configuration/__init__.py b/twilio/rest/flex_api/v1/plugin_configuration/__init__.py index ebe173985b..b17d697e3b 100644 --- a/twilio/rest/flex_api/v1/plugin_configuration/__init__.py +++ b/twilio/rest/flex_api/v1/plugin_configuration/__init__.py @@ -154,7 +154,13 @@ def fetch( } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=data) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) return PluginConfigurationInstance( self._version, @@ -179,8 +185,12 @@ async def fetch_async( } ) + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return PluginConfigurationInstance( @@ -271,9 +281,14 @@ def create( headers = values.of( { "Flex-Metadata": flex_metadata, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = self._version.create( method="POST", uri=self._uri, data=data, headers=headers ) @@ -308,9 +323,14 @@ async def create_async( headers = values.of( { "Flex-Metadata": flex_metadata, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = await self._version.create_async( method="POST", uri=self._uri, data=data, headers=headers ) @@ -459,7 +479,18 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of( + { + "Flex-Metadata": flex_metadata, + "Content-Type": "application/x-www-form-urlencoded", + } + ) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return PluginConfigurationPage(self._version, response) async def page_async( @@ -489,8 +520,17 @@ async def page_async( } ) + headers = values.of( + { + "Flex-Metadata": flex_metadata, + "Content-Type": "application/x-www-form-urlencoded", + } + ) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return PluginConfigurationPage(self._version, response) diff --git a/twilio/rest/flex_api/v1/plugin_configuration/configured_plugin.py b/twilio/rest/flex_api/v1/plugin_configuration/configured_plugin.py index 6e54012eb0..062a7db7b4 100644 --- a/twilio/rest/flex_api/v1/plugin_configuration/configured_plugin.py +++ b/twilio/rest/flex_api/v1/plugin_configuration/configured_plugin.py @@ -170,7 +170,13 @@ def fetch( } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=data) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) return ConfiguredPluginInstance( self._version, @@ -196,8 +202,12 @@ async def fetch_async( } ) + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ConfiguredPluginInstance( @@ -402,7 +412,18 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of( + { + "Flex-Metadata": flex_metadata, + "Content-Type": "application/x-www-form-urlencoded", + } + ) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ConfiguredPluginPage(self._version, response, self._solution) async def page_async( @@ -432,8 +453,17 @@ async def page_async( } ) + headers = values.of( + { + "Flex-Metadata": flex_metadata, + "Content-Type": "application/x-www-form-urlencoded", + } + ) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ConfiguredPluginPage(self._version, response, self._solution) diff --git a/twilio/rest/flex_api/v1/plugin_configuration_archive.py b/twilio/rest/flex_api/v1/plugin_configuration_archive.py index 97d2f8120d..3fec073333 100644 --- a/twilio/rest/flex_api/v1/plugin_configuration_archive.py +++ b/twilio/rest/flex_api/v1/plugin_configuration_archive.py @@ -136,12 +136,17 @@ def update( :returns: The updated PluginConfigurationArchiveInstance """ + data = values.of({}) - headers = values.of( - { - "Flex-Metadata": flex_metadata, - } - ) + headers = values.of({}) + + if not ( + flex_metadata is values.unset + or (isinstance(flex_metadata, str) and not flex_metadata) + ): + headers["Flex-Metadata"] = flex_metadata + + headers["Accept"] = "application/json" payload = self._version.update( method="POST", uri=self._uri, data=data, headers=headers @@ -161,12 +166,17 @@ async def update_async( :returns: The updated PluginConfigurationArchiveInstance """ + data = values.of({}) - headers = values.of( - { - "Flex-Metadata": flex_metadata, - } - ) + headers = values.of({}) + + if not ( + flex_metadata is values.unset + or (isinstance(flex_metadata, str) and not flex_metadata) + ): + headers["Flex-Metadata"] = flex_metadata + + headers["Accept"] = "application/json" payload = await self._version.update_async( method="POST", uri=self._uri, data=data, headers=headers diff --git a/twilio/rest/flex_api/v1/plugin_release.py b/twilio/rest/flex_api/v1/plugin_release.py index f2e8efd306..0694b05f8b 100644 --- a/twilio/rest/flex_api/v1/plugin_release.py +++ b/twilio/rest/flex_api/v1/plugin_release.py @@ -136,7 +136,13 @@ def fetch( } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=data) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) return PluginReleaseInstance( self._version, @@ -161,8 +167,12 @@ async def fetch_async( } ) + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return PluginReleaseInstance( @@ -233,9 +243,14 @@ def create( headers = values.of( { "Flex-Metadata": flex_metadata, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = self._version.create( method="POST", uri=self._uri, data=data, headers=headers ) @@ -262,9 +277,14 @@ async def create_async( headers = values.of( { "Flex-Metadata": flex_metadata, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = await self._version.create_async( method="POST", uri=self._uri, data=data, headers=headers ) @@ -413,7 +433,18 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of( + { + "Flex-Metadata": flex_metadata, + "Content-Type": "application/x-www-form-urlencoded", + } + ) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return PluginReleasePage(self._version, response) async def page_async( @@ -443,8 +474,17 @@ async def page_async( } ) + headers = values.of( + { + "Flex-Metadata": flex_metadata, + "Content-Type": "application/x-www-form-urlencoded", + } + ) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return PluginReleasePage(self._version, response) diff --git a/twilio/rest/flex_api/v1/plugin_version_archive.py b/twilio/rest/flex_api/v1/plugin_version_archive.py index ae8d2f3dff..be169d4d64 100644 --- a/twilio/rest/flex_api/v1/plugin_version_archive.py +++ b/twilio/rest/flex_api/v1/plugin_version_archive.py @@ -148,12 +148,17 @@ def update( :returns: The updated PluginVersionArchiveInstance """ + data = values.of({}) - headers = values.of( - { - "Flex-Metadata": flex_metadata, - } - ) + headers = values.of({}) + + if not ( + flex_metadata is values.unset + or (isinstance(flex_metadata, str) and not flex_metadata) + ): + headers["Flex-Metadata"] = flex_metadata + + headers["Accept"] = "application/json" payload = self._version.update( method="POST", uri=self._uri, data=data, headers=headers @@ -176,12 +181,17 @@ async def update_async( :returns: The updated PluginVersionArchiveInstance """ + data = values.of({}) - headers = values.of( - { - "Flex-Metadata": flex_metadata, - } - ) + headers = values.of({}) + + if not ( + flex_metadata is values.unset + or (isinstance(flex_metadata, str) and not flex_metadata) + ): + headers["Flex-Metadata"] = flex_metadata + + headers["Accept"] = "application/json" payload = await self._version.update_async( method="POST", uri=self._uri, data=data, headers=headers diff --git a/twilio/rest/flex_api/v1/provisioning_status.py b/twilio/rest/flex_api/v1/provisioning_status.py index 9cc9144dcc..2a7bc5b465 100644 --- a/twilio/rest/flex_api/v1/provisioning_status.py +++ b/twilio/rest/flex_api/v1/provisioning_status.py @@ -13,6 +13,7 @@ """ 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 @@ -104,10 +105,11 @@ def fetch(self) -> ProvisioningStatusInstance: :returns: The fetched ProvisioningStatusInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ProvisioningStatusInstance( self._version, @@ -122,9 +124,12 @@ async def fetch_async(self) -> ProvisioningStatusInstance: :returns: The fetched ProvisioningStatusInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ProvisioningStatusInstance( diff --git a/twilio/rest/flex_api/v1/web_channel.py b/twilio/rest/flex_api/v1/web_channel.py index ddf9c8f902..46e44fcecd 100644 --- a/twilio/rest/flex_api/v1/web_channel.py +++ b/twilio/rest/flex_api/v1/web_channel.py @@ -178,10 +178,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -190,9 +190,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> WebChannelInstance: @@ -203,10 +205,11 @@ def fetch(self) -> WebChannelInstance: :returns: The fetched WebChannelInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return WebChannelInstance( self._version, @@ -222,9 +225,12 @@ async def fetch_async(self) -> WebChannelInstance: :returns: The fetched WebChannelInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return WebChannelInstance( @@ -246,17 +252,21 @@ def update( :returns: The updated WebChannelInstance """ + data = values.of( { "ChatStatus": chat_status, "PostEngagementData": post_engagement_data, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WebChannelInstance(self._version, payload, sid=self._solution["sid"]) @@ -274,17 +284,21 @@ async def update_async( :returns: The updated WebChannelInstance """ + data = values.of( { "ChatStatus": chat_status, "PostEngagementData": post_engagement_data, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WebChannelInstance(self._version, payload, sid=self._solution["sid"]) @@ -363,11 +377,14 @@ def create( "PreEngagementData": pre_engagement_data, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WebChannelInstance(self._version, payload) @@ -404,11 +421,14 @@ async def create_async( "PreEngagementData": pre_engagement_data, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WebChannelInstance(self._version, payload) @@ -540,7 +560,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return WebChannelPage(self._version, response) async def page_async( @@ -567,8 +593,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return WebChannelPage(self._version, response) diff --git a/twilio/rest/flex_api/v2/__init__.py b/twilio/rest/flex_api/v2/__init__.py index 021615e19f..e05ffcdfb5 100644 --- a/twilio/rest/flex_api/v2/__init__.py +++ b/twilio/rest/flex_api/v2/__init__.py @@ -15,6 +15,7 @@ from typing import Optional from twilio.base.version import Version from twilio.base.domain import Domain +from twilio.rest.flex_api.v2.flex_user import FlexUserList from twilio.rest.flex_api.v2.web_channels import WebChannelsList @@ -27,8 +28,15 @@ def __init__(self, domain: Domain): :param domain: The Twilio.flex_api domain """ super().__init__(domain, "v2") + self._flex_user: Optional[FlexUserList] = None self._web_channels: Optional[WebChannelsList] = None + @property + def flex_user(self) -> FlexUserList: + if self._flex_user is None: + self._flex_user = FlexUserList(self) + return self._flex_user + @property def web_channels(self) -> WebChannelsList: if self._web_channels is None: diff --git a/twilio/rest/flex_api/v2/flex_user.py b/twilio/rest/flex_api/v2/flex_user.py new file mode 100644 index 0000000000..eb2228d015 --- /dev/null +++ b/twilio/rest/flex_api/v2/flex_user.py @@ -0,0 +1,358 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Flex + 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 +from twilio.base import deserialize, values +from twilio.base.instance_context import InstanceContext +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + + +class FlexUserInstance(InstanceResource): + """ + :ivar account_sid: The unique SID of the account that created the resource. + :ivar instance_sid: The unique ID created by Twilio to identify a Flex instance. + :ivar user_sid: The unique SID identifier of the Twilio Unified User. + :ivar flex_user_sid: The unique SID identifier of the Flex User. + :ivar worker_sid: The unique SID identifier of the worker. + :ivar workspace_sid: The unique SID identifier of the workspace. + :ivar flex_team_sid: The unique SID identifier of the Flex Team. + :ivar username: Username of the User. + :ivar email: Email 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. + :ivar url: + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + instance_sid: Optional[str] = None, + flex_user_sid: Optional[str] = None, + ): + super().__init__(version) + + self.account_sid: Optional[str] = payload.get("account_sid") + self.instance_sid: Optional[str] = payload.get("instance_sid") + self.user_sid: Optional[str] = payload.get("user_sid") + self.flex_user_sid: Optional[str] = payload.get("flex_user_sid") + self.worker_sid: Optional[str] = payload.get("worker_sid") + self.workspace_sid: Optional[str] = payload.get("workspace_sid") + self.flex_team_sid: Optional[str] = payload.get("flex_team_sid") + self.username: Optional[str] = payload.get("username") + self.email: Optional[str] = payload.get("email") + 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") + ) + self.updated_date: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("updated_date") + ) + self.version: Optional[int] = deserialize.integer(payload.get("version")) + self.url: Optional[str] = payload.get("url") + + self._solution = { + "instance_sid": instance_sid or self.instance_sid, + "flex_user_sid": flex_user_sid or self.flex_user_sid, + } + self._context: Optional[FlexUserContext] = None + + @property + def _proxy(self) -> "FlexUserContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: FlexUserContext for this FlexUserInstance + """ + if self._context is None: + self._context = FlexUserContext( + self._version, + instance_sid=self._solution["instance_sid"], + flex_user_sid=self._solution["flex_user_sid"], + ) + return self._context + + def fetch(self) -> "FlexUserInstance": + """ + Fetch the FlexUserInstance + + + :returns: The fetched FlexUserInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "FlexUserInstance": + """ + Asynchronous coroutine to fetch the FlexUserInstance + + + :returns: The fetched FlexUserInstance + """ + return await self._proxy.fetch_async() + + def update( + self, + email: Union[str, object] = values.unset, + user_sid: Union[str, object] = values.unset, + locale: Union[str, object] = values.unset, + ) -> "FlexUserInstance": + """ + Update the FlexUserInstance + + :param email: Email 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( + email=email, + user_sid=user_sid, + locale=locale, + ) + + async def update_async( + self, + email: 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 email: Email 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( + email=email, + user_sid=user_sid, + locale=locale, + ) + + 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 FlexUserContext(InstanceContext): + + def __init__(self, version: Version, instance_sid: str, flex_user_sid: str): + """ + Initialize the FlexUserContext + + :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. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "instance_sid": instance_sid, + "flex_user_sid": flex_user_sid, + } + self._uri = "/Instances/{instance_sid}/Users/{flex_user_sid}".format( + **self._solution + ) + + def fetch(self) -> FlexUserInstance: + """ + Fetch the FlexUserInstance + + + :returns: The fetched FlexUserInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return FlexUserInstance( + self._version, + payload, + instance_sid=self._solution["instance_sid"], + flex_user_sid=self._solution["flex_user_sid"], + ) + + async def fetch_async(self) -> FlexUserInstance: + """ + Asynchronous coroutine to fetch the FlexUserInstance + + + :returns: The fetched FlexUserInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + return FlexUserInstance( + self._version, + payload, + instance_sid=self._solution["instance_sid"], + flex_user_sid=self._solution["flex_user_sid"], + ) + + def update( + self, + email: Union[str, object] = values.unset, + user_sid: Union[str, object] = values.unset, + locale: Union[str, object] = values.unset, + ) -> FlexUserInstance: + """ + Update the FlexUserInstance + + :param email: Email 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( + { + "Email": email, + "UserSid": user_sid, + "Locale": locale, + } + ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = self._version.update( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return FlexUserInstance( + self._version, + payload, + instance_sid=self._solution["instance_sid"], + flex_user_sid=self._solution["flex_user_sid"], + ) + + async def update_async( + self, + email: 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 email: Email 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( + { + "Email": email, + "UserSid": user_sid, + "Locale": locale, + } + ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = await self._version.update_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return 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 + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class FlexUserList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the FlexUserList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + 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. + """ + return FlexUserContext( + self._version, instance_sid=instance_sid, flex_user_sid=flex_user_sid + ) + + 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. + """ + return FlexUserContext( + self._version, instance_sid=instance_sid, flex_user_sid=flex_user_sid + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/flex_api/v2/web_channels.py b/twilio/rest/flex_api/v2/web_channels.py index 13e5b28d7a..8e5aff8226 100644 --- a/twilio/rest/flex_api/v2/web_channels.py +++ b/twilio/rest/flex_api/v2/web_channels.py @@ -58,6 +58,7 @@ def __init__(self, version: Version): def create( self, address_sid: str, + ui_version: Union[str, object] = values.unset, chat_friendly_name: Union[str, object] = values.unset, customer_friendly_name: Union[str, object] = values.unset, pre_engagement_data: Union[str, object] = values.unset, @@ -66,6 +67,7 @@ def create( Create the WebChannelsInstance :param address_sid: The SID of the Conversations Address. See [Address Configuration Resource](https://www.twilio.com/docs/conversations/api/address-configuration-resource) for configuration details. When a conversation is created on the Flex backend, the callback URL will be set to the corresponding Studio Flow SID or webhook URL in your address configuration. + :param ui_version: The Ui-Version HTTP request header :param chat_friendly_name: The Conversation's friendly name. See the [Conversation resource](https://www.twilio.com/docs/conversations/api/conversation-resource) for an example. :param customer_friendly_name: The Conversation participant's friendly name. See the [Conversation Participant Resource](https://www.twilio.com/docs/conversations/api/conversation-participant-resource) for an example. :param pre_engagement_data: The pre-engagement data. @@ -81,11 +83,19 @@ def create( "PreEngagementData": pre_engagement_data, } ) + headers = values.of( + { + "Ui-Version": ui_version, + "Content-Type": "application/x-www-form-urlencoded", + } + ) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WebChannelsInstance(self._version, payload) @@ -93,6 +103,7 @@ def create( async def create_async( self, address_sid: str, + ui_version: Union[str, object] = values.unset, chat_friendly_name: Union[str, object] = values.unset, customer_friendly_name: Union[str, object] = values.unset, pre_engagement_data: Union[str, object] = values.unset, @@ -101,6 +112,7 @@ async def create_async( Asynchronously create the WebChannelsInstance :param address_sid: The SID of the Conversations Address. See [Address Configuration Resource](https://www.twilio.com/docs/conversations/api/address-configuration-resource) for configuration details. When a conversation is created on the Flex backend, the callback URL will be set to the corresponding Studio Flow SID or webhook URL in your address configuration. + :param ui_version: The Ui-Version HTTP request header :param chat_friendly_name: The Conversation's friendly name. See the [Conversation resource](https://www.twilio.com/docs/conversations/api/conversation-resource) for an example. :param customer_friendly_name: The Conversation participant's friendly name. See the [Conversation Participant Resource](https://www.twilio.com/docs/conversations/api/conversation-participant-resource) for an example. :param pre_engagement_data: The pre-engagement data. @@ -116,11 +128,19 @@ async def create_async( "PreEngagementData": pre_engagement_data, } ) + headers = values.of( + { + "Ui-Version": ui_version, + "Content-Type": "application/x-www-form-urlencoded", + } + ) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WebChannelsInstance(self._version, payload) diff --git a/twilio/rest/frontline_api/v1/user.py b/twilio/rest/frontline_api/v1/user.py index 8c9dd93853..a45ed2ffee 100644 --- a/twilio/rest/frontline_api/v1/user.py +++ b/twilio/rest/frontline_api/v1/user.py @@ -170,10 +170,11 @@ def fetch(self) -> UserInstance: :returns: The fetched UserInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return UserInstance( self._version, @@ -189,9 +190,12 @@ async def fetch_async(self) -> UserInstance: :returns: The fetched UserInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return UserInstance( @@ -217,6 +221,7 @@ def update( :returns: The updated UserInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -225,11 +230,14 @@ def update( "IsAvailable": serialize.boolean_to_string(is_available), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return UserInstance(self._version, payload, sid=self._solution["sid"]) @@ -251,6 +259,7 @@ async def update_async( :returns: The updated UserInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -259,11 +268,14 @@ async def update_async( "IsAvailable": serialize.boolean_to_string(is_available), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return UserInstance(self._version, payload, sid=self._solution["sid"]) diff --git a/twilio/rest/media/MediaBase.py b/twilio/rest/iam/IamBase.py similarity index 77% rename from twilio/rest/media/MediaBase.py rename to twilio/rest/iam/IamBase.py index 6581eb5d09..2882ec145b 100644 --- a/twilio/rest/media/MediaBase.py +++ b/twilio/rest/iam/IamBase.py @@ -13,24 +13,24 @@ from twilio.base.domain import Domain from twilio.rest import Client -from twilio.rest.media.v1 import V1 +from twilio.rest.iam.v1 import V1 -class MediaBase(Domain): +class IamBase(Domain): def __init__(self, twilio: Client): """ - Initialize the Media Domain + Initialize the Iam Domain - :returns: Domain for Media + :returns: Domain for Iam """ - super().__init__(twilio, "https://media.twilio.com") + super().__init__(twilio, "https://iam.twilio.com") self._v1: Optional[V1] = None @property def v1(self) -> V1: """ - :returns: Versions v1 of Media + :returns: Versions v1 of Iam """ if self._v1 is None: self._v1 = V1(self) @@ -41,4 +41,4 @@ def __repr__(self) -> str: Provide a friendly representation :returns: Machine friendly representation """ - return "" + return "" diff --git a/twilio/rest/iam/__init__.py b/twilio/rest/iam/__init__.py new file mode 100644 index 0000000000..994ecee62f --- /dev/null +++ b/twilio/rest/iam/__init__.py @@ -0,0 +1,25 @@ +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 + + +class Iam(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 diff --git a/twilio/rest/iam/v1/__init__.py b/twilio/rest/iam/v1/__init__.py new file mode 100644 index 0000000000..08c45435a6 --- /dev/null +++ b/twilio/rest/iam/v1/__init__.py @@ -0,0 +1,67 @@ +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 +from twilio.rest.iam.v1.token import TokenList + + +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 + self._token: Optional[TokenList] = 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 + + @property + def token(self) -> TokenList: + if self._token is None: + self._token = TokenList(self) + return self._token + + def __repr__(self) -> str: + """ + Provide a friendly representation + :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 0000000000..f07512c09b --- /dev/null +++ b/twilio/rest/iam/v1/api_key.py @@ -0,0 +1,342 @@ +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 + """ + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the ApiKeyInstance + + + :returns: True if delete succeeds, False otherwise + """ + + headers = values.of({}) + + return await self._version.delete_async( + method="DELETE", uri=self._uri, headers=headers + ) + + def fetch(self) -> ApiKeyInstance: + """ + Fetch the ApiKeyInstance + + + :returns: The fetched ApiKeyInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + 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 + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + 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), + } + ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = self._version.update( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return 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), + } + ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = await self._version.update_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return 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 0000000000..03b29cdb38 --- /dev/null +++ b/twilio/rest/iam/v1/get_api_keys.py @@ -0,0 +1,304 @@ +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, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return 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, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + return 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 0000000000..760ce79ca3 --- /dev/null +++ b/twilio/rest/iam/v1/new_api_key.py @@ -0,0 +1,157 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Iam + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from datetime import datetime +from typing import Any, Dict, Optional, Union +from twilio.base import deserialize, serialize, values + +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + + +class 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"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = self._version.create( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return 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"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return NewApiKeyInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/iam/v1/token.py b/twilio/rest/iam/v1/token.py new file mode 100644 index 0000000000..50d3d11930 --- /dev/null +++ b/twilio/rest/iam/v1/token.py @@ -0,0 +1,170 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Iam + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from typing import Any, Dict, Optional, Union +from twilio.base import values + +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + + +class TokenInstance(InstanceResource): + """ + :ivar access_token: Token which carries the necessary information to access a Twilio resource directly. + :ivar refresh_token: Token which carries the information necessary to get a new access token. + :ivar id_token: Token which carries the information necessary of user profile. + :ivar token_type: Token type + :ivar expires_in: + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.access_token: Optional[str] = payload.get("access_token") + self.refresh_token: Optional[str] = payload.get("refresh_token") + self.id_token: Optional[str] = payload.get("id_token") + self.token_type: Optional[str] = payload.get("token_type") + self.expires_in: Optional[int] = payload.get("expires_in") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class TokenList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the TokenList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/token" + + def create( + self, + grant_type: str, + client_id: str, + client_secret: Union[str, object] = values.unset, + code: Union[str, object] = values.unset, + redirect_uri: Union[str, object] = values.unset, + audience: Union[str, object] = values.unset, + refresh_token: Union[str, object] = values.unset, + scope: Union[str, object] = values.unset, + ) -> TokenInstance: + """ + Create the TokenInstance + + :param grant_type: Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token. + :param client_id: A 34 character string that uniquely identifies this OAuth App. + :param client_secret: The credential for confidential OAuth App. + :param code: JWT token related to the authorization code grant type. + :param redirect_uri: The redirect uri + :param audience: The targeted audience uri + :param refresh_token: JWT token related to refresh access token. + :param scope: The scope of token + + :returns: The created TokenInstance + """ + + data = values.of( + { + "grant_type": grant_type, + "client_id": client_id, + "client_secret": client_secret, + "code": code, + "redirect_uri": redirect_uri, + "audience": audience, + "refresh_token": refresh_token, + "scope": scope, + } + ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = self._version.create( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return TokenInstance(self._version, payload) + + async def create_async( + self, + grant_type: str, + client_id: str, + client_secret: Union[str, object] = values.unset, + code: Union[str, object] = values.unset, + redirect_uri: Union[str, object] = values.unset, + audience: Union[str, object] = values.unset, + refresh_token: Union[str, object] = values.unset, + scope: Union[str, object] = values.unset, + ) -> TokenInstance: + """ + Asynchronously create the TokenInstance + + :param grant_type: Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token. + :param client_id: A 34 character string that uniquely identifies this OAuth App. + :param client_secret: The credential for confidential OAuth App. + :param code: JWT token related to the authorization code grant type. + :param redirect_uri: The redirect uri + :param audience: The targeted audience uri + :param refresh_token: JWT token related to refresh access token. + :param scope: The scope of token + + :returns: The created TokenInstance + """ + + data = values.of( + { + "grant_type": grant_type, + "client_id": client_id, + "client_secret": client_secret, + "code": code, + "redirect_uri": redirect_uri, + "audience": audience, + "refresh_token": refresh_token, + "scope": scope, + } + ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return TokenInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/insights/v1/call/__init__.py b/twilio/rest/insights/v1/call/__init__.py index ff628b7d06..cb08aa58aa 100644 --- a/twilio/rest/insights/v1/call/__init__.py +++ b/twilio/rest/insights/v1/call/__init__.py @@ -13,6 +13,7 @@ """ 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 @@ -146,10 +147,11 @@ def fetch(self) -> CallInstance: :returns: The fetched CallInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return CallInstance( self._version, @@ -165,9 +167,12 @@ async def fetch_async(self) -> CallInstance: :returns: The fetched CallInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return CallInstance( diff --git a/twilio/rest/insights/v1/call/annotation.py b/twilio/rest/insights/v1/call/annotation.py index d560003c0a..6e705d3916 100644 --- a/twilio/rest/insights/v1/call/annotation.py +++ b/twilio/rest/insights/v1/call/annotation.py @@ -209,10 +209,11 @@ def fetch(self) -> AnnotationInstance: :returns: The fetched AnnotationInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return AnnotationInstance( self._version, @@ -228,9 +229,12 @@ async def fetch_async(self) -> AnnotationInstance: :returns: The fetched AnnotationInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return AnnotationInstance( @@ -264,6 +268,7 @@ def update( :returns: The updated AnnotationInstance """ + data = values.of( { "AnsweredBy": answered_by, @@ -275,11 +280,14 @@ def update( "Incident": incident, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AnnotationInstance( @@ -311,6 +319,7 @@ async def update_async( :returns: The updated AnnotationInstance """ + data = values.of( { "AnsweredBy": answered_by, @@ -322,11 +331,14 @@ async def update_async( "Incident": incident, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AnnotationInstance( diff --git a/twilio/rest/insights/v1/call/call_summary.py b/twilio/rest/insights/v1/call/call_summary.py index 0e256b36c8..e21af100a1 100644 --- a/twilio/rest/insights/v1/call/call_summary.py +++ b/twilio/rest/insights/v1/call/call_summary.py @@ -47,6 +47,7 @@ class CallType(object): SIP = "sip" TRUNKING = "trunking" CLIENT = "client" + WHATSAPP = "whatsapp" class ProcessingState(object): COMPLETE = "complete" @@ -222,7 +223,13 @@ def fetch( } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=data) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) return CallSummaryInstance( self._version, @@ -250,8 +257,12 @@ async def fetch_async( } ) + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return CallSummaryInstance( diff --git a/twilio/rest/insights/v1/call/event.py b/twilio/rest/insights/v1/call/event.py index 89734f110a..98dce5eb71 100644 --- a/twilio/rest/insights/v1/call/event.py +++ b/twilio/rest/insights/v1/call/event.py @@ -259,7 +259,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return EventPage(self._version, response, self._solution) async def page_async( @@ -289,8 +295,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return EventPage(self._version, response, self._solution) diff --git a/twilio/rest/insights/v1/call/metric.py b/twilio/rest/insights/v1/call/metric.py index 3cf9decc53..77f770ae7c 100644 --- a/twilio/rest/insights/v1/call/metric.py +++ b/twilio/rest/insights/v1/call/metric.py @@ -271,7 +271,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return MetricPage(self._version, response, self._solution) async def page_async( @@ -304,8 +310,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return MetricPage(self._version, response, self._solution) diff --git a/twilio/rest/insights/v1/call_summaries.py b/twilio/rest/insights/v1/call_summaries.py index f68744eefc..0a75e38454 100644 --- a/twilio/rest/insights/v1/call_summaries.py +++ b/twilio/rest/insights/v1/call_summaries.py @@ -48,6 +48,7 @@ class CallType(object): SIP = "sip" TRUNKING = "trunking" CLIENT = "client" + WHATSAPP = "whatsapp" class ProcessingState(object): COMPLETE = "complete" @@ -182,7 +183,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 +202,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 +226,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 +243,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 +269,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 +286,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 +308,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 +327,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 +351,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 +368,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 +394,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 +411,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 +433,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 +452,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 +475,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 +492,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 +518,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 +535,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 +557,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 +576,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 +599,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 +616,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 +643,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 +660,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 +682,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 +701,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 +724,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 +741,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 +764,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,13 +781,30 @@ 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, } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return CallSummariesPage(self._version, response) async def page_async( @@ -686,7 +815,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 +834,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 +857,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 +874,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 +897,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,14 +914,29 @@ 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, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return CallSummariesPage(self._version, response) diff --git a/twilio/rest/insights/v1/conference/__init__.py b/twilio/rest/insights/v1/conference/__init__.py index 1ee8c09dc8..ef3c51dac3 100644 --- a/twilio/rest/insights/v1/conference/__init__.py +++ b/twilio/rest/insights/v1/conference/__init__.py @@ -51,12 +51,14 @@ class ProcessingState(object): class Region(object): US1 = "us1" + US2 = "us2" AU1 = "au1" BR1 = "br1" IE1 = "ie1" JP1 = "jp1" SG1 = "sg1" DE1 = "de1" + IN1 = "in1" class Tag(object): INVALID_REQUESTED_REGION = "invalid_requested_region" @@ -70,6 +72,7 @@ class Tag(object): HIGH_LATENCY = "high_latency" LOW_MOS = "low_mos" DETECTED_SILENCE = "detected_silence" + NO_CONCURRENT_PARTICIPANTS = "no_concurrent_participants" """ :ivar conference_sid: The unique SID identifier of the Conference. @@ -239,10 +242,11 @@ def fetch(self) -> ConferenceInstance: :returns: The fetched ConferenceInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ConferenceInstance( self._version, @@ -258,9 +262,12 @@ async def fetch_async(self) -> ConferenceInstance: :returns: The fetched ConferenceInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ConferenceInstance( @@ -604,7 +611,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ConferencePage(self._version, response) async def page_async( @@ -661,8 +674,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ConferencePage(self._version, response) diff --git a/twilio/rest/insights/v1/conference/conference_participant.py b/twilio/rest/insights/v1/conference/conference_participant.py index 68faa690b3..171f4f1f87 100644 --- a/twilio/rest/insights/v1/conference/conference_participant.py +++ b/twilio/rest/insights/v1/conference/conference_participant.py @@ -62,6 +62,7 @@ class Region(object): JP1 = "jp1" SG1 = "sg1" DE1 = "de1" + IN1 = "in1" """ :ivar participant_sid: SID for this participant. @@ -268,7 +269,13 @@ def fetch( } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=data) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) return ConferenceParticipantInstance( self._version, @@ -298,8 +305,12 @@ async def fetch_async( } ) + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ConferenceParticipantInstance( @@ -536,7 +547,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ConferenceParticipantPage(self._version, response, self._solution) async def page_async( @@ -572,8 +589,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ConferenceParticipantPage(self._version, response, self._solution) diff --git a/twilio/rest/insights/v1/room/__init__.py b/twilio/rest/insights/v1/room/__init__.py index 7361018e23..6fe0c476b5 100644 --- a/twilio/rest/insights/v1/room/__init__.py +++ b/twilio/rest/insights/v1/room/__init__.py @@ -29,6 +29,7 @@ class Codec(object): VP8 = "VP8" H264 = "H264" VP9 = "VP9" + OPUS = "opus" class CreatedMethod(object): SDK = "sdk" @@ -53,6 +54,8 @@ class EndReason(object): class ProcessingState(object): COMPLETE = "complete" IN_PROGRESS = "in_progress" + TIMEOUT = "timeout" + NOT_STARTED = "not_started" class RoomStatus(object): IN_PROGRESS = "in_progress" @@ -75,6 +78,18 @@ class TwilioRealm(object): IN1 = "in1" DE1 = "de1" GLL = "gll" + STAGE_US1 = "stage_us1" + STAGE_US2 = "stage_us2" + DEV_US1 = "dev_us1" + DEV_US2 = "dev_us2" + STAGE_DE1 = "stage_de1" + STAGE_IN1 = "stage_in1" + STAGE_IE1 = "stage_ie1" + STAGE_BR1 = "stage_br1" + STAGE_AU1 = "stage_au1" + STAGE_SG1 = "stage_sg1" + STAGE_JP1 = "stage_jp1" + OUTSIDE = "outside" """ :ivar account_sid: Account SID associated with this room. @@ -249,10 +264,11 @@ def fetch(self) -> RoomInstance: :returns: The fetched RoomInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return RoomInstance( self._version, @@ -268,9 +284,12 @@ async def fetch_async(self) -> RoomInstance: :returns: The fetched RoomInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return RoomInstance( @@ -539,7 +558,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return RoomPage(self._version, response) async def page_async( @@ -581,8 +606,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return RoomPage(self._version, response) diff --git a/twilio/rest/insights/v1/room/participant.py b/twilio/rest/insights/v1/room/participant.py index 0f6617f549..d0d3e592e0 100644 --- a/twilio/rest/insights/v1/room/participant.py +++ b/twilio/rest/insights/v1/room/participant.py @@ -28,6 +28,7 @@ class Codec(object): VP8 = "VP8" H264 = "H264" VP9 = "VP9" + OPUS = "opus" class EdgeLocation(object): ASHBURN = "ashburn" @@ -42,7 +43,9 @@ class EdgeLocation(object): class RoomStatus(object): IN_PROGRESS = "in_progress" + CONNECTED = "connected" COMPLETED = "completed" + DISCONNECTED = "disconnected" class TwilioRealm(object): US1 = "us1" @@ -55,6 +58,18 @@ class TwilioRealm(object): IN1 = "in1" DE1 = "de1" GLL = "gll" + STAGE_US1 = "stage_us1" + DEV_US1 = "dev_us1" + STAGE_AU1 = "stage_au1" + STAGE_SG1 = "stage_sg1" + STAGE_BR1 = "stage_br1" + STAGE_IN1 = "stage_in1" + STAGE_JP1 = "stage_jp1" + STAGE_DE1 = "stage_de1" + STAGE_IE1 = "stage_ie1" + STAGE_US2 = "stage_us2" + DEV_US2 = "dev_us2" + OUTSIDE = "outside" """ :ivar participant_sid: Unique identifier for the participant. @@ -190,10 +205,11 @@ def fetch(self) -> ParticipantInstance: :returns: The fetched ParticipantInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ParticipantInstance( self._version, @@ -210,9 +226,12 @@ async def fetch_async(self) -> ParticipantInstance: :returns: The fetched ParticipantInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ParticipantInstance( @@ -398,7 +417,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ParticipantPage(self._version, response, self._solution) async def page_async( @@ -425,8 +450,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ParticipantPage(self._version, response, self._solution) diff --git a/twilio/rest/insights/v1/setting.py b/twilio/rest/insights/v1/setting.py index c385fc424e..3c6b746f07 100644 --- a/twilio/rest/insights/v1/setting.py +++ b/twilio/rest/insights/v1/setting.py @@ -161,7 +161,13 @@ def fetch( } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=data) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) return SettingInstance( self._version, @@ -185,8 +191,12 @@ async def fetch_async( } ) + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return SettingInstance( @@ -209,6 +219,7 @@ def update( :returns: The updated SettingInstance """ + data = values.of( { "AdvancedFeatures": serialize.boolean_to_string(advanced_features), @@ -216,11 +227,14 @@ def update( "SubaccountSid": subaccount_sid, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SettingInstance(self._version, payload) @@ -240,6 +254,7 @@ async def update_async( :returns: The updated SettingInstance """ + data = values.of( { "AdvancedFeatures": serialize.boolean_to_string(advanced_features), @@ -247,11 +262,14 @@ async def update_async( "SubaccountSid": subaccount_sid, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SettingInstance(self._version, payload) diff --git a/twilio/rest/intelligence/v2/__init__.py b/twilio/rest/intelligence/v2/__init__.py index e20b125ced..4999146f93 100644 --- a/twilio/rest/intelligence/v2/__init__.py +++ b/twilio/rest/intelligence/v2/__init__.py @@ -15,6 +15,12 @@ from typing import Optional from twilio.base.version import Version from twilio.base.domain import Domain +from twilio.rest.intelligence.v2.custom_operator import CustomOperatorList +from twilio.rest.intelligence.v2.operator import OperatorList +from twilio.rest.intelligence.v2.operator_attachment import OperatorAttachmentList +from twilio.rest.intelligence.v2.operator_attachments import OperatorAttachmentsList +from twilio.rest.intelligence.v2.operator_type import OperatorTypeList +from twilio.rest.intelligence.v2.prebuilt_operator import PrebuiltOperatorList from twilio.rest.intelligence.v2.service import ServiceList from twilio.rest.intelligence.v2.transcript import TranscriptList @@ -28,9 +34,51 @@ def __init__(self, domain: Domain): :param domain: The Twilio.intelligence domain """ super().__init__(domain, "v2") + self._custom_operators: Optional[CustomOperatorList] = None + self._operators: Optional[OperatorList] = None + self._operator_attachment: Optional[OperatorAttachmentList] = None + self._operator_attachments: Optional[OperatorAttachmentsList] = None + self._operator_type: Optional[OperatorTypeList] = None + self._prebuilt_operators: Optional[PrebuiltOperatorList] = None self._services: Optional[ServiceList] = None self._transcripts: Optional[TranscriptList] = None + @property + def custom_operators(self) -> CustomOperatorList: + if self._custom_operators is None: + self._custom_operators = CustomOperatorList(self) + return self._custom_operators + + @property + def operators(self) -> OperatorList: + if self._operators is None: + self._operators = OperatorList(self) + return self._operators + + @property + def operator_attachment(self) -> OperatorAttachmentList: + if self._operator_attachment is None: + self._operator_attachment = OperatorAttachmentList(self) + return self._operator_attachment + + @property + def operator_attachments(self) -> OperatorAttachmentsList: + if self._operator_attachments is None: + self._operator_attachments = OperatorAttachmentsList(self) + return self._operator_attachments + + @property + def operator_type(self) -> OperatorTypeList: + if self._operator_type is None: + self._operator_type = OperatorTypeList(self) + return self._operator_type + + @property + def prebuilt_operators(self) -> PrebuiltOperatorList: + if self._prebuilt_operators is None: + self._prebuilt_operators = PrebuiltOperatorList(self) + return self._prebuilt_operators + @property def services(self) -> ServiceList: if self._services is None: diff --git a/twilio/rest/intelligence/v2/custom_operator.py b/twilio/rest/intelligence/v2/custom_operator.py new file mode 100644 index 0000000000..3dd73d47bb --- /dev/null +++ b/twilio/rest/intelligence/v2/custom_operator.py @@ -0,0 +1,716 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Intelligence + 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 CustomOperatorInstance(InstanceResource): + + class Availability(object): + INTERNAL = "internal" + BETA = "beta" + PUBLIC = "public" + RETIRED = "retired" + + """ + :ivar account_sid: The unique SID identifier of the Account the Custom Operator belongs to. + :ivar sid: A 34 character string that uniquely identifies this Custom Operator. + :ivar friendly_name: A human-readable name of this resource, up to 64 characters. + :ivar description: A human-readable description of this resource, longer than the friendly name. + :ivar author: The creator of the Custom Operator. Custom Operators can only be created by a Twilio Account. + :ivar operator_type: Operator Type for this Operator. References an existing Operator Type resource. + :ivar version: Numeric Custom Operator version. Incremented with each update on the resource, used to ensure integrity when updating the Custom Operator. + :ivar availability: + :ivar config: Operator configuration, following the schema defined by the Operator Type. Only available on Operators created by the Account. + :ivar date_created: The date that this Custom Operator was created, given in ISO 8601 format. + :ivar date_updated: The date that this Custom Operator was updated, given in ISO 8601 format. + :ivar url: The URL of this resource. + """ + + def __init__( + self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None + ): + super().__init__(version) + + self.account_sid: Optional[str] = payload.get("account_sid") + self.sid: Optional[str] = payload.get("sid") + self.friendly_name: Optional[str] = payload.get("friendly_name") + self.description: Optional[str] = payload.get("description") + self.author: Optional[str] = payload.get("author") + self.operator_type: Optional[str] = payload.get("operator_type") + self.version: Optional[int] = deserialize.integer(payload.get("version")) + self.availability: Optional["CustomOperatorInstance.Availability"] = ( + payload.get("availability") + ) + self.config: Optional[Dict[str, object]] = payload.get("config") + 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 = { + "sid": sid or self.sid, + } + self._context: Optional[CustomOperatorContext] = None + + @property + def _proxy(self) -> "CustomOperatorContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: CustomOperatorContext for this CustomOperatorInstance + """ + if self._context is None: + self._context = CustomOperatorContext( + self._version, + sid=self._solution["sid"], + ) + return self._context + + def delete(self) -> bool: + """ + Deletes the CustomOperatorInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._proxy.delete() + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the CustomOperatorInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._proxy.delete_async() + + def fetch(self) -> "CustomOperatorInstance": + """ + Fetch the CustomOperatorInstance + + + :returns: The fetched CustomOperatorInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "CustomOperatorInstance": + """ + Asynchronous coroutine to fetch the CustomOperatorInstance + + + :returns: The fetched CustomOperatorInstance + """ + return await self._proxy.fetch_async() + + def update( + self, + friendly_name: str, + config: object, + if_match: Union[str, object] = values.unset, + ) -> "CustomOperatorInstance": + """ + Update the CustomOperatorInstance + + :param friendly_name: A human-readable name of this resource, up to 64 characters. + :param config: Operator configuration, following the schema defined by the Operator Type. + :param if_match: The If-Match HTTP request header + + :returns: The updated CustomOperatorInstance + """ + return self._proxy.update( + friendly_name=friendly_name, + config=config, + if_match=if_match, + ) + + async def update_async( + self, + friendly_name: str, + config: object, + if_match: Union[str, object] = values.unset, + ) -> "CustomOperatorInstance": + """ + Asynchronous coroutine to update the CustomOperatorInstance + + :param friendly_name: A human-readable name of this resource, up to 64 characters. + :param config: Operator configuration, following the schema defined by the Operator Type. + :param if_match: The If-Match HTTP request header + + :returns: The updated CustomOperatorInstance + """ + return await self._proxy.update_async( + friendly_name=friendly_name, + config=config, + if_match=if_match, + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class CustomOperatorContext(InstanceContext): + + def __init__(self, version: Version, sid: str): + """ + Initialize the CustomOperatorContext + + :param version: Version that contains the resource + :param sid: A 34 character string that uniquely identifies this Custom Operator. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "sid": sid, + } + self._uri = "/Operators/Custom/{sid}".format(**self._solution) + + def delete(self) -> bool: + """ + Deletes the CustomOperatorInstance + + + :returns: True if delete succeeds, False otherwise + """ + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the CustomOperatorInstance + + + :returns: True if delete succeeds, False otherwise + """ + + headers = values.of({}) + + return await self._version.delete_async( + method="DELETE", uri=self._uri, headers=headers + ) + + def fetch(self) -> CustomOperatorInstance: + """ + Fetch the CustomOperatorInstance + + + :returns: The fetched CustomOperatorInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return CustomOperatorInstance( + self._version, + payload, + sid=self._solution["sid"], + ) + + async def fetch_async(self) -> CustomOperatorInstance: + """ + Asynchronous coroutine to fetch the CustomOperatorInstance + + + :returns: The fetched CustomOperatorInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + return CustomOperatorInstance( + self._version, + payload, + sid=self._solution["sid"], + ) + + def update( + self, + friendly_name: str, + config: object, + if_match: Union[str, object] = values.unset, + ) -> CustomOperatorInstance: + """ + Update the CustomOperatorInstance + + :param friendly_name: A human-readable name of this resource, up to 64 characters. + :param config: Operator configuration, following the schema defined by the Operator Type. + :param if_match: The If-Match HTTP request header + + :returns: The updated CustomOperatorInstance + """ + + data = values.of( + { + "FriendlyName": friendly_name, + "Config": serialize.object(config), + } + ) + headers = values.of({}) + + if not ( + if_match is values.unset or (isinstance(if_match, str) and not if_match) + ): + headers["If-Match"] = if_match + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = self._version.update( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return CustomOperatorInstance(self._version, payload, sid=self._solution["sid"]) + + async def update_async( + self, + friendly_name: str, + config: object, + if_match: Union[str, object] = values.unset, + ) -> CustomOperatorInstance: + """ + Asynchronous coroutine to update the CustomOperatorInstance + + :param friendly_name: A human-readable name of this resource, up to 64 characters. + :param config: Operator configuration, following the schema defined by the Operator Type. + :param if_match: The If-Match HTTP request header + + :returns: The updated CustomOperatorInstance + """ + + data = values.of( + { + "FriendlyName": friendly_name, + "Config": serialize.object(config), + } + ) + headers = values.of({}) + + if not ( + if_match is values.unset or (isinstance(if_match, str) and not if_match) + ): + headers["If-Match"] = if_match + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = await self._version.update_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return CustomOperatorInstance(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 CustomOperatorPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> CustomOperatorInstance: + """ + Build an instance of CustomOperatorInstance + + :param payload: Payload response from the API + """ + return CustomOperatorInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class CustomOperatorList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the CustomOperatorList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/Operators/Custom" + + def create( + self, friendly_name: str, operator_type: str, config: object + ) -> CustomOperatorInstance: + """ + Create the CustomOperatorInstance + + :param friendly_name: A human readable description of the new Operator, up to 64 characters. + :param operator_type: Operator Type for this Operator. References an existing Operator Type resource. + :param config: Operator configuration, following the schema defined by the Operator Type. + + :returns: The created CustomOperatorInstance + """ + + data = values.of( + { + "FriendlyName": friendly_name, + "OperatorType": operator_type, + "Config": serialize.object(config), + } + ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = self._version.create( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return CustomOperatorInstance(self._version, payload) + + async def create_async( + self, friendly_name: str, operator_type: str, config: object + ) -> CustomOperatorInstance: + """ + Asynchronously create the CustomOperatorInstance + + :param friendly_name: A human readable description of the new Operator, up to 64 characters. + :param operator_type: Operator Type for this Operator. References an existing Operator Type resource. + :param config: Operator configuration, following the schema defined by the Operator Type. + + :returns: The created CustomOperatorInstance + """ + + data = values.of( + { + "FriendlyName": friendly_name, + "OperatorType": operator_type, + "Config": serialize.object(config), + } + ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return CustomOperatorInstance(self._version, payload) + + def stream( + self, + availability: Union[ + "CustomOperatorInstance.Availability", object + ] = values.unset, + language_code: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[CustomOperatorInstance]: + """ + Streams CustomOperatorInstance 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 "CustomOperatorInstance.Availability" availability: Returns Custom Operators with the provided availability type. Possible values: internal, beta, public, retired. + :param str language_code: Returns Custom Operators that support the provided language code. + :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( + availability=availability, + language_code=language_code, + page_size=limits["page_size"], + ) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + availability: Union[ + "CustomOperatorInstance.Availability", object + ] = values.unset, + language_code: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[CustomOperatorInstance]: + """ + Asynchronously streams CustomOperatorInstance 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 "CustomOperatorInstance.Availability" availability: Returns Custom Operators with the provided availability type. Possible values: internal, beta, public, retired. + :param str language_code: Returns Custom Operators that support the provided language code. + :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( + availability=availability, + language_code=language_code, + page_size=limits["page_size"], + ) + + return self._version.stream_async(page, limits["limit"]) + + def list( + self, + availability: Union[ + "CustomOperatorInstance.Availability", object + ] = values.unset, + language_code: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[CustomOperatorInstance]: + """ + Lists CustomOperatorInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param "CustomOperatorInstance.Availability" availability: Returns Custom Operators with the provided availability type. Possible values: internal, beta, public, retired. + :param str language_code: Returns Custom Operators that support the provided language code. + :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( + availability=availability, + language_code=language_code, + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + availability: Union[ + "CustomOperatorInstance.Availability", object + ] = values.unset, + language_code: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[CustomOperatorInstance]: + """ + Asynchronously lists CustomOperatorInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param "CustomOperatorInstance.Availability" availability: Returns Custom Operators with the provided availability type. Possible values: internal, beta, public, retired. + :param str language_code: Returns Custom Operators that support the provided language code. + :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( + availability=availability, + language_code=language_code, + limit=limit, + page_size=page_size, + ) + ] + + def page( + self, + availability: Union[ + "CustomOperatorInstance.Availability", object + ] = values.unset, + language_code: 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, + ) -> CustomOperatorPage: + """ + Retrieve a single page of CustomOperatorInstance records from the API. + Request is executed immediately + + :param availability: Returns Custom Operators with the provided availability type. Possible values: internal, beta, public, retired. + :param language_code: Returns Custom Operators that support the provided language code. + :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 CustomOperatorInstance + """ + data = values.of( + { + "Availability": availability, + "LanguageCode": language_code, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return CustomOperatorPage(self._version, response) + + async def page_async( + self, + availability: Union[ + "CustomOperatorInstance.Availability", object + ] = values.unset, + language_code: 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, + ) -> CustomOperatorPage: + """ + Asynchronously retrieve a single page of CustomOperatorInstance records from the API. + Request is executed immediately + + :param availability: Returns Custom Operators with the provided availability type. Possible values: internal, beta, public, retired. + :param language_code: Returns Custom Operators that support the provided language code. + :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 CustomOperatorInstance + """ + data = values.of( + { + "Availability": availability, + "LanguageCode": language_code, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + return CustomOperatorPage(self._version, response) + + def get_page(self, target_url: str) -> CustomOperatorPage: + """ + Retrieve a specific page of CustomOperatorInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of CustomOperatorInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return CustomOperatorPage(self._version, response) + + async def get_page_async(self, target_url: str) -> CustomOperatorPage: + """ + Asynchronously retrieve a specific page of CustomOperatorInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of CustomOperatorInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return CustomOperatorPage(self._version, response) + + def get(self, sid: str) -> CustomOperatorContext: + """ + Constructs a CustomOperatorContext + + :param sid: A 34 character string that uniquely identifies this Custom Operator. + """ + return CustomOperatorContext(self._version, sid=sid) + + def __call__(self, sid: str) -> CustomOperatorContext: + """ + Constructs a CustomOperatorContext + + :param sid: A 34 character string that uniquely identifies this Custom Operator. + """ + return CustomOperatorContext(self._version, sid=sid) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/intelligence/v2/operator.py b/twilio/rest/intelligence/v2/operator.py new file mode 100644 index 0000000000..984c46d724 --- /dev/null +++ b/twilio/rest/intelligence/v2/operator.py @@ -0,0 +1,476 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Intelligence + 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 OperatorInstance(InstanceResource): + + class Availability(object): + INTERNAL = "internal" + BETA = "beta" + PUBLIC = "public" + RETIRED = "retired" + + """ + :ivar account_sid: The unique SID identifier of the Account the Operator belongs to. + :ivar sid: A 34 character string that uniquely identifies this Operator. + :ivar friendly_name: A human-readable name of this resource, up to 64 characters. + :ivar description: A human-readable description of this resource, longer than the friendly name. + :ivar author: The creator of the Operator. Either Twilio or the creating Account. + :ivar operator_type: Operator Type for this Operator. References an existing Operator Type resource. + :ivar version: Numeric Operator version. Incremented with each update on the resource, used to ensure integrity when updating the Operator. + :ivar availability: + :ivar config: Operator configuration, following the schema defined by the Operator Type. Only available on Custom Operators created by the Account. + :ivar date_created: The date that this Operator was created, given in ISO 8601 format. + :ivar date_updated: The date that this Operator was updated, given in ISO 8601 format. + :ivar url: The URL of this resource. + """ + + def __init__( + self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None + ): + super().__init__(version) + + self.account_sid: Optional[str] = payload.get("account_sid") + self.sid: Optional[str] = payload.get("sid") + self.friendly_name: Optional[str] = payload.get("friendly_name") + self.description: Optional[str] = payload.get("description") + self.author: Optional[str] = payload.get("author") + self.operator_type: Optional[str] = payload.get("operator_type") + self.version: Optional[int] = deserialize.integer(payload.get("version")) + self.availability: Optional["OperatorInstance.Availability"] = payload.get( + "availability" + ) + self.config: Optional[Dict[str, object]] = payload.get("config") + 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 = { + "sid": sid or self.sid, + } + self._context: Optional[OperatorContext] = None + + @property + def _proxy(self) -> "OperatorContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: OperatorContext for this OperatorInstance + """ + if self._context is None: + self._context = OperatorContext( + self._version, + sid=self._solution["sid"], + ) + return self._context + + def fetch(self) -> "OperatorInstance": + """ + Fetch the OperatorInstance + + + :returns: The fetched OperatorInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "OperatorInstance": + """ + Asynchronous coroutine to fetch the OperatorInstance + + + :returns: The fetched OperatorInstance + """ + 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 OperatorContext(InstanceContext): + + def __init__(self, version: Version, sid: str): + """ + Initialize the OperatorContext + + :param version: Version that contains the resource + :param sid: A 34 character string that uniquely identifies this Operator. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "sid": sid, + } + self._uri = "/Operators/{sid}".format(**self._solution) + + def fetch(self) -> OperatorInstance: + """ + Fetch the OperatorInstance + + + :returns: The fetched OperatorInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return OperatorInstance( + self._version, + payload, + sid=self._solution["sid"], + ) + + async def fetch_async(self) -> OperatorInstance: + """ + Asynchronous coroutine to fetch the OperatorInstance + + + :returns: The fetched OperatorInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + return OperatorInstance( + 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 OperatorPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> OperatorInstance: + """ + Build an instance of OperatorInstance + + :param payload: Payload response from the API + """ + return OperatorInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class OperatorList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the OperatorList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/Operators" + + def stream( + self, + availability: Union["OperatorInstance.Availability", object] = values.unset, + language_code: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[OperatorInstance]: + """ + Streams OperatorInstance 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 "OperatorInstance.Availability" availability: Returns Operators with the provided availability type. Possible values: internal, beta, public, retired. + :param str language_code: Returns Operators that support the provided language code. + :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( + availability=availability, + language_code=language_code, + page_size=limits["page_size"], + ) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + availability: Union["OperatorInstance.Availability", object] = values.unset, + language_code: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[OperatorInstance]: + """ + Asynchronously streams OperatorInstance 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 "OperatorInstance.Availability" availability: Returns Operators with the provided availability type. Possible values: internal, beta, public, retired. + :param str language_code: Returns Operators that support the provided language code. + :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( + availability=availability, + language_code=language_code, + page_size=limits["page_size"], + ) + + return self._version.stream_async(page, limits["limit"]) + + def list( + self, + availability: Union["OperatorInstance.Availability", object] = values.unset, + language_code: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[OperatorInstance]: + """ + Lists OperatorInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param "OperatorInstance.Availability" availability: Returns Operators with the provided availability type. Possible values: internal, beta, public, retired. + :param str language_code: Returns Operators that support the provided language code. + :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( + availability=availability, + language_code=language_code, + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + availability: Union["OperatorInstance.Availability", object] = values.unset, + language_code: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[OperatorInstance]: + """ + Asynchronously lists OperatorInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param "OperatorInstance.Availability" availability: Returns Operators with the provided availability type. Possible values: internal, beta, public, retired. + :param str language_code: Returns Operators that support the provided language code. + :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( + availability=availability, + language_code=language_code, + limit=limit, + page_size=page_size, + ) + ] + + def page( + self, + availability: Union["OperatorInstance.Availability", object] = values.unset, + language_code: 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, + ) -> OperatorPage: + """ + Retrieve a single page of OperatorInstance records from the API. + Request is executed immediately + + :param availability: Returns Operators with the provided availability type. Possible values: internal, beta, public, retired. + :param language_code: Returns Operators that support the provided language code. + :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 OperatorInstance + """ + data = values.of( + { + "Availability": availability, + "LanguageCode": language_code, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return OperatorPage(self._version, response) + + async def page_async( + self, + availability: Union["OperatorInstance.Availability", object] = values.unset, + language_code: 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, + ) -> OperatorPage: + """ + Asynchronously retrieve a single page of OperatorInstance records from the API. + Request is executed immediately + + :param availability: Returns Operators with the provided availability type. Possible values: internal, beta, public, retired. + :param language_code: Returns Operators that support the provided language code. + :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 OperatorInstance + """ + data = values.of( + { + "Availability": availability, + "LanguageCode": language_code, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + return OperatorPage(self._version, response) + + def get_page(self, target_url: str) -> OperatorPage: + """ + Retrieve a specific page of OperatorInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of OperatorInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return OperatorPage(self._version, response) + + async def get_page_async(self, target_url: str) -> OperatorPage: + """ + Asynchronously retrieve a specific page of OperatorInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of OperatorInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return OperatorPage(self._version, response) + + def get(self, sid: str) -> OperatorContext: + """ + Constructs a OperatorContext + + :param sid: A 34 character string that uniquely identifies this Operator. + """ + return OperatorContext(self._version, sid=sid) + + def __call__(self, sid: str) -> OperatorContext: + """ + Constructs a OperatorContext + + :param sid: A 34 character string that uniquely identifies this Operator. + """ + return OperatorContext(self._version, sid=sid) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/intelligence/v2/operator_attachment.py b/twilio/rest/intelligence/v2/operator_attachment.py new file mode 100644 index 0000000000..6080bc5ebf --- /dev/null +++ b/twilio/rest/intelligence/v2/operator_attachment.py @@ -0,0 +1,247 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Intelligence + 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 OperatorAttachmentInstance(InstanceResource): + """ + :ivar service_sid: The unique SID identifier of the Service. + :ivar operator_sid: The unique SID identifier of the Operator. + :ivar url: The URL of this resource. + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + service_sid: Optional[str] = None, + operator_sid: Optional[str] = None, + ): + super().__init__(version) + + self.service_sid: Optional[str] = payload.get("service_sid") + self.operator_sid: Optional[str] = payload.get("operator_sid") + self.url: Optional[str] = payload.get("url") + + self._solution = { + "service_sid": service_sid or self.service_sid, + "operator_sid": operator_sid or self.operator_sid, + } + self._context: Optional[OperatorAttachmentContext] = None + + @property + def _proxy(self) -> "OperatorAttachmentContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: OperatorAttachmentContext for this OperatorAttachmentInstance + """ + if self._context is None: + self._context = OperatorAttachmentContext( + self._version, + service_sid=self._solution["service_sid"], + operator_sid=self._solution["operator_sid"], + ) + return self._context + + def create(self) -> "OperatorAttachmentInstance": + """ + Create the OperatorAttachmentInstance + + + :returns: The created OperatorAttachmentInstance + """ + return self._proxy.create() + + async def create_async(self) -> "OperatorAttachmentInstance": + """ + Asynchronous coroutine to create the OperatorAttachmentInstance + + + :returns: The created OperatorAttachmentInstance + """ + return await self._proxy.create_async() + + def delete(self) -> bool: + """ + Deletes the OperatorAttachmentInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._proxy.delete() + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the OperatorAttachmentInstance + + + :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 OperatorAttachmentContext(InstanceContext): + + def __init__(self, version: Version, service_sid: str, operator_sid: str): + """ + Initialize the OperatorAttachmentContext + + :param version: Version that contains the resource + :param service_sid: The unique SID identifier of the Service. + :param operator_sid: The unique SID identifier of the Operator. Allows both Custom and Pre-built Operators. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "service_sid": service_sid, + "operator_sid": operator_sid, + } + self._uri = "/Services/{service_sid}/Operators/{operator_sid}".format( + **self._solution + ) + + def create(self) -> OperatorAttachmentInstance: + """ + Create the OperatorAttachmentInstance + + + :returns: The created OperatorAttachmentInstance + """ + data = values.of({}) + + payload = self._version.create(method="POST", uri=self._uri, data=data) + + return OperatorAttachmentInstance( + self._version, + payload, + service_sid=self._solution["service_sid"], + operator_sid=self._solution["operator_sid"], + ) + + async def create_async(self) -> OperatorAttachmentInstance: + """ + Asynchronous coroutine to create the OperatorAttachmentInstance + + + :returns: The created OperatorAttachmentInstance + """ + data = values.of({}) + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data + ) + + return OperatorAttachmentInstance( + self._version, + payload, + service_sid=self._solution["service_sid"], + operator_sid=self._solution["operator_sid"], + ) + + def delete(self) -> bool: + """ + Deletes the OperatorAttachmentInstance + + + :returns: True if delete succeeds, False otherwise + """ + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the OperatorAttachmentInstance + + + :returns: True if delete succeeds, False otherwise + """ + + headers = values.of({}) + + return await self._version.delete_async( + method="DELETE", uri=self._uri, headers=headers + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class OperatorAttachmentList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the OperatorAttachmentList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + def get(self, service_sid: str, operator_sid: str) -> OperatorAttachmentContext: + """ + Constructs a OperatorAttachmentContext + + :param service_sid: The unique SID identifier of the Service. + :param operator_sid: The unique SID identifier of the Operator. Allows both Custom and Pre-built Operators. + """ + return OperatorAttachmentContext( + self._version, service_sid=service_sid, operator_sid=operator_sid + ) + + def __call__( + self, service_sid: str, operator_sid: str + ) -> OperatorAttachmentContext: + """ + Constructs a OperatorAttachmentContext + + :param service_sid: The unique SID identifier of the Service. + :param operator_sid: The unique SID identifier of the Operator. Allows both Custom and Pre-built Operators. + """ + return OperatorAttachmentContext( + self._version, service_sid=service_sid, operator_sid=operator_sid + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/intelligence/v2/operator_attachments.py b/twilio/rest/intelligence/v2/operator_attachments.py new file mode 100644 index 0000000000..19a875f76b --- /dev/null +++ b/twilio/rest/intelligence/v2/operator_attachments.py @@ -0,0 +1,192 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Intelligence + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from typing import Any, Dict, List, Optional +from twilio.base import values +from twilio.base.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 OperatorAttachmentsInstance(InstanceResource): + """ + :ivar service_sid: The unique SID identifier of the Service. + :ivar operator_sids: List of Operator SIDs attached to the service. Includes both Custom and Pre-built Operators. + :ivar url: The URL of this resource. + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + service_sid: Optional[str] = None, + ): + super().__init__(version) + + self.service_sid: Optional[str] = payload.get("service_sid") + self.operator_sids: Optional[List[str]] = payload.get("operator_sids") + self.url: Optional[str] = payload.get("url") + + self._solution = { + "service_sid": service_sid or self.service_sid, + } + self._context: Optional[OperatorAttachmentsContext] = None + + @property + def _proxy(self) -> "OperatorAttachmentsContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: OperatorAttachmentsContext for this OperatorAttachmentsInstance + """ + if self._context is None: + self._context = OperatorAttachmentsContext( + self._version, + service_sid=self._solution["service_sid"], + ) + return self._context + + def fetch(self) -> "OperatorAttachmentsInstance": + """ + Fetch the OperatorAttachmentsInstance + + + :returns: The fetched OperatorAttachmentsInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "OperatorAttachmentsInstance": + """ + Asynchronous coroutine to fetch the OperatorAttachmentsInstance + + + :returns: The fetched OperatorAttachmentsInstance + """ + 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 OperatorAttachmentsContext(InstanceContext): + + def __init__(self, version: Version, service_sid: str): + """ + Initialize the OperatorAttachmentsContext + + :param version: Version that contains the resource + :param service_sid: The unique SID identifier of the Service. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "service_sid": service_sid, + } + self._uri = "/Services/{service_sid}/Operators".format(**self._solution) + + def fetch(self) -> OperatorAttachmentsInstance: + """ + Fetch the OperatorAttachmentsInstance + + + :returns: The fetched OperatorAttachmentsInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return OperatorAttachmentsInstance( + self._version, + payload, + service_sid=self._solution["service_sid"], + ) + + async def fetch_async(self) -> OperatorAttachmentsInstance: + """ + Asynchronous coroutine to fetch the OperatorAttachmentsInstance + + + :returns: The fetched OperatorAttachmentsInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + return OperatorAttachmentsInstance( + self._version, + payload, + service_sid=self._solution["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 OperatorAttachmentsList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the OperatorAttachmentsList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + def get(self, service_sid: str) -> OperatorAttachmentsContext: + """ + Constructs a OperatorAttachmentsContext + + :param service_sid: The unique SID identifier of the Service. + """ + return OperatorAttachmentsContext(self._version, service_sid=service_sid) + + def __call__(self, service_sid: str) -> OperatorAttachmentsContext: + """ + Constructs a OperatorAttachmentsContext + + :param service_sid: The unique SID identifier of the Service. + """ + return OperatorAttachmentsContext(self._version, service_sid=service_sid) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/intelligence/v2/operator_type.py b/twilio/rest/intelligence/v2/operator_type.py new file mode 100644 index 0000000000..b14e677ad2 --- /dev/null +++ b/twilio/rest/intelligence/v2/operator_type.py @@ -0,0 +1,458 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Intelligence + 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 OperatorTypeInstance(InstanceResource): + + class Availability(object): + INTERNAL = "internal" + BETA = "beta" + GENERAL_AVAILABILITY = "general-availability" + RETIRED = "retired" + DEPRECATED = "deprecated" + + class OutputType(object): + TEXT_CLASSIFICATION = "text-classification" + TEXT_EXTRACTION = "text-extraction" + TEXT_EXTRACTION_NORMALIZED = "text-extraction-normalized" + TEXT_GENERATION = "text-generation" + + class Provider(object): + TWILIO = "twilio" + AMAZON = "amazon" + OPENAI = "openai" + + """ + :ivar name: A unique name that references an Operator's Operator Type. + :ivar sid: A 34 character string that uniquely identifies this Operator Type. + :ivar friendly_name: A human-readable name of this resource, up to 64 characters. + :ivar description: A human-readable description of this resource, longer than the friendly name. + :ivar docs_link: Additional documentation for the Operator Type. + :ivar output_type: + :ivar supported_languages: List of languages this Operator Type supports. + :ivar provider: + :ivar availability: + :ivar configurable: Operators can be created from configurable Operator Types. + :ivar config_schema: JSON Schema for configuring an Operator with this Operator Type. Following https://json-schema.org/ + :ivar date_created: The date that this Operator Type was created, given in ISO 8601 format. + :ivar date_updated: The date that this Operator Type was updated, given in ISO 8601 format. + :ivar url: The URL of this resource. + """ + + def __init__( + self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None + ): + super().__init__(version) + + self.name: Optional[str] = payload.get("name") + self.sid: Optional[str] = payload.get("sid") + self.friendly_name: Optional[str] = payload.get("friendly_name") + self.description: Optional[str] = payload.get("description") + self.docs_link: Optional[str] = payload.get("docs_link") + self.output_type: Optional["OperatorTypeInstance.OutputType"] = payload.get( + "output_type" + ) + self.supported_languages: Optional[List[str]] = payload.get( + "supported_languages" + ) + self.provider: Optional["OperatorTypeInstance.Provider"] = payload.get( + "provider" + ) + self.availability: Optional["OperatorTypeInstance.Availability"] = payload.get( + "availability" + ) + self.configurable: Optional[bool] = payload.get("configurable") + self.config_schema: Optional[Dict[str, object]] = payload.get("config_schema") + 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 = { + "sid": sid or self.sid, + } + self._context: Optional[OperatorTypeContext] = None + + @property + def _proxy(self) -> "OperatorTypeContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: OperatorTypeContext for this OperatorTypeInstance + """ + if self._context is None: + self._context = OperatorTypeContext( + self._version, + sid=self._solution["sid"], + ) + return self._context + + def fetch(self) -> "OperatorTypeInstance": + """ + Fetch the OperatorTypeInstance + + + :returns: The fetched OperatorTypeInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "OperatorTypeInstance": + """ + Asynchronous coroutine to fetch the OperatorTypeInstance + + + :returns: The fetched OperatorTypeInstance + """ + 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 OperatorTypeContext(InstanceContext): + + def __init__(self, version: Version, sid: str): + """ + Initialize the OperatorTypeContext + + :param version: Version that contains the resource + :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) + + # Path Solution + self._solution = { + "sid": sid, + } + self._uri = "/OperatorTypes/{sid}".format(**self._solution) + + def fetch(self) -> OperatorTypeInstance: + """ + Fetch the OperatorTypeInstance + + + :returns: The fetched OperatorTypeInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return OperatorTypeInstance( + self._version, + payload, + sid=self._solution["sid"], + ) + + async def fetch_async(self) -> OperatorTypeInstance: + """ + Asynchronous coroutine to fetch the OperatorTypeInstance + + + :returns: The fetched OperatorTypeInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + return OperatorTypeInstance( + 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 OperatorTypePage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> OperatorTypeInstance: + """ + Build an instance of OperatorTypeInstance + + :param payload: Payload response from the API + """ + return OperatorTypeInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class OperatorTypeList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the OperatorTypeList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/OperatorTypes" + + def stream( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[OperatorTypeInstance]: + """ + Streams OperatorTypeInstance 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[OperatorTypeInstance]: + """ + Asynchronously streams OperatorTypeInstance 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[OperatorTypeInstance]: + """ + Lists OperatorTypeInstance 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[OperatorTypeInstance]: + """ + Asynchronously lists OperatorTypeInstance 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, + ) -> OperatorTypePage: + """ + Retrieve a single page of OperatorTypeInstance 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 OperatorTypeInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return OperatorTypePage(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, + ) -> OperatorTypePage: + """ + Asynchronously retrieve a single page of OperatorTypeInstance 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 OperatorTypeInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + return OperatorTypePage(self._version, response) + + def get_page(self, target_url: str) -> OperatorTypePage: + """ + Retrieve a specific page of OperatorTypeInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of OperatorTypeInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return OperatorTypePage(self._version, response) + + async def get_page_async(self, target_url: str) -> OperatorTypePage: + """ + Asynchronously retrieve a specific page of OperatorTypeInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of OperatorTypeInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return OperatorTypePage(self._version, response) + + def get(self, sid: str) -> OperatorTypeContext: + """ + Constructs a OperatorTypeContext + + :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) + + def __call__(self, sid: str) -> OperatorTypeContext: + """ + Constructs a OperatorTypeContext + + :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) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/intelligence/v2/prebuilt_operator.py b/twilio/rest/intelligence/v2/prebuilt_operator.py new file mode 100644 index 0000000000..50693f29c2 --- /dev/null +++ b/twilio/rest/intelligence/v2/prebuilt_operator.py @@ -0,0 +1,488 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Intelligence + 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 PrebuiltOperatorInstance(InstanceResource): + + class Availability(object): + INTERNAL = "internal" + BETA = "beta" + PUBLIC = "public" + RETIRED = "retired" + + """ + :ivar account_sid: The unique SID identifier of the Account the Pre-built Operator belongs to. + :ivar sid: A 34 character string that uniquely identifies this Pre-built Operator. + :ivar friendly_name: A human-readable name of this resource, up to 64 characters. + :ivar description: A human-readable description of this resource, longer than the friendly name. + :ivar author: The creator of the Operator. Pre-built Operators can only be created by Twilio. + :ivar operator_type: Operator Type for this Operator. References an existing Operator Type resource. + :ivar version: Numeric Operator version. Incremented with each update on the resource, used to ensure integrity when updating the Operator. + :ivar availability: + :ivar config: Operator configuration, following the schema defined by the Operator Type. Only available on Custom Operators created by the Account, will be empty for Pre-Built Operators. + :ivar date_created: The date that this Pre-built Operator was created, given in ISO 8601 format. + :ivar date_updated: The date that this Pre-built Operator was updated, given in ISO 8601 format. + :ivar url: The URL of this resource. + """ + + def __init__( + self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None + ): + super().__init__(version) + + self.account_sid: Optional[str] = payload.get("account_sid") + self.sid: Optional[str] = payload.get("sid") + self.friendly_name: Optional[str] = payload.get("friendly_name") + self.description: Optional[str] = payload.get("description") + self.author: Optional[str] = payload.get("author") + self.operator_type: Optional[str] = payload.get("operator_type") + self.version: Optional[int] = deserialize.integer(payload.get("version")) + self.availability: Optional["PrebuiltOperatorInstance.Availability"] = ( + payload.get("availability") + ) + self.config: Optional[Dict[str, object]] = payload.get("config") + 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 = { + "sid": sid or self.sid, + } + self._context: Optional[PrebuiltOperatorContext] = None + + @property + def _proxy(self) -> "PrebuiltOperatorContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: PrebuiltOperatorContext for this PrebuiltOperatorInstance + """ + if self._context is None: + self._context = PrebuiltOperatorContext( + self._version, + sid=self._solution["sid"], + ) + return self._context + + def fetch(self) -> "PrebuiltOperatorInstance": + """ + Fetch the PrebuiltOperatorInstance + + + :returns: The fetched PrebuiltOperatorInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "PrebuiltOperatorInstance": + """ + Asynchronous coroutine to fetch the PrebuiltOperatorInstance + + + :returns: The fetched PrebuiltOperatorInstance + """ + 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 PrebuiltOperatorContext(InstanceContext): + + def __init__(self, version: Version, sid: str): + """ + Initialize the PrebuiltOperatorContext + + :param version: Version that contains the resource + :param sid: A 34 character string that uniquely identifies this Pre-built Operator. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "sid": sid, + } + self._uri = "/Operators/PreBuilt/{sid}".format(**self._solution) + + def fetch(self) -> PrebuiltOperatorInstance: + """ + Fetch the PrebuiltOperatorInstance + + + :returns: The fetched PrebuiltOperatorInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return PrebuiltOperatorInstance( + self._version, + payload, + sid=self._solution["sid"], + ) + + async def fetch_async(self) -> PrebuiltOperatorInstance: + """ + Asynchronous coroutine to fetch the PrebuiltOperatorInstance + + + :returns: The fetched PrebuiltOperatorInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + return PrebuiltOperatorInstance( + 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 PrebuiltOperatorPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> PrebuiltOperatorInstance: + """ + Build an instance of PrebuiltOperatorInstance + + :param payload: Payload response from the API + """ + return PrebuiltOperatorInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class PrebuiltOperatorList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the PrebuiltOperatorList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/Operators/PreBuilt" + + def stream( + self, + availability: Union[ + "PrebuiltOperatorInstance.Availability", object + ] = values.unset, + language_code: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[PrebuiltOperatorInstance]: + """ + Streams PrebuiltOperatorInstance 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 "PrebuiltOperatorInstance.Availability" availability: Returns Pre-built Operators with the provided availability type. Possible values: internal, beta, public, retired. + :param str language_code: Returns Pre-built Operators that support the provided language code. + :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( + availability=availability, + language_code=language_code, + page_size=limits["page_size"], + ) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + availability: Union[ + "PrebuiltOperatorInstance.Availability", object + ] = values.unset, + language_code: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[PrebuiltOperatorInstance]: + """ + Asynchronously streams PrebuiltOperatorInstance 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 "PrebuiltOperatorInstance.Availability" availability: Returns Pre-built Operators with the provided availability type. Possible values: internal, beta, public, retired. + :param str language_code: Returns Pre-built Operators that support the provided language code. + :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( + availability=availability, + language_code=language_code, + page_size=limits["page_size"], + ) + + return self._version.stream_async(page, limits["limit"]) + + def list( + self, + availability: Union[ + "PrebuiltOperatorInstance.Availability", object + ] = values.unset, + language_code: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[PrebuiltOperatorInstance]: + """ + Lists PrebuiltOperatorInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param "PrebuiltOperatorInstance.Availability" availability: Returns Pre-built Operators with the provided availability type. Possible values: internal, beta, public, retired. + :param str language_code: Returns Pre-built Operators that support the provided language code. + :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( + availability=availability, + language_code=language_code, + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + availability: Union[ + "PrebuiltOperatorInstance.Availability", object + ] = values.unset, + language_code: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[PrebuiltOperatorInstance]: + """ + Asynchronously lists PrebuiltOperatorInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param "PrebuiltOperatorInstance.Availability" availability: Returns Pre-built Operators with the provided availability type. Possible values: internal, beta, public, retired. + :param str language_code: Returns Pre-built Operators that support the provided language code. + :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( + availability=availability, + language_code=language_code, + limit=limit, + page_size=page_size, + ) + ] + + def page( + self, + availability: Union[ + "PrebuiltOperatorInstance.Availability", object + ] = values.unset, + language_code: 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, + ) -> PrebuiltOperatorPage: + """ + Retrieve a single page of PrebuiltOperatorInstance records from the API. + Request is executed immediately + + :param availability: Returns Pre-built Operators with the provided availability type. Possible values: internal, beta, public, retired. + :param language_code: Returns Pre-built Operators that support the provided language code. + :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 PrebuiltOperatorInstance + """ + data = values.of( + { + "Availability": availability, + "LanguageCode": language_code, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return PrebuiltOperatorPage(self._version, response) + + async def page_async( + self, + availability: Union[ + "PrebuiltOperatorInstance.Availability", object + ] = values.unset, + language_code: 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, + ) -> PrebuiltOperatorPage: + """ + Asynchronously retrieve a single page of PrebuiltOperatorInstance records from the API. + Request is executed immediately + + :param availability: Returns Pre-built Operators with the provided availability type. Possible values: internal, beta, public, retired. + :param language_code: Returns Pre-built Operators that support the provided language code. + :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 PrebuiltOperatorInstance + """ + data = values.of( + { + "Availability": availability, + "LanguageCode": language_code, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + return PrebuiltOperatorPage(self._version, response) + + def get_page(self, target_url: str) -> PrebuiltOperatorPage: + """ + Retrieve a specific page of PrebuiltOperatorInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of PrebuiltOperatorInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return PrebuiltOperatorPage(self._version, response) + + async def get_page_async(self, target_url: str) -> PrebuiltOperatorPage: + """ + Asynchronously retrieve a specific page of PrebuiltOperatorInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of PrebuiltOperatorInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return PrebuiltOperatorPage(self._version, response) + + def get(self, sid: str) -> PrebuiltOperatorContext: + """ + Constructs a PrebuiltOperatorContext + + :param sid: A 34 character string that uniquely identifies this Pre-built Operator. + """ + return PrebuiltOperatorContext(self._version, sid=sid) + + def __call__(self, sid: str) -> PrebuiltOperatorContext: + """ + Constructs a PrebuiltOperatorContext + + :param sid: A 34 character string that uniquely identifies this Pre-built Operator. + """ + return PrebuiltOperatorContext(self._version, sid=sid) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/intelligence/v2/service.py b/twilio/rest/intelligence/v2/service.py index d983be5b2e..fac3eb8473 100644 --- a/twilio/rest/intelligence/v2/service.py +++ b/twilio/rest/intelligence/v2/service.py @@ -38,12 +38,13 @@ class HttpMethod(object): :ivar date_created: The date that this Service was created, given in ISO 8601 format. :ivar date_updated: The date that this Service was updated, given in ISO 8601 format. :ivar friendly_name: A human readable description of this resource, up to 64 characters. - :ivar language_code: The default language code of the audio. + :ivar language_code: The language code set during Service creation determines the Transcription language for all call recordings processed by that Service. The default is en-US if no language code is set. A Service can only support one language code, and it cannot be updated once it's set. :ivar sid: A 34 character string that uniquely identifies this Service. :ivar unique_name: Provides a unique and addressable name to be assigned to this Service, assigned by the developer, to be optionally used in addition to SID. :ivar url: The URL of this resource. :ivar webhook_url: The URL Twilio will request when executing the Webhook. :ivar webhook_http_method: + :ivar read_only_attached_operator_sids: Operator sids attached to this service, read only :ivar version: The version number of this Service. """ @@ -72,6 +73,9 @@ def __init__( self.webhook_http_method: Optional["ServiceInstance.HttpMethod"] = payload.get( "webhook_http_method" ) + self.read_only_attached_operator_sids: Optional[List[str]] = payload.get( + "read_only_attached_operator_sids" + ) self.version: Optional[int] = deserialize.integer(payload.get("version")) self._solution = { @@ -136,7 +140,6 @@ def update( auto_transcribe: Union[bool, object] = values.unset, data_logging: Union[bool, object] = values.unset, friendly_name: Union[str, object] = values.unset, - language_code: Union[str, object] = values.unset, unique_name: Union[str, object] = values.unset, auto_redaction: Union[bool, object] = values.unset, media_redaction: Union[bool, object] = values.unset, @@ -150,7 +153,6 @@ def update( :param auto_transcribe: Instructs the Speech Recognition service to automatically transcribe all recordings made on the account. :param data_logging: Data logging allows Twilio to improve the quality of the speech recognition & language understanding services through using customer data to refine, fine tune and evaluate machine learning models. Note: Data logging cannot be activated via API, only via www.twilio.com, as it requires additional consent. :param friendly_name: A human readable description of this resource, up to 64 characters. - :param language_code: The default language code of the audio. :param unique_name: Provides a unique and addressable name to be assigned to this Service, assigned by the developer, to be optionally used in addition to SID. :param auto_redaction: Instructs the Speech Recognition service to automatically redact PII from all transcripts made on this service. :param media_redaction: Instructs the Speech Recognition service to automatically redact PII from all transcripts media made on this service. The auto_redaction flag must be enabled, results in error otherwise. @@ -164,7 +166,6 @@ def update( auto_transcribe=auto_transcribe, data_logging=data_logging, friendly_name=friendly_name, - language_code=language_code, unique_name=unique_name, auto_redaction=auto_redaction, media_redaction=media_redaction, @@ -178,7 +179,6 @@ async def update_async( auto_transcribe: Union[bool, object] = values.unset, data_logging: Union[bool, object] = values.unset, friendly_name: Union[str, object] = values.unset, - language_code: Union[str, object] = values.unset, unique_name: Union[str, object] = values.unset, auto_redaction: Union[bool, object] = values.unset, media_redaction: Union[bool, object] = values.unset, @@ -192,7 +192,6 @@ async def update_async( :param auto_transcribe: Instructs the Speech Recognition service to automatically transcribe all recordings made on the account. :param data_logging: Data logging allows Twilio to improve the quality of the speech recognition & language understanding services through using customer data to refine, fine tune and evaluate machine learning models. Note: Data logging cannot be activated via API, only via www.twilio.com, as it requires additional consent. :param friendly_name: A human readable description of this resource, up to 64 characters. - :param language_code: The default language code of the audio. :param unique_name: Provides a unique and addressable name to be assigned to this Service, assigned by the developer, to be optionally used in addition to SID. :param auto_redaction: Instructs the Speech Recognition service to automatically redact PII from all transcripts made on this service. :param media_redaction: Instructs the Speech Recognition service to automatically redact PII from all transcripts media made on this service. The auto_redaction flag must be enabled, results in error otherwise. @@ -206,7 +205,6 @@ async def update_async( auto_transcribe=auto_transcribe, data_logging=data_logging, friendly_name=friendly_name, - language_code=language_code, unique_name=unique_name, auto_redaction=auto_redaction, media_redaction=media_redaction, @@ -248,10 +246,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -260,9 +258,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> ServiceInstance: @@ -273,10 +273,11 @@ def fetch(self) -> ServiceInstance: :returns: The fetched ServiceInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ServiceInstance( self._version, @@ -292,9 +293,12 @@ async def fetch_async(self) -> ServiceInstance: :returns: The fetched ServiceInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ServiceInstance( @@ -309,7 +313,6 @@ def update( auto_transcribe: Union[bool, object] = values.unset, data_logging: Union[bool, object] = values.unset, friendly_name: Union[str, object] = values.unset, - language_code: Union[str, object] = values.unset, unique_name: Union[str, object] = values.unset, auto_redaction: Union[bool, object] = values.unset, media_redaction: Union[bool, object] = values.unset, @@ -323,7 +326,6 @@ def update( :param auto_transcribe: Instructs the Speech Recognition service to automatically transcribe all recordings made on the account. :param data_logging: Data logging allows Twilio to improve the quality of the speech recognition & language understanding services through using customer data to refine, fine tune and evaluate machine learning models. Note: Data logging cannot be activated via API, only via www.twilio.com, as it requires additional consent. :param friendly_name: A human readable description of this resource, up to 64 characters. - :param language_code: The default language code of the audio. :param unique_name: Provides a unique and addressable name to be assigned to this Service, assigned by the developer, to be optionally used in addition to SID. :param auto_redaction: Instructs the Speech Recognition service to automatically redact PII from all transcripts made on this service. :param media_redaction: Instructs the Speech Recognition service to automatically redact PII from all transcripts media made on this service. The auto_redaction flag must be enabled, results in error otherwise. @@ -332,12 +334,12 @@ def update( :returns: The updated ServiceInstance """ + data = values.of( { "AutoTranscribe": serialize.boolean_to_string(auto_transcribe), "DataLogging": serialize.boolean_to_string(data_logging), "FriendlyName": friendly_name, - "LanguageCode": language_code, "UniqueName": unique_name, "AutoRedaction": serialize.boolean_to_string(auto_redaction), "MediaRedaction": serialize.boolean_to_string(media_redaction), @@ -345,11 +347,16 @@ def update( "WebhookHttpMethod": webhook_http_method, } ) - headers = values.of( - { - "If-Match": if_match, - } - ) + headers = values.of({}) + + if not ( + if_match is values.unset or (isinstance(if_match, str) and not if_match) + ): + headers["If-Match"] = if_match + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( method="POST", uri=self._uri, data=data, headers=headers @@ -363,7 +370,6 @@ async def update_async( auto_transcribe: Union[bool, object] = values.unset, data_logging: Union[bool, object] = values.unset, friendly_name: Union[str, object] = values.unset, - language_code: Union[str, object] = values.unset, unique_name: Union[str, object] = values.unset, auto_redaction: Union[bool, object] = values.unset, media_redaction: Union[bool, object] = values.unset, @@ -377,7 +383,6 @@ async def update_async( :param auto_transcribe: Instructs the Speech Recognition service to automatically transcribe all recordings made on the account. :param data_logging: Data logging allows Twilio to improve the quality of the speech recognition & language understanding services through using customer data to refine, fine tune and evaluate machine learning models. Note: Data logging cannot be activated via API, only via www.twilio.com, as it requires additional consent. :param friendly_name: A human readable description of this resource, up to 64 characters. - :param language_code: The default language code of the audio. :param unique_name: Provides a unique and addressable name to be assigned to this Service, assigned by the developer, to be optionally used in addition to SID. :param auto_redaction: Instructs the Speech Recognition service to automatically redact PII from all transcripts made on this service. :param media_redaction: Instructs the Speech Recognition service to automatically redact PII from all transcripts media made on this service. The auto_redaction flag must be enabled, results in error otherwise. @@ -386,12 +391,12 @@ async def update_async( :returns: The updated ServiceInstance """ + data = values.of( { "AutoTranscribe": serialize.boolean_to_string(auto_transcribe), "DataLogging": serialize.boolean_to_string(data_logging), "FriendlyName": friendly_name, - "LanguageCode": language_code, "UniqueName": unique_name, "AutoRedaction": serialize.boolean_to_string(auto_redaction), "MediaRedaction": serialize.boolean_to_string(media_redaction), @@ -399,11 +404,16 @@ async def update_async( "WebhookHttpMethod": webhook_http_method, } ) - headers = values.of( - { - "If-Match": if_match, - } - ) + headers = values.of({}) + + if not ( + if_match is values.unset or (isinstance(if_match, str) and not if_match) + ): + headers["If-Match"] = if_match + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( method="POST", uri=self._uri, data=data, headers=headers @@ -472,7 +482,7 @@ def create( :param auto_transcribe: Instructs the Speech Recognition service to automatically transcribe all recordings made on the account. :param data_logging: Data logging allows Twilio to improve the quality of the speech recognition & language understanding services through using customer data to refine, fine tune and evaluate machine learning models. Note: Data logging cannot be activated via API, only via www.twilio.com, as it requires additional consent. :param friendly_name: A human readable description of this resource, up to 64 characters. - :param language_code: The default language code of the audio. + :param language_code: The language code set during Service creation determines the Transcription language for all call recordings processed by that Service. The default is en-US if no language code is set. A Service can only support one language code, and it cannot be updated once it's set. :param auto_redaction: Instructs the Speech Recognition service to automatically redact PII from all transcripts made on this service. :param media_redaction: Instructs the Speech Recognition service to automatically redact PII from all transcripts media made on this service. The auto_redaction flag must be enabled, results in error otherwise. :param webhook_url: The URL Twilio will request when executing the Webhook. @@ -494,11 +504,14 @@ def create( "WebhookHttpMethod": webhook_http_method, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload) @@ -522,7 +535,7 @@ async def create_async( :param auto_transcribe: Instructs the Speech Recognition service to automatically transcribe all recordings made on the account. :param data_logging: Data logging allows Twilio to improve the quality of the speech recognition & language understanding services through using customer data to refine, fine tune and evaluate machine learning models. Note: Data logging cannot be activated via API, only via www.twilio.com, as it requires additional consent. :param friendly_name: A human readable description of this resource, up to 64 characters. - :param language_code: The default language code of the audio. + :param language_code: The language code set during Service creation determines the Transcription language for all call recordings processed by that Service. The default is en-US if no language code is set. A Service can only support one language code, and it cannot be updated once it's set. :param auto_redaction: Instructs the Speech Recognition service to automatically redact PII from all transcripts made on this service. :param media_redaction: Instructs the Speech Recognition service to automatically redact PII from all transcripts media made on this service. The auto_redaction flag must be enabled, results in error otherwise. :param webhook_url: The URL Twilio will request when executing the Webhook. @@ -544,11 +557,14 @@ async def create_async( "WebhookHttpMethod": webhook_http_method, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload) @@ -680,7 +696,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ServicePage(self._version, response) async def page_async( @@ -707,8 +729,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ServicePage(self._version, response) diff --git a/twilio/rest/intelligence/v2/transcript/__init__.py b/twilio/rest/intelligence/v2/transcript/__init__.py index 30b97f89bd..c2141bb5da 100644 --- a/twilio/rest/intelligence/v2/transcript/__init__.py +++ b/twilio/rest/intelligence/v2/transcript/__init__.py @@ -194,10 +194,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -206,9 +206,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> TranscriptInstance: @@ -219,10 +221,11 @@ def fetch(self) -> TranscriptInstance: :returns: The fetched TranscriptInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return TranscriptInstance( self._version, @@ -238,9 +241,12 @@ async def fetch_async(self) -> TranscriptInstance: :returns: The fetched TranscriptInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return TranscriptInstance( @@ -353,11 +359,14 @@ def create( "MediaStartTime": serialize.iso8601_datetime(media_start_time), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TranscriptInstance(self._version, payload) @@ -388,11 +397,14 @@ async def create_async( "MediaStartTime": serialize.iso8601_datetime(media_start_time), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TranscriptInstance(self._version, payload) @@ -648,7 +660,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return TranscriptPage(self._version, response) async def page_async( @@ -699,8 +717,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return TranscriptPage(self._version, response) diff --git a/twilio/rest/intelligence/v2/transcript/media.py b/twilio/rest/intelligence/v2/transcript/media.py index 74d3ab9959..76bc448e9b 100644 --- a/twilio/rest/intelligence/v2/transcript/media.py +++ b/twilio/rest/intelligence/v2/transcript/media.py @@ -126,7 +126,13 @@ def fetch(self, redacted: Union[bool, object] = values.unset) -> MediaInstance: } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=data) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) return MediaInstance( self._version, @@ -151,8 +157,12 @@ async def fetch_async( } ) + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return MediaInstance( diff --git a/twilio/rest/intelligence/v2/transcript/operator_result.py b/twilio/rest/intelligence/v2/transcript/operator_result.py index 9d1d614f4d..9ba2c57f62 100644 --- a/twilio/rest/intelligence/v2/transcript/operator_result.py +++ b/twilio/rest/intelligence/v2/transcript/operator_result.py @@ -29,6 +29,8 @@ class OperatorType(object): EXTRACT = "extract" EXTRACT_NORMALIZE = "extract_normalize" PII_EXTRACT = "pii_extract" + TEXT_GENERATION = "text_generation" + JSON = "json" """ :ivar operator_type: @@ -44,6 +46,7 @@ class OperatorType(object): :ivar label_probabilities: The labels probabilities. This might be available on conversation classify model outputs. :ivar extract_results: List of text extraction results. This might be available on classify-extract model outputs. :ivar text_generation_results: Output of a text generation operator for example Conversation Sumamary. + :ivar json_results: :ivar transcript_sid: A 34 character string that uniquely identifies this Transcript. :ivar url: The URL of this resource. """ @@ -84,6 +87,7 @@ def __init__( self.text_generation_results: Optional[Dict[str, object]] = payload.get( "text_generation_results" ) + self.json_results: Optional[Dict[str, object]] = payload.get("json_results") self.transcript_sid: Optional[str] = payload.get("transcript_sid") self.url: Optional[str] = payload.get("url") @@ -187,7 +191,13 @@ def fetch( } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=data) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) return OperatorResultInstance( self._version, @@ -213,8 +223,12 @@ async def fetch_async( } ) + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return OperatorResultInstance( @@ -415,7 +429,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return OperatorResultPage(self._version, response, self._solution) async def page_async( @@ -445,8 +465,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return OperatorResultPage(self._version, response, self._solution) diff --git a/twilio/rest/intelligence/v2/transcript/sentence.py b/twilio/rest/intelligence/v2/transcript/sentence.py index 5bdd18b00f..f4fb0b3b92 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,18 +260,26 @@ 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, } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return SentencePage(self._version, response, self._solution) 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 +289,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,14 +299,19 @@ 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, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return SentencePage(self._version, response, self._solution) diff --git a/twilio/rest/ip_messaging/v1/credential.py b/twilio/rest/ip_messaging/v1/credential.py index eac8e38cf5..4aa6d3fc63 100644 --- a/twilio/rest/ip_messaging/v1/credential.py +++ b/twilio/rest/ip_messaging/v1/credential.py @@ -208,10 +208,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -220,9 +220,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> CredentialInstance: @@ -233,10 +235,11 @@ def fetch(self) -> CredentialInstance: :returns: The fetched CredentialInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return CredentialInstance( self._version, @@ -252,9 +255,12 @@ async def fetch_async(self) -> CredentialInstance: :returns: The fetched CredentialInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return CredentialInstance( @@ -284,6 +290,7 @@ def update( :returns: The updated CredentialInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -294,11 +301,14 @@ def update( "Secret": secret, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CredentialInstance(self._version, payload, sid=self._solution["sid"]) @@ -324,6 +334,7 @@ async def update_async( :returns: The updated CredentialInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -334,11 +345,14 @@ async def update_async( "Secret": secret, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CredentialInstance(self._version, payload, sid=self._solution["sid"]) @@ -420,11 +434,14 @@ def create( "Secret": secret, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CredentialInstance(self._version, payload) @@ -464,11 +481,14 @@ async def create_async( "Secret": secret, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CredentialInstance(self._version, payload) @@ -600,7 +620,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return CredentialPage(self._version, response) async def page_async( @@ -627,8 +653,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return CredentialPage(self._version, response) diff --git a/twilio/rest/ip_messaging/v1/service/__init__.py b/twilio/rest/ip_messaging/v1/service/__init__.py index ad4f002513..3a77cf765e 100644 --- a/twilio/rest/ip_messaging/v1/service/__init__.py +++ b/twilio/rest/ip_messaging/v1/service/__init__.py @@ -554,10 +554,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -566,9 +566,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> ServiceInstance: @@ -579,10 +581,11 @@ def fetch(self) -> ServiceInstance: :returns: The fetched ServiceInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ServiceInstance( self._version, @@ -598,9 +601,12 @@ async def fetch_async(self) -> ServiceInstance: :returns: The fetched ServiceInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ServiceInstance( @@ -726,6 +732,7 @@ def update( :returns: The updated ServiceInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -794,11 +801,14 @@ def update( "Limits.UserChannels": limits_user_channels, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload, sid=self._solution["sid"]) @@ -920,6 +930,7 @@ async def update_async( :returns: The updated ServiceInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -988,11 +999,14 @@ async def update_async( "Limits.UserChannels": limits_user_channels, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload, sid=self._solution["sid"]) @@ -1089,11 +1103,14 @@ def create(self, friendly_name: str) -> ServiceInstance: "FriendlyName": friendly_name, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload) @@ -1112,11 +1129,14 @@ async def create_async(self, friendly_name: str) -> ServiceInstance: "FriendlyName": friendly_name, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload) @@ -1248,7 +1268,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ServicePage(self._version, response) async def page_async( @@ -1275,8 +1301,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ServicePage(self._version, response) diff --git a/twilio/rest/ip_messaging/v1/service/channel/__init__.py b/twilio/rest/ip_messaging/v1/service/channel/__init__.py index ef469e97f2..14423c9e38 100644 --- a/twilio/rest/ip_messaging/v1/service/channel/__init__.py +++ b/twilio/rest/ip_messaging/v1/service/channel/__init__.py @@ -241,10 +241,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -253,9 +253,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> ChannelInstance: @@ -266,10 +268,11 @@ def fetch(self) -> ChannelInstance: :returns: The fetched ChannelInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ChannelInstance( self._version, @@ -286,9 +289,12 @@ async def fetch_async(self) -> ChannelInstance: :returns: The fetched ChannelInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ChannelInstance( @@ -313,6 +319,7 @@ def update( :returns: The updated ChannelInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -320,11 +327,14 @@ def update( "Attributes": attributes, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ChannelInstance( @@ -349,6 +359,7 @@ async def update_async( :returns: The updated ChannelInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -356,11 +367,14 @@ async def update_async( "Attributes": attributes, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ChannelInstance( @@ -484,11 +498,14 @@ def create( "Type": type, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ChannelInstance( @@ -521,11 +538,14 @@ async def create_async( "Type": type, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ChannelInstance( @@ -672,7 +692,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ChannelPage(self._version, response, self._solution) async def page_async( @@ -702,8 +728,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ChannelPage(self._version, response, self._solution) diff --git a/twilio/rest/ip_messaging/v1/service/channel/invite.py b/twilio/rest/ip_messaging/v1/service/channel/invite.py index 7078058a40..d348540346 100644 --- a/twilio/rest/ip_messaging/v1/service/channel/invite.py +++ b/twilio/rest/ip_messaging/v1/service/channel/invite.py @@ -163,10 +163,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -175,9 +175,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> InviteInstance: @@ -188,10 +190,11 @@ def fetch(self) -> InviteInstance: :returns: The fetched InviteInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return InviteInstance( self._version, @@ -209,9 +212,12 @@ async def fetch_async(self) -> InviteInstance: :returns: The fetched InviteInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return InviteInstance( @@ -296,11 +302,14 @@ def create( "RoleSid": role_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return InviteInstance( @@ -328,11 +337,14 @@ async def create_async( "RoleSid": role_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return InviteInstance( @@ -482,7 +494,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return InvitePage(self._version, response, self._solution) async def page_async( @@ -512,8 +530,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return InvitePage(self._version, response, self._solution) diff --git a/twilio/rest/ip_messaging/v1/service/channel/member.py b/twilio/rest/ip_messaging/v1/service/channel/member.py index c52fde5a8e..26a68650ef 100644 --- a/twilio/rest/ip_messaging/v1/service/channel/member.py +++ b/twilio/rest/ip_messaging/v1/service/channel/member.py @@ -205,10 +205,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -217,9 +217,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> MemberInstance: @@ -230,10 +232,11 @@ def fetch(self) -> MemberInstance: :returns: The fetched MemberInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return MemberInstance( self._version, @@ -251,9 +254,12 @@ async def fetch_async(self) -> MemberInstance: :returns: The fetched MemberInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return MemberInstance( @@ -277,17 +283,21 @@ def update( :returns: The updated MemberInstance """ + data = values.of( { "RoleSid": role_sid, "LastConsumedMessageIndex": last_consumed_message_index, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return MemberInstance( @@ -311,17 +321,21 @@ async def update_async( :returns: The updated MemberInstance """ + data = values.of( { "RoleSid": role_sid, "LastConsumedMessageIndex": last_consumed_message_index, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return MemberInstance( @@ -406,11 +420,14 @@ def create( "RoleSid": role_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return MemberInstance( @@ -438,11 +455,14 @@ async def create_async( "RoleSid": role_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return MemberInstance( @@ -592,7 +612,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return MemberPage(self._version, response, self._solution) async def page_async( @@ -622,8 +648,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return MemberPage(self._version, response, self._solution) diff --git a/twilio/rest/ip_messaging/v1/service/channel/message.py b/twilio/rest/ip_messaging/v1/service/channel/message.py index f9f2a2b1a6..ad7c05d8a1 100644 --- a/twilio/rest/ip_messaging/v1/service/channel/message.py +++ b/twilio/rest/ip_messaging/v1/service/channel/message.py @@ -210,10 +210,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -222,9 +222,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> MessageInstance: @@ -235,10 +237,11 @@ def fetch(self) -> MessageInstance: :returns: The fetched MessageInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return MessageInstance( self._version, @@ -256,9 +259,12 @@ async def fetch_async(self) -> MessageInstance: :returns: The fetched MessageInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return MessageInstance( @@ -282,17 +288,21 @@ def update( :returns: The updated MessageInstance """ + data = values.of( { "Body": body, "Attributes": attributes, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return MessageInstance( @@ -316,17 +326,21 @@ async def update_async( :returns: The updated MessageInstance """ + data = values.of( { "Body": body, "Attributes": attributes, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return MessageInstance( @@ -416,11 +430,14 @@ def create( "Attributes": attributes, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return MessageInstance( @@ -453,11 +470,14 @@ async def create_async( "Attributes": attributes, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return MessageInstance( @@ -607,7 +627,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return MessagePage(self._version, response, self._solution) async def page_async( @@ -637,8 +663,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return MessagePage(self._version, response, self._solution) diff --git a/twilio/rest/ip_messaging/v1/service/role.py b/twilio/rest/ip_messaging/v1/service/role.py index 935a99e180..d5d0628032 100644 --- a/twilio/rest/ip_messaging/v1/service/role.py +++ b/twilio/rest/ip_messaging/v1/service/role.py @@ -181,10 +181,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -193,9 +193,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> RoleInstance: @@ -206,10 +208,11 @@ def fetch(self) -> RoleInstance: :returns: The fetched RoleInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return RoleInstance( self._version, @@ -226,9 +229,12 @@ async def fetch_async(self) -> RoleInstance: :returns: The fetched RoleInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return RoleInstance( @@ -246,16 +252,20 @@ def update(self, permission: List[str]) -> RoleInstance: :returns: The updated RoleInstance """ + data = values.of( { "Permission": serialize.map(permission, lambda e: e), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RoleInstance( @@ -273,16 +283,20 @@ async def update_async(self, permission: List[str]) -> RoleInstance: :returns: The updated RoleInstance """ + data = values.of( { "Permission": serialize.map(permission, lambda e: e), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RoleInstance( @@ -361,11 +375,14 @@ def create( "Permission": serialize.map(permission, lambda e: e), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RoleInstance( @@ -392,11 +409,14 @@ async def create_async( "Permission": serialize.map(permission, lambda e: e), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RoleInstance( @@ -530,7 +550,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return RolePage(self._version, response, self._solution) async def page_async( @@ -557,8 +583,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return RolePage(self._version, response, self._solution) diff --git a/twilio/rest/ip_messaging/v1/service/user/__init__.py b/twilio/rest/ip_messaging/v1/service/user/__init__.py index ef24fa776f..5f37f2d3aa 100644 --- a/twilio/rest/ip_messaging/v1/service/user/__init__.py +++ b/twilio/rest/ip_messaging/v1/service/user/__init__.py @@ -216,10 +216,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -228,9 +228,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> UserInstance: @@ -241,10 +243,11 @@ def fetch(self) -> UserInstance: :returns: The fetched UserInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return UserInstance( self._version, @@ -261,9 +264,12 @@ async def fetch_async(self) -> UserInstance: :returns: The fetched UserInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return UserInstance( @@ -288,6 +294,7 @@ def update( :returns: The updated UserInstance """ + data = values.of( { "RoleSid": role_sid, @@ -295,11 +302,14 @@ def update( "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return UserInstance( @@ -324,6 +334,7 @@ async def update_async( :returns: The updated UserInstance """ + data = values.of( { "RoleSid": role_sid, @@ -331,11 +342,14 @@ async def update_async( "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return UserInstance( @@ -433,11 +447,14 @@ def create( "FriendlyName": friendly_name, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return UserInstance( @@ -470,11 +487,14 @@ async def create_async( "FriendlyName": friendly_name, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return UserInstance( @@ -608,7 +628,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return UserPage(self._version, response, self._solution) async def page_async( @@ -635,8 +661,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return UserPage(self._version, response, self._solution) diff --git a/twilio/rest/ip_messaging/v1/service/user/user_channel.py b/twilio/rest/ip_messaging/v1/service/user/user_channel.py index 192aafb380..4245449869 100644 --- a/twilio/rest/ip_messaging/v1/service/user/user_channel.py +++ b/twilio/rest/ip_messaging/v1/service/user/user_channel.py @@ -247,7 +247,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return UserChannelPage(self._version, response, self._solution) async def page_async( @@ -274,8 +280,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return UserChannelPage(self._version, response, self._solution) diff --git a/twilio/rest/ip_messaging/v2/credential.py b/twilio/rest/ip_messaging/v2/credential.py index beec9fbebe..065c5048e9 100644 --- a/twilio/rest/ip_messaging/v2/credential.py +++ b/twilio/rest/ip_messaging/v2/credential.py @@ -208,10 +208,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -220,9 +220,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> CredentialInstance: @@ -233,10 +235,11 @@ def fetch(self) -> CredentialInstance: :returns: The fetched CredentialInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return CredentialInstance( self._version, @@ -252,9 +255,12 @@ async def fetch_async(self) -> CredentialInstance: :returns: The fetched CredentialInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return CredentialInstance( @@ -284,6 +290,7 @@ def update( :returns: The updated CredentialInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -294,11 +301,14 @@ def update( "Secret": secret, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CredentialInstance(self._version, payload, sid=self._solution["sid"]) @@ -324,6 +334,7 @@ async def update_async( :returns: The updated CredentialInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -334,11 +345,14 @@ async def update_async( "Secret": secret, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CredentialInstance(self._version, payload, sid=self._solution["sid"]) @@ -420,11 +434,14 @@ def create( "Secret": secret, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CredentialInstance(self._version, payload) @@ -464,11 +481,14 @@ async def create_async( "Secret": secret, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CredentialInstance(self._version, payload) @@ -600,7 +620,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return CredentialPage(self._version, response) async def page_async( @@ -627,8 +653,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return CredentialPage(self._version, response) diff --git a/twilio/rest/ip_messaging/v2/service/__init__.py b/twilio/rest/ip_messaging/v2/service/__init__.py index b107a11976..a303f10f33 100644 --- a/twilio/rest/ip_messaging/v2/service/__init__.py +++ b/twilio/rest/ip_messaging/v2/service/__init__.py @@ -437,10 +437,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -449,9 +449,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> ServiceInstance: @@ -462,10 +464,11 @@ def fetch(self) -> ServiceInstance: :returns: The fetched ServiceInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ServiceInstance( self._version, @@ -481,9 +484,12 @@ async def fetch_async(self) -> ServiceInstance: :returns: The fetched ServiceInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ServiceInstance( @@ -565,6 +571,7 @@ def update( :returns: The updated ServiceInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -614,11 +621,14 @@ def update( ), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload, sid=self._solution["sid"]) @@ -696,6 +706,7 @@ async def update_async( :returns: The updated ServiceInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -745,11 +756,14 @@ async def update_async( ), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload, sid=self._solution["sid"]) @@ -858,11 +872,14 @@ def create(self, friendly_name: str) -> ServiceInstance: "FriendlyName": friendly_name, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload) @@ -881,11 +898,14 @@ async def create_async(self, friendly_name: str) -> ServiceInstance: "FriendlyName": friendly_name, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload) @@ -1017,7 +1037,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ServicePage(self._version, response) async def page_async( @@ -1044,8 +1070,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ServicePage(self._version, response) diff --git a/twilio/rest/ip_messaging/v2/service/binding.py b/twilio/rest/ip_messaging/v2/service/binding.py index 24c4f65a4b..af9018af9f 100644 --- a/twilio/rest/ip_messaging/v2/service/binding.py +++ b/twilio/rest/ip_messaging/v2/service/binding.py @@ -166,10 +166,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -178,9 +178,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> BindingInstance: @@ -191,10 +193,11 @@ def fetch(self) -> BindingInstance: :returns: The fetched BindingInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return BindingInstance( self._version, @@ -211,9 +214,12 @@ async def fetch_async(self) -> BindingInstance: :returns: The fetched BindingInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return BindingInstance( @@ -429,7 +435,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return BindingPage(self._version, response, self._solution) async def page_async( @@ -462,8 +474,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return BindingPage(self._version, response, self._solution) diff --git a/twilio/rest/ip_messaging/v2/service/channel/__init__.py b/twilio/rest/ip_messaging/v2/service/channel/__init__.py index c4e03d4536..8220a4be9c 100644 --- a/twilio/rest/ip_messaging/v2/service/channel/__init__.py +++ b/twilio/rest/ip_messaging/v2/service/channel/__init__.py @@ -310,6 +310,8 @@ def delete( } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async( @@ -331,6 +333,8 @@ async def delete_async( } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -343,10 +347,11 @@ def fetch(self) -> ChannelInstance: :returns: The fetched ChannelInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ChannelInstance( self._version, @@ -363,9 +368,12 @@ async def fetch_async(self) -> ChannelInstance: :returns: The fetched ChannelInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ChannelInstance( @@ -400,6 +408,7 @@ def update( :returns: The updated ChannelInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -410,11 +419,20 @@ def update( "CreatedBy": created_by, } ) - headers = values.of( - { - "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, - } - ) + headers = values.of({}) + + if not ( + x_twilio_webhook_enabled is values.unset + or ( + isinstance(x_twilio_webhook_enabled, str) + and not x_twilio_webhook_enabled + ) + ): + headers["X-Twilio-Webhook-Enabled"] = x_twilio_webhook_enabled + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( method="POST", uri=self._uri, data=data, headers=headers @@ -452,6 +470,7 @@ async def update_async( :returns: The updated ChannelInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -462,11 +481,20 @@ async def update_async( "CreatedBy": created_by, } ) - headers = values.of( - { - "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, - } - ) + headers = values.of({}) + + if not ( + x_twilio_webhook_enabled is values.unset + or ( + isinstance(x_twilio_webhook_enabled, str) + and not x_twilio_webhook_enabled + ) + ): + headers["X-Twilio-Webhook-Enabled"] = x_twilio_webhook_enabled + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( method="POST", uri=self._uri, data=data, headers=headers @@ -622,9 +650,14 @@ def create( headers = values.of( { "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = self._version.create( method="POST", uri=self._uri, data=data, headers=headers ) @@ -675,9 +708,14 @@ async def create_async( headers = values.of( { "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = await self._version.create_async( method="POST", uri=self._uri, data=data, headers=headers ) @@ -826,7 +864,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ChannelPage(self._version, response, self._solution) async def page_async( @@ -856,8 +900,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ChannelPage(self._version, response, self._solution) diff --git a/twilio/rest/ip_messaging/v2/service/channel/invite.py b/twilio/rest/ip_messaging/v2/service/channel/invite.py index 0f863d70f0..4fa3c187fc 100644 --- a/twilio/rest/ip_messaging/v2/service/channel/invite.py +++ b/twilio/rest/ip_messaging/v2/service/channel/invite.py @@ -163,10 +163,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -175,9 +175,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> InviteInstance: @@ -188,10 +190,11 @@ def fetch(self) -> InviteInstance: :returns: The fetched InviteInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return InviteInstance( self._version, @@ -209,9 +212,12 @@ async def fetch_async(self) -> InviteInstance: :returns: The fetched InviteInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return InviteInstance( @@ -296,11 +302,14 @@ def create( "RoleSid": role_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return InviteInstance( @@ -328,11 +337,14 @@ async def create_async( "RoleSid": role_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return InviteInstance( @@ -482,7 +494,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return InvitePage(self._version, response, self._solution) async def page_async( @@ -512,8 +530,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return InvitePage(self._version, response, self._solution) diff --git a/twilio/rest/ip_messaging/v2/service/channel/member.py b/twilio/rest/ip_messaging/v2/service/channel/member.py index 5de4520ed3..6456d3be20 100644 --- a/twilio/rest/ip_messaging/v2/service/channel/member.py +++ b/twilio/rest/ip_messaging/v2/service/channel/member.py @@ -274,6 +274,8 @@ def delete( } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async( @@ -295,6 +297,8 @@ async def delete_async( } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -307,10 +311,11 @@ def fetch(self) -> MemberInstance: :returns: The fetched MemberInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return MemberInstance( self._version, @@ -328,9 +333,12 @@ async def fetch_async(self) -> MemberInstance: :returns: The fetched MemberInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return MemberInstance( @@ -366,6 +374,7 @@ def update( :returns: The updated MemberInstance """ + data = values.of( { "RoleSid": role_sid, @@ -378,11 +387,20 @@ def update( "Attributes": attributes, } ) - headers = values.of( - { - "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, - } - ) + headers = values.of({}) + + if not ( + x_twilio_webhook_enabled is values.unset + or ( + isinstance(x_twilio_webhook_enabled, str) + and not x_twilio_webhook_enabled + ) + ): + headers["X-Twilio-Webhook-Enabled"] = x_twilio_webhook_enabled + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( method="POST", uri=self._uri, data=data, headers=headers @@ -421,6 +439,7 @@ async def update_async( :returns: The updated MemberInstance """ + data = values.of( { "RoleSid": role_sid, @@ -433,11 +452,20 @@ async def update_async( "Attributes": attributes, } ) - headers = values.of( - { - "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, - } - ) + headers = values.of({}) + + if not ( + x_twilio_webhook_enabled is values.unset + or ( + isinstance(x_twilio_webhook_enabled, str) + and not x_twilio_webhook_enabled + ) + ): + headers["X-Twilio-Webhook-Enabled"] = x_twilio_webhook_enabled + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( method="POST", uri=self._uri, data=data, headers=headers @@ -551,9 +579,14 @@ def create( headers = values.of( { "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = self._version.create( method="POST", uri=self._uri, data=data, headers=headers ) @@ -609,9 +642,14 @@ async def create_async( headers = values.of( { "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = await self._version.create_async( method="POST", uri=self._uri, data=data, headers=headers ) @@ -763,7 +801,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return MemberPage(self._version, response, self._solution) async def page_async( @@ -793,8 +837,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return MemberPage(self._version, response, self._solution) diff --git a/twilio/rest/ip_messaging/v2/service/channel/message.py b/twilio/rest/ip_messaging/v2/service/channel/message.py index 057571c2ab..838b3c7271 100644 --- a/twilio/rest/ip_messaging/v2/service/channel/message.py +++ b/twilio/rest/ip_messaging/v2/service/channel/message.py @@ -282,6 +282,8 @@ def delete( } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async( @@ -303,6 +305,8 @@ async def delete_async( } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -315,10 +319,11 @@ def fetch(self) -> MessageInstance: :returns: The fetched MessageInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return MessageInstance( self._version, @@ -336,9 +341,12 @@ async def fetch_async(self) -> MessageInstance: :returns: The fetched MessageInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return MessageInstance( @@ -374,6 +382,7 @@ def update( :returns: The updated MessageInstance """ + data = values.of( { "Body": body, @@ -384,11 +393,20 @@ def update( "From": from_, } ) - headers = values.of( - { - "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, - } - ) + headers = values.of({}) + + if not ( + x_twilio_webhook_enabled is values.unset + or ( + isinstance(x_twilio_webhook_enabled, str) + and not x_twilio_webhook_enabled + ) + ): + headers["X-Twilio-Webhook-Enabled"] = x_twilio_webhook_enabled + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( method="POST", uri=self._uri, data=data, headers=headers @@ -427,6 +445,7 @@ async def update_async( :returns: The updated MessageInstance """ + data = values.of( { "Body": body, @@ -437,11 +456,20 @@ async def update_async( "From": from_, } ) - headers = values.of( - { - "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, - } - ) + headers = values.of({}) + + if not ( + x_twilio_webhook_enabled is values.unset + or ( + isinstance(x_twilio_webhook_enabled, str) + and not x_twilio_webhook_enabled + ) + ): + headers["X-Twilio-Webhook-Enabled"] = x_twilio_webhook_enabled + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( method="POST", uri=self._uri, data=data, headers=headers @@ -553,9 +581,14 @@ def create( headers = values.of( { "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = self._version.create( method="POST", uri=self._uri, data=data, headers=headers ) @@ -609,9 +642,14 @@ async def create_async( headers = values.of( { "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = await self._version.create_async( method="POST", uri=self._uri, data=data, headers=headers ) @@ -763,7 +801,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return MessagePage(self._version, response, self._solution) async def page_async( @@ -793,8 +837,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return MessagePage(self._version, response, self._solution) diff --git a/twilio/rest/ip_messaging/v2/service/channel/webhook.py b/twilio/rest/ip_messaging/v2/service/channel/webhook.py index 633acfd51f..3c7570fd0e 100644 --- a/twilio/rest/ip_messaging/v2/service/channel/webhook.py +++ b/twilio/rest/ip_messaging/v2/service/channel/webhook.py @@ -231,10 +231,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -243,9 +243,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> WebhookInstance: @@ -256,10 +258,11 @@ def fetch(self) -> WebhookInstance: :returns: The fetched WebhookInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return WebhookInstance( self._version, @@ -277,9 +280,12 @@ async def fetch_async(self) -> WebhookInstance: :returns: The fetched WebhookInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return WebhookInstance( @@ -311,6 +317,7 @@ def update( :returns: The updated WebhookInstance """ + data = values.of( { "Configuration.Url": configuration_url, @@ -325,11 +332,14 @@ def update( "Configuration.RetryCount": configuration_retry_count, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WebhookInstance( @@ -361,6 +371,7 @@ async def update_async( :returns: The updated WebhookInstance """ + data = values.of( { "Configuration.Url": configuration_url, @@ -375,11 +386,14 @@ async def update_async( "Configuration.RetryCount": configuration_retry_count, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WebhookInstance( @@ -485,11 +499,14 @@ def create( "Configuration.RetryCount": configuration_retry_count, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WebhookInstance( @@ -538,11 +555,14 @@ async def create_async( "Configuration.RetryCount": configuration_retry_count, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WebhookInstance( @@ -679,7 +699,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return WebhookPage(self._version, response, self._solution) async def page_async( @@ -706,8 +732,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return WebhookPage(self._version, response, self._solution) diff --git a/twilio/rest/ip_messaging/v2/service/role.py b/twilio/rest/ip_messaging/v2/service/role.py index 91fc1af939..32f70c2272 100644 --- a/twilio/rest/ip_messaging/v2/service/role.py +++ b/twilio/rest/ip_messaging/v2/service/role.py @@ -181,10 +181,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -193,9 +193,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> RoleInstance: @@ -206,10 +208,11 @@ def fetch(self) -> RoleInstance: :returns: The fetched RoleInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return RoleInstance( self._version, @@ -226,9 +229,12 @@ async def fetch_async(self) -> RoleInstance: :returns: The fetched RoleInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return RoleInstance( @@ -246,16 +252,20 @@ def update(self, permission: List[str]) -> RoleInstance: :returns: The updated RoleInstance """ + data = values.of( { "Permission": serialize.map(permission, lambda e: e), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RoleInstance( @@ -273,16 +283,20 @@ async def update_async(self, permission: List[str]) -> RoleInstance: :returns: The updated RoleInstance """ + data = values.of( { "Permission": serialize.map(permission, lambda e: e), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RoleInstance( @@ -361,11 +375,14 @@ def create( "Permission": serialize.map(permission, lambda e: e), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RoleInstance( @@ -392,11 +409,14 @@ async def create_async( "Permission": serialize.map(permission, lambda e: e), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RoleInstance( @@ -530,7 +550,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return RolePage(self._version, response, self._solution) async def page_async( @@ -557,8 +583,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return RolePage(self._version, response, self._solution) diff --git a/twilio/rest/ip_messaging/v2/service/user/__init__.py b/twilio/rest/ip_messaging/v2/service/user/__init__.py index 1b3ba1b391..f5f1454c72 100644 --- a/twilio/rest/ip_messaging/v2/service/user/__init__.py +++ b/twilio/rest/ip_messaging/v2/service/user/__init__.py @@ -240,10 +240,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -252,9 +252,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> UserInstance: @@ -265,10 +267,11 @@ def fetch(self) -> UserInstance: :returns: The fetched UserInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return UserInstance( self._version, @@ -285,9 +288,12 @@ async def fetch_async(self) -> UserInstance: :returns: The fetched UserInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return UserInstance( @@ -316,6 +322,7 @@ def update( :returns: The updated UserInstance """ + data = values.of( { "RoleSid": role_sid, @@ -323,11 +330,20 @@ def update( "FriendlyName": friendly_name, } ) - headers = values.of( - { - "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, - } - ) + headers = values.of({}) + + if not ( + x_twilio_webhook_enabled is values.unset + or ( + isinstance(x_twilio_webhook_enabled, str) + and not x_twilio_webhook_enabled + ) + ): + headers["X-Twilio-Webhook-Enabled"] = x_twilio_webhook_enabled + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( method="POST", uri=self._uri, data=data, headers=headers @@ -359,6 +375,7 @@ async def update_async( :returns: The updated UserInstance """ + data = values.of( { "RoleSid": role_sid, @@ -366,11 +383,20 @@ async def update_async( "FriendlyName": friendly_name, } ) - headers = values.of( - { - "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, - } - ) + headers = values.of({}) + + if not ( + x_twilio_webhook_enabled is values.unset + or ( + isinstance(x_twilio_webhook_enabled, str) + and not x_twilio_webhook_enabled + ) + ): + headers["X-Twilio-Webhook-Enabled"] = x_twilio_webhook_enabled + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( method="POST", uri=self._uri, data=data, headers=headers @@ -491,9 +517,14 @@ def create( headers = values.of( { "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = self._version.create( method="POST", uri=self._uri, data=data, headers=headers ) @@ -535,9 +566,14 @@ async def create_async( headers = values.of( { "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, + "Content-Type": "application/x-www-form-urlencoded", } ) + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + payload = await self._version.create_async( method="POST", uri=self._uri, data=data, headers=headers ) @@ -673,7 +709,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return UserPage(self._version, response, self._solution) async def page_async( @@ -700,8 +742,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return UserPage(self._version, response, self._solution) diff --git a/twilio/rest/ip_messaging/v2/service/user/user_binding.py b/twilio/rest/ip_messaging/v2/service/user/user_binding.py index 575a295cbb..4f1d9f10a7 100644 --- a/twilio/rest/ip_messaging/v2/service/user/user_binding.py +++ b/twilio/rest/ip_messaging/v2/service/user/user_binding.py @@ -173,10 +173,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -185,9 +185,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> UserBindingInstance: @@ -198,10 +200,11 @@ def fetch(self) -> UserBindingInstance: :returns: The fetched UserBindingInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return UserBindingInstance( self._version, @@ -219,9 +222,12 @@ async def fetch_async(self) -> UserBindingInstance: :returns: The fetched UserBindingInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return UserBindingInstance( @@ -440,7 +446,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return UserBindingPage(self._version, response, self._solution) async def page_async( @@ -472,8 +484,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return UserBindingPage(self._version, response, self._solution) diff --git a/twilio/rest/ip_messaging/v2/service/user/user_channel.py b/twilio/rest/ip_messaging/v2/service/user/user_channel.py index d89e6cb80d..5cb544fc3f 100644 --- a/twilio/rest/ip_messaging/v2/service/user/user_channel.py +++ b/twilio/rest/ip_messaging/v2/service/user/user_channel.py @@ -227,10 +227,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -239,9 +239,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> UserChannelInstance: @@ -252,10 +254,11 @@ def fetch(self) -> UserChannelInstance: :returns: The fetched UserChannelInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return UserChannelInstance( self._version, @@ -273,9 +276,12 @@ async def fetch_async(self) -> UserChannelInstance: :returns: The fetched UserChannelInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return UserChannelInstance( @@ -303,6 +309,7 @@ def update( :returns: The updated UserChannelInstance """ + data = values.of( { "NotificationLevel": notification_level, @@ -312,11 +319,14 @@ def update( ), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return UserChannelInstance( @@ -344,6 +354,7 @@ async def update_async( :returns: The updated UserChannelInstance """ + data = values.of( { "NotificationLevel": notification_level, @@ -353,11 +364,14 @@ async def update_async( ), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return UserChannelInstance( @@ -551,7 +565,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return UserChannelPage(self._version, response, self._solution) async def page_async( @@ -578,8 +598,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return UserChannelPage(self._version, response, self._solution) diff --git a/twilio/rest/knowledge/KnowledgeBase.py b/twilio/rest/knowledge/KnowledgeBase.py new file mode 100644 index 0000000000..902f0e8b96 --- /dev/null +++ b/twilio/rest/knowledge/KnowledgeBase.py @@ -0,0 +1,44 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from typing import Optional + +from twilio.base.domain import Domain +from twilio.rest import Client +from twilio.rest.knowledge.v1 import V1 + + +class KnowledgeBase(Domain): + + def __init__(self, twilio: Client): + """ + Initialize the Knowledge Domain + + :returns: Domain for Knowledge + """ + super().__init__(twilio, "https://knowledge.twilio.com") + self._v1: Optional[V1] = None + + @property + def v1(self) -> V1: + """ + :returns: Versions v1 of Knowledge + """ + if self._v1 is None: + self._v1 = V1(self) + return self._v1 + + def __repr__(self) -> str: + """ + Provide a friendly representation + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/preview/sync/__init__.py b/twilio/rest/knowledge/v1/__init__.py similarity index 62% rename from twilio/rest/preview/sync/__init__.py rename to twilio/rest/knowledge/v1/__init__.py index d84c79039b..9609bff951 100644 --- a/twilio/rest/preview/sync/__init__.py +++ b/twilio/rest/knowledge/v1/__init__.py @@ -4,7 +4,7 @@ | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - Twilio - Preview + Twilio - Knowledge This is the public Twilio REST API. NOTE: This class is auto generated by OpenAPI Generator. @@ -15,29 +15,29 @@ from typing import Optional from twilio.base.version import Version from twilio.base.domain import Domain -from twilio.rest.preview.sync.service import ServiceList +from twilio.rest.knowledge.v1.knowledge import KnowledgeList -class Sync(Version): +class V1(Version): def __init__(self, domain: Domain): """ - Initialize the Sync version of Preview + Initialize the V1 version of Knowledge - :param domain: The Twilio.preview domain + :param domain: The Twilio.knowledge domain """ - super().__init__(domain, "Sync") - self._services: Optional[ServiceList] = None + super().__init__(domain, "v1") + self._knowledge: Optional[KnowledgeList] = None @property - def services(self) -> ServiceList: - if self._services is None: - self._services = ServiceList(self) - return self._services + def knowledge(self) -> KnowledgeList: + if self._knowledge is None: + self._knowledge = KnowledgeList(self) + return self._knowledge def __repr__(self) -> str: """ Provide a friendly representation :returns: Machine friendly representation """ - return "" + return "" diff --git a/twilio/rest/knowledge/v1/knowledge/__init__.py b/twilio/rest/knowledge/v1/knowledge/__init__.py new file mode 100644 index 0000000000..8ba6b2c481 --- /dev/null +++ b/twilio/rest/knowledge/v1/knowledge/__init__.py @@ -0,0 +1,935 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Knowledge + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from datetime import datetime +from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator +from twilio.base import deserialize, values +from twilio.base.instance_context import InstanceContext +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version +from twilio.base.page import Page +from twilio.rest.knowledge.v1.knowledge.chunk import ChunkList +from twilio.rest.knowledge.v1.knowledge.knowledge_status import KnowledgeStatusList + + +class KnowledgeInstance(InstanceResource): + + class KnowledgeV1ServiceCreateKnowledgeRequest(object): + """ + :ivar description: The description of the knowledge source. + :ivar knowledge_source_details: The details of the knowledge source based on the type. + :ivar name: The name of the tool. + :ivar policy: + :ivar type: The type of the knowledge source. + :ivar embedding_model: The embedding model to be used for the knowledge source. It's required for 'Database' type but disallowed for other types. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.description: Optional[str] = payload.get("description") + self.knowledge_source_details: Optional[Dict[str, object]] = payload.get( + "knowledge_source_details" + ) + self.name: Optional[str] = payload.get("name") + self.policy: Optional[ + KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest + ] = payload.get("policy") + self.type: Optional[str] = payload.get("type") + self.embedding_model: Optional[str] = payload.get("embedding_model") + + def to_dict(self): + return { + "description": self.description, + "knowledge_source_details": self.knowledge_source_details, + "name": self.name, + "policy": self.policy.to_dict() if self.policy is not None else None, + "type": self.type, + "embedding_model": self.embedding_model, + } + + class KnowledgeV1ServiceCreatePolicyRequest(object): + """ + :ivar description: The description of the policy. + :ivar id: The Policy ID. + :ivar name: The name of the policy. + :ivar policy_details: + :ivar type: The description of the policy. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.description: Optional[str] = payload.get("description") + self.id: Optional[str] = payload.get("id") + self.name: Optional[str] = payload.get("name") + self.policy_details: Optional[Dict[str, object]] = payload.get( + "policy_details" + ) + self.type: Optional[str] = payload.get("type") + + def to_dict(self): + return { + "description": self.description, + "id": self.id, + "name": self.name, + "policy_details": self.policy_details, + "type": self.type, + } + + class KnowledgeV1ServiceUpdateKnowledgeRequest(object): + """ + :ivar description: The description of the knowledge source. + :ivar knowledge_source_details: The details of the knowledge source based on the type. + :ivar name: The name of the knowledge source. + :ivar policy: + :ivar type: The description of the knowledge source. + :ivar embedding_model: The embedding model to be used for the knowledge source. It's only applicable to 'Database' type. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.description: Optional[str] = payload.get("description") + self.knowledge_source_details: Optional[Dict[str, object]] = payload.get( + "knowledge_source_details" + ) + self.name: Optional[str] = payload.get("name") + self.policy: Optional[ + KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest + ] = payload.get("policy") + self.type: Optional[str] = payload.get("type") + self.embedding_model: Optional[str] = payload.get("embedding_model") + + def to_dict(self): + return { + "description": self.description, + "knowledge_source_details": self.knowledge_source_details, + "name": self.name, + "policy": self.policy.to_dict() if self.policy is not None else None, + "type": self.type, + "embedding_model": self.embedding_model, + } + + """ + :ivar description: The type of knowledge source. + :ivar id: The description of knowledge. + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Knowledge resource. + :ivar knowledge_source_details: The details of the knowledge source based on the type. + :ivar name: The name of the knowledge source. + :ivar status: The status of processing the knowledge source ('QUEUED', 'PROCESSING', 'COMPLETED', 'FAILED') + :ivar type: The type of knowledge source ('Web', 'Database', 'Text', 'File') + :ivar url: The url of the knowledge resource. + :ivar embedding_model: The embedding model to be used for the knowledge source. + :ivar date_created: The date and time in GMT when the Knowledge was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + :ivar date_updated: The date and time in GMT when the Knowledge was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + """ + + def __init__( + self, version: Version, payload: Dict[str, Any], id: Optional[str] = None + ): + super().__init__(version) + + self.description: Optional[str] = payload.get("description") + self.id: Optional[str] = payload.get("id") + self.account_sid: Optional[str] = payload.get("account_sid") + self.knowledge_source_details: Optional[Dict[str, object]] = payload.get( + "knowledge_source_details" + ) + self.name: Optional[str] = payload.get("name") + self.status: Optional[str] = payload.get("status") + self.type: Optional[str] = payload.get("type") + self.url: Optional[str] = payload.get("url") + self.embedding_model: Optional[str] = payload.get("embedding_model") + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_created") + ) + self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_updated") + ) + + self._solution = { + "id": id or self.id, + } + self._context: Optional[KnowledgeContext] = None + + @property + def _proxy(self) -> "KnowledgeContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: KnowledgeContext for this KnowledgeInstance + """ + if self._context is None: + self._context = KnowledgeContext( + self._version, + id=self._solution["id"], + ) + return self._context + + def delete(self) -> bool: + """ + Deletes the KnowledgeInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._proxy.delete() + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the KnowledgeInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._proxy.delete_async() + + def fetch(self) -> "KnowledgeInstance": + """ + Fetch the KnowledgeInstance + + + :returns: The fetched KnowledgeInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "KnowledgeInstance": + """ + Asynchronous coroutine to fetch the KnowledgeInstance + + + :returns: The fetched KnowledgeInstance + """ + return await self._proxy.fetch_async() + + def update( + self, + knowledge_v1_service_update_knowledge_request: Union[ + KnowledgeV1ServiceUpdateKnowledgeRequest, object + ] = values.unset, + ) -> "KnowledgeInstance": + """ + Update the KnowledgeInstance + + :param knowledge_v1_service_update_knowledge_request: + + :returns: The updated KnowledgeInstance + """ + return self._proxy.update( + knowledge_v1_service_update_knowledge_request=knowledge_v1_service_update_knowledge_request, + ) + + async def update_async( + self, + knowledge_v1_service_update_knowledge_request: Union[ + KnowledgeV1ServiceUpdateKnowledgeRequest, object + ] = values.unset, + ) -> "KnowledgeInstance": + """ + Asynchronous coroutine to update the KnowledgeInstance + + :param knowledge_v1_service_update_knowledge_request: + + :returns: The updated KnowledgeInstance + """ + return await self._proxy.update_async( + knowledge_v1_service_update_knowledge_request=knowledge_v1_service_update_knowledge_request, + ) + + @property + def chunks(self) -> ChunkList: + """ + Access the chunks + """ + return self._proxy.chunks + + @property + def knowledge_status(self) -> KnowledgeStatusList: + """ + Access the knowledge_status + """ + return self._proxy.knowledge_status + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class KnowledgeContext(InstanceContext): + + class KnowledgeV1ServiceCreateKnowledgeRequest(object): + """ + :ivar description: The description of the knowledge source. + :ivar knowledge_source_details: The details of the knowledge source based on the type. + :ivar name: The name of the tool. + :ivar policy: + :ivar type: The type of the knowledge source. + :ivar embedding_model: The embedding model to be used for the knowledge source. It's required for 'Database' type but disallowed for other types. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.description: Optional[str] = payload.get("description") + self.knowledge_source_details: Optional[Dict[str, object]] = payload.get( + "knowledge_source_details" + ) + self.name: Optional[str] = payload.get("name") + self.policy: Optional[ + KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest + ] = payload.get("policy") + self.type: Optional[str] = payload.get("type") + self.embedding_model: Optional[str] = payload.get("embedding_model") + + def to_dict(self): + return { + "description": self.description, + "knowledge_source_details": self.knowledge_source_details, + "name": self.name, + "policy": self.policy.to_dict() if self.policy is not None else None, + "type": self.type, + "embedding_model": self.embedding_model, + } + + class KnowledgeV1ServiceCreatePolicyRequest(object): + """ + :ivar description: The description of the policy. + :ivar id: The Policy ID. + :ivar name: The name of the policy. + :ivar policy_details: + :ivar type: The description of the policy. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.description: Optional[str] = payload.get("description") + self.id: Optional[str] = payload.get("id") + self.name: Optional[str] = payload.get("name") + self.policy_details: Optional[Dict[str, object]] = payload.get( + "policy_details" + ) + self.type: Optional[str] = payload.get("type") + + def to_dict(self): + return { + "description": self.description, + "id": self.id, + "name": self.name, + "policy_details": self.policy_details, + "type": self.type, + } + + class KnowledgeV1ServiceUpdateKnowledgeRequest(object): + """ + :ivar description: The description of the knowledge source. + :ivar knowledge_source_details: The details of the knowledge source based on the type. + :ivar name: The name of the knowledge source. + :ivar policy: + :ivar type: The description of the knowledge source. + :ivar embedding_model: The embedding model to be used for the knowledge source. It's only applicable to 'Database' type. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.description: Optional[str] = payload.get("description") + self.knowledge_source_details: Optional[Dict[str, object]] = payload.get( + "knowledge_source_details" + ) + self.name: Optional[str] = payload.get("name") + self.policy: Optional[ + KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest + ] = payload.get("policy") + self.type: Optional[str] = payload.get("type") + self.embedding_model: Optional[str] = payload.get("embedding_model") + + def to_dict(self): + return { + "description": self.description, + "knowledge_source_details": self.knowledge_source_details, + "name": self.name, + "policy": self.policy.to_dict() if self.policy is not None else None, + "type": self.type, + "embedding_model": self.embedding_model, + } + + def __init__(self, version: Version, id: str): + """ + Initialize the KnowledgeContext + + :param version: Version that contains the resource + :param id: + """ + super().__init__(version) + + # Path Solution + self._solution = { + "id": id, + } + self._uri = "/Knowledge/{id}".format(**self._solution) + + self._chunks: Optional[ChunkList] = None + self._knowledge_status: Optional[KnowledgeStatusList] = None + + def delete(self) -> bool: + """ + Deletes the KnowledgeInstance + + + :returns: True if delete succeeds, False otherwise + """ + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the KnowledgeInstance + + + :returns: True if delete succeeds, False otherwise + """ + + headers = values.of({}) + + return await self._version.delete_async( + method="DELETE", uri=self._uri, headers=headers + ) + + def fetch(self) -> KnowledgeInstance: + """ + Fetch the KnowledgeInstance + + + :returns: The fetched KnowledgeInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return KnowledgeInstance( + self._version, + payload, + id=self._solution["id"], + ) + + async def fetch_async(self) -> KnowledgeInstance: + """ + Asynchronous coroutine to fetch the KnowledgeInstance + + + :returns: The fetched KnowledgeInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + return KnowledgeInstance( + self._version, + payload, + id=self._solution["id"], + ) + + def update( + self, + knowledge_v1_service_update_knowledge_request: Union[ + KnowledgeV1ServiceUpdateKnowledgeRequest, object + ] = values.unset, + ) -> KnowledgeInstance: + """ + Update the KnowledgeInstance + + :param knowledge_v1_service_update_knowledge_request: + + :returns: The updated KnowledgeInstance + """ + data = knowledge_v1_service_update_knowledge_request.to_dict() + + headers = values.of({}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + payload = self._version.update( + method="PUT", uri=self._uri, data=data, headers=headers + ) + + return KnowledgeInstance(self._version, payload, id=self._solution["id"]) + + async def update_async( + self, + knowledge_v1_service_update_knowledge_request: Union[ + KnowledgeV1ServiceUpdateKnowledgeRequest, object + ] = values.unset, + ) -> KnowledgeInstance: + """ + Asynchronous coroutine to update the KnowledgeInstance + + :param knowledge_v1_service_update_knowledge_request: + + :returns: The updated KnowledgeInstance + """ + data = knowledge_v1_service_update_knowledge_request.to_dict() + + headers = values.of({}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + payload = await self._version.update_async( + method="PUT", uri=self._uri, data=data, headers=headers + ) + + return KnowledgeInstance(self._version, payload, id=self._solution["id"]) + + @property + def chunks(self) -> ChunkList: + """ + Access the chunks + """ + if self._chunks is None: + self._chunks = ChunkList( + self._version, + self._solution["id"], + ) + return self._chunks + + @property + def knowledge_status(self) -> KnowledgeStatusList: + """ + Access the knowledge_status + """ + if self._knowledge_status is None: + self._knowledge_status = KnowledgeStatusList( + self._version, + self._solution["id"], + ) + return self._knowledge_status + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class KnowledgePage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> KnowledgeInstance: + """ + Build an instance of KnowledgeInstance + + :param payload: Payload response from the API + """ + return KnowledgeInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class KnowledgeList(ListResource): + + class KnowledgeV1ServiceCreateKnowledgeRequest(object): + """ + :ivar description: The description of the knowledge source. + :ivar knowledge_source_details: The details of the knowledge source based on the type. + :ivar name: The name of the tool. + :ivar policy: + :ivar type: The type of the knowledge source. + :ivar embedding_model: The embedding model to be used for the knowledge source. It's required for 'Database' type but disallowed for other types. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.description: Optional[str] = payload.get("description") + self.knowledge_source_details: Optional[Dict[str, object]] = payload.get( + "knowledge_source_details" + ) + self.name: Optional[str] = payload.get("name") + self.policy: Optional[ + KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest + ] = payload.get("policy") + self.type: Optional[str] = payload.get("type") + self.embedding_model: Optional[str] = payload.get("embedding_model") + + def to_dict(self): + return { + "description": self.description, + "knowledge_source_details": self.knowledge_source_details, + "name": self.name, + "policy": self.policy.to_dict() if self.policy is not None else None, + "type": self.type, + "embedding_model": self.embedding_model, + } + + class KnowledgeV1ServiceCreatePolicyRequest(object): + """ + :ivar description: The description of the policy. + :ivar id: The Policy ID. + :ivar name: The name of the policy. + :ivar policy_details: + :ivar type: The description of the policy. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.description: Optional[str] = payload.get("description") + self.id: Optional[str] = payload.get("id") + self.name: Optional[str] = payload.get("name") + self.policy_details: Optional[Dict[str, object]] = payload.get( + "policy_details" + ) + self.type: Optional[str] = payload.get("type") + + def to_dict(self): + return { + "description": self.description, + "id": self.id, + "name": self.name, + "policy_details": self.policy_details, + "type": self.type, + } + + class KnowledgeV1ServiceUpdateKnowledgeRequest(object): + """ + :ivar description: The description of the knowledge source. + :ivar knowledge_source_details: The details of the knowledge source based on the type. + :ivar name: The name of the knowledge source. + :ivar policy: + :ivar type: The description of the knowledge source. + :ivar embedding_model: The embedding model to be used for the knowledge source. It's only applicable to 'Database' type. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.description: Optional[str] = payload.get("description") + self.knowledge_source_details: Optional[Dict[str, object]] = payload.get( + "knowledge_source_details" + ) + self.name: Optional[str] = payload.get("name") + self.policy: Optional[ + KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest + ] = payload.get("policy") + self.type: Optional[str] = payload.get("type") + self.embedding_model: Optional[str] = payload.get("embedding_model") + + def to_dict(self): + return { + "description": self.description, + "knowledge_source_details": self.knowledge_source_details, + "name": self.name, + "policy": self.policy.to_dict() if self.policy is not None else None, + "type": self.type, + "embedding_model": self.embedding_model, + } + + def __init__(self, version: Version): + """ + Initialize the KnowledgeList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/Knowledge" + + def create( + self, + knowledge_v1_service_create_knowledge_request: KnowledgeV1ServiceCreateKnowledgeRequest, + ) -> KnowledgeInstance: + """ + Create the KnowledgeInstance + + :param knowledge_v1_service_create_knowledge_request: + + :returns: The created KnowledgeInstance + """ + data = knowledge_v1_service_create_knowledge_request.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + payload = self._version.create( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return KnowledgeInstance(self._version, payload) + + async def create_async( + self, + knowledge_v1_service_create_knowledge_request: KnowledgeV1ServiceCreateKnowledgeRequest, + ) -> KnowledgeInstance: + """ + Asynchronously create the KnowledgeInstance + + :param knowledge_v1_service_create_knowledge_request: + + :returns: The created KnowledgeInstance + """ + data = knowledge_v1_service_create_knowledge_request.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return KnowledgeInstance(self._version, payload) + + def stream( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[KnowledgeInstance]: + """ + Streams KnowledgeInstance records from the API as a generator stream. + This operation lazily loads records as efficiently as possible until the limit + is reached. + The results are returned as a generator, so this operation is memory efficient. + + :param limit: Upper limit for the number of records to return. stream() + guarantees to never return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, stream() will attempt to read the + limit with the most efficient page size, i.e. min(limit, 1000) + + :returns: Generator that will yield up to limit results + """ + limits = self._version.read_limits(limit, page_size) + page = self.page(page_size=limits["page_size"]) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[KnowledgeInstance]: + """ + Asynchronously streams KnowledgeInstance records from the API as a generator stream. + This operation lazily loads records as efficiently as possible until the limit + is reached. + The results are returned as a generator, so this operation is memory efficient. + + :param limit: Upper limit for the number of records to return. stream() + guarantees to never return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, stream() will attempt to read the + limit with the most efficient page size, i.e. min(limit, 1000) + + :returns: Generator that will yield up to limit results + """ + limits = self._version.read_limits(limit, page_size) + page = await self.page_async(page_size=limits["page_size"]) + + return self._version.stream_async(page, limits["limit"]) + + def list( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[KnowledgeInstance]: + """ + Lists KnowledgeInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param limit: Upper limit for the number of records to return. list() guarantees + never to return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, list() will attempt to read the limit + with the most efficient page size, i.e. min(limit, 1000) + + :returns: list that will contain up to limit results + """ + return list( + self.stream( + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[KnowledgeInstance]: + """ + Asynchronously lists KnowledgeInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param limit: Upper limit for the number of records to return. list() guarantees + never to return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, list() will attempt to read the limit + with the most efficient page size, i.e. min(limit, 1000) + + :returns: list that will contain up to limit results + """ + return [ + record + async for record in await self.stream_async( + limit=limit, + page_size=page_size, + ) + ] + + def page( + self, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> KnowledgePage: + """ + Retrieve a single page of KnowledgeInstance records from the API. + Request is executed immediately + + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: Page of KnowledgeInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return KnowledgePage(self._version, response) + + async def page_async( + self, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> KnowledgePage: + """ + Asynchronously retrieve a single page of KnowledgeInstance records from the API. + Request is executed immediately + + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: Page of KnowledgeInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + return KnowledgePage(self._version, response) + + def get_page(self, target_url: str) -> KnowledgePage: + """ + Retrieve a specific page of KnowledgeInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of KnowledgeInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return KnowledgePage(self._version, response) + + async def get_page_async(self, target_url: str) -> KnowledgePage: + """ + Asynchronously retrieve a specific page of KnowledgeInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of KnowledgeInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return KnowledgePage(self._version, response) + + def get(self, id: str) -> KnowledgeContext: + """ + Constructs a KnowledgeContext + + :param id: + """ + return KnowledgeContext(self._version, id=id) + + def __call__(self, id: str) -> KnowledgeContext: + """ + Constructs a KnowledgeContext + + :param id: + """ + return KnowledgeContext(self._version, id=id) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/knowledge/v1/knowledge/chunk.py b/twilio/rest/knowledge/v1/knowledge/chunk.py new file mode 100644 index 0000000000..55c0b1be1a --- /dev/null +++ b/twilio/rest/knowledge/v1/knowledge/chunk.py @@ -0,0 +1,297 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Knowledge + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from datetime import datetime +from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator +from twilio.base import deserialize, values + +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version +from twilio.base.page import Page + + +class ChunkInstance(InstanceResource): + """ + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Knowledge resource. + :ivar content: The chunk content. + :ivar metadata: The metadata of the chunk. + :ivar date_created: The date and time in GMT when the Chunk was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + :ivar date_updated: The date and time in GMT when the Chunk was updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + """ + + def __init__(self, version: Version, payload: Dict[str, Any], id: str): + super().__init__(version) + + self.account_sid: Optional[str] = payload.get("account_sid") + self.content: Optional[str] = payload.get("content") + self.metadata: Optional[Dict[str, object]] = payload.get("metadata") + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_created") + ) + self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_updated") + ) + + self._solution = { + "id": id, + } + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class ChunkPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> ChunkInstance: + """ + Build an instance of ChunkInstance + + :param payload: Payload response from the API + """ + return ChunkInstance(self._version, payload, id=self._solution["id"]) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class ChunkList(ListResource): + + def __init__(self, version: Version, id: str): + """ + Initialize the ChunkList + + :param version: Version that contains the resource + :param id: The knowledge ID. + + """ + super().__init__(version) + + # Path Solution + self._solution = { + "id": id, + } + self._uri = "/Knowledge/{id}/Chunks".format(**self._solution) + + def stream( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[ChunkInstance]: + """ + Streams ChunkInstance records from the API as a generator stream. + This operation lazily loads records as efficiently as possible until the limit + is reached. + The results are returned as a generator, so this operation is memory efficient. + + :param limit: Upper limit for the number of records to return. stream() + guarantees to never return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, stream() will attempt to read the + limit with the most efficient page size, i.e. min(limit, 1000) + + :returns: Generator that will yield up to limit results + """ + limits = self._version.read_limits(limit, page_size) + page = self.page(page_size=limits["page_size"]) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[ChunkInstance]: + """ + Asynchronously streams ChunkInstance records from the API as a generator stream. + This operation lazily loads records as efficiently as possible until the limit + is reached. + The results are returned as a generator, so this operation is memory efficient. + + :param limit: Upper limit for the number of records to return. stream() + guarantees to never return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, stream() will attempt to read the + limit with the most efficient page size, i.e. min(limit, 1000) + + :returns: Generator that will yield up to limit results + """ + limits = self._version.read_limits(limit, page_size) + page = await self.page_async(page_size=limits["page_size"]) + + return self._version.stream_async(page, limits["limit"]) + + def list( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[ChunkInstance]: + """ + Lists ChunkInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param limit: Upper limit for the number of records to return. list() guarantees + never to return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, list() will attempt to read the limit + with the most efficient page size, i.e. min(limit, 1000) + + :returns: list that will contain up to limit results + """ + return list( + self.stream( + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[ChunkInstance]: + """ + Asynchronously lists ChunkInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param limit: Upper limit for the number of records to return. list() guarantees + never to return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, list() will attempt to read the limit + with the most efficient page size, i.e. min(limit, 1000) + + :returns: list that will contain up to limit results + """ + return [ + record + async for record in await self.stream_async( + limit=limit, + page_size=page_size, + ) + ] + + def page( + self, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> ChunkPage: + """ + Retrieve a single page of ChunkInstance records from the API. + Request is executed immediately + + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: Page of ChunkInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return ChunkPage(self._version, response, self._solution) + + async def page_async( + self, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> ChunkPage: + """ + Asynchronously retrieve a single page of ChunkInstance records from the API. + Request is executed immediately + + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: Page of ChunkInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + return ChunkPage(self._version, response, self._solution) + + def get_page(self, target_url: str) -> ChunkPage: + """ + Retrieve a specific page of ChunkInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of ChunkInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return ChunkPage(self._version, response, self._solution) + + async def get_page_async(self, target_url: str) -> ChunkPage: + """ + Asynchronously retrieve a specific page of ChunkInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of ChunkInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return ChunkPage(self._version, response, self._solution) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/knowledge/v1/knowledge/knowledge_status.py b/twilio/rest/knowledge/v1/knowledge/knowledge_status.py new file mode 100644 index 0000000000..984c577aac --- /dev/null +++ b/twilio/rest/knowledge/v1/knowledge/knowledge_status.py @@ -0,0 +1,196 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Knowledge + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from datetime import datetime +from typing import Any, Dict, Optional +from twilio.base import deserialize, values +from twilio.base.instance_context import InstanceContext +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + + +class KnowledgeStatusInstance(InstanceResource): + """ + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Knowledge resource. + :ivar status: The status of processing the knowledge source ('QUEUED', 'PROCESSING', 'COMPLETED', 'FAILED') + :ivar last_status: The last status of processing the knowledge source ('QUEUED', 'PROCESSING', 'COMPLETED', 'FAILED') + :ivar date_updated: The date and time in GMT when the Knowledge was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + """ + + def __init__(self, version: Version, payload: Dict[str, Any], id: str): + super().__init__(version) + + self.account_sid: Optional[str] = payload.get("account_sid") + self.status: Optional[str] = payload.get("status") + self.last_status: Optional[str] = payload.get("last_status") + self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_updated") + ) + + self._solution = { + "id": id, + } + self._context: Optional[KnowledgeStatusContext] = None + + @property + def _proxy(self) -> "KnowledgeStatusContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: KnowledgeStatusContext for this KnowledgeStatusInstance + """ + if self._context is None: + self._context = KnowledgeStatusContext( + self._version, + id=self._solution["id"], + ) + return self._context + + def fetch(self) -> "KnowledgeStatusInstance": + """ + Fetch the KnowledgeStatusInstance + + + :returns: The fetched KnowledgeStatusInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "KnowledgeStatusInstance": + """ + Asynchronous coroutine to fetch the KnowledgeStatusInstance + + + :returns: The fetched KnowledgeStatusInstance + """ + return await self._proxy.fetch_async() + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class KnowledgeStatusContext(InstanceContext): + + def __init__(self, version: Version, id: str): + """ + Initialize the KnowledgeStatusContext + + :param version: Version that contains the resource + :param id: the Knowledge ID. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "id": id, + } + self._uri = "/Knowledge/{id}/Status".format(**self._solution) + + def fetch(self) -> KnowledgeStatusInstance: + """ + Fetch the KnowledgeStatusInstance + + + :returns: The fetched KnowledgeStatusInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return KnowledgeStatusInstance( + self._version, + payload, + id=self._solution["id"], + ) + + async def fetch_async(self) -> KnowledgeStatusInstance: + """ + Asynchronous coroutine to fetch the KnowledgeStatusInstance + + + :returns: The fetched KnowledgeStatusInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + return KnowledgeStatusInstance( + self._version, + payload, + id=self._solution["id"], + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class KnowledgeStatusList(ListResource): + + def __init__(self, version: Version, id: str): + """ + Initialize the KnowledgeStatusList + + :param version: Version that contains the resource + :param id: the Knowledge ID. + + """ + super().__init__(version) + + # Path Solution + self._solution = { + "id": id, + } + + def get(self) -> KnowledgeStatusContext: + """ + Constructs a KnowledgeStatusContext + + """ + return KnowledgeStatusContext(self._version, id=self._solution["id"]) + + def __call__(self) -> KnowledgeStatusContext: + """ + Constructs a KnowledgeStatusContext + + """ + return KnowledgeStatusContext(self._version, id=self._solution["id"]) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/lookups/v1/phone_number.py b/twilio/rest/lookups/v1/phone_number.py index fe521c73e9..304b89ab15 100644 --- a/twilio/rest/lookups/v1/phone_number.py +++ b/twilio/rest/lookups/v1/phone_number.py @@ -78,7 +78,7 @@ def fetch( Fetch the PhoneNumberInstance :param country_code: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the phone number to fetch. This is used to specify the country when the phone number is provided in a national format. - :param type: The type of information to return. Can be: `carrier` or `caller-name`. The default is null. Carrier information costs $0.005 per phone number looked up. Caller Name information is currently available only in the US and costs $0.01 per phone number looked up. To retrieve both types on information, specify this parameter twice; once with `carrier` and once with `caller-name` as the value. + :param type: The type of information to return. Can be: `carrier` or `caller-name`. The default is null. To retrieve both types of information, specify this parameter twice; once with `carrier` and once with `caller-name` as the value. :param add_ons: The `unique_name` of an Add-on you would like to invoke. Can be the `unique_name` of an Add-on that is installed on your account. You can specify multiple instances of this parameter to invoke multiple Add-ons. For more information about Add-ons, see the [Add-ons documentation](https://www.twilio.com/docs/add-ons). :param add_ons_data: Data specific to the add-on you would like to invoke. The content and format of this value depends on the add-on. @@ -102,7 +102,7 @@ async def fetch_async( Asynchronous coroutine to fetch the PhoneNumberInstance :param country_code: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the phone number to fetch. This is used to specify the country when the phone number is provided in a national format. - :param type: The type of information to return. Can be: `carrier` or `caller-name`. The default is null. Carrier information costs $0.005 per phone number looked up. Caller Name information is currently available only in the US and costs $0.01 per phone number looked up. To retrieve both types on information, specify this parameter twice; once with `carrier` and once with `caller-name` as the value. + :param type: The type of information to return. Can be: `carrier` or `caller-name`. The default is null. To retrieve both types of information, specify this parameter twice; once with `carrier` and once with `caller-name` as the value. :param add_ons: The `unique_name` of an Add-on you would like to invoke. Can be the `unique_name` of an Add-on that is installed on your account. You can specify multiple instances of this parameter to invoke multiple Add-ons. For more information about Add-ons, see the [Add-ons documentation](https://www.twilio.com/docs/add-ons). :param add_ons_data: Data specific to the add-on you would like to invoke. The content and format of this value depends on the add-on. @@ -153,7 +153,7 @@ def fetch( Fetch the PhoneNumberInstance :param country_code: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the phone number to fetch. This is used to specify the country when the phone number is provided in a national format. - :param type: The type of information to return. Can be: `carrier` or `caller-name`. The default is null. Carrier information costs $0.005 per phone number looked up. Caller Name information is currently available only in the US and costs $0.01 per phone number looked up. To retrieve both types on information, specify this parameter twice; once with `carrier` and once with `caller-name` as the value. + :param type: The type of information to return. Can be: `carrier` or `caller-name`. The default is null. To retrieve both types of information, specify this parameter twice; once with `carrier` and once with `caller-name` as the value. :param add_ons: The `unique_name` of an Add-on you would like to invoke. Can be the `unique_name` of an Add-on that is installed on your account. You can specify multiple instances of this parameter to invoke multiple Add-ons. For more information about Add-ons, see the [Add-ons documentation](https://www.twilio.com/docs/add-ons). :param add_ons_data: Data specific to the add-on you would like to invoke. The content and format of this value depends on the add-on. @@ -167,9 +167,16 @@ def fetch( "AddOns": serialize.map(add_ons, lambda e: e), } ) + data.update(serialize.prefixed_collapsible_map(add_ons_data, "AddOns")) - payload = self._version.fetch(method="GET", uri=self._uri, params=data) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) return PhoneNumberInstance( self._version, @@ -188,7 +195,7 @@ async def fetch_async( Asynchronous coroutine to fetch the PhoneNumberInstance :param country_code: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the phone number to fetch. This is used to specify the country when the phone number is provided in a national format. - :param type: The type of information to return. Can be: `carrier` or `caller-name`. The default is null. Carrier information costs $0.005 per phone number looked up. Caller Name information is currently available only in the US and costs $0.01 per phone number looked up. To retrieve both types on information, specify this parameter twice; once with `carrier` and once with `caller-name` as the value. + :param type: The type of information to return. Can be: `carrier` or `caller-name`. The default is null. To retrieve both types of information, specify this parameter twice; once with `carrier` and once with `caller-name` as the value. :param add_ons: The `unique_name` of an Add-on you would like to invoke. Can be the `unique_name` of an Add-on that is installed on your account. You can specify multiple instances of this parameter to invoke multiple Add-ons. For more information about Add-ons, see the [Add-ons documentation](https://www.twilio.com/docs/add-ons). :param add_ons_data: Data specific to the add-on you would like to invoke. The content and format of this value depends on the add-on. @@ -202,10 +209,15 @@ async def fetch_async( "AddOns": serialize.map(add_ons, lambda e: e), } ) + data.update(serialize.prefixed_collapsible_map(add_ons_data, "AddOns")) + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return PhoneNumberInstance( diff --git a/twilio/rest/lookups/v2/phone_number.py b/twilio/rest/lookups/v2/phone_number.py index 57491aa0a9..fc60eed6d3 100644 --- a/twilio/rest/lookups/v2/phone_number.py +++ b/twilio/rest/lookups/v2/phone_number.py @@ -46,6 +46,7 @@ class ValidationError(object): :ivar reassigned_number: An object that contains reassigned number information. Reassigned Numbers will return a phone number's reassignment status given a phone number and date :ivar sms_pumping_risk: An object that contains information on if a phone number has been currently or previously blocked by Verify Fraud Guard for receiving malicious SMS pumping traffic as well as other signals associated with risky carriers and low conversion rates. :ivar phone_number_quality_score: An object that contains information of a mobile phone number quality score. Quality score will return a risk score about the phone number. + :ivar pre_fill: An object that contains pre fill information. pre_fill will return PII information associated with the phone number like first name, last name, address line, country code, state and postal code. :ivar url: The absolute URL of the resource. """ @@ -84,6 +85,7 @@ def __init__( self.phone_number_quality_score: Optional[Dict[str, object]] = payload.get( "phone_number_quality_score" ) + self.pre_fill: Optional[Dict[str, object]] = payload.get("pre_fill") self.url: Optional[str] = payload.get("url") self._solution = { @@ -121,11 +123,13 @@ def fetch( national_id: Union[str, object] = values.unset, date_of_birth: Union[str, object] = values.unset, last_verified_date: Union[str, object] = values.unset, + verification_sid: Union[str, object] = values.unset, + partner_sub_id: Union[str, object] = values.unset, ) -> "PhoneNumberInstance": """ Fetch the PhoneNumberInstance - :param fields: A comma-separated list of fields to return. Possible values are validation, caller_name, sim_swap, call_forwarding, line_status, line_type_intelligence, identity_match, reassigned_number, sms_pumping_risk, phone_number_quality_score. + :param fields: A comma-separated list of fields to return. Possible values are validation, caller_name, sim_swap, call_forwarding, line_status, line_type_intelligence, identity_match, reassigned_number, sms_pumping_risk, phone_number_quality_score, pre_fill. :param country_code: The [country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) used if the phone number provided is in national format. :param first_name: User’s first name. This query parameter is only used (optionally) for identity_match package requests. :param last_name: User’s last name. This query parameter is only used (optionally) for identity_match package requests. @@ -138,6 +142,8 @@ def fetch( :param national_id: User’s national ID, such as SSN or Passport ID. This query parameter is only used (optionally) for identity_match package requests. :param date_of_birth: User’s date of birth, in YYYYMMDD format. This query parameter is only used (optionally) for identity_match package requests. :param last_verified_date: The date you obtained consent to call or text the end-user of the phone number or a date on which you are reasonably certain that the end-user could still be reached at that number. This query parameter is only used (optionally) for reassigned_number package requests. + :param verification_sid: The unique identifier associated with a verification process through verify API. This query parameter is only used (optionally) for pre_fill package requests. + :param partner_sub_id: The optional partnerSubId parameter to provide context for your sub-accounts, tenantIDs, sender IDs or other segmentation, enhancing the accuracy of the risk analysis. :returns: The fetched PhoneNumberInstance """ @@ -155,6 +161,8 @@ def fetch( national_id=national_id, date_of_birth=date_of_birth, last_verified_date=last_verified_date, + verification_sid=verification_sid, + partner_sub_id=partner_sub_id, ) async def fetch_async( @@ -172,11 +180,13 @@ async def fetch_async( national_id: Union[str, object] = values.unset, date_of_birth: Union[str, object] = values.unset, last_verified_date: Union[str, object] = values.unset, + verification_sid: Union[str, object] = values.unset, + partner_sub_id: Union[str, object] = values.unset, ) -> "PhoneNumberInstance": """ Asynchronous coroutine to fetch the PhoneNumberInstance - :param fields: A comma-separated list of fields to return. Possible values are validation, caller_name, sim_swap, call_forwarding, line_status, line_type_intelligence, identity_match, reassigned_number, sms_pumping_risk, phone_number_quality_score. + :param fields: A comma-separated list of fields to return. Possible values are validation, caller_name, sim_swap, call_forwarding, line_status, line_type_intelligence, identity_match, reassigned_number, sms_pumping_risk, phone_number_quality_score, pre_fill. :param country_code: The [country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) used if the phone number provided is in national format. :param first_name: User’s first name. This query parameter is only used (optionally) for identity_match package requests. :param last_name: User’s last name. This query parameter is only used (optionally) for identity_match package requests. @@ -189,6 +199,8 @@ async def fetch_async( :param national_id: User’s national ID, such as SSN or Passport ID. This query parameter is only used (optionally) for identity_match package requests. :param date_of_birth: User’s date of birth, in YYYYMMDD format. This query parameter is only used (optionally) for identity_match package requests. :param last_verified_date: The date you obtained consent to call or text the end-user of the phone number or a date on which you are reasonably certain that the end-user could still be reached at that number. This query parameter is only used (optionally) for reassigned_number package requests. + :param verification_sid: The unique identifier associated with a verification process through verify API. This query parameter is only used (optionally) for pre_fill package requests. + :param partner_sub_id: The optional partnerSubId parameter to provide context for your sub-accounts, tenantIDs, sender IDs or other segmentation, enhancing the accuracy of the risk analysis. :returns: The fetched PhoneNumberInstance """ @@ -206,6 +218,8 @@ async def fetch_async( national_id=national_id, date_of_birth=date_of_birth, last_verified_date=last_verified_date, + verification_sid=verification_sid, + partner_sub_id=partner_sub_id, ) def __repr__(self) -> str: @@ -250,11 +264,13 @@ def fetch( national_id: Union[str, object] = values.unset, date_of_birth: Union[str, object] = values.unset, last_verified_date: Union[str, object] = values.unset, + verification_sid: Union[str, object] = values.unset, + partner_sub_id: Union[str, object] = values.unset, ) -> PhoneNumberInstance: """ Fetch the PhoneNumberInstance - :param fields: A comma-separated list of fields to return. Possible values are validation, caller_name, sim_swap, call_forwarding, line_status, line_type_intelligence, identity_match, reassigned_number, sms_pumping_risk, phone_number_quality_score. + :param fields: A comma-separated list of fields to return. Possible values are validation, caller_name, sim_swap, call_forwarding, line_status, line_type_intelligence, identity_match, reassigned_number, sms_pumping_risk, phone_number_quality_score, pre_fill. :param country_code: The [country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) used if the phone number provided is in national format. :param first_name: User’s first name. This query parameter is only used (optionally) for identity_match package requests. :param last_name: User’s last name. This query parameter is only used (optionally) for identity_match package requests. @@ -267,6 +283,8 @@ def fetch( :param national_id: User’s national ID, such as SSN or Passport ID. This query parameter is only used (optionally) for identity_match package requests. :param date_of_birth: User’s date of birth, in YYYYMMDD format. This query parameter is only used (optionally) for identity_match package requests. :param last_verified_date: The date you obtained consent to call or text the end-user of the phone number or a date on which you are reasonably certain that the end-user could still be reached at that number. This query parameter is only used (optionally) for reassigned_number package requests. + :param verification_sid: The unique identifier associated with a verification process through verify API. This query parameter is only used (optionally) for pre_fill package requests. + :param partner_sub_id: The optional partnerSubId parameter to provide context for your sub-accounts, tenantIDs, sender IDs or other segmentation, enhancing the accuracy of the risk analysis. :returns: The fetched PhoneNumberInstance """ @@ -286,10 +304,18 @@ def fetch( "NationalId": national_id, "DateOfBirth": date_of_birth, "LastVerifiedDate": last_verified_date, + "VerificationSid": verification_sid, + "PartnerSubId": partner_sub_id, } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=data) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) return PhoneNumberInstance( self._version, @@ -312,11 +338,13 @@ async def fetch_async( national_id: Union[str, object] = values.unset, date_of_birth: Union[str, object] = values.unset, last_verified_date: Union[str, object] = values.unset, + verification_sid: Union[str, object] = values.unset, + partner_sub_id: Union[str, object] = values.unset, ) -> PhoneNumberInstance: """ Asynchronous coroutine to fetch the PhoneNumberInstance - :param fields: A comma-separated list of fields to return. Possible values are validation, caller_name, sim_swap, call_forwarding, line_status, line_type_intelligence, identity_match, reassigned_number, sms_pumping_risk, phone_number_quality_score. + :param fields: A comma-separated list of fields to return. Possible values are validation, caller_name, sim_swap, call_forwarding, line_status, line_type_intelligence, identity_match, reassigned_number, sms_pumping_risk, phone_number_quality_score, pre_fill. :param country_code: The [country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) used if the phone number provided is in national format. :param first_name: User’s first name. This query parameter is only used (optionally) for identity_match package requests. :param last_name: User’s last name. This query parameter is only used (optionally) for identity_match package requests. @@ -329,6 +357,8 @@ async def fetch_async( :param national_id: User’s national ID, such as SSN or Passport ID. This query parameter is only used (optionally) for identity_match package requests. :param date_of_birth: User’s date of birth, in YYYYMMDD format. This query parameter is only used (optionally) for identity_match package requests. :param last_verified_date: The date you obtained consent to call or text the end-user of the phone number or a date on which you are reasonably certain that the end-user could still be reached at that number. This query parameter is only used (optionally) for reassigned_number package requests. + :param verification_sid: The unique identifier associated with a verification process through verify API. This query parameter is only used (optionally) for pre_fill package requests. + :param partner_sub_id: The optional partnerSubId parameter to provide context for your sub-accounts, tenantIDs, sender IDs or other segmentation, enhancing the accuracy of the risk analysis. :returns: The fetched PhoneNumberInstance """ @@ -348,11 +378,17 @@ async def fetch_async( "NationalId": national_id, "DateOfBirth": date_of_birth, "LastVerifiedDate": last_verified_date, + "VerificationSid": verification_sid, + "PartnerSubId": partner_sub_id, } ) + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return PhoneNumberInstance( diff --git a/twilio/rest/marketplace/MarketplaceBase.py b/twilio/rest/marketplace/MarketplaceBase.py new file mode 100644 index 0000000000..9fbe193d99 --- /dev/null +++ b/twilio/rest/marketplace/MarketplaceBase.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.marketplace.v1 import V1 + + +class MarketplaceBase(Domain): + + def __init__(self, twilio: Client): + """ + Initialize the Marketplace Domain + + :returns: Domain for Marketplace + """ + super().__init__(twilio, "https://marketplace.twilio.com") + self._v1: Optional[V1] = None + + @property + def v1(self) -> V1: + """ + :returns: Versions v1 of Marketplace + """ + 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/marketplace/__init__.py b/twilio/rest/marketplace/__init__.py new file mode 100644 index 0000000000..f0276a8f84 --- /dev/null +++ b/twilio/rest/marketplace/__init__.py @@ -0,0 +1,9 @@ +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 diff --git a/twilio/rest/marketplace/v1/__init__.py b/twilio/rest/marketplace/v1/__init__.py new file mode 100644 index 0000000000..6a84b31cd9 --- /dev/null +++ b/twilio/rest/marketplace/v1/__init__.py @@ -0,0 +1,75 @@ +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 Optional +from twilio.base.version import Version +from twilio.base.domain import Domain +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 import ModuleDataList +from twilio.rest.marketplace.v1.module_data_management import ModuleDataManagementList +from twilio.rest.marketplace.v1.referral_conversion import ReferralConversionList + + +class V1(Version): + + def __init__(self, domain: Domain): + """ + Initialize the V1 version of Marketplace + + :param domain: The Twilio.marketplace domain + """ + super().__init__(domain, "v1") + self._available_add_ons: Optional[AvailableAddOnList] = None + self._installed_add_ons: Optional[InstalledAddOnList] = None + self._module_data: Optional[ModuleDataList] = None + self._module_data_management: Optional[ModuleDataManagementList] = None + self._referral_conversion: Optional[ReferralConversionList] = None + + @property + def available_add_ons(self) -> AvailableAddOnList: + if self._available_add_ons is None: + self._available_add_ons = AvailableAddOnList(self) + return self._available_add_ons + + @property + def installed_add_ons(self) -> InstalledAddOnList: + if self._installed_add_ons is None: + self._installed_add_ons = InstalledAddOnList(self) + return self._installed_add_ons + + @property + def module_data(self) -> ModuleDataList: + if self._module_data is None: + self._module_data = ModuleDataList(self) + return self._module_data + + @property + def module_data_management(self) -> ModuleDataManagementList: + if self._module_data_management is None: + 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 + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/marketplace/v1/available_add_on/__init__.py b/twilio/rest/marketplace/v1/available_add_on/__init__.py new file mode 100644 index 0000000000..297d5dd6f3 --- /dev/null +++ b/twilio/rest/marketplace/v1/available_add_on/__init__.py @@ -0,0 +1,438 @@ +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, 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 +from twilio.rest.marketplace.v1.available_add_on.available_add_on_extension import ( + AvailableAddOnExtensionList, +) + + +class AvailableAddOnInstance(InstanceResource): + """ + :ivar sid: The unique string that we created to identify the AvailableAddOn resource. + :ivar friendly_name: The string that you assigned to describe the resource. + :ivar description: A short description of the Add-on's functionality. + :ivar pricing_type: How customers are charged for using this Add-on. + :ivar configuration_schema: The JSON object with the configuration that must be provided when installing a given Add-on. + :ivar url: The absolute URL of the resource. + :ivar links: The URLs of related resources. + """ + + 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.description: Optional[str] = payload.get("description") + self.pricing_type: Optional[str] = payload.get("pricing_type") + self.configuration_schema: Optional[Dict[str, object]] = payload.get( + "configuration_schema" + ) + self.url: Optional[str] = payload.get("url") + self.links: Optional[Dict[str, object]] = payload.get("links") + + self._solution = { + "sid": sid or self.sid, + } + self._context: Optional[AvailableAddOnContext] = None + + @property + def _proxy(self) -> "AvailableAddOnContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: AvailableAddOnContext for this AvailableAddOnInstance + """ + if self._context is None: + self._context = AvailableAddOnContext( + self._version, + sid=self._solution["sid"], + ) + return self._context + + def fetch(self) -> "AvailableAddOnInstance": + """ + Fetch the AvailableAddOnInstance + + + :returns: The fetched AvailableAddOnInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "AvailableAddOnInstance": + """ + Asynchronous coroutine to fetch the AvailableAddOnInstance + + + :returns: The fetched AvailableAddOnInstance + """ + return await self._proxy.fetch_async() + + @property + def extensions(self) -> AvailableAddOnExtensionList: + """ + Access the extensions + """ + return self._proxy.extensions + + 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 AvailableAddOnContext(InstanceContext): + + def __init__(self, version: Version, sid: str): + """ + Initialize the AvailableAddOnContext + + :param version: Version that contains the resource + :param sid: The SID of the AvailableAddOn resource to fetch. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "sid": sid, + } + self._uri = "/AvailableAddOns/{sid}".format(**self._solution) + + self._extensions: Optional[AvailableAddOnExtensionList] = None + + def fetch(self) -> AvailableAddOnInstance: + """ + Fetch the AvailableAddOnInstance + + + :returns: The fetched AvailableAddOnInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return AvailableAddOnInstance( + self._version, + payload, + sid=self._solution["sid"], + ) + + async def fetch_async(self) -> AvailableAddOnInstance: + """ + Asynchronous coroutine to fetch the AvailableAddOnInstance + + + :returns: The fetched AvailableAddOnInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + return AvailableAddOnInstance( + self._version, + payload, + sid=self._solution["sid"], + ) + + @property + def extensions(self) -> AvailableAddOnExtensionList: + """ + Access the extensions + """ + if self._extensions is None: + self._extensions = AvailableAddOnExtensionList( + self._version, + self._solution["sid"], + ) + return self._extensions + + 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 AvailableAddOnPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> AvailableAddOnInstance: + """ + Build an instance of AvailableAddOnInstance + + :param payload: Payload response from the API + """ + return AvailableAddOnInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class AvailableAddOnList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the AvailableAddOnList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/AvailableAddOns" + + def stream( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[AvailableAddOnInstance]: + """ + Streams AvailableAddOnInstance 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[AvailableAddOnInstance]: + """ + Asynchronously streams AvailableAddOnInstance 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[AvailableAddOnInstance]: + """ + Lists AvailableAddOnInstance 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[AvailableAddOnInstance]: + """ + Asynchronously lists AvailableAddOnInstance 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, + ) -> AvailableAddOnPage: + """ + Retrieve a single page of AvailableAddOnInstance 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 AvailableAddOnInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return AvailableAddOnPage(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, + ) -> AvailableAddOnPage: + """ + Asynchronously retrieve a single page of AvailableAddOnInstance 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 AvailableAddOnInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + return AvailableAddOnPage(self._version, response) + + def get_page(self, target_url: str) -> AvailableAddOnPage: + """ + Retrieve a specific page of AvailableAddOnInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of AvailableAddOnInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return AvailableAddOnPage(self._version, response) + + async def get_page_async(self, target_url: str) -> AvailableAddOnPage: + """ + Asynchronously retrieve a specific page of AvailableAddOnInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of AvailableAddOnInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return AvailableAddOnPage(self._version, response) + + def get(self, sid: str) -> AvailableAddOnContext: + """ + Constructs a AvailableAddOnContext + + :param sid: The SID of the AvailableAddOn resource to fetch. + """ + return AvailableAddOnContext(self._version, sid=sid) + + def __call__(self, sid: str) -> AvailableAddOnContext: + """ + Constructs a AvailableAddOnContext + + :param sid: The SID of the AvailableAddOn resource to fetch. + """ + return AvailableAddOnContext(self._version, sid=sid) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/marketplace/v1/available_add_on/available_add_on_extension.py b/twilio/rest/marketplace/v1/available_add_on/available_add_on_extension.py new file mode 100644 index 0000000000..a8973a08b0 --- /dev/null +++ b/twilio/rest/marketplace/v1/available_add_on/available_add_on_extension.py @@ -0,0 +1,445 @@ +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, 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 AvailableAddOnExtensionInstance(InstanceResource): + """ + :ivar sid: The unique string that we created to identify the AvailableAddOnExtension resource. + :ivar available_add_on_sid: The SID of the AvailableAddOn resource to which this extension applies. + :ivar friendly_name: The string that you assigned to describe the resource. + :ivar product_name: The name of the Product this Extension is used within. + :ivar unique_name: An application-defined string that uniquely identifies the resource. + :ivar url: The absolute URL of the resource. + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + available_add_on_sid: str, + sid: Optional[str] = None, + ): + super().__init__(version) + + self.sid: Optional[str] = payload.get("sid") + self.available_add_on_sid: Optional[str] = payload.get("available_add_on_sid") + self.friendly_name: Optional[str] = payload.get("friendly_name") + self.product_name: Optional[str] = payload.get("product_name") + self.unique_name: Optional[str] = payload.get("unique_name") + self.url: Optional[str] = payload.get("url") + + self._solution = { + "available_add_on_sid": available_add_on_sid, + "sid": sid or self.sid, + } + self._context: Optional[AvailableAddOnExtensionContext] = None + + @property + def _proxy(self) -> "AvailableAddOnExtensionContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: AvailableAddOnExtensionContext for this AvailableAddOnExtensionInstance + """ + if self._context is None: + self._context = AvailableAddOnExtensionContext( + self._version, + available_add_on_sid=self._solution["available_add_on_sid"], + sid=self._solution["sid"], + ) + return self._context + + def fetch(self) -> "AvailableAddOnExtensionInstance": + """ + Fetch the AvailableAddOnExtensionInstance + + + :returns: The fetched AvailableAddOnExtensionInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "AvailableAddOnExtensionInstance": + """ + Asynchronous coroutine to fetch the AvailableAddOnExtensionInstance + + + :returns: The fetched AvailableAddOnExtensionInstance + """ + 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 AvailableAddOnExtensionContext(InstanceContext): + + def __init__(self, version: Version, available_add_on_sid: str, sid: str): + """ + Initialize the AvailableAddOnExtensionContext + + :param version: Version that contains the resource + :param available_add_on_sid: The SID of the AvailableAddOn resource with the extension to fetch. + :param sid: The SID of the AvailableAddOn Extension resource to fetch. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "available_add_on_sid": available_add_on_sid, + "sid": sid, + } + self._uri = "/AvailableAddOns/{available_add_on_sid}/Extensions/{sid}".format( + **self._solution + ) + + def fetch(self) -> AvailableAddOnExtensionInstance: + """ + Fetch the AvailableAddOnExtensionInstance + + + :returns: The fetched AvailableAddOnExtensionInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return AvailableAddOnExtensionInstance( + self._version, + payload, + available_add_on_sid=self._solution["available_add_on_sid"], + sid=self._solution["sid"], + ) + + async def fetch_async(self) -> AvailableAddOnExtensionInstance: + """ + Asynchronous coroutine to fetch the AvailableAddOnExtensionInstance + + + :returns: The fetched AvailableAddOnExtensionInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + return AvailableAddOnExtensionInstance( + self._version, + payload, + available_add_on_sid=self._solution["available_add_on_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 AvailableAddOnExtensionPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> AvailableAddOnExtensionInstance: + """ + Build an instance of AvailableAddOnExtensionInstance + + :param payload: Payload response from the API + """ + return AvailableAddOnExtensionInstance( + self._version, + payload, + available_add_on_sid=self._solution["available_add_on_sid"], + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class AvailableAddOnExtensionList(ListResource): + + def __init__(self, version: Version, available_add_on_sid: str): + """ + Initialize the AvailableAddOnExtensionList + + :param version: Version that contains the resource + :param available_add_on_sid: The SID of the AvailableAddOn resource with the extensions to read. + + """ + super().__init__(version) + + # Path Solution + self._solution = { + "available_add_on_sid": available_add_on_sid, + } + self._uri = "/AvailableAddOns/{available_add_on_sid}/Extensions".format( + **self._solution + ) + + def stream( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[AvailableAddOnExtensionInstance]: + """ + Streams AvailableAddOnExtensionInstance 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[AvailableAddOnExtensionInstance]: + """ + Asynchronously streams AvailableAddOnExtensionInstance 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[AvailableAddOnExtensionInstance]: + """ + Lists AvailableAddOnExtensionInstance 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[AvailableAddOnExtensionInstance]: + """ + Asynchronously lists AvailableAddOnExtensionInstance 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, + ) -> AvailableAddOnExtensionPage: + """ + Retrieve a single page of AvailableAddOnExtensionInstance 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 AvailableAddOnExtensionInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return AvailableAddOnExtensionPage(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, + ) -> AvailableAddOnExtensionPage: + """ + Asynchronously retrieve a single page of AvailableAddOnExtensionInstance 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 AvailableAddOnExtensionInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + return AvailableAddOnExtensionPage(self._version, response, self._solution) + + def get_page(self, target_url: str) -> AvailableAddOnExtensionPage: + """ + Retrieve a specific page of AvailableAddOnExtensionInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of AvailableAddOnExtensionInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return AvailableAddOnExtensionPage(self._version, response, self._solution) + + async def get_page_async(self, target_url: str) -> AvailableAddOnExtensionPage: + """ + Asynchronously retrieve a specific page of AvailableAddOnExtensionInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of AvailableAddOnExtensionInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return AvailableAddOnExtensionPage(self._version, response, self._solution) + + def get(self, sid: str) -> AvailableAddOnExtensionContext: + """ + Constructs a AvailableAddOnExtensionContext + + :param sid: The SID of the AvailableAddOn Extension resource to fetch. + """ + return AvailableAddOnExtensionContext( + self._version, + available_add_on_sid=self._solution["available_add_on_sid"], + sid=sid, + ) + + def __call__(self, sid: str) -> AvailableAddOnExtensionContext: + """ + Constructs a AvailableAddOnExtensionContext + + :param sid: The SID of the AvailableAddOn Extension resource to fetch. + """ + return AvailableAddOnExtensionContext( + self._version, + available_add_on_sid=self._solution["available_add_on_sid"], + sid=sid, + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/marketplace/v1/installed_add_on/__init__.py b/twilio/rest/marketplace/v1/installed_add_on/__init__.py new file mode 100644 index 0000000000..8fedfb9b41 --- /dev/null +++ b/twilio/rest/marketplace/v1/installed_add_on/__init__.py @@ -0,0 +1,694 @@ +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 datetime import datetime +from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator +from twilio.base import deserialize, serialize, values +from twilio.base.instance_context import InstanceContext +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version +from twilio.base.page import Page +from twilio.rest.marketplace.v1.installed_add_on.installed_add_on_extension import ( + InstalledAddOnExtensionList, +) +from twilio.rest.marketplace.v1.installed_add_on.installed_add_on_usage import ( + InstalledAddOnUsageList, +) + + +class InstalledAddOnInstance(InstanceResource): + """ + :ivar sid: The unique string that we created to identify the InstalledAddOn resource. This Sid can also be found in the Console on that specific Add-ons page as the 'Available Add-on Sid'. + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the InstalledAddOn resource. + :ivar friendly_name: The string that you assigned to describe the resource. + :ivar description: A short description of the Add-on's functionality. + :ivar configuration: The JSON object that represents the current configuration of installed Add-on. + :ivar unique_name: An application-defined string that uniquely identifies the resource. + :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 absolute URL of the resource. + :ivar links: The URLs of related resources. + """ + + def __init__( + self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None + ): + super().__init__(version) + + self.sid: Optional[str] = payload.get("sid") + self.account_sid: Optional[str] = payload.get("account_sid") + self.friendly_name: Optional[str] = payload.get("friendly_name") + self.description: Optional[str] = payload.get("description") + self.configuration: Optional[Dict[str, object]] = payload.get("configuration") + self.unique_name: Optional[str] = payload.get("unique_name") + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_created") + ) + self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_updated") + ) + self.url: Optional[str] = payload.get("url") + self.links: Optional[Dict[str, object]] = payload.get("links") + + self._solution = { + "sid": sid or self.sid, + } + self._context: Optional[InstalledAddOnContext] = None + + @property + def _proxy(self) -> "InstalledAddOnContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: InstalledAddOnContext for this InstalledAddOnInstance + """ + if self._context is None: + self._context = InstalledAddOnContext( + self._version, + sid=self._solution["sid"], + ) + return self._context + + def delete(self) -> bool: + """ + Deletes the InstalledAddOnInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._proxy.delete() + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the InstalledAddOnInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._proxy.delete_async() + + def fetch(self) -> "InstalledAddOnInstance": + """ + Fetch the InstalledAddOnInstance + + + :returns: The fetched InstalledAddOnInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "InstalledAddOnInstance": + """ + Asynchronous coroutine to fetch the InstalledAddOnInstance + + + :returns: The fetched InstalledAddOnInstance + """ + return await self._proxy.fetch_async() + + def update( + self, + configuration: Union[object, object] = values.unset, + unique_name: Union[str, object] = values.unset, + ) -> "InstalledAddOnInstance": + """ + Update the InstalledAddOnInstance + + :param configuration: Valid JSON object that conform to the configuration schema exposed by the associated AvailableAddOn resource. This is only required by Add-ons that need to be configured + :param unique_name: An application-defined string that uniquely identifies the resource. This value must be unique within the Account. + + :returns: The updated InstalledAddOnInstance + """ + return self._proxy.update( + configuration=configuration, + unique_name=unique_name, + ) + + async def update_async( + self, + configuration: Union[object, object] = values.unset, + unique_name: Union[str, object] = values.unset, + ) -> "InstalledAddOnInstance": + """ + Asynchronous coroutine to update the InstalledAddOnInstance + + :param configuration: Valid JSON object that conform to the configuration schema exposed by the associated AvailableAddOn resource. This is only required by Add-ons that need to be configured + :param unique_name: An application-defined string that uniquely identifies the resource. This value must be unique within the Account. + + :returns: The updated InstalledAddOnInstance + """ + return await self._proxy.update_async( + configuration=configuration, + unique_name=unique_name, + ) + + @property + def extensions(self) -> InstalledAddOnExtensionList: + """ + Access the extensions + """ + return self._proxy.extensions + + @property + def usage(self) -> InstalledAddOnUsageList: + """ + Access the usage + """ + return self._proxy.usage + + 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 InstalledAddOnContext(InstanceContext): + + def __init__(self, version: Version, sid: str): + """ + Initialize the InstalledAddOnContext + + :param version: Version that contains the resource + :param sid: The SID of the InstalledAddOn resource to update. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "sid": sid, + } + self._uri = "/InstalledAddOns/{sid}".format(**self._solution) + + self._extensions: Optional[InstalledAddOnExtensionList] = None + self._usage: Optional[InstalledAddOnUsageList] = None + + def delete(self) -> bool: + """ + Deletes the InstalledAddOnInstance + + + :returns: True if delete succeeds, False otherwise + """ + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the InstalledAddOnInstance + + + :returns: True if delete succeeds, False otherwise + """ + + headers = values.of({}) + + return await self._version.delete_async( + method="DELETE", uri=self._uri, headers=headers + ) + + def fetch(self) -> InstalledAddOnInstance: + """ + Fetch the InstalledAddOnInstance + + + :returns: The fetched InstalledAddOnInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return InstalledAddOnInstance( + self._version, + payload, + sid=self._solution["sid"], + ) + + async def fetch_async(self) -> InstalledAddOnInstance: + """ + Asynchronous coroutine to fetch the InstalledAddOnInstance + + + :returns: The fetched InstalledAddOnInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + return InstalledAddOnInstance( + self._version, + payload, + sid=self._solution["sid"], + ) + + def update( + self, + configuration: Union[object, object] = values.unset, + unique_name: Union[str, object] = values.unset, + ) -> InstalledAddOnInstance: + """ + Update the InstalledAddOnInstance + + :param configuration: Valid JSON object that conform to the configuration schema exposed by the associated AvailableAddOn resource. This is only required by Add-ons that need to be configured + :param unique_name: An application-defined string that uniquely identifies the resource. This value must be unique within the Account. + + :returns: The updated InstalledAddOnInstance + """ + + data = values.of( + { + "Configuration": serialize.object(configuration), + "UniqueName": unique_name, + } + ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = self._version.update( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return InstalledAddOnInstance(self._version, payload, sid=self._solution["sid"]) + + async def update_async( + self, + configuration: Union[object, object] = values.unset, + unique_name: Union[str, object] = values.unset, + ) -> InstalledAddOnInstance: + """ + Asynchronous coroutine to update the InstalledAddOnInstance + + :param configuration: Valid JSON object that conform to the configuration schema exposed by the associated AvailableAddOn resource. This is only required by Add-ons that need to be configured + :param unique_name: An application-defined string that uniquely identifies the resource. This value must be unique within the Account. + + :returns: The updated InstalledAddOnInstance + """ + + data = values.of( + { + "Configuration": serialize.object(configuration), + "UniqueName": unique_name, + } + ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = await self._version.update_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return InstalledAddOnInstance(self._version, payload, sid=self._solution["sid"]) + + @property + def extensions(self) -> InstalledAddOnExtensionList: + """ + Access the extensions + """ + if self._extensions is None: + self._extensions = InstalledAddOnExtensionList( + self._version, + self._solution["sid"], + ) + return self._extensions + + @property + def usage(self) -> InstalledAddOnUsageList: + """ + Access the usage + """ + if self._usage is None: + self._usage = InstalledAddOnUsageList( + self._version, + self._solution["sid"], + ) + return self._usage + + 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 InstalledAddOnPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> InstalledAddOnInstance: + """ + Build an instance of InstalledAddOnInstance + + :param payload: Payload response from the API + """ + return InstalledAddOnInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class InstalledAddOnList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the InstalledAddOnList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/InstalledAddOns" + + def create( + self, + available_add_on_sid: str, + accept_terms_of_service: bool, + configuration: Union[object, object] = values.unset, + unique_name: Union[str, object] = values.unset, + ) -> InstalledAddOnInstance: + """ + Create the InstalledAddOnInstance + + :param available_add_on_sid: The SID of the AvaliableAddOn to install. + :param accept_terms_of_service: Whether the Terms of Service were accepted. + :param configuration: The JSON object that represents the configuration of the new Add-on being installed. + :param unique_name: An application-defined string that uniquely identifies the resource. This value must be unique within the Account. + + :returns: The created InstalledAddOnInstance + """ + + data = values.of( + { + "AvailableAddOnSid": available_add_on_sid, + "AcceptTermsOfService": serialize.boolean_to_string( + accept_terms_of_service + ), + "Configuration": serialize.object(configuration), + "UniqueName": unique_name, + } + ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = self._version.create( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return InstalledAddOnInstance(self._version, payload) + + async def create_async( + self, + available_add_on_sid: str, + accept_terms_of_service: bool, + configuration: Union[object, object] = values.unset, + unique_name: Union[str, object] = values.unset, + ) -> InstalledAddOnInstance: + """ + Asynchronously create the InstalledAddOnInstance + + :param available_add_on_sid: The SID of the AvaliableAddOn to install. + :param accept_terms_of_service: Whether the Terms of Service were accepted. + :param configuration: The JSON object that represents the configuration of the new Add-on being installed. + :param unique_name: An application-defined string that uniquely identifies the resource. This value must be unique within the Account. + + :returns: The created InstalledAddOnInstance + """ + + data = values.of( + { + "AvailableAddOnSid": available_add_on_sid, + "AcceptTermsOfService": serialize.boolean_to_string( + accept_terms_of_service + ), + "Configuration": serialize.object(configuration), + "UniqueName": unique_name, + } + ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return InstalledAddOnInstance(self._version, payload) + + def stream( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[InstalledAddOnInstance]: + """ + Streams InstalledAddOnInstance 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[InstalledAddOnInstance]: + """ + Asynchronously streams InstalledAddOnInstance 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[InstalledAddOnInstance]: + """ + Lists InstalledAddOnInstance 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[InstalledAddOnInstance]: + """ + Asynchronously lists InstalledAddOnInstance 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, + ) -> InstalledAddOnPage: + """ + Retrieve a single page of InstalledAddOnInstance 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 InstalledAddOnInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return InstalledAddOnPage(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, + ) -> InstalledAddOnPage: + """ + Asynchronously retrieve a single page of InstalledAddOnInstance 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 InstalledAddOnInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + return InstalledAddOnPage(self._version, response) + + def get_page(self, target_url: str) -> InstalledAddOnPage: + """ + Retrieve a specific page of InstalledAddOnInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of InstalledAddOnInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return InstalledAddOnPage(self._version, response) + + async def get_page_async(self, target_url: str) -> InstalledAddOnPage: + """ + Asynchronously retrieve a specific page of InstalledAddOnInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of InstalledAddOnInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return InstalledAddOnPage(self._version, response) + + def get(self, sid: str) -> InstalledAddOnContext: + """ + Constructs a InstalledAddOnContext + + :param sid: The SID of the InstalledAddOn resource to update. + """ + return InstalledAddOnContext(self._version, sid=sid) + + def __call__(self, sid: str) -> InstalledAddOnContext: + """ + Constructs a InstalledAddOnContext + + :param sid: The SID of the InstalledAddOn resource to update. + """ + return InstalledAddOnContext(self._version, sid=sid) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/marketplace/v1/installed_add_on/installed_add_on_extension.py b/twilio/rest/marketplace/v1/installed_add_on/installed_add_on_extension.py new file mode 100644 index 0000000000..88f160ed29 --- /dev/null +++ b/twilio/rest/marketplace/v1/installed_add_on/installed_add_on_extension.py @@ -0,0 +1,533 @@ +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, List, Optional, Union, Iterator, AsyncIterator +from twilio.base import serialize, values +from twilio.base.instance_context import InstanceContext +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version +from twilio.base.page import Page + + +class InstalledAddOnExtensionInstance(InstanceResource): + """ + :ivar sid: The unique string that we created to identify the InstalledAddOn Extension resource. + :ivar installed_add_on_sid: The SID of the InstalledAddOn resource to which this extension applies. + :ivar friendly_name: The string that you assigned to describe the resource. + :ivar product_name: The name of the Product this Extension is used within. + :ivar unique_name: An application-defined string that uniquely identifies the resource. + :ivar enabled: Whether the Extension will be invoked. + :ivar url: The absolute URL of the resource. + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + installed_add_on_sid: str, + sid: Optional[str] = None, + ): + super().__init__(version) + + self.sid: Optional[str] = payload.get("sid") + self.installed_add_on_sid: Optional[str] = payload.get("installed_add_on_sid") + self.friendly_name: Optional[str] = payload.get("friendly_name") + self.product_name: Optional[str] = payload.get("product_name") + self.unique_name: Optional[str] = payload.get("unique_name") + self.enabled: Optional[bool] = payload.get("enabled") + self.url: Optional[str] = payload.get("url") + + self._solution = { + "installed_add_on_sid": installed_add_on_sid, + "sid": sid or self.sid, + } + self._context: Optional[InstalledAddOnExtensionContext] = None + + @property + def _proxy(self) -> "InstalledAddOnExtensionContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: InstalledAddOnExtensionContext for this InstalledAddOnExtensionInstance + """ + if self._context is None: + self._context = InstalledAddOnExtensionContext( + self._version, + installed_add_on_sid=self._solution["installed_add_on_sid"], + sid=self._solution["sid"], + ) + return self._context + + def fetch(self) -> "InstalledAddOnExtensionInstance": + """ + Fetch the InstalledAddOnExtensionInstance + + + :returns: The fetched InstalledAddOnExtensionInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "InstalledAddOnExtensionInstance": + """ + Asynchronous coroutine to fetch the InstalledAddOnExtensionInstance + + + :returns: The fetched InstalledAddOnExtensionInstance + """ + return await self._proxy.fetch_async() + + def update(self, enabled: bool) -> "InstalledAddOnExtensionInstance": + """ + Update the InstalledAddOnExtensionInstance + + :param enabled: Whether the Extension should be invoked. + + :returns: The updated InstalledAddOnExtensionInstance + """ + return self._proxy.update( + enabled=enabled, + ) + + async def update_async(self, enabled: bool) -> "InstalledAddOnExtensionInstance": + """ + Asynchronous coroutine to update the InstalledAddOnExtensionInstance + + :param enabled: Whether the Extension should be invoked. + + :returns: The updated InstalledAddOnExtensionInstance + """ + return await self._proxy.update_async( + 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 InstalledAddOnExtensionContext(InstanceContext): + + def __init__(self, version: Version, installed_add_on_sid: str, sid: str): + """ + Initialize the InstalledAddOnExtensionContext + + :param version: Version that contains the resource + :param installed_add_on_sid: The SID of the InstalledAddOn resource with the extension to update. + :param sid: The SID of the InstalledAddOn Extension resource to update. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "installed_add_on_sid": installed_add_on_sid, + "sid": sid, + } + self._uri = "/InstalledAddOns/{installed_add_on_sid}/Extensions/{sid}".format( + **self._solution + ) + + def fetch(self) -> InstalledAddOnExtensionInstance: + """ + Fetch the InstalledAddOnExtensionInstance + + + :returns: The fetched InstalledAddOnExtensionInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return InstalledAddOnExtensionInstance( + self._version, + payload, + installed_add_on_sid=self._solution["installed_add_on_sid"], + sid=self._solution["sid"], + ) + + async def fetch_async(self) -> InstalledAddOnExtensionInstance: + """ + Asynchronous coroutine to fetch the InstalledAddOnExtensionInstance + + + :returns: The fetched InstalledAddOnExtensionInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + return InstalledAddOnExtensionInstance( + self._version, + payload, + installed_add_on_sid=self._solution["installed_add_on_sid"], + sid=self._solution["sid"], + ) + + def update(self, enabled: bool) -> InstalledAddOnExtensionInstance: + """ + Update the InstalledAddOnExtensionInstance + + :param enabled: Whether the Extension should be invoked. + + :returns: The updated InstalledAddOnExtensionInstance + """ + + data = values.of( + { + "Enabled": serialize.boolean_to_string(enabled), + } + ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = self._version.update( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return InstalledAddOnExtensionInstance( + self._version, + payload, + installed_add_on_sid=self._solution["installed_add_on_sid"], + sid=self._solution["sid"], + ) + + async def update_async(self, enabled: bool) -> InstalledAddOnExtensionInstance: + """ + Asynchronous coroutine to update the InstalledAddOnExtensionInstance + + :param enabled: Whether the Extension should be invoked. + + :returns: The updated InstalledAddOnExtensionInstance + """ + + data = values.of( + { + "Enabled": serialize.boolean_to_string(enabled), + } + ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = await self._version.update_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return InstalledAddOnExtensionInstance( + self._version, + payload, + installed_add_on_sid=self._solution["installed_add_on_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 InstalledAddOnExtensionPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> InstalledAddOnExtensionInstance: + """ + Build an instance of InstalledAddOnExtensionInstance + + :param payload: Payload response from the API + """ + return InstalledAddOnExtensionInstance( + self._version, + payload, + installed_add_on_sid=self._solution["installed_add_on_sid"], + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class InstalledAddOnExtensionList(ListResource): + + def __init__(self, version: Version, installed_add_on_sid: str): + """ + Initialize the InstalledAddOnExtensionList + + :param version: Version that contains the resource + :param installed_add_on_sid: The SID of the InstalledAddOn resource with the extensions to read. + + """ + super().__init__(version) + + # Path Solution + self._solution = { + "installed_add_on_sid": installed_add_on_sid, + } + self._uri = "/InstalledAddOns/{installed_add_on_sid}/Extensions".format( + **self._solution + ) + + def stream( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[InstalledAddOnExtensionInstance]: + """ + Streams InstalledAddOnExtensionInstance 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[InstalledAddOnExtensionInstance]: + """ + Asynchronously streams InstalledAddOnExtensionInstance 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[InstalledAddOnExtensionInstance]: + """ + Lists InstalledAddOnExtensionInstance 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[InstalledAddOnExtensionInstance]: + """ + Asynchronously lists InstalledAddOnExtensionInstance 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, + ) -> InstalledAddOnExtensionPage: + """ + Retrieve a single page of InstalledAddOnExtensionInstance 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 InstalledAddOnExtensionInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return InstalledAddOnExtensionPage(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, + ) -> InstalledAddOnExtensionPage: + """ + Asynchronously retrieve a single page of InstalledAddOnExtensionInstance 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 InstalledAddOnExtensionInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + return InstalledAddOnExtensionPage(self._version, response, self._solution) + + def get_page(self, target_url: str) -> InstalledAddOnExtensionPage: + """ + Retrieve a specific page of InstalledAddOnExtensionInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of InstalledAddOnExtensionInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return InstalledAddOnExtensionPage(self._version, response, self._solution) + + async def get_page_async(self, target_url: str) -> InstalledAddOnExtensionPage: + """ + Asynchronously retrieve a specific page of InstalledAddOnExtensionInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of InstalledAddOnExtensionInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return InstalledAddOnExtensionPage(self._version, response, self._solution) + + def get(self, sid: str) -> InstalledAddOnExtensionContext: + """ + Constructs a InstalledAddOnExtensionContext + + :param sid: The SID of the InstalledAddOn Extension resource to update. + """ + return InstalledAddOnExtensionContext( + self._version, + installed_add_on_sid=self._solution["installed_add_on_sid"], + sid=sid, + ) + + def __call__(self, sid: str) -> InstalledAddOnExtensionContext: + """ + Constructs a InstalledAddOnExtensionContext + + :param sid: The SID of the InstalledAddOn Extension resource to update. + """ + return InstalledAddOnExtensionContext( + self._version, + installed_add_on_sid=self._solution["installed_add_on_sid"], + sid=sid, + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" 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 new file mode 100644 index 0000000000..1a54756496 --- /dev/null +++ b/twilio/rest/marketplace/v1/installed_add_on/installed_add_on_usage.py @@ -0,0 +1,234 @@ +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, List, Optional +from twilio.base import deserialize, values + +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + + +class InstalledAddOnUsageInstance(InstanceResource): + + 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 + ] + ] = payload.get("billable_items") + + def to_dict(self): + return { + "total_submitted": self.total_submitted, + "billable_items": ( + [billable_items.to_dict() for billable_items in self.billable_items] + if self.billable_items is not None + else None + ), + } + + class MarketplaceV1InstalledAddOnInstalledAddOnUsageBillableItems(object): + """ + :ivar quantity: Total amount in local currency that was billed for this Billing Item. Can be any floating number greater than 0. + :ivar sid: BillingSid to use for billing. + :ivar submitted: Whether the billing event was successfully generated for this Billable Item. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.quantity: Optional[float] = payload.get("quantity") + self.sid: Optional[str] = payload.get("sid") + self.submitted: Optional[bool] = payload.get("submitted") + + def to_dict(self): + return { + "quantity": self.quantity, + "sid": self.sid, + "submitted": self.submitted, + } + + """ + :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, version: Version, payload: Dict[str, Any], installed_add_on_sid: str + ): + super().__init__(version) + + 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, + } + + 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 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 + ] + ] = payload.get("billable_items") + + def to_dict(self): + return { + "total_submitted": self.total_submitted, + "billable_items": ( + [billable_items.to_dict() for billable_items in self.billable_items] + if self.billable_items is not None + else None + ), + } + + class MarketplaceV1InstalledAddOnInstalledAddOnUsageBillableItems(object): + """ + :ivar quantity: Total amount in local currency that was billed for this Billing Item. Can be any floating number greater than 0. + :ivar sid: BillingSid to use for billing. + :ivar submitted: Whether the billing event was successfully generated for this Billable Item. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.quantity: Optional[float] = payload.get("quantity") + self.sid: Optional[str] = payload.get("sid") + self.submitted: Optional[bool] = payload.get("submitted") + + def to_dict(self): + return { + "quantity": self.quantity, + "sid": self.sid, + "submitted": self.submitted, + } + + 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: Customer Installation SID to report usage on. + + """ + super().__init__(version) + + # Path Solution + self._solution = { + "installed_add_on_sid": installed_add_on_sid, + } + self._uri = "/InstalledAddOns/{installed_add_on_sid}/Usage".format( + **self._solution + ) + + def create( + self, + marketplace_v1_installed_add_on_installed_add_on_usage: MarketplaceV1InstalledAddOnInstalledAddOnUsage, + ) -> InstalledAddOnUsageInstance: + """ + Create the InstalledAddOnUsageInstance + + :param marketplace_v1_installed_add_on_installed_add_on_usage: + + :returns: The created InstalledAddOnUsageInstance + """ + 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" + + headers["Accept"] = "application/json" + + payload = self._version.create( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return InstalledAddOnUsageInstance( + self._version, + payload, + installed_add_on_sid=self._solution["installed_add_on_sid"], + ) + + async def create_async( + self, + marketplace_v1_installed_add_on_installed_add_on_usage: MarketplaceV1InstalledAddOnInstalledAddOnUsage, + ) -> InstalledAddOnUsageInstance: + """ + Asynchronously create the InstalledAddOnUsageInstance + + :param marketplace_v1_installed_add_on_installed_add_on_usage: + + :returns: The created InstalledAddOnUsageInstance + """ + 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" + + headers["Accept"] = "application/json" + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return InstalledAddOnUsageInstance( + self._version, + payload, + installed_add_on_sid=self._solution["installed_add_on_sid"], + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/marketplace/v1/module_data.py b/twilio/rest/marketplace/v1/module_data.py new file mode 100644 index 0000000000..1308c17a91 --- /dev/null +++ b/twilio/rest/marketplace/v1/module_data.py @@ -0,0 +1,176 @@ +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, List, 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 ModuleDataInstance(InstanceResource): + """ + :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. + :ivar pricing: A JSON object for providing Listing specific pricing information. + :ivar listings: + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.url: Optional[str] = payload.get("url") + self.sid: Optional[str] = payload.get("sid") + self.description: Optional[Dict[str, object]] = payload.get("description") + self.support: Optional[Dict[str, object]] = payload.get("support") + 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.pricing: Optional[Dict[str, object]] = payload.get("pricing") + self.listings: Optional[List[Dict[str, object]]] = payload.get("listings") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class ModuleDataList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the ModuleDataList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/Listings" + + def create( + self, + module_info: Union[str, object] = values.unset, + configuration: Union[str, object] = values.unset, + ) -> ModuleDataInstance: + """ + Create the ModuleDataInstance + + :param module_info: A JSON object containing essential attributes that define a Listing. + :param configuration: A JSON object for providing Listing-specific configuration. Contains button setup, notification URL, and more. + + :returns: The created ModuleDataInstance + """ + + data = values.of( + { + "ModuleInfo": module_info, + "Configuration": configuration, + } + ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = self._version.create( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return ModuleDataInstance(self._version, payload) + + async def create_async( + self, + module_info: Union[str, object] = values.unset, + configuration: Union[str, object] = values.unset, + ) -> ModuleDataInstance: + """ + Asynchronously create the ModuleDataInstance + + :param module_info: A JSON object containing essential attributes that define a Listing. + :param configuration: A JSON object for providing Listing-specific configuration. Contains button setup, notification URL, and more. + + :returns: The created ModuleDataInstance + """ + + data = values.of( + { + "ModuleInfo": module_info, + "Configuration": configuration, + } + ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return ModuleDataInstance(self._version, payload) + + def fetch(self) -> ModuleDataInstance: + """ + Asynchronously fetch the ModuleDataInstance + + + :returns: The fetched ModuleDataInstance + """ + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return ModuleDataInstance(self._version, payload) + + async def fetch_async(self) -> ModuleDataInstance: + """ + Asynchronously fetch the ModuleDataInstance + + + :returns: The fetched ModuleDataInstance + """ + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + return ModuleDataInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/marketplace/v1/module_data_management.py b/twilio/rest/marketplace/v1/module_data_management.py new file mode 100644 index 0000000000..6ed82d846d --- /dev/null +++ b/twilio/rest/marketplace/v1/module_data_management.py @@ -0,0 +1,367 @@ +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, List, Optional, Union +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 ModuleDataManagementInstance(InstanceResource): + """ + :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. + :ivar pricing: A JSON object for providing Listing specific pricing information. + :ivar listings: + """ + + def __init__( + self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None + ): + super().__init__(version) + + self.url: Optional[str] = payload.get("url") + self.sid: Optional[str] = payload.get("sid") + self.description: Optional[Dict[str, object]] = payload.get("description") + self.support: Optional[Dict[str, object]] = payload.get("support") + 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.pricing: Optional[Dict[str, object]] = payload.get("pricing") + self.listings: Optional[List[Dict[str, object]]] = payload.get("listings") + + self._solution = { + "sid": sid or self.sid, + } + self._context: Optional[ModuleDataManagementContext] = None + + @property + def _proxy(self) -> "ModuleDataManagementContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: ModuleDataManagementContext for this ModuleDataManagementInstance + """ + if self._context is None: + self._context = ModuleDataManagementContext( + self._version, + sid=self._solution["sid"], + ) + return self._context + + def fetch(self) -> "ModuleDataManagementInstance": + """ + Fetch the ModuleDataManagementInstance + + + :returns: The fetched ModuleDataManagementInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "ModuleDataManagementInstance": + """ + Asynchronous coroutine to fetch the ModuleDataManagementInstance + + + :returns: The fetched ModuleDataManagementInstance + """ + return await self._proxy.fetch_async() + + def update( + self, + module_info: Union[str, object] = values.unset, + description: Union[str, object] = values.unset, + documentation: Union[str, object] = values.unset, + 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: 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 + """ + return self._proxy.update( + module_info=module_info, + description=description, + documentation=documentation, + policies=policies, + support=support, + configuration=configuration, + pricing=pricing, + ) + + async def update_async( + self, + module_info: Union[str, object] = values.unset, + description: Union[str, object] = values.unset, + documentation: Union[str, object] = values.unset, + 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: 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 + """ + return await self._proxy.update_async( + module_info=module_info, + description=description, + documentation=documentation, + policies=policies, + support=support, + configuration=configuration, + pricing=pricing, + ) + + 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 ModuleDataManagementContext(InstanceContext): + + def __init__(self, version: Version, sid: str): + """ + Initialize the ModuleDataManagementContext + + :param version: Version that contains the resource + :param sid: SID that uniquely identifies the Listing. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "sid": sid, + } + self._uri = "/Listing/{sid}".format(**self._solution) + + def fetch(self) -> ModuleDataManagementInstance: + """ + Fetch the ModuleDataManagementInstance + + + :returns: The fetched ModuleDataManagementInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return ModuleDataManagementInstance( + self._version, + payload, + sid=self._solution["sid"], + ) + + async def fetch_async(self) -> ModuleDataManagementInstance: + """ + Asynchronous coroutine to fetch the ModuleDataManagementInstance + + + :returns: The fetched ModuleDataManagementInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + return ModuleDataManagementInstance( + self._version, + payload, + sid=self._solution["sid"], + ) + + def update( + self, + module_info: Union[str, object] = values.unset, + description: Union[str, object] = values.unset, + documentation: Union[str, object] = values.unset, + 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: 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 + """ + + data = values.of( + { + "ModuleInfo": module_info, + "Description": description, + "Documentation": documentation, + "Policies": policies, + "Support": support, + "Configuration": configuration, + "Pricing": pricing, + } + ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = self._version.update( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return ModuleDataManagementInstance( + self._version, payload, sid=self._solution["sid"] + ) + + async def update_async( + self, + module_info: Union[str, object] = values.unset, + description: Union[str, object] = values.unset, + documentation: Union[str, object] = values.unset, + 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: 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 + """ + + data = values.of( + { + "ModuleInfo": module_info, + "Description": description, + "Documentation": documentation, + "Policies": policies, + "Support": support, + "Configuration": configuration, + "Pricing": pricing, + } + ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = await self._version.update_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return ModuleDataManagementInstance( + 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 ModuleDataManagementList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the ModuleDataManagementList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + def get(self, sid: str) -> ModuleDataManagementContext: + """ + Constructs a ModuleDataManagementContext + + :param sid: SID that uniquely identifies the Listing. + """ + return ModuleDataManagementContext(self._version, sid=sid) + + def __call__(self, sid: str) -> ModuleDataManagementContext: + """ + Constructs a ModuleDataManagementContext + + :param sid: SID that uniquely identifies the Listing. + """ + return ModuleDataManagementContext(self._version, sid=sid) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/marketplace/v1/referral_conversion.py b/twilio/rest/marketplace/v1/referral_conversion.py new file mode 100644 index 0000000000..9d9f3c2fa9 --- /dev/null +++ b/twilio/rest/marketplace/v1/referral_conversion.py @@ -0,0 +1,143 @@ +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_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + + +class ReferralConversionInstance(InstanceResource): + + 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, + } + + """ + :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") + + 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) + + 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 = create_referral_conversion_request.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + payload = self._version.create( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return ReferralConversionInstance(self._version, payload) + + async def create_async( + self, create_referral_conversion_request: CreateReferralConversionRequest + ) -> ReferralConversionInstance: + """ + Asynchronously create the ReferralConversionInstance + + :param create_referral_conversion_request: + + :returns: The created ReferralConversionInstance + """ + data = create_referral_conversion_request.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return ReferralConversionInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/media/__init__.py b/twilio/rest/media/__init__.py deleted file mode 100644 index ce6207e29a..0000000000 --- a/twilio/rest/media/__init__.py +++ /dev/null @@ -1,35 +0,0 @@ -from warnings import warn - -from twilio.rest.media.MediaBase import MediaBase -from twilio.rest.media.v1.media_processor import MediaProcessorList -from twilio.rest.media.v1.media_recording import MediaRecordingList -from twilio.rest.media.v1.player_streamer import PlayerStreamerList - - -class Media(MediaBase): - @property - def media_processor(self) -> MediaProcessorList: - warn( - "media_processor is deprecated. Use v1.media_processor instead.", - DeprecationWarning, - stacklevel=2, - ) - return self.v1.media_processor - - @property - def media_recording(self) -> MediaRecordingList: - warn( - "media_recording is deprecated. Use v1.media_recording instead.", - DeprecationWarning, - stacklevel=2, - ) - return self.v1.media_recording - - @property - def player_streamer(self) -> PlayerStreamerList: - warn( - "player_streamer is deprecated. Use v1.player_streamer instead.", - DeprecationWarning, - stacklevel=2, - ) - return self.v1.player_streamer diff --git a/twilio/rest/media/v1/__init__.py b/twilio/rest/media/v1/__init__.py deleted file mode 100644 index 3cef1df9b2..0000000000 --- a/twilio/rest/media/v1/__init__.py +++ /dev/null @@ -1,59 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Media - 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.media.v1.media_processor import MediaProcessorList -from twilio.rest.media.v1.media_recording import MediaRecordingList -from twilio.rest.media.v1.player_streamer import PlayerStreamerList - - -class V1(Version): - - def __init__(self, domain: Domain): - """ - Initialize the V1 version of Media - - :param domain: The Twilio.media domain - """ - super().__init__(domain, "v1") - self._media_processor: Optional[MediaProcessorList] = None - self._media_recording: Optional[MediaRecordingList] = None - self._player_streamer: Optional[PlayerStreamerList] = None - - @property - def media_processor(self) -> MediaProcessorList: - if self._media_processor is None: - self._media_processor = MediaProcessorList(self) - return self._media_processor - - @property - def media_recording(self) -> MediaRecordingList: - if self._media_recording is None: - self._media_recording = MediaRecordingList(self) - return self._media_recording - - @property - def player_streamer(self) -> PlayerStreamerList: - if self._player_streamer is None: - self._player_streamer = PlayerStreamerList(self) - return self._player_streamer - - def __repr__(self) -> str: - """ - Provide a friendly representation - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/media/v1/media_processor.py b/twilio/rest/media/v1/media_processor.py deleted file mode 100644 index 7f1d2825b1..0000000000 --- a/twilio/rest/media/v1/media_processor.py +++ /dev/null @@ -1,622 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Media - 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 MediaProcessorInstance(InstanceResource): - - class Order(object): - ASC = "asc" - DESC = "desc" - - class Status(object): - FAILED = "failed" - STARTED = "started" - ENDED = "ended" - - class UpdateStatus(object): - ENDED = "ended" - - """ - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the MediaProcessor resource. - :ivar sid: The unique string generated to identify the MediaProcessor resource. - :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 extension: The [Media Extension](/docs/live/media-extensions-overview) name or URL. Ex: `video-composer-v2` - :ivar extension_context: The context of the Media Extension, represented as a JSON dictionary. See the documentation for the specific [Media Extension](/docs/live/media-extensions-overview) you are using for more information about the context to send. - :ivar status: - :ivar url: The absolute URL of the resource. - :ivar ended_reason: The reason why a MediaProcessor ended. When a MediaProcessor is in progress, will be `null`. When a MediaProcessor is completed, can be `ended-via-api`, `max-duration-exceeded`, `error-loading-extension`, `error-streaming-media` or `internal-service-error`. See [ended reasons](/docs/live/api/mediaprocessors#mediaprocessor-ended-reason-values) for more details. - :ivar status_callback: The URL to which Twilio will send asynchronous webhook requests for every MediaProcessor event. See [Status Callbacks](/docs/live/api/status-callbacks) for details. - :ivar status_callback_method: The HTTP method Twilio should use to call the `status_callback` URL. Can be `POST` or `GET` and the default is `POST`. - :ivar max_duration: The maximum time, in seconds, that the MediaProcessor can run before automatically ends. The default value is 300 seconds, and the maximum value is 90000 seconds. Once this maximum duration is reached, Twilio will end the MediaProcessor, regardless of whether media is still streaming. - """ - - def __init__( - self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None - ): - super().__init__(version) - - self.account_sid: Optional[str] = payload.get("account_sid") - self.sid: Optional[str] = payload.get("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.extension: Optional[str] = payload.get("extension") - self.extension_context: Optional[str] = payload.get("extension_context") - self.status: Optional["MediaProcessorInstance.Status"] = payload.get("status") - self.url: Optional[str] = payload.get("url") - self.ended_reason: Optional[str] = payload.get("ended_reason") - self.status_callback: Optional[str] = payload.get("status_callback") - self.status_callback_method: Optional[str] = payload.get( - "status_callback_method" - ) - self.max_duration: Optional[int] = deserialize.integer( - payload.get("max_duration") - ) - - self._solution = { - "sid": sid or self.sid, - } - self._context: Optional[MediaProcessorContext] = None - - @property - def _proxy(self) -> "MediaProcessorContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: MediaProcessorContext for this MediaProcessorInstance - """ - if self._context is None: - self._context = MediaProcessorContext( - self._version, - sid=self._solution["sid"], - ) - return self._context - - def fetch(self) -> "MediaProcessorInstance": - """ - Fetch the MediaProcessorInstance - - - :returns: The fetched MediaProcessorInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "MediaProcessorInstance": - """ - Asynchronous coroutine to fetch the MediaProcessorInstance - - - :returns: The fetched MediaProcessorInstance - """ - return await self._proxy.fetch_async() - - def update( - self, status: "MediaProcessorInstance.UpdateStatus" - ) -> "MediaProcessorInstance": - """ - Update the MediaProcessorInstance - - :param status: - - :returns: The updated MediaProcessorInstance - """ - return self._proxy.update( - status=status, - ) - - async def update_async( - self, status: "MediaProcessorInstance.UpdateStatus" - ) -> "MediaProcessorInstance": - """ - Asynchronous coroutine to update the MediaProcessorInstance - - :param status: - - :returns: The updated MediaProcessorInstance - """ - return await self._proxy.update_async( - status=status, - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) - return "".format(context) - - -class MediaProcessorContext(InstanceContext): - - def __init__(self, version: Version, sid: str): - """ - Initialize the MediaProcessorContext - - :param version: Version that contains the resource - :param sid: The SID of the MediaProcessor resource to update. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "sid": sid, - } - self._uri = "/MediaProcessors/{sid}".format(**self._solution) - - def fetch(self) -> MediaProcessorInstance: - """ - Fetch the MediaProcessorInstance - - - :returns: The fetched MediaProcessorInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return MediaProcessorInstance( - self._version, - payload, - sid=self._solution["sid"], - ) - - async def fetch_async(self) -> MediaProcessorInstance: - """ - Asynchronous coroutine to fetch the MediaProcessorInstance - - - :returns: The fetched MediaProcessorInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return MediaProcessorInstance( - self._version, - payload, - sid=self._solution["sid"], - ) - - def update( - self, status: "MediaProcessorInstance.UpdateStatus" - ) -> MediaProcessorInstance: - """ - Update the MediaProcessorInstance - - :param status: - - :returns: The updated MediaProcessorInstance - """ - data = values.of( - { - "Status": status, - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return MediaProcessorInstance(self._version, payload, sid=self._solution["sid"]) - - async def update_async( - self, status: "MediaProcessorInstance.UpdateStatus" - ) -> MediaProcessorInstance: - """ - Asynchronous coroutine to update the MediaProcessorInstance - - :param status: - - :returns: The updated MediaProcessorInstance - """ - data = values.of( - { - "Status": status, - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return MediaProcessorInstance(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 MediaProcessorPage(Page): - - def get_instance(self, payload: Dict[str, Any]) -> MediaProcessorInstance: - """ - Build an instance of MediaProcessorInstance - - :param payload: Payload response from the API - """ - return MediaProcessorInstance(self._version, payload) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class MediaProcessorList(ListResource): - - def __init__(self, version: Version): - """ - Initialize the MediaProcessorList - - :param version: Version that contains the resource - - """ - super().__init__(version) - - self._uri = "/MediaProcessors" - - def create( - self, - extension: str, - extension_context: str, - extension_environment: Union[object, object] = values.unset, - status_callback: Union[str, object] = values.unset, - status_callback_method: Union[str, object] = values.unset, - max_duration: Union[int, object] = values.unset, - ) -> MediaProcessorInstance: - """ - Create the MediaProcessorInstance - - :param extension: The [Media Extension](/docs/live/media-extensions-overview) name or URL. Ex: `video-composer-v2` - :param extension_context: The context of the Media Extension, represented as a JSON dictionary. See the documentation for the specific [Media Extension](/docs/live/media-extensions-overview) you are using for more information about the context to send. - :param extension_environment: User-defined environment variables for the Media Extension, represented as a JSON dictionary of key/value strings. See the documentation for the specific [Media Extension](/docs/live/media-extensions-overview) you are using for more information about whether you need to provide this. - :param status_callback: The URL to which Twilio will send asynchronous webhook requests for every MediaProcessor event. See [Status Callbacks](/docs/live/api/status-callbacks) for details. - :param status_callback_method: The HTTP method Twilio should use to call the `status_callback` URL. Can be `POST` or `GET` and the default is `POST`. - :param max_duration: The maximum time, in seconds, that the MediaProcessor can run before automatically ends. The default value is 300 seconds, and the maximum value is 90000 seconds. Once this maximum duration is reached, Twilio will end the MediaProcessor, regardless of whether media is still streaming. - - :returns: The created MediaProcessorInstance - """ - - data = values.of( - { - "Extension": extension, - "ExtensionContext": extension_context, - "ExtensionEnvironment": serialize.object(extension_environment), - "StatusCallback": status_callback, - "StatusCallbackMethod": status_callback_method, - "MaxDuration": max_duration, - } - ) - - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) - - return MediaProcessorInstance(self._version, payload) - - async def create_async( - self, - extension: str, - extension_context: str, - extension_environment: Union[object, object] = values.unset, - status_callback: Union[str, object] = values.unset, - status_callback_method: Union[str, object] = values.unset, - max_duration: Union[int, object] = values.unset, - ) -> MediaProcessorInstance: - """ - Asynchronously create the MediaProcessorInstance - - :param extension: The [Media Extension](/docs/live/media-extensions-overview) name or URL. Ex: `video-composer-v2` - :param extension_context: The context of the Media Extension, represented as a JSON dictionary. See the documentation for the specific [Media Extension](/docs/live/media-extensions-overview) you are using for more information about the context to send. - :param extension_environment: User-defined environment variables for the Media Extension, represented as a JSON dictionary of key/value strings. See the documentation for the specific [Media Extension](/docs/live/media-extensions-overview) you are using for more information about whether you need to provide this. - :param status_callback: The URL to which Twilio will send asynchronous webhook requests for every MediaProcessor event. See [Status Callbacks](/docs/live/api/status-callbacks) for details. - :param status_callback_method: The HTTP method Twilio should use to call the `status_callback` URL. Can be `POST` or `GET` and the default is `POST`. - :param max_duration: The maximum time, in seconds, that the MediaProcessor can run before automatically ends. The default value is 300 seconds, and the maximum value is 90000 seconds. Once this maximum duration is reached, Twilio will end the MediaProcessor, regardless of whether media is still streaming. - - :returns: The created MediaProcessorInstance - """ - - data = values.of( - { - "Extension": extension, - "ExtensionContext": extension_context, - "ExtensionEnvironment": serialize.object(extension_environment), - "StatusCallback": status_callback, - "StatusCallbackMethod": status_callback_method, - "MaxDuration": max_duration, - } - ) - - payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, - ) - - return MediaProcessorInstance(self._version, payload) - - def stream( - self, - order: Union["MediaProcessorInstance.Order", object] = values.unset, - status: Union["MediaProcessorInstance.Status", object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[MediaProcessorInstance]: - """ - Streams MediaProcessorInstance 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 "MediaProcessorInstance.Order" order: The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default. - :param "MediaProcessorInstance.Status" status: Status to filter by, with possible values `started`, `ended` or `failed`. - :param limit: Upper limit for the number of records to return. stream() - guarantees to never return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, stream() will attempt to read the - limit with the most efficient page size, i.e. min(limit, 1000) - - :returns: Generator that will yield up to limit results - """ - limits = self._version.read_limits(limit, page_size) - page = self.page(order=order, status=status, page_size=limits["page_size"]) - - return self._version.stream(page, limits["limit"]) - - async def stream_async( - self, - order: Union["MediaProcessorInstance.Order", object] = values.unset, - status: Union["MediaProcessorInstance.Status", object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> AsyncIterator[MediaProcessorInstance]: - """ - Asynchronously streams MediaProcessorInstance 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 "MediaProcessorInstance.Order" order: The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default. - :param "MediaProcessorInstance.Status" status: Status to filter by, with possible values `started`, `ended` or `failed`. - :param limit: Upper limit for the number of records to return. stream() - guarantees to never return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, stream() will attempt to read the - limit with the most efficient page size, i.e. min(limit, 1000) - - :returns: Generator that will yield up to limit results - """ - limits = self._version.read_limits(limit, page_size) - page = await self.page_async( - order=order, status=status, page_size=limits["page_size"] - ) - - return self._version.stream_async(page, limits["limit"]) - - def list( - self, - order: Union["MediaProcessorInstance.Order", object] = values.unset, - status: Union["MediaProcessorInstance.Status", object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[MediaProcessorInstance]: - """ - Lists MediaProcessorInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param "MediaProcessorInstance.Order" order: The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default. - :param "MediaProcessorInstance.Status" status: Status to filter by, with possible values `started`, `ended` or `failed`. - :param limit: Upper limit for the number of records to return. list() guarantees - never to return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, list() will attempt to read the limit - with the most efficient page size, i.e. min(limit, 1000) - - :returns: list that will contain up to limit results - """ - return list( - self.stream( - order=order, - status=status, - limit=limit, - page_size=page_size, - ) - ) - - async def list_async( - self, - order: Union["MediaProcessorInstance.Order", object] = values.unset, - status: Union["MediaProcessorInstance.Status", object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[MediaProcessorInstance]: - """ - Asynchronously lists MediaProcessorInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param "MediaProcessorInstance.Order" order: The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default. - :param "MediaProcessorInstance.Status" status: Status to filter by, with possible values `started`, `ended` or `failed`. - :param limit: Upper limit for the number of records to return. list() guarantees - never to return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, list() will attempt to read the limit - with the most efficient page size, i.e. min(limit, 1000) - - :returns: list that will contain up to limit results - """ - return [ - record - async for record in await self.stream_async( - order=order, - status=status, - limit=limit, - page_size=page_size, - ) - ] - - def page( - self, - order: Union["MediaProcessorInstance.Order", object] = values.unset, - status: Union["MediaProcessorInstance.Status", object] = values.unset, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> MediaProcessorPage: - """ - Retrieve a single page of MediaProcessorInstance records from the API. - Request is executed immediately - - :param order: The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default. - :param status: Status to filter by, with possible values `started`, `ended` or `failed`. - :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 MediaProcessorInstance - """ - data = values.of( - { - "Order": order, - "Status": status, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = self._version.page(method="GET", uri=self._uri, params=data) - return MediaProcessorPage(self._version, response) - - async def page_async( - self, - order: Union["MediaProcessorInstance.Order", object] = values.unset, - status: Union["MediaProcessorInstance.Status", object] = values.unset, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> MediaProcessorPage: - """ - Asynchronously retrieve a single page of MediaProcessorInstance records from the API. - Request is executed immediately - - :param order: The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default. - :param status: Status to filter by, with possible values `started`, `ended` or `failed`. - :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 MediaProcessorInstance - """ - data = values.of( - { - "Order": order, - "Status": status, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = await self._version.page_async( - method="GET", uri=self._uri, params=data - ) - return MediaProcessorPage(self._version, response) - - def get_page(self, target_url: str) -> MediaProcessorPage: - """ - Retrieve a specific page of MediaProcessorInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of MediaProcessorInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return MediaProcessorPage(self._version, response) - - async def get_page_async(self, target_url: str) -> MediaProcessorPage: - """ - Asynchronously retrieve a specific page of MediaProcessorInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of MediaProcessorInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return MediaProcessorPage(self._version, response) - - def get(self, sid: str) -> MediaProcessorContext: - """ - Constructs a MediaProcessorContext - - :param sid: The SID of the MediaProcessor resource to update. - """ - return MediaProcessorContext(self._version, sid=sid) - - def __call__(self, sid: str) -> MediaProcessorContext: - """ - Constructs a MediaProcessorContext - - :param sid: The SID of the MediaProcessor resource to update. - """ - return MediaProcessorContext(self._version, sid=sid) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/media/v1/media_recording.py b/twilio/rest/media/v1/media_recording.py deleted file mode 100644 index fb916e5278..0000000000 --- a/twilio/rest/media/v1/media_recording.py +++ /dev/null @@ -1,554 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Media - 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 MediaRecordingInstance(InstanceResource): - - class Format(object): - MP4 = "mp4" - WEBM = "webm" - - class Order(object): - ASC = "asc" - DESC = "desc" - - class Status(object): - PROCESSING = "processing" - COMPLETED = "completed" - DELETED = "deleted" - FAILED = "failed" - - """ - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the MediaRecording resource. - :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 duration: The duration of the MediaRecording in seconds. - :ivar format: - :ivar links: The URLs of related resources. - :ivar processor_sid: The SID of the MediaProcessor resource which produced the MediaRecording. - :ivar resolution: The dimensions of the video image in pixels expressed as columns (width) and rows (height). - :ivar source_sid: The SID of the resource that generated the original media track(s) of the MediaRecording. - :ivar sid: The unique string generated to identify the MediaRecording resource. - :ivar media_size: The size of the recording media in bytes. - :ivar status: - :ivar status_callback: The URL to which Twilio will send asynchronous webhook requests for every MediaRecording event. See [Status Callbacks](/docs/live/api/status-callbacks) for more details. - :ivar status_callback_method: The HTTP method Twilio should use to call the `status_callback` URL. Can be `POST` or `GET` and the default is `POST`. - :ivar url: The absolute URL of the resource. - """ - - def __init__( - self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None - ): - super().__init__(version) - - self.account_sid: Optional[str] = payload.get("account_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.duration: Optional[int] = deserialize.integer(payload.get("duration")) - self.format: Optional["MediaRecordingInstance.Format"] = payload.get("format") - self.links: Optional[Dict[str, object]] = payload.get("links") - self.processor_sid: Optional[str] = payload.get("processor_sid") - self.resolution: Optional[str] = payload.get("resolution") - self.source_sid: Optional[str] = payload.get("source_sid") - self.sid: Optional[str] = payload.get("sid") - self.media_size: Optional[int] = payload.get("media_size") - self.status: Optional["MediaRecordingInstance.Status"] = payload.get("status") - self.status_callback: Optional[str] = payload.get("status_callback") - self.status_callback_method: Optional[str] = payload.get( - "status_callback_method" - ) - self.url: Optional[str] = payload.get("url") - - self._solution = { - "sid": sid or self.sid, - } - self._context: Optional[MediaRecordingContext] = None - - @property - def _proxy(self) -> "MediaRecordingContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: MediaRecordingContext for this MediaRecordingInstance - """ - if self._context is None: - self._context = MediaRecordingContext( - self._version, - sid=self._solution["sid"], - ) - return self._context - - def delete(self) -> bool: - """ - Deletes the MediaRecordingInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the MediaRecordingInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def fetch(self) -> "MediaRecordingInstance": - """ - Fetch the MediaRecordingInstance - - - :returns: The fetched MediaRecordingInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "MediaRecordingInstance": - """ - Asynchronous coroutine to fetch the MediaRecordingInstance - - - :returns: The fetched MediaRecordingInstance - """ - 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 MediaRecordingContext(InstanceContext): - - def __init__(self, version: Version, sid: str): - """ - Initialize the MediaRecordingContext - - :param version: Version that contains the resource - :param sid: The SID of the MediaRecording resource to fetch. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "sid": sid, - } - self._uri = "/MediaRecordings/{sid}".format(**self._solution) - - def delete(self) -> bool: - """ - Deletes the MediaRecordingInstance - - - :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 MediaRecordingInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._version.delete_async( - method="DELETE", - uri=self._uri, - ) - - def fetch(self) -> MediaRecordingInstance: - """ - Fetch the MediaRecordingInstance - - - :returns: The fetched MediaRecordingInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return MediaRecordingInstance( - self._version, - payload, - sid=self._solution["sid"], - ) - - async def fetch_async(self) -> MediaRecordingInstance: - """ - Asynchronous coroutine to fetch the MediaRecordingInstance - - - :returns: The fetched MediaRecordingInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return MediaRecordingInstance( - 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 MediaRecordingPage(Page): - - def get_instance(self, payload: Dict[str, Any]) -> MediaRecordingInstance: - """ - Build an instance of MediaRecordingInstance - - :param payload: Payload response from the API - """ - return MediaRecordingInstance(self._version, payload) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class MediaRecordingList(ListResource): - - def __init__(self, version: Version): - """ - Initialize the MediaRecordingList - - :param version: Version that contains the resource - - """ - super().__init__(version) - - self._uri = "/MediaRecordings" - - def stream( - self, - order: Union["MediaRecordingInstance.Order", object] = values.unset, - status: Union["MediaRecordingInstance.Status", object] = values.unset, - processor_sid: Union[str, object] = values.unset, - source_sid: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[MediaRecordingInstance]: - """ - Streams MediaRecordingInstance 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 "MediaRecordingInstance.Order" order: The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default. - :param "MediaRecordingInstance.Status" status: Status to filter by, with possible values `processing`, `completed`, `deleted`, or `failed`. - :param str processor_sid: SID of a MediaProcessor to filter by. - :param str source_sid: SID of a MediaRecording source to filter by. - :param limit: Upper limit for the number of records to return. stream() - guarantees to never return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, stream() will attempt to read the - limit with the most efficient page size, i.e. min(limit, 1000) - - :returns: Generator that will yield up to limit results - """ - limits = self._version.read_limits(limit, page_size) - page = self.page( - order=order, - status=status, - processor_sid=processor_sid, - source_sid=source_sid, - page_size=limits["page_size"], - ) - - return self._version.stream(page, limits["limit"]) - - async def stream_async( - self, - order: Union["MediaRecordingInstance.Order", object] = values.unset, - status: Union["MediaRecordingInstance.Status", object] = values.unset, - processor_sid: Union[str, object] = values.unset, - source_sid: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> AsyncIterator[MediaRecordingInstance]: - """ - Asynchronously streams MediaRecordingInstance 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 "MediaRecordingInstance.Order" order: The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default. - :param "MediaRecordingInstance.Status" status: Status to filter by, with possible values `processing`, `completed`, `deleted`, or `failed`. - :param str processor_sid: SID of a MediaProcessor to filter by. - :param str source_sid: SID of a MediaRecording source to filter by. - :param limit: Upper limit for the number of records to return. stream() - guarantees to never return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, stream() will attempt to read the - limit with the most efficient page size, i.e. min(limit, 1000) - - :returns: Generator that will yield up to limit results - """ - limits = self._version.read_limits(limit, page_size) - page = await self.page_async( - order=order, - status=status, - processor_sid=processor_sid, - source_sid=source_sid, - page_size=limits["page_size"], - ) - - return self._version.stream_async(page, limits["limit"]) - - def list( - self, - order: Union["MediaRecordingInstance.Order", object] = values.unset, - status: Union["MediaRecordingInstance.Status", object] = values.unset, - processor_sid: Union[str, object] = values.unset, - source_sid: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[MediaRecordingInstance]: - """ - Lists MediaRecordingInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param "MediaRecordingInstance.Order" order: The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default. - :param "MediaRecordingInstance.Status" status: Status to filter by, with possible values `processing`, `completed`, `deleted`, or `failed`. - :param str processor_sid: SID of a MediaProcessor to filter by. - :param str source_sid: SID of a MediaRecording source to filter by. - :param limit: Upper limit for the number of records to return. list() guarantees - never to return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, list() will attempt to read the limit - with the most efficient page size, i.e. min(limit, 1000) - - :returns: list that will contain up to limit results - """ - return list( - self.stream( - order=order, - status=status, - processor_sid=processor_sid, - source_sid=source_sid, - limit=limit, - page_size=page_size, - ) - ) - - async def list_async( - self, - order: Union["MediaRecordingInstance.Order", object] = values.unset, - status: Union["MediaRecordingInstance.Status", object] = values.unset, - processor_sid: Union[str, object] = values.unset, - source_sid: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[MediaRecordingInstance]: - """ - Asynchronously lists MediaRecordingInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param "MediaRecordingInstance.Order" order: The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default. - :param "MediaRecordingInstance.Status" status: Status to filter by, with possible values `processing`, `completed`, `deleted`, or `failed`. - :param str processor_sid: SID of a MediaProcessor to filter by. - :param str source_sid: SID of a MediaRecording source to filter by. - :param limit: Upper limit for the number of records to return. list() guarantees - never to return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, list() will attempt to read the limit - with the most efficient page size, i.e. min(limit, 1000) - - :returns: list that will contain up to limit results - """ - return [ - record - async for record in await self.stream_async( - order=order, - status=status, - processor_sid=processor_sid, - source_sid=source_sid, - limit=limit, - page_size=page_size, - ) - ] - - def page( - self, - order: Union["MediaRecordingInstance.Order", object] = values.unset, - status: Union["MediaRecordingInstance.Status", object] = values.unset, - processor_sid: Union[str, object] = values.unset, - source_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, - ) -> MediaRecordingPage: - """ - Retrieve a single page of MediaRecordingInstance records from the API. - Request is executed immediately - - :param order: The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default. - :param status: Status to filter by, with possible values `processing`, `completed`, `deleted`, or `failed`. - :param processor_sid: SID of a MediaProcessor to filter by. - :param source_sid: SID of a MediaRecording source to filter by. - :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 MediaRecordingInstance - """ - data = values.of( - { - "Order": order, - "Status": status, - "ProcessorSid": processor_sid, - "SourceSid": source_sid, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = self._version.page(method="GET", uri=self._uri, params=data) - return MediaRecordingPage(self._version, response) - - async def page_async( - self, - order: Union["MediaRecordingInstance.Order", object] = values.unset, - status: Union["MediaRecordingInstance.Status", object] = values.unset, - processor_sid: Union[str, object] = values.unset, - source_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, - ) -> MediaRecordingPage: - """ - Asynchronously retrieve a single page of MediaRecordingInstance records from the API. - Request is executed immediately - - :param order: The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default. - :param status: Status to filter by, with possible values `processing`, `completed`, `deleted`, or `failed`. - :param processor_sid: SID of a MediaProcessor to filter by. - :param source_sid: SID of a MediaRecording source to filter by. - :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 MediaRecordingInstance - """ - data = values.of( - { - "Order": order, - "Status": status, - "ProcessorSid": processor_sid, - "SourceSid": source_sid, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = await self._version.page_async( - method="GET", uri=self._uri, params=data - ) - return MediaRecordingPage(self._version, response) - - def get_page(self, target_url: str) -> MediaRecordingPage: - """ - Retrieve a specific page of MediaRecordingInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of MediaRecordingInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return MediaRecordingPage(self._version, response) - - async def get_page_async(self, target_url: str) -> MediaRecordingPage: - """ - Asynchronously retrieve a specific page of MediaRecordingInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of MediaRecordingInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return MediaRecordingPage(self._version, response) - - def get(self, sid: str) -> MediaRecordingContext: - """ - Constructs a MediaRecordingContext - - :param sid: The SID of the MediaRecording resource to fetch. - """ - return MediaRecordingContext(self._version, sid=sid) - - def __call__(self, sid: str) -> MediaRecordingContext: - """ - Constructs a MediaRecordingContext - - :param sid: The SID of the MediaRecording resource to fetch. - """ - return MediaRecordingContext(self._version, sid=sid) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/media/v1/player_streamer/__init__.py b/twilio/rest/media/v1/player_streamer/__init__.py deleted file mode 100644 index 86832ba990..0000000000 --- a/twilio/rest/media/v1/player_streamer/__init__.py +++ /dev/null @@ -1,641 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Media - This is the public Twilio REST API. - - NOTE: This class is auto generated by OpenAPI Generator. - https://openapi-generator.tech - Do not edit the class manually. -""" - -from datetime import datetime -from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator -from twilio.base import deserialize, serialize, values -from twilio.base.instance_context import InstanceContext -from twilio.base.instance_resource import InstanceResource -from twilio.base.list_resource import ListResource -from twilio.base.version import Version -from twilio.base.page import Page -from twilio.rest.media.v1.player_streamer.playback_grant import PlaybackGrantList - - -class PlayerStreamerInstance(InstanceResource): - - class EndedReason(object): - ENDED_VIA_API = "ended-via-api" - MAX_DURATION_EXCEEDED = "max-duration-exceeded" - STREAM_DISCONNECTED_BY_SOURCE = "stream-disconnected-by-source" - UNEXPECTED_FAILURE = "unexpected-failure" - - class Order(object): - ASC = "asc" - DESC = "desc" - - class Status(object): - CREATED = "created" - STARTED = "started" - ENDED = "ended" - FAILED = "failed" - - class UpdateStatus(object): - ENDED = "ended" - - """ - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the PlayerStreamer resource. - :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 video: Specifies whether the PlayerStreamer is configured to stream video. Defaults to `true`. - :ivar links: The URLs of related resources. - :ivar sid: The unique string generated to identify the PlayerStreamer resource. - :ivar status: - :ivar url: The absolute URL of the resource. - :ivar status_callback: The URL to which Twilio will send asynchronous webhook requests for every PlayerStreamer event. See [Status Callbacks](/docs/live/api/status-callbacks) for more details. - :ivar status_callback_method: The HTTP method Twilio should use to call the `status_callback` URL. Can be `POST` or `GET` and the default is `POST`. - :ivar ended_reason: - :ivar max_duration: The maximum time, in seconds, that the PlayerStreamer is active (`created` or `started`) before automatically ends. The default value is 300 seconds, and the maximum value is 90000 seconds. Once this maximum duration is reached, Twilio will end the PlayerStreamer, regardless of whether media is still streaming. - """ - - def __init__( - self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None - ): - super().__init__(version) - - self.account_sid: Optional[str] = payload.get("account_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.video: Optional[bool] = payload.get("video") - self.links: Optional[Dict[str, object]] = payload.get("links") - self.sid: Optional[str] = payload.get("sid") - self.status: Optional["PlayerStreamerInstance.Status"] = payload.get("status") - self.url: Optional[str] = payload.get("url") - self.status_callback: Optional[str] = payload.get("status_callback") - self.status_callback_method: Optional[str] = payload.get( - "status_callback_method" - ) - self.ended_reason: Optional["PlayerStreamerInstance.EndedReason"] = payload.get( - "ended_reason" - ) - self.max_duration: Optional[int] = deserialize.integer( - payload.get("max_duration") - ) - - self._solution = { - "sid": sid or self.sid, - } - self._context: Optional[PlayerStreamerContext] = None - - @property - def _proxy(self) -> "PlayerStreamerContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: PlayerStreamerContext for this PlayerStreamerInstance - """ - if self._context is None: - self._context = PlayerStreamerContext( - self._version, - sid=self._solution["sid"], - ) - return self._context - - def fetch(self) -> "PlayerStreamerInstance": - """ - Fetch the PlayerStreamerInstance - - - :returns: The fetched PlayerStreamerInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "PlayerStreamerInstance": - """ - Asynchronous coroutine to fetch the PlayerStreamerInstance - - - :returns: The fetched PlayerStreamerInstance - """ - return await self._proxy.fetch_async() - - def update( - self, status: "PlayerStreamerInstance.UpdateStatus" - ) -> "PlayerStreamerInstance": - """ - Update the PlayerStreamerInstance - - :param status: - - :returns: The updated PlayerStreamerInstance - """ - return self._proxy.update( - status=status, - ) - - async def update_async( - self, status: "PlayerStreamerInstance.UpdateStatus" - ) -> "PlayerStreamerInstance": - """ - Asynchronous coroutine to update the PlayerStreamerInstance - - :param status: - - :returns: The updated PlayerStreamerInstance - """ - return await self._proxy.update_async( - status=status, - ) - - @property - def playback_grant(self) -> PlaybackGrantList: - """ - Access the playback_grant - """ - return self._proxy.playback_grant - - 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 PlayerStreamerContext(InstanceContext): - - def __init__(self, version: Version, sid: str): - """ - Initialize the PlayerStreamerContext - - :param version: Version that contains the resource - :param sid: The SID of the PlayerStreamer resource to update. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "sid": sid, - } - self._uri = "/PlayerStreamers/{sid}".format(**self._solution) - - self._playback_grant: Optional[PlaybackGrantList] = None - - def fetch(self) -> PlayerStreamerInstance: - """ - Fetch the PlayerStreamerInstance - - - :returns: The fetched PlayerStreamerInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return PlayerStreamerInstance( - self._version, - payload, - sid=self._solution["sid"], - ) - - async def fetch_async(self) -> PlayerStreamerInstance: - """ - Asynchronous coroutine to fetch the PlayerStreamerInstance - - - :returns: The fetched PlayerStreamerInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return PlayerStreamerInstance( - self._version, - payload, - sid=self._solution["sid"], - ) - - def update( - self, status: "PlayerStreamerInstance.UpdateStatus" - ) -> PlayerStreamerInstance: - """ - Update the PlayerStreamerInstance - - :param status: - - :returns: The updated PlayerStreamerInstance - """ - data = values.of( - { - "Status": status, - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return PlayerStreamerInstance(self._version, payload, sid=self._solution["sid"]) - - async def update_async( - self, status: "PlayerStreamerInstance.UpdateStatus" - ) -> PlayerStreamerInstance: - """ - Asynchronous coroutine to update the PlayerStreamerInstance - - :param status: - - :returns: The updated PlayerStreamerInstance - """ - data = values.of( - { - "Status": status, - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return PlayerStreamerInstance(self._version, payload, sid=self._solution["sid"]) - - @property - def playback_grant(self) -> PlaybackGrantList: - """ - Access the playback_grant - """ - if self._playback_grant is None: - self._playback_grant = PlaybackGrantList( - self._version, - self._solution["sid"], - ) - return self._playback_grant - - 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 PlayerStreamerPage(Page): - - def get_instance(self, payload: Dict[str, Any]) -> PlayerStreamerInstance: - """ - Build an instance of PlayerStreamerInstance - - :param payload: Payload response from the API - """ - return PlayerStreamerInstance(self._version, payload) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class PlayerStreamerList(ListResource): - - def __init__(self, version: Version): - """ - Initialize the PlayerStreamerList - - :param version: Version that contains the resource - - """ - super().__init__(version) - - self._uri = "/PlayerStreamers" - - def create( - self, - video: Union[bool, object] = values.unset, - status_callback: Union[str, object] = values.unset, - status_callback_method: Union[str, object] = values.unset, - max_duration: Union[int, object] = values.unset, - ) -> PlayerStreamerInstance: - """ - Create the PlayerStreamerInstance - - :param video: Specifies whether the PlayerStreamer is configured to stream video. Defaults to `true`. - :param status_callback: The URL to which Twilio will send asynchronous webhook requests for every PlayerStreamer event. See [Status Callbacks](/docs/live/api/status-callbacks) for more details. - :param status_callback_method: The HTTP method Twilio should use to call the `status_callback` URL. Can be `POST` or `GET` and the default is `POST`. - :param max_duration: The maximum time, in seconds, that the PlayerStreamer is active (`created` or `started`) before automatically ends. The default value is 300 seconds, and the maximum value is 90000 seconds. Once this maximum duration is reached, Twilio will end the PlayerStreamer, regardless of whether media is still streaming. - - :returns: The created PlayerStreamerInstance - """ - - data = values.of( - { - "Video": serialize.boolean_to_string(video), - "StatusCallback": status_callback, - "StatusCallbackMethod": status_callback_method, - "MaxDuration": max_duration, - } - ) - - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) - - return PlayerStreamerInstance(self._version, payload) - - async def create_async( - self, - video: Union[bool, object] = values.unset, - status_callback: Union[str, object] = values.unset, - status_callback_method: Union[str, object] = values.unset, - max_duration: Union[int, object] = values.unset, - ) -> PlayerStreamerInstance: - """ - Asynchronously create the PlayerStreamerInstance - - :param video: Specifies whether the PlayerStreamer is configured to stream video. Defaults to `true`. - :param status_callback: The URL to which Twilio will send asynchronous webhook requests for every PlayerStreamer event. See [Status Callbacks](/docs/live/api/status-callbacks) for more details. - :param status_callback_method: The HTTP method Twilio should use to call the `status_callback` URL. Can be `POST` or `GET` and the default is `POST`. - :param max_duration: The maximum time, in seconds, that the PlayerStreamer is active (`created` or `started`) before automatically ends. The default value is 300 seconds, and the maximum value is 90000 seconds. Once this maximum duration is reached, Twilio will end the PlayerStreamer, regardless of whether media is still streaming. - - :returns: The created PlayerStreamerInstance - """ - - data = values.of( - { - "Video": serialize.boolean_to_string(video), - "StatusCallback": status_callback, - "StatusCallbackMethod": status_callback_method, - "MaxDuration": max_duration, - } - ) - - payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, - ) - - return PlayerStreamerInstance(self._version, payload) - - def stream( - self, - order: Union["PlayerStreamerInstance.Order", object] = values.unset, - status: Union["PlayerStreamerInstance.Status", object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[PlayerStreamerInstance]: - """ - Streams PlayerStreamerInstance 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 "PlayerStreamerInstance.Order" order: The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default. - :param "PlayerStreamerInstance.Status" status: Status to filter by, with possible values `created`, `started`, `ended`, or `failed`. - :param limit: Upper limit for the number of records to return. stream() - guarantees to never return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, stream() will attempt to read the - limit with the most efficient page size, i.e. min(limit, 1000) - - :returns: Generator that will yield up to limit results - """ - limits = self._version.read_limits(limit, page_size) - page = self.page(order=order, status=status, page_size=limits["page_size"]) - - return self._version.stream(page, limits["limit"]) - - async def stream_async( - self, - order: Union["PlayerStreamerInstance.Order", object] = values.unset, - status: Union["PlayerStreamerInstance.Status", object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> AsyncIterator[PlayerStreamerInstance]: - """ - Asynchronously streams PlayerStreamerInstance 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 "PlayerStreamerInstance.Order" order: The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default. - :param "PlayerStreamerInstance.Status" status: Status to filter by, with possible values `created`, `started`, `ended`, or `failed`. - :param limit: Upper limit for the number of records to return. stream() - guarantees to never return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, stream() will attempt to read the - limit with the most efficient page size, i.e. min(limit, 1000) - - :returns: Generator that will yield up to limit results - """ - limits = self._version.read_limits(limit, page_size) - page = await self.page_async( - order=order, status=status, page_size=limits["page_size"] - ) - - return self._version.stream_async(page, limits["limit"]) - - def list( - self, - order: Union["PlayerStreamerInstance.Order", object] = values.unset, - status: Union["PlayerStreamerInstance.Status", object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[PlayerStreamerInstance]: - """ - Lists PlayerStreamerInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param "PlayerStreamerInstance.Order" order: The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default. - :param "PlayerStreamerInstance.Status" status: Status to filter by, with possible values `created`, `started`, `ended`, or `failed`. - :param limit: Upper limit for the number of records to return. list() guarantees - never to return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, list() will attempt to read the limit - with the most efficient page size, i.e. min(limit, 1000) - - :returns: list that will contain up to limit results - """ - return list( - self.stream( - order=order, - status=status, - limit=limit, - page_size=page_size, - ) - ) - - async def list_async( - self, - order: Union["PlayerStreamerInstance.Order", object] = values.unset, - status: Union["PlayerStreamerInstance.Status", object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[PlayerStreamerInstance]: - """ - Asynchronously lists PlayerStreamerInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param "PlayerStreamerInstance.Order" order: The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default. - :param "PlayerStreamerInstance.Status" status: Status to filter by, with possible values `created`, `started`, `ended`, or `failed`. - :param limit: Upper limit for the number of records to return. list() guarantees - never to return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, list() will attempt to read the limit - with the most efficient page size, i.e. min(limit, 1000) - - :returns: list that will contain up to limit results - """ - return [ - record - async for record in await self.stream_async( - order=order, - status=status, - limit=limit, - page_size=page_size, - ) - ] - - def page( - self, - order: Union["PlayerStreamerInstance.Order", object] = values.unset, - status: Union["PlayerStreamerInstance.Status", object] = values.unset, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> PlayerStreamerPage: - """ - Retrieve a single page of PlayerStreamerInstance records from the API. - Request is executed immediately - - :param order: The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default. - :param status: Status to filter by, with possible values `created`, `started`, `ended`, or `failed`. - :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 PlayerStreamerInstance - """ - data = values.of( - { - "Order": order, - "Status": status, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = self._version.page(method="GET", uri=self._uri, params=data) - return PlayerStreamerPage(self._version, response) - - async def page_async( - self, - order: Union["PlayerStreamerInstance.Order", object] = values.unset, - status: Union["PlayerStreamerInstance.Status", object] = values.unset, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> PlayerStreamerPage: - """ - Asynchronously retrieve a single page of PlayerStreamerInstance records from the API. - Request is executed immediately - - :param order: The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default. - :param status: Status to filter by, with possible values `created`, `started`, `ended`, or `failed`. - :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 PlayerStreamerInstance - """ - data = values.of( - { - "Order": order, - "Status": status, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = await self._version.page_async( - method="GET", uri=self._uri, params=data - ) - return PlayerStreamerPage(self._version, response) - - def get_page(self, target_url: str) -> PlayerStreamerPage: - """ - Retrieve a specific page of PlayerStreamerInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of PlayerStreamerInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return PlayerStreamerPage(self._version, response) - - async def get_page_async(self, target_url: str) -> PlayerStreamerPage: - """ - Asynchronously retrieve a specific page of PlayerStreamerInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of PlayerStreamerInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return PlayerStreamerPage(self._version, response) - - def get(self, sid: str) -> PlayerStreamerContext: - """ - Constructs a PlayerStreamerContext - - :param sid: The SID of the PlayerStreamer resource to update. - """ - return PlayerStreamerContext(self._version, sid=sid) - - def __call__(self, sid: str) -> PlayerStreamerContext: - """ - Constructs a PlayerStreamerContext - - :param sid: The SID of the PlayerStreamer resource to update. - """ - return PlayerStreamerContext(self._version, sid=sid) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/media/v1/player_streamer/playback_grant.py b/twilio/rest/media/v1/player_streamer/playback_grant.py deleted file mode 100644 index a4cdbb4026..0000000000 --- a/twilio/rest/media/v1/player_streamer/playback_grant.py +++ /dev/null @@ -1,280 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Media - 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, 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 PlaybackGrantInstance(InstanceResource): - """ - :ivar sid: The unique string generated to identify the PlayerStreamer resource that this PlaybackGrant authorizes views for. - :ivar url: The absolute URL of the resource. - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created this resource. - :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 grant: The grant that authorizes the player sdk to connect to the livestream - """ - - def __init__(self, version: Version, payload: Dict[str, Any], sid: str): - super().__init__(version) - - self.sid: Optional[str] = payload.get("sid") - self.url: Optional[str] = payload.get("url") - self.account_sid: Optional[str] = payload.get("account_sid") - self.date_created: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("date_created") - ) - self.grant: Optional[Dict[str, object]] = payload.get("grant") - - self._solution = { - "sid": sid, - } - self._context: Optional[PlaybackGrantContext] = None - - @property - def _proxy(self) -> "PlaybackGrantContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: PlaybackGrantContext for this PlaybackGrantInstance - """ - if self._context is None: - self._context = PlaybackGrantContext( - self._version, - sid=self._solution["sid"], - ) - return self._context - - def create( - self, - ttl: Union[int, object] = values.unset, - access_control_allow_origin: Union[str, object] = values.unset, - ) -> "PlaybackGrantInstance": - """ - Create the PlaybackGrantInstance - - :param ttl: The time to live of the PlaybackGrant. Default value is 15 seconds. Maximum value is 60 seconds. - :param access_control_allow_origin: The full origin URL where the livestream can be streamed. If this is not provided, it can be streamed from any domain. - - :returns: The created PlaybackGrantInstance - """ - return self._proxy.create( - ttl=ttl, - access_control_allow_origin=access_control_allow_origin, - ) - - async def create_async( - self, - ttl: Union[int, object] = values.unset, - access_control_allow_origin: Union[str, object] = values.unset, - ) -> "PlaybackGrantInstance": - """ - Asynchronous coroutine to create the PlaybackGrantInstance - - :param ttl: The time to live of the PlaybackGrant. Default value is 15 seconds. Maximum value is 60 seconds. - :param access_control_allow_origin: The full origin URL where the livestream can be streamed. If this is not provided, it can be streamed from any domain. - - :returns: The created PlaybackGrantInstance - """ - return await self._proxy.create_async( - ttl=ttl, - access_control_allow_origin=access_control_allow_origin, - ) - - def fetch(self) -> "PlaybackGrantInstance": - """ - Fetch the PlaybackGrantInstance - - - :returns: The fetched PlaybackGrantInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "PlaybackGrantInstance": - """ - Asynchronous coroutine to fetch the PlaybackGrantInstance - - - :returns: The fetched PlaybackGrantInstance - """ - 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 PlaybackGrantContext(InstanceContext): - - def __init__(self, version: Version, sid: str): - """ - Initialize the PlaybackGrantContext - - :param version: Version that contains the resource - :param sid: The SID of the PlayerStreamer resource to fetch. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "sid": sid, - } - self._uri = "/PlayerStreamers/{sid}/PlaybackGrant".format(**self._solution) - - def create( - self, - ttl: Union[int, object] = values.unset, - access_control_allow_origin: Union[str, object] = values.unset, - ) -> PlaybackGrantInstance: - """ - Create the PlaybackGrantInstance - - :param ttl: The time to live of the PlaybackGrant. Default value is 15 seconds. Maximum value is 60 seconds. - :param access_control_allow_origin: The full origin URL where the livestream can be streamed. If this is not provided, it can be streamed from any domain. - - :returns: The created PlaybackGrantInstance - """ - data = values.of( - { - "Ttl": ttl, - "AccessControlAllowOrigin": access_control_allow_origin, - } - ) - - payload = self._version.create(method="POST", uri=self._uri, data=data) - - return PlaybackGrantInstance(self._version, payload, sid=self._solution["sid"]) - - async def create_async( - self, - ttl: Union[int, object] = values.unset, - access_control_allow_origin: Union[str, object] = values.unset, - ) -> PlaybackGrantInstance: - """ - Asynchronous coroutine to create the PlaybackGrantInstance - - :param ttl: The time to live of the PlaybackGrant. Default value is 15 seconds. Maximum value is 60 seconds. - :param access_control_allow_origin: The full origin URL where the livestream can be streamed. If this is not provided, it can be streamed from any domain. - - :returns: The created PlaybackGrantInstance - """ - data = values.of( - { - "Ttl": ttl, - "AccessControlAllowOrigin": access_control_allow_origin, - } - ) - - payload = await self._version.create_async( - method="POST", uri=self._uri, data=data - ) - - return PlaybackGrantInstance(self._version, payload, sid=self._solution["sid"]) - - def fetch(self) -> PlaybackGrantInstance: - """ - Fetch the PlaybackGrantInstance - - - :returns: The fetched PlaybackGrantInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return PlaybackGrantInstance( - self._version, - payload, - sid=self._solution["sid"], - ) - - async def fetch_async(self) -> PlaybackGrantInstance: - """ - Asynchronous coroutine to fetch the PlaybackGrantInstance - - - :returns: The fetched PlaybackGrantInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return PlaybackGrantInstance( - 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 PlaybackGrantList(ListResource): - - def __init__(self, version: Version, sid: str): - """ - Initialize the PlaybackGrantList - - :param version: Version that contains the resource - :param sid: The unique string generated to identify the PlayerStreamer resource associated with this PlaybackGrant - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "sid": sid, - } - - def get(self) -> PlaybackGrantContext: - """ - Constructs a PlaybackGrantContext - - """ - return PlaybackGrantContext(self._version, sid=self._solution["sid"]) - - def __call__(self) -> PlaybackGrantContext: - """ - Constructs a PlaybackGrantContext - - """ - return PlaybackGrantContext(self._version, sid=self._solution["sid"]) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/messaging/MessagingBase.py b/twilio/rest/messaging/MessagingBase.py index 4fff74d914..e45ed56fcd 100644 --- a/twilio/rest/messaging/MessagingBase.py +++ b/twilio/rest/messaging/MessagingBase.py @@ -14,6 +14,7 @@ from twilio.base.domain import Domain from twilio.rest import Client from twilio.rest.messaging.v1 import V1 +from twilio.rest.messaging.v2 import V2 class MessagingBase(Domain): @@ -26,6 +27,7 @@ def __init__(self, twilio: Client): """ super().__init__(twilio, "https://messaging.twilio.com") self._v1: Optional[V1] = None + self._v2: Optional[V2] = None @property def v1(self) -> V1: @@ -36,6 +38,15 @@ def v1(self) -> V1: self._v1 = V1(self) return self._v1 + @property + def v2(self) -> V2: + """ + :returns: Versions v2 of Messaging + """ + if self._v2 is None: + self._v2 = V2(self) + return self._v2 + def __repr__(self) -> str: """ Provide a friendly representation diff --git a/twilio/rest/messaging/v1/__init__.py b/twilio/rest/messaging/v1/__init__.py index 6262dfe938..6bd630fbd8 100644 --- a/twilio/rest/messaging/v1/__init__.py +++ b/twilio/rest/messaging/v1/__init__.py @@ -29,6 +29,7 @@ from twilio.rest.messaging.v1.linkshortening_messaging_service_domain_association import ( LinkshorteningMessagingServiceDomainAssociationList, ) +from twilio.rest.messaging.v1.request_managed_cert import RequestManagedCertList from twilio.rest.messaging.v1.service import ServiceList from twilio.rest.messaging.v1.tollfree_verification import TollfreeVerificationList from twilio.rest.messaging.v1.usecase import UsecaseList @@ -57,6 +58,7 @@ def __init__(self, domain: Domain): self._linkshortening_messaging_service_domain_association: Optional[ LinkshorteningMessagingServiceDomainAssociationList ] = None + self._request_managed_cert: Optional[RequestManagedCertList] = None self._services: Optional[ServiceList] = None self._tollfree_verifications: Optional[TollfreeVerificationList] = None self._usecases: Optional[UsecaseList] = None @@ -117,6 +119,12 @@ def linkshortening_messaging_service_domain_association( ) return self._linkshortening_messaging_service_domain_association + @property + def request_managed_cert(self) -> RequestManagedCertList: + if self._request_managed_cert is None: + self._request_managed_cert = RequestManagedCertList(self) + return self._request_managed_cert + @property def services(self) -> ServiceList: if self._services is None: diff --git a/twilio/rest/messaging/v1/brand_registration/__init__.py b/twilio/rest/messaging/v1/brand_registration/__init__.py index b02af94919..939cba604c 100644 --- a/twilio/rest/messaging/v1/brand_registration/__init__.py +++ b/twilio/rest/messaging/v1/brand_registration/__init__.py @@ -46,7 +46,9 @@ class Status(object): APPROVED = "APPROVED" FAILED = "FAILED" IN_REVIEW = "IN_REVIEW" - DELETED = "DELETED" + DELETION_PENDING = "DELETION_PENDING" + DELETION_FAILED = "DELETION_FAILED" + SUSPENDED = "SUSPENDED" """ :ivar sid: The unique string to identify Brand Registration. @@ -225,10 +227,11 @@ def fetch(self) -> BrandRegistrationInstance: :returns: The fetched BrandRegistrationInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return BrandRegistrationInstance( self._version, @@ -244,9 +247,12 @@ async def fetch_async(self) -> BrandRegistrationInstance: :returns: The fetched BrandRegistrationInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return BrandRegistrationInstance( @@ -262,12 +268,14 @@ def update(self) -> BrandRegistrationInstance: :returns: The updated BrandRegistrationInstance """ + data = values.of({}) + headers = values.of({}) + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return BrandRegistrationInstance( @@ -281,12 +289,14 @@ async def update_async(self) -> BrandRegistrationInstance: :returns: The updated BrandRegistrationInstance """ + data = values.of({}) + headers = values.of({}) + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return BrandRegistrationInstance( @@ -390,11 +400,14 @@ def create( ), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return BrandRegistrationInstance(self._version, payload) @@ -430,11 +443,14 @@ async def create_async( ), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return BrandRegistrationInstance(self._version, payload) @@ -566,7 +582,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return BrandRegistrationPage(self._version, response) async def page_async( @@ -593,8 +615,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return BrandRegistrationPage(self._version, response) diff --git a/twilio/rest/messaging/v1/brand_registration/brand_registration_otp.py b/twilio/rest/messaging/v1/brand_registration/brand_registration_otp.py index 20ce245b37..415dec9589 100644 --- a/twilio/rest/messaging/v1/brand_registration/brand_registration_otp.py +++ b/twilio/rest/messaging/v1/brand_registration/brand_registration_otp.py @@ -13,6 +13,7 @@ """ 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 @@ -77,10 +78,11 @@ def create(self) -> BrandRegistrationOtpInstance: :returns: The created BrandRegistrationOtpInstance """ - payload = self._version.create( - method="POST", - uri=self._uri, - ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + payload = self._version.create(method="POST", uri=self._uri, headers=headers) return BrandRegistrationOtpInstance( self._version, @@ -96,9 +98,12 @@ async def create_async(self) -> BrandRegistrationOtpInstance: :returns: The created BrandRegistrationOtpInstance """ + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + payload = await self._version.create_async( - method="POST", - uri=self._uri, + method="POST", uri=self._uri, headers=headers ) return BrandRegistrationOtpInstance( diff --git a/twilio/rest/messaging/v1/brand_registration/brand_vetting.py b/twilio/rest/messaging/v1/brand_registration/brand_vetting.py index c801cb12b4..b633144a71 100644 --- a/twilio/rest/messaging/v1/brand_registration/brand_vetting.py +++ b/twilio/rest/messaging/v1/brand_registration/brand_vetting.py @@ -26,6 +26,7 @@ class BrandVettingInstance(InstanceResource): class VettingProvider(object): CAMPAIGN_VERIFY = "campaign-verify" + AEGIS = "aegis" """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the vetting record. @@ -147,10 +148,11 @@ def fetch(self) -> BrandVettingInstance: :returns: The fetched BrandVettingInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return BrandVettingInstance( self._version, @@ -167,9 +169,12 @@ async def fetch_async(self) -> BrandVettingInstance: :returns: The fetched BrandVettingInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return BrandVettingInstance( @@ -250,11 +255,14 @@ def create( "VettingId": vetting_id, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return BrandVettingInstance( @@ -281,11 +289,14 @@ async def create_async( "VettingId": vetting_id, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return BrandVettingInstance( @@ -446,7 +457,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return BrandVettingPage(self._version, response, self._solution) async def page_async( @@ -478,8 +495,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return BrandVettingPage(self._version, response, self._solution) diff --git a/twilio/rest/messaging/v1/deactivations.py b/twilio/rest/messaging/v1/deactivations.py index 6616d87df5..e2cbf17a94 100644 --- a/twilio/rest/messaging/v1/deactivations.py +++ b/twilio/rest/messaging/v1/deactivations.py @@ -112,7 +112,13 @@ def fetch(self, date: Union[date, object] = values.unset) -> DeactivationsInstan } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=data) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) return DeactivationsInstance( self._version, @@ -136,8 +142,12 @@ async def fetch_async( } ) + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return DeactivationsInstance( diff --git a/twilio/rest/messaging/v1/domain_certs.py b/twilio/rest/messaging/v1/domain_certs.py index 3acc8a18ff..6da256cdb0 100644 --- a/twilio/rest/messaging/v1/domain_certs.py +++ b/twilio/rest/messaging/v1/domain_certs.py @@ -174,10 +174,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -186,9 +186,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> DomainCertsInstance: @@ -199,10 +201,11 @@ def fetch(self) -> DomainCertsInstance: :returns: The fetched DomainCertsInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return DomainCertsInstance( self._version, @@ -218,9 +221,12 @@ async def fetch_async(self) -> DomainCertsInstance: :returns: The fetched DomainCertsInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return DomainCertsInstance( @@ -237,16 +243,20 @@ def update(self, tls_cert: str) -> DomainCertsInstance: :returns: The updated DomainCertsInstance """ + data = values.of( { "TlsCert": tls_cert, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return DomainCertsInstance( @@ -261,16 +271,20 @@ async def update_async(self, tls_cert: str) -> DomainCertsInstance: :returns: The updated DomainCertsInstance """ + data = values.of( { "TlsCert": tls_cert, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return DomainCertsInstance( diff --git a/twilio/rest/messaging/v1/domain_config.py b/twilio/rest/messaging/v1/domain_config.py index 25d69342d0..ed70351077 100644 --- a/twilio/rest/messaging/v1/domain_config.py +++ b/twilio/rest/messaging/v1/domain_config.py @@ -179,10 +179,11 @@ def fetch(self) -> DomainConfigInstance: :returns: The fetched DomainConfigInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return DomainConfigInstance( self._version, @@ -198,9 +199,12 @@ async def fetch_async(self) -> DomainConfigInstance: :returns: The fetched DomainConfigInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return DomainConfigInstance( @@ -226,6 +230,7 @@ def update( :returns: The updated DomainConfigInstance """ + data = values.of( { "FallbackUrl": fallback_url, @@ -234,11 +239,14 @@ def update( "DisableHttps": serialize.boolean_to_string(disable_https), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return DomainConfigInstance( @@ -262,6 +270,7 @@ async def update_async( :returns: The updated DomainConfigInstance """ + data = values.of( { "FallbackUrl": fallback_url, @@ -270,11 +279,14 @@ async def update_async( "DisableHttps": serialize.boolean_to_string(disable_https), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return DomainConfigInstance( diff --git a/twilio/rest/messaging/v1/domain_config_messaging_service.py b/twilio/rest/messaging/v1/domain_config_messaging_service.py index 178ebd544e..2bcd4aa88c 100644 --- a/twilio/rest/messaging/v1/domain_config_messaging_service.py +++ b/twilio/rest/messaging/v1/domain_config_messaging_service.py @@ -14,7 +14,7 @@ from datetime import datetime from typing import Any, Dict, Optional -from twilio.base import deserialize +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 @@ -134,10 +134,11 @@ def fetch(self) -> DomainConfigMessagingServiceInstance: :returns: The fetched DomainConfigMessagingServiceInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return DomainConfigMessagingServiceInstance( self._version, @@ -153,9 +154,12 @@ async def fetch_async(self) -> DomainConfigMessagingServiceInstance: :returns: The fetched DomainConfigMessagingServiceInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return DomainConfigMessagingServiceInstance( diff --git a/twilio/rest/messaging/v1/external_campaign.py b/twilio/rest/messaging/v1/external_campaign.py index b70d8a4ee1..eed039a6cc 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,25 +84,33 @@ 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"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) 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 """ @@ -107,13 +119,17 @@ 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"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ExternalCampaignInstance(self._version, payload) diff --git a/twilio/rest/messaging/v1/linkshortening_messaging_service.py b/twilio/rest/messaging/v1/linkshortening_messaging_service.py index 94ebfa6173..ac69842a0c 100644 --- a/twilio/rest/messaging/v1/linkshortening_messaging_service.py +++ b/twilio/rest/messaging/v1/linkshortening_messaging_service.py @@ -177,10 +177,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -189,9 +189,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def __repr__(self) -> str: diff --git a/twilio/rest/messaging/v1/linkshortening_messaging_service_domain_association.py b/twilio/rest/messaging/v1/linkshortening_messaging_service_domain_association.py index a1252d2b35..4c0b52bddf 100644 --- a/twilio/rest/messaging/v1/linkshortening_messaging_service_domain_association.py +++ b/twilio/rest/messaging/v1/linkshortening_messaging_service_domain_association.py @@ -13,6 +13,7 @@ """ 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 @@ -122,10 +123,11 @@ def fetch(self) -> LinkshorteningMessagingServiceDomainAssociationInstance: :returns: The fetched LinkshorteningMessagingServiceDomainAssociationInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return LinkshorteningMessagingServiceDomainAssociationInstance( self._version, @@ -143,9 +145,12 @@ async def fetch_async( :returns: The fetched LinkshorteningMessagingServiceDomainAssociationInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return LinkshorteningMessagingServiceDomainAssociationInstance( diff --git a/twilio/rest/messaging/v1/request_managed_cert.py b/twilio/rest/messaging/v1/request_managed_cert.py new file mode 100644 index 0000000000..81ccf9486c --- /dev/null +++ b/twilio/rest/messaging/v1/request_managed_cert.py @@ -0,0 +1,213 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Messaging + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from datetime import datetime +from typing import Any, Dict, Optional +from twilio.base import deserialize, values +from twilio.base.instance_context import InstanceContext +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + + +class RequestManagedCertInstance(InstanceResource): + """ + :ivar domain_sid: The unique string that we created to identify the Domain resource. + :ivar date_updated: Date that this Domain was last updated. + :ivar date_created: Date that this Domain was registered to the Twilio platform to create a new Domain object. + :ivar date_expires: Date that the private certificate associated with this domain expires. This is the expiration date of your existing cert. + :ivar domain_name: Full url path for this domain. + :ivar certificate_sid: The unique string that we created to identify this Certificate resource. + :ivar url: + :ivar managed: A boolean flag indicating if the certificate is managed by Twilio. + :ivar requesting: A boolean flag indicating if a managed certificate needs to be fulfilled by Twilio. + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + domain_sid: Optional[str] = None, + ): + super().__init__(version) + + self.domain_sid: Optional[str] = payload.get("domain_sid") + self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_updated") + ) + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_created") + ) + self.date_expires: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_expires") + ) + self.domain_name: Optional[str] = payload.get("domain_name") + self.certificate_sid: Optional[str] = payload.get("certificate_sid") + self.url: Optional[str] = payload.get("url") + self.managed: Optional[bool] = payload.get("managed") + self.requesting: Optional[bool] = payload.get("requesting") + + self._solution = { + "domain_sid": domain_sid or self.domain_sid, + } + self._context: Optional[RequestManagedCertContext] = None + + @property + def _proxy(self) -> "RequestManagedCertContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: RequestManagedCertContext for this RequestManagedCertInstance + """ + if self._context is None: + self._context = RequestManagedCertContext( + self._version, + domain_sid=self._solution["domain_sid"], + ) + return self._context + + def update(self) -> "RequestManagedCertInstance": + """ + Update the RequestManagedCertInstance + + + :returns: The updated RequestManagedCertInstance + """ + return self._proxy.update() + + async def update_async(self) -> "RequestManagedCertInstance": + """ + Asynchronous coroutine to update the RequestManagedCertInstance + + + :returns: The updated RequestManagedCertInstance + """ + return await self._proxy.update_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 RequestManagedCertContext(InstanceContext): + + def __init__(self, version: Version, domain_sid: str): + """ + Initialize the RequestManagedCertContext + + :param version: Version that contains the resource + :param domain_sid: Unique string used to identify the domain that this certificate should be associated with. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "domain_sid": domain_sid, + } + self._uri = "/LinkShortening/Domains/{domain_sid}/RequestManagedCert".format( + **self._solution + ) + + def update(self) -> RequestManagedCertInstance: + """ + Update the RequestManagedCertInstance + + + :returns: The updated RequestManagedCertInstance + """ + + data = values.of({}) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.update( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return RequestManagedCertInstance( + self._version, payload, domain_sid=self._solution["domain_sid"] + ) + + async def update_async(self) -> RequestManagedCertInstance: + """ + Asynchronous coroutine to update the RequestManagedCertInstance + + + :returns: The updated RequestManagedCertInstance + """ + + data = values.of({}) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.update_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return RequestManagedCertInstance( + self._version, payload, domain_sid=self._solution["domain_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 RequestManagedCertList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the RequestManagedCertList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + def get(self, domain_sid: str) -> RequestManagedCertContext: + """ + Constructs a RequestManagedCertContext + + :param domain_sid: Unique string used to identify the domain that this certificate should be associated with. + """ + return RequestManagedCertContext(self._version, domain_sid=domain_sid) + + def __call__(self, domain_sid: str) -> RequestManagedCertContext: + """ + Constructs a RequestManagedCertContext + + :param domain_sid: Unique string used to identify the domain that this certificate should be associated with. + """ + return RequestManagedCertContext(self._version, domain_sid=domain_sid) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/messaging/v1/service/__init__.py b/twilio/rest/messaging/v1/service/__init__.py index 75c798f4c4..06a53c9a20 100644 --- a/twilio/rest/messaging/v1/service/__init__.py +++ b/twilio/rest/messaging/v1/service/__init__.py @@ -22,6 +22,9 @@ from twilio.base.page import Page from twilio.rest.messaging.v1.service.alpha_sender import AlphaSenderList from twilio.rest.messaging.v1.service.channel_sender import ChannelSenderList +from twilio.rest.messaging.v1.service.destination_alpha_sender import ( + DestinationAlphaSenderList, +) from twilio.rest.messaging.v1.service.phone_number import PhoneNumberList from twilio.rest.messaging.v1.service.short_code import ShortCodeList from twilio.rest.messaging.v1.service.us_app_to_person import UsAppToPersonList @@ -55,7 +58,7 @@ class ScanMessageContent(object): :ivar fallback_to_long_code: [OBSOLETE] Former feature used to fallback to long code sender after certain short code message failures. :ivar area_code_geomatch: Whether to enable [Area Code Geomatch](https://www.twilio.com/docs/messaging/services#area-code-geomatch) on the Service Instance. :ivar synchronous_validation: Reserved. - :ivar validity_period: How long, in seconds, messages sent from the Service are valid. Can be an integer from `1` to `14,400`. + :ivar validity_period: How long, in seconds, messages sent from the Service are valid. Can be an integer from `1` to `14,400`. Default value is `14,400`. :ivar url: The absolute URL of the Service resource. :ivar links: The absolute URLs of related resources. :ivar usecase: A string that describes the scenario in which the Messaging Service will be used. Possible values are `notifications`, `marketing`, `verification`, `discussion`, `poll`, `undeclared`. @@ -200,7 +203,7 @@ def update( :param scan_message_content: :param fallback_to_long_code: [OBSOLETE] Former feature used to fallback to long code sender after certain short code message failures. :param area_code_geomatch: Whether to enable [Area Code Geomatch](https://www.twilio.com/docs/messaging/services#area-code-geomatch) on the Service Instance. - :param validity_period: How long, in seconds, messages sent from the Service are valid. Can be an integer from `1` to `14,400`. + :param validity_period: How long, in seconds, messages sent from the Service are valid. Can be an integer from `1` to `14,400`. Default value is `14,400`. :param synchronous_validation: Reserved. :param usecase: A string that describes the scenario in which the Messaging Service will be used. Possible values are `notifications`, `marketing`, `verification`, `discussion`, `poll`, `undeclared`. :param use_inbound_webhook_on_number: A boolean value that indicates either the webhook url configured on the phone number will be used or `inbound_request_url`/`fallback_url` url will be called when a message is received from the phone number. If this field is enabled then the webhook url defined on the phone number will override the `inbound_request_url`/`fallback_url` defined for the Messaging Service. @@ -262,7 +265,7 @@ async def update_async( :param scan_message_content: :param fallback_to_long_code: [OBSOLETE] Former feature used to fallback to long code sender after certain short code message failures. :param area_code_geomatch: Whether to enable [Area Code Geomatch](https://www.twilio.com/docs/messaging/services#area-code-geomatch) on the Service Instance. - :param validity_period: How long, in seconds, messages sent from the Service are valid. Can be an integer from `1` to `14,400`. + :param validity_period: How long, in seconds, messages sent from the Service are valid. Can be an integer from `1` to `14,400`. Default value is `14,400`. :param synchronous_validation: Reserved. :param usecase: A string that describes the scenario in which the Messaging Service will be used. Possible values are `notifications`, `marketing`, `verification`, `discussion`, `poll`, `undeclared`. :param use_inbound_webhook_on_number: A boolean value that indicates either the webhook url configured on the phone number will be used or `inbound_request_url`/`fallback_url` url will be called when a message is received from the phone number. If this field is enabled then the webhook url defined on the phone number will override the `inbound_request_url`/`fallback_url` defined for the Messaging Service. @@ -302,6 +305,13 @@ def channel_senders(self) -> ChannelSenderList: """ return self._proxy.channel_senders + @property + def destination_alpha_senders(self) -> DestinationAlphaSenderList: + """ + Access the destination_alpha_senders + """ + return self._proxy.destination_alpha_senders + @property def phone_numbers(self) -> PhoneNumberList: """ @@ -359,6 +369,7 @@ def __init__(self, version: Version, sid: str): self._alpha_senders: Optional[AlphaSenderList] = None self._channel_senders: Optional[ChannelSenderList] = None + self._destination_alpha_senders: Optional[DestinationAlphaSenderList] = None self._phone_numbers: Optional[PhoneNumberList] = None self._short_codes: Optional[ShortCodeList] = None self._us_app_to_person: Optional[UsAppToPersonList] = None @@ -371,10 +382,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -383,9 +394,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> ServiceInstance: @@ -396,10 +409,11 @@ def fetch(self) -> ServiceInstance: :returns: The fetched ServiceInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ServiceInstance( self._version, @@ -415,9 +429,12 @@ async def fetch_async(self) -> ServiceInstance: :returns: The fetched ServiceInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ServiceInstance( @@ -462,13 +479,14 @@ def update( :param scan_message_content: :param fallback_to_long_code: [OBSOLETE] Former feature used to fallback to long code sender after certain short code message failures. :param area_code_geomatch: Whether to enable [Area Code Geomatch](https://www.twilio.com/docs/messaging/services#area-code-geomatch) on the Service Instance. - :param validity_period: How long, in seconds, messages sent from the Service are valid. Can be an integer from `1` to `14,400`. + :param validity_period: How long, in seconds, messages sent from the Service are valid. Can be an integer from `1` to `14,400`. Default value is `14,400`. :param synchronous_validation: Reserved. :param usecase: A string that describes the scenario in which the Messaging Service will be used. Possible values are `notifications`, `marketing`, `verification`, `discussion`, `poll`, `undeclared`. :param use_inbound_webhook_on_number: A boolean value that indicates either the webhook url configured on the phone number will be used or `inbound_request_url`/`fallback_url` url will be called when a message is received from the phone number. If this field is enabled then the webhook url defined on the phone number will override the `inbound_request_url`/`fallback_url` defined for the Messaging Service. :returns: The updated ServiceInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -495,11 +513,14 @@ def update( ), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload, sid=self._solution["sid"]) @@ -540,13 +561,14 @@ async def update_async( :param scan_message_content: :param fallback_to_long_code: [OBSOLETE] Former feature used to fallback to long code sender after certain short code message failures. :param area_code_geomatch: Whether to enable [Area Code Geomatch](https://www.twilio.com/docs/messaging/services#area-code-geomatch) on the Service Instance. - :param validity_period: How long, in seconds, messages sent from the Service are valid. Can be an integer from `1` to `14,400`. + :param validity_period: How long, in seconds, messages sent from the Service are valid. Can be an integer from `1` to `14,400`. Default value is `14,400`. :param synchronous_validation: Reserved. :param usecase: A string that describes the scenario in which the Messaging Service will be used. Possible values are `notifications`, `marketing`, `verification`, `discussion`, `poll`, `undeclared`. :param use_inbound_webhook_on_number: A boolean value that indicates either the webhook url configured on the phone number will be used or `inbound_request_url`/`fallback_url` url will be called when a message is received from the phone number. If this field is enabled then the webhook url defined on the phone number will override the `inbound_request_url`/`fallback_url` defined for the Messaging Service. :returns: The updated ServiceInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -573,11 +595,14 @@ async def update_async( ), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload, sid=self._solution["sid"]) @@ -606,6 +631,18 @@ def channel_senders(self) -> ChannelSenderList: ) return self._channel_senders + @property + def destination_alpha_senders(self) -> DestinationAlphaSenderList: + """ + Access the destination_alpha_senders + """ + if self._destination_alpha_senders is None: + self._destination_alpha_senders = DestinationAlphaSenderList( + self._version, + self._solution["sid"], + ) + return self._destination_alpha_senders + @property def phone_numbers(self) -> PhoneNumberList: """ @@ -732,7 +769,7 @@ def create( :param scan_message_content: :param fallback_to_long_code: [OBSOLETE] Former feature used to fallback to long code sender after certain short code message failures. :param area_code_geomatch: Whether to enable [Area Code Geomatch](https://www.twilio.com/docs/messaging/services#area-code-geomatch) on the Service Instance. - :param validity_period: How long, in seconds, messages sent from the Service are valid. Can be an integer from `1` to `14,400`. + :param validity_period: How long, in seconds, messages sent from the Service are valid. Can be an integer from `1` to `14,400`. Default value is `14,400`. :param synchronous_validation: Reserved. :param usecase: A string that describes the scenario in which the Messaging Service will be used. Possible values are `notifications`, `marketing`, `verification`, `discussion`, `poll`, `undeclared`. :param use_inbound_webhook_on_number: A boolean value that indicates either the webhook url configured on the phone number will be used or `inbound_request_url`/`fallback_url` url will be called when a message is received from the phone number. If this field is enabled then the webhook url defined on the phone number will override the `inbound_request_url`/`fallback_url` defined for the Messaging Service. @@ -766,11 +803,14 @@ def create( ), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload) @@ -811,7 +851,7 @@ async def create_async( :param scan_message_content: :param fallback_to_long_code: [OBSOLETE] Former feature used to fallback to long code sender after certain short code message failures. :param area_code_geomatch: Whether to enable [Area Code Geomatch](https://www.twilio.com/docs/messaging/services#area-code-geomatch) on the Service Instance. - :param validity_period: How long, in seconds, messages sent from the Service are valid. Can be an integer from `1` to `14,400`. + :param validity_period: How long, in seconds, messages sent from the Service are valid. Can be an integer from `1` to `14,400`. Default value is `14,400`. :param synchronous_validation: Reserved. :param usecase: A string that describes the scenario in which the Messaging Service will be used. Possible values are `notifications`, `marketing`, `verification`, `discussion`, `poll`, `undeclared`. :param use_inbound_webhook_on_number: A boolean value that indicates either the webhook url configured on the phone number will be used or `inbound_request_url`/`fallback_url` url will be called when a message is received from the phone number. If this field is enabled then the webhook url defined on the phone number will override the `inbound_request_url`/`fallback_url` defined for the Messaging Service. @@ -845,11 +885,14 @@ async def create_async( ), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload) @@ -981,7 +1024,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ServicePage(self._version, response) async def page_async( @@ -1008,8 +1057,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ServicePage(self._version, response) diff --git a/twilio/rest/messaging/v1/service/alpha_sender.py b/twilio/rest/messaging/v1/service/alpha_sender.py index 38d2d0d5e9..2ba4c2a45c 100644 --- a/twilio/rest/messaging/v1/service/alpha_sender.py +++ b/twilio/rest/messaging/v1/service/alpha_sender.py @@ -152,10 +152,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -164,9 +164,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> AlphaSenderInstance: @@ -177,10 +179,11 @@ def fetch(self) -> AlphaSenderInstance: :returns: The fetched AlphaSenderInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return AlphaSenderInstance( self._version, @@ -197,9 +200,12 @@ async def fetch_async(self) -> AlphaSenderInstance: :returns: The fetched AlphaSenderInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return AlphaSenderInstance( @@ -272,11 +278,14 @@ def create(self, alpha_sender: str) -> AlphaSenderInstance: "AlphaSender": alpha_sender, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AlphaSenderInstance( @@ -297,11 +306,14 @@ async def create_async(self, alpha_sender: str) -> AlphaSenderInstance: "AlphaSender": alpha_sender, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AlphaSenderInstance( @@ -435,7 +447,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return AlphaSenderPage(self._version, response, self._solution) async def page_async( @@ -462,8 +480,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return AlphaSenderPage(self._version, response, self._solution) diff --git a/twilio/rest/messaging/v1/service/channel_sender.py b/twilio/rest/messaging/v1/service/channel_sender.py index a8de3d0cf6..9d708a2fba 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,32 @@ 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 + """ + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the ChannelSenderInstance + + + :returns: True if delete succeeds, False otherwise + """ + + headers = values.of({}) + + return await self._version.delete_async( + method="DELETE", uri=self._uri, headers=headers + ) + def fetch(self) -> ChannelSenderInstance: """ Fetch the ChannelSenderInstance @@ -137,10 +181,11 @@ def fetch(self) -> ChannelSenderInstance: :returns: The fetched ChannelSenderInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ChannelSenderInstance( self._version, @@ -157,9 +202,12 @@ async def fetch_async(self) -> ChannelSenderInstance: :returns: The fetched ChannelSenderInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ChannelSenderInstance( @@ -222,6 +270,66 @@ 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"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = self._version.create( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return 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"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return ChannelSenderInstance( + self._version, + payload, + messaging_service_sid=self._solution["messaging_service_sid"], + ) + def stream( self, limit: Optional[int] = None, @@ -349,7 +457,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ChannelSenderPage(self._version, response, self._solution) async def page_async( @@ -376,8 +490,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ChannelSenderPage(self._version, response, self._solution) diff --git a/twilio/rest/preview/sync/service/document/__init__.py b/twilio/rest/messaging/v1/service/destination_alpha_sender.py similarity index 55% rename from twilio/rest/preview/sync/service/document/__init__.py rename to twilio/rest/messaging/v1/service/destination_alpha_sender.py index e7ab4ae8b8..ffe1700929 100644 --- a/twilio/rest/preview/sync/service/document/__init__.py +++ b/twilio/rest/messaging/v1/service/destination_alpha_sender.py @@ -4,7 +4,7 @@ | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - Twilio - Preview + Twilio - Messaging This is the public Twilio REST API. NOTE: This class is auto generated by OpenAPI Generator. @@ -14,30 +14,25 @@ from datetime import datetime from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator -from twilio.base import deserialize, serialize, values +from twilio.base import deserialize, values from twilio.base.instance_context import InstanceContext from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.version import Version from twilio.base.page import Page -from twilio.rest.preview.sync.service.document.document_permission import ( - DocumentPermissionList, -) -class DocumentInstance(InstanceResource): +class DestinationAlphaSenderInstance(InstanceResource): """ - :ivar sid: - :ivar unique_name: - :ivar account_sid: - :ivar service_sid: - :ivar url: - :ivar links: - :ivar revision: - :ivar data: - :ivar date_created: - :ivar date_updated: - :ivar created_by: + :ivar sid: The unique string that we created to identify the AlphaSender resource. + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the AlphaSender resource. + :ivar service_sid: The SID of the [Service](https://www.twilio.com/docs/chat/rest/service-resource) the resource is associated with. + :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 alpha_sender: The Alphanumeric Sender ID string. + :ivar capabilities: An array of values that describe whether the number can receive calls or messages. Can be: `SMS`. + :ivar url: The absolute URL of the AlphaSender resource. + :ivar iso_country_code: The Two Character ISO Country Code the Alphanumeric Sender ID will be used for. For Default Alpha Senders that work across countries, this value will be an empty string """ def __init__( @@ -50,37 +45,35 @@ def __init__( super().__init__(version) self.sid: Optional[str] = payload.get("sid") - self.unique_name: Optional[str] = payload.get("unique_name") self.account_sid: Optional[str] = payload.get("account_sid") self.service_sid: Optional[str] = payload.get("service_sid") - self.url: Optional[str] = payload.get("url") - self.links: Optional[Dict[str, object]] = payload.get("links") - self.revision: Optional[str] = payload.get("revision") - self.data: Optional[Dict[str, object]] = payload.get("data") self.date_created: Optional[datetime] = deserialize.iso8601_datetime( payload.get("date_created") ) self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( payload.get("date_updated") ) - self.created_by: Optional[str] = payload.get("created_by") + self.alpha_sender: Optional[str] = payload.get("alpha_sender") + self.capabilities: Optional[List[str]] = payload.get("capabilities") + self.url: Optional[str] = payload.get("url") + self.iso_country_code: Optional[str] = payload.get("iso_country_code") self._solution = { "service_sid": service_sid, "sid": sid or self.sid, } - self._context: Optional[DocumentContext] = None + self._context: Optional[DestinationAlphaSenderContext] = None @property - def _proxy(self) -> "DocumentContext": + def _proxy(self) -> "DestinationAlphaSenderContext": """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context - :returns: DocumentContext for this DocumentInstance + :returns: DestinationAlphaSenderContext for this DestinationAlphaSenderInstance """ if self._context is None: - self._context = DocumentContext( + self._context = DestinationAlphaSenderContext( self._version, service_sid=self._solution["service_sid"], sid=self._solution["sid"], @@ -89,7 +82,7 @@ def _proxy(self) -> "DocumentContext": def delete(self) -> bool: """ - Deletes the DocumentInstance + Deletes the DestinationAlphaSenderInstance :returns: True if delete succeeds, False otherwise @@ -98,70 +91,31 @@ def delete(self) -> bool: async def delete_async(self) -> bool: """ - Asynchronous coroutine that deletes the DocumentInstance + Asynchronous coroutine that deletes the DestinationAlphaSenderInstance :returns: True if delete succeeds, False otherwise """ return await self._proxy.delete_async() - def fetch(self) -> "DocumentInstance": + def fetch(self) -> "DestinationAlphaSenderInstance": """ - Fetch the DocumentInstance + Fetch the DestinationAlphaSenderInstance - :returns: The fetched DocumentInstance + :returns: The fetched DestinationAlphaSenderInstance """ return self._proxy.fetch() - async def fetch_async(self) -> "DocumentInstance": + async def fetch_async(self) -> "DestinationAlphaSenderInstance": """ - Asynchronous coroutine to fetch the DocumentInstance + Asynchronous coroutine to fetch the DestinationAlphaSenderInstance - :returns: The fetched DocumentInstance + :returns: The fetched DestinationAlphaSenderInstance """ return await self._proxy.fetch_async() - def update( - self, data: object, if_match: Union[str, object] = values.unset - ) -> "DocumentInstance": - """ - Update the DocumentInstance - - :param data: - :param if_match: The If-Match HTTP request header - - :returns: The updated DocumentInstance - """ - return self._proxy.update( - data=data, - if_match=if_match, - ) - - async def update_async( - self, data: object, if_match: Union[str, object] = values.unset - ) -> "DocumentInstance": - """ - Asynchronous coroutine to update the DocumentInstance - - :param data: - :param if_match: The If-Match HTTP request header - - :returns: The updated DocumentInstance - """ - return await self._proxy.update_async( - data=data, - if_match=if_match, - ) - - @property - def document_permissions(self) -> DocumentPermissionList: - """ - Access the document_permissions - """ - return self._proxy.document_permissions - def __repr__(self) -> str: """ Provide a friendly representation @@ -169,18 +123,18 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) - return "".format(context) + return "".format(context) -class DocumentContext(InstanceContext): +class DestinationAlphaSenderContext(InstanceContext): def __init__(self, version: Version, service_sid: str, sid: str): """ - Initialize the DocumentContext + Initialize the DestinationAlphaSenderContext :param version: Version that contains the resource - :param service_sid: - :param sid: + :param service_sid: The SID of the [Service](https://www.twilio.com/docs/chat/rest/service-resource) to fetch the resource from. + :param sid: The SID of the AlphaSender resource to fetch. """ super().__init__(version) @@ -189,153 +143,80 @@ def __init__(self, version: Version, service_sid: str, sid: str): "service_sid": service_sid, "sid": sid, } - self._uri = "/Services/{service_sid}/Documents/{sid}".format(**self._solution) - - self._document_permissions: Optional[DocumentPermissionList] = None + self._uri = "/Services/{service_sid}/DestinationAlphaSenders/{sid}".format( + **self._solution + ) def delete(self) -> bool: """ - Deletes the DocumentInstance + Deletes the DestinationAlphaSenderInstance :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ - Asynchronous coroutine that deletes the DocumentInstance + Asynchronous coroutine that deletes the DestinationAlphaSenderInstance :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) - def fetch(self) -> DocumentInstance: + def fetch(self) -> DestinationAlphaSenderInstance: """ - Fetch the DocumentInstance + Fetch the DestinationAlphaSenderInstance - :returns: The fetched DocumentInstance + :returns: The fetched DestinationAlphaSenderInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) - return DocumentInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - sid=self._solution["sid"], - ) - - async def fetch_async(self) -> DocumentInstance: - """ - Asynchronous coroutine to fetch the DocumentInstance + headers["Accept"] = "application/json" + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) - :returns: The fetched DocumentInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return DocumentInstance( + return DestinationAlphaSenderInstance( self._version, payload, service_sid=self._solution["service_sid"], sid=self._solution["sid"], ) - def update( - self, data: object, if_match: Union[str, object] = values.unset - ) -> DocumentInstance: + async def fetch_async(self) -> DestinationAlphaSenderInstance: """ - Update the DocumentInstance - - :param data: - :param if_match: The If-Match HTTP request header - - :returns: The updated DocumentInstance - """ - data = values.of( - { - "Data": serialize.object(data), - } - ) - headers = values.of( - { - "If-Match": if_match, - } - ) + Asynchronous coroutine to fetch the DestinationAlphaSenderInstance - payload = self._version.update( - method="POST", uri=self._uri, data=data, headers=headers - ) - - return DocumentInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - sid=self._solution["sid"], - ) - async def update_async( - self, data: object, if_match: Union[str, object] = values.unset - ) -> DocumentInstance: + :returns: The fetched DestinationAlphaSenderInstance """ - Asynchronous coroutine to update the DocumentInstance - :param data: - :param if_match: The If-Match HTTP request header + headers = values.of({}) - :returns: The updated DocumentInstance - """ - data = values.of( - { - "Data": serialize.object(data), - } - ) - headers = values.of( - { - "If-Match": if_match, - } - ) + headers["Accept"] = "application/json" - payload = await self._version.update_async( - method="POST", uri=self._uri, data=data, headers=headers + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers ) - return DocumentInstance( + return DestinationAlphaSenderInstance( self._version, payload, service_sid=self._solution["service_sid"], sid=self._solution["sid"], ) - @property - def document_permissions(self) -> DocumentPermissionList: - """ - Access the document_permissions - """ - if self._document_permissions is None: - self._document_permissions = DocumentPermissionList( - self._version, - self._solution["service_sid"], - self._solution["sid"], - ) - return self._document_permissions - def __repr__(self) -> str: """ Provide a friendly representation @@ -343,18 +224,18 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) - return "".format(context) + return "".format(context) -class DocumentPage(Page): +class DestinationAlphaSenderPage(Page): - def get_instance(self, payload: Dict[str, Any]) -> DocumentInstance: + def get_instance(self, payload: Dict[str, Any]) -> DestinationAlphaSenderInstance: """ - Build an instance of DocumentInstance + Build an instance of DestinationAlphaSenderInstance :param payload: Payload response from the API """ - return DocumentInstance( + return DestinationAlphaSenderInstance( self._version, payload, service_sid=self._solution["service_sid"] ) @@ -364,17 +245,17 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ - return "" + return "" -class DocumentList(ListResource): +class DestinationAlphaSenderList(ListResource): def __init__(self, version: Version, service_sid: str): """ - Initialize the DocumentList + Initialize the DestinationAlphaSenderList :param version: Version that contains the resource - :param service_sid: + :param service_sid: The SID of the [Service](https://www.twilio.com/docs/chat/rest/service-resource) to read the resources from. """ super().__init__(version) @@ -383,67 +264,71 @@ def __init__(self, version: Version, service_sid: str): self._solution = { "service_sid": service_sid, } - self._uri = "/Services/{service_sid}/Documents".format(**self._solution) + self._uri = "/Services/{service_sid}/DestinationAlphaSenders".format( + **self._solution + ) def create( - self, - unique_name: Union[str, object] = values.unset, - data: Union[object, object] = values.unset, - ) -> DocumentInstance: + self, alpha_sender: str, iso_country_code: Union[str, object] = values.unset + ) -> DestinationAlphaSenderInstance: """ - Create the DocumentInstance + Create the DestinationAlphaSenderInstance - :param unique_name: - :param data: + :param alpha_sender: The Alphanumeric Sender ID string. Can be up to 11 characters long. Valid characters are A-Z, a-z, 0-9, space, hyphen `-`, plus `+`, underscore `_` and ampersand `&`. This value cannot contain only numbers. + :param iso_country_code: The Optional Two Character ISO Country Code the Alphanumeric Sender ID will be used for. If the IsoCountryCode is not provided, a default Alpha Sender will be created that can be used across all countries. - :returns: The created DocumentInstance + :returns: The created DestinationAlphaSenderInstance """ data = values.of( { - "UniqueName": unique_name, - "Data": serialize.object(data), + "AlphaSender": alpha_sender, + "IsoCountryCode": iso_country_code, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) - return DocumentInstance( + return DestinationAlphaSenderInstance( self._version, payload, service_sid=self._solution["service_sid"] ) async def create_async( - self, - unique_name: Union[str, object] = values.unset, - data: Union[object, object] = values.unset, - ) -> DocumentInstance: + self, alpha_sender: str, iso_country_code: Union[str, object] = values.unset + ) -> DestinationAlphaSenderInstance: """ - Asynchronously create the DocumentInstance + Asynchronously create the DestinationAlphaSenderInstance - :param unique_name: - :param data: + :param alpha_sender: The Alphanumeric Sender ID string. Can be up to 11 characters long. Valid characters are A-Z, a-z, 0-9, space, hyphen `-`, plus `+`, underscore `_` and ampersand `&`. This value cannot contain only numbers. + :param iso_country_code: The Optional Two Character ISO Country Code the Alphanumeric Sender ID will be used for. If the IsoCountryCode is not provided, a default Alpha Sender will be created that can be used across all countries. - :returns: The created DocumentInstance + :returns: The created DestinationAlphaSenderInstance """ data = values.of( { - "UniqueName": unique_name, - "Data": serialize.object(data), + "AlphaSender": alpha_sender, + "IsoCountryCode": iso_country_code, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) - return DocumentInstance( + return DestinationAlphaSenderInstance( self._version, payload, service_sid=self._solution["service_sid"] ) @@ -451,9 +336,9 @@ def stream( self, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> Iterator[DocumentInstance]: + ) -> Iterator[DestinationAlphaSenderInstance]: """ - Streams DocumentInstance records from the API as a generator stream. + Streams DestinationAlphaSenderInstance 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. @@ -476,9 +361,9 @@ async def stream_async( self, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> AsyncIterator[DocumentInstance]: + ) -> AsyncIterator[DestinationAlphaSenderInstance]: """ - Asynchronously streams DocumentInstance records from the API as a generator stream. + Asynchronously streams DestinationAlphaSenderInstance 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. @@ -501,9 +386,9 @@ def list( self, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> List[DocumentInstance]: + ) -> List[DestinationAlphaSenderInstance]: """ - Lists DocumentInstance records from the API as a list. + Lists DestinationAlphaSenderInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @@ -527,9 +412,9 @@ async def list_async( self, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> List[DocumentInstance]: + ) -> List[DestinationAlphaSenderInstance]: """ - Asynchronously lists DocumentInstance records from the API as a list. + Asynchronously lists DestinationAlphaSenderInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @@ -555,16 +440,16 @@ def page( page_token: Union[str, object] = values.unset, page_number: Union[int, object] = values.unset, page_size: Union[int, object] = values.unset, - ) -> DocumentPage: + ) -> DestinationAlphaSenderPage: """ - Retrieve a single page of DocumentInstance records from the API. + Retrieve a single page of DestinationAlphaSenderInstance records from the API. Request is executed immediately :param page_token: PageToken provided by the API :param page_number: Page Number, this value is simply for client state :param page_size: Number of records to return, defaults to 50 - :returns: Page of DocumentInstance + :returns: Page of DestinationAlphaSenderInstance """ data = values.of( { @@ -574,24 +459,30 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) - return DocumentPage(self._version, response, self._solution) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return DestinationAlphaSenderPage(self._version, response, self._solution) async def page_async( self, page_token: Union[str, object] = values.unset, page_number: Union[int, object] = values.unset, page_size: Union[int, object] = values.unset, - ) -> DocumentPage: + ) -> DestinationAlphaSenderPage: """ - Asynchronously retrieve a single page of DocumentInstance records from the API. + Asynchronously retrieve a single page of DestinationAlphaSenderInstance records from the API. Request is executed immediately :param page_token: PageToken provided by the API :param page_number: Page Number, this value is simply for client state :param page_size: Number of records to return, defaults to 50 - :returns: Page of DocumentInstance + :returns: Page of DestinationAlphaSenderInstance """ data = values.of( { @@ -601,52 +492,56 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) - return DocumentPage(self._version, response, self._solution) + return DestinationAlphaSenderPage(self._version, response, self._solution) - def get_page(self, target_url: str) -> DocumentPage: + def get_page(self, target_url: str) -> DestinationAlphaSenderPage: """ - Retrieve a specific page of DocumentInstance records from the API. + Retrieve a specific page of DestinationAlphaSenderInstance records from the API. Request is executed immediately :param target_url: API-generated URL for the requested results page - :returns: Page of DocumentInstance + :returns: Page of DestinationAlphaSenderInstance """ response = self._version.domain.twilio.request("GET", target_url) - return DocumentPage(self._version, response, self._solution) + return DestinationAlphaSenderPage(self._version, response, self._solution) - async def get_page_async(self, target_url: str) -> DocumentPage: + async def get_page_async(self, target_url: str) -> DestinationAlphaSenderPage: """ - Asynchronously retrieve a specific page of DocumentInstance records from the API. + Asynchronously retrieve a specific page of DestinationAlphaSenderInstance records from the API. Request is executed immediately :param target_url: API-generated URL for the requested results page - :returns: Page of DocumentInstance + :returns: Page of DestinationAlphaSenderInstance """ response = await self._version.domain.twilio.request_async("GET", target_url) - return DocumentPage(self._version, response, self._solution) + return DestinationAlphaSenderPage(self._version, response, self._solution) - def get(self, sid: str) -> DocumentContext: + def get(self, sid: str) -> DestinationAlphaSenderContext: """ - Constructs a DocumentContext + Constructs a DestinationAlphaSenderContext - :param sid: + :param sid: The SID of the AlphaSender resource to fetch. """ - return DocumentContext( + return DestinationAlphaSenderContext( self._version, service_sid=self._solution["service_sid"], sid=sid ) - def __call__(self, sid: str) -> DocumentContext: + def __call__(self, sid: str) -> DestinationAlphaSenderContext: """ - Constructs a DocumentContext + Constructs a DestinationAlphaSenderContext - :param sid: + :param sid: The SID of the AlphaSender resource to fetch. """ - return DocumentContext( + return DestinationAlphaSenderContext( self._version, service_sid=self._solution["service_sid"], sid=sid ) @@ -656,4 +551,4 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ - return "" + return "" diff --git a/twilio/rest/messaging/v1/service/phone_number.py b/twilio/rest/messaging/v1/service/phone_number.py index 8b0b4c0900..11b806583e 100644 --- a/twilio/rest/messaging/v1/service/phone_number.py +++ b/twilio/rest/messaging/v1/service/phone_number.py @@ -154,10 +154,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -166,9 +166,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> PhoneNumberInstance: @@ -179,10 +181,11 @@ def fetch(self) -> PhoneNumberInstance: :returns: The fetched PhoneNumberInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return PhoneNumberInstance( self._version, @@ -199,9 +202,12 @@ async def fetch_async(self) -> PhoneNumberInstance: :returns: The fetched PhoneNumberInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return PhoneNumberInstance( @@ -274,11 +280,14 @@ def create(self, phone_number_sid: str) -> PhoneNumberInstance: "PhoneNumberSid": phone_number_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return PhoneNumberInstance( @@ -299,11 +308,14 @@ async def create_async(self, phone_number_sid: str) -> PhoneNumberInstance: "PhoneNumberSid": phone_number_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return PhoneNumberInstance( @@ -437,7 +449,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return PhoneNumberPage(self._version, response, self._solution) async def page_async( @@ -464,8 +482,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return PhoneNumberPage(self._version, response, self._solution) diff --git a/twilio/rest/messaging/v1/service/short_code.py b/twilio/rest/messaging/v1/service/short_code.py index 6537875891..172c78dbb9 100644 --- a/twilio/rest/messaging/v1/service/short_code.py +++ b/twilio/rest/messaging/v1/service/short_code.py @@ -152,10 +152,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -164,9 +164,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> ShortCodeInstance: @@ -177,10 +179,11 @@ def fetch(self) -> ShortCodeInstance: :returns: The fetched ShortCodeInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ShortCodeInstance( self._version, @@ -197,9 +200,12 @@ async def fetch_async(self) -> ShortCodeInstance: :returns: The fetched ShortCodeInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ShortCodeInstance( @@ -272,11 +278,14 @@ def create(self, short_code_sid: str) -> ShortCodeInstance: "ShortCodeSid": short_code_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ShortCodeInstance( @@ -297,11 +306,14 @@ async def create_async(self, short_code_sid: str) -> ShortCodeInstance: "ShortCodeSid": short_code_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ShortCodeInstance( @@ -435,7 +447,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ShortCodePage(self._version, response, self._solution) async def page_async( @@ -462,8 +480,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ShortCodePage(self._version, response, self._solution) diff --git a/twilio/rest/messaging/v1/service/us_app_to_person.py b/twilio/rest/messaging/v1/service/us_app_to_person.py index 9034e4e2eb..dd451f5c59 100644 --- a/twilio/rest/messaging/v1/service/us_app_to_person.py +++ b/twilio/rest/messaging/v1/service/us_app_to_person.py @@ -264,10 +264,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -276,9 +276,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> UsAppToPersonInstance: @@ -289,10 +291,11 @@ def fetch(self) -> UsAppToPersonInstance: :returns: The fetched UsAppToPersonInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return UsAppToPersonInstance( self._version, @@ -309,9 +312,12 @@ async def fetch_async(self) -> UsAppToPersonInstance: :returns: The fetched UsAppToPersonInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return UsAppToPersonInstance( @@ -344,6 +350,7 @@ def update( :returns: The updated UsAppToPersonInstance """ + data = values.of( { "HasEmbeddedLinks": serialize.boolean_to_string(has_embedded_links), @@ -355,11 +362,14 @@ def update( "DirectLending": serialize.boolean_to_string(direct_lending), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return UsAppToPersonInstance( @@ -392,6 +402,7 @@ async def update_async( :returns: The updated UsAppToPersonInstance """ + data = values.of( { "HasEmbeddedLinks": serialize.boolean_to_string(has_embedded_links), @@ -403,11 +414,14 @@ async def update_async( "DirectLending": serialize.boolean_to_string(direct_lending), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return UsAppToPersonInstance( @@ -532,11 +546,14 @@ def create( "DirectLending": serialize.boolean_to_string(direct_lending), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return UsAppToPersonInstance( @@ -607,11 +624,14 @@ async def create_async( "DirectLending": serialize.boolean_to_string(direct_lending), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return UsAppToPersonInstance( @@ -747,7 +767,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return UsAppToPersonPage(self._version, response, self._solution) async def page_async( @@ -774,8 +800,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return UsAppToPersonPage(self._version, response, self._solution) diff --git a/twilio/rest/messaging/v1/service/us_app_to_person_usecase.py b/twilio/rest/messaging/v1/service/us_app_to_person_usecase.py index debcf940d9..bf9e48e626 100644 --- a/twilio/rest/messaging/v1/service/us_app_to_person_usecase.py +++ b/twilio/rest/messaging/v1/service/us_app_to_person_usecase.py @@ -79,6 +79,9 @@ def fetch( :param brand_registration_sid: The unique string to identify the A2P brand. :returns: The fetched UsAppToPersonUsecaseInstance """ + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" params = values.of( { @@ -86,7 +89,9 @@ def fetch( } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=params) + payload = self._version.fetch( + method="GET", uri=self._uri, headers=headers, params=params + ) return UsAppToPersonUsecaseInstance( self._version, @@ -103,6 +108,9 @@ async def fetch_async( :param brand_registration_sid: The unique string to identify the A2P brand. :returns: The fetched UsAppToPersonUsecaseInstance """ + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" params = values.of( { @@ -111,7 +119,7 @@ async def fetch_async( ) payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=params + method="GET", uri=self._uri, headers=headers, params=params ) return UsAppToPersonUsecaseInstance( diff --git a/twilio/rest/messaging/v1/tollfree_verification.py b/twilio/rest/messaging/v1/tollfree_verification.py index e742c57191..00cf9c96e3 100644 --- a/twilio/rest/messaging/v1/tollfree_verification.py +++ b/twilio/rest/messaging/v1/tollfree_verification.py @@ -30,6 +30,8 @@ class OptInType(object): PAPER_FORM = "PAPER_FORM" VIA_TEXT = "VIA_TEXT" MOBILE_QR_CODE = "MOBILE_QR_CODE" + IMPORT = "IMPORT" + IMPORT_PLEASE_REPLACE = "IMPORT_PLEASE_REPLACE" class Status(object): PENDING_REVIEW = "PENDING_REVIEW" @@ -398,10 +400,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -410,9 +412,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> TollfreeVerificationInstance: @@ -423,10 +427,11 @@ def fetch(self) -> TollfreeVerificationInstance: :returns: The fetched TollfreeVerificationInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return TollfreeVerificationInstance( self._version, @@ -442,9 +447,12 @@ async def fetch_async(self) -> TollfreeVerificationInstance: :returns: The fetched TollfreeVerificationInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return TollfreeVerificationInstance( @@ -506,6 +514,7 @@ def update( :returns: The updated TollfreeVerificationInstance """ + data = values.of( { "BusinessName": business_name, @@ -531,11 +540,14 @@ def update( "EditReason": edit_reason, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TollfreeVerificationInstance( @@ -595,6 +607,7 @@ async def update_async( :returns: The updated TollfreeVerificationInstance """ + data = values.of( { "BusinessName": business_name, @@ -620,11 +633,14 @@ async def update_async( "EditReason": edit_reason, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TollfreeVerificationInstance( @@ -756,11 +772,14 @@ def create( "ExternalReferenceId": external_reference_id, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TollfreeVerificationInstance(self._version, payload) @@ -848,11 +867,14 @@ async def create_async( "ExternalReferenceId": external_reference_id, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TollfreeVerificationInstance(self._version, payload) @@ -861,6 +883,8 @@ def stream( self, tollfree_phone_number_sid: Union[str, object] = values.unset, status: Union["TollfreeVerificationInstance.Status", object] = values.unset, + external_reference_id: Union[str, object] = values.unset, + include_sub_accounts: Union[bool, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, ) -> Iterator[TollfreeVerificationInstance]: @@ -872,6 +896,8 @@ def stream( :param str tollfree_phone_number_sid: The SID of the Phone Number associated with the Tollfree Verification. :param "TollfreeVerificationInstance.Status" status: The compliance status of the Tollfree Verification record. + :param str external_reference_id: Customer supplied reference id for the Tollfree Verification record. + :param bool include_sub_accounts: Whether to include Tollfree Verifications from sub accounts in list response. :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 @@ -885,6 +911,8 @@ def stream( page = self.page( tollfree_phone_number_sid=tollfree_phone_number_sid, status=status, + external_reference_id=external_reference_id, + include_sub_accounts=include_sub_accounts, page_size=limits["page_size"], ) @@ -894,6 +922,8 @@ async def stream_async( self, tollfree_phone_number_sid: Union[str, object] = values.unset, status: Union["TollfreeVerificationInstance.Status", object] = values.unset, + external_reference_id: Union[str, object] = values.unset, + include_sub_accounts: Union[bool, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, ) -> AsyncIterator[TollfreeVerificationInstance]: @@ -905,6 +935,8 @@ async def stream_async( :param str tollfree_phone_number_sid: The SID of the Phone Number associated with the Tollfree Verification. :param "TollfreeVerificationInstance.Status" status: The compliance status of the Tollfree Verification record. + :param str external_reference_id: Customer supplied reference id for the Tollfree Verification record. + :param bool include_sub_accounts: Whether to include Tollfree Verifications from sub accounts in list response. :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 @@ -918,6 +950,8 @@ async def stream_async( page = await self.page_async( tollfree_phone_number_sid=tollfree_phone_number_sid, status=status, + external_reference_id=external_reference_id, + include_sub_accounts=include_sub_accounts, page_size=limits["page_size"], ) @@ -927,6 +961,8 @@ def list( self, tollfree_phone_number_sid: Union[str, object] = values.unset, status: Union["TollfreeVerificationInstance.Status", object] = values.unset, + external_reference_id: Union[str, object] = values.unset, + include_sub_accounts: Union[bool, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, ) -> List[TollfreeVerificationInstance]: @@ -937,6 +973,8 @@ def list( :param str tollfree_phone_number_sid: The SID of the Phone Number associated with the Tollfree Verification. :param "TollfreeVerificationInstance.Status" status: The compliance status of the Tollfree Verification record. + :param str external_reference_id: Customer supplied reference id for the Tollfree Verification record. + :param bool include_sub_accounts: Whether to include Tollfree Verifications from sub accounts in list response. :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 @@ -950,6 +988,8 @@ def list( self.stream( tollfree_phone_number_sid=tollfree_phone_number_sid, status=status, + external_reference_id=external_reference_id, + include_sub_accounts=include_sub_accounts, limit=limit, page_size=page_size, ) @@ -959,6 +999,8 @@ async def list_async( self, tollfree_phone_number_sid: Union[str, object] = values.unset, status: Union["TollfreeVerificationInstance.Status", object] = values.unset, + external_reference_id: Union[str, object] = values.unset, + include_sub_accounts: Union[bool, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, ) -> List[TollfreeVerificationInstance]: @@ -969,6 +1011,8 @@ async def list_async( :param str tollfree_phone_number_sid: The SID of the Phone Number associated with the Tollfree Verification. :param "TollfreeVerificationInstance.Status" status: The compliance status of the Tollfree Verification record. + :param str external_reference_id: Customer supplied reference id for the Tollfree Verification record. + :param bool include_sub_accounts: Whether to include Tollfree Verifications from sub accounts in list response. :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 @@ -983,6 +1027,8 @@ async def list_async( async for record in await self.stream_async( tollfree_phone_number_sid=tollfree_phone_number_sid, status=status, + external_reference_id=external_reference_id, + include_sub_accounts=include_sub_accounts, limit=limit, page_size=page_size, ) @@ -992,6 +1038,8 @@ def page( self, tollfree_phone_number_sid: Union[str, object] = values.unset, status: Union["TollfreeVerificationInstance.Status", object] = values.unset, + external_reference_id: Union[str, object] = values.unset, + include_sub_accounts: 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, @@ -1002,6 +1050,8 @@ def page( :param tollfree_phone_number_sid: The SID of the Phone Number associated with the Tollfree Verification. :param status: The compliance status of the Tollfree Verification record. + :param external_reference_id: Customer supplied reference id for the Tollfree Verification record. + :param include_sub_accounts: Whether to include Tollfree Verifications from sub accounts in list response. :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 @@ -1012,19 +1062,29 @@ def page( { "TollfreePhoneNumberSid": tollfree_phone_number_sid, "Status": status, + "ExternalReferenceId": external_reference_id, + "IncludeSubAccounts": serialize.boolean_to_string(include_sub_accounts), "PageToken": page_token, "Page": page_number, "PageSize": page_size, } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return TollfreeVerificationPage(self._version, response) async def page_async( self, tollfree_phone_number_sid: Union[str, object] = values.unset, status: Union["TollfreeVerificationInstance.Status", object] = values.unset, + external_reference_id: Union[str, object] = values.unset, + include_sub_accounts: 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, @@ -1035,6 +1095,8 @@ async def page_async( :param tollfree_phone_number_sid: The SID of the Phone Number associated with the Tollfree Verification. :param status: The compliance status of the Tollfree Verification record. + :param external_reference_id: Customer supplied reference id for the Tollfree Verification record. + :param include_sub_accounts: Whether to include Tollfree Verifications from sub accounts in list response. :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 @@ -1045,14 +1107,20 @@ async def page_async( { "TollfreePhoneNumberSid": tollfree_phone_number_sid, "Status": status, + "ExternalReferenceId": external_reference_id, + "IncludeSubAccounts": serialize.boolean_to_string(include_sub_accounts), "PageToken": page_token, "Page": page_number, "PageSize": page_size, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return TollfreeVerificationPage(self._version, response) diff --git a/twilio/rest/messaging/v1/usecase.py b/twilio/rest/messaging/v1/usecase.py index d7223f3632..fe811e0c84 100644 --- a/twilio/rest/messaging/v1/usecase.py +++ b/twilio/rest/messaging/v1/usecase.py @@ -13,6 +13,7 @@ """ from typing import Any, Dict, List, Optional +from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource @@ -59,8 +60,11 @@ def fetch(self) -> UsecaseInstance: :returns: The fetched UsecaseInstance """ + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - payload = self._version.fetch(method="GET", uri=self._uri) + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return UsecaseInstance(self._version, payload) @@ -71,8 +75,13 @@ async def fetch_async(self) -> UsecaseInstance: :returns: The fetched UsecaseInstance """ + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" - payload = await self._version.fetch_async(method="GET", uri=self._uri) + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) return UsecaseInstance(self._version, payload) diff --git a/twilio/rest/preview/deployed_devices/__init__.py b/twilio/rest/messaging/v2/__init__.py similarity index 59% rename from twilio/rest/preview/deployed_devices/__init__.py rename to twilio/rest/messaging/v2/__init__.py index 795ee96566..7ef89fdc5a 100644 --- a/twilio/rest/preview/deployed_devices/__init__.py +++ b/twilio/rest/messaging/v2/__init__.py @@ -4,7 +4,7 @@ | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - Twilio - Preview + Twilio - Messaging This is the public Twilio REST API. NOTE: This class is auto generated by OpenAPI Generator. @@ -15,29 +15,29 @@ from typing import Optional from twilio.base.version import Version from twilio.base.domain import Domain -from twilio.rest.preview.deployed_devices.fleet import FleetList +from twilio.rest.messaging.v2.channels_sender import ChannelsSenderList -class DeployedDevices(Version): +class V2(Version): def __init__(self, domain: Domain): """ - Initialize the DeployedDevices version of Preview + Initialize the V2 version of Messaging - :param domain: The Twilio.preview domain + :param domain: The Twilio.messaging domain """ - super().__init__(domain, "DeployedDevices") - self._fleets: Optional[FleetList] = None + super().__init__(domain, "v2") + self._channels_senders: Optional[ChannelsSenderList] = None @property - def fleets(self) -> FleetList: - if self._fleets is None: - self._fleets = FleetList(self) - return self._fleets + def channels_senders(self) -> ChannelsSenderList: + if self._channels_senders is None: + self._channels_senders = ChannelsSenderList(self) + return self._channels_senders def __repr__(self) -> str: """ Provide a friendly representation :returns: Machine friendly representation """ - return "" + return "" diff --git a/twilio/rest/messaging/v2/channels_sender.py b/twilio/rest/messaging/v2/channels_sender.py new file mode 100644 index 0000000000..53fa2e6e1e --- /dev/null +++ b/twilio/rest/messaging/v2/channels_sender.py @@ -0,0 +1,1242 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Messaging + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator +from twilio.base import 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 ChannelsSenderInstance(InstanceResource): + + class MessagingV2ChannelsSenderConfiguration(object): + """ + :ivar waba_id: The ID of the WhatsApp Business Account to use for this sender. + :ivar verification_method: The method to use for verification. Either \"sms\" or \"voice\". + :ivar verification_code: The verification code to use for this sender. + :ivar voice_application_sid: The SID of the Twilio Voice application to use for this sender. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.waba_id: Optional[str] = payload.get("waba_id") + self.verification_method: Optional["ChannelsSenderInstance.str"] = ( + payload.get("verification_method") + ) + self.verification_code: Optional[str] = payload.get("verification_code") + self.voice_application_sid: Optional[str] = payload.get( + "voice_application_sid" + ) + + def to_dict(self): + return { + "waba_id": self.waba_id, + "verification_method": self.verification_method, + "verification_code": self.verification_code, + "voice_application_sid": self.voice_application_sid, + } + + class MessagingV2ChannelsSenderProfile(object): + """ + :ivar name: The name of the sender. + :ivar about: The about text of the sender. + :ivar address: The address of the sender. + :ivar description: The description of the sender. + :ivar emails: The emails of the sender. + :ivar logo_url: The logo URL of the sender. + :ivar vertical: The vertical of the sender. Allowed values are: - \"Automotive\" - \"Beauty, Spa and Salon\" - \"Clothing and Apparel\" - \"Education\" - \"Entertainment\" - \"Event Planning and Service\" - \"Finance and Banking\" - \"Food and Grocery\" - \"Public Service\" - \"Hotel and Lodging\" - \"Medical and Health\" - \"Non-profit\" - \"Professional Services\" - \"Shopping and Retail\" - \"Travel and Transportation\" - \"Restaurant\" - \"Other\" + :ivar websites: The websites of the sender. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.name: Optional[str] = payload.get("name") + self.about: Optional[str] = payload.get("about") + self.address: Optional[str] = payload.get("address") + self.description: Optional[str] = payload.get("description") + self.emails: Optional[ + List[ChannelsSenderList.MessagingV2ChannelsSenderProfileEmails] + ] = payload.get("emails") + self.logo_url: Optional[str] = payload.get("logo_url") + self.vertical: Optional[str] = payload.get("vertical") + self.websites: Optional[ + List[ChannelsSenderList.MessagingV2ChannelsSenderProfileWebsites] + ] = payload.get("websites") + + def to_dict(self): + return { + "name": self.name, + "about": self.about, + "address": self.address, + "description": self.description, + "emails": ( + [emails.to_dict() for emails in self.emails] + if self.emails is not None + else None + ), + "logo_url": self.logo_url, + "vertical": self.vertical, + "websites": ( + [websites.to_dict() for websites in self.websites] + if self.websites is not None + else None + ), + } + + class MessagingV2ChannelsSenderProfileEmails(object): + """ + :ivar email: The email of the sender. + :ivar label: The label of the sender. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.email: Optional[str] = payload.get("email") + self.label: Optional[str] = payload.get("label") + + def to_dict(self): + return { + "email": self.email, + "label": self.label, + } + + class MessagingV2ChannelsSenderProfileWebsites(object): + """ + :ivar label: The label of the sender. + :ivar website: The website of the sender. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.label: Optional[str] = payload.get("label") + self.website: Optional[str] = payload.get("website") + + def to_dict(self): + return { + "label": self.label, + "website": self.website, + } + + class MessagingV2ChannelsSenderRequestsCreate(object): + """ + :ivar sender_id: The ID of this Sender prefixed with the channel, e.g., `whatsapp:E.164` + :ivar configuration: + :ivar webhook: + :ivar profile: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.sender_id: Optional[str] = payload.get("sender_id") + self.configuration: Optional[ + ChannelsSenderList.MessagingV2ChannelsSenderConfiguration + ] = payload.get("configuration") + self.webhook: Optional[ + ChannelsSenderList.MessagingV2ChannelsSenderWebhook + ] = payload.get("webhook") + self.profile: Optional[ + ChannelsSenderList.MessagingV2ChannelsSenderProfile + ] = payload.get("profile") + + def to_dict(self): + return { + "sender_id": self.sender_id, + "configuration": ( + self.configuration.to_dict() + if self.configuration is not None + else None + ), + "webhook": self.webhook.to_dict() if self.webhook is not None else None, + "profile": self.profile.to_dict() if self.profile is not None else None, + } + + class MessagingV2ChannelsSenderRequestsUpdate(object): + """ + :ivar configuration: + :ivar webhook: + :ivar profile: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.configuration: Optional[ + ChannelsSenderList.MessagingV2ChannelsSenderConfiguration + ] = payload.get("configuration") + self.webhook: Optional[ + ChannelsSenderList.MessagingV2ChannelsSenderWebhook + ] = payload.get("webhook") + self.profile: Optional[ + ChannelsSenderList.MessagingV2ChannelsSenderProfile + ] = payload.get("profile") + + def to_dict(self): + return { + "configuration": ( + self.configuration.to_dict() + if self.configuration is not None + else None + ), + "webhook": self.webhook.to_dict() if self.webhook is not None else None, + "profile": self.profile.to_dict() if self.profile is not None else None, + } + + class MessagingV2ChannelsSenderWebhook(object): + """ + :ivar callback_url: The URL to send the webhook to. + :ivar callback_method: The HTTP method to use for the webhook. Either \"POST\" or \"PUT\". + :ivar fallback_url: The URL to send the fallback webhook to. + :ivar fallback_method: The HTTP method to use for the fallback webhook. Either \"POST\" or \"PUT\". + :ivar status_callback_url: The URL to send the status callback to. + :ivar status_callback_method: The HTTP method to use for the status callback. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.callback_url: Optional[str] = payload.get("callback_url") + self.callback_method: Optional["ChannelsSenderInstance.str"] = payload.get( + "callback_method" + ) + self.fallback_url: Optional[str] = payload.get("fallback_url") + self.fallback_method: Optional["ChannelsSenderInstance.str"] = payload.get( + "fallback_method" + ) + self.status_callback_url: Optional[str] = payload.get("status_callback_url") + self.status_callback_method: Optional[str] = payload.get( + "status_callback_method" + ) + + def to_dict(self): + return { + "callback_url": self.callback_url, + "callback_method": self.callback_method, + "fallback_url": self.fallback_url, + "fallback_method": self.fallback_method, + "status_callback_url": self.status_callback_url, + "status_callback_method": self.status_callback_method, + } + + class Status(object): + CREATING = "CREATING" + ONLINE = "ONLINE" + OFFLINE = "OFFLINE" + PENDING_VERIFICATION = "PENDING_VERIFICATION" + VERIFYING = "VERIFYING" + ONLINE_UPDATING = "ONLINE:UPDATING" + STUBBED = "STUBBED" + + """ + :ivar sid: A 34 character string that uniquely identifies this Sender. + :ivar status: + :ivar sender_id: The ID of this Sender prefixed with the channel, e.g., `whatsapp:E.164` + :ivar configuration: + :ivar webhook: + :ivar profile: + :ivar properties: + :ivar offline_reasons: Reasons why the sender is offline., e.g., [{\"code\": \"21211400\", \"message\": \"Whatsapp business account is banned by provider {provider_name} | Credit line is assigned to another BSP\", \"more_info\": \"https://www.twilio.com/docs/errors/21211400\"}] + :ivar url: The URL of this resource, relative to `https://messaging.twilio.com`. + """ + + def __init__( + self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None + ): + super().__init__(version) + + self.sid: Optional[str] = payload.get("sid") + self.status: Optional["ChannelsSenderInstance.Status"] = payload.get("status") + self.sender_id: Optional[str] = payload.get("sender_id") + self.configuration: Optional[str] = payload.get("configuration") + self.webhook: Optional[str] = payload.get("webhook") + self.profile: Optional[str] = payload.get("profile") + self.properties: Optional[str] = payload.get("properties") + self.offline_reasons: Optional[List[str]] = payload.get("offline_reasons") + self.url: Optional[str] = payload.get("url") + + self._solution = { + "sid": sid or self.sid, + } + self._context: Optional[ChannelsSenderContext] = None + + @property + def _proxy(self) -> "ChannelsSenderContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: ChannelsSenderContext for this ChannelsSenderInstance + """ + if self._context is None: + self._context = ChannelsSenderContext( + self._version, + sid=self._solution["sid"], + ) + return self._context + + def delete(self) -> bool: + """ + Deletes the ChannelsSenderInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._proxy.delete() + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the ChannelsSenderInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._proxy.delete_async() + + def fetch(self) -> "ChannelsSenderInstance": + """ + Fetch the ChannelsSenderInstance + + + :returns: The fetched ChannelsSenderInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "ChannelsSenderInstance": + """ + Asynchronous coroutine to fetch the ChannelsSenderInstance + + + :returns: The fetched ChannelsSenderInstance + """ + return await self._proxy.fetch_async() + + def update( + self, + messaging_v2_channels_sender_requests_update: Union[ + MessagingV2ChannelsSenderRequestsUpdate, object + ] = values.unset, + ) -> "ChannelsSenderInstance": + """ + Update the ChannelsSenderInstance + + :param messaging_v2_channels_sender_requests_update: + + :returns: The updated ChannelsSenderInstance + """ + return self._proxy.update( + messaging_v2_channels_sender_requests_update=messaging_v2_channels_sender_requests_update, + ) + + async def update_async( + self, + messaging_v2_channels_sender_requests_update: Union[ + MessagingV2ChannelsSenderRequestsUpdate, object + ] = values.unset, + ) -> "ChannelsSenderInstance": + """ + Asynchronous coroutine to update the ChannelsSenderInstance + + :param messaging_v2_channels_sender_requests_update: + + :returns: The updated ChannelsSenderInstance + """ + return await self._proxy.update_async( + messaging_v2_channels_sender_requests_update=messaging_v2_channels_sender_requests_update, + ) + + 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 ChannelsSenderContext(InstanceContext): + + class MessagingV2ChannelsSenderConfiguration(object): + """ + :ivar waba_id: The ID of the WhatsApp Business Account to use for this sender. + :ivar verification_method: The method to use for verification. Either \"sms\" or \"voice\". + :ivar verification_code: The verification code to use for this sender. + :ivar voice_application_sid: The SID of the Twilio Voice application to use for this sender. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.waba_id: Optional[str] = payload.get("waba_id") + self.verification_method: Optional["ChannelsSenderInstance.str"] = ( + payload.get("verification_method") + ) + self.verification_code: Optional[str] = payload.get("verification_code") + self.voice_application_sid: Optional[str] = payload.get( + "voice_application_sid" + ) + + def to_dict(self): + return { + "waba_id": self.waba_id, + "verification_method": self.verification_method, + "verification_code": self.verification_code, + "voice_application_sid": self.voice_application_sid, + } + + class MessagingV2ChannelsSenderProfile(object): + """ + :ivar name: The name of the sender. + :ivar about: The about text of the sender. + :ivar address: The address of the sender. + :ivar description: The description of the sender. + :ivar emails: The emails of the sender. + :ivar logo_url: The logo URL of the sender. + :ivar vertical: The vertical of the sender. Allowed values are: - \"Automotive\" - \"Beauty, Spa and Salon\" - \"Clothing and Apparel\" - \"Education\" - \"Entertainment\" - \"Event Planning and Service\" - \"Finance and Banking\" - \"Food and Grocery\" - \"Public Service\" - \"Hotel and Lodging\" - \"Medical and Health\" - \"Non-profit\" - \"Professional Services\" - \"Shopping and Retail\" - \"Travel and Transportation\" - \"Restaurant\" - \"Other\" + :ivar websites: The websites of the sender. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.name: Optional[str] = payload.get("name") + self.about: Optional[str] = payload.get("about") + self.address: Optional[str] = payload.get("address") + self.description: Optional[str] = payload.get("description") + self.emails: Optional[ + List[ChannelsSenderList.MessagingV2ChannelsSenderProfileEmails] + ] = payload.get("emails") + self.logo_url: Optional[str] = payload.get("logo_url") + self.vertical: Optional[str] = payload.get("vertical") + self.websites: Optional[ + List[ChannelsSenderList.MessagingV2ChannelsSenderProfileWebsites] + ] = payload.get("websites") + + def to_dict(self): + return { + "name": self.name, + "about": self.about, + "address": self.address, + "description": self.description, + "emails": ( + [emails.to_dict() for emails in self.emails] + if self.emails is not None + else None + ), + "logo_url": self.logo_url, + "vertical": self.vertical, + "websites": ( + [websites.to_dict() for websites in self.websites] + if self.websites is not None + else None + ), + } + + class MessagingV2ChannelsSenderProfileEmails(object): + """ + :ivar email: The email of the sender. + :ivar label: The label of the sender. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.email: Optional[str] = payload.get("email") + self.label: Optional[str] = payload.get("label") + + def to_dict(self): + return { + "email": self.email, + "label": self.label, + } + + class MessagingV2ChannelsSenderProfileWebsites(object): + """ + :ivar label: The label of the sender. + :ivar website: The website of the sender. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.label: Optional[str] = payload.get("label") + self.website: Optional[str] = payload.get("website") + + def to_dict(self): + return { + "label": self.label, + "website": self.website, + } + + class MessagingV2ChannelsSenderRequestsCreate(object): + """ + :ivar sender_id: The ID of this Sender prefixed with the channel, e.g., `whatsapp:E.164` + :ivar configuration: + :ivar webhook: + :ivar profile: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.sender_id: Optional[str] = payload.get("sender_id") + self.configuration: Optional[ + ChannelsSenderList.MessagingV2ChannelsSenderConfiguration + ] = payload.get("configuration") + self.webhook: Optional[ + ChannelsSenderList.MessagingV2ChannelsSenderWebhook + ] = payload.get("webhook") + self.profile: Optional[ + ChannelsSenderList.MessagingV2ChannelsSenderProfile + ] = payload.get("profile") + + def to_dict(self): + return { + "sender_id": self.sender_id, + "configuration": ( + self.configuration.to_dict() + if self.configuration is not None + else None + ), + "webhook": self.webhook.to_dict() if self.webhook is not None else None, + "profile": self.profile.to_dict() if self.profile is not None else None, + } + + class MessagingV2ChannelsSenderRequestsUpdate(object): + """ + :ivar configuration: + :ivar webhook: + :ivar profile: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.configuration: Optional[ + ChannelsSenderList.MessagingV2ChannelsSenderConfiguration + ] = payload.get("configuration") + self.webhook: Optional[ + ChannelsSenderList.MessagingV2ChannelsSenderWebhook + ] = payload.get("webhook") + self.profile: Optional[ + ChannelsSenderList.MessagingV2ChannelsSenderProfile + ] = payload.get("profile") + + def to_dict(self): + return { + "configuration": ( + self.configuration.to_dict() + if self.configuration is not None + else None + ), + "webhook": self.webhook.to_dict() if self.webhook is not None else None, + "profile": self.profile.to_dict() if self.profile is not None else None, + } + + class MessagingV2ChannelsSenderWebhook(object): + """ + :ivar callback_url: The URL to send the webhook to. + :ivar callback_method: The HTTP method to use for the webhook. Either \"POST\" or \"PUT\". + :ivar fallback_url: The URL to send the fallback webhook to. + :ivar fallback_method: The HTTP method to use for the fallback webhook. Either \"POST\" or \"PUT\". + :ivar status_callback_url: The URL to send the status callback to. + :ivar status_callback_method: The HTTP method to use for the status callback. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.callback_url: Optional[str] = payload.get("callback_url") + self.callback_method: Optional["ChannelsSenderInstance.str"] = payload.get( + "callback_method" + ) + self.fallback_url: Optional[str] = payload.get("fallback_url") + self.fallback_method: Optional["ChannelsSenderInstance.str"] = payload.get( + "fallback_method" + ) + self.status_callback_url: Optional[str] = payload.get("status_callback_url") + self.status_callback_method: Optional[str] = payload.get( + "status_callback_method" + ) + + def to_dict(self): + return { + "callback_url": self.callback_url, + "callback_method": self.callback_method, + "fallback_url": self.fallback_url, + "fallback_method": self.fallback_method, + "status_callback_url": self.status_callback_url, + "status_callback_method": self.status_callback_method, + } + + def __init__(self, version: Version, sid: str): + """ + Initialize the ChannelsSenderContext + + :param version: Version that contains the resource + :param sid: A 34 character string that uniquely identifies this Sender. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "sid": sid, + } + self._uri = "/Channels/Senders/{sid}".format(**self._solution) + + def delete(self) -> bool: + """ + Deletes the ChannelsSenderInstance + + + :returns: True if delete succeeds, False otherwise + """ + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the ChannelsSenderInstance + + + :returns: True if delete succeeds, False otherwise + """ + + headers = values.of({}) + + return await self._version.delete_async( + method="DELETE", uri=self._uri, headers=headers + ) + + def fetch(self) -> ChannelsSenderInstance: + """ + Fetch the ChannelsSenderInstance + + + :returns: The fetched ChannelsSenderInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return ChannelsSenderInstance( + self._version, + payload, + sid=self._solution["sid"], + ) + + async def fetch_async(self) -> ChannelsSenderInstance: + """ + Asynchronous coroutine to fetch the ChannelsSenderInstance + + + :returns: The fetched ChannelsSenderInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + return ChannelsSenderInstance( + self._version, + payload, + sid=self._solution["sid"], + ) + + def update( + self, + messaging_v2_channels_sender_requests_update: Union[ + MessagingV2ChannelsSenderRequestsUpdate, object + ] = values.unset, + ) -> ChannelsSenderInstance: + """ + Update the ChannelsSenderInstance + + :param messaging_v2_channels_sender_requests_update: + + :returns: The updated ChannelsSenderInstance + """ + data = messaging_v2_channels_sender_requests_update.to_dict() + + headers = values.of({}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + payload = self._version.update( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return ChannelsSenderInstance(self._version, payload, sid=self._solution["sid"]) + + async def update_async( + self, + messaging_v2_channels_sender_requests_update: Union[ + MessagingV2ChannelsSenderRequestsUpdate, object + ] = values.unset, + ) -> ChannelsSenderInstance: + """ + Asynchronous coroutine to update the ChannelsSenderInstance + + :param messaging_v2_channels_sender_requests_update: + + :returns: The updated ChannelsSenderInstance + """ + data = messaging_v2_channels_sender_requests_update.to_dict() + + headers = values.of({}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + payload = await self._version.update_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return ChannelsSenderInstance(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 ChannelsSenderPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> ChannelsSenderInstance: + """ + Build an instance of ChannelsSenderInstance + + :param payload: Payload response from the API + """ + return ChannelsSenderInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class ChannelsSenderList(ListResource): + + class MessagingV2ChannelsSenderConfiguration(object): + """ + :ivar waba_id: The ID of the WhatsApp Business Account to use for this sender. + :ivar verification_method: The method to use for verification. Either \"sms\" or \"voice\". + :ivar verification_code: The verification code to use for this sender. + :ivar voice_application_sid: The SID of the Twilio Voice application to use for this sender. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.waba_id: Optional[str] = payload.get("waba_id") + self.verification_method: Optional["ChannelsSenderInstance.str"] = ( + payload.get("verification_method") + ) + self.verification_code: Optional[str] = payload.get("verification_code") + self.voice_application_sid: Optional[str] = payload.get( + "voice_application_sid" + ) + + def to_dict(self): + return { + "waba_id": self.waba_id, + "verification_method": self.verification_method, + "verification_code": self.verification_code, + "voice_application_sid": self.voice_application_sid, + } + + class MessagingV2ChannelsSenderProfile(object): + """ + :ivar name: The name of the sender. + :ivar about: The about text of the sender. + :ivar address: The address of the sender. + :ivar description: The description of the sender. + :ivar emails: The emails of the sender. + :ivar logo_url: The logo URL of the sender. + :ivar vertical: The vertical of the sender. Allowed values are: - \"Automotive\" - \"Beauty, Spa and Salon\" - \"Clothing and Apparel\" - \"Education\" - \"Entertainment\" - \"Event Planning and Service\" - \"Finance and Banking\" - \"Food and Grocery\" - \"Public Service\" - \"Hotel and Lodging\" - \"Medical and Health\" - \"Non-profit\" - \"Professional Services\" - \"Shopping and Retail\" - \"Travel and Transportation\" - \"Restaurant\" - \"Other\" + :ivar websites: The websites of the sender. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.name: Optional[str] = payload.get("name") + self.about: Optional[str] = payload.get("about") + self.address: Optional[str] = payload.get("address") + self.description: Optional[str] = payload.get("description") + self.emails: Optional[ + List[ChannelsSenderList.MessagingV2ChannelsSenderProfileEmails] + ] = payload.get("emails") + self.logo_url: Optional[str] = payload.get("logo_url") + self.vertical: Optional[str] = payload.get("vertical") + self.websites: Optional[ + List[ChannelsSenderList.MessagingV2ChannelsSenderProfileWebsites] + ] = payload.get("websites") + + def to_dict(self): + return { + "name": self.name, + "about": self.about, + "address": self.address, + "description": self.description, + "emails": ( + [emails.to_dict() for emails in self.emails] + if self.emails is not None + else None + ), + "logo_url": self.logo_url, + "vertical": self.vertical, + "websites": ( + [websites.to_dict() for websites in self.websites] + if self.websites is not None + else None + ), + } + + class MessagingV2ChannelsSenderProfileEmails(object): + """ + :ivar email: The email of the sender. + :ivar label: The label of the sender. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.email: Optional[str] = payload.get("email") + self.label: Optional[str] = payload.get("label") + + def to_dict(self): + return { + "email": self.email, + "label": self.label, + } + + class MessagingV2ChannelsSenderProfileWebsites(object): + """ + :ivar label: The label of the sender. + :ivar website: The website of the sender. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.label: Optional[str] = payload.get("label") + self.website: Optional[str] = payload.get("website") + + def to_dict(self): + return { + "label": self.label, + "website": self.website, + } + + class MessagingV2ChannelsSenderRequestsCreate(object): + """ + :ivar sender_id: The ID of this Sender prefixed with the channel, e.g., `whatsapp:E.164` + :ivar configuration: + :ivar webhook: + :ivar profile: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.sender_id: Optional[str] = payload.get("sender_id") + self.configuration: Optional[ + ChannelsSenderList.MessagingV2ChannelsSenderConfiguration + ] = payload.get("configuration") + self.webhook: Optional[ + ChannelsSenderList.MessagingV2ChannelsSenderWebhook + ] = payload.get("webhook") + self.profile: Optional[ + ChannelsSenderList.MessagingV2ChannelsSenderProfile + ] = payload.get("profile") + + def to_dict(self): + return { + "sender_id": self.sender_id, + "configuration": ( + self.configuration.to_dict() + if self.configuration is not None + else None + ), + "webhook": self.webhook.to_dict() if self.webhook is not None else None, + "profile": self.profile.to_dict() if self.profile is not None else None, + } + + class MessagingV2ChannelsSenderRequestsUpdate(object): + """ + :ivar configuration: + :ivar webhook: + :ivar profile: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.configuration: Optional[ + ChannelsSenderList.MessagingV2ChannelsSenderConfiguration + ] = payload.get("configuration") + self.webhook: Optional[ + ChannelsSenderList.MessagingV2ChannelsSenderWebhook + ] = payload.get("webhook") + self.profile: Optional[ + ChannelsSenderList.MessagingV2ChannelsSenderProfile + ] = payload.get("profile") + + def to_dict(self): + return { + "configuration": ( + self.configuration.to_dict() + if self.configuration is not None + else None + ), + "webhook": self.webhook.to_dict() if self.webhook is not None else None, + "profile": self.profile.to_dict() if self.profile is not None else None, + } + + class MessagingV2ChannelsSenderWebhook(object): + """ + :ivar callback_url: The URL to send the webhook to. + :ivar callback_method: The HTTP method to use for the webhook. Either \"POST\" or \"PUT\". + :ivar fallback_url: The URL to send the fallback webhook to. + :ivar fallback_method: The HTTP method to use for the fallback webhook. Either \"POST\" or \"PUT\". + :ivar status_callback_url: The URL to send the status callback to. + :ivar status_callback_method: The HTTP method to use for the status callback. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.callback_url: Optional[str] = payload.get("callback_url") + self.callback_method: Optional["ChannelsSenderInstance.str"] = payload.get( + "callback_method" + ) + self.fallback_url: Optional[str] = payload.get("fallback_url") + self.fallback_method: Optional["ChannelsSenderInstance.str"] = payload.get( + "fallback_method" + ) + self.status_callback_url: Optional[str] = payload.get("status_callback_url") + self.status_callback_method: Optional[str] = payload.get( + "status_callback_method" + ) + + def to_dict(self): + return { + "callback_url": self.callback_url, + "callback_method": self.callback_method, + "fallback_url": self.fallback_url, + "fallback_method": self.fallback_method, + "status_callback_url": self.status_callback_url, + "status_callback_method": self.status_callback_method, + } + + def __init__(self, version: Version): + """ + Initialize the ChannelsSenderList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/Channels/Senders" + + def create( + self, + messaging_v2_channels_sender_requests_create: MessagingV2ChannelsSenderRequestsCreate, + ) -> ChannelsSenderInstance: + """ + Create the ChannelsSenderInstance + + :param messaging_v2_channels_sender_requests_create: + + :returns: The created ChannelsSenderInstance + """ + data = messaging_v2_channels_sender_requests_create.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + payload = self._version.create( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return ChannelsSenderInstance(self._version, payload) + + async def create_async( + self, + messaging_v2_channels_sender_requests_create: MessagingV2ChannelsSenderRequestsCreate, + ) -> ChannelsSenderInstance: + """ + Asynchronously create the ChannelsSenderInstance + + :param messaging_v2_channels_sender_requests_create: + + :returns: The created ChannelsSenderInstance + """ + data = messaging_v2_channels_sender_requests_create.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return ChannelsSenderInstance(self._version, payload) + + def stream( + self, + channel: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[ChannelsSenderInstance]: + """ + Streams ChannelsSenderInstance 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 channel: + :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(channel=channel, page_size=limits["page_size"]) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + channel: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[ChannelsSenderInstance]: + """ + Asynchronously streams ChannelsSenderInstance 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 channel: + :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(channel=channel, page_size=limits["page_size"]) + + return self._version.stream_async(page, limits["limit"]) + + def list( + self, + channel: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[ChannelsSenderInstance]: + """ + Lists ChannelsSenderInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str channel: + :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( + channel=channel, + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + channel: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[ChannelsSenderInstance]: + """ + Asynchronously lists ChannelsSenderInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str channel: + :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( + channel=channel, + limit=limit, + page_size=page_size, + ) + ] + + def page( + self, + channel: 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, + ) -> ChannelsSenderPage: + """ + Retrieve a single page of ChannelsSenderInstance records from the API. + Request is executed immediately + + :param channel: + :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 ChannelsSenderInstance + """ + data = values.of( + { + "Channel": channel, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return ChannelsSenderPage(self._version, response) + + async def page_async( + self, + channel: 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, + ) -> ChannelsSenderPage: + """ + Asynchronously retrieve a single page of ChannelsSenderInstance records from the API. + Request is executed immediately + + :param channel: + :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 ChannelsSenderInstance + """ + data = values.of( + { + "Channel": channel, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + return ChannelsSenderPage(self._version, response) + + def get_page(self, target_url: str) -> ChannelsSenderPage: + """ + Retrieve a specific page of ChannelsSenderInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of ChannelsSenderInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return ChannelsSenderPage(self._version, response) + + async def get_page_async(self, target_url: str) -> ChannelsSenderPage: + """ + Asynchronously retrieve a specific page of ChannelsSenderInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of ChannelsSenderInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return ChannelsSenderPage(self._version, response) + + def get(self, sid: str) -> ChannelsSenderContext: + """ + Constructs a ChannelsSenderContext + + :param sid: A 34 character string that uniquely identifies this Sender. + """ + return ChannelsSenderContext(self._version, sid=sid) + + def __call__(self, sid: str) -> ChannelsSenderContext: + """ + Constructs a ChannelsSenderContext + + :param sid: A 34 character string that uniquely identifies this Sender. + """ + return ChannelsSenderContext(self._version, sid=sid) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/microvisor/v1/account_config.py b/twilio/rest/microvisor/v1/account_config.py index 3d37b01cd2..7faba8acb1 100644 --- a/twilio/rest/microvisor/v1/account_config.py +++ b/twilio/rest/microvisor/v1/account_config.py @@ -156,10 +156,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -168,9 +168,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> AccountConfigInstance: @@ -181,10 +183,11 @@ def fetch(self) -> AccountConfigInstance: :returns: The fetched AccountConfigInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return AccountConfigInstance( self._version, @@ -200,9 +203,12 @@ async def fetch_async(self) -> AccountConfigInstance: :returns: The fetched AccountConfigInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return AccountConfigInstance( @@ -219,16 +225,20 @@ def update(self, value: str) -> AccountConfigInstance: :returns: The updated AccountConfigInstance """ + data = values.of( { "Value": value, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AccountConfigInstance(self._version, payload, key=self._solution["key"]) @@ -241,16 +251,20 @@ async def update_async(self, value: str) -> AccountConfigInstance: :returns: The updated AccountConfigInstance """ + data = values.of( { "Value": value, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AccountConfigInstance(self._version, payload, key=self._solution["key"]) @@ -313,11 +327,14 @@ def create(self, key: str, value: str) -> AccountConfigInstance: "Value": value, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AccountConfigInstance(self._version, payload) @@ -338,11 +355,14 @@ async def create_async(self, key: str, value: str) -> AccountConfigInstance: "Value": value, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AccountConfigInstance(self._version, payload) @@ -474,7 +494,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return AccountConfigPage(self._version, response) async def page_async( @@ -501,8 +527,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return AccountConfigPage(self._version, response) diff --git a/twilio/rest/microvisor/v1/account_secret.py b/twilio/rest/microvisor/v1/account_secret.py index cca0e1d773..13ca961e61 100644 --- a/twilio/rest/microvisor/v1/account_secret.py +++ b/twilio/rest/microvisor/v1/account_secret.py @@ -154,10 +154,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -166,9 +166,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> AccountSecretInstance: @@ -179,10 +181,11 @@ def fetch(self) -> AccountSecretInstance: :returns: The fetched AccountSecretInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return AccountSecretInstance( self._version, @@ -198,9 +201,12 @@ async def fetch_async(self) -> AccountSecretInstance: :returns: The fetched AccountSecretInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return AccountSecretInstance( @@ -217,16 +223,20 @@ def update(self, value: str) -> AccountSecretInstance: :returns: The updated AccountSecretInstance """ + data = values.of( { "Value": value, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AccountSecretInstance(self._version, payload, key=self._solution["key"]) @@ -239,16 +249,20 @@ async def update_async(self, value: str) -> AccountSecretInstance: :returns: The updated AccountSecretInstance """ + data = values.of( { "Value": value, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AccountSecretInstance(self._version, payload, key=self._solution["key"]) @@ -311,11 +325,14 @@ def create(self, key: str, value: str) -> AccountSecretInstance: "Value": value, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AccountSecretInstance(self._version, payload) @@ -336,11 +353,14 @@ async def create_async(self, key: str, value: str) -> AccountSecretInstance: "Value": value, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AccountSecretInstance(self._version, payload) @@ -472,7 +492,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return AccountSecretPage(self._version, response) async def page_async( @@ -499,8 +525,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return AccountSecretPage(self._version, response) diff --git a/twilio/rest/microvisor/v1/app/__init__.py b/twilio/rest/microvisor/v1/app/__init__.py index 0c91fe3c50..8cfbbe68df 100644 --- a/twilio/rest/microvisor/v1/app/__init__.py +++ b/twilio/rest/microvisor/v1/app/__init__.py @@ -152,10 +152,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -164,9 +164,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> AppInstance: @@ -177,10 +179,11 @@ def fetch(self) -> AppInstance: :returns: The fetched AppInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return AppInstance( self._version, @@ -196,9 +199,12 @@ async def fetch_async(self) -> AppInstance: :returns: The fetched AppInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return AppInstance( @@ -388,7 +394,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return AppPage(self._version, response) async def page_async( @@ -415,8 +427,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return AppPage(self._version, response) diff --git a/twilio/rest/microvisor/v1/app/app_manifest.py b/twilio/rest/microvisor/v1/app/app_manifest.py index 4f9eab075e..0412cadcc1 100644 --- a/twilio/rest/microvisor/v1/app/app_manifest.py +++ b/twilio/rest/microvisor/v1/app/app_manifest.py @@ -13,6 +13,7 @@ """ 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 @@ -108,10 +109,11 @@ def fetch(self) -> AppManifestInstance: :returns: The fetched AppManifestInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return AppManifestInstance( self._version, @@ -127,9 +129,12 @@ async def fetch_async(self) -> AppManifestInstance: :returns: The fetched AppManifestInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return AppManifestInstance( diff --git a/twilio/rest/microvisor/v1/device/__init__.py b/twilio/rest/microvisor/v1/device/__init__.py index 42a17340f6..a3b3089162 100644 --- a/twilio/rest/microvisor/v1/device/__init__.py +++ b/twilio/rest/microvisor/v1/device/__init__.py @@ -194,10 +194,11 @@ def fetch(self) -> DeviceInstance: :returns: The fetched DeviceInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return DeviceInstance( self._version, @@ -213,9 +214,12 @@ async def fetch_async(self) -> DeviceInstance: :returns: The fetched DeviceInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return DeviceInstance( @@ -241,6 +245,7 @@ def update( :returns: The updated DeviceInstance """ + data = values.of( { "UniqueName": unique_name, @@ -249,11 +254,14 @@ def update( "RestartApp": serialize.boolean_to_string(restart_app), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return DeviceInstance(self._version, payload, sid=self._solution["sid"]) @@ -275,6 +283,7 @@ async def update_async( :returns: The updated DeviceInstance """ + data = values.of( { "UniqueName": unique_name, @@ -283,11 +292,14 @@ async def update_async( "RestartApp": serialize.boolean_to_string(restart_app), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return DeviceInstance(self._version, payload, sid=self._solution["sid"]) @@ -485,7 +497,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return DevicePage(self._version, response) async def page_async( @@ -512,8 +530,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return DevicePage(self._version, response) diff --git a/twilio/rest/microvisor/v1/device/device_config.py b/twilio/rest/microvisor/v1/device/device_config.py index 3607e971f2..b87063f53f 100644 --- a/twilio/rest/microvisor/v1/device/device_config.py +++ b/twilio/rest/microvisor/v1/device/device_config.py @@ -166,10 +166,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -178,9 +178,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> DeviceConfigInstance: @@ -191,10 +193,11 @@ def fetch(self) -> DeviceConfigInstance: :returns: The fetched DeviceConfigInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return DeviceConfigInstance( self._version, @@ -211,9 +214,12 @@ async def fetch_async(self) -> DeviceConfigInstance: :returns: The fetched DeviceConfigInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return DeviceConfigInstance( @@ -231,16 +237,20 @@ def update(self, value: str) -> DeviceConfigInstance: :returns: The updated DeviceConfigInstance """ + data = values.of( { "Value": value, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return DeviceConfigInstance( @@ -258,16 +268,20 @@ async def update_async(self, value: str) -> DeviceConfigInstance: :returns: The updated DeviceConfigInstance """ + data = values.of( { "Value": value, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return DeviceConfigInstance( @@ -342,11 +356,14 @@ def create(self, key: str, value: str) -> DeviceConfigInstance: "Value": value, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return DeviceConfigInstance( @@ -369,11 +386,14 @@ async def create_async(self, key: str, value: str) -> DeviceConfigInstance: "Value": value, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return DeviceConfigInstance( @@ -507,7 +527,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return DeviceConfigPage(self._version, response, self._solution) async def page_async( @@ -534,8 +560,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return DeviceConfigPage(self._version, response, self._solution) diff --git a/twilio/rest/microvisor/v1/device/device_secret.py b/twilio/rest/microvisor/v1/device/device_secret.py index 0ab9b1c721..30b805ea6b 100644 --- a/twilio/rest/microvisor/v1/device/device_secret.py +++ b/twilio/rest/microvisor/v1/device/device_secret.py @@ -164,10 +164,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -176,9 +176,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> DeviceSecretInstance: @@ -189,10 +191,11 @@ def fetch(self) -> DeviceSecretInstance: :returns: The fetched DeviceSecretInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return DeviceSecretInstance( self._version, @@ -209,9 +212,12 @@ async def fetch_async(self) -> DeviceSecretInstance: :returns: The fetched DeviceSecretInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return DeviceSecretInstance( @@ -229,16 +235,20 @@ def update(self, value: str) -> DeviceSecretInstance: :returns: The updated DeviceSecretInstance """ + data = values.of( { "Value": value, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return DeviceSecretInstance( @@ -256,16 +266,20 @@ async def update_async(self, value: str) -> DeviceSecretInstance: :returns: The updated DeviceSecretInstance """ + data = values.of( { "Value": value, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return DeviceSecretInstance( @@ -340,11 +354,14 @@ def create(self, key: str, value: str) -> DeviceSecretInstance: "Value": value, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return DeviceSecretInstance( @@ -367,11 +384,14 @@ async def create_async(self, key: str, value: str) -> DeviceSecretInstance: "Value": value, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return DeviceSecretInstance( @@ -505,7 +525,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return DeviceSecretPage(self._version, response, self._solution) async def page_async( @@ -532,8 +558,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return DeviceSecretPage(self._version, response, self._solution) diff --git a/twilio/rest/monitor/v1/alert.py b/twilio/rest/monitor/v1/alert.py index ef8cf39dda..829e633643 100644 --- a/twilio/rest/monitor/v1/alert.py +++ b/twilio/rest/monitor/v1/alert.py @@ -149,10 +149,11 @@ def fetch(self) -> AlertInstance: :returns: The fetched AlertInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return AlertInstance( self._version, @@ -168,9 +169,12 @@ async def fetch_async(self) -> AlertInstance: :returns: The fetched AlertInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return AlertInstance( @@ -397,7 +401,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return AlertPage(self._version, response) async def page_async( @@ -433,8 +443,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return AlertPage(self._version, response) diff --git a/twilio/rest/monitor/v1/event.py b/twilio/rest/monitor/v1/event.py index 6b67a9c029..61450c872c 100644 --- a/twilio/rest/monitor/v1/event.py +++ b/twilio/rest/monitor/v1/event.py @@ -25,7 +25,7 @@ class EventInstance(InstanceResource): """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Event resource. - :ivar actor_sid: The SID of the actor that caused the event, if available. Can be `null`. + :ivar actor_sid: The SID of the actor that caused the event, if available. This can be either a User ID (matching the pattern `^US[0-9a-fA-F]{32}$`) or an Account SID (matching the pattern `^AC[0-9a-fA-F]{32}$`). If the actor's SID isn't available, this field will be `null`. :ivar actor_type: The type of actor that caused the event. Can be: `user` for a change made by a logged-in user in the Twilio Console, `account` for an event caused by an API request by an authenticating Account, `twilio-admin` for an event caused by a Twilio employee, and so on. :ivar description: A description of the event. Can be `null`. :ivar event_data: An object with additional data about the event. The contents depend on `event_type`. For example, event-types of the form `RESOURCE.updated`, this value contains a `resource_properties` dictionary that describes the previous and updated properties of the resource. @@ -135,10 +135,11 @@ def fetch(self) -> EventInstance: :returns: The fetched EventInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return EventInstance( self._version, @@ -154,9 +155,12 @@ async def fetch_async(self) -> EventInstance: :returns: The fetched EventInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return EventInstance( @@ -428,7 +432,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return EventPage(self._version, response) async def page_async( @@ -473,8 +483,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return EventPage(self._version, response) diff --git a/twilio/rest/notify/v1/credential.py b/twilio/rest/notify/v1/credential.py index 5cb86363a3..9ca59927cb 100644 --- a/twilio/rest/notify/v1/credential.py +++ b/twilio/rest/notify/v1/credential.py @@ -208,10 +208,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -220,9 +220,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> CredentialInstance: @@ -233,10 +235,11 @@ def fetch(self) -> CredentialInstance: :returns: The fetched CredentialInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return CredentialInstance( self._version, @@ -252,9 +255,12 @@ async def fetch_async(self) -> CredentialInstance: :returns: The fetched CredentialInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return CredentialInstance( @@ -284,6 +290,7 @@ def update( :returns: The updated CredentialInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -294,11 +301,14 @@ def update( "Secret": secret, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CredentialInstance(self._version, payload, sid=self._solution["sid"]) @@ -324,6 +334,7 @@ async def update_async( :returns: The updated CredentialInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -334,11 +345,14 @@ async def update_async( "Secret": secret, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CredentialInstance(self._version, payload, sid=self._solution["sid"]) @@ -420,11 +434,14 @@ def create( "Secret": secret, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CredentialInstance(self._version, payload) @@ -464,11 +481,14 @@ async def create_async( "Secret": secret, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CredentialInstance(self._version, payload) @@ -600,7 +620,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return CredentialPage(self._version, response) async def page_async( @@ -627,8 +653,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return CredentialPage(self._version, response) diff --git a/twilio/rest/notify/v1/service/__init__.py b/twilio/rest/notify/v1/service/__init__.py index 0cd9adb685..e097e69a67 100644 --- a/twilio/rest/notify/v1/service/__init__.py +++ b/twilio/rest/notify/v1/service/__init__.py @@ -305,10 +305,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -317,9 +317,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> ServiceInstance: @@ -330,10 +332,11 @@ def fetch(self) -> ServiceInstance: :returns: The fetched ServiceInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ServiceInstance( self._version, @@ -349,9 +352,12 @@ async def fetch_async(self) -> ServiceInstance: :returns: The fetched ServiceInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ServiceInstance( @@ -397,6 +403,7 @@ def update( :returns: The updated ServiceInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -417,11 +424,14 @@ def update( ), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload, sid=self._solution["sid"]) @@ -463,6 +473,7 @@ async def update_async( :returns: The updated ServiceInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -483,11 +494,14 @@ async def update_async( ), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload, sid=self._solution["sid"]) @@ -616,11 +630,14 @@ def create( ), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload) @@ -683,11 +700,14 @@ async def create_async( ), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload) @@ -834,7 +854,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ServicePage(self._version, response) async def page_async( @@ -864,8 +890,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ServicePage(self._version, response) diff --git a/twilio/rest/notify/v1/service/binding.py b/twilio/rest/notify/v1/service/binding.py index a6b1e3f087..33b1a4aac0 100644 --- a/twilio/rest/notify/v1/service/binding.py +++ b/twilio/rest/notify/v1/service/binding.py @@ -173,10 +173,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -185,9 +185,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> BindingInstance: @@ -198,10 +200,11 @@ def fetch(self) -> BindingInstance: :returns: The fetched BindingInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return BindingInstance( self._version, @@ -218,9 +221,12 @@ async def fetch_async(self) -> BindingInstance: :returns: The fetched BindingInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return BindingInstance( @@ -314,11 +320,14 @@ def create( "Endpoint": endpoint, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return BindingInstance( @@ -360,11 +369,14 @@ async def create_async( "Endpoint": endpoint, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return BindingInstance( @@ -562,7 +574,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return BindingPage(self._version, response, self._solution) async def page_async( @@ -601,8 +619,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return BindingPage(self._version, response, self._solution) diff --git a/twilio/rest/notify/v1/service/notification.py b/twilio/rest/notify/v1/service/notification.py index e2482be109..4d228e864f 100644 --- a/twilio/rest/notify/v1/service/notification.py +++ b/twilio/rest/notify/v1/service/notification.py @@ -180,11 +180,14 @@ def create( "Tag": serialize.map(tag, lambda e: e), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return NotificationInstance( @@ -259,11 +262,14 @@ async def create_async( "Tag": serialize.map(tag, lambda e: e), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return NotificationInstance( diff --git a/twilio/rest/numbers/v1/__init__.py b/twilio/rest/numbers/v1/__init__.py index 9da80f3a34..043364c3d5 100644 --- a/twilio/rest/numbers/v1/__init__.py +++ b/twilio/rest/numbers/v1/__init__.py @@ -17,10 +17,23 @@ from twilio.base.domain import Domain from twilio.rest.numbers.v1.bulk_eligibility import BulkEligibilityList from twilio.rest.numbers.v1.eligibility import EligibilityList -from twilio.rest.numbers.v1.porting_bulk_portability import PortingBulkPortabilityList from twilio.rest.numbers.v1.porting_port_in import PortingPortInList -from twilio.rest.numbers.v1.porting_port_in_fetch import PortingPortInFetchList +from twilio.rest.numbers.v1.porting_port_in_phone_number import ( + PortingPortInPhoneNumberList, +) from twilio.rest.numbers.v1.porting_portability import PortingPortabilityList +from twilio.rest.numbers.v1.porting_webhook_configuration import ( + PortingWebhookConfigurationList, +) +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, +) class V1(Version): @@ -34,10 +47,23 @@ def __init__(self, domain: Domain): super().__init__(domain, "v1") self._bulk_eligibilities: Optional[BulkEligibilityList] = None self._eligibilities: Optional[EligibilityList] = None - self._porting_bulk_portabilities: Optional[PortingBulkPortabilityList] = None self._porting_port_ins: Optional[PortingPortInList] = None - self._porting_port_ins_fetch: Optional[PortingPortInFetchList] = None + self._porting_port_in_phone_number: Optional[PortingPortInPhoneNumberList] = ( + None + ) self._porting_portabilities: Optional[PortingPortabilityList] = None + self._porting_webhook_configurations: Optional[ + PortingWebhookConfigurationList + ] = None + self._porting_webhook_configurations_delete: Optional[ + PortingWebhookConfigurationDeleteList + ] = None + self._porting_webhook_configuration_fetch: Optional[ + PortingWebhookConfigurationFetchList + ] = None + self._signing_request_configurations: Optional[ + SigningRequestConfigurationList + ] = None @property def bulk_eligibilities(self) -> BulkEligibilityList: @@ -51,12 +77,6 @@ def eligibilities(self) -> EligibilityList: self._eligibilities = EligibilityList(self) return self._eligibilities - @property - def porting_bulk_portabilities(self) -> PortingBulkPortabilityList: - if self._porting_bulk_portabilities is None: - self._porting_bulk_portabilities = PortingBulkPortabilityList(self) - return self._porting_bulk_portabilities - @property def porting_port_ins(self) -> PortingPortInList: if self._porting_port_ins is None: @@ -64,10 +84,10 @@ def porting_port_ins(self) -> PortingPortInList: return self._porting_port_ins @property - def porting_port_ins_fetch(self) -> PortingPortInFetchList: - if self._porting_port_ins_fetch is None: - self._porting_port_ins_fetch = PortingPortInFetchList(self) - return self._porting_port_ins_fetch + def porting_port_in_phone_number(self) -> PortingPortInPhoneNumberList: + if self._porting_port_in_phone_number is None: + self._porting_port_in_phone_number = PortingPortInPhoneNumberList(self) + return self._porting_port_in_phone_number @property def porting_portabilities(self) -> PortingPortabilityList: @@ -75,6 +95,38 @@ def porting_portabilities(self) -> PortingPortabilityList: self._porting_portabilities = PortingPortabilityList(self) return self._porting_portabilities + @property + def porting_webhook_configurations(self) -> PortingWebhookConfigurationList: + if self._porting_webhook_configurations is None: + self._porting_webhook_configurations = PortingWebhookConfigurationList(self) + return self._porting_webhook_configurations + + @property + def porting_webhook_configurations_delete( + self, + ) -> PortingWebhookConfigurationDeleteList: + if self._porting_webhook_configurations_delete is None: + self._porting_webhook_configurations_delete = ( + PortingWebhookConfigurationDeleteList(self) + ) + 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 + def __repr__(self) -> str: """ Provide a friendly representation diff --git a/twilio/rest/numbers/v1/bulk_eligibility.py b/twilio/rest/numbers/v1/bulk_eligibility.py index 3915116416..766032f7c4 100644 --- a/twilio/rest/numbers/v1/bulk_eligibility.py +++ b/twilio/rest/numbers/v1/bulk_eligibility.py @@ -127,10 +127,11 @@ def fetch(self) -> BulkEligibilityInstance: :returns: The fetched BulkEligibilityInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return BulkEligibilityInstance( self._version, @@ -146,9 +147,12 @@ async def fetch_async(self) -> BulkEligibilityInstance: :returns: The fetched BulkEligibilityInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return BulkEligibilityInstance( @@ -192,7 +196,12 @@ def create( """ data = body.to_dict() - headers = {"Content-Type": "application/json"} + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + payload = self._version.create( method="POST", uri=self._uri, data=data, headers=headers ) @@ -209,9 +218,13 @@ async def create_async( :returns: The created BulkEligibilityInstance """ - data = body.to_dict() - headers = {"Content-Type": "application/json"} + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" payload = await self._version.create_async( method="POST", uri=self._uri, data=data, headers=headers diff --git a/twilio/rest/numbers/v1/eligibility.py b/twilio/rest/numbers/v1/eligibility.py index 3b8b5be345..8c5af0ac64 100644 --- a/twilio/rest/numbers/v1/eligibility.py +++ b/twilio/rest/numbers/v1/eligibility.py @@ -63,7 +63,12 @@ def create(self, body: Union[object, object] = values.unset) -> EligibilityInsta """ data = body.to_dict() - headers = {"Content-Type": "application/json"} + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + payload = self._version.create( method="POST", uri=self._uri, data=data, headers=headers ) @@ -80,9 +85,13 @@ async def create_async( :returns: The created EligibilityInstance """ - data = body.to_dict() - headers = {"Content-Type": "application/json"} + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" payload = await self._version.create_async( method="POST", uri=self._uri, data=data, headers=headers diff --git a/twilio/rest/numbers/v1/porting_bulk_portability.py b/twilio/rest/numbers/v1/porting_bulk_portability.py deleted file mode 100644 index c3fedcd5bb..0000000000 --- a/twilio/rest/numbers/v1/porting_bulk_portability.py +++ /dev/null @@ -1,252 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Numbers - This is the public Twilio REST API. - - NOTE: This class is auto generated by OpenAPI Generator. - https://openapi-generator.tech - Do not edit the class manually. -""" - -from datetime import datetime -from typing import Any, Dict, List, Optional -from twilio.base import deserialize, 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 PortingBulkPortabilityInstance(InstanceResource): - - class Status(object): - IN_PROGRESS = "in-progress" - COMPLETED = "completed" - EXPIRED = "expired" - - """ - :ivar sid: A 34 character string that uniquely identifies this Portability check. - :ivar status: - :ivar datetime_created: The date that the Portability check was created, given in ISO 8601 format. - :ivar phone_numbers: Contains a list with all the information of the requested phone numbers. Each phone number contains the following properties: `phone_number`: The phone number which portability is to be checked. `portable`: Boolean flag specifying if phone number is portable or not. `not_portable_reason`: Reason why the phone number cannot be ported into Twilio, `null` otherwise. `not_portable_reason_code`: The Portability Reason Code for the phone number if it cannot be ported in Twilio, `null` otherwise. `pin_and_account_number_required`: Boolean flag specifying if PIN and account number is required for the phone number. `number_type`: The type of the requested phone number. `country` Country the phone number belongs to. `messaging_carrier` Current messaging carrier of the phone number. `voice_carrier` Current voice carrier of the phone number. - :ivar url: This is the url of the request that you're trying to reach out to locate the resource. - """ - - def __init__( - self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None - ): - super().__init__(version) - - self.sid: Optional[str] = payload.get("sid") - self.status: Optional["PortingBulkPortabilityInstance.Status"] = payload.get( - "status" - ) - self.datetime_created: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("datetime_created") - ) - self.phone_numbers: Optional[List[Dict[str, object]]] = payload.get( - "phone_numbers" - ) - self.url: Optional[str] = payload.get("url") - - self._solution = { - "sid": sid or self.sid, - } - self._context: Optional[PortingBulkPortabilityContext] = None - - @property - def _proxy(self) -> "PortingBulkPortabilityContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: PortingBulkPortabilityContext for this PortingBulkPortabilityInstance - """ - if self._context is None: - self._context = PortingBulkPortabilityContext( - self._version, - sid=self._solution["sid"], - ) - return self._context - - def fetch(self) -> "PortingBulkPortabilityInstance": - """ - Fetch the PortingBulkPortabilityInstance - - - :returns: The fetched PortingBulkPortabilityInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "PortingBulkPortabilityInstance": - """ - Asynchronous coroutine to fetch the PortingBulkPortabilityInstance - - - :returns: The fetched PortingBulkPortabilityInstance - """ - 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 PortingBulkPortabilityContext(InstanceContext): - - def __init__(self, version: Version, sid: str): - """ - Initialize the PortingBulkPortabilityContext - - :param version: Version that contains the resource - :param sid: A 34 character string that uniquely identifies the Portability check. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "sid": sid, - } - self._uri = "/Porting/Portability/{sid}".format(**self._solution) - - def fetch(self) -> PortingBulkPortabilityInstance: - """ - Fetch the PortingBulkPortabilityInstance - - - :returns: The fetched PortingBulkPortabilityInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return PortingBulkPortabilityInstance( - self._version, - payload, - sid=self._solution["sid"], - ) - - async def fetch_async(self) -> PortingBulkPortabilityInstance: - """ - Asynchronous coroutine to fetch the PortingBulkPortabilityInstance - - - :returns: The fetched PortingBulkPortabilityInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return PortingBulkPortabilityInstance( - 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 PortingBulkPortabilityList(ListResource): - - def __init__(self, version: Version): - """ - Initialize the PortingBulkPortabilityList - - :param version: Version that contains the resource - - """ - super().__init__(version) - - self._uri = "/Porting/Portability" - - def create(self, phone_numbers: List[str]) -> PortingBulkPortabilityInstance: - """ - Create the PortingBulkPortabilityInstance - - :param phone_numbers: The phone numbers which portability is to be checked. This should be a list of strings. Phone numbers are in E.164 format (e.g. +16175551212). . - - :returns: The created PortingBulkPortabilityInstance - """ - - data = values.of( - { - "PhoneNumbers": serialize.map(phone_numbers, lambda e: e), - } - ) - - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) - - return PortingBulkPortabilityInstance(self._version, payload) - - async def create_async( - self, phone_numbers: List[str] - ) -> PortingBulkPortabilityInstance: - """ - Asynchronously create the PortingBulkPortabilityInstance - - :param phone_numbers: The phone numbers which portability is to be checked. This should be a list of strings. Phone numbers are in E.164 format (e.g. +16175551212). . - - :returns: The created PortingBulkPortabilityInstance - """ - - data = values.of( - { - "PhoneNumbers": serialize.map(phone_numbers, lambda e: e), - } - ) - - payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, - ) - - return PortingBulkPortabilityInstance(self._version, payload) - - def get(self, sid: str) -> PortingBulkPortabilityContext: - """ - Constructs a PortingBulkPortabilityContext - - :param sid: A 34 character string that uniquely identifies the Portability check. - """ - return PortingBulkPortabilityContext(self._version, sid=sid) - - def __call__(self, sid: str) -> PortingBulkPortabilityContext: - """ - Constructs a PortingBulkPortabilityContext - - :param sid: A 34 character string that uniquely identifies the Portability check. - """ - return PortingBulkPortabilityContext(self._version, sid=sid) - - 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 b0cd0fdfc1..bfca5762e0 100644 --- a/twilio/rest/numbers/v1/porting_port_in.py +++ b/twilio/rest/numbers/v1/porting_port_in.py @@ -12,9 +12,10 @@ Do not edit the class manually. """ -from typing import Any, Dict, Optional, Union -from twilio.base import values - +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 from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.version import Version @@ -23,14 +24,111 @@ 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: + :ivar url: The URL of this Port In request + :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: 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: """ - def __init__(self, version: Version, payload: Dict[str, Any]): + def __init__( + self, + version: Version, + payload: Dict[str, Any], + port_in_request_sid: Optional[str] = None, + ): super().__init__(version) self.port_in_request_sid: Optional[str] = payload.get("port_in_request_sid") self.url: Optional[str] = payload.get("url") + self.account_sid: Optional[str] = payload.get("account_sid") + self.notification_emails: Optional[List[str]] = payload.get( + "notification_emails" + ) + self.target_port_in_date: Optional[date] = deserialize.iso8601_date( + payload.get("target_port_in_date") + ) + self.target_port_in_time_range_start: Optional[str] = payload.get( + "target_port_in_time_range_start" + ) + self.target_port_in_time_range_end: Optional[str] = payload.get( + "target_port_in_time_range_end" + ) + self.port_in_request_status: Optional[str] = payload.get( + "port_in_request_status" + ) + self.losing_carrier_information: Optional[Dict[str, object]] = payload.get( + "losing_carrier_information" + ) + self.phone_numbers: Optional[List[Dict[str, object]]] = payload.get( + "phone_numbers" + ) + self.documents: Optional[List[str]] = payload.get("documents") + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_created") + ) + + self._solution = { + "port_in_request_sid": port_in_request_sid or self.port_in_request_sid, + } + self._context: Optional[PortingPortInContext] = None + + @property + def _proxy(self) -> "PortingPortInContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: PortingPortInContext for this PortingPortInInstance + """ + if self._context is None: + self._context = PortingPortInContext( + self._version, + port_in_request_sid=self._solution["port_in_request_sid"], + ) + return self._context + + def delete(self) -> bool: + """ + Deletes the PortingPortInInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._proxy.delete() + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the PortingPortInInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._proxy.delete_async() + + def fetch(self) -> "PortingPortInInstance": + """ + Fetch the PortingPortInInstance + + + :returns: The fetched PortingPortInInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "PortingPortInInstance": + """ + Asynchronous coroutine to fetch the PortingPortInInstance + + + :returns: The fetched PortingPortInInstance + """ + return await self._proxy.fetch_async() def __repr__(self) -> str: """ @@ -38,8 +136,103 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class PortingPortInContext(InstanceContext): + + def __init__(self, version: Version, port_in_request_sid: str): + """ + Initialize the PortingPortInContext + + :param version: Version that contains the resource + :param port_in_request_sid: The SID of the Port In request. This is a unique identifier of the port in request. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "port_in_request_sid": port_in_request_sid, + } + self._uri = "/Porting/PortIn/{port_in_request_sid}".format(**self._solution) + + def delete(self) -> bool: + """ + Deletes the PortingPortInInstance + + + :returns: True if delete succeeds, False otherwise + """ + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the PortingPortInInstance + + + :returns: True if delete succeeds, False otherwise + """ + + headers = values.of({}) + + return await self._version.delete_async( + method="DELETE", uri=self._uri, headers=headers + ) + + def fetch(self) -> PortingPortInInstance: + """ + Fetch the PortingPortInInstance + + + :returns: The fetched PortingPortInInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return PortingPortInInstance( + self._version, + payload, + port_in_request_sid=self._solution["port_in_request_sid"], + ) + + async def fetch_async(self) -> PortingPortInInstance: + """ + Asynchronous coroutine to fetch the PortingPortInInstance - return "" + + :returns: The fetched PortingPortInInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + return PortingPortInInstance( + self._version, + payload, + port_in_request_sid=self._solution["port_in_request_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 PortingPortInList(ListResource): @@ -67,7 +260,12 @@ def create( """ data = body.to_dict() - headers = {"Content-Type": "application/json"} + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + payload = self._version.create( method="POST", uri=self._uri, data=data, headers=headers ) @@ -84,9 +282,13 @@ async def create_async( :returns: The created PortingPortInInstance """ - data = body.to_dict() - headers = {"Content-Type": "application/json"} + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" payload = await self._version.create_async( method="POST", uri=self._uri, data=data, headers=headers @@ -94,6 +296,26 @@ async def create_async( return PortingPortInInstance(self._version, payload) + def get(self, port_in_request_sid: str) -> PortingPortInContext: + """ + Constructs a PortingPortInContext + + :param port_in_request_sid: The SID of the Port In request. This is a unique identifier of the port in request. + """ + return PortingPortInContext( + self._version, port_in_request_sid=port_in_request_sid + ) + + def __call__(self, port_in_request_sid: str) -> PortingPortInContext: + """ + Constructs a PortingPortInContext + + :param port_in_request_sid: The SID of the Port In request. This is a unique identifier of the port in request. + """ + return PortingPortInContext( + self._version, port_in_request_sid=port_in_request_sid + ) + def __repr__(self) -> str: """ Provide a friendly representation diff --git a/twilio/rest/numbers/v1/porting_port_in_fetch.py b/twilio/rest/numbers/v1/porting_port_in_fetch.py deleted file mode 100644 index 78e31afbd8..0000000000 --- a/twilio/rest/numbers/v1/porting_port_in_fetch.py +++ /dev/null @@ -1,219 +0,0 @@ -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 date -from typing import Any, Dict, List, 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 PortingPortInFetchInstance(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 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 - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - port_in_request_sid: Optional[str] = None, - ): - super().__init__(version) - - self.port_in_request_sid: Optional[str] = payload.get("port_in_request_sid") - self.url: Optional[str] = payload.get("url") - self.account_sid: Optional[str] = payload.get("account_sid") - self.notification_emails: Optional[List[str]] = payload.get( - "notification_emails" - ) - self.target_port_in_date: Optional[date] = deserialize.iso8601_date( - payload.get("target_port_in_date") - ) - self.target_port_in_time_range_start: Optional[str] = payload.get( - "target_port_in_time_range_start" - ) - self.target_port_in_time_range_end: Optional[str] = payload.get( - "target_port_in_time_range_end" - ) - self.losing_carrier_information: Optional[Dict[str, object]] = payload.get( - "losing_carrier_information" - ) - self.phone_numbers: Optional[List[Dict[str, object]]] = payload.get( - "phone_numbers" - ) - self.documents: Optional[List[str]] = payload.get("documents") - - self._solution = { - "port_in_request_sid": port_in_request_sid or self.port_in_request_sid, - } - self._context: Optional[PortingPortInFetchContext] = None - - @property - def _proxy(self) -> "PortingPortInFetchContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: PortingPortInFetchContext for this PortingPortInFetchInstance - """ - if self._context is None: - self._context = PortingPortInFetchContext( - self._version, - port_in_request_sid=self._solution["port_in_request_sid"], - ) - return self._context - - def fetch(self) -> "PortingPortInFetchInstance": - """ - Fetch the PortingPortInFetchInstance - - - :returns: The fetched PortingPortInFetchInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "PortingPortInFetchInstance": - """ - Asynchronous coroutine to fetch the PortingPortInFetchInstance - - - :returns: The fetched PortingPortInFetchInstance - """ - 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 PortingPortInFetchContext(InstanceContext): - - def __init__(self, version: Version, port_in_request_sid: str): - """ - Initialize the PortingPortInFetchContext - - :param version: Version that contains the resource - :param port_in_request_sid: The SID of the Port In request. This is a unique identifier of the port in request. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "port_in_request_sid": port_in_request_sid, - } - self._uri = "/Porting/PortIn/{port_in_request_sid}".format(**self._solution) - - def fetch(self) -> PortingPortInFetchInstance: - """ - Fetch the PortingPortInFetchInstance - - - :returns: The fetched PortingPortInFetchInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return PortingPortInFetchInstance( - self._version, - payload, - port_in_request_sid=self._solution["port_in_request_sid"], - ) - - async def fetch_async(self) -> PortingPortInFetchInstance: - """ - Asynchronous coroutine to fetch the PortingPortInFetchInstance - - - :returns: The fetched PortingPortInFetchInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return PortingPortInFetchInstance( - self._version, - payload, - port_in_request_sid=self._solution["port_in_request_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 PortingPortInFetchList(ListResource): - - def __init__(self, version: Version): - """ - Initialize the PortingPortInFetchList - - :param version: Version that contains the resource - - """ - super().__init__(version) - - def get(self, port_in_request_sid: str) -> PortingPortInFetchContext: - """ - Constructs a PortingPortInFetchContext - - :param port_in_request_sid: The SID of the Port In request. This is a unique identifier of the port in request. - """ - return PortingPortInFetchContext( - self._version, port_in_request_sid=port_in_request_sid - ) - - def __call__(self, port_in_request_sid: str) -> PortingPortInFetchContext: - """ - Constructs a PortingPortInFetchContext - - :param port_in_request_sid: The SID of the Port In request. This is a unique identifier of the port in request. - """ - return PortingPortInFetchContext( - self._version, port_in_request_sid=port_in_request_sid - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/numbers/v1/porting_port_in_phone_number.py b/twilio/rest/numbers/v1/porting_port_in_phone_number.py new file mode 100644 index 0000000000..cc8120f78f --- /dev/null +++ b/twilio/rest/numbers/v1/porting_port_in_phone_number.py @@ -0,0 +1,310 @@ +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 +from twilio.base import deserialize, values +from twilio.base.instance_context import InstanceContext +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + + +class PortingPortInPhoneNumberInstance(InstanceResource): + """ + :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__( + self, + version: Version, + payload: Dict[str, Any], + port_in_request_sid: Optional[str] = None, + phone_number_sid: Optional[str] = None, + ): + super().__init__(version) + + self.port_in_request_sid: Optional[str] = payload.get("port_in_request_sid") + self.phone_number_sid: Optional[str] = payload.get("phone_number_sid") + self.url: Optional[str] = payload.get("url") + self.account_sid: Optional[str] = payload.get("account_sid") + self.phone_number_type: Optional[str] = payload.get("phone_number_type") + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_created") + ) + self.country: Optional[str] = payload.get("country") + self.missing_required_fields: Optional[bool] = payload.get( + "missing_required_fields" + ) + self.last_updated: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("last_updated") + ) + self.phone_number: Optional[str] = payload.get("phone_number") + self.portable: Optional[bool] = payload.get("portable") + self.not_portability_reason: Optional[str] = payload.get( + "not_portability_reason" + ) + self.not_portability_reason_code: Optional[int] = deserialize.integer( + payload.get("not_portability_reason_code") + ) + self.port_in_phone_number_status: Optional[str] = payload.get( + "port_in_phone_number_status" + ) + self.port_out_pin: Optional[int] = deserialize.integer( + payload.get("port_out_pin") + ) + self.rejection_reason: Optional[str] = payload.get("rejection_reason") + 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, + "phone_number_sid": phone_number_sid or self.phone_number_sid, + } + self._context: Optional[PortingPortInPhoneNumberContext] = None + + @property + def _proxy(self) -> "PortingPortInPhoneNumberContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: PortingPortInPhoneNumberContext for this PortingPortInPhoneNumberInstance + """ + if self._context is None: + self._context = PortingPortInPhoneNumberContext( + self._version, + port_in_request_sid=self._solution["port_in_request_sid"], + phone_number_sid=self._solution["phone_number_sid"], + ) + return self._context + + def delete(self) -> bool: + """ + Deletes the PortingPortInPhoneNumberInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._proxy.delete() + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the PortingPortInPhoneNumberInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._proxy.delete_async() + + def fetch(self) -> "PortingPortInPhoneNumberInstance": + """ + Fetch the PortingPortInPhoneNumberInstance + + + :returns: The fetched PortingPortInPhoneNumberInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "PortingPortInPhoneNumberInstance": + """ + Asynchronous coroutine to fetch the PortingPortInPhoneNumberInstance + + + :returns: The fetched PortingPortInPhoneNumberInstance + """ + 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 PortingPortInPhoneNumberContext(InstanceContext): + + def __init__( + self, version: Version, port_in_request_sid: str, phone_number_sid: str + ): + """ + Initialize the PortingPortInPhoneNumberContext + + :param version: Version that contains the resource + :param port_in_request_sid: The SID of the Port In request. This is a unique identifier of the port in request. + :param phone_number_sid: The SID of the Phone number. This is a unique identifier of the phone number. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "port_in_request_sid": port_in_request_sid, + "phone_number_sid": phone_number_sid, + } + self._uri = "/Porting/PortIn/{port_in_request_sid}/PhoneNumber/{phone_number_sid}".format( + **self._solution + ) + + def delete(self) -> bool: + """ + Deletes the PortingPortInPhoneNumberInstance + + + :returns: True if delete succeeds, False otherwise + """ + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the PortingPortInPhoneNumberInstance + + + :returns: True if delete succeeds, False otherwise + """ + + headers = values.of({}) + + return await self._version.delete_async( + method="DELETE", uri=self._uri, headers=headers + ) + + def fetch(self) -> PortingPortInPhoneNumberInstance: + """ + Fetch the PortingPortInPhoneNumberInstance + + + :returns: The fetched PortingPortInPhoneNumberInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return PortingPortInPhoneNumberInstance( + self._version, + payload, + port_in_request_sid=self._solution["port_in_request_sid"], + phone_number_sid=self._solution["phone_number_sid"], + ) + + async def fetch_async(self) -> PortingPortInPhoneNumberInstance: + """ + Asynchronous coroutine to fetch the PortingPortInPhoneNumberInstance + + + :returns: The fetched PortingPortInPhoneNumberInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + return PortingPortInPhoneNumberInstance( + self._version, + payload, + port_in_request_sid=self._solution["port_in_request_sid"], + phone_number_sid=self._solution["phone_number_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 PortingPortInPhoneNumberList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the PortingPortInPhoneNumberList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + def get( + self, port_in_request_sid: str, phone_number_sid: str + ) -> PortingPortInPhoneNumberContext: + """ + Constructs a PortingPortInPhoneNumberContext + + :param port_in_request_sid: The SID of the Port In request. This is a unique identifier of the port in request. + :param phone_number_sid: The SID of the Phone number. This is a unique identifier of the phone number. + """ + return PortingPortInPhoneNumberContext( + self._version, + port_in_request_sid=port_in_request_sid, + phone_number_sid=phone_number_sid, + ) + + def __call__( + self, port_in_request_sid: str, phone_number_sid: str + ) -> PortingPortInPhoneNumberContext: + """ + Constructs a PortingPortInPhoneNumberContext + + :param port_in_request_sid: The SID of the Port In request. This is a unique identifier of the port in request. + :param phone_number_sid: The SID of the Phone number. This is a unique identifier of the phone number. + """ + return PortingPortInPhoneNumberContext( + self._version, + port_in_request_sid=port_in_request_sid, + phone_number_sid=phone_number_sid, + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/numbers/v1/porting_portability.py b/twilio/rest/numbers/v1/porting_portability.py index f1cf0cb8c9..351cd541af 100644 --- a/twilio/rest/numbers/v1/porting_portability.py +++ b/twilio/rest/numbers/v1/porting_portability.py @@ -30,15 +30,13 @@ 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 messaging_carrier: Current messaging carrier of the phone number - :ivar voice_carrier: Current voice carrier of the phone number :ivar url: This is the url of the request that you're trying to reach out to locate the resource. """ @@ -64,8 +62,6 @@ def __init__( payload.get("number_type") ) self.country: Optional[str] = payload.get("country") - self.messaging_carrier: Optional[str] = payload.get("messaging_carrier") - self.voice_carrier: Optional[str] = payload.get("voice_carrier") self.url: Optional[str] = payload.get("url") self._solution = { @@ -89,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: 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. + :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: 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. + :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: @@ -133,7 +137,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) @@ -146,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: 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. + :param address_sid: Address Sid of customer to which the number will be ported. :returns: The fetched PortingPortabilityInstance """ @@ -159,10 +166,17 @@ def fetch( data = values.of( { "TargetAccountSid": target_account_sid, + "AddressSid": address_sid, } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=data) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) return PortingPortabilityInstance( self._version, @@ -171,12 +185,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: 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. + :param address_sid: Address Sid of customer to which the number will be ported. :returns: The fetched PortingPortabilityInstance """ @@ -184,11 +201,16 @@ async def fetch_async( data = values.of( { "TargetAccountSid": target_account_sid, + "AddressSid": address_sid, } ) + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return PortingPortabilityInstance( @@ -222,7 +244,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) @@ -230,7 +252,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 new file mode 100644 index 0000000000..cfd9e1d0a8 --- /dev/null +++ b/twilio/rest/numbers/v1/porting_webhook_configuration.py @@ -0,0 +1,116 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Numbers + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from typing import Any, Dict, List, Optional, 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 PortingWebhookConfigurationInstance(InstanceResource): + """ + :ivar url: The URL of the webhook configuration request + :ivar port_in_target_url: The complete webhook url that will be called when a notification event for port in request or port in phone number happens + :ivar port_out_target_url: The complete webhook url that will be called when a notification event for a port out phone number happens. + :ivar notifications_of: A list to filter what notification events to receive for this account and its sub accounts. If it is an empty list, then it means that there are no filters for the notifications events to send in each webhook and all events will get sent. + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.url: Optional[str] = payload.get("url") + self.port_in_target_url: Optional[str] = payload.get("port_in_target_url") + self.port_out_target_url: Optional[str] = payload.get("port_out_target_url") + self.notifications_of: Optional[List[str]] = payload.get("notifications_of") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class PortingWebhookConfigurationList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the PortingWebhookConfigurationList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/Porting/Configuration/Webhook" + + def create( + self, body: Union[object, object] = values.unset + ) -> PortingWebhookConfigurationInstance: + """ + Create the PortingWebhookConfigurationInstance + + :param body: + + :returns: The created PortingWebhookConfigurationInstance + """ + data = body.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + payload = self._version.create( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return PortingWebhookConfigurationInstance(self._version, payload) + + async def create_async( + self, body: Union[object, object] = values.unset + ) -> PortingWebhookConfigurationInstance: + """ + Asynchronously create the PortingWebhookConfigurationInstance + + :param body: + + :returns: The created PortingWebhookConfigurationInstance + """ + data = body.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return PortingWebhookConfigurationInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/numbers/v1/porting_webhook_configuration_delete.py b/twilio/rest/numbers/v1/porting_webhook_configuration_delete.py new file mode 100644 index 0000000000..11572f1846 --- /dev/null +++ b/twilio/rest/numbers/v1/porting_webhook_configuration_delete.py @@ -0,0 +1,124 @@ +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 twilio.base import values +from twilio.base.instance_context import InstanceContext + +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + + +class PortingWebhookConfigurationDeleteContext(InstanceContext): + + def __init__( + self, + version: Version, + webhook_type: "PortingWebhookConfigurationDeleteInstance.WebhookType", + ): + """ + Initialize the PortingWebhookConfigurationDeleteContext + + :param version: Version that contains the resource + :param webhook_type: The webhook type for the configuration to be delete. `PORT_IN`, `PORT_OUT` + """ + super().__init__(version) + + # Path Solution + self._solution = { + "webhook_type": webhook_type, + } + self._uri = "/Porting/Configuration/Webhook/{webhook_type}".format( + **self._solution + ) + + def delete(self) -> bool: + """ + Deletes the PortingWebhookConfigurationDeleteInstance + + + :returns: True if delete succeeds, False otherwise + """ + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the PortingWebhookConfigurationDeleteInstance + + + :returns: True if delete succeeds, False otherwise + """ + + headers = values.of({}) + + return await self._version.delete_async( + method="DELETE", uri=self._uri, headers=headers + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format( + context + ) + + +class PortingWebhookConfigurationDeleteList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the PortingWebhookConfigurationDeleteList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + def get( + self, webhook_type: "PortingWebhookConfigurationDeleteInstance.WebhookType" + ) -> PortingWebhookConfigurationDeleteContext: + """ + Constructs a PortingWebhookConfigurationDeleteContext + + :param webhook_type: The webhook type for the configuration to be delete. `PORT_IN`, `PORT_OUT` + """ + return PortingWebhookConfigurationDeleteContext( + self._version, webhook_type=webhook_type + ) + + def __call__( + self, webhook_type: "PortingWebhookConfigurationDeleteInstance.WebhookType" + ) -> PortingWebhookConfigurationDeleteContext: + """ + Constructs a PortingWebhookConfigurationDeleteContext + + :param webhook_type: The webhook type for the configuration to be delete. `PORT_IN`, `PORT_OUT` + """ + return PortingWebhookConfigurationDeleteContext( + self._version, webhook_type=webhook_type + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/numbers/v1/porting_webhook_configuration_fetch.py b/twilio/rest/numbers/v1/porting_webhook_configuration_fetch.py new file mode 100644 index 0000000000..5d381768c7 --- /dev/null +++ b/twilio/rest/numbers/v1/porting_webhook_configuration_fetch.py @@ -0,0 +1,109 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Numbers + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from datetime import datetime +from typing import Any, Dict, List, Optional +from twilio.base import deserialize, values + +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + + +class PortingWebhookConfigurationFetchInstance(InstanceResource): + """ + :ivar url: The URL of the webhook configuration request + :ivar port_in_target_url: The complete webhook url that will be called when a notification event for port in request or port in phone number happens + :ivar port_out_target_url: The complete webhook url that will be called when a notification event for a port out phone number happens. + :ivar notifications_of: A list to filter what notification events to receive for this account and its sub accounts. If it is an empty list, then it means that there are no filters for the notifications events to send in each webhook and all events will get sent. + :ivar port_in_target_date_created: Creation date for the port in webhook configuration + :ivar port_out_target_date_created: Creation date for the port out webhook configuration + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.url: Optional[str] = payload.get("url") + self.port_in_target_url: Optional[str] = payload.get("port_in_target_url") + self.port_out_target_url: Optional[str] = payload.get("port_out_target_url") + self.notifications_of: Optional[List[str]] = payload.get("notifications_of") + self.port_in_target_date_created: Optional[datetime] = ( + deserialize.iso8601_datetime(payload.get("port_in_target_date_created")) + ) + self.port_out_target_date_created: Optional[datetime] = ( + deserialize.iso8601_datetime(payload.get("port_out_target_date_created")) + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class PortingWebhookConfigurationFetchList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the PortingWebhookConfigurationFetchList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/Porting/Configuration/Webhook" + + def fetch(self) -> PortingWebhookConfigurationFetchInstance: + """ + Asynchronously fetch the PortingWebhookConfigurationFetchInstance + + + :returns: The fetched PortingWebhookConfigurationFetchInstance + """ + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return PortingWebhookConfigurationFetchInstance(self._version, payload) + + async def fetch_async(self) -> PortingWebhookConfigurationFetchInstance: + """ + Asynchronously fetch the PortingWebhookConfigurationFetchInstance + + + :returns: The fetched PortingWebhookConfigurationFetchInstance + """ + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + return PortingWebhookConfigurationFetchInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/numbers/v1/signing_request_configuration.py b/twilio/rest/numbers/v1/signing_request_configuration.py new file mode 100644 index 0000000000..fcfcd7777b --- /dev/null +++ b/twilio/rest/numbers/v1/signing_request_configuration.py @@ -0,0 +1,375 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Numbers + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from typing import Any, Dict, List, Optional, 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): + """ + :ivar logo_sid: The SID of the document that includes the logo that will appear in the LOA. To upload documents follow the following guide: https://www.twilio.com/docs/phone-numbers/regulatory/getting-started/create-new-bundle-public-rest-apis#supporting-document-create + :ivar friendly_name: This is the string that you assigned as a friendly name for describing the creation of the configuration. + :ivar product: The product or service for which is requesting the signature. + :ivar country: The country ISO code to apply the configuration. + :ivar email_subject: Subject of the email that the end client will receive ex: “Twilio Hosting Request”, maximum length of 255 characters. + :ivar email_message: Content of the email that the end client will receive ex: “This is a Hosting request from Twilio, please check the document and sign it”, maximum length of 5,000 characters. + :ivar url_redirection: Url the end client will be redirected after signing a document. + :ivar url: + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.logo_sid: Optional[str] = payload.get("logo_sid") + self.friendly_name: Optional[str] = payload.get("friendly_name") + self.product: Optional[str] = payload.get("product") + self.country: Optional[str] = payload.get("country") + self.email_subject: Optional[str] = payload.get("email_subject") + self.email_message: Optional[str] = payload.get("email_message") + self.url_redirection: Optional[str] = payload.get("url_redirection") + self.url: Optional[str] = payload.get("url") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + 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): + """ + Initialize the SigningRequestConfigurationList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/SigningRequest/Configuration" + + def create( + self, body: Union[object, object] = values.unset + ) -> SigningRequestConfigurationInstance: + """ + Create the SigningRequestConfigurationInstance + + :param body: + + :returns: The created SigningRequestConfigurationInstance + """ + data = body.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + payload = self._version.create( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return SigningRequestConfigurationInstance(self._version, payload) + + async def create_async( + self, body: Union[object, object] = values.unset + ) -> SigningRequestConfigurationInstance: + """ + Asynchronously create the SigningRequestConfigurationInstance + + :param body: + + :returns: The created SigningRequestConfigurationInstance + """ + data = body.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return 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, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return 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, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + return 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 + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/numbers/v2/__init__.py b/twilio/rest/numbers/v2/__init__.py index 9b5b50154e..04b303486e 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/authorization_document/__init__.py b/twilio/rest/numbers/v2/authorization_document/__init__.py index 7e0a4d9184..033a32cfd7 100644 --- a/twilio/rest/numbers/v2/authorization_document/__init__.py +++ b/twilio/rest/numbers/v2/authorization_document/__init__.py @@ -170,10 +170,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -182,9 +182,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> AuthorizationDocumentInstance: @@ -195,10 +197,11 @@ def fetch(self) -> AuthorizationDocumentInstance: :returns: The fetched AuthorizationDocumentInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return AuthorizationDocumentInstance( self._version, @@ -214,9 +217,12 @@ async def fetch_async(self) -> AuthorizationDocumentInstance: :returns: The fetched AuthorizationDocumentInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return AuthorizationDocumentInstance( @@ -313,11 +319,14 @@ def create( "CcEmails": serialize.map(cc_emails, lambda e: e), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AuthorizationDocumentInstance(self._version, payload) @@ -356,11 +365,14 @@ async def create_async( "CcEmails": serialize.map(cc_emails, lambda e: e), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AuthorizationDocumentInstance(self._version, payload) @@ -520,7 +532,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return AuthorizationDocumentPage(self._version, response) async def page_async( @@ -553,8 +571,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return AuthorizationDocumentPage(self._version, response) diff --git a/twilio/rest/numbers/v2/authorization_document/dependent_hosted_number_order.py b/twilio/rest/numbers/v2/authorization_document/dependent_hosted_number_order.py index 7fc558fee2..36f961f5ef 100644 --- a/twilio/rest/numbers/v2/authorization_document/dependent_hosted_number_order.py +++ b/twilio/rest/numbers/v2/authorization_document/dependent_hosted_number_order.py @@ -350,7 +350,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return DependentHostedNumberOrderPage(self._version, response, self._solution) async def page_async( @@ -391,8 +397,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return DependentHostedNumberOrderPage(self._version, response, self._solution) diff --git a/twilio/rest/numbers/v2/bulk_hosted_number_order.py b/twilio/rest/numbers/v2/bulk_hosted_number_order.py index 0e75a5067b..7259c801d2 100644 --- a/twilio/rest/numbers/v2/bulk_hosted_number_order.py +++ b/twilio/rest/numbers/v2/bulk_hosted_number_order.py @@ -160,7 +160,13 @@ def fetch( } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=data) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) return BulkHostedNumberOrderInstance( self._version, @@ -185,8 +191,12 @@ async def fetch_async( } ) + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return BulkHostedNumberOrderInstance( @@ -230,7 +240,12 @@ def create( """ data = body.to_dict() - headers = {"Content-Type": "application/json"} + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + payload = self._version.create( method="POST", uri=self._uri, data=data, headers=headers ) @@ -247,9 +262,13 @@ async def create_async( :returns: The created BulkHostedNumberOrderInstance """ - data = body.to_dict() - headers = {"Content-Type": "application/json"} + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" payload = await self._version.create_async( method="POST", uri=self._uri, data=data, headers=headers diff --git a/twilio/rest/numbers/v2/bundle_clone.py b/twilio/rest/numbers/v2/bundle_clone.py new file mode 100644 index 0000000000..820fbc9db5 --- /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: 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 + """ + 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: 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 + """ + 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: 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 + """ + 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: 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 + """ + 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/hosted_number_order.py b/twilio/rest/numbers/v2/hosted_number_order.py index 2063e7a87d..6afa755bd3 100644 --- a/twilio/rest/numbers/v2/hosted_number_order.py +++ b/twilio/rest/numbers/v2/hosted_number_order.py @@ -25,14 +25,20 @@ class HostedNumberOrderInstance(InstanceResource): class Status(object): + TWILIO_PROCESSING = "twilio-processing" RECEIVED = "received" + PENDING_VERIFICATION = "pending-verification" VERIFIED = "verified" PENDING_LOA = "pending-loa" CARRIER_PROCESSING = "carrier-processing" + TESTING = "testing" COMPLETED = "completed" FAILED = "failed" ACTION_REQUIRED = "action-required" + class VerificationType(object): + PHONE_CALL = "phone-call" + """ :ivar sid: A 34 character string that uniquely identifies this HostedNumberOrder. :ivar account_sid: A 34 character string that uniquely identifies the account. @@ -53,6 +59,12 @@ class Status(object): :ivar contact_phone_number: The contact phone number of the person authorized to sign the Authorization Document. :ivar bulk_hosting_request_sid: A 34 character string that uniquely identifies the bulk hosting request associated with this HostedNumberOrder. :ivar next_step: The next step you need to take to complete the hosted number order and request it successfully. + :ivar verification_attempts: The number of attempts made to verify ownership via a call for the hosted phone number. + :ivar verification_call_sids: The Call SIDs that identify the calls placed to verify ownership. + :ivar verification_call_delay: The number of seconds to wait before initiating the ownership verification call. Can be a value between 0 and 60, inclusive. + :ivar verification_call_extension: The numerical extension to dial when making the ownership verification call. + :ivar verification_code: The digits the user must pass in the ownership verification call. + :ivar verification_type: """ def __init__( @@ -89,6 +101,22 @@ def __init__( "bulk_hosting_request_sid" ) self.next_step: Optional[str] = payload.get("next_step") + self.verification_attempts: Optional[int] = deserialize.integer( + payload.get("verification_attempts") + ) + self.verification_call_sids: Optional[List[str]] = payload.get( + "verification_call_sids" + ) + self.verification_call_delay: Optional[int] = deserialize.integer( + payload.get("verification_call_delay") + ) + self.verification_call_extension: Optional[str] = payload.get( + "verification_call_extension" + ) + self.verification_code: Optional[str] = payload.get("verification_code") + self.verification_type: Optional[ + "HostedNumberOrderInstance.VerificationType" + ] = payload.get("verification_type") self._solution = { "sid": sid or self.sid, @@ -146,6 +174,48 @@ async def fetch_async(self) -> "HostedNumberOrderInstance": """ return await self._proxy.fetch_async() + def update( + self, + status: "HostedNumberOrderInstance.Status", + verification_call_delay: Union[int, object] = values.unset, + verification_call_extension: Union[str, object] = values.unset, + ) -> "HostedNumberOrderInstance": + """ + Update the HostedNumberOrderInstance + + :param status: + :param verification_call_delay: The number of seconds to wait before initiating the ownership verification call. Can be a value between 0 and 60, inclusive. + :param verification_call_extension: The numerical extension to dial when making the ownership verification call. + + :returns: The updated HostedNumberOrderInstance + """ + return self._proxy.update( + status=status, + verification_call_delay=verification_call_delay, + verification_call_extension=verification_call_extension, + ) + + async def update_async( + self, + status: "HostedNumberOrderInstance.Status", + verification_call_delay: Union[int, object] = values.unset, + verification_call_extension: Union[str, object] = values.unset, + ) -> "HostedNumberOrderInstance": + """ + Asynchronous coroutine to update the HostedNumberOrderInstance + + :param status: + :param verification_call_delay: The number of seconds to wait before initiating the ownership verification call. Can be a value between 0 and 60, inclusive. + :param verification_call_extension: The numerical extension to dial when making the ownership verification call. + + :returns: The updated HostedNumberOrderInstance + """ + return await self._proxy.update_async( + status=status, + verification_call_delay=verification_call_delay, + verification_call_extension=verification_call_extension, + ) + def __repr__(self) -> str: """ Provide a friendly representation @@ -163,7 +233,7 @@ def __init__(self, version: Version, sid: str): Initialize the HostedNumberOrderContext :param version: Version that contains the resource - :param sid: A 34 character string that uniquely identifies this HostedNumberOrder. + :param sid: The SID of the HostedNumberOrder resource to update. """ super().__init__(version) @@ -180,10 +250,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -192,9 +262,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> HostedNumberOrderInstance: @@ -205,10 +277,11 @@ def fetch(self) -> HostedNumberOrderInstance: :returns: The fetched HostedNumberOrderInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return HostedNumberOrderInstance( self._version, @@ -224,9 +297,12 @@ async def fetch_async(self) -> HostedNumberOrderInstance: :returns: The fetched HostedNumberOrderInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return HostedNumberOrderInstance( @@ -235,6 +311,80 @@ async def fetch_async(self) -> HostedNumberOrderInstance: sid=self._solution["sid"], ) + def update( + self, + status: "HostedNumberOrderInstance.Status", + verification_call_delay: Union[int, object] = values.unset, + verification_call_extension: Union[str, object] = values.unset, + ) -> HostedNumberOrderInstance: + """ + Update the HostedNumberOrderInstance + + :param status: + :param verification_call_delay: The number of seconds to wait before initiating the ownership verification call. Can be a value between 0 and 60, inclusive. + :param verification_call_extension: The numerical extension to dial when making the ownership verification call. + + :returns: The updated HostedNumberOrderInstance + """ + + data = values.of( + { + "Status": status, + "VerificationCallDelay": verification_call_delay, + "VerificationCallExtension": verification_call_extension, + } + ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = self._version.update( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return HostedNumberOrderInstance( + self._version, payload, sid=self._solution["sid"] + ) + + async def update_async( + self, + status: "HostedNumberOrderInstance.Status", + verification_call_delay: Union[int, object] = values.unset, + verification_call_extension: Union[str, object] = values.unset, + ) -> HostedNumberOrderInstance: + """ + Asynchronous coroutine to update the HostedNumberOrderInstance + + :param status: + :param verification_call_delay: The number of seconds to wait before initiating the ownership verification call. Can be a value between 0 and 60, inclusive. + :param verification_call_extension: The numerical extension to dial when making the ownership verification call. + + :returns: The updated HostedNumberOrderInstance + """ + + data = values.of( + { + "Status": status, + "VerificationCallDelay": verification_call_delay, + "VerificationCallExtension": verification_call_extension, + } + ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = await self._version.update_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return HostedNumberOrderInstance( + self._version, payload, sid=self._solution["sid"] + ) + def __repr__(self) -> str: """ Provide a friendly representation @@ -339,11 +489,14 @@ def create( "ContactTitle": contact_title, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return HostedNumberOrderInstance(self._version, payload) @@ -410,11 +563,14 @@ async def create_async( "ContactTitle": contact_title, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return HostedNumberOrderInstance(self._version, payload) @@ -625,7 +781,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return HostedNumberOrderPage(self._version, response) async def page_async( @@ -667,8 +829,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return HostedNumberOrderPage(self._version, response) @@ -700,7 +866,7 @@ def get(self, sid: str) -> HostedNumberOrderContext: """ Constructs a HostedNumberOrderContext - :param sid: A 34 character string that uniquely identifies this HostedNumberOrder. + :param sid: The SID of the HostedNumberOrder resource to update. """ return HostedNumberOrderContext(self._version, sid=sid) @@ -708,7 +874,7 @@ def __call__(self, sid: str) -> HostedNumberOrderContext: """ Constructs a HostedNumberOrderContext - :param sid: A 34 character string that uniquely identifies this HostedNumberOrder. + :param sid: The SID of the HostedNumberOrder resource to update. """ return HostedNumberOrderContext(self._version, sid=sid) diff --git a/twilio/rest/numbers/v2/regulatory_compliance/bundle/__init__.py b/twilio/rest/numbers/v2/regulatory_compliance/bundle/__init__.py index d37caa0fb8..079540d87b 100644 --- a/twilio/rest/numbers/v2/regulatory_compliance/bundle/__init__.py +++ b/twilio/rest/numbers/v2/regulatory_compliance/bundle/__init__.py @@ -266,10 +266,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -278,9 +278,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> BundleInstance: @@ -291,10 +293,11 @@ def fetch(self) -> BundleInstance: :returns: The fetched BundleInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return BundleInstance( self._version, @@ -310,9 +313,12 @@ async def fetch_async(self) -> BundleInstance: :returns: The fetched BundleInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return BundleInstance( @@ -338,6 +344,7 @@ def update( :returns: The updated BundleInstance """ + data = values.of( { "Status": status, @@ -346,11 +353,14 @@ def update( "Email": email, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return BundleInstance(self._version, payload, sid=self._solution["sid"]) @@ -372,6 +382,7 @@ async def update_async( :returns: The updated BundleInstance """ + data = values.of( { "Status": status, @@ -380,11 +391,14 @@ async def update_async( "Email": email, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return BundleInstance(self._version, payload, sid=self._solution["sid"]) @@ -488,6 +502,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 @@ -498,7 +513,8 @@ 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 """ @@ -512,13 +528,17 @@ 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"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return BundleInstance(self._version, payload) @@ -532,6 +552,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,7 +563,8 @@ 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 """ @@ -556,13 +578,17 @@ 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"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return BundleInstance(self._version, payload) @@ -593,7 +619,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`. @@ -653,7 +679,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`. @@ -712,7 +738,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`. @@ -771,7 +797,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`. @@ -831,7 +857,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`. @@ -863,7 +889,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return BundlePage(self._version, response) async def page_async( @@ -891,7 +923,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`. @@ -923,8 +955,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return BundlePage(self._version, response) diff --git a/twilio/rest/numbers/v2/regulatory_compliance/bundle/bundle_copy.py b/twilio/rest/numbers/v2/regulatory_compliance/bundle/bundle_copy.py index a8cf77fd18..d20a569690 100644 --- a/twilio/rest/numbers/v2/regulatory_compliance/bundle/bundle_copy.py +++ b/twilio/rest/numbers/v2/regulatory_compliance/bundle/bundle_copy.py @@ -136,11 +136,14 @@ def create( "FriendlyName": friendly_name, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return BundleCopyInstance( @@ -163,11 +166,14 @@ async def create_async( "FriendlyName": friendly_name, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return BundleCopyInstance( @@ -301,7 +307,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return BundleCopyPage(self._version, response, self._solution) async def page_async( @@ -328,8 +340,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return BundleCopyPage(self._version, response, self._solution) diff --git a/twilio/rest/numbers/v2/regulatory_compliance/bundle/evaluation.py b/twilio/rest/numbers/v2/regulatory_compliance/bundle/evaluation.py index 39aae3b6ed..fd45064808 100644 --- a/twilio/rest/numbers/v2/regulatory_compliance/bundle/evaluation.py +++ b/twilio/rest/numbers/v2/regulatory_compliance/bundle/evaluation.py @@ -140,10 +140,11 @@ def fetch(self) -> EvaluationInstance: :returns: The fetched EvaluationInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return EvaluationInstance( self._version, @@ -160,9 +161,12 @@ async def fetch_async(self) -> EvaluationInstance: :returns: The fetched EvaluationInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return EvaluationInstance( @@ -231,10 +235,11 @@ def create(self) -> EvaluationInstance: :returns: The created EvaluationInstance """ - payload = self._version.create( - method="POST", - uri=self._uri, - ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + payload = self._version.create(method="POST", uri=self._uri, headers=headers) return EvaluationInstance( self._version, payload, bundle_sid=self._solution["bundle_sid"] @@ -248,9 +253,12 @@ async def create_async(self) -> EvaluationInstance: :returns: The created EvaluationInstance """ + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + payload = await self._version.create_async( - method="POST", - uri=self._uri, + method="POST", uri=self._uri, headers=headers ) return EvaluationInstance( @@ -384,7 +392,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return EvaluationPage(self._version, response, self._solution) async def page_async( @@ -411,8 +425,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return EvaluationPage(self._version, response, self._solution) diff --git a/twilio/rest/numbers/v2/regulatory_compliance/bundle/item_assignment.py b/twilio/rest/numbers/v2/regulatory_compliance/bundle/item_assignment.py index d22fc31396..4eb1fe2b33 100644 --- a/twilio/rest/numbers/v2/regulatory_compliance/bundle/item_assignment.py +++ b/twilio/rest/numbers/v2/regulatory_compliance/bundle/item_assignment.py @@ -148,10 +148,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -160,9 +160,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> ItemAssignmentInstance: @@ -173,10 +175,11 @@ def fetch(self) -> ItemAssignmentInstance: :returns: The fetched ItemAssignmentInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ItemAssignmentInstance( self._version, @@ -193,9 +196,12 @@ async def fetch_async(self) -> ItemAssignmentInstance: :returns: The fetched ItemAssignmentInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ItemAssignmentInstance( @@ -270,11 +276,14 @@ def create(self, object_sid: str) -> ItemAssignmentInstance: "ObjectSid": object_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ItemAssignmentInstance( @@ -295,11 +304,14 @@ async def create_async(self, object_sid: str) -> ItemAssignmentInstance: "ObjectSid": object_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ItemAssignmentInstance( @@ -433,7 +445,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ItemAssignmentPage(self._version, response, self._solution) async def page_async( @@ -460,8 +478,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ItemAssignmentPage(self._version, response, self._solution) diff --git a/twilio/rest/numbers/v2/regulatory_compliance/bundle/replace_items.py b/twilio/rest/numbers/v2/regulatory_compliance/bundle/replace_items.py index 09e2823ada..a6a1de024d 100644 --- a/twilio/rest/numbers/v2/regulatory_compliance/bundle/replace_items.py +++ b/twilio/rest/numbers/v2/regulatory_compliance/bundle/replace_items.py @@ -112,11 +112,14 @@ def create(self, from_bundle_sid: str) -> ReplaceItemsInstance: "FromBundleSid": from_bundle_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ReplaceItemsInstance( @@ -137,11 +140,14 @@ async def create_async(self, from_bundle_sid: str) -> ReplaceItemsInstance: "FromBundleSid": from_bundle_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ReplaceItemsInstance( diff --git a/twilio/rest/numbers/v2/regulatory_compliance/end_user.py b/twilio/rest/numbers/v2/regulatory_compliance/end_user.py index 3f9e5ec856..ab1803372a 100644 --- a/twilio/rest/numbers/v2/regulatory_compliance/end_user.py +++ b/twilio/rest/numbers/v2/regulatory_compliance/end_user.py @@ -183,10 +183,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -195,9 +195,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> EndUserInstance: @@ -208,10 +210,11 @@ def fetch(self) -> EndUserInstance: :returns: The fetched EndUserInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return EndUserInstance( self._version, @@ -227,9 +230,12 @@ async def fetch_async(self) -> EndUserInstance: :returns: The fetched EndUserInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return EndUserInstance( @@ -251,17 +257,21 @@ def update( :returns: The updated EndUserInstance """ + data = values.of( { "FriendlyName": friendly_name, "Attributes": serialize.object(attributes), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return EndUserInstance(self._version, payload, sid=self._solution["sid"]) @@ -279,17 +289,21 @@ async def update_async( :returns: The updated EndUserInstance """ + data = values.of( { "FriendlyName": friendly_name, "Attributes": serialize.object(attributes), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return EndUserInstance(self._version, payload, sid=self._solution["sid"]) @@ -359,11 +373,14 @@ def create( "Attributes": serialize.object(attributes), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return EndUserInstance(self._version, payload) @@ -391,11 +408,14 @@ async def create_async( "Attributes": serialize.object(attributes), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return EndUserInstance(self._version, payload) @@ -527,7 +547,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return EndUserPage(self._version, response) async def page_async( @@ -554,8 +580,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return EndUserPage(self._version, response) diff --git a/twilio/rest/numbers/v2/regulatory_compliance/end_user_type.py b/twilio/rest/numbers/v2/regulatory_compliance/end_user_type.py index ba155575ac..f14c8905c7 100644 --- a/twilio/rest/numbers/v2/regulatory_compliance/end_user_type.py +++ b/twilio/rest/numbers/v2/regulatory_compliance/end_user_type.py @@ -114,10 +114,11 @@ def fetch(self) -> EndUserTypeInstance: :returns: The fetched EndUserTypeInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return EndUserTypeInstance( self._version, @@ -133,9 +134,12 @@ async def fetch_async(self) -> EndUserTypeInstance: :returns: The fetched EndUserTypeInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return EndUserTypeInstance( @@ -313,7 +317,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return EndUserTypePage(self._version, response) async def page_async( @@ -340,8 +350,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return EndUserTypePage(self._version, response) diff --git a/twilio/rest/numbers/v2/regulatory_compliance/regulation.py b/twilio/rest/numbers/v2/regulatory_compliance/regulation.py index 9d9a508810..9c1227905e 100644 --- a/twilio/rest/numbers/v2/regulatory_compliance/regulation.py +++ b/twilio/rest/numbers/v2/regulatory_compliance/regulation.py @@ -13,7 +13,7 @@ """ from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator -from twilio.base import values +from twilio.base import serialize, values from twilio.base.instance_context import InstanceContext from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource @@ -72,23 +72,33 @@ def _proxy(self) -> "RegulationContext": ) return self._context - def fetch(self) -> "RegulationInstance": + def fetch( + self, include_constraints: Union[bool, object] = values.unset + ) -> "RegulationInstance": """ Fetch the RegulationInstance + :param include_constraints: A boolean parameter indicating whether to include constraints or not for supporting end user, documents and their fields :returns: The fetched RegulationInstance """ - return self._proxy.fetch() + return self._proxy.fetch( + include_constraints=include_constraints, + ) - async def fetch_async(self) -> "RegulationInstance": + async def fetch_async( + self, include_constraints: Union[bool, object] = values.unset + ) -> "RegulationInstance": """ Asynchronous coroutine to fetch the RegulationInstance + :param include_constraints: A boolean parameter indicating whether to include constraints or not for supporting end user, documents and their fields :returns: The fetched RegulationInstance """ - return await self._proxy.fetch_async() + return await self._proxy.fetch_async( + include_constraints=include_constraints, + ) def __repr__(self) -> str: """ @@ -117,17 +127,29 @@ def __init__(self, version: Version, sid: str): } self._uri = "/RegulatoryCompliance/Regulations/{sid}".format(**self._solution) - def fetch(self) -> RegulationInstance: + def fetch( + self, include_constraints: Union[bool, object] = values.unset + ) -> RegulationInstance: """ Fetch the RegulationInstance + :param include_constraints: A boolean parameter indicating whether to include constraints or not for supporting end user, documents and their fields :returns: The fetched RegulationInstance """ + data = values.of( + { + "IncludeConstraints": serialize.boolean_to_string(include_constraints), + } + ) + + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = self._version.fetch( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, params=data, headers=headers ) return RegulationInstance( @@ -136,17 +158,29 @@ def fetch(self) -> RegulationInstance: sid=self._solution["sid"], ) - async def fetch_async(self) -> RegulationInstance: + async def fetch_async( + self, include_constraints: Union[bool, object] = values.unset + ) -> RegulationInstance: """ Asynchronous coroutine to fetch the RegulationInstance + :param include_constraints: A boolean parameter indicating whether to include constraints or not for supporting end user, documents and their fields :returns: The fetched RegulationInstance """ + data = values.of( + { + "IncludeConstraints": serialize.boolean_to_string(include_constraints), + } + ) + + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, params=data, headers=headers ) return RegulationInstance( @@ -202,6 +236,7 @@ def stream( end_user_type: Union["RegulationInstance.EndUserType", object] = values.unset, iso_country: Union[str, object] = values.unset, number_type: Union[str, object] = values.unset, + include_constraints: Union[bool, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, ) -> Iterator[RegulationInstance]: @@ -214,6 +249,7 @@ def stream( :param "RegulationInstance.EndUserType" end_user_type: The type of End User the regulation requires - can be `individual` or `business`. :param str iso_country: The ISO country code of the phone number's country. :param str number_type: The type of phone number that the regulatory requiremnt is restricting. + :param bool include_constraints: A boolean parameter indicating whether to include constraints or not for supporting end user, documents and their fields :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 @@ -228,6 +264,7 @@ def stream( end_user_type=end_user_type, iso_country=iso_country, number_type=number_type, + include_constraints=include_constraints, page_size=limits["page_size"], ) @@ -238,6 +275,7 @@ async def stream_async( end_user_type: Union["RegulationInstance.EndUserType", object] = values.unset, iso_country: Union[str, object] = values.unset, number_type: Union[str, object] = values.unset, + include_constraints: Union[bool, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, ) -> AsyncIterator[RegulationInstance]: @@ -250,6 +288,7 @@ async def stream_async( :param "RegulationInstance.EndUserType" end_user_type: The type of End User the regulation requires - can be `individual` or `business`. :param str iso_country: The ISO country code of the phone number's country. :param str number_type: The type of phone number that the regulatory requiremnt is restricting. + :param bool include_constraints: A boolean parameter indicating whether to include constraints or not for supporting end user, documents and their fields :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 @@ -264,6 +303,7 @@ async def stream_async( end_user_type=end_user_type, iso_country=iso_country, number_type=number_type, + include_constraints=include_constraints, page_size=limits["page_size"], ) @@ -274,6 +314,7 @@ def list( end_user_type: Union["RegulationInstance.EndUserType", object] = values.unset, iso_country: Union[str, object] = values.unset, number_type: Union[str, object] = values.unset, + include_constraints: Union[bool, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, ) -> List[RegulationInstance]: @@ -285,6 +326,7 @@ def list( :param "RegulationInstance.EndUserType" end_user_type: The type of End User the regulation requires - can be `individual` or `business`. :param str iso_country: The ISO country code of the phone number's country. :param str number_type: The type of phone number that the regulatory requiremnt is restricting. + :param bool include_constraints: A boolean parameter indicating whether to include constraints or not for supporting end user, documents and their fields :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 @@ -299,6 +341,7 @@ def list( end_user_type=end_user_type, iso_country=iso_country, number_type=number_type, + include_constraints=include_constraints, limit=limit, page_size=page_size, ) @@ -309,6 +352,7 @@ async def list_async( end_user_type: Union["RegulationInstance.EndUserType", object] = values.unset, iso_country: Union[str, object] = values.unset, number_type: Union[str, object] = values.unset, + include_constraints: Union[bool, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, ) -> List[RegulationInstance]: @@ -320,6 +364,7 @@ async def list_async( :param "RegulationInstance.EndUserType" end_user_type: The type of End User the regulation requires - can be `individual` or `business`. :param str iso_country: The ISO country code of the phone number's country. :param str number_type: The type of phone number that the regulatory requiremnt is restricting. + :param bool include_constraints: A boolean parameter indicating whether to include constraints or not for supporting end user, documents and their fields :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 @@ -335,6 +380,7 @@ async def list_async( end_user_type=end_user_type, iso_country=iso_country, number_type=number_type, + include_constraints=include_constraints, limit=limit, page_size=page_size, ) @@ -345,6 +391,7 @@ def page( end_user_type: Union["RegulationInstance.EndUserType", object] = values.unset, iso_country: Union[str, object] = values.unset, number_type: Union[str, object] = values.unset, + include_constraints: 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, @@ -356,6 +403,7 @@ def page( :param end_user_type: The type of End User the regulation requires - can be `individual` or `business`. :param iso_country: The ISO country code of the phone number's country. :param number_type: The type of phone number that the regulatory requiremnt is restricting. + :param include_constraints: A boolean parameter indicating whether to include constraints or not for supporting end user, documents and their fields :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 @@ -367,13 +415,20 @@ def page( "EndUserType": end_user_type, "IsoCountry": iso_country, "NumberType": number_type, + "IncludeConstraints": serialize.boolean_to_string(include_constraints), "PageToken": page_token, "Page": page_number, "PageSize": page_size, } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return RegulationPage(self._version, response) async def page_async( @@ -381,6 +436,7 @@ async def page_async( end_user_type: Union["RegulationInstance.EndUserType", object] = values.unset, iso_country: Union[str, object] = values.unset, number_type: Union[str, object] = values.unset, + include_constraints: 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, @@ -392,6 +448,7 @@ async def page_async( :param end_user_type: The type of End User the regulation requires - can be `individual` or `business`. :param iso_country: The ISO country code of the phone number's country. :param number_type: The type of phone number that the regulatory requiremnt is restricting. + :param include_constraints: A boolean parameter indicating whether to include constraints or not for supporting end user, documents and their fields :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 @@ -403,14 +460,19 @@ async def page_async( "EndUserType": end_user_type, "IsoCountry": iso_country, "NumberType": number_type, + "IncludeConstraints": serialize.boolean_to_string(include_constraints), "PageToken": page_token, "Page": page_number, "PageSize": page_size, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return RegulationPage(self._version, response) diff --git a/twilio/rest/numbers/v2/regulatory_compliance/supporting_document.py b/twilio/rest/numbers/v2/regulatory_compliance/supporting_document.py index f2cd4e13d2..b72f993858 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( @@ -197,10 +199,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -209,9 +211,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> SupportingDocumentInstance: @@ -222,10 +226,11 @@ def fetch(self) -> SupportingDocumentInstance: :returns: The fetched SupportingDocumentInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return SupportingDocumentInstance( self._version, @@ -241,9 +246,12 @@ async def fetch_async(self) -> SupportingDocumentInstance: :returns: The fetched SupportingDocumentInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return SupportingDocumentInstance( @@ -265,17 +273,21 @@ def update( :returns: The updated SupportingDocumentInstance """ + data = values.of( { "FriendlyName": friendly_name, "Attributes": serialize.object(attributes), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SupportingDocumentInstance( @@ -295,17 +307,21 @@ async def update_async( :returns: The updated SupportingDocumentInstance """ + data = values.of( { "FriendlyName": friendly_name, "Attributes": serialize.object(attributes), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SupportingDocumentInstance( @@ -377,11 +393,14 @@ def create( "Attributes": serialize.object(attributes), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SupportingDocumentInstance(self._version, payload) @@ -409,11 +428,14 @@ async def create_async( "Attributes": serialize.object(attributes), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SupportingDocumentInstance(self._version, payload) @@ -545,7 +567,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return SupportingDocumentPage(self._version, response) async def page_async( @@ -572,8 +600,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return SupportingDocumentPage(self._version, response) diff --git a/twilio/rest/numbers/v2/regulatory_compliance/supporting_document_type.py b/twilio/rest/numbers/v2/regulatory_compliance/supporting_document_type.py index 0c7dc7b302..692248cb45 100644 --- a/twilio/rest/numbers/v2/regulatory_compliance/supporting_document_type.py +++ b/twilio/rest/numbers/v2/regulatory_compliance/supporting_document_type.py @@ -116,10 +116,11 @@ def fetch(self) -> SupportingDocumentTypeInstance: :returns: The fetched SupportingDocumentTypeInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return SupportingDocumentTypeInstance( self._version, @@ -135,9 +136,12 @@ async def fetch_async(self) -> SupportingDocumentTypeInstance: :returns: The fetched SupportingDocumentTypeInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return SupportingDocumentTypeInstance( @@ -315,7 +319,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return SupportingDocumentTypePage(self._version, response) async def page_async( @@ -342,8 +352,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return SupportingDocumentTypePage(self._version, response) diff --git a/twilio/rest/oauth/__init__.py b/twilio/rest/oauth/__init__.py index 709150e9e0..586cf6b4d9 100644 --- a/twilio/rest/oauth/__init__.py +++ b/twilio/rest/oauth/__init__.py @@ -1,40 +1,10 @@ from warnings import warn from twilio.rest.oauth.OauthBase import OauthBase -from twilio.rest.oauth.v1.device_code import DeviceCodeList -from twilio.rest.oauth.v1.oauth import OauthList -from twilio.rest.oauth.v1.openid_discovery import OpenidDiscoveryList from twilio.rest.oauth.v1.token import TokenList -from twilio.rest.oauth.v1.user_info import UserInfoList class Oauth(OauthBase): - @property - def oauth(self) -> OauthList: - warn( - "oauth is deprecated. Use v1.oauth instead.", - DeprecationWarning, - stacklevel=2, - ) - return self.v1.oauth - - @property - def device_code(self) -> DeviceCodeList: - warn( - "device_code is deprecated. Use v1.device_code instead.", - DeprecationWarning, - stacklevel=2, - ) - return self.v1.device_code - - @property - def openid_discovery(self) -> OpenidDiscoveryList: - warn( - "openid_discovery is deprecated. Use v1.openid_discovery instead.", - DeprecationWarning, - stacklevel=2, - ) - return self.v1.openid_discovery @property def token(self) -> TokenList: @@ -44,12 +14,3 @@ def token(self) -> TokenList: stacklevel=2, ) return self.v1.token - - @property - def user_info(self) -> UserInfoList: - warn( - "user_info is deprecated. Use v1.user_info instead.", - DeprecationWarning, - stacklevel=2, - ) - return self.v1.user_info diff --git a/twilio/rest/oauth/v1/authorize.py b/twilio/rest/oauth/v1/authorize.py index 9798a73f3f..a353c4b8e0 100644 --- a/twilio/rest/oauth/v1/authorize.py +++ b/twilio/rest/oauth/v1/authorize.py @@ -67,6 +67,9 @@ def fetch( :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"}) + + headers["Accept"] = "application/json" params = values.of( { @@ -78,7 +81,9 @@ def fetch( } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=params) + payload = self._version.fetch( + method="GET", uri=self._uri, headers=headers, params=params + ) return AuthorizeInstance(self._version, payload) @@ -96,6 +101,9 @@ async def fetch_async( :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"}) + + headers["Accept"] = "application/json" params = values.of( { @@ -108,7 +116,7 @@ async def fetch_async( ) payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=params + method="GET", uri=self._uri, headers=headers, params=params ) return AuthorizeInstance(self._version, payload) diff --git a/twilio/rest/oauth/v1/token.py b/twilio/rest/oauth/v1/token.py index eb6d9d1b74..18de1008cb 100644 --- a/twilio/rest/oauth/v1/token.py +++ b/twilio/rest/oauth/v1/token.py @@ -12,9 +12,8 @@ Do not edit the class manually. """ -from datetime import datetime from typing import Any, Dict, Optional, Union -from twilio.base import deserialize, values +from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource @@ -37,9 +36,7 @@ def __init__(self, version: Version, payload: Dict[str, Any]): 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[datetime] = deserialize.iso8601_datetime( - payload.get("expires_in") - ) + self.expires_in: Optional[int] = payload.get("expires_in") def __repr__(self) -> str: """ @@ -68,10 +65,12 @@ def create( self, grant_type: str, client_id: str, - client_secret: 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 @@ -82,6 +81,8 @@ def create( :param code: JWT token related to the authorization code grant type. :param redirect_uri: The redirect uri :param audience: The targeted audience uri + :param refresh_token: JWT token related to refresh access token. + :param scope: The scope of token :returns: The created TokenInstance """ @@ -94,13 +95,18 @@ def create( "Code": code, "RedirectUri": redirect_uri, "Audience": audience, + "RefreshToken": refresh_token, + "Scope": scope, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TokenInstance(self._version, payload) @@ -109,10 +115,12 @@ async def create_async( self, grant_type: str, client_id: str, - client_secret: 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,6 +131,8 @@ async def create_async( :param code: JWT token related to the authorization code grant type. :param redirect_uri: The redirect uri :param audience: The targeted audience uri + :param refresh_token: JWT token related to refresh access token. + :param scope: The scope of token :returns: The created TokenInstance """ @@ -135,13 +145,18 @@ async def create_async( "Code": code, "RedirectUri": redirect_uri, "Audience": audience, + "RefreshToken": refresh_token, + "Scope": scope, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TokenInstance(self._version, payload) diff --git a/twilio/rest/preview/PreviewBase.py b/twilio/rest/preview/PreviewBase.py index 6608a69a2c..dd8317b4c0 100644 --- a/twilio/rest/preview/PreviewBase.py +++ b/twilio/rest/preview/PreviewBase.py @@ -13,9 +13,7 @@ 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 from twilio.rest.preview.wireless import Wireless @@ -29,21 +27,10 @@ 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: """ @@ -53,15 +40,6 @@ def hosted_numbers(self) -> HostedNumbers: self._hosted_numbers = HostedNumbers(self) return self._hosted_numbers - @property - def sync(self) -> Sync: - """ - :returns: Versions sync of Preview - """ - if self._sync is None: - self._sync = Sync(self) - return self._sync - @property def marketplace(self) -> Marketplace: """ diff --git a/twilio/rest/preview/__init__.py b/twilio/rest/preview/__init__.py index 79d870e134..501ae417d0 100644 --- a/twilio/rest/preview/__init__.py +++ b/twilio/rest/preview/__init__.py @@ -1,7 +1,6 @@ from warnings import warn from twilio.rest.preview.PreviewBase import PreviewBase -from twilio.rest.preview.deployed_devices.fleet import FleetList from twilio.rest.preview.hosted_numbers.authorization_document import ( AuthorizationDocumentList, ) @@ -15,14 +14,6 @@ class Preview(PreviewBase): - @property - def fleets(self) -> FleetList: - warn( - "fleets is deprecated. Use deployed_devices.fleets instead.", - DeprecationWarning, - stacklevel=2, - ) - return self.deployed_devices.fleets @property def authorization_documents(self) -> AuthorizationDocumentList: 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 0f5c284468..0000000000 --- a/twilio/rest/preview/deployed_devices/fleet/__init__.py +++ /dev/null @@ -1,676 +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, - } - ) - - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) - - 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, - } - ) - - payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, - ) - - 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 1511a06134..0000000000 --- a/twilio/rest/preview/deployed_devices/fleet/certificate.py +++ /dev/null @@ -1,658 +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, - } - ) - - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) - - 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, - } - ) - - payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, - ) - - 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 5c0d109eab..0000000000 --- a/twilio/rest/preview/deployed_devices/fleet/deployment.py +++ /dev/null @@ -1,632 +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, - } - ) - - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) - - 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, - } - ) - - payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, - ) - - 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 7e9b818140..0000000000 --- a/twilio/rest/preview/deployed_devices/fleet/device.py +++ /dev/null @@ -1,702 +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), - } - ) - - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) - - 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), - } - ) - - payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, - ) - - 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 eabfc456cc..0000000000 --- a/twilio/rest/preview/deployed_devices/fleet/key.py +++ /dev/null @@ -1,648 +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, - } - ) - - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) - - 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, - } - ) - - payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, - ) - - 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/preview/hosted_numbers/authorization_document/__init__.py b/twilio/rest/preview/hosted_numbers/authorization_document/__init__.py index 162d0b11a5..49d3d40da5 100644 --- a/twilio/rest/preview/hosted_numbers/authorization_document/__init__.py +++ b/twilio/rest/preview/hosted_numbers/authorization_document/__init__.py @@ -219,10 +219,11 @@ def fetch(self) -> AuthorizationDocumentInstance: :returns: The fetched AuthorizationDocumentInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return AuthorizationDocumentInstance( self._version, @@ -238,9 +239,12 @@ async def fetch_async(self) -> AuthorizationDocumentInstance: :returns: The fetched AuthorizationDocumentInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return AuthorizationDocumentInstance( @@ -272,6 +276,7 @@ def update( :returns: The updated AuthorizationDocumentInstance """ + data = values.of( { "HostedNumberOrderSids": serialize.map( @@ -285,11 +290,14 @@ def update( "ContactPhoneNumber": contact_phone_number, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AuthorizationDocumentInstance( @@ -319,6 +327,7 @@ async def update_async( :returns: The updated AuthorizationDocumentInstance """ + data = values.of( { "HostedNumberOrderSids": serialize.map( @@ -332,11 +341,14 @@ async def update_async( "ContactPhoneNumber": contact_phone_number, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AuthorizationDocumentInstance( @@ -433,11 +445,14 @@ def create( "CcEmails": serialize.map(cc_emails, lambda e: e), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AuthorizationDocumentInstance(self._version, payload) @@ -476,11 +491,14 @@ async def create_async( "CcEmails": serialize.map(cc_emails, lambda e: e), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AuthorizationDocumentInstance(self._version, payload) @@ -640,7 +658,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return AuthorizationDocumentPage(self._version, response) async def page_async( @@ -673,8 +697,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return AuthorizationDocumentPage(self._version, response) diff --git a/twilio/rest/preview/hosted_numbers/authorization_document/dependent_hosted_number_order.py b/twilio/rest/preview/hosted_numbers/authorization_document/dependent_hosted_number_order.py index 35b67d71c7..0ec58f8792 100644 --- a/twilio/rest/preview/hosted_numbers/authorization_document/dependent_hosted_number_order.py +++ b/twilio/rest/preview/hosted_numbers/authorization_document/dependent_hosted_number_order.py @@ -385,7 +385,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return DependentHostedNumberOrderPage(self._version, response, self._solution) async def page_async( @@ -429,8 +435,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return DependentHostedNumberOrderPage(self._version, response, self._solution) diff --git a/twilio/rest/preview/hosted_numbers/hosted_number_order.py b/twilio/rest/preview/hosted_numbers/hosted_number_order.py index 7e68f57b56..0c20af8791 100644 --- a/twilio/rest/preview/hosted_numbers/hosted_number_order.py +++ b/twilio/rest/preview/hosted_numbers/hosted_number_order.py @@ -290,10 +290,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -302,9 +302,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> HostedNumberOrderInstance: @@ -315,10 +317,11 @@ def fetch(self) -> HostedNumberOrderInstance: :returns: The fetched HostedNumberOrderInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return HostedNumberOrderInstance( self._version, @@ -334,9 +337,12 @@ async def fetch_async(self) -> HostedNumberOrderInstance: :returns: The fetched HostedNumberOrderInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return HostedNumberOrderInstance( @@ -376,6 +382,7 @@ def update( :returns: The updated HostedNumberOrderInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -390,11 +397,14 @@ def update( "CallDelay": call_delay, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return HostedNumberOrderInstance( @@ -432,6 +442,7 @@ async def update_async( :returns: The updated HostedNumberOrderInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -446,11 +457,14 @@ async def update_async( "CallDelay": call_delay, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return HostedNumberOrderInstance( @@ -568,11 +582,14 @@ def create( "VerificationDocumentSid": verification_document_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return HostedNumberOrderInstance(self._version, payload) @@ -644,11 +661,14 @@ async def create_async( "VerificationDocumentSid": verification_document_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return HostedNumberOrderInstance(self._version, payload) @@ -859,7 +879,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return HostedNumberOrderPage(self._version, response) async def page_async( @@ -901,8 +927,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return HostedNumberOrderPage(self._version, response) diff --git a/twilio/rest/preview/marketplace/available_add_on/__init__.py b/twilio/rest/preview/marketplace/available_add_on/__init__.py index 7743d8a8c3..e81ec649de 100644 --- a/twilio/rest/preview/marketplace/available_add_on/__init__.py +++ b/twilio/rest/preview/marketplace/available_add_on/__init__.py @@ -132,10 +132,11 @@ def fetch(self) -> AvailableAddOnInstance: :returns: The fetched AvailableAddOnInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return AvailableAddOnInstance( self._version, @@ -151,9 +152,12 @@ async def fetch_async(self) -> AvailableAddOnInstance: :returns: The fetched AvailableAddOnInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return AvailableAddOnInstance( @@ -343,7 +347,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return AvailableAddOnPage(self._version, response) async def page_async( @@ -370,8 +380,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return AvailableAddOnPage(self._version, response) diff --git a/twilio/rest/preview/marketplace/available_add_on/available_add_on_extension.py b/twilio/rest/preview/marketplace/available_add_on/available_add_on_extension.py index d27b74cbfc..4c05f4244d 100644 --- a/twilio/rest/preview/marketplace/available_add_on/available_add_on_extension.py +++ b/twilio/rest/preview/marketplace/available_add_on/available_add_on_extension.py @@ -128,10 +128,11 @@ def fetch(self) -> AvailableAddOnExtensionInstance: :returns: The fetched AvailableAddOnExtensionInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return AvailableAddOnExtensionInstance( self._version, @@ -148,9 +149,12 @@ async def fetch_async(self) -> AvailableAddOnExtensionInstance: :returns: The fetched AvailableAddOnExtensionInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return AvailableAddOnExtensionInstance( @@ -342,7 +346,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return AvailableAddOnExtensionPage(self._version, response, self._solution) async def page_async( @@ -369,8 +379,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return AvailableAddOnExtensionPage(self._version, response, self._solution) diff --git a/twilio/rest/preview/marketplace/installed_add_on/__init__.py b/twilio/rest/preview/marketplace/installed_add_on/__init__.py index d067f9fe79..7f1fadc510 100644 --- a/twilio/rest/preview/marketplace/installed_add_on/__init__.py +++ b/twilio/rest/preview/marketplace/installed_add_on/__init__.py @@ -194,10 +194,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -206,9 +206,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> InstalledAddOnInstance: @@ -219,10 +221,11 @@ def fetch(self) -> InstalledAddOnInstance: :returns: The fetched InstalledAddOnInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return InstalledAddOnInstance( self._version, @@ -238,9 +241,12 @@ async def fetch_async(self) -> InstalledAddOnInstance: :returns: The fetched InstalledAddOnInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return InstalledAddOnInstance( @@ -262,17 +268,21 @@ def update( :returns: The updated InstalledAddOnInstance """ + data = values.of( { "Configuration": serialize.object(configuration), "UniqueName": unique_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return InstalledAddOnInstance(self._version, payload, sid=self._solution["sid"]) @@ -290,17 +300,21 @@ async def update_async( :returns: The updated InstalledAddOnInstance """ + data = values.of( { "Configuration": serialize.object(configuration), "UniqueName": unique_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return InstalledAddOnInstance(self._version, payload, sid=self._solution["sid"]) @@ -387,11 +401,14 @@ def create( "UniqueName": unique_name, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return InstalledAddOnInstance(self._version, payload) @@ -424,11 +441,14 @@ async def create_async( "UniqueName": unique_name, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return InstalledAddOnInstance(self._version, payload) @@ -560,7 +580,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return InstalledAddOnPage(self._version, response) async def page_async( @@ -587,8 +613,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return InstalledAddOnPage(self._version, response) diff --git a/twilio/rest/preview/marketplace/installed_add_on/installed_add_on_extension.py b/twilio/rest/preview/marketplace/installed_add_on/installed_add_on_extension.py index f8e65d12c1..e0574ee2fd 100644 --- a/twilio/rest/preview/marketplace/installed_add_on/installed_add_on_extension.py +++ b/twilio/rest/preview/marketplace/installed_add_on/installed_add_on_extension.py @@ -154,10 +154,11 @@ def fetch(self) -> InstalledAddOnExtensionInstance: :returns: The fetched InstalledAddOnExtensionInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return InstalledAddOnExtensionInstance( self._version, @@ -174,9 +175,12 @@ async def fetch_async(self) -> InstalledAddOnExtensionInstance: :returns: The fetched InstalledAddOnExtensionInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return InstalledAddOnExtensionInstance( @@ -194,16 +198,20 @@ def update(self, enabled: bool) -> InstalledAddOnExtensionInstance: :returns: The updated InstalledAddOnExtensionInstance """ + data = values.of( { "Enabled": serialize.boolean_to_string(enabled), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return InstalledAddOnExtensionInstance( @@ -221,16 +229,20 @@ async def update_async(self, enabled: bool) -> InstalledAddOnExtensionInstance: :returns: The updated InstalledAddOnExtensionInstance """ + data = values.of( { "Enabled": serialize.boolean_to_string(enabled), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return InstalledAddOnExtensionInstance( @@ -422,7 +434,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return InstalledAddOnExtensionPage(self._version, response, self._solution) async def page_async( @@ -449,8 +467,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return InstalledAddOnExtensionPage(self._version, response, self._solution) diff --git a/twilio/rest/preview/sync/service/__init__.py b/twilio/rest/preview/sync/service/__init__.py deleted file mode 100644 index cb8cdf7910..0000000000 --- a/twilio/rest/preview/sync/service/__init__.py +++ /dev/null @@ -1,711 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Preview - This is the public Twilio REST API. - - NOTE: This class is auto generated by OpenAPI Generator. - https://openapi-generator.tech - Do not edit the class manually. -""" - -from datetime import datetime -from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator -from twilio.base import deserialize, serialize, values -from twilio.base.instance_context import InstanceContext -from twilio.base.instance_resource import InstanceResource -from twilio.base.list_resource import ListResource -from twilio.base.version import Version -from twilio.base.page import Page -from twilio.rest.preview.sync.service.document import DocumentList -from twilio.rest.preview.sync.service.sync_list import SyncListList -from twilio.rest.preview.sync.service.sync_map import SyncMapList - - -class ServiceInstance(InstanceResource): - """ - :ivar sid: - :ivar account_sid: - :ivar friendly_name: - :ivar date_created: - :ivar date_updated: - :ivar url: - :ivar webhook_url: - :ivar reachability_webhooks_enabled: - :ivar acl_enabled: - :ivar links: - """ - - def __init__( - self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None - ): - super().__init__(version) - - self.sid: Optional[str] = payload.get("sid") - self.account_sid: Optional[str] = payload.get("account_sid") - self.friendly_name: Optional[str] = payload.get("friendly_name") - self.date_created: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("date_created") - ) - self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("date_updated") - ) - self.url: Optional[str] = payload.get("url") - self.webhook_url: Optional[str] = payload.get("webhook_url") - self.reachability_webhooks_enabled: Optional[bool] = payload.get( - "reachability_webhooks_enabled" - ) - self.acl_enabled: Optional[bool] = payload.get("acl_enabled") - self.links: Optional[Dict[str, object]] = payload.get("links") - - self._solution = { - "sid": sid or self.sid, - } - self._context: Optional[ServiceContext] = None - - @property - def _proxy(self) -> "ServiceContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: ServiceContext for this ServiceInstance - """ - if self._context is None: - self._context = ServiceContext( - self._version, - sid=self._solution["sid"], - ) - return self._context - - def delete(self) -> bool: - """ - Deletes the ServiceInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the ServiceInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def fetch(self) -> "ServiceInstance": - """ - Fetch the ServiceInstance - - - :returns: The fetched ServiceInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "ServiceInstance": - """ - Asynchronous coroutine to fetch the ServiceInstance - - - :returns: The fetched ServiceInstance - """ - return await self._proxy.fetch_async() - - def update( - self, - webhook_url: Union[str, object] = values.unset, - friendly_name: Union[str, object] = values.unset, - reachability_webhooks_enabled: Union[bool, object] = values.unset, - acl_enabled: Union[bool, object] = values.unset, - ) -> "ServiceInstance": - """ - Update the ServiceInstance - - :param webhook_url: - :param friendly_name: - :param reachability_webhooks_enabled: - :param acl_enabled: - - :returns: The updated ServiceInstance - """ - return self._proxy.update( - webhook_url=webhook_url, - friendly_name=friendly_name, - reachability_webhooks_enabled=reachability_webhooks_enabled, - acl_enabled=acl_enabled, - ) - - async def update_async( - self, - webhook_url: Union[str, object] = values.unset, - friendly_name: Union[str, object] = values.unset, - reachability_webhooks_enabled: Union[bool, object] = values.unset, - acl_enabled: Union[bool, object] = values.unset, - ) -> "ServiceInstance": - """ - Asynchronous coroutine to update the ServiceInstance - - :param webhook_url: - :param friendly_name: - :param reachability_webhooks_enabled: - :param acl_enabled: - - :returns: The updated ServiceInstance - """ - return await self._proxy.update_async( - webhook_url=webhook_url, - friendly_name=friendly_name, - reachability_webhooks_enabled=reachability_webhooks_enabled, - acl_enabled=acl_enabled, - ) - - @property - def documents(self) -> DocumentList: - """ - Access the documents - """ - return self._proxy.documents - - @property - def sync_lists(self) -> SyncListList: - """ - Access the sync_lists - """ - return self._proxy.sync_lists - - @property - def sync_maps(self) -> SyncMapList: - """ - Access the sync_maps - """ - return self._proxy.sync_maps - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) - return "".format(context) - - -class ServiceContext(InstanceContext): - - def __init__(self, version: Version, sid: str): - """ - Initialize the ServiceContext - - :param version: Version that contains the resource - :param sid: - """ - super().__init__(version) - - # Path Solution - self._solution = { - "sid": sid, - } - self._uri = "/Services/{sid}".format(**self._solution) - - self._documents: Optional[DocumentList] = None - self._sync_lists: Optional[SyncListList] = None - self._sync_maps: Optional[SyncMapList] = None - - def delete(self) -> bool: - """ - Deletes the ServiceInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the ServiceInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._version.delete_async( - method="DELETE", - uri=self._uri, - ) - - def fetch(self) -> ServiceInstance: - """ - Fetch the ServiceInstance - - - :returns: The fetched ServiceInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return ServiceInstance( - self._version, - payload, - sid=self._solution["sid"], - ) - - async def fetch_async(self) -> ServiceInstance: - """ - Asynchronous coroutine to fetch the ServiceInstance - - - :returns: The fetched ServiceInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return ServiceInstance( - self._version, - payload, - sid=self._solution["sid"], - ) - - def update( - self, - webhook_url: Union[str, object] = values.unset, - friendly_name: Union[str, object] = values.unset, - reachability_webhooks_enabled: Union[bool, object] = values.unset, - acl_enabled: Union[bool, object] = values.unset, - ) -> ServiceInstance: - """ - Update the ServiceInstance - - :param webhook_url: - :param friendly_name: - :param reachability_webhooks_enabled: - :param acl_enabled: - - :returns: The updated ServiceInstance - """ - data = values.of( - { - "WebhookUrl": webhook_url, - "FriendlyName": friendly_name, - "ReachabilityWebhooksEnabled": serialize.boolean_to_string( - reachability_webhooks_enabled - ), - "AclEnabled": serialize.boolean_to_string(acl_enabled), - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return ServiceInstance(self._version, payload, sid=self._solution["sid"]) - - async def update_async( - self, - webhook_url: Union[str, object] = values.unset, - friendly_name: Union[str, object] = values.unset, - reachability_webhooks_enabled: Union[bool, object] = values.unset, - acl_enabled: Union[bool, object] = values.unset, - ) -> ServiceInstance: - """ - Asynchronous coroutine to update the ServiceInstance - - :param webhook_url: - :param friendly_name: - :param reachability_webhooks_enabled: - :param acl_enabled: - - :returns: The updated ServiceInstance - """ - data = values.of( - { - "WebhookUrl": webhook_url, - "FriendlyName": friendly_name, - "ReachabilityWebhooksEnabled": serialize.boolean_to_string( - reachability_webhooks_enabled - ), - "AclEnabled": serialize.boolean_to_string(acl_enabled), - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return ServiceInstance(self._version, payload, sid=self._solution["sid"]) - - @property - def documents(self) -> DocumentList: - """ - Access the documents - """ - if self._documents is None: - self._documents = DocumentList( - self._version, - self._solution["sid"], - ) - return self._documents - - @property - def sync_lists(self) -> SyncListList: - """ - Access the sync_lists - """ - if self._sync_lists is None: - self._sync_lists = SyncListList( - self._version, - self._solution["sid"], - ) - return self._sync_lists - - @property - def sync_maps(self) -> SyncMapList: - """ - Access the sync_maps - """ - if self._sync_maps is None: - self._sync_maps = SyncMapList( - self._version, - self._solution["sid"], - ) - return self._sync_maps - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) - return "".format(context) - - -class ServicePage(Page): - - def get_instance(self, payload: Dict[str, Any]) -> ServiceInstance: - """ - Build an instance of ServiceInstance - - :param payload: Payload response from the API - """ - return ServiceInstance(self._version, payload) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class ServiceList(ListResource): - - def __init__(self, version: Version): - """ - Initialize the ServiceList - - :param version: Version that contains the resource - - """ - super().__init__(version) - - self._uri = "/Services" - - def create( - self, - friendly_name: Union[str, object] = values.unset, - webhook_url: Union[str, object] = values.unset, - reachability_webhooks_enabled: Union[bool, object] = values.unset, - acl_enabled: Union[bool, object] = values.unset, - ) -> ServiceInstance: - """ - Create the ServiceInstance - - :param friendly_name: - :param webhook_url: - :param reachability_webhooks_enabled: - :param acl_enabled: - - :returns: The created ServiceInstance - """ - - data = values.of( - { - "FriendlyName": friendly_name, - "WebhookUrl": webhook_url, - "ReachabilityWebhooksEnabled": serialize.boolean_to_string( - reachability_webhooks_enabled - ), - "AclEnabled": serialize.boolean_to_string(acl_enabled), - } - ) - - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) - - return ServiceInstance(self._version, payload) - - async def create_async( - self, - friendly_name: Union[str, object] = values.unset, - webhook_url: Union[str, object] = values.unset, - reachability_webhooks_enabled: Union[bool, object] = values.unset, - acl_enabled: Union[bool, object] = values.unset, - ) -> ServiceInstance: - """ - Asynchronously create the ServiceInstance - - :param friendly_name: - :param webhook_url: - :param reachability_webhooks_enabled: - :param acl_enabled: - - :returns: The created ServiceInstance - """ - - data = values.of( - { - "FriendlyName": friendly_name, - "WebhookUrl": webhook_url, - "ReachabilityWebhooksEnabled": serialize.boolean_to_string( - reachability_webhooks_enabled - ), - "AclEnabled": serialize.boolean_to_string(acl_enabled), - } - ) - - payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, - ) - - return ServiceInstance(self._version, payload) - - def stream( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[ServiceInstance]: - """ - Streams ServiceInstance records from the API as a generator stream. - This operation lazily loads records as efficiently as possible until the limit - is reached. - The results are returned as a generator, so this operation is memory efficient. - - :param limit: Upper limit for the number of records to return. stream() - guarantees to never return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, stream() will attempt to read the - limit with the most efficient page size, i.e. min(limit, 1000) - - :returns: Generator that will yield up to limit results - """ - limits = self._version.read_limits(limit, page_size) - page = self.page(page_size=limits["page_size"]) - - return self._version.stream(page, limits["limit"]) - - async def stream_async( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> AsyncIterator[ServiceInstance]: - """ - Asynchronously streams ServiceInstance records from the API as a generator stream. - This operation lazily loads records as efficiently as possible until the limit - is reached. - The results are returned as a generator, so this operation is memory efficient. - - :param limit: Upper limit for the number of records to return. stream() - guarantees to never return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, stream() will attempt to read the - limit with the most efficient page size, i.e. min(limit, 1000) - - :returns: Generator that will yield up to limit results - """ - limits = self._version.read_limits(limit, page_size) - page = await self.page_async(page_size=limits["page_size"]) - - return self._version.stream_async(page, limits["limit"]) - - def list( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[ServiceInstance]: - """ - Lists ServiceInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param limit: Upper limit for the number of records to return. list() guarantees - never to return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, list() will attempt to read the limit - with the most efficient page size, i.e. min(limit, 1000) - - :returns: list that will contain up to limit results - """ - return list( - self.stream( - limit=limit, - page_size=page_size, - ) - ) - - async def list_async( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[ServiceInstance]: - """ - Asynchronously lists ServiceInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param limit: Upper limit for the number of records to return. list() guarantees - never to return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, list() will attempt to read the limit - with the most efficient page size, i.e. min(limit, 1000) - - :returns: list that will contain up to limit results - """ - return [ - record - async for record in await self.stream_async( - limit=limit, - page_size=page_size, - ) - ] - - def page( - self, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> ServicePage: - """ - Retrieve a single page of ServiceInstance records from the API. - Request is executed immediately - - :param page_token: PageToken provided by the API - :param page_number: Page Number, this value is simply for client state - :param page_size: Number of records to return, defaults to 50 - - :returns: Page of ServiceInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = self._version.page(method="GET", uri=self._uri, params=data) - return ServicePage(self._version, response) - - async def page_async( - self, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> ServicePage: - """ - Asynchronously retrieve a single page of ServiceInstance records from the API. - Request is executed immediately - - :param page_token: PageToken provided by the API - :param page_number: Page Number, this value is simply for client state - :param page_size: Number of records to return, defaults to 50 - - :returns: Page of ServiceInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = await self._version.page_async( - method="GET", uri=self._uri, params=data - ) - return ServicePage(self._version, response) - - def get_page(self, target_url: str) -> ServicePage: - """ - Retrieve a specific page of ServiceInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of ServiceInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return ServicePage(self._version, response) - - async def get_page_async(self, target_url: str) -> ServicePage: - """ - Asynchronously retrieve a specific page of ServiceInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of ServiceInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return ServicePage(self._version, response) - - def get(self, sid: str) -> ServiceContext: - """ - Constructs a ServiceContext - - :param sid: - """ - return ServiceContext(self._version, sid=sid) - - def __call__(self, sid: str) -> ServiceContext: - """ - Constructs a ServiceContext - - :param sid: - """ - return ServiceContext(self._version, sid=sid) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview/sync/service/document/document_permission.py b/twilio/rest/preview/sync/service/document/document_permission.py deleted file mode 100644 index 48addbb163..0000000000 --- a/twilio/rest/preview/sync/service/document/document_permission.py +++ /dev/null @@ -1,593 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Preview - This is the public Twilio REST API. - - NOTE: This class is auto generated by OpenAPI Generator. - https://openapi-generator.tech - Do not edit the class manually. -""" - -from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator -from twilio.base import serialize, values -from twilio.base.instance_context import InstanceContext -from twilio.base.instance_resource import InstanceResource -from twilio.base.list_resource import ListResource -from twilio.base.version import Version -from twilio.base.page import Page - - -class DocumentPermissionInstance(InstanceResource): - """ - :ivar account_sid: The unique SID identifier of the Twilio Account. - :ivar service_sid: The unique SID identifier of the Sync Service Instance. - :ivar document_sid: The unique SID identifier of the Sync Document to which the Permission applies. - :ivar identity: Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer. - :ivar read: Boolean flag specifying whether the identity can read the Sync Document. - :ivar write: Boolean flag specifying whether the identity can update the Sync Document. - :ivar manage: Boolean flag specifying whether the identity can delete the Sync Document. - :ivar url: Contains an absolute URL for this Sync Document Permission. - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - service_sid: str, - document_sid: str, - identity: Optional[str] = None, - ): - super().__init__(version) - - self.account_sid: Optional[str] = payload.get("account_sid") - self.service_sid: Optional[str] = payload.get("service_sid") - self.document_sid: Optional[str] = payload.get("document_sid") - self.identity: Optional[str] = payload.get("identity") - self.read: Optional[bool] = payload.get("read") - self.write: Optional[bool] = payload.get("write") - self.manage: Optional[bool] = payload.get("manage") - self.url: Optional[str] = payload.get("url") - - self._solution = { - "service_sid": service_sid, - "document_sid": document_sid, - "identity": identity or self.identity, - } - self._context: Optional[DocumentPermissionContext] = None - - @property - def _proxy(self) -> "DocumentPermissionContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: DocumentPermissionContext for this DocumentPermissionInstance - """ - if self._context is None: - self._context = DocumentPermissionContext( - self._version, - service_sid=self._solution["service_sid"], - document_sid=self._solution["document_sid"], - identity=self._solution["identity"], - ) - return self._context - - def delete(self) -> bool: - """ - Deletes the DocumentPermissionInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the DocumentPermissionInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def fetch(self) -> "DocumentPermissionInstance": - """ - Fetch the DocumentPermissionInstance - - - :returns: The fetched DocumentPermissionInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "DocumentPermissionInstance": - """ - Asynchronous coroutine to fetch the DocumentPermissionInstance - - - :returns: The fetched DocumentPermissionInstance - """ - return await self._proxy.fetch_async() - - def update( - self, read: bool, write: bool, manage: bool - ) -> "DocumentPermissionInstance": - """ - Update the DocumentPermissionInstance - - :param read: Boolean flag specifying whether the identity can read the Sync Document. - :param write: Boolean flag specifying whether the identity can update the Sync Document. - :param manage: Boolean flag specifying whether the identity can delete the Sync Document. - - :returns: The updated DocumentPermissionInstance - """ - return self._proxy.update( - read=read, - write=write, - manage=manage, - ) - - async def update_async( - self, read: bool, write: bool, manage: bool - ) -> "DocumentPermissionInstance": - """ - Asynchronous coroutine to update the DocumentPermissionInstance - - :param read: Boolean flag specifying whether the identity can read the Sync Document. - :param write: Boolean flag specifying whether the identity can update the Sync Document. - :param manage: Boolean flag specifying whether the identity can delete the Sync Document. - - :returns: The updated DocumentPermissionInstance - """ - return await self._proxy.update_async( - read=read, - write=write, - manage=manage, - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) - return "".format(context) - - -class DocumentPermissionContext(InstanceContext): - - def __init__( - self, version: Version, service_sid: str, document_sid: str, identity: str - ): - """ - Initialize the DocumentPermissionContext - - :param version: Version that contains the resource - :param service_sid: The unique SID identifier of the Sync Service Instance. - :param document_sid: Identifier of the Sync Document. Either a SID or a unique name. - :param identity: Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "service_sid": service_sid, - "document_sid": document_sid, - "identity": identity, - } - self._uri = "/Services/{service_sid}/Documents/{document_sid}/Permissions/{identity}".format( - **self._solution - ) - - def delete(self) -> bool: - """ - Deletes the DocumentPermissionInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the DocumentPermissionInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._version.delete_async( - method="DELETE", - uri=self._uri, - ) - - def fetch(self) -> DocumentPermissionInstance: - """ - Fetch the DocumentPermissionInstance - - - :returns: The fetched DocumentPermissionInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return DocumentPermissionInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - document_sid=self._solution["document_sid"], - identity=self._solution["identity"], - ) - - async def fetch_async(self) -> DocumentPermissionInstance: - """ - Asynchronous coroutine to fetch the DocumentPermissionInstance - - - :returns: The fetched DocumentPermissionInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return DocumentPermissionInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - document_sid=self._solution["document_sid"], - identity=self._solution["identity"], - ) - - def update( - self, read: bool, write: bool, manage: bool - ) -> DocumentPermissionInstance: - """ - Update the DocumentPermissionInstance - - :param read: Boolean flag specifying whether the identity can read the Sync Document. - :param write: Boolean flag specifying whether the identity can update the Sync Document. - :param manage: Boolean flag specifying whether the identity can delete the Sync Document. - - :returns: The updated DocumentPermissionInstance - """ - data = values.of( - { - "Read": serialize.boolean_to_string(read), - "Write": serialize.boolean_to_string(write), - "Manage": serialize.boolean_to_string(manage), - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return DocumentPermissionInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - document_sid=self._solution["document_sid"], - identity=self._solution["identity"], - ) - - async def update_async( - self, read: bool, write: bool, manage: bool - ) -> DocumentPermissionInstance: - """ - Asynchronous coroutine to update the DocumentPermissionInstance - - :param read: Boolean flag specifying whether the identity can read the Sync Document. - :param write: Boolean flag specifying whether the identity can update the Sync Document. - :param manage: Boolean flag specifying whether the identity can delete the Sync Document. - - :returns: The updated DocumentPermissionInstance - """ - data = values.of( - { - "Read": serialize.boolean_to_string(read), - "Write": serialize.boolean_to_string(write), - "Manage": serialize.boolean_to_string(manage), - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return DocumentPermissionInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - document_sid=self._solution["document_sid"], - identity=self._solution["identity"], - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) - return "".format(context) - - -class DocumentPermissionPage(Page): - - def get_instance(self, payload: Dict[str, Any]) -> DocumentPermissionInstance: - """ - Build an instance of DocumentPermissionInstance - - :param payload: Payload response from the API - """ - return DocumentPermissionInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - document_sid=self._solution["document_sid"], - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class DocumentPermissionList(ListResource): - - def __init__(self, version: Version, service_sid: str, document_sid: str): - """ - Initialize the DocumentPermissionList - - :param version: Version that contains the resource - :param service_sid: - :param document_sid: Identifier of the Sync Document. Either a SID or a unique name. - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "service_sid": service_sid, - "document_sid": document_sid, - } - self._uri = ( - "/Services/{service_sid}/Documents/{document_sid}/Permissions".format( - **self._solution - ) - ) - - def stream( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[DocumentPermissionInstance]: - """ - Streams DocumentPermissionInstance records from the API as a generator stream. - This operation lazily loads records as efficiently as possible until the limit - is reached. - The results are returned as a generator, so this operation is memory efficient. - - :param limit: Upper limit for the number of records to return. stream() - guarantees to never return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, stream() will attempt to read the - limit with the most efficient page size, i.e. min(limit, 1000) - - :returns: Generator that will yield up to limit results - """ - limits = self._version.read_limits(limit, page_size) - page = self.page(page_size=limits["page_size"]) - - return self._version.stream(page, limits["limit"]) - - async def stream_async( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> AsyncIterator[DocumentPermissionInstance]: - """ - Asynchronously streams DocumentPermissionInstance records from the API as a generator stream. - This operation lazily loads records as efficiently as possible until the limit - is reached. - The results are returned as a generator, so this operation is memory efficient. - - :param limit: Upper limit for the number of records to return. stream() - guarantees to never return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, stream() will attempt to read the - limit with the most efficient page size, i.e. min(limit, 1000) - - :returns: Generator that will yield up to limit results - """ - limits = self._version.read_limits(limit, page_size) - page = await self.page_async(page_size=limits["page_size"]) - - return self._version.stream_async(page, limits["limit"]) - - def list( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[DocumentPermissionInstance]: - """ - Lists DocumentPermissionInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param limit: Upper limit for the number of records to return. list() guarantees - never to return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, list() will attempt to read the limit - with the most efficient page size, i.e. min(limit, 1000) - - :returns: list that will contain up to limit results - """ - return list( - self.stream( - limit=limit, - page_size=page_size, - ) - ) - - async def list_async( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[DocumentPermissionInstance]: - """ - Asynchronously lists DocumentPermissionInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param limit: Upper limit for the number of records to return. list() guarantees - never to return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, list() will attempt to read the limit - with the most efficient page size, i.e. min(limit, 1000) - - :returns: list that will contain up to limit results - """ - return [ - record - async for record in await self.stream_async( - limit=limit, - page_size=page_size, - ) - ] - - def page( - self, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> DocumentPermissionPage: - """ - Retrieve a single page of DocumentPermissionInstance records from the API. - Request is executed immediately - - :param page_token: PageToken provided by the API - :param page_number: Page Number, this value is simply for client state - :param page_size: Number of records to return, defaults to 50 - - :returns: Page of DocumentPermissionInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = self._version.page(method="GET", uri=self._uri, params=data) - return DocumentPermissionPage(self._version, response, self._solution) - - async def page_async( - self, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> DocumentPermissionPage: - """ - Asynchronously retrieve a single page of DocumentPermissionInstance records from the API. - Request is executed immediately - - :param page_token: PageToken provided by the API - :param page_number: Page Number, this value is simply for client state - :param page_size: Number of records to return, defaults to 50 - - :returns: Page of DocumentPermissionInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = await self._version.page_async( - method="GET", uri=self._uri, params=data - ) - return DocumentPermissionPage(self._version, response, self._solution) - - def get_page(self, target_url: str) -> DocumentPermissionPage: - """ - Retrieve a specific page of DocumentPermissionInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of DocumentPermissionInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return DocumentPermissionPage(self._version, response, self._solution) - - async def get_page_async(self, target_url: str) -> DocumentPermissionPage: - """ - Asynchronously retrieve a specific page of DocumentPermissionInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of DocumentPermissionInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return DocumentPermissionPage(self._version, response, self._solution) - - def get(self, identity: str) -> DocumentPermissionContext: - """ - Constructs a DocumentPermissionContext - - :param identity: Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer. - """ - return DocumentPermissionContext( - self._version, - service_sid=self._solution["service_sid"], - document_sid=self._solution["document_sid"], - identity=identity, - ) - - def __call__(self, identity: str) -> DocumentPermissionContext: - """ - Constructs a DocumentPermissionContext - - :param identity: Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer. - """ - return DocumentPermissionContext( - self._version, - service_sid=self._solution["service_sid"], - document_sid=self._solution["document_sid"], - identity=identity, - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview/sync/service/sync_list/sync_list_item.py b/twilio/rest/preview/sync/service/sync_list/sync_list_item.py deleted file mode 100644 index 0cefd6c66b..0000000000 --- a/twilio/rest/preview/sync/service/sync_list/sync_list_item.py +++ /dev/null @@ -1,727 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Preview - This is the public Twilio REST API. - - NOTE: This class is auto generated by OpenAPI Generator. - https://openapi-generator.tech - Do not edit the class manually. -""" - -from datetime import datetime -from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator -from twilio.base import deserialize, serialize, values -from twilio.base.instance_context import InstanceContext -from twilio.base.instance_resource import InstanceResource -from twilio.base.list_resource import ListResource -from twilio.base.version import Version -from twilio.base.page import Page - - -class SyncListItemInstance(InstanceResource): - - class QueryFromBoundType(object): - INCLUSIVE = "inclusive" - EXCLUSIVE = "exclusive" - - class QueryResultOrder(object): - ASC = "asc" - DESC = "desc" - - """ - :ivar index: - :ivar account_sid: - :ivar service_sid: - :ivar list_sid: - :ivar url: - :ivar revision: - :ivar data: - :ivar date_created: - :ivar date_updated: - :ivar created_by: - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - service_sid: str, - list_sid: str, - index: Optional[int] = None, - ): - super().__init__(version) - - self.index: Optional[int] = deserialize.integer(payload.get("index")) - self.account_sid: Optional[str] = payload.get("account_sid") - self.service_sid: Optional[str] = payload.get("service_sid") - self.list_sid: Optional[str] = payload.get("list_sid") - self.url: Optional[str] = payload.get("url") - self.revision: Optional[str] = payload.get("revision") - self.data: Optional[Dict[str, object]] = payload.get("data") - self.date_created: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("date_created") - ) - self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("date_updated") - ) - self.created_by: Optional[str] = payload.get("created_by") - - self._solution = { - "service_sid": service_sid, - "list_sid": list_sid, - "index": index or self.index, - } - self._context: Optional[SyncListItemContext] = None - - @property - def _proxy(self) -> "SyncListItemContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: SyncListItemContext for this SyncListItemInstance - """ - if self._context is None: - self._context = SyncListItemContext( - self._version, - service_sid=self._solution["service_sid"], - list_sid=self._solution["list_sid"], - index=self._solution["index"], - ) - return self._context - - def delete(self, if_match: Union[str, object] = values.unset) -> bool: - """ - Deletes the SyncListItemInstance - - :param if_match: The If-Match HTTP request header - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete( - if_match=if_match, - ) - - async def delete_async(self, if_match: Union[str, object] = values.unset) -> bool: - """ - Asynchronous coroutine that deletes the SyncListItemInstance - - :param if_match: The If-Match HTTP request header - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async( - if_match=if_match, - ) - - def fetch(self) -> "SyncListItemInstance": - """ - Fetch the SyncListItemInstance - - - :returns: The fetched SyncListItemInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "SyncListItemInstance": - """ - Asynchronous coroutine to fetch the SyncListItemInstance - - - :returns: The fetched SyncListItemInstance - """ - return await self._proxy.fetch_async() - - def update( - self, data: object, if_match: Union[str, object] = values.unset - ) -> "SyncListItemInstance": - """ - Update the SyncListItemInstance - - :param data: - :param if_match: The If-Match HTTP request header - - :returns: The updated SyncListItemInstance - """ - return self._proxy.update( - data=data, - if_match=if_match, - ) - - async def update_async( - self, data: object, if_match: Union[str, object] = values.unset - ) -> "SyncListItemInstance": - """ - Asynchronous coroutine to update the SyncListItemInstance - - :param data: - :param if_match: The If-Match HTTP request header - - :returns: The updated SyncListItemInstance - """ - return await self._proxy.update_async( - data=data, - if_match=if_match, - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) - return "".format(context) - - -class SyncListItemContext(InstanceContext): - - def __init__(self, version: Version, service_sid: str, list_sid: str, index: int): - """ - Initialize the SyncListItemContext - - :param version: Version that contains the resource - :param service_sid: - :param list_sid: - :param index: - """ - super().__init__(version) - - # Path Solution - self._solution = { - "service_sid": service_sid, - "list_sid": list_sid, - "index": index, - } - self._uri = "/Services/{service_sid}/Lists/{list_sid}/Items/{index}".format( - **self._solution - ) - - def delete(self, if_match: Union[str, object] = values.unset) -> bool: - """ - Deletes the SyncListItemInstance - - :param if_match: The If-Match HTTP request header - - :returns: True if delete succeeds, False otherwise - """ - headers = values.of( - { - "If-Match": if_match, - } - ) - - return self._version.delete(method="DELETE", uri=self._uri, headers=headers) - - async def delete_async(self, if_match: Union[str, object] = values.unset) -> bool: - """ - Asynchronous coroutine that deletes the SyncListItemInstance - - :param if_match: The If-Match HTTP request header - - :returns: True if delete succeeds, False otherwise - """ - headers = values.of( - { - "If-Match": if_match, - } - ) - - return await self._version.delete_async( - method="DELETE", uri=self._uri, headers=headers - ) - - def fetch(self) -> SyncListItemInstance: - """ - Fetch the SyncListItemInstance - - - :returns: The fetched SyncListItemInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return SyncListItemInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - list_sid=self._solution["list_sid"], - index=self._solution["index"], - ) - - async def fetch_async(self) -> SyncListItemInstance: - """ - Asynchronous coroutine to fetch the SyncListItemInstance - - - :returns: The fetched SyncListItemInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return SyncListItemInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - list_sid=self._solution["list_sid"], - index=self._solution["index"], - ) - - def update( - self, data: object, if_match: Union[str, object] = values.unset - ) -> SyncListItemInstance: - """ - Update the SyncListItemInstance - - :param data: - :param if_match: The If-Match HTTP request header - - :returns: The updated SyncListItemInstance - """ - data = values.of( - { - "Data": serialize.object(data), - } - ) - headers = values.of( - { - "If-Match": if_match, - } - ) - - payload = self._version.update( - method="POST", uri=self._uri, data=data, headers=headers - ) - - return SyncListItemInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - list_sid=self._solution["list_sid"], - index=self._solution["index"], - ) - - async def update_async( - self, data: object, if_match: Union[str, object] = values.unset - ) -> SyncListItemInstance: - """ - Asynchronous coroutine to update the SyncListItemInstance - - :param data: - :param if_match: The If-Match HTTP request header - - :returns: The updated SyncListItemInstance - """ - data = values.of( - { - "Data": serialize.object(data), - } - ) - headers = values.of( - { - "If-Match": if_match, - } - ) - - payload = await self._version.update_async( - method="POST", uri=self._uri, data=data, headers=headers - ) - - return SyncListItemInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - list_sid=self._solution["list_sid"], - index=self._solution["index"], - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) - return "".format(context) - - -class SyncListItemPage(Page): - - def get_instance(self, payload: Dict[str, Any]) -> SyncListItemInstance: - """ - Build an instance of SyncListItemInstance - - :param payload: Payload response from the API - """ - return SyncListItemInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - list_sid=self._solution["list_sid"], - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class SyncListItemList(ListResource): - - def __init__(self, version: Version, service_sid: str, list_sid: str): - """ - Initialize the SyncListItemList - - :param version: Version that contains the resource - :param service_sid: - :param list_sid: - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "service_sid": service_sid, - "list_sid": list_sid, - } - self._uri = "/Services/{service_sid}/Lists/{list_sid}/Items".format( - **self._solution - ) - - def create(self, data: object) -> SyncListItemInstance: - """ - Create the SyncListItemInstance - - :param data: - - :returns: The created SyncListItemInstance - """ - - data = values.of( - { - "Data": serialize.object(data), - } - ) - - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) - - return SyncListItemInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - list_sid=self._solution["list_sid"], - ) - - async def create_async(self, data: object) -> SyncListItemInstance: - """ - Asynchronously create the SyncListItemInstance - - :param data: - - :returns: The created SyncListItemInstance - """ - - data = values.of( - { - "Data": serialize.object(data), - } - ) - - payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, - ) - - return SyncListItemInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - list_sid=self._solution["list_sid"], - ) - - def stream( - self, - order: Union["SyncListItemInstance.QueryResultOrder", object] = values.unset, - from_: Union[str, object] = values.unset, - bounds: Union["SyncListItemInstance.QueryFromBoundType", object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[SyncListItemInstance]: - """ - Streams SyncListItemInstance records from the API as a generator stream. - This operation lazily loads records as efficiently as possible until the limit - is reached. - The results are returned as a generator, so this operation is memory efficient. - - :param "SyncListItemInstance.QueryResultOrder" order: - :param str from_: - :param "SyncListItemInstance.QueryFromBoundType" bounds: - :param limit: Upper limit for the number of records to return. stream() - guarantees to never return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, stream() will attempt to read the - limit with the most efficient page size, i.e. min(limit, 1000) - - :returns: Generator that will yield up to limit results - """ - limits = self._version.read_limits(limit, page_size) - page = self.page( - order=order, from_=from_, bounds=bounds, page_size=limits["page_size"] - ) - - return self._version.stream(page, limits["limit"]) - - async def stream_async( - self, - order: Union["SyncListItemInstance.QueryResultOrder", object] = values.unset, - from_: Union[str, object] = values.unset, - bounds: Union["SyncListItemInstance.QueryFromBoundType", object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> AsyncIterator[SyncListItemInstance]: - """ - Asynchronously streams SyncListItemInstance records from the API as a generator stream. - This operation lazily loads records as efficiently as possible until the limit - is reached. - The results are returned as a generator, so this operation is memory efficient. - - :param "SyncListItemInstance.QueryResultOrder" order: - :param str from_: - :param "SyncListItemInstance.QueryFromBoundType" bounds: - :param limit: Upper limit for the number of records to return. stream() - guarantees to never return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, stream() will attempt to read the - limit with the most efficient page size, i.e. min(limit, 1000) - - :returns: Generator that will yield up to limit results - """ - limits = self._version.read_limits(limit, page_size) - page = await self.page_async( - order=order, from_=from_, bounds=bounds, page_size=limits["page_size"] - ) - - return self._version.stream_async(page, limits["limit"]) - - def list( - self, - order: Union["SyncListItemInstance.QueryResultOrder", object] = values.unset, - from_: Union[str, object] = values.unset, - bounds: Union["SyncListItemInstance.QueryFromBoundType", object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[SyncListItemInstance]: - """ - Lists SyncListItemInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param "SyncListItemInstance.QueryResultOrder" order: - :param str from_: - :param "SyncListItemInstance.QueryFromBoundType" bounds: - :param limit: Upper limit for the number of records to return. list() guarantees - never to return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, list() will attempt to read the limit - with the most efficient page size, i.e. min(limit, 1000) - - :returns: list that will contain up to limit results - """ - return list( - self.stream( - order=order, - from_=from_, - bounds=bounds, - limit=limit, - page_size=page_size, - ) - ) - - async def list_async( - self, - order: Union["SyncListItemInstance.QueryResultOrder", object] = values.unset, - from_: Union[str, object] = values.unset, - bounds: Union["SyncListItemInstance.QueryFromBoundType", object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[SyncListItemInstance]: - """ - Asynchronously lists SyncListItemInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param "SyncListItemInstance.QueryResultOrder" order: - :param str from_: - :param "SyncListItemInstance.QueryFromBoundType" bounds: - :param limit: Upper limit for the number of records to return. list() guarantees - never to return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, list() will attempt to read the limit - with the most efficient page size, i.e. min(limit, 1000) - - :returns: list that will contain up to limit results - """ - return [ - record - async for record in await self.stream_async( - order=order, - from_=from_, - bounds=bounds, - limit=limit, - page_size=page_size, - ) - ] - - def page( - self, - order: Union["SyncListItemInstance.QueryResultOrder", object] = values.unset, - from_: Union[str, object] = values.unset, - bounds: Union["SyncListItemInstance.QueryFromBoundType", object] = values.unset, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> SyncListItemPage: - """ - Retrieve a single page of SyncListItemInstance records from the API. - Request is executed immediately - - :param order: - :param from_: - :param bounds: - :param page_token: PageToken provided by the API - :param page_number: Page Number, this value is simply for client state - :param page_size: Number of records to return, defaults to 50 - - :returns: Page of SyncListItemInstance - """ - data = values.of( - { - "Order": order, - "From": from_, - "Bounds": bounds, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = self._version.page(method="GET", uri=self._uri, params=data) - return SyncListItemPage(self._version, response, self._solution) - - async def page_async( - self, - order: Union["SyncListItemInstance.QueryResultOrder", object] = values.unset, - from_: Union[str, object] = values.unset, - bounds: Union["SyncListItemInstance.QueryFromBoundType", object] = values.unset, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> SyncListItemPage: - """ - Asynchronously retrieve a single page of SyncListItemInstance records from the API. - Request is executed immediately - - :param order: - :param from_: - :param bounds: - :param page_token: PageToken provided by the API - :param page_number: Page Number, this value is simply for client state - :param page_size: Number of records to return, defaults to 50 - - :returns: Page of SyncListItemInstance - """ - data = values.of( - { - "Order": order, - "From": from_, - "Bounds": bounds, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = await self._version.page_async( - method="GET", uri=self._uri, params=data - ) - return SyncListItemPage(self._version, response, self._solution) - - def get_page(self, target_url: str) -> SyncListItemPage: - """ - Retrieve a specific page of SyncListItemInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of SyncListItemInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return SyncListItemPage(self._version, response, self._solution) - - async def get_page_async(self, target_url: str) -> SyncListItemPage: - """ - Asynchronously retrieve a specific page of SyncListItemInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of SyncListItemInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return SyncListItemPage(self._version, response, self._solution) - - def get(self, index: int) -> SyncListItemContext: - """ - Constructs a SyncListItemContext - - :param index: - """ - return SyncListItemContext( - self._version, - service_sid=self._solution["service_sid"], - list_sid=self._solution["list_sid"], - index=index, - ) - - def __call__(self, index: int) -> SyncListItemContext: - """ - Constructs a SyncListItemContext - - :param index: - """ - return SyncListItemContext( - self._version, - service_sid=self._solution["service_sid"], - list_sid=self._solution["list_sid"], - index=index, - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview/sync/service/sync_list/sync_list_permission.py b/twilio/rest/preview/sync/service/sync_list/sync_list_permission.py deleted file mode 100644 index 2fcaca5b26..0000000000 --- a/twilio/rest/preview/sync/service/sync_list/sync_list_permission.py +++ /dev/null @@ -1,593 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Preview - This is the public Twilio REST API. - - NOTE: This class is auto generated by OpenAPI Generator. - https://openapi-generator.tech - Do not edit the class manually. -""" - -from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator -from twilio.base import serialize, values -from twilio.base.instance_context import InstanceContext -from twilio.base.instance_resource import InstanceResource -from twilio.base.list_resource import ListResource -from twilio.base.version import Version -from twilio.base.page import Page - - -class SyncListPermissionInstance(InstanceResource): - """ - :ivar account_sid: The unique SID identifier of the Twilio Account. - :ivar service_sid: The unique SID identifier of the Sync Service Instance. - :ivar list_sid: The unique SID identifier of the Sync List to which the Permission applies. - :ivar identity: Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer. - :ivar read: Boolean flag specifying whether the identity can read the Sync List and its Items. - :ivar write: Boolean flag specifying whether the identity can create, update and delete Items of the Sync List. - :ivar manage: Boolean flag specifying whether the identity can delete the Sync List. - :ivar url: Contains an absolute URL for this Sync List Permission. - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - service_sid: str, - list_sid: str, - identity: Optional[str] = None, - ): - super().__init__(version) - - self.account_sid: Optional[str] = payload.get("account_sid") - self.service_sid: Optional[str] = payload.get("service_sid") - self.list_sid: Optional[str] = payload.get("list_sid") - self.identity: Optional[str] = payload.get("identity") - self.read: Optional[bool] = payload.get("read") - self.write: Optional[bool] = payload.get("write") - self.manage: Optional[bool] = payload.get("manage") - self.url: Optional[str] = payload.get("url") - - self._solution = { - "service_sid": service_sid, - "list_sid": list_sid, - "identity": identity or self.identity, - } - self._context: Optional[SyncListPermissionContext] = None - - @property - def _proxy(self) -> "SyncListPermissionContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: SyncListPermissionContext for this SyncListPermissionInstance - """ - if self._context is None: - self._context = SyncListPermissionContext( - self._version, - service_sid=self._solution["service_sid"], - list_sid=self._solution["list_sid"], - identity=self._solution["identity"], - ) - return self._context - - def delete(self) -> bool: - """ - Deletes the SyncListPermissionInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the SyncListPermissionInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def fetch(self) -> "SyncListPermissionInstance": - """ - Fetch the SyncListPermissionInstance - - - :returns: The fetched SyncListPermissionInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "SyncListPermissionInstance": - """ - Asynchronous coroutine to fetch the SyncListPermissionInstance - - - :returns: The fetched SyncListPermissionInstance - """ - return await self._proxy.fetch_async() - - def update( - self, read: bool, write: bool, manage: bool - ) -> "SyncListPermissionInstance": - """ - Update the SyncListPermissionInstance - - :param read: Boolean flag specifying whether the identity can read the Sync List. - :param write: Boolean flag specifying whether the identity can create, update and delete Items of the Sync List. - :param manage: Boolean flag specifying whether the identity can delete the Sync List. - - :returns: The updated SyncListPermissionInstance - """ - return self._proxy.update( - read=read, - write=write, - manage=manage, - ) - - async def update_async( - self, read: bool, write: bool, manage: bool - ) -> "SyncListPermissionInstance": - """ - Asynchronous coroutine to update the SyncListPermissionInstance - - :param read: Boolean flag specifying whether the identity can read the Sync List. - :param write: Boolean flag specifying whether the identity can create, update and delete Items of the Sync List. - :param manage: Boolean flag specifying whether the identity can delete the Sync List. - - :returns: The updated SyncListPermissionInstance - """ - return await self._proxy.update_async( - read=read, - write=write, - manage=manage, - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) - return "".format(context) - - -class SyncListPermissionContext(InstanceContext): - - def __init__( - self, version: Version, service_sid: str, list_sid: str, identity: str - ): - """ - Initialize the SyncListPermissionContext - - :param version: Version that contains the resource - :param service_sid: The unique SID identifier of the Sync Service Instance. - :param list_sid: Identifier of the Sync List. Either a SID or a unique name. - :param identity: Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "service_sid": service_sid, - "list_sid": list_sid, - "identity": identity, - } - self._uri = ( - "/Services/{service_sid}/Lists/{list_sid}/Permissions/{identity}".format( - **self._solution - ) - ) - - def delete(self) -> bool: - """ - Deletes the SyncListPermissionInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the SyncListPermissionInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._version.delete_async( - method="DELETE", - uri=self._uri, - ) - - def fetch(self) -> SyncListPermissionInstance: - """ - Fetch the SyncListPermissionInstance - - - :returns: The fetched SyncListPermissionInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return SyncListPermissionInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - list_sid=self._solution["list_sid"], - identity=self._solution["identity"], - ) - - async def fetch_async(self) -> SyncListPermissionInstance: - """ - Asynchronous coroutine to fetch the SyncListPermissionInstance - - - :returns: The fetched SyncListPermissionInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return SyncListPermissionInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - list_sid=self._solution["list_sid"], - identity=self._solution["identity"], - ) - - def update( - self, read: bool, write: bool, manage: bool - ) -> SyncListPermissionInstance: - """ - Update the SyncListPermissionInstance - - :param read: Boolean flag specifying whether the identity can read the Sync List. - :param write: Boolean flag specifying whether the identity can create, update and delete Items of the Sync List. - :param manage: Boolean flag specifying whether the identity can delete the Sync List. - - :returns: The updated SyncListPermissionInstance - """ - data = values.of( - { - "Read": serialize.boolean_to_string(read), - "Write": serialize.boolean_to_string(write), - "Manage": serialize.boolean_to_string(manage), - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return SyncListPermissionInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - list_sid=self._solution["list_sid"], - identity=self._solution["identity"], - ) - - async def update_async( - self, read: bool, write: bool, manage: bool - ) -> SyncListPermissionInstance: - """ - Asynchronous coroutine to update the SyncListPermissionInstance - - :param read: Boolean flag specifying whether the identity can read the Sync List. - :param write: Boolean flag specifying whether the identity can create, update and delete Items of the Sync List. - :param manage: Boolean flag specifying whether the identity can delete the Sync List. - - :returns: The updated SyncListPermissionInstance - """ - data = values.of( - { - "Read": serialize.boolean_to_string(read), - "Write": serialize.boolean_to_string(write), - "Manage": serialize.boolean_to_string(manage), - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return SyncListPermissionInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - list_sid=self._solution["list_sid"], - identity=self._solution["identity"], - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) - return "".format(context) - - -class SyncListPermissionPage(Page): - - def get_instance(self, payload: Dict[str, Any]) -> SyncListPermissionInstance: - """ - Build an instance of SyncListPermissionInstance - - :param payload: Payload response from the API - """ - return SyncListPermissionInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - list_sid=self._solution["list_sid"], - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class SyncListPermissionList(ListResource): - - def __init__(self, version: Version, service_sid: str, list_sid: str): - """ - Initialize the SyncListPermissionList - - :param version: Version that contains the resource - :param service_sid: - :param list_sid: Identifier of the Sync List. Either a SID or a unique name. - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "service_sid": service_sid, - "list_sid": list_sid, - } - self._uri = "/Services/{service_sid}/Lists/{list_sid}/Permissions".format( - **self._solution - ) - - def stream( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[SyncListPermissionInstance]: - """ - Streams SyncListPermissionInstance records from the API as a generator stream. - This operation lazily loads records as efficiently as possible until the limit - is reached. - The results are returned as a generator, so this operation is memory efficient. - - :param limit: Upper limit for the number of records to return. stream() - guarantees to never return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, stream() will attempt to read the - limit with the most efficient page size, i.e. min(limit, 1000) - - :returns: Generator that will yield up to limit results - """ - limits = self._version.read_limits(limit, page_size) - page = self.page(page_size=limits["page_size"]) - - return self._version.stream(page, limits["limit"]) - - async def stream_async( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> AsyncIterator[SyncListPermissionInstance]: - """ - Asynchronously streams SyncListPermissionInstance records from the API as a generator stream. - This operation lazily loads records as efficiently as possible until the limit - is reached. - The results are returned as a generator, so this operation is memory efficient. - - :param limit: Upper limit for the number of records to return. stream() - guarantees to never return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, stream() will attempt to read the - limit with the most efficient page size, i.e. min(limit, 1000) - - :returns: Generator that will yield up to limit results - """ - limits = self._version.read_limits(limit, page_size) - page = await self.page_async(page_size=limits["page_size"]) - - return self._version.stream_async(page, limits["limit"]) - - def list( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[SyncListPermissionInstance]: - """ - Lists SyncListPermissionInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param limit: Upper limit for the number of records to return. list() guarantees - never to return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, list() will attempt to read the limit - with the most efficient page size, i.e. min(limit, 1000) - - :returns: list that will contain up to limit results - """ - return list( - self.stream( - limit=limit, - page_size=page_size, - ) - ) - - async def list_async( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[SyncListPermissionInstance]: - """ - Asynchronously lists SyncListPermissionInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param limit: Upper limit for the number of records to return. list() guarantees - never to return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, list() will attempt to read the limit - with the most efficient page size, i.e. min(limit, 1000) - - :returns: list that will contain up to limit results - """ - return [ - record - async for record in await self.stream_async( - limit=limit, - page_size=page_size, - ) - ] - - def page( - self, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> SyncListPermissionPage: - """ - Retrieve a single page of SyncListPermissionInstance records from the API. - Request is executed immediately - - :param page_token: PageToken provided by the API - :param page_number: Page Number, this value is simply for client state - :param page_size: Number of records to return, defaults to 50 - - :returns: Page of SyncListPermissionInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = self._version.page(method="GET", uri=self._uri, params=data) - return SyncListPermissionPage(self._version, response, self._solution) - - async def page_async( - self, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> SyncListPermissionPage: - """ - Asynchronously retrieve a single page of SyncListPermissionInstance records from the API. - Request is executed immediately - - :param page_token: PageToken provided by the API - :param page_number: Page Number, this value is simply for client state - :param page_size: Number of records to return, defaults to 50 - - :returns: Page of SyncListPermissionInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = await self._version.page_async( - method="GET", uri=self._uri, params=data - ) - return SyncListPermissionPage(self._version, response, self._solution) - - def get_page(self, target_url: str) -> SyncListPermissionPage: - """ - Retrieve a specific page of SyncListPermissionInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of SyncListPermissionInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return SyncListPermissionPage(self._version, response, self._solution) - - async def get_page_async(self, target_url: str) -> SyncListPermissionPage: - """ - Asynchronously retrieve a specific page of SyncListPermissionInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of SyncListPermissionInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return SyncListPermissionPage(self._version, response, self._solution) - - def get(self, identity: str) -> SyncListPermissionContext: - """ - Constructs a SyncListPermissionContext - - :param identity: Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer. - """ - return SyncListPermissionContext( - self._version, - service_sid=self._solution["service_sid"], - list_sid=self._solution["list_sid"], - identity=identity, - ) - - def __call__(self, identity: str) -> SyncListPermissionContext: - """ - Constructs a SyncListPermissionContext - - :param identity: Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer. - """ - return SyncListPermissionContext( - self._version, - service_sid=self._solution["service_sid"], - list_sid=self._solution["list_sid"], - identity=identity, - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview/sync/service/sync_map/sync_map_item.py b/twilio/rest/preview/sync/service/sync_map/sync_map_item.py deleted file mode 100644 index 322c8ed225..0000000000 --- a/twilio/rest/preview/sync/service/sync_map/sync_map_item.py +++ /dev/null @@ -1,731 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Preview - This is the public Twilio REST API. - - NOTE: This class is auto generated by OpenAPI Generator. - https://openapi-generator.tech - Do not edit the class manually. -""" - -from datetime import datetime -from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator -from twilio.base import deserialize, serialize, values -from twilio.base.instance_context import InstanceContext -from twilio.base.instance_resource import InstanceResource -from twilio.base.list_resource import ListResource -from twilio.base.version import Version -from twilio.base.page import Page - - -class SyncMapItemInstance(InstanceResource): - - class QueryFromBoundType(object): - INCLUSIVE = "inclusive" - EXCLUSIVE = "exclusive" - - class QueryResultOrder(object): - ASC = "asc" - DESC = "desc" - - """ - :ivar key: - :ivar account_sid: - :ivar service_sid: - :ivar map_sid: - :ivar url: - :ivar revision: - :ivar data: - :ivar date_created: - :ivar date_updated: - :ivar created_by: - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - service_sid: str, - map_sid: str, - key: Optional[str] = None, - ): - super().__init__(version) - - self.key: Optional[str] = payload.get("key") - self.account_sid: Optional[str] = payload.get("account_sid") - self.service_sid: Optional[str] = payload.get("service_sid") - self.map_sid: Optional[str] = payload.get("map_sid") - self.url: Optional[str] = payload.get("url") - self.revision: Optional[str] = payload.get("revision") - self.data: Optional[Dict[str, object]] = payload.get("data") - self.date_created: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("date_created") - ) - self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("date_updated") - ) - self.created_by: Optional[str] = payload.get("created_by") - - self._solution = { - "service_sid": service_sid, - "map_sid": map_sid, - "key": key or self.key, - } - self._context: Optional[SyncMapItemContext] = None - - @property - def _proxy(self) -> "SyncMapItemContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: SyncMapItemContext for this SyncMapItemInstance - """ - if self._context is None: - self._context = SyncMapItemContext( - self._version, - service_sid=self._solution["service_sid"], - map_sid=self._solution["map_sid"], - key=self._solution["key"], - ) - return self._context - - def delete(self, if_match: Union[str, object] = values.unset) -> bool: - """ - Deletes the SyncMapItemInstance - - :param if_match: The If-Match HTTP request header - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete( - if_match=if_match, - ) - - async def delete_async(self, if_match: Union[str, object] = values.unset) -> bool: - """ - Asynchronous coroutine that deletes the SyncMapItemInstance - - :param if_match: The If-Match HTTP request header - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async( - if_match=if_match, - ) - - def fetch(self) -> "SyncMapItemInstance": - """ - Fetch the SyncMapItemInstance - - - :returns: The fetched SyncMapItemInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "SyncMapItemInstance": - """ - Asynchronous coroutine to fetch the SyncMapItemInstance - - - :returns: The fetched SyncMapItemInstance - """ - return await self._proxy.fetch_async() - - def update( - self, data: object, if_match: Union[str, object] = values.unset - ) -> "SyncMapItemInstance": - """ - Update the SyncMapItemInstance - - :param data: - :param if_match: The If-Match HTTP request header - - :returns: The updated SyncMapItemInstance - """ - return self._proxy.update( - data=data, - if_match=if_match, - ) - - async def update_async( - self, data: object, if_match: Union[str, object] = values.unset - ) -> "SyncMapItemInstance": - """ - Asynchronous coroutine to update the SyncMapItemInstance - - :param data: - :param if_match: The If-Match HTTP request header - - :returns: The updated SyncMapItemInstance - """ - return await self._proxy.update_async( - data=data, - if_match=if_match, - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) - return "".format(context) - - -class SyncMapItemContext(InstanceContext): - - def __init__(self, version: Version, service_sid: str, map_sid: str, key: str): - """ - Initialize the SyncMapItemContext - - :param version: Version that contains the resource - :param service_sid: - :param map_sid: - :param key: - """ - super().__init__(version) - - # Path Solution - self._solution = { - "service_sid": service_sid, - "map_sid": map_sid, - "key": key, - } - self._uri = "/Services/{service_sid}/Maps/{map_sid}/Items/{key}".format( - **self._solution - ) - - def delete(self, if_match: Union[str, object] = values.unset) -> bool: - """ - Deletes the SyncMapItemInstance - - :param if_match: The If-Match HTTP request header - - :returns: True if delete succeeds, False otherwise - """ - headers = values.of( - { - "If-Match": if_match, - } - ) - - return self._version.delete(method="DELETE", uri=self._uri, headers=headers) - - async def delete_async(self, if_match: Union[str, object] = values.unset) -> bool: - """ - Asynchronous coroutine that deletes the SyncMapItemInstance - - :param if_match: The If-Match HTTP request header - - :returns: True if delete succeeds, False otherwise - """ - headers = values.of( - { - "If-Match": if_match, - } - ) - - return await self._version.delete_async( - method="DELETE", uri=self._uri, headers=headers - ) - - def fetch(self) -> SyncMapItemInstance: - """ - Fetch the SyncMapItemInstance - - - :returns: The fetched SyncMapItemInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return SyncMapItemInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - map_sid=self._solution["map_sid"], - key=self._solution["key"], - ) - - async def fetch_async(self) -> SyncMapItemInstance: - """ - Asynchronous coroutine to fetch the SyncMapItemInstance - - - :returns: The fetched SyncMapItemInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return SyncMapItemInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - map_sid=self._solution["map_sid"], - key=self._solution["key"], - ) - - def update( - self, data: object, if_match: Union[str, object] = values.unset - ) -> SyncMapItemInstance: - """ - Update the SyncMapItemInstance - - :param data: - :param if_match: The If-Match HTTP request header - - :returns: The updated SyncMapItemInstance - """ - data = values.of( - { - "Data": serialize.object(data), - } - ) - headers = values.of( - { - "If-Match": if_match, - } - ) - - payload = self._version.update( - method="POST", uri=self._uri, data=data, headers=headers - ) - - return SyncMapItemInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - map_sid=self._solution["map_sid"], - key=self._solution["key"], - ) - - async def update_async( - self, data: object, if_match: Union[str, object] = values.unset - ) -> SyncMapItemInstance: - """ - Asynchronous coroutine to update the SyncMapItemInstance - - :param data: - :param if_match: The If-Match HTTP request header - - :returns: The updated SyncMapItemInstance - """ - data = values.of( - { - "Data": serialize.object(data), - } - ) - headers = values.of( - { - "If-Match": if_match, - } - ) - - payload = await self._version.update_async( - method="POST", uri=self._uri, data=data, headers=headers - ) - - return SyncMapItemInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - map_sid=self._solution["map_sid"], - key=self._solution["key"], - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) - return "".format(context) - - -class SyncMapItemPage(Page): - - def get_instance(self, payload: Dict[str, Any]) -> SyncMapItemInstance: - """ - Build an instance of SyncMapItemInstance - - :param payload: Payload response from the API - """ - return SyncMapItemInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - map_sid=self._solution["map_sid"], - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class SyncMapItemList(ListResource): - - def __init__(self, version: Version, service_sid: str, map_sid: str): - """ - Initialize the SyncMapItemList - - :param version: Version that contains the resource - :param service_sid: - :param map_sid: - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "service_sid": service_sid, - "map_sid": map_sid, - } - self._uri = "/Services/{service_sid}/Maps/{map_sid}/Items".format( - **self._solution - ) - - def create(self, key: str, data: object) -> SyncMapItemInstance: - """ - Create the SyncMapItemInstance - - :param key: - :param data: - - :returns: The created SyncMapItemInstance - """ - - data = values.of( - { - "Key": key, - "Data": serialize.object(data), - } - ) - - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) - - return SyncMapItemInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - map_sid=self._solution["map_sid"], - ) - - async def create_async(self, key: str, data: object) -> SyncMapItemInstance: - """ - Asynchronously create the SyncMapItemInstance - - :param key: - :param data: - - :returns: The created SyncMapItemInstance - """ - - data = values.of( - { - "Key": key, - "Data": serialize.object(data), - } - ) - - payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, - ) - - return SyncMapItemInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - map_sid=self._solution["map_sid"], - ) - - def stream( - self, - order: Union["SyncMapItemInstance.QueryResultOrder", object] = values.unset, - from_: Union[str, object] = values.unset, - bounds: Union["SyncMapItemInstance.QueryFromBoundType", object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[SyncMapItemInstance]: - """ - Streams SyncMapItemInstance records from the API as a generator stream. - This operation lazily loads records as efficiently as possible until the limit - is reached. - The results are returned as a generator, so this operation is memory efficient. - - :param "SyncMapItemInstance.QueryResultOrder" order: - :param str from_: - :param "SyncMapItemInstance.QueryFromBoundType" bounds: - :param limit: Upper limit for the number of records to return. stream() - guarantees to never return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, stream() will attempt to read the - limit with the most efficient page size, i.e. min(limit, 1000) - - :returns: Generator that will yield up to limit results - """ - limits = self._version.read_limits(limit, page_size) - page = self.page( - order=order, from_=from_, bounds=bounds, page_size=limits["page_size"] - ) - - return self._version.stream(page, limits["limit"]) - - async def stream_async( - self, - order: Union["SyncMapItemInstance.QueryResultOrder", object] = values.unset, - from_: Union[str, object] = values.unset, - bounds: Union["SyncMapItemInstance.QueryFromBoundType", object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> AsyncIterator[SyncMapItemInstance]: - """ - Asynchronously streams SyncMapItemInstance records from the API as a generator stream. - This operation lazily loads records as efficiently as possible until the limit - is reached. - The results are returned as a generator, so this operation is memory efficient. - - :param "SyncMapItemInstance.QueryResultOrder" order: - :param str from_: - :param "SyncMapItemInstance.QueryFromBoundType" bounds: - :param limit: Upper limit for the number of records to return. stream() - guarantees to never return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, stream() will attempt to read the - limit with the most efficient page size, i.e. min(limit, 1000) - - :returns: Generator that will yield up to limit results - """ - limits = self._version.read_limits(limit, page_size) - page = await self.page_async( - order=order, from_=from_, bounds=bounds, page_size=limits["page_size"] - ) - - return self._version.stream_async(page, limits["limit"]) - - def list( - self, - order: Union["SyncMapItemInstance.QueryResultOrder", object] = values.unset, - from_: Union[str, object] = values.unset, - bounds: Union["SyncMapItemInstance.QueryFromBoundType", object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[SyncMapItemInstance]: - """ - Lists SyncMapItemInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param "SyncMapItemInstance.QueryResultOrder" order: - :param str from_: - :param "SyncMapItemInstance.QueryFromBoundType" bounds: - :param limit: Upper limit for the number of records to return. list() guarantees - never to return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, list() will attempt to read the limit - with the most efficient page size, i.e. min(limit, 1000) - - :returns: list that will contain up to limit results - """ - return list( - self.stream( - order=order, - from_=from_, - bounds=bounds, - limit=limit, - page_size=page_size, - ) - ) - - async def list_async( - self, - order: Union["SyncMapItemInstance.QueryResultOrder", object] = values.unset, - from_: Union[str, object] = values.unset, - bounds: Union["SyncMapItemInstance.QueryFromBoundType", object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[SyncMapItemInstance]: - """ - Asynchronously lists SyncMapItemInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param "SyncMapItemInstance.QueryResultOrder" order: - :param str from_: - :param "SyncMapItemInstance.QueryFromBoundType" bounds: - :param limit: Upper limit for the number of records to return. list() guarantees - never to return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, list() will attempt to read the limit - with the most efficient page size, i.e. min(limit, 1000) - - :returns: list that will contain up to limit results - """ - return [ - record - async for record in await self.stream_async( - order=order, - from_=from_, - bounds=bounds, - limit=limit, - page_size=page_size, - ) - ] - - def page( - self, - order: Union["SyncMapItemInstance.QueryResultOrder", object] = values.unset, - from_: Union[str, object] = values.unset, - bounds: Union["SyncMapItemInstance.QueryFromBoundType", object] = values.unset, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> SyncMapItemPage: - """ - Retrieve a single page of SyncMapItemInstance records from the API. - Request is executed immediately - - :param order: - :param from_: - :param bounds: - :param page_token: PageToken provided by the API - :param page_number: Page Number, this value is simply for client state - :param page_size: Number of records to return, defaults to 50 - - :returns: Page of SyncMapItemInstance - """ - data = values.of( - { - "Order": order, - "From": from_, - "Bounds": bounds, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = self._version.page(method="GET", uri=self._uri, params=data) - return SyncMapItemPage(self._version, response, self._solution) - - async def page_async( - self, - order: Union["SyncMapItemInstance.QueryResultOrder", object] = values.unset, - from_: Union[str, object] = values.unset, - bounds: Union["SyncMapItemInstance.QueryFromBoundType", object] = values.unset, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> SyncMapItemPage: - """ - Asynchronously retrieve a single page of SyncMapItemInstance records from the API. - Request is executed immediately - - :param order: - :param from_: - :param bounds: - :param page_token: PageToken provided by the API - :param page_number: Page Number, this value is simply for client state - :param page_size: Number of records to return, defaults to 50 - - :returns: Page of SyncMapItemInstance - """ - data = values.of( - { - "Order": order, - "From": from_, - "Bounds": bounds, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = await self._version.page_async( - method="GET", uri=self._uri, params=data - ) - return SyncMapItemPage(self._version, response, self._solution) - - def get_page(self, target_url: str) -> SyncMapItemPage: - """ - Retrieve a specific page of SyncMapItemInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of SyncMapItemInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return SyncMapItemPage(self._version, response, self._solution) - - async def get_page_async(self, target_url: str) -> SyncMapItemPage: - """ - Asynchronously retrieve a specific page of SyncMapItemInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of SyncMapItemInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return SyncMapItemPage(self._version, response, self._solution) - - def get(self, key: str) -> SyncMapItemContext: - """ - Constructs a SyncMapItemContext - - :param key: - """ - return SyncMapItemContext( - self._version, - service_sid=self._solution["service_sid"], - map_sid=self._solution["map_sid"], - key=key, - ) - - def __call__(self, key: str) -> SyncMapItemContext: - """ - Constructs a SyncMapItemContext - - :param key: - """ - return SyncMapItemContext( - self._version, - service_sid=self._solution["service_sid"], - map_sid=self._solution["map_sid"], - key=key, - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview/sync/service/sync_map/sync_map_permission.py b/twilio/rest/preview/sync/service/sync_map/sync_map_permission.py deleted file mode 100644 index b626f07bdc..0000000000 --- a/twilio/rest/preview/sync/service/sync_map/sync_map_permission.py +++ /dev/null @@ -1,591 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Preview - This is the public Twilio REST API. - - NOTE: This class is auto generated by OpenAPI Generator. - https://openapi-generator.tech - Do not edit the class manually. -""" - -from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator -from twilio.base import serialize, values -from twilio.base.instance_context import InstanceContext -from twilio.base.instance_resource import InstanceResource -from twilio.base.list_resource import ListResource -from twilio.base.version import Version -from twilio.base.page import Page - - -class SyncMapPermissionInstance(InstanceResource): - """ - :ivar account_sid: The unique SID identifier of the Twilio Account. - :ivar service_sid: The unique SID identifier of the Sync Service Instance. - :ivar map_sid: The unique SID identifier of the Sync Map to which the Permission applies. - :ivar identity: Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer. - :ivar read: Boolean flag specifying whether the identity can read the Sync Map and its Items. - :ivar write: Boolean flag specifying whether the identity can create, update and delete Items of the Sync Map. - :ivar manage: Boolean flag specifying whether the identity can delete the Sync Map. - :ivar url: Contains an absolute URL for this Sync Map Permission. - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - service_sid: str, - map_sid: str, - identity: Optional[str] = None, - ): - super().__init__(version) - - self.account_sid: Optional[str] = payload.get("account_sid") - self.service_sid: Optional[str] = payload.get("service_sid") - self.map_sid: Optional[str] = payload.get("map_sid") - self.identity: Optional[str] = payload.get("identity") - self.read: Optional[bool] = payload.get("read") - self.write: Optional[bool] = payload.get("write") - self.manage: Optional[bool] = payload.get("manage") - self.url: Optional[str] = payload.get("url") - - self._solution = { - "service_sid": service_sid, - "map_sid": map_sid, - "identity": identity or self.identity, - } - self._context: Optional[SyncMapPermissionContext] = None - - @property - def _proxy(self) -> "SyncMapPermissionContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: SyncMapPermissionContext for this SyncMapPermissionInstance - """ - if self._context is None: - self._context = SyncMapPermissionContext( - self._version, - service_sid=self._solution["service_sid"], - map_sid=self._solution["map_sid"], - identity=self._solution["identity"], - ) - return self._context - - def delete(self) -> bool: - """ - Deletes the SyncMapPermissionInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the SyncMapPermissionInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def fetch(self) -> "SyncMapPermissionInstance": - """ - Fetch the SyncMapPermissionInstance - - - :returns: The fetched SyncMapPermissionInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "SyncMapPermissionInstance": - """ - Asynchronous coroutine to fetch the SyncMapPermissionInstance - - - :returns: The fetched SyncMapPermissionInstance - """ - return await self._proxy.fetch_async() - - def update( - self, read: bool, write: bool, manage: bool - ) -> "SyncMapPermissionInstance": - """ - Update the SyncMapPermissionInstance - - :param read: Boolean flag specifying whether the identity can read the Sync Map. - :param write: Boolean flag specifying whether the identity can create, update and delete Items of the Sync Map. - :param manage: Boolean flag specifying whether the identity can delete the Sync Map. - - :returns: The updated SyncMapPermissionInstance - """ - return self._proxy.update( - read=read, - write=write, - manage=manage, - ) - - async def update_async( - self, read: bool, write: bool, manage: bool - ) -> "SyncMapPermissionInstance": - """ - Asynchronous coroutine to update the SyncMapPermissionInstance - - :param read: Boolean flag specifying whether the identity can read the Sync Map. - :param write: Boolean flag specifying whether the identity can create, update and delete Items of the Sync Map. - :param manage: Boolean flag specifying whether the identity can delete the Sync Map. - - :returns: The updated SyncMapPermissionInstance - """ - return await self._proxy.update_async( - read=read, - write=write, - manage=manage, - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) - return "".format(context) - - -class SyncMapPermissionContext(InstanceContext): - - def __init__(self, version: Version, service_sid: str, map_sid: str, identity: str): - """ - Initialize the SyncMapPermissionContext - - :param version: Version that contains the resource - :param service_sid: The unique SID identifier of the Sync Service Instance. - :param map_sid: Identifier of the Sync Map. Either a SID or a unique name. - :param identity: Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "service_sid": service_sid, - "map_sid": map_sid, - "identity": identity, - } - self._uri = ( - "/Services/{service_sid}/Maps/{map_sid}/Permissions/{identity}".format( - **self._solution - ) - ) - - def delete(self) -> bool: - """ - Deletes the SyncMapPermissionInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the SyncMapPermissionInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._version.delete_async( - method="DELETE", - uri=self._uri, - ) - - def fetch(self) -> SyncMapPermissionInstance: - """ - Fetch the SyncMapPermissionInstance - - - :returns: The fetched SyncMapPermissionInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return SyncMapPermissionInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - map_sid=self._solution["map_sid"], - identity=self._solution["identity"], - ) - - async def fetch_async(self) -> SyncMapPermissionInstance: - """ - Asynchronous coroutine to fetch the SyncMapPermissionInstance - - - :returns: The fetched SyncMapPermissionInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return SyncMapPermissionInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - map_sid=self._solution["map_sid"], - identity=self._solution["identity"], - ) - - def update( - self, read: bool, write: bool, manage: bool - ) -> SyncMapPermissionInstance: - """ - Update the SyncMapPermissionInstance - - :param read: Boolean flag specifying whether the identity can read the Sync Map. - :param write: Boolean flag specifying whether the identity can create, update and delete Items of the Sync Map. - :param manage: Boolean flag specifying whether the identity can delete the Sync Map. - - :returns: The updated SyncMapPermissionInstance - """ - data = values.of( - { - "Read": serialize.boolean_to_string(read), - "Write": serialize.boolean_to_string(write), - "Manage": serialize.boolean_to_string(manage), - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return SyncMapPermissionInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - map_sid=self._solution["map_sid"], - identity=self._solution["identity"], - ) - - async def update_async( - self, read: bool, write: bool, manage: bool - ) -> SyncMapPermissionInstance: - """ - Asynchronous coroutine to update the SyncMapPermissionInstance - - :param read: Boolean flag specifying whether the identity can read the Sync Map. - :param write: Boolean flag specifying whether the identity can create, update and delete Items of the Sync Map. - :param manage: Boolean flag specifying whether the identity can delete the Sync Map. - - :returns: The updated SyncMapPermissionInstance - """ - data = values.of( - { - "Read": serialize.boolean_to_string(read), - "Write": serialize.boolean_to_string(write), - "Manage": serialize.boolean_to_string(manage), - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return SyncMapPermissionInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - map_sid=self._solution["map_sid"], - identity=self._solution["identity"], - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) - return "".format(context) - - -class SyncMapPermissionPage(Page): - - def get_instance(self, payload: Dict[str, Any]) -> SyncMapPermissionInstance: - """ - Build an instance of SyncMapPermissionInstance - - :param payload: Payload response from the API - """ - return SyncMapPermissionInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - map_sid=self._solution["map_sid"], - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class SyncMapPermissionList(ListResource): - - def __init__(self, version: Version, service_sid: str, map_sid: str): - """ - Initialize the SyncMapPermissionList - - :param version: Version that contains the resource - :param service_sid: - :param map_sid: Identifier of the Sync Map. Either a SID or a unique name. - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "service_sid": service_sid, - "map_sid": map_sid, - } - self._uri = "/Services/{service_sid}/Maps/{map_sid}/Permissions".format( - **self._solution - ) - - def stream( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[SyncMapPermissionInstance]: - """ - Streams SyncMapPermissionInstance records from the API as a generator stream. - This operation lazily loads records as efficiently as possible until the limit - is reached. - The results are returned as a generator, so this operation is memory efficient. - - :param limit: Upper limit for the number of records to return. stream() - guarantees to never return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, stream() will attempt to read the - limit with the most efficient page size, i.e. min(limit, 1000) - - :returns: Generator that will yield up to limit results - """ - limits = self._version.read_limits(limit, page_size) - page = self.page(page_size=limits["page_size"]) - - return self._version.stream(page, limits["limit"]) - - async def stream_async( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> AsyncIterator[SyncMapPermissionInstance]: - """ - Asynchronously streams SyncMapPermissionInstance records from the API as a generator stream. - This operation lazily loads records as efficiently as possible until the limit - is reached. - The results are returned as a generator, so this operation is memory efficient. - - :param limit: Upper limit for the number of records to return. stream() - guarantees to never return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, stream() will attempt to read the - limit with the most efficient page size, i.e. min(limit, 1000) - - :returns: Generator that will yield up to limit results - """ - limits = self._version.read_limits(limit, page_size) - page = await self.page_async(page_size=limits["page_size"]) - - return self._version.stream_async(page, limits["limit"]) - - def list( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[SyncMapPermissionInstance]: - """ - Lists SyncMapPermissionInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param limit: Upper limit for the number of records to return. list() guarantees - never to return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, list() will attempt to read the limit - with the most efficient page size, i.e. min(limit, 1000) - - :returns: list that will contain up to limit results - """ - return list( - self.stream( - limit=limit, - page_size=page_size, - ) - ) - - async def list_async( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[SyncMapPermissionInstance]: - """ - Asynchronously lists SyncMapPermissionInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param limit: Upper limit for the number of records to return. list() guarantees - never to return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, list() will attempt to read the limit - with the most efficient page size, i.e. min(limit, 1000) - - :returns: list that will contain up to limit results - """ - return [ - record - async for record in await self.stream_async( - limit=limit, - page_size=page_size, - ) - ] - - def page( - self, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> SyncMapPermissionPage: - """ - Retrieve a single page of SyncMapPermissionInstance records from the API. - Request is executed immediately - - :param page_token: PageToken provided by the API - :param page_number: Page Number, this value is simply for client state - :param page_size: Number of records to return, defaults to 50 - - :returns: Page of SyncMapPermissionInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = self._version.page(method="GET", uri=self._uri, params=data) - return SyncMapPermissionPage(self._version, response, self._solution) - - async def page_async( - self, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> SyncMapPermissionPage: - """ - Asynchronously retrieve a single page of SyncMapPermissionInstance records from the API. - Request is executed immediately - - :param page_token: PageToken provided by the API - :param page_number: Page Number, this value is simply for client state - :param page_size: Number of records to return, defaults to 50 - - :returns: Page of SyncMapPermissionInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = await self._version.page_async( - method="GET", uri=self._uri, params=data - ) - return SyncMapPermissionPage(self._version, response, self._solution) - - def get_page(self, target_url: str) -> SyncMapPermissionPage: - """ - Retrieve a specific page of SyncMapPermissionInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of SyncMapPermissionInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return SyncMapPermissionPage(self._version, response, self._solution) - - async def get_page_async(self, target_url: str) -> SyncMapPermissionPage: - """ - Asynchronously retrieve a specific page of SyncMapPermissionInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of SyncMapPermissionInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return SyncMapPermissionPage(self._version, response, self._solution) - - def get(self, identity: str) -> SyncMapPermissionContext: - """ - Constructs a SyncMapPermissionContext - - :param identity: Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer. - """ - return SyncMapPermissionContext( - self._version, - service_sid=self._solution["service_sid"], - map_sid=self._solution["map_sid"], - identity=identity, - ) - - def __call__(self, identity: str) -> SyncMapPermissionContext: - """ - Constructs a SyncMapPermissionContext - - :param identity: Arbitrary string identifier representing a human user associated with an FPA token, assigned by the developer. - """ - return SyncMapPermissionContext( - self._version, - service_sid=self._solution["service_sid"], - map_sid=self._solution["map_sid"], - identity=identity, - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview/wireless/command.py b/twilio/rest/preview/wireless/command.py index 755256bb6b..8e715e09ef 100644 --- a/twilio/rest/preview/wireless/command.py +++ b/twilio/rest/preview/wireless/command.py @@ -131,10 +131,11 @@ def fetch(self) -> CommandInstance: :returns: The fetched CommandInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return CommandInstance( self._version, @@ -150,9 +151,12 @@ async def fetch_async(self) -> CommandInstance: :returns: The fetched CommandInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return CommandInstance( @@ -238,11 +242,14 @@ def create( "IncludeSid": include_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CommandInstance(self._version, payload) @@ -282,11 +289,14 @@ async def create_async( "IncludeSid": include_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CommandInstance(self._version, payload) @@ -482,7 +492,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return CommandPage(self._version, response) async def page_async( @@ -521,8 +537,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return CommandPage(self._version, response) diff --git a/twilio/rest/preview/wireless/rate_plan.py b/twilio/rest/preview/wireless/rate_plan.py index f3484efa66..95e45f1ef2 100644 --- a/twilio/rest/preview/wireless/rate_plan.py +++ b/twilio/rest/preview/wireless/rate_plan.py @@ -194,10 +194,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -206,9 +206,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> RatePlanInstance: @@ -219,10 +221,11 @@ def fetch(self) -> RatePlanInstance: :returns: The fetched RatePlanInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return RatePlanInstance( self._version, @@ -238,9 +241,12 @@ async def fetch_async(self) -> RatePlanInstance: :returns: The fetched RatePlanInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return RatePlanInstance( @@ -262,17 +268,21 @@ def update( :returns: The updated RatePlanInstance """ + data = values.of( { "UniqueName": unique_name, "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RatePlanInstance(self._version, payload, sid=self._solution["sid"]) @@ -290,17 +300,21 @@ async def update_async( :returns: The updated RatePlanInstance """ + data = values.of( { "UniqueName": unique_name, "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RatePlanInstance(self._version, payload, sid=self._solution["sid"]) @@ -395,11 +409,14 @@ def create( ), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RatePlanInstance(self._version, payload) @@ -452,11 +469,14 @@ async def create_async( ), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RatePlanInstance(self._version, payload) @@ -588,7 +608,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return RatePlanPage(self._version, response) async def page_async( @@ -615,8 +641,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return RatePlanPage(self._version, response) diff --git a/twilio/rest/preview/wireless/sim/__init__.py b/twilio/rest/preview/wireless/sim/__init__.py index 8620c03ba2..07a9e74da0 100644 --- a/twilio/rest/preview/wireless/sim/__init__.py +++ b/twilio/rest/preview/wireless/sim/__init__.py @@ -285,10 +285,11 @@ def fetch(self) -> SimInstance: :returns: The fetched SimInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return SimInstance( self._version, @@ -304,9 +305,12 @@ async def fetch_async(self) -> SimInstance: :returns: The fetched SimInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return SimInstance( @@ -356,6 +360,7 @@ def update( :returns: The updated SimInstance """ + data = values.of( { "UniqueName": unique_name, @@ -376,11 +381,14 @@ def update( "VoiceUrl": voice_url, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SimInstance(self._version, payload, sid=self._solution["sid"]) @@ -426,6 +434,7 @@ async def update_async( :returns: The updated SimInstance """ + data = values.of( { "UniqueName": unique_name, @@ -446,11 +455,14 @@ async def update_async( "VoiceUrl": voice_url, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SimInstance(self._version, payload, sid=self._solution["sid"]) @@ -715,7 +727,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return SimPage(self._version, response) async def page_async( @@ -757,8 +775,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return SimPage(self._version, response) diff --git a/twilio/rest/preview/wireless/sim/usage.py b/twilio/rest/preview/wireless/sim/usage.py index d90b5f9e84..aff3731b51 100644 --- a/twilio/rest/preview/wireless/sim/usage.py +++ b/twilio/rest/preview/wireless/sim/usage.py @@ -150,7 +150,13 @@ def fetch( } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=data) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) return UsageInstance( self._version, @@ -179,8 +185,12 @@ async def fetch_async( } ) + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return UsageInstance( diff --git a/twilio/rest/preview_iam/PreviewIamBase.py b/twilio/rest/preview_iam/PreviewIamBase.py new file mode 100644 index 0000000000..22fcbe70b1 --- /dev/null +++ b/twilio/rest/preview_iam/PreviewIamBase.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.preview_iam.v1 import V1 + + +class PreviewIamBase(Domain): + + def __init__(self, twilio: Client): + """ + Initialize the PreviewIam Domain + + :returns: Domain for PreviewIam + """ + super().__init__(twilio, "https://preview-iam.twilio.com") + self._v1: Optional[V1] = None + + @property + def v1(self) -> V1: + """ + :returns: Versions v1 of PreviewIam + """ + if self._v1 is None: + self._v1 = V1(self) + return self._v1 + + def __repr__(self) -> str: + """ + Provide a friendly representation + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/preview_iam/__init__.py b/twilio/rest/preview_iam/__init__.py new file mode 100644 index 0000000000..9a5bf85b24 --- /dev/null +++ b/twilio/rest/preview_iam/__init__.py @@ -0,0 +1,26 @@ +from twilio.rest.preview_iam.PreviewIamBase import PreviewIamBase + +from twilio.rest.preview_iam.v1.authorize import ( + AuthorizeList, +) +from twilio.rest.preview_iam.v1.token import ( + TokenList, +) +from twilio.rest.preview_iam.versionless.organization import ( + OrganizationList, +) +from twilio.rest.preview_iam.versionless import Versionless + + +class PreviewIam(PreviewIamBase): + @property + def organization(self) -> OrganizationList: + return Versionless(self).organization + + @property + def authorize(self) -> AuthorizeList: + return self.v1.authorize + + @property + def token(self) -> TokenList: + return self.v1.token diff --git a/twilio/rest/preview_iam/v1/__init__.py b/twilio/rest/preview_iam/v1/__init__.py new file mode 100644 index 0000000000..2243277793 --- /dev/null +++ b/twilio/rest/preview_iam/v1/__init__.py @@ -0,0 +1,51 @@ +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.v1.authorize import AuthorizeList +from twilio.rest.preview_iam.v1.token import TokenList + + +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._authorize: Optional[AuthorizeList] = None + self._token: Optional[TokenList] = None + + @property + def authorize(self) -> AuthorizeList: + if self._authorize is None: + self._authorize = AuthorizeList(self) + return self._authorize + + @property + def token(self) -> TokenList: + if self._token is None: + self._token = TokenList(self) + return self._token + + def __repr__(self) -> str: + """ + Provide a friendly representation + :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 0000000000..4166b4aea2 --- /dev/null +++ b/twilio/rest/preview_iam/v1/authorize.py @@ -0,0 +1,130 @@ +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"}) + + headers["Accept"] = "application/json" + + 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"}) + + headers["Accept"] = "application/json" + + 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/v1/token.py b/twilio/rest/preview_iam/v1/token.py new file mode 100644 index 0000000000..34d9f30080 --- /dev/null +++ b/twilio/rest/preview_iam/v1/token.py @@ -0,0 +1,170 @@ +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 TokenInstance(InstanceResource): + """ + :ivar access_token: Token which carries the necessary information to access a Twilio resource directly. + :ivar refresh_token: Token which carries the information necessary to get a new access token. + :ivar id_token: Token which carries the information necessary of user profile. + :ivar token_type: Token type + :ivar expires_in: + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.access_token: Optional[str] = payload.get("access_token") + self.refresh_token: Optional[str] = payload.get("refresh_token") + self.id_token: Optional[str] = payload.get("id_token") + self.token_type: Optional[str] = payload.get("token_type") + self.expires_in: Optional[int] = payload.get("expires_in") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class TokenList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the TokenList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/token" + + def create( + self, + grant_type: str, + client_id: str, + client_secret: Union[str, object] = values.unset, + code: Union[str, object] = values.unset, + redirect_uri: Union[str, object] = values.unset, + audience: Union[str, object] = values.unset, + refresh_token: Union[str, object] = values.unset, + scope: Union[str, object] = values.unset, + ) -> TokenInstance: + """ + Create the TokenInstance + + :param grant_type: Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token. + :param client_id: A 34 character string that uniquely identifies this OAuth App. + :param client_secret: The credential for confidential OAuth App. + :param code: JWT token related to the authorization code grant type. + :param redirect_uri: The redirect uri + :param audience: The targeted audience uri + :param refresh_token: JWT token related to refresh access token. + :param scope: The scope of token + + :returns: The created TokenInstance + """ + + data = values.of( + { + "grant_type": grant_type, + "client_id": client_id, + "client_secret": client_secret, + "code": code, + "redirect_uri": redirect_uri, + "audience": audience, + "refresh_token": refresh_token, + "scope": scope, + } + ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = self._version.create( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return TokenInstance(self._version, payload) + + async def create_async( + self, + grant_type: str, + client_id: str, + client_secret: Union[str, object] = values.unset, + code: Union[str, object] = values.unset, + redirect_uri: Union[str, object] = values.unset, + audience: Union[str, object] = values.unset, + refresh_token: Union[str, object] = values.unset, + scope: Union[str, object] = values.unset, + ) -> TokenInstance: + """ + Asynchronously create the TokenInstance + + :param grant_type: Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token. + :param client_id: A 34 character string that uniquely identifies this OAuth App. + :param client_secret: The credential for confidential OAuth App. + :param code: JWT token related to the authorization code grant type. + :param redirect_uri: The redirect uri + :param audience: The targeted audience uri + :param refresh_token: JWT token related to refresh access token. + :param scope: The scope of token + + :returns: The created TokenInstance + """ + + data = values.of( + { + "grant_type": grant_type, + "client_id": client_id, + "client_secret": client_secret, + "code": code, + "redirect_uri": redirect_uri, + "audience": audience, + "refresh_token": refresh_token, + "scope": scope, + } + ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return TokenInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/preview_iam/versionless/__init__.py b/twilio/rest/preview_iam/versionless/__init__.py new file mode 100644 index 0000000000..7d6d210f14 --- /dev/null +++ b/twilio/rest/preview_iam/versionless/__init__.py @@ -0,0 +1,43 @@ +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.versionless.organization import OrganizationList + + +class Versionless(Version): + + def __init__(self, domain: Domain): + """ + Initialize the Versionless version of PreviewIam + + :param domain: The Twilio.preview_iam domain + """ + super().__init__(domain, "Organizations") + self._organization: Optional[OrganizationList] = None + + @property + def organization(self) -> OrganizationList: + if self._organization is None: + self._organization = OrganizationList(self) + return self._organization + + def __repr__(self) -> str: + """ + Provide a friendly representation + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/preview_iam/versionless/organization/__init__.py b/twilio/rest/preview_iam/versionless/organization/__init__.py new file mode 100644 index 0000000000..ce6e70e978 --- /dev/null +++ b/twilio/rest/preview_iam/versionless/organization/__init__.py @@ -0,0 +1,128 @@ +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.instance_context import InstanceContext + +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + +from twilio.rest.preview_iam.versionless.organization.account import AccountList +from twilio.rest.preview_iam.versionless.organization.role_assignment import ( + RoleAssignmentList, +) +from twilio.rest.preview_iam.versionless.organization.user import UserList + + +class OrganizationContext(InstanceContext): + + def __init__(self, version: Version, organization_sid: str): + """ + Initialize the OrganizationContext + + :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}".format(**self._solution) + + self._accounts: Optional[AccountList] = None + self._role_assignments: Optional[RoleAssignmentList] = None + self._users: Optional[UserList] = None + + @property + def accounts(self) -> AccountList: + """ + Access the accounts + """ + if self._accounts is None: + self._accounts = AccountList( + self._version, + self._solution["organization_sid"], + ) + return self._accounts + + @property + def role_assignments(self) -> RoleAssignmentList: + """ + Access the role_assignments + """ + if self._role_assignments is None: + self._role_assignments = RoleAssignmentList( + self._version, + self._solution["organization_sid"], + ) + return self._role_assignments + + @property + def users(self) -> UserList: + """ + Access the users + """ + if self._users is None: + self._users = UserList( + self._version, + self._solution["organization_sid"], + ) + return self._users + + 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 OrganizationList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the OrganizationList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + def get(self, organization_sid: str) -> OrganizationContext: + """ + Constructs a OrganizationContext + + :param organization_sid: + """ + return OrganizationContext(self._version, organization_sid=organization_sid) + + def __call__(self, organization_sid: str) -> OrganizationContext: + """ + Constructs a OrganizationContext + + :param organization_sid: + """ + return OrganizationContext(self._version, organization_sid=organization_sid) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/preview_iam/versionless/organization/account.py b/twilio/rest/preview_iam/versionless/organization/account.py new file mode 100644 index 0000000000..f1c8019860 --- /dev/null +++ b/twilio/rest/preview_iam/versionless/organization/account.py @@ -0,0 +1,438 @@ +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: str, + 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, + "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 + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + 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 + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + 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, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return 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, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + return 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, account_sid: str) -> AccountContext: + """ + Constructs a AccountContext + + :param account_sid: + """ + return AccountContext( + self._version, + organization_sid=self._solution["organization_sid"], + account_sid=account_sid, + ) + + def __call__(self, account_sid: str) -> AccountContext: + """ + Constructs a AccountContext + + :param account_sid: + """ + return AccountContext( + self._version, + organization_sid=self._solution["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/versionless/organization/role_assignment.py b/twilio/rest/preview_iam/versionless/organization/role_assignment.py new file mode 100644 index 0000000000..9d356f2c7c --- /dev/null +++ b/twilio/rest/preview_iam/versionless/organization/role_assignment.py @@ -0,0 +1,574 @@ +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): + + 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, + } + + """ + :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: str, + 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, + "sid": sid or self.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"], + sid=self._solution["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): + + 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, sid: str): + """ + Initialize the RoleAssignmentContext + + :param version: Version that contains the resource + :param organization_sid: + :param sid: + """ + super().__init__(version) + + # Path Solution + self._solution = { + "organization_sid": organization_sid, + "sid": sid, + } + self._uri = "/{organization_sid}/RoleAssignments/{sid}".format(**self._solution) + + def delete(self) -> bool: + """ + Deletes the RoleAssignmentInstance + + + :returns: True if delete succeeds, False otherwise + """ + + headers = values.of({}) + + headers["Accept"] = "application/scim+json" + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the RoleAssignmentInstance + + + :returns: True if delete succeeds, False otherwise + """ + + headers = values.of({}) + + headers["Accept"] = "application/scim+json" + + return await self._version.delete_async( + method="DELETE", uri=self._uri, headers=headers + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format( + context + ) + + +class 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" + + headers["Accept"] = "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" + + headers["Accept"] = "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, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return 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, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + return 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, sid: str) -> RoleAssignmentContext: + """ + Constructs a RoleAssignmentContext + + :param sid: + """ + return RoleAssignmentContext( + self._version, organization_sid=self._solution["organization_sid"], sid=sid + ) + + def __call__(self, sid: str) -> RoleAssignmentContext: + """ + Constructs a RoleAssignmentContext + + :param sid: + """ + return RoleAssignmentContext( + self._version, organization_sid=self._solution["organization_sid"], sid=sid + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/preview_iam/versionless/organization/user.py b/twilio/rest/preview_iam/versionless/organization/user.py new file mode 100644 index 0000000000..166f76b421 --- /dev/null +++ b/twilio/rest/preview_iam/versionless/organization/user.py @@ -0,0 +1,1050 @@ +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 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 UserInstance(InstanceResource): + + class ScimEmailAddress(object): + """ + :ivar primary: Indicates if this email address is the primary one + :ivar value: The actual email address value + :ivar type: The type of email address (e.g., work, home, etc.) + """ + + def __init__(self, payload: Dict[str, Any]): + + self.primary: Optional[bool] = payload.get("primary") + self.value: Optional[str] = payload.get("value") + self.type: Optional[str] = payload.get("type") + + def to_dict(self): + return { + "primary": self.primary, + "value": self.value, + "type": self.type, + } + + class ScimMeta(object): + """ + :ivar resource_type: Indicates the type of the resource + :ivar created: The date and time when the resource was created in the system + :ivar last_modified: The date and time when the resource was last modified + :ivar version: A version identifier for the resource. This can be used to manage resource versioning and concurrency control. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.resource_type: Optional[str] = payload.get("resource_type") + self.created: Optional[datetime] = payload.get("created") + self.last_modified: Optional[datetime] = payload.get("last_modified") + self.version: Optional[str] = payload.get("version") + + def to_dict(self): + return { + "resource_type": self.resource_type, + "created": self.created, + "last_modified": self.last_modified, + "version": self.version, + } + + class ScimName(object): + """ + :ivar given_name: The user's first or given name + :ivar family_name: The user's last or family name + """ + + def __init__(self, payload: Dict[str, Any]): + + self.given_name: Optional[str] = payload.get("given_name") + self.family_name: Optional[str] = payload.get("family_name") + + def to_dict(self): + return { + "given_name": self.given_name, + "family_name": self.family_name, + } + + class ScimUser(object): + """ + :ivar id: Unique Twilio user sid + :ivar external_id: External unique resource id defined by provisioning client + :ivar user_name: Unique username, MUST be same as primary email address + :ivar display_name: User friendly display name + :ivar name: + :ivar emails: Email address list of the user. Primary email must be defined if there are more than 1 email. Primary email must match the username. + :ivar active: Indicates whether the user is active + :ivar locale: User's locale + :ivar timezone: User's time zone + :ivar schemas: An array of URIs that indicate the schemas supported for this user resource + :ivar meta: + :ivar detail: A human-readable description of the error + :ivar scim_type: A scimType error code as defined in RFC7644 + :ivar status: Http status code + :ivar code: Twilio-specific error code + :ivar more_info: Link to Error Code References + """ + + def __init__(self, payload: Dict[str, Any]): + + self.id: Optional[str] = payload.get("id") + self.external_id: Optional[str] = payload.get("external_id") + self.user_name: Optional[str] = payload.get("user_name") + self.display_name: Optional[str] = payload.get("display_name") + self.name: Optional[UserList.ScimName] = payload.get("name") + self.emails: Optional[List[UserList.ScimEmailAddress]] = payload.get( + "emails" + ) + self.active: Optional[bool] = payload.get("active") + self.locale: Optional[str] = payload.get("locale") + self.timezone: Optional[str] = payload.get("timezone") + self.schemas: Optional[List[str]] = payload.get("schemas") + self.meta: Optional[UserList.ScimMeta] = payload.get("meta") + self.detail: Optional[str] = payload.get("detail") + self.scim_type: Optional[str] = payload.get("scim_type") + self.status: Optional[str] = payload.get("status") + self.code: Optional[int] = payload.get("code") + self.more_info: Optional[str] = payload.get("more_info") + + def to_dict(self): + return { + "id": self.id, + "externalId": self.external_id, + "userName": self.user_name, + "displayName": self.display_name, + "name": self.name.to_dict() if self.name is not None else None, + "emails": ( + [emails.to_dict() for emails in self.emails] + if self.emails is not None + else None + ), + "active": self.active, + "locale": self.locale, + "timezone": self.timezone, + "schemas": self.schemas, + "meta": self.meta.to_dict() if self.meta is not None else None, + "detail": self.detail, + "scimType": self.scim_type, + "status": self.status, + "code": self.code, + "moreInfo": self.more_info, + } + + """ + :ivar id: Unique Twilio user sid + :ivar external_id: External unique resource id defined by provisioning client + :ivar user_name: Unique username, MUST be same as primary email address + :ivar display_name: User friendly display name + :ivar name: + :ivar emails: Email address list of the user. Primary email must be defined if there are more than 1 email. Primary email must match the username. + :ivar active: Indicates whether the user is active + :ivar locale: User's locale + :ivar timezone: User's time zone + :ivar schemas: An array of URIs that indicate the schemas supported for this user resource + :ivar meta: + :ivar detail: A human-readable description of the error + :ivar scim_type: A scimType error code as defined in RFC7644 + :ivar status: Http status code + :ivar code: Twilio-specific error code + :ivar more_info: Link to Error Code References + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + organization_sid: str, + id: Optional[str] = None, + ): + super().__init__(version) + + self.id: Optional[str] = payload.get("id") + self.external_id: Optional[str] = payload.get("externalId") + self.user_name: Optional[str] = payload.get("userName") + self.display_name: Optional[str] = payload.get("displayName") + self.name: Optional[UserList.str] = payload.get("name") + self.emails: Optional[List[UserList.str]] = payload.get("emails") + self.active: Optional[bool] = payload.get("active") + self.locale: Optional[str] = payload.get("locale") + self.timezone: Optional[str] = payload.get("timezone") + self.schemas: Optional[List[str]] = payload.get("schemas") + self.meta: Optional[UserList.str] = payload.get("meta") + self.detail: Optional[str] = payload.get("detail") + self.scim_type: Optional[str] = payload.get("scimType") + self.status: Optional[str] = payload.get("status") + self.code: Optional[int] = payload.get("code") + self.more_info: Optional[str] = payload.get("moreInfo") + + self._solution = { + "organization_sid": organization_sid, + "id": id or self.id, + } + self._context: Optional[UserContext] = None + + @property + def _proxy(self) -> "UserContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: UserContext for this UserInstance + """ + if self._context is None: + self._context = UserContext( + self._version, + organization_sid=self._solution["organization_sid"], + id=self._solution["id"], + ) + return self._context + + def delete(self) -> bool: + """ + Deletes the UserInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._proxy.delete() + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the UserInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._proxy.delete_async() + + def fetch(self) -> "UserInstance": + """ + Fetch the UserInstance + + + :returns: The fetched UserInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "UserInstance": + """ + Asynchronous coroutine to fetch the UserInstance + + + :returns: The fetched UserInstance + """ + return await self._proxy.fetch_async() + + def update( + self, scim_user: ScimUser, if_match: Union[str, object] = values.unset + ) -> "UserInstance": + """ + Update the UserInstance + + :param scim_user: + :param if_match: + + :returns: The updated UserInstance + """ + return self._proxy.update( + scim_user=scim_user, + if_match=if_match, + ) + + async def update_async( + self, scim_user: ScimUser, if_match: Union[str, object] = values.unset + ) -> "UserInstance": + """ + Asynchronous coroutine to update the UserInstance + + :param scim_user: + :param if_match: + + :returns: The updated UserInstance + """ + return await self._proxy.update_async( + scim_user=scim_user, + if_match=if_match, + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class UserContext(InstanceContext): + + class ScimEmailAddress(object): + """ + :ivar primary: Indicates if this email address is the primary one + :ivar value: The actual email address value + :ivar type: The type of email address (e.g., work, home, etc.) + """ + + def __init__(self, payload: Dict[str, Any]): + + self.primary: Optional[bool] = payload.get("primary") + self.value: Optional[str] = payload.get("value") + self.type: Optional[str] = payload.get("type") + + def to_dict(self): + return { + "primary": self.primary, + "value": self.value, + "type": self.type, + } + + class ScimMeta(object): + """ + :ivar resource_type: Indicates the type of the resource + :ivar created: The date and time when the resource was created in the system + :ivar last_modified: The date and time when the resource was last modified + :ivar version: A version identifier for the resource. This can be used to manage resource versioning and concurrency control. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.resource_type: Optional[str] = payload.get("resource_type") + self.created: Optional[datetime] = payload.get("created") + self.last_modified: Optional[datetime] = payload.get("last_modified") + self.version: Optional[str] = payload.get("version") + + def to_dict(self): + return { + "resource_type": self.resource_type, + "created": self.created, + "last_modified": self.last_modified, + "version": self.version, + } + + class ScimName(object): + """ + :ivar given_name: The user's first or given name + :ivar family_name: The user's last or family name + """ + + def __init__(self, payload: Dict[str, Any]): + + self.given_name: Optional[str] = payload.get("given_name") + self.family_name: Optional[str] = payload.get("family_name") + + def to_dict(self): + return { + "given_name": self.given_name, + "family_name": self.family_name, + } + + class ScimUser(object): + """ + :ivar id: Unique Twilio user sid + :ivar external_id: External unique resource id defined by provisioning client + :ivar user_name: Unique username, MUST be same as primary email address + :ivar display_name: User friendly display name + :ivar name: + :ivar emails: Email address list of the user. Primary email must be defined if there are more than 1 email. Primary email must match the username. + :ivar active: Indicates whether the user is active + :ivar locale: User's locale + :ivar timezone: User's time zone + :ivar schemas: An array of URIs that indicate the schemas supported for this user resource + :ivar meta: + :ivar detail: A human-readable description of the error + :ivar scim_type: A scimType error code as defined in RFC7644 + :ivar status: Http status code + :ivar code: Twilio-specific error code + :ivar more_info: Link to Error Code References + """ + + def __init__(self, payload: Dict[str, Any]): + + self.id: Optional[str] = payload.get("id") + self.external_id: Optional[str] = payload.get("external_id") + self.user_name: Optional[str] = payload.get("user_name") + self.display_name: Optional[str] = payload.get("display_name") + self.name: Optional[UserList.ScimName] = payload.get("name") + self.emails: Optional[List[UserList.ScimEmailAddress]] = payload.get( + "emails" + ) + self.active: Optional[bool] = payload.get("active") + self.locale: Optional[str] = payload.get("locale") + self.timezone: Optional[str] = payload.get("timezone") + self.schemas: Optional[List[str]] = payload.get("schemas") + self.meta: Optional[UserList.ScimMeta] = payload.get("meta") + self.detail: Optional[str] = payload.get("detail") + self.scim_type: Optional[str] = payload.get("scim_type") + self.status: Optional[str] = payload.get("status") + self.code: Optional[int] = payload.get("code") + self.more_info: Optional[str] = payload.get("more_info") + + def to_dict(self): + return { + "id": self.id, + "externalId": self.external_id, + "userName": self.user_name, + "displayName": self.display_name, + "name": self.name.to_dict() if self.name is not None else None, + "emails": ( + [emails.to_dict() for emails in self.emails] + if self.emails is not None + else None + ), + "active": self.active, + "locale": self.locale, + "timezone": self.timezone, + "schemas": self.schemas, + "meta": self.meta.to_dict() if self.meta is not None else None, + "detail": self.detail, + "scimType": self.scim_type, + "status": self.status, + "code": self.code, + "moreInfo": self.more_info, + } + + def __init__(self, version: Version, organization_sid: str, id: str): + """ + Initialize the UserContext + + :param version: Version that contains the resource + :param organization_sid: + :param id: + """ + super().__init__(version) + + # Path Solution + self._solution = { + "organization_sid": organization_sid, + "id": id, + } + self._uri = "/{organization_sid}/scim/Users/{id}".format(**self._solution) + + def delete(self) -> bool: + """ + Deletes the UserInstance + + + :returns: True if delete succeeds, False otherwise + """ + + headers = values.of({}) + + headers["Accept"] = "application/scim+json" + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the UserInstance + + + :returns: True if delete succeeds, False otherwise + """ + + headers = values.of({}) + + headers["Accept"] = "application/scim+json" + + return await self._version.delete_async( + method="DELETE", uri=self._uri, headers=headers + ) + + def fetch(self) -> UserInstance: + """ + Fetch the UserInstance + + + :returns: The fetched UserInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/scim+json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return UserInstance( + self._version, + payload, + organization_sid=self._solution["organization_sid"], + id=self._solution["id"], + ) + + async def fetch_async(self) -> UserInstance: + """ + Asynchronous coroutine to fetch the UserInstance + + + :returns: The fetched UserInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/scim+json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + return UserInstance( + self._version, + payload, + organization_sid=self._solution["organization_sid"], + id=self._solution["id"], + ) + + def update( + self, scim_user: ScimUser, if_match: Union[str, object] = values.unset + ) -> UserInstance: + """ + Update the UserInstance + + :param scim_user: + :param if_match: + + :returns: The updated UserInstance + """ + data = scim_user.to_dict() + + headers = values.of({}) + + if not ( + if_match is values.unset or (isinstance(if_match, str) and not if_match) + ): + headers["If-Match"] = if_match + + headers["Content-Type"] = "application/json" + + headers["Content-Type"] = "application/scim+json" + + headers["Accept"] = "application/scim+json" + + payload = self._version.update( + method="PUT", uri=self._uri, data=data, headers=headers + ) + + return UserInstance( + self._version, + payload, + organization_sid=self._solution["organization_sid"], + id=self._solution["id"], + ) + + async def update_async( + self, scim_user: ScimUser, if_match: Union[str, object] = values.unset + ) -> UserInstance: + """ + Asynchronous coroutine to update the UserInstance + + :param scim_user: + :param if_match: + + :returns: The updated UserInstance + """ + data = scim_user.to_dict() + + headers = values.of({}) + + if not ( + if_match is values.unset or (isinstance(if_match, str) and not if_match) + ): + headers["If-Match"] = if_match + + headers["Content-Type"] = "application/json" + + headers["Content-Type"] = "application/scim+json" + + headers["Accept"] = "application/scim+json" + + payload = await self._version.update_async( + method="PUT", uri=self._uri, data=data, headers=headers + ) + + return UserInstance( + self._version, + payload, + organization_sid=self._solution["organization_sid"], + 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 UserPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> UserInstance: + """ + Build an instance of UserInstance + + :param payload: Payload response from the API + """ + return UserInstance( + self._version, payload, organization_sid=self._solution["organization_sid"] + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class UserList(ListResource): + + class ScimEmailAddress(object): + """ + :ivar primary: Indicates if this email address is the primary one + :ivar value: The actual email address value + :ivar type: The type of email address (e.g., work, home, etc.) + """ + + def __init__(self, payload: Dict[str, Any]): + + self.primary: Optional[bool] = payload.get("primary") + self.value: Optional[str] = payload.get("value") + self.type: Optional[str] = payload.get("type") + + def to_dict(self): + return { + "primary": self.primary, + "value": self.value, + "type": self.type, + } + + class ScimMeta(object): + """ + :ivar resource_type: Indicates the type of the resource + :ivar created: The date and time when the resource was created in the system + :ivar last_modified: The date and time when the resource was last modified + :ivar version: A version identifier for the resource. This can be used to manage resource versioning and concurrency control. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.resource_type: Optional[str] = payload.get("resource_type") + self.created: Optional[datetime] = payload.get("created") + self.last_modified: Optional[datetime] = payload.get("last_modified") + self.version: Optional[str] = payload.get("version") + + def to_dict(self): + return { + "resource_type": self.resource_type, + "created": self.created, + "last_modified": self.last_modified, + "version": self.version, + } + + class ScimName(object): + """ + :ivar given_name: The user's first or given name + :ivar family_name: The user's last or family name + """ + + def __init__(self, payload: Dict[str, Any]): + + self.given_name: Optional[str] = payload.get("given_name") + self.family_name: Optional[str] = payload.get("family_name") + + def to_dict(self): + return { + "given_name": self.given_name, + "family_name": self.family_name, + } + + class ScimUser(object): + """ + :ivar id: Unique Twilio user sid + :ivar external_id: External unique resource id defined by provisioning client + :ivar user_name: Unique username, MUST be same as primary email address + :ivar display_name: User friendly display name + :ivar name: + :ivar emails: Email address list of the user. Primary email must be defined if there are more than 1 email. Primary email must match the username. + :ivar active: Indicates whether the user is active + :ivar locale: User's locale + :ivar timezone: User's time zone + :ivar schemas: An array of URIs that indicate the schemas supported for this user resource + :ivar meta: + :ivar detail: A human-readable description of the error + :ivar scim_type: A scimType error code as defined in RFC7644 + :ivar status: Http status code + :ivar code: Twilio-specific error code + :ivar more_info: Link to Error Code References + """ + + def __init__(self, payload: Dict[str, Any]): + + self.id: Optional[str] = payload.get("id") + self.external_id: Optional[str] = payload.get("external_id") + self.user_name: Optional[str] = payload.get("user_name") + self.display_name: Optional[str] = payload.get("display_name") + self.name: Optional[UserList.ScimName] = payload.get("name") + self.emails: Optional[List[UserList.ScimEmailAddress]] = payload.get( + "emails" + ) + self.active: Optional[bool] = payload.get("active") + self.locale: Optional[str] = payload.get("locale") + self.timezone: Optional[str] = payload.get("timezone") + self.schemas: Optional[List[str]] = payload.get("schemas") + self.meta: Optional[UserList.ScimMeta] = payload.get("meta") + self.detail: Optional[str] = payload.get("detail") + self.scim_type: Optional[str] = payload.get("scim_type") + self.status: Optional[str] = payload.get("status") + self.code: Optional[int] = payload.get("code") + self.more_info: Optional[str] = payload.get("more_info") + + def to_dict(self): + return { + "id": self.id, + "externalId": self.external_id, + "userName": self.user_name, + "displayName": self.display_name, + "name": self.name.to_dict() if self.name is not None else None, + "emails": ( + [emails.to_dict() for emails in self.emails] + if self.emails is not None + else None + ), + "active": self.active, + "locale": self.locale, + "timezone": self.timezone, + "schemas": self.schemas, + "meta": self.meta.to_dict() if self.meta is not None else None, + "detail": self.detail, + "scimType": self.scim_type, + "status": self.status, + "code": self.code, + "moreInfo": self.more_info, + } + + def __init__(self, version: Version, organization_sid: str): + """ + Initialize the UserList + + :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}/scim/Users".format(**self._solution) + + def create(self, scim_user: ScimUser) -> UserInstance: + """ + Create the UserInstance + + :param scim_user: + + :returns: The created UserInstance + """ + data = scim_user.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Content-Type"] = "application/scim+json" + + headers["Accept"] = "application/scim+json" + + payload = self._version.create( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return UserInstance( + self._version, payload, organization_sid=self._solution["organization_sid"] + ) + + async def create_async(self, scim_user: ScimUser) -> UserInstance: + """ + Asynchronously create the UserInstance + + :param scim_user: + + :returns: The created UserInstance + """ + data = scim_user.to_dict() + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Content-Type"] = "application/scim+json" + + headers["Accept"] = "application/scim+json" + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return UserInstance( + self._version, payload, organization_sid=self._solution["organization_sid"] + ) + + def stream( + self, + filter: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[UserInstance]: + """ + Streams UserInstance 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 filter: + :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(filter=filter, page_size=limits["page_size"]) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + filter: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[UserInstance]: + """ + Asynchronously streams UserInstance 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 filter: + :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(filter=filter, page_size=limits["page_size"]) + + return self._version.stream_async(page, limits["limit"]) + + def list( + self, + filter: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[UserInstance]: + """ + Lists UserInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str filter: + :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( + filter=filter, + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + filter: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[UserInstance]: + """ + Asynchronously lists UserInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str filter: + :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( + filter=filter, + limit=limit, + page_size=page_size, + ) + ] + + def page( + self, + filter: 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, + ) -> UserPage: + """ + Retrieve a single page of UserInstance records from the API. + Request is executed immediately + + :param filter: + :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 UserInstance + """ + data = values.of( + { + "filter": filter, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/scim+json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return UserPage(self._version, response, self._solution) + + async def page_async( + self, + filter: 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, + ) -> UserPage: + """ + Asynchronously retrieve a single page of UserInstance records from the API. + Request is executed immediately + + :param filter: + :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 UserInstance + """ + data = values.of( + { + "filter": filter, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/scim+json" + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + return UserPage(self._version, response, self._solution) + + def get_page(self, target_url: str) -> UserPage: + """ + Retrieve a specific page of UserInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of UserInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return UserPage(self._version, response, self._solution) + + async def get_page_async(self, target_url: str) -> UserPage: + """ + Asynchronously retrieve a specific page of UserInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of UserInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return UserPage(self._version, response, self._solution) + + def get(self, id: str) -> UserContext: + """ + Constructs a UserContext + + :param id: + """ + return UserContext( + self._version, organization_sid=self._solution["organization_sid"], id=id + ) + + def __call__(self, id: str) -> UserContext: + """ + Constructs a UserContext + + :param id: + """ + return UserContext( + self._version, organization_sid=self._solution["organization_sid"], id=id + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/preview_messaging/__init__.py b/twilio/rest/preview_messaging/__init__.py deleted file mode 100644 index 73bf67969d..0000000000 --- a/twilio/rest/preview_messaging/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -from twilio.rest.preview_messaging.PreviewMessagingBase import PreviewMessagingBase -from twilio.rest.preview_messaging.v1.broadcast import BroadcastList -from twilio.rest.preview_messaging.v1.message import MessageList - - -class PreviewMessaging(PreviewMessagingBase): - @property - def broadcast(self) -> BroadcastList: - return self.v1.broadcasts - - @property - def messages(self) -> MessageList: - return self.v1.messages diff --git a/twilio/rest/preview_messaging/v1/__init__.py b/twilio/rest/preview_messaging/v1/__init__.py deleted file mode 100644 index 424af648e8..0000000000 --- a/twilio/rest/preview_messaging/v1/__init__.py +++ /dev/null @@ -1,51 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Bulk Messaging and Broadcast - Bulk Sending is a public Twilio REST API for 1:Many Message creation up to 100 recipients. Broadcast is a public Twilio REST API for 1:Many Message creation up to 10,000 recipients via file upload. - - 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_messaging.v1.broadcast import BroadcastList -from twilio.rest.preview_messaging.v1.message import MessageList - - -class V1(Version): - - def __init__(self, domain: Domain): - """ - Initialize the V1 version of PreviewMessaging - - :param domain: The Twilio.preview_messaging domain - """ - super().__init__(domain, "v1") - self._broadcasts: Optional[BroadcastList] = None - self._messages: Optional[MessageList] = None - - @property - def broadcasts(self) -> BroadcastList: - if self._broadcasts is None: - self._broadcasts = BroadcastList(self) - return self._broadcasts - - @property - def messages(self) -> MessageList: - if self._messages is None: - self._messages = MessageList(self) - return self._messages - - def __repr__(self) -> str: - """ - Provide a friendly representation - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview_messaging/v1/broadcast.py b/twilio/rest/preview_messaging/v1/broadcast.py deleted file mode 100644 index e41e066bad..0000000000 --- a/twilio/rest/preview_messaging/v1/broadcast.py +++ /dev/null @@ -1,125 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Bulk Messaging and Broadcast - Bulk Sending is a public Twilio REST API for 1:Many Message creation up to 100 recipients. Broadcast is a public Twilio REST API for 1:Many Message creation up to 10,000 recipients via file upload. - - NOTE: This class is auto generated by OpenAPI Generator. - https://openapi-generator.tech - Do not edit the class manually. -""" - -from datetime import datetime -from typing import Any, Dict, Optional, Union -from twilio.base import deserialize, values - -from twilio.base.instance_resource import InstanceResource -from twilio.base.list_resource import ListResource -from twilio.base.version import Version - - -class BroadcastInstance(InstanceResource): - """ - :ivar broadcast_sid: Numeric ID indentifying individual Broadcast requests - :ivar created_date: Timestamp of when the Broadcast was created - :ivar updated_date: Timestamp of when the Broadcast was last updated - :ivar broadcast_status: Status of the Broadcast request. Valid values are None, Pending-Upload, Uploaded, Queued, Executing, Execution-Failure, Execution-Completed, Cancelation-Requested, and Canceled - :ivar execution_details: - :ivar results_file: Path to a file detailing successful requests and errors from Broadcast execution - """ - - def __init__(self, version: Version, payload: Dict[str, Any]): - super().__init__(version) - - self.broadcast_sid: Optional[str] = payload.get("broadcast_sid") - self.created_date: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("created_date") - ) - self.updated_date: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("updated_date") - ) - self.broadcast_status: Optional[str] = payload.get("broadcast_status") - self.execution_details: Optional[str] = payload.get("execution_details") - self.results_file: Optional[str] = payload.get("results_file") - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - - return "" - - -class BroadcastList(ListResource): - - def __init__(self, version: Version): - """ - Initialize the BroadcastList - - :param version: Version that contains the resource - - """ - super().__init__(version) - - self._uri = "/Broadcasts" - - def create( - self, x_twilio_request_key: Union[str, object] = values.unset - ) -> BroadcastInstance: - """ - Create the BroadcastInstance - - :param x_twilio_request_key: Idempotency key provided by the client - - :returns: The created BroadcastInstance - """ - - data = values.of({}) - headers = values.of( - { - "X-Twilio-Request-Key": x_twilio_request_key, - } - ) - - payload = self._version.create( - method="POST", uri=self._uri, data=data, headers=headers - ) - - return BroadcastInstance(self._version, payload) - - async def create_async( - self, x_twilio_request_key: Union[str, object] = values.unset - ) -> BroadcastInstance: - """ - Asynchronously create the BroadcastInstance - - :param x_twilio_request_key: Idempotency key provided by the client - - :returns: The created BroadcastInstance - """ - - data = values.of({}) - headers = values.of( - { - "X-Twilio-Request-Key": x_twilio_request_key, - } - ) - - payload = await self._version.create_async( - method="POST", uri=self._uri, data=data, headers=headers - ) - - return BroadcastInstance(self._version, payload) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview_messaging/v1/message.py b/twilio/rest/preview_messaging/v1/message.py deleted file mode 100644 index c6212c7f4f..0000000000 --- a/twilio/rest/preview_messaging/v1/message.py +++ /dev/null @@ -1,203 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Bulk Messaging and Broadcast - Bulk Sending is a public Twilio REST API for 1:Many Message creation up to 100 recipients. Broadcast is a public Twilio REST API for 1:Many Message creation up to 10,000 recipients via file upload. - - 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 deserialize - -from twilio.base.instance_resource import InstanceResource -from twilio.base.list_resource import ListResource -from twilio.base.version import Version - - -class MessageInstance(InstanceResource): - """ - :ivar total_message_count: The number of Messages processed in the request, equal to the sum of success_count and error_count. - :ivar success_count: The number of Messages successfully created. - :ivar error_count: The number of Messages unsuccessfully processed in the request. - :ivar message_receipts: - :ivar failed_message_receipts: - """ - - def __init__(self, version: Version, payload: Dict[str, Any]): - super().__init__(version) - - self.total_message_count: Optional[int] = deserialize.integer( - payload.get("total_message_count") - ) - self.success_count: Optional[int] = deserialize.integer( - payload.get("success_count") - ) - self.error_count: Optional[int] = deserialize.integer( - payload.get("error_count") - ) - self.message_receipts: Optional[List[str]] = payload.get("message_receipts") - self.failed_message_receipts: Optional[List[str]] = payload.get( - "failed_message_receipts" - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - - return "" - - -class MessageList(ListResource): - - class CreateMessagesRequest(object): - """ - :ivar messages: - :ivar from_: A Twilio phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, an [alphanumeric sender ID](https://www.twilio.com/docs/sms/send-messages#use-an-alphanumeric-sender-id), or a [Channel Endpoint address](https://www.twilio.com/docs/sms/channels#channel-addresses) that is enabled for the type of message you want to send. Phone numbers or [short codes](https://www.twilio.com/docs/sms/api/short-code) purchased from Twilio also work here. You cannot, for example, spoof messages from a private cell phone number. If you are using `messaging_service_sid`, this parameter must be empty. - :ivar messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/sms/services#send-a-message-with-copilot) you want to associate with the Message. Set this parameter to use the [Messaging Service Settings and Copilot Features](https://www.twilio.com/console/sms/services) you have configured and leave the `from` parameter empty. When only this parameter is set, Twilio will use your enabled Copilot Features to select the `from` phone number for delivery. - :ivar body: The text of the message you want to send. Can be up to 1,600 characters in length. - :ivar content_sid: The SID of the preconfigured [Content Template](https://www.twilio.com/docs/content-api/create-and-send-your-first-content-api-template#create-a-template) you want to associate with the Message. Must be used in conjuction with a preconfigured [Messaging Service Settings and Copilot Features](https://www.twilio.com/console/sms/services) When this parameter is set, Twilio will use your configured content template and the provided `ContentVariables`. This Twilio product is currently in Private Beta. - :ivar media_url: The URL of the media to send with the message. The media can be of type `gif`, `png`, and `jpeg` and will be formatted correctly on the recipient's device. The media size limit is 5MB for supported file types (JPEG, PNG, GIF) and 500KB for [other types](https://www.twilio.com/docs/sms/accepted-mime-types) of accepted media. To send more than one image in the message body, provide multiple `media_url` parameters in the POST request. You can include up to 10 `media_url` parameters per message. You can send images in an SMS message in only the US and Canada. - :ivar status_callback: The URL we should call using the \"status_callback_method\" to send status information to your application. If specified, we POST these message status changes to the URL - queued, failed, sent, delivered, or undelivered. Twilio will POST its [standard request parameters](https://www.twilio.com/docs/messaging/twiml#request-parameters) as well as some additional parameters including \"MessageSid\", \"MessageStatus\", and \"ErrorCode\". If you include this parameter with the \"messaging_service_sid\", we use this URL instead of the Status Callback URL of the [Messaging Service](https://www.twilio.com/docs/messaging/services/api). URLs must contain a valid hostname and underscores are not allowed. - :ivar validity_period: How long in seconds the message can remain in our outgoing message queue. After this period elapses, the message fails and we call your status callback. Can be between 1 and the default value of 14,400 seconds. After a message has been accepted by a carrier, however, we cannot guarantee that the message will not be queued after this period. We recommend that this value be at least 5 seconds. - :ivar send_at: The time at which Twilio will send the message. This parameter can be used to schedule a message to be sent at a particular time. Must be in ISO 8601 format. - :ivar schedule_type: This parameter indicates your intent to schedule a message. Pass the value `fixed` to schedule a message at a fixed time. This parameter works in conjuction with the `SendAt` parameter. - :ivar shorten_urls: Determines the usage of Click Tracking. Setting it to `true` will instruct Twilio to replace all links in the Message with a shortened version based on the associated Domain Sid and track clicks on them. If this parameter is not set on an API call, we will use the value set on the Messaging Service. If this parameter is not set and the value is not configured on the Messaging Service used this will default to `false`. - :ivar send_as_mms: If set to True, Twilio will deliver the message as a single MMS message, regardless of the presence of media. - :ivar max_price: The maximum total price in US dollars that you will pay for the message to be delivered. Can be a decimal value that has up to 4 decimal places. All messages are queued for delivery and the message cost is checked before the message is sent. If the cost exceeds max_price, the message will fail and a status of Failed is sent to the status callback. If MaxPrice is not set, the message cost is not checked. - :ivar attempt: Total number of attempts made ( including this ) to send out the message regardless of the provider used - :ivar smart_encoded: This parameter indicates whether to detect Unicode characters that have a similar GSM-7 character and replace them. Can be true or false. - :ivar force_delivery: This parameter allows Twilio to send SMS traffic to carriers without checking/caring whether the destination number is a mobile or a landline. - :ivar application_sid: The SID of the application that should receive message status. We POST a message_sid parameter and a message_status parameter with a value of sent or failed to the application's message_status_callback. If a status_callback parameter is also passed, it will be ignored and the application's message_status_callback parameter will be used. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.messages: Optional[List[MessageList.MessagingV1Message]] = payload.get( - "messages" - ) - self.from_: Optional[str] = payload.get("from_") - self.messaging_service_sid: Optional[str] = payload.get( - "messaging_service_sid" - ) - self.body: Optional[str] = payload.get("body") - self.content_sid: Optional[str] = payload.get("content_sid") - self.media_url: Optional[List[str]] = payload.get("media_url") - self.status_callback: Optional[str] = payload.get("status_callback") - self.validity_period: Optional[int] = payload.get("validity_period") - self.send_at: Optional[str] = payload.get("send_at") - self.schedule_type: Optional[str] = payload.get("schedule_type") - self.shorten_urls: Optional[bool] = payload.get("shorten_urls") - self.send_as_mms: Optional[bool] = payload.get("send_as_mms") - self.max_price: Optional[float] = payload.get("max_price") - self.attempt: Optional[int] = payload.get("attempt") - self.smart_encoded: Optional[bool] = payload.get("smart_encoded") - self.force_delivery: Optional[bool] = payload.get("force_delivery") - self.application_sid: Optional[str] = payload.get("application_sid") - - def to_dict(self): - return { - "messages": [messages.to_dict() for messages in self.messages], - "from": self.from_, - "messaging_service_sid": self.messaging_service_sid, - "body": self.body, - "content_sid": self.content_sid, - "media_url": self.media_url, - "status_callback": self.status_callback, - "validity_period": self.validity_period, - "send_at": self.send_at, - "schedule_type": self.schedule_type, - "shorten_urls": self.shorten_urls, - "send_as_mms": self.send_as_mms, - "max_price": self.max_price, - "attempt": self.attempt, - "smart_encoded": self.smart_encoded, - "force_delivery": self.force_delivery, - "application_sid": self.application_sid, - } - - class MessagingV1Message(object): - """ - :ivar to: The destination phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format for SMS/MMS or [Channel user address](https://www.twilio.com/docs/sms/channels#channel-addresses) for other 3rd-party channels. - :ivar body: The text of the message you want to send. Can be up to 1,600 characters in length. Overrides the request-level body and content template if provided. - :ivar content_variables: Key-value pairs of variable names to substitution values. Refer to the [Twilio Content API Resources](https://www.twilio.com/docs/content-api/content-api-resources#send-a-message-with-preconfigured-content) for more details. - """ - - def __init__(self, payload: Dict[str, Any]): - - self.to: Optional[str] = payload.get("to") - self.body: Optional[str] = payload.get("body") - self.content_variables: Optional[dict[str, str]] = payload.get( - "content_variables" - ) - - def to_dict(self): - return { - "to": self.to, - "body": self.body, - "content_variables": self.content_variables, - } - - def __init__(self, version: Version): - """ - Initialize the MessageList - - :param version: Version that contains the resource - - """ - super().__init__(version) - - self._uri = "/Messages" - - def create(self, create_messages_request: CreateMessagesRequest) -> MessageInstance: - """ - Create the MessageInstance - - :param create_messages_request: - - :returns: The created MessageInstance - """ - data = create_messages_request.to_dict() - - headers = {"Content-Type": "application/json"} - payload = self._version.create( - method="POST", uri=self._uri, data=data, headers=headers - ) - - return MessageInstance(self._version, payload) - - async def create_async( - self, create_messages_request: CreateMessagesRequest - ) -> MessageInstance: - """ - Asynchronously create the MessageInstance - - :param create_messages_request: - - :returns: The created MessageInstance - """ - - data = create_messages_request.to_dict() - 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) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/pricing/v1/messaging/country.py b/twilio/rest/pricing/v1/messaging/country.py index 47f5707ce8..49360cd85c 100644 --- a/twilio/rest/pricing/v1/messaging/country.py +++ b/twilio/rest/pricing/v1/messaging/country.py @@ -121,10 +121,11 @@ def fetch(self) -> CountryInstance: :returns: The fetched CountryInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return CountryInstance( self._version, @@ -140,9 +141,12 @@ async def fetch_async(self) -> CountryInstance: :returns: The fetched CountryInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return CountryInstance( @@ -320,7 +324,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return CountryPage(self._version, response) async def page_async( @@ -347,8 +357,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return CountryPage(self._version, response) diff --git a/twilio/rest/pricing/v1/phone_number/country.py b/twilio/rest/pricing/v1/phone_number/country.py index b0822fff23..2d11cd1c3e 100644 --- a/twilio/rest/pricing/v1/phone_number/country.py +++ b/twilio/rest/pricing/v1/phone_number/country.py @@ -119,10 +119,11 @@ def fetch(self) -> CountryInstance: :returns: The fetched CountryInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return CountryInstance( self._version, @@ -138,9 +139,12 @@ async def fetch_async(self) -> CountryInstance: :returns: The fetched CountryInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return CountryInstance( @@ -318,7 +322,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return CountryPage(self._version, response) async def page_async( @@ -345,8 +355,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return CountryPage(self._version, response) diff --git a/twilio/rest/pricing/v1/voice/country.py b/twilio/rest/pricing/v1/voice/country.py index e3b1496de4..7fb0da883a 100644 --- a/twilio/rest/pricing/v1/voice/country.py +++ b/twilio/rest/pricing/v1/voice/country.py @@ -123,10 +123,11 @@ def fetch(self) -> CountryInstance: :returns: The fetched CountryInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return CountryInstance( self._version, @@ -142,9 +143,12 @@ async def fetch_async(self) -> CountryInstance: :returns: The fetched CountryInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return CountryInstance( @@ -322,7 +326,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return CountryPage(self._version, response) async def page_async( @@ -349,8 +359,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return CountryPage(self._version, response) diff --git a/twilio/rest/pricing/v1/voice/number.py b/twilio/rest/pricing/v1/voice/number.py index 910919707e..5bff8cd5d6 100644 --- a/twilio/rest/pricing/v1/voice/number.py +++ b/twilio/rest/pricing/v1/voice/number.py @@ -13,6 +13,7 @@ """ 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 @@ -116,10 +117,11 @@ def fetch(self) -> NumberInstance: :returns: The fetched NumberInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return NumberInstance( self._version, @@ -135,9 +137,12 @@ async def fetch_async(self) -> NumberInstance: :returns: The fetched NumberInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return NumberInstance( diff --git a/twilio/rest/pricing/v2/country.py b/twilio/rest/pricing/v2/country.py index a058c071b5..30672235a8 100644 --- a/twilio/rest/pricing/v2/country.py +++ b/twilio/rest/pricing/v2/country.py @@ -123,10 +123,11 @@ def fetch(self) -> CountryInstance: :returns: The fetched CountryInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return CountryInstance( self._version, @@ -142,9 +143,12 @@ async def fetch_async(self) -> CountryInstance: :returns: The fetched CountryInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return CountryInstance( @@ -322,7 +326,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return CountryPage(self._version, response) async def page_async( @@ -349,8 +359,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return CountryPage(self._version, response) diff --git a/twilio/rest/pricing/v2/number.py b/twilio/rest/pricing/v2/number.py index 6c4cd9fe9d..1dead39347 100644 --- a/twilio/rest/pricing/v2/number.py +++ b/twilio/rest/pricing/v2/number.py @@ -145,7 +145,13 @@ def fetch( } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=data) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) return NumberInstance( self._version, @@ -170,8 +176,12 @@ async def fetch_async( } ) + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return NumberInstance( diff --git a/twilio/rest/pricing/v2/voice/country.py b/twilio/rest/pricing/v2/voice/country.py index 4a84bbd734..997f368462 100644 --- a/twilio/rest/pricing/v2/voice/country.py +++ b/twilio/rest/pricing/v2/voice/country.py @@ -123,10 +123,11 @@ def fetch(self) -> CountryInstance: :returns: The fetched CountryInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return CountryInstance( self._version, @@ -142,9 +143,12 @@ async def fetch_async(self) -> CountryInstance: :returns: The fetched CountryInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return CountryInstance( @@ -322,7 +326,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return CountryPage(self._version, response) async def page_async( @@ -349,8 +359,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return CountryPage(self._version, response) diff --git a/twilio/rest/pricing/v2/voice/number.py b/twilio/rest/pricing/v2/voice/number.py index 6dd8764821..97a3a526ff 100644 --- a/twilio/rest/pricing/v2/voice/number.py +++ b/twilio/rest/pricing/v2/voice/number.py @@ -143,7 +143,13 @@ def fetch( } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=data) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) return NumberInstance( self._version, @@ -168,8 +174,12 @@ async def fetch_async( } ) + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return NumberInstance( diff --git a/twilio/rest/proxy/v1/service/__init__.py b/twilio/rest/proxy/v1/service/__init__.py index 6be2def24c..ff1e7ed7d7 100644 --- a/twilio/rest/proxy/v1/service/__init__.py +++ b/twilio/rest/proxy/v1/service/__init__.py @@ -279,10 +279,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -291,9 +291,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> ServiceInstance: @@ -304,10 +306,11 @@ def fetch(self) -> ServiceInstance: :returns: The fetched ServiceInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ServiceInstance( self._version, @@ -323,9 +326,12 @@ async def fetch_async(self) -> ServiceInstance: :returns: The fetched ServiceInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ServiceInstance( @@ -361,6 +367,7 @@ def update( :returns: The updated ServiceInstance """ + data = values.of( { "UniqueName": unique_name, @@ -373,11 +380,14 @@ def update( "ChatInstanceSid": chat_instance_sid, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload, sid=self._solution["sid"]) @@ -409,6 +419,7 @@ async def update_async( :returns: The updated ServiceInstance """ + data = values.of( { "UniqueName": unique_name, @@ -421,11 +432,14 @@ async def update_async( "ChatInstanceSid": chat_instance_sid, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload, sid=self._solution["sid"]) @@ -548,11 +562,14 @@ def create( "ChatInstanceSid": chat_instance_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload) @@ -597,11 +614,14 @@ async def create_async( "ChatInstanceSid": chat_instance_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload) @@ -733,7 +753,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ServicePage(self._version, response) async def page_async( @@ -760,8 +786,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ServicePage(self._version, response) diff --git a/twilio/rest/proxy/v1/service/phone_number.py b/twilio/rest/proxy/v1/service/phone_number.py index 366b9ba11f..3c8517cedd 100644 --- a/twilio/rest/proxy/v1/service/phone_number.py +++ b/twilio/rest/proxy/v1/service/phone_number.py @@ -188,10 +188,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -200,9 +200,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> PhoneNumberInstance: @@ -213,10 +215,11 @@ def fetch(self) -> PhoneNumberInstance: :returns: The fetched PhoneNumberInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return PhoneNumberInstance( self._version, @@ -233,9 +236,12 @@ async def fetch_async(self) -> PhoneNumberInstance: :returns: The fetched PhoneNumberInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return PhoneNumberInstance( @@ -255,16 +261,20 @@ def update( :returns: The updated PhoneNumberInstance """ + data = values.of( { "IsReserved": serialize.boolean_to_string(is_reserved), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return PhoneNumberInstance( @@ -284,16 +294,20 @@ async def update_async( :returns: The updated PhoneNumberInstance """ + data = values.of( { "IsReserved": serialize.boolean_to_string(is_reserved), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return PhoneNumberInstance( @@ -375,11 +389,14 @@ def create( "IsReserved": serialize.boolean_to_string(is_reserved), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return PhoneNumberInstance( @@ -409,11 +426,14 @@ async def create_async( "IsReserved": serialize.boolean_to_string(is_reserved), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return PhoneNumberInstance( @@ -547,7 +567,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return PhoneNumberPage(self._version, response, self._solution) async def page_async( @@ -574,8 +600,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return PhoneNumberPage(self._version, response, self._solution) diff --git a/twilio/rest/proxy/v1/service/session/__init__.py b/twilio/rest/proxy/v1/service/session/__init__.py index 26ff177889..839db075c3 100644 --- a/twilio/rest/proxy/v1/service/session/__init__.py +++ b/twilio/rest/proxy/v1/service/session/__init__.py @@ -248,10 +248,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -260,9 +260,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> SessionInstance: @@ -273,10 +275,11 @@ def fetch(self) -> SessionInstance: :returns: The fetched SessionInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return SessionInstance( self._version, @@ -293,9 +296,12 @@ async def fetch_async(self) -> SessionInstance: :returns: The fetched SessionInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return SessionInstance( @@ -320,6 +326,7 @@ def update( :returns: The updated SessionInstance """ + data = values.of( { "DateExpiry": serialize.iso8601_datetime(date_expiry), @@ -327,11 +334,14 @@ def update( "Status": status, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SessionInstance( @@ -356,6 +366,7 @@ async def update_async( :returns: The updated SessionInstance """ + data = values.of( { "DateExpiry": serialize.iso8601_datetime(date_expiry), @@ -363,11 +374,14 @@ async def update_async( "Status": status, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SessionInstance( @@ -486,11 +500,14 @@ def create( ), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SessionInstance( @@ -531,11 +548,14 @@ async def create_async( ), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SessionInstance( @@ -669,7 +689,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return SessionPage(self._version, response, self._solution) async def page_async( @@ -696,8 +722,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return SessionPage(self._version, response, self._solution) diff --git a/twilio/rest/proxy/v1/service/session/interaction.py b/twilio/rest/proxy/v1/service/session/interaction.py index 6e4cac7c14..7eeccda5bc 100644 --- a/twilio/rest/proxy/v1/service/session/interaction.py +++ b/twilio/rest/proxy/v1/service/session/interaction.py @@ -220,10 +220,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -232,9 +232,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> InteractionInstance: @@ -245,10 +247,11 @@ def fetch(self) -> InteractionInstance: :returns: The fetched InteractionInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return InteractionInstance( self._version, @@ -266,9 +269,12 @@ async def fetch_async(self) -> InteractionInstance: :returns: The fetched InteractionInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return InteractionInstance( @@ -464,7 +470,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return InteractionPage(self._version, response, self._solution) async def page_async( @@ -491,8 +503,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return InteractionPage(self._version, response, self._solution) diff --git a/twilio/rest/proxy/v1/service/session/participant/__init__.py b/twilio/rest/proxy/v1/service/session/participant/__init__.py index 266396f08f..7ad20fcffb 100644 --- a/twilio/rest/proxy/v1/service/session/participant/__init__.py +++ b/twilio/rest/proxy/v1/service/session/participant/__init__.py @@ -183,10 +183,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -195,9 +195,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> ParticipantInstance: @@ -208,10 +210,11 @@ def fetch(self) -> ParticipantInstance: :returns: The fetched ParticipantInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ParticipantInstance( self._version, @@ -229,9 +232,12 @@ async def fetch_async(self) -> ParticipantInstance: :returns: The fetched ParticipantInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ParticipantInstance( @@ -340,11 +346,14 @@ def create( "ProxyIdentifierSid": proxy_identifier_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ParticipantInstance( @@ -380,11 +389,14 @@ async def create_async( "ProxyIdentifierSid": proxy_identifier_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ParticipantInstance( @@ -521,7 +533,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ParticipantPage(self._version, response, self._solution) async def page_async( @@ -548,8 +566,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ParticipantPage(self._version, response, self._solution) diff --git a/twilio/rest/proxy/v1/service/session/participant/message_interaction.py b/twilio/rest/proxy/v1/service/session/participant/message_interaction.py index b260b4693f..4ffe67965b 100644 --- a/twilio/rest/proxy/v1/service/session/participant/message_interaction.py +++ b/twilio/rest/proxy/v1/service/session/participant/message_interaction.py @@ -215,10 +215,11 @@ def fetch(self) -> MessageInteractionInstance: :returns: The fetched MessageInteractionInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return MessageInteractionInstance( self._version, @@ -237,9 +238,12 @@ async def fetch_async(self) -> MessageInteractionInstance: :returns: The fetched MessageInteractionInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return MessageInteractionInstance( @@ -332,11 +336,14 @@ def create( "MediaUrl": serialize.map(media_url, lambda e: e), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return MessageInteractionInstance( @@ -367,11 +374,14 @@ async def create_async( "MediaUrl": serialize.map(media_url, lambda e: e), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return MessageInteractionInstance( @@ -509,7 +519,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return MessageInteractionPage(self._version, response, self._solution) async def page_async( @@ -536,8 +552,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return MessageInteractionPage(self._version, response, self._solution) diff --git a/twilio/rest/proxy/v1/service/short_code.py b/twilio/rest/proxy/v1/service/short_code.py index 712d6f82fa..df71d4bdd5 100644 --- a/twilio/rest/proxy/v1/service/short_code.py +++ b/twilio/rest/proxy/v1/service/short_code.py @@ -182,10 +182,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -194,9 +194,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> ShortCodeInstance: @@ -207,10 +209,11 @@ def fetch(self) -> ShortCodeInstance: :returns: The fetched ShortCodeInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ShortCodeInstance( self._version, @@ -227,9 +230,12 @@ async def fetch_async(self) -> ShortCodeInstance: :returns: The fetched ShortCodeInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ShortCodeInstance( @@ -249,16 +255,20 @@ def update( :returns: The updated ShortCodeInstance """ + data = values.of( { "IsReserved": serialize.boolean_to_string(is_reserved), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ShortCodeInstance( @@ -278,16 +288,20 @@ async def update_async( :returns: The updated ShortCodeInstance """ + data = values.of( { "IsReserved": serialize.boolean_to_string(is_reserved), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ShortCodeInstance( @@ -360,11 +374,14 @@ def create(self, sid: str) -> ShortCodeInstance: "Sid": sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ShortCodeInstance( @@ -385,11 +402,14 @@ async def create_async(self, sid: str) -> ShortCodeInstance: "Sid": sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ShortCodeInstance( @@ -523,7 +543,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ShortCodePage(self._version, response, self._solution) async def page_async( @@ -550,8 +576,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ShortCodePage(self._version, response, self._solution) diff --git a/twilio/rest/routes/v2/phone_number.py b/twilio/rest/routes/v2/phone_number.py index 4f452e3616..1b67509bb0 100644 --- a/twilio/rest/routes/v2/phone_number.py +++ b/twilio/rest/routes/v2/phone_number.py @@ -163,10 +163,11 @@ def fetch(self) -> PhoneNumberInstance: :returns: The fetched PhoneNumberInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return PhoneNumberInstance( self._version, @@ -182,9 +183,12 @@ async def fetch_async(self) -> PhoneNumberInstance: :returns: The fetched PhoneNumberInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return PhoneNumberInstance( @@ -206,17 +210,21 @@ def update( :returns: The updated PhoneNumberInstance """ + data = values.of( { "VoiceRegion": voice_region, "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return PhoneNumberInstance( @@ -236,17 +244,21 @@ async def update_async( :returns: The updated PhoneNumberInstance """ + data = values.of( { "VoiceRegion": voice_region, "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return PhoneNumberInstance( diff --git a/twilio/rest/routes/v2/sip_domain.py b/twilio/rest/routes/v2/sip_domain.py index cad3a4922c..2326a5dbc1 100644 --- a/twilio/rest/routes/v2/sip_domain.py +++ b/twilio/rest/routes/v2/sip_domain.py @@ -163,10 +163,11 @@ def fetch(self) -> SipDomainInstance: :returns: The fetched SipDomainInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return SipDomainInstance( self._version, @@ -182,9 +183,12 @@ async def fetch_async(self) -> SipDomainInstance: :returns: The fetched SipDomainInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return SipDomainInstance( @@ -206,17 +210,21 @@ def update( :returns: The updated SipDomainInstance """ + data = values.of( { "VoiceRegion": voice_region, "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SipDomainInstance( @@ -236,17 +244,21 @@ async def update_async( :returns: The updated SipDomainInstance """ + data = values.of( { "VoiceRegion": voice_region, "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SipDomainInstance( diff --git a/twilio/rest/routes/v2/trunk.py b/twilio/rest/routes/v2/trunk.py index 2baf2788ae..f783ce92ca 100644 --- a/twilio/rest/routes/v2/trunk.py +++ b/twilio/rest/routes/v2/trunk.py @@ -163,10 +163,11 @@ def fetch(self) -> TrunkInstance: :returns: The fetched TrunkInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return TrunkInstance( self._version, @@ -182,9 +183,12 @@ async def fetch_async(self) -> TrunkInstance: :returns: The fetched TrunkInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return TrunkInstance( @@ -206,17 +210,21 @@ def update( :returns: The updated TrunkInstance """ + data = values.of( { "VoiceRegion": voice_region, "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TrunkInstance( @@ -236,17 +244,21 @@ async def update_async( :returns: The updated TrunkInstance """ + data = values.of( { "VoiceRegion": voice_region, "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TrunkInstance( diff --git a/twilio/rest/serverless/v1/service/__init__.py b/twilio/rest/serverless/v1/service/__init__.py index 0fe404c8f1..f6e4e5841e 100644 --- a/twilio/rest/serverless/v1/service/__init__.py +++ b/twilio/rest/serverless/v1/service/__init__.py @@ -227,10 +227,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -239,9 +239,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> ServiceInstance: @@ -252,10 +254,11 @@ def fetch(self) -> ServiceInstance: :returns: The fetched ServiceInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ServiceInstance( self._version, @@ -271,9 +274,12 @@ async def fetch_async(self) -> ServiceInstance: :returns: The fetched ServiceInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ServiceInstance( @@ -297,6 +303,7 @@ def update( :returns: The updated ServiceInstance """ + data = values.of( { "IncludeCredentials": serialize.boolean_to_string(include_credentials), @@ -304,11 +311,14 @@ def update( "UiEditable": serialize.boolean_to_string(ui_editable), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload, sid=self._solution["sid"]) @@ -328,6 +338,7 @@ async def update_async( :returns: The updated ServiceInstance """ + data = values.of( { "IncludeCredentials": serialize.boolean_to_string(include_credentials), @@ -335,11 +346,14 @@ async def update_async( "UiEditable": serialize.boolean_to_string(ui_editable), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload, sid=self._solution["sid"]) @@ -460,11 +474,14 @@ def create( "UiEditable": serialize.boolean_to_string(ui_editable), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload) @@ -495,11 +512,14 @@ async def create_async( "UiEditable": serialize.boolean_to_string(ui_editable), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload) @@ -631,7 +651,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ServicePage(self._version, response) async def page_async( @@ -658,8 +684,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ServicePage(self._version, response) diff --git a/twilio/rest/serverless/v1/service/asset/__init__.py b/twilio/rest/serverless/v1/service/asset/__init__.py index 2049c9d46b..de68b969be 100644 --- a/twilio/rest/serverless/v1/service/asset/__init__.py +++ b/twilio/rest/serverless/v1/service/asset/__init__.py @@ -184,10 +184,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -196,9 +196,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> AssetInstance: @@ -209,10 +211,11 @@ def fetch(self) -> AssetInstance: :returns: The fetched AssetInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return AssetInstance( self._version, @@ -229,9 +232,12 @@ async def fetch_async(self) -> AssetInstance: :returns: The fetched AssetInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return AssetInstance( @@ -249,16 +255,20 @@ def update(self, friendly_name: str) -> AssetInstance: :returns: The updated AssetInstance """ + data = values.of( { "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AssetInstance( @@ -276,16 +286,20 @@ async def update_async(self, friendly_name: str) -> AssetInstance: :returns: The updated AssetInstance """ + data = values.of( { "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AssetInstance( @@ -371,11 +385,14 @@ def create(self, friendly_name: str) -> AssetInstance: "FriendlyName": friendly_name, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AssetInstance( @@ -396,11 +413,14 @@ async def create_async(self, friendly_name: str) -> AssetInstance: "FriendlyName": friendly_name, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AssetInstance( @@ -534,7 +554,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return AssetPage(self._version, response, self._solution) async def page_async( @@ -561,8 +587,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return AssetPage(self._version, response, self._solution) diff --git a/twilio/rest/serverless/v1/service/asset/asset_version.py b/twilio/rest/serverless/v1/service/asset/asset_version.py index fbe7b30800..31f85d4c29 100644 --- a/twilio/rest/serverless/v1/service/asset/asset_version.py +++ b/twilio/rest/serverless/v1/service/asset/asset_version.py @@ -146,10 +146,11 @@ def fetch(self) -> AssetVersionInstance: :returns: The fetched AssetVersionInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return AssetVersionInstance( self._version, @@ -167,9 +168,12 @@ async def fetch_async(self) -> AssetVersionInstance: :returns: The fetched AssetVersionInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return AssetVersionInstance( @@ -363,7 +367,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return AssetVersionPage(self._version, response, self._solution) async def page_async( @@ -390,8 +400,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return AssetVersionPage(self._version, response, self._solution) diff --git a/twilio/rest/serverless/v1/service/build/__init__.py b/twilio/rest/serverless/v1/service/build/__init__.py index 25997bec2e..5a7b6b7023 100644 --- a/twilio/rest/serverless/v1/service/build/__init__.py +++ b/twilio/rest/serverless/v1/service/build/__init__.py @@ -26,6 +26,7 @@ class BuildInstance(InstanceResource): + class Runtime(object): NODE8 = "node8" NODE10 = "node10" @@ -33,6 +34,8 @@ class Runtime(object): NODE14 = "node14" NODE16 = "node16" NODE18 = "node18" + NODE20 = "node20" + NODE22 = "node22" class Status(object): BUILDING = "building" @@ -173,7 +176,13 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete(method='DELETE', uri=self._uri,) + + + headers = values.of({}) + + + + return self._version.delete(method='DELETE', uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -182,7 +191,12 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return await self._version.delete_async(method='DELETE', uri=self._uri,) + + headers = values.of({}) + + + + return await self._version.delete_async(method='DELETE', uri=self._uri, headers=headers) def fetch(self) -> BuildInstance: @@ -193,7 +207,13 @@ def fetch(self) -> BuildInstance: :returns: The fetched BuildInstance """ - payload = self._version.fetch(method='GET', uri=self._uri, ) + + headers = values.of({}) + + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method='GET', uri=self._uri , headers=headers) return BuildInstance( self._version, @@ -211,7 +231,13 @@ async def fetch_async(self) -> BuildInstance: :returns: The fetched BuildInstance """ - payload = await self._version.fetch_async(method='GET', uri=self._uri, ) + + headers = values.of({}) + + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async(method='GET', uri=self._uri , headers=headers) return BuildInstance( self._version, @@ -313,9 +339,17 @@ def create(self, asset_versions: Union[List[str], object]=values.unset, function 'Dependencies': dependencies, 'Runtime': runtime, }) + headers = values.of({ + 'Content-Type': 'application/x-www-form-urlencoded' + }) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" - payload = self._version.create(method='POST', uri=self._uri, data=data,) + + payload = self._version.create(method='POST', uri=self._uri, data=data, headers=headers) return BuildInstance(self._version, payload, service_sid=self._solution['service_sid']) @@ -337,9 +371,17 @@ async def create_async(self, asset_versions: Union[List[str], object]=values.uns 'Dependencies': dependencies, 'Runtime': runtime, }) + headers = values.of({ + 'Content-Type': 'application/x-www-form-urlencoded' + }) + + headers["Content-Type"] = "application/x-www-form-urlencoded" - payload = await self._version.create_async(method='POST', uri=self._uri, data=data,) + headers["Accept"] = "application/json" + + + payload = await self._version.create_async(method='POST', uri=self._uri, data=data, headers=headers) return BuildInstance(self._version, payload, service_sid=self._solution['service_sid']) @@ -468,7 +510,15 @@ def page(self, 'PageSize': page_size, }) - response = self._version.page(method='GET', uri=self._uri, params=data) + headers = values.of({ + 'Content-Type': 'application/x-www-form-urlencoded' + }) + + + headers["Accept"] = "application/json" + + + response = self._version.page(method='GET', uri=self._uri, params=data, headers=headers) return BuildPage(self._version, response, self._solution) async def page_async(self, @@ -493,7 +543,15 @@ async def page_async(self, 'PageSize': page_size, }) - response = await self._version.page_async(method='GET', uri=self._uri, params=data) + headers = values.of({ + 'Content-Type': 'application/x-www-form-urlencoded' + }) + + + headers["Accept"] = "application/json" + + + response = await self._version.page_async(method='GET', uri=self._uri, params=data, headers=headers) return BuildPage(self._version, response, self._solution) def get_page(self, target_url: str) -> BuildPage: diff --git a/twilio/rest/serverless/v1/service/build/build_status.py b/twilio/rest/serverless/v1/service/build/build_status.py index 2613ae3cb6..e67c00e00e 100644 --- a/twilio/rest/serverless/v1/service/build/build_status.py +++ b/twilio/rest/serverless/v1/service/build/build_status.py @@ -14,6 +14,7 @@ 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 @@ -23,6 +24,7 @@ class BuildStatusInstance(InstanceResource): + class Status(object): BUILDING = "building" COMPLETED = "completed" @@ -123,7 +125,13 @@ def fetch(self) -> BuildStatusInstance: :returns: The fetched BuildStatusInstance """ - payload = self._version.fetch(method='GET', uri=self._uri, ) + + headers = values.of({}) + + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method='GET', uri=self._uri , headers=headers) return BuildStatusInstance( self._version, @@ -141,7 +149,13 @@ async def fetch_async(self) -> BuildStatusInstance: :returns: The fetched BuildStatusInstance """ - payload = await self._version.fetch_async(method='GET', uri=self._uri, ) + + headers = values.of({}) + + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async(method='GET', uri=self._uri , headers=headers) return BuildStatusInstance( self._version, diff --git a/twilio/rest/serverless/v1/service/environment/__init__.py b/twilio/rest/serverless/v1/service/environment/__init__.py index 46b7ddacf4..cdad0504a7 100644 --- a/twilio/rest/serverless/v1/service/environment/__init__.py +++ b/twilio/rest/serverless/v1/service/environment/__init__.py @@ -186,10 +186,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -198,9 +198,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> EnvironmentInstance: @@ -211,10 +213,11 @@ def fetch(self) -> EnvironmentInstance: :returns: The fetched EnvironmentInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return EnvironmentInstance( self._version, @@ -231,9 +234,12 @@ async def fetch_async(self) -> EnvironmentInstance: :returns: The fetched EnvironmentInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return EnvironmentInstance( @@ -349,11 +355,14 @@ def create( "DomainSuffix": domain_suffix, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return EnvironmentInstance( @@ -378,11 +387,14 @@ async def create_async( "DomainSuffix": domain_suffix, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return EnvironmentInstance( @@ -516,7 +528,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return EnvironmentPage(self._version, response, self._solution) async def page_async( @@ -543,8 +561,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return EnvironmentPage(self._version, response, self._solution) diff --git a/twilio/rest/serverless/v1/service/environment/deployment.py b/twilio/rest/serverless/v1/service/environment/deployment.py index 1ff896f93a..d28a4b8db1 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 @@ -142,10 +142,11 @@ def fetch(self) -> DeploymentInstance: :returns: The fetched DeploymentInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return DeploymentInstance( self._version, @@ -163,9 +164,12 @@ async def fetch_async(self) -> DeploymentInstance: :returns: The fetched DeploymentInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return DeploymentInstance( @@ -235,12 +239,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,13 +255,17 @@ 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"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return DeploymentInstance( @@ -265,12 +276,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 """ @@ -278,13 +292,17 @@ 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"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return DeploymentInstance( @@ -421,7 +439,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return DeploymentPage(self._version, response, self._solution) async def page_async( @@ -448,8 +472,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return DeploymentPage(self._version, response, self._solution) diff --git a/twilio/rest/serverless/v1/service/environment/log.py b/twilio/rest/serverless/v1/service/environment/log.py index e1aff5214f..a3c9a6c2da 100644 --- a/twilio/rest/serverless/v1/service/environment/log.py +++ b/twilio/rest/serverless/v1/service/environment/log.py @@ -156,10 +156,11 @@ def fetch(self) -> LogInstance: :returns: The fetched LogInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return LogInstance( self._version, @@ -177,9 +178,12 @@ async def fetch_async(self) -> LogInstance: :returns: The fetched LogInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return LogInstance( @@ -424,7 +428,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return LogPage(self._version, response, self._solution) async def page_async( @@ -460,8 +470,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return LogPage(self._version, response, self._solution) diff --git a/twilio/rest/serverless/v1/service/environment/variable.py b/twilio/rest/serverless/v1/service/environment/variable.py index f69c129f81..fbc6b48ac8 100644 --- a/twilio/rest/serverless/v1/service/environment/variable.py +++ b/twilio/rest/serverless/v1/service/environment/variable.py @@ -197,10 +197,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -209,9 +209,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> VariableInstance: @@ -222,10 +224,11 @@ def fetch(self) -> VariableInstance: :returns: The fetched VariableInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return VariableInstance( self._version, @@ -243,9 +246,12 @@ async def fetch_async(self) -> VariableInstance: :returns: The fetched VariableInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return VariableInstance( @@ -269,17 +275,21 @@ def update( :returns: The updated VariableInstance """ + data = values.of( { "Key": key, "Value": value, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return VariableInstance( @@ -303,17 +313,21 @@ async def update_async( :returns: The updated VariableInstance """ + data = values.of( { "Key": key, "Value": value, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return VariableInstance( @@ -398,11 +412,14 @@ def create(self, key: str, value: str) -> VariableInstance: "Value": value, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return VariableInstance( @@ -428,11 +445,14 @@ async def create_async(self, key: str, value: str) -> VariableInstance: "Value": value, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return VariableInstance( @@ -569,7 +589,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return VariablePage(self._version, response, self._solution) async def page_async( @@ -596,8 +622,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return VariablePage(self._version, response, self._solution) diff --git a/twilio/rest/serverless/v1/service/function/__init__.py b/twilio/rest/serverless/v1/service/function/__init__.py index 71bbad8466..7697587e60 100644 --- a/twilio/rest/serverless/v1/service/function/__init__.py +++ b/twilio/rest/serverless/v1/service/function/__init__.py @@ -186,10 +186,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -198,9 +198,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> FunctionInstance: @@ -211,10 +213,11 @@ def fetch(self) -> FunctionInstance: :returns: The fetched FunctionInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return FunctionInstance( self._version, @@ -231,9 +234,12 @@ async def fetch_async(self) -> FunctionInstance: :returns: The fetched FunctionInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return FunctionInstance( @@ -251,16 +257,20 @@ def update(self, friendly_name: str) -> FunctionInstance: :returns: The updated FunctionInstance """ + data = values.of( { "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return FunctionInstance( @@ -278,16 +288,20 @@ async def update_async(self, friendly_name: str) -> FunctionInstance: :returns: The updated FunctionInstance """ + data = values.of( { "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return FunctionInstance( @@ -373,11 +387,14 @@ def create(self, friendly_name: str) -> FunctionInstance: "FriendlyName": friendly_name, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return FunctionInstance( @@ -398,11 +415,14 @@ async def create_async(self, friendly_name: str) -> FunctionInstance: "FriendlyName": friendly_name, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return FunctionInstance( @@ -536,7 +556,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return FunctionPage(self._version, response, self._solution) async def page_async( @@ -563,8 +589,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return FunctionPage(self._version, response, self._solution) diff --git a/twilio/rest/serverless/v1/service/function/function_version/__init__.py b/twilio/rest/serverless/v1/service/function/function_version/__init__.py index e915894f11..88b666208c 100644 --- a/twilio/rest/serverless/v1/service/function/function_version/__init__.py +++ b/twilio/rest/serverless/v1/service/function/function_version/__init__.py @@ -162,10 +162,11 @@ def fetch(self) -> FunctionVersionInstance: :returns: The fetched FunctionVersionInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return FunctionVersionInstance( self._version, @@ -183,9 +184,12 @@ async def fetch_async(self) -> FunctionVersionInstance: :returns: The fetched FunctionVersionInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return FunctionVersionInstance( @@ -393,7 +397,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return FunctionVersionPage(self._version, response, self._solution) async def page_async( @@ -420,8 +430,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return FunctionVersionPage(self._version, response, self._solution) diff --git a/twilio/rest/serverless/v1/service/function/function_version/function_version_content.py b/twilio/rest/serverless/v1/service/function/function_version/function_version_content.py index c58fa574e7..f16833da2a 100644 --- a/twilio/rest/serverless/v1/service/function/function_version/function_version_content.py +++ b/twilio/rest/serverless/v1/service/function/function_version/function_version_content.py @@ -13,6 +13,7 @@ """ 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 @@ -131,10 +132,11 @@ def fetch(self) -> FunctionVersionContentInstance: :returns: The fetched FunctionVersionContentInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return FunctionVersionContentInstance( self._version, @@ -152,9 +154,12 @@ async def fetch_async(self) -> FunctionVersionContentInstance: :returns: The fetched FunctionVersionContentInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return FunctionVersionContentInstance( diff --git a/twilio/rest/studio/v1/flow/__init__.py b/twilio/rest/studio/v1/flow/__init__.py index bb0f78658b..533c1a45f5 100644 --- a/twilio/rest/studio/v1/flow/__init__.py +++ b/twilio/rest/studio/v1/flow/__init__.py @@ -168,10 +168,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -180,9 +180,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> FlowInstance: @@ -193,10 +195,11 @@ def fetch(self) -> FlowInstance: :returns: The fetched FlowInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return FlowInstance( self._version, @@ -212,9 +215,12 @@ async def fetch_async(self) -> FlowInstance: :returns: The fetched FlowInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return FlowInstance( @@ -416,7 +422,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return FlowPage(self._version, response) async def page_async( @@ -443,8 +455,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return FlowPage(self._version, response) diff --git a/twilio/rest/studio/v1/flow/engagement/__init__.py b/twilio/rest/studio/v1/flow/engagement/__init__.py index f6d95abd5f..759d92506c 100644 --- a/twilio/rest/studio/v1/flow/engagement/__init__.py +++ b/twilio/rest/studio/v1/flow/engagement/__init__.py @@ -184,10 +184,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -196,9 +196,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> EngagementInstance: @@ -209,10 +211,11 @@ def fetch(self) -> EngagementInstance: :returns: The fetched EngagementInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return EngagementInstance( self._version, @@ -229,9 +232,12 @@ async def fetch_async(self) -> EngagementInstance: :returns: The fetched EngagementInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return EngagementInstance( @@ -336,11 +342,14 @@ def create( "Parameters": serialize.object(parameters), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return EngagementInstance( @@ -367,11 +376,14 @@ async def create_async( "Parameters": serialize.object(parameters), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return EngagementInstance( @@ -505,7 +517,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return EngagementPage(self._version, response, self._solution) async def page_async( @@ -532,8 +550,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return EngagementPage(self._version, response, self._solution) diff --git a/twilio/rest/studio/v1/flow/engagement/engagement_context.py b/twilio/rest/studio/v1/flow/engagement/engagement_context.py index f534db6922..73161011eb 100644 --- a/twilio/rest/studio/v1/flow/engagement/engagement_context.py +++ b/twilio/rest/studio/v1/flow/engagement/engagement_context.py @@ -13,6 +13,7 @@ """ 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 @@ -122,10 +123,11 @@ def fetch(self) -> EngagementContextInstance: :returns: The fetched EngagementContextInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return EngagementContextInstance( self._version, @@ -142,9 +144,12 @@ async def fetch_async(self) -> EngagementContextInstance: :returns: The fetched EngagementContextInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return EngagementContextInstance( diff --git a/twilio/rest/studio/v1/flow/engagement/step/__init__.py b/twilio/rest/studio/v1/flow/engagement/step/__init__.py index 1a2d8570c9..a5017c3313 100644 --- a/twilio/rest/studio/v1/flow/engagement/step/__init__.py +++ b/twilio/rest/studio/v1/flow/engagement/step/__init__.py @@ -31,6 +31,7 @@ class StepInstance(InstanceResource): :ivar engagement_sid: The SID of the Engagement. :ivar name: The event that caused the Flow to transition to the Step. :ivar context: The current state of the Flow's Execution. As a flow executes, we save its state in this context. We save data that your widgets can access as variables in configuration fields or in text areas as variable substitution. + :ivar parent_step_sid: The SID of the parent Step. :ivar transitioned_from: The Widget that preceded the Widget for the Step. :ivar transitioned_to: The Widget that will follow the Widget for the Step. :ivar date_created: The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. @@ -55,6 +56,7 @@ def __init__( self.engagement_sid: Optional[str] = payload.get("engagement_sid") self.name: Optional[str] = payload.get("name") self.context: Optional[Dict[str, object]] = payload.get("context") + self.parent_step_sid: Optional[str] = payload.get("parent_step_sid") self.transitioned_from: Optional[str] = payload.get("transitioned_from") self.transitioned_to: Optional[str] = payload.get("transitioned_to") self.date_created: Optional[datetime] = deserialize.iso8601_datetime( @@ -158,10 +160,11 @@ def fetch(self) -> StepInstance: :returns: The fetched StepInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return StepInstance( self._version, @@ -179,9 +182,12 @@ async def fetch_async(self) -> StepInstance: :returns: The fetched StepInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return StepInstance( @@ -389,7 +395,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return StepPage(self._version, response, self._solution) async def page_async( @@ -416,8 +428,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return StepPage(self._version, response, self._solution) diff --git a/twilio/rest/studio/v1/flow/engagement/step/step_context.py b/twilio/rest/studio/v1/flow/engagement/step/step_context.py index 69c4c22465..6b299ebe5d 100644 --- a/twilio/rest/studio/v1/flow/engagement/step/step_context.py +++ b/twilio/rest/studio/v1/flow/engagement/step/step_context.py @@ -13,6 +13,7 @@ """ 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 @@ -131,10 +132,11 @@ def fetch(self) -> StepContextInstance: :returns: The fetched StepContextInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return StepContextInstance( self._version, @@ -152,9 +154,12 @@ async def fetch_async(self) -> StepContextInstance: :returns: The fetched StepContextInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return StepContextInstance( diff --git a/twilio/rest/studio/v1/flow/execution/__init__.py b/twilio/rest/studio/v1/flow/execution/__init__.py index 57239e5154..624b381768 100644 --- a/twilio/rest/studio/v1/flow/execution/__init__.py +++ b/twilio/rest/studio/v1/flow/execution/__init__.py @@ -208,10 +208,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -220,9 +220,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> ExecutionInstance: @@ -233,10 +235,11 @@ def fetch(self) -> ExecutionInstance: :returns: The fetched ExecutionInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ExecutionInstance( self._version, @@ -253,9 +256,12 @@ async def fetch_async(self) -> ExecutionInstance: :returns: The fetched ExecutionInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ExecutionInstance( @@ -273,16 +279,20 @@ def update(self, status: "ExecutionInstance.Status") -> ExecutionInstance: :returns: The updated ExecutionInstance """ + data = values.of( { "Status": status, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ExecutionInstance( @@ -302,16 +312,20 @@ async def update_async( :returns: The updated ExecutionInstance """ + data = values.of( { "Status": status, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ExecutionInstance( @@ -416,11 +430,14 @@ def create( "Parameters": serialize.object(parameters), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ExecutionInstance( @@ -447,11 +464,14 @@ async def create_async( "Parameters": serialize.object(parameters), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ExecutionInstance( @@ -619,7 +639,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ExecutionPage(self._version, response, self._solution) async def page_async( @@ -652,8 +678,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ExecutionPage(self._version, response, self._solution) diff --git a/twilio/rest/studio/v1/flow/execution/execution_context.py b/twilio/rest/studio/v1/flow/execution/execution_context.py index a2765bbc9b..0841a9ef24 100644 --- a/twilio/rest/studio/v1/flow/execution/execution_context.py +++ b/twilio/rest/studio/v1/flow/execution/execution_context.py @@ -13,6 +13,7 @@ """ 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 @@ -122,10 +123,11 @@ def fetch(self) -> ExecutionContextInstance: :returns: The fetched ExecutionContextInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ExecutionContextInstance( self._version, @@ -142,9 +144,12 @@ async def fetch_async(self) -> ExecutionContextInstance: :returns: The fetched ExecutionContextInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ExecutionContextInstance( diff --git a/twilio/rest/studio/v1/flow/execution/execution_step/__init__.py b/twilio/rest/studio/v1/flow/execution/execution_step/__init__.py index 6e19ca4453..50a1e2371d 100644 --- a/twilio/rest/studio/v1/flow/execution/execution_step/__init__.py +++ b/twilio/rest/studio/v1/flow/execution/execution_step/__init__.py @@ -31,6 +31,7 @@ class ExecutionStepInstance(InstanceResource): :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the ExecutionStep resource. :ivar flow_sid: The SID of the Flow. :ivar execution_sid: The SID of the Step's Execution resource. + :ivar parent_step_sid: This field shows the Step SID of the Widget in the parent Flow that started the Subflow. If this Step is not part of a Subflow execution, the value is null. :ivar name: The event that caused the Flow to transition to the Step. :ivar context: The current state of the Flow's Execution. As a flow executes, we save its state in this context. We save data that your widgets can access as variables in configuration fields or in text areas as variable substitution. :ivar transitioned_from: The Widget that preceded the Widget for the Step. @@ -55,6 +56,7 @@ def __init__( self.account_sid: Optional[str] = payload.get("account_sid") self.flow_sid: Optional[str] = payload.get("flow_sid") self.execution_sid: Optional[str] = payload.get("execution_sid") + self.parent_step_sid: Optional[str] = payload.get("parent_step_sid") self.name: Optional[str] = payload.get("name") self.context: Optional[Dict[str, object]] = payload.get("context") self.transitioned_from: Optional[str] = payload.get("transitioned_from") @@ -160,10 +162,11 @@ def fetch(self) -> ExecutionStepInstance: :returns: The fetched ExecutionStepInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ExecutionStepInstance( self._version, @@ -181,9 +184,12 @@ async def fetch_async(self) -> ExecutionStepInstance: :returns: The fetched ExecutionStepInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ExecutionStepInstance( @@ -391,7 +397,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ExecutionStepPage(self._version, response, self._solution) async def page_async( @@ -418,8 +430,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ExecutionStepPage(self._version, response, self._solution) diff --git a/twilio/rest/studio/v1/flow/execution/execution_step/execution_step_context.py b/twilio/rest/studio/v1/flow/execution/execution_step/execution_step_context.py index 224f92d0f5..78249a9562 100644 --- a/twilio/rest/studio/v1/flow/execution/execution_step/execution_step_context.py +++ b/twilio/rest/studio/v1/flow/execution/execution_step/execution_step_context.py @@ -13,6 +13,7 @@ """ 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 @@ -131,10 +132,11 @@ def fetch(self) -> ExecutionStepContextInstance: :returns: The fetched ExecutionStepContextInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ExecutionStepContextInstance( self._version, @@ -152,9 +154,12 @@ async def fetch_async(self) -> ExecutionStepContextInstance: :returns: The fetched ExecutionStepContextInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ExecutionStepContextInstance( diff --git a/twilio/rest/studio/v2/flow/__init__.py b/twilio/rest/studio/v2/flow/__init__.py index 21138d29cc..b4c542fdc0 100644 --- a/twilio/rest/studio/v2/flow/__init__.py +++ b/twilio/rest/studio/v2/flow/__init__.py @@ -237,10 +237,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -249,9 +249,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> FlowInstance: @@ -262,10 +264,11 @@ def fetch(self) -> FlowInstance: :returns: The fetched FlowInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return FlowInstance( self._version, @@ -281,9 +284,12 @@ async def fetch_async(self) -> FlowInstance: :returns: The fetched FlowInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return FlowInstance( @@ -309,6 +315,7 @@ def update( :returns: The updated FlowInstance """ + data = values.of( { "Status": status, @@ -317,11 +324,14 @@ def update( "CommitMessage": commit_message, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return FlowInstance(self._version, payload, sid=self._solution["sid"]) @@ -343,6 +353,7 @@ async def update_async( :returns: The updated FlowInstance """ + data = values.of( { "Status": status, @@ -351,11 +362,14 @@ async def update_async( "CommitMessage": commit_message, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return FlowInstance(self._version, payload, sid=self._solution["sid"]) @@ -464,11 +478,14 @@ def create( "CommitMessage": commit_message, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return FlowInstance(self._version, payload) @@ -499,11 +516,14 @@ async def create_async( "CommitMessage": commit_message, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return FlowInstance(self._version, payload) @@ -635,7 +655,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return FlowPage(self._version, response) async def page_async( @@ -662,8 +688,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return FlowPage(self._version, response) diff --git a/twilio/rest/studio/v2/flow/execution/__init__.py b/twilio/rest/studio/v2/flow/execution/__init__.py index 38d3b2b539..c47a3fbbc0 100644 --- a/twilio/rest/studio/v2/flow/execution/__init__.py +++ b/twilio/rest/studio/v2/flow/execution/__init__.py @@ -206,10 +206,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -218,9 +218,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> ExecutionInstance: @@ -231,10 +233,11 @@ def fetch(self) -> ExecutionInstance: :returns: The fetched ExecutionInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ExecutionInstance( self._version, @@ -251,9 +254,12 @@ async def fetch_async(self) -> ExecutionInstance: :returns: The fetched ExecutionInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ExecutionInstance( @@ -271,16 +277,20 @@ def update(self, status: "ExecutionInstance.Status") -> ExecutionInstance: :returns: The updated ExecutionInstance """ + data = values.of( { "Status": status, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ExecutionInstance( @@ -300,16 +310,20 @@ async def update_async( :returns: The updated ExecutionInstance """ + data = values.of( { "Status": status, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ExecutionInstance( @@ -414,11 +428,14 @@ def create( "Parameters": serialize.object(parameters), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ExecutionInstance( @@ -445,11 +462,14 @@ async def create_async( "Parameters": serialize.object(parameters), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ExecutionInstance( @@ -617,7 +637,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ExecutionPage(self._version, response, self._solution) async def page_async( @@ -650,8 +676,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ExecutionPage(self._version, response, self._solution) diff --git a/twilio/rest/studio/v2/flow/execution/execution_context.py b/twilio/rest/studio/v2/flow/execution/execution_context.py index facb52eed7..4c18f81d11 100644 --- a/twilio/rest/studio/v2/flow/execution/execution_context.py +++ b/twilio/rest/studio/v2/flow/execution/execution_context.py @@ -13,6 +13,7 @@ """ 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 @@ -122,10 +123,11 @@ def fetch(self) -> ExecutionContextInstance: :returns: The fetched ExecutionContextInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ExecutionContextInstance( self._version, @@ -142,9 +144,12 @@ async def fetch_async(self) -> ExecutionContextInstance: :returns: The fetched ExecutionContextInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ExecutionContextInstance( diff --git a/twilio/rest/studio/v2/flow/execution/execution_step/__init__.py b/twilio/rest/studio/v2/flow/execution/execution_step/__init__.py index 257e16b1df..9ffb2502e6 100644 --- a/twilio/rest/studio/v2/flow/execution/execution_step/__init__.py +++ b/twilio/rest/studio/v2/flow/execution/execution_step/__init__.py @@ -31,6 +31,7 @@ class ExecutionStepInstance(InstanceResource): :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the ExecutionStep resource. :ivar flow_sid: The SID of the Flow. :ivar execution_sid: The SID of the Step's Execution resource. + :ivar parent_step_sid: The SID of the parent Step. :ivar name: The event that caused the Flow to transition to the Step. :ivar context: The current state of the Flow's Execution. As a flow executes, we save its state in this context. We save data that your widgets can access as variables in configuration fields or in text areas as variable substitution. :ivar transitioned_from: The Widget that preceded the Widget for the Step. @@ -55,6 +56,7 @@ def __init__( self.account_sid: Optional[str] = payload.get("account_sid") self.flow_sid: Optional[str] = payload.get("flow_sid") self.execution_sid: Optional[str] = payload.get("execution_sid") + self.parent_step_sid: Optional[str] = payload.get("parent_step_sid") self.name: Optional[str] = payload.get("name") self.context: Optional[Dict[str, object]] = payload.get("context") self.transitioned_from: Optional[str] = payload.get("transitioned_from") @@ -160,10 +162,11 @@ def fetch(self) -> ExecutionStepInstance: :returns: The fetched ExecutionStepInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ExecutionStepInstance( self._version, @@ -181,9 +184,12 @@ async def fetch_async(self) -> ExecutionStepInstance: :returns: The fetched ExecutionStepInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ExecutionStepInstance( @@ -391,7 +397,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ExecutionStepPage(self._version, response, self._solution) async def page_async( @@ -418,8 +430,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ExecutionStepPage(self._version, response, self._solution) diff --git a/twilio/rest/studio/v2/flow/execution/execution_step/execution_step_context.py b/twilio/rest/studio/v2/flow/execution/execution_step/execution_step_context.py index 41661238b5..7f00e0d180 100644 --- a/twilio/rest/studio/v2/flow/execution/execution_step/execution_step_context.py +++ b/twilio/rest/studio/v2/flow/execution/execution_step/execution_step_context.py @@ -13,6 +13,7 @@ """ 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 @@ -131,10 +132,11 @@ def fetch(self) -> ExecutionStepContextInstance: :returns: The fetched ExecutionStepContextInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ExecutionStepContextInstance( self._version, @@ -152,9 +154,12 @@ async def fetch_async(self) -> ExecutionStepContextInstance: :returns: The fetched ExecutionStepContextInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ExecutionStepContextInstance( diff --git a/twilio/rest/studio/v2/flow/flow_revision.py b/twilio/rest/studio/v2/flow/flow_revision.py index 0de91513ed..aa065074d1 100644 --- a/twilio/rest/studio/v2/flow/flow_revision.py +++ b/twilio/rest/studio/v2/flow/flow_revision.py @@ -146,10 +146,11 @@ def fetch(self) -> FlowRevisionInstance: :returns: The fetched FlowRevisionInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return FlowRevisionInstance( self._version, @@ -166,9 +167,12 @@ async def fetch_async(self) -> FlowRevisionInstance: :returns: The fetched FlowRevisionInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return FlowRevisionInstance( @@ -352,7 +356,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return FlowRevisionPage(self._version, response, self._solution) async def page_async( @@ -379,8 +389,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return FlowRevisionPage(self._version, response, self._solution) diff --git a/twilio/rest/studio/v2/flow/flow_test_user.py b/twilio/rest/studio/v2/flow/flow_test_user.py index 3465632353..cff41cd7e2 100644 --- a/twilio/rest/studio/v2/flow/flow_test_user.py +++ b/twilio/rest/studio/v2/flow/flow_test_user.py @@ -131,10 +131,11 @@ def fetch(self) -> FlowTestUserInstance: :returns: The fetched FlowTestUserInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return FlowTestUserInstance( self._version, @@ -150,9 +151,12 @@ async def fetch_async(self) -> FlowTestUserInstance: :returns: The fetched FlowTestUserInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return FlowTestUserInstance( @@ -169,16 +173,20 @@ def update(self, test_users: List[str]) -> FlowTestUserInstance: :returns: The updated FlowTestUserInstance """ + data = values.of( { "TestUsers": serialize.map(test_users, lambda e: e), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return FlowTestUserInstance(self._version, payload, sid=self._solution["sid"]) @@ -191,16 +199,20 @@ async def update_async(self, test_users: List[str]) -> FlowTestUserInstance: :returns: The updated FlowTestUserInstance """ + data = values.of( { "TestUsers": serialize.map(test_users, lambda e: e), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return FlowTestUserInstance(self._version, payload, sid=self._solution["sid"]) diff --git a/twilio/rest/studio/v2/flow_validate.py b/twilio/rest/studio/v2/flow_validate.py index 6994e6af14..5f8b308547 100644 --- a/twilio/rest/studio/v2/flow_validate.py +++ b/twilio/rest/studio/v2/flow_validate.py @@ -75,6 +75,7 @@ def update( :returns: The created FlowValidateInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -83,11 +84,14 @@ def update( "CommitMessage": commit_message, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return FlowValidateInstance(self._version, payload) @@ -109,6 +113,7 @@ async def update_async( :returns: The created FlowValidateInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -117,11 +122,14 @@ async def update_async( "CommitMessage": commit_message, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return FlowValidateInstance(self._version, payload) diff --git a/twilio/rest/supersim/v1/esim_profile.py b/twilio/rest/supersim/v1/esim_profile.py index 847bcae33a..d12bb9b73f 100644 --- a/twilio/rest/supersim/v1/esim_profile.py +++ b/twilio/rest/supersim/v1/esim_profile.py @@ -146,10 +146,11 @@ def fetch(self) -> EsimProfileInstance: :returns: The fetched EsimProfileInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return EsimProfileInstance( self._version, @@ -165,9 +166,12 @@ async def fetch_async(self) -> EsimProfileInstance: :returns: The fetched EsimProfileInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return EsimProfileInstance( @@ -244,11 +248,14 @@ def create( "Eid": eid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return EsimProfileInstance(self._version, payload) @@ -279,11 +286,14 @@ async def create_async( "Eid": eid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return EsimProfileInstance(self._version, payload) @@ -458,7 +468,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return EsimProfilePage(self._version, response) async def page_async( @@ -494,8 +510,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return EsimProfilePage(self._version, response) diff --git a/twilio/rest/supersim/v1/fleet.py b/twilio/rest/supersim/v1/fleet.py index 2003eb77b5..3ea067cff2 100644 --- a/twilio/rest/supersim/v1/fleet.py +++ b/twilio/rest/supersim/v1/fleet.py @@ -213,10 +213,11 @@ def fetch(self) -> FleetInstance: :returns: The fetched FleetInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return FleetInstance( self._version, @@ -232,9 +233,12 @@ async def fetch_async(self) -> FleetInstance: :returns: The fetched FleetInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return FleetInstance( @@ -266,6 +270,7 @@ def update( :returns: The updated FleetInstance """ + data = values.of( { "UniqueName": unique_name, @@ -277,11 +282,14 @@ def update( "DataLimit": data_limit, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return FleetInstance(self._version, payload, sid=self._solution["sid"]) @@ -309,6 +317,7 @@ async def update_async( :returns: The updated FleetInstance """ + data = values.of( { "UniqueName": unique_name, @@ -320,11 +329,14 @@ async def update_async( "DataLimit": data_limit, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return FleetInstance(self._version, payload, sid=self._solution["sid"]) @@ -412,11 +424,14 @@ def create( "SmsCommandsMethod": sms_commands_method, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return FleetInstance(self._version, payload) @@ -462,11 +477,14 @@ async def create_async( "SmsCommandsMethod": sms_commands_method, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return FleetInstance(self._version, payload) @@ -615,7 +633,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return FleetPage(self._version, response) async def page_async( @@ -645,8 +669,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return FleetPage(self._version, response) diff --git a/twilio/rest/supersim/v1/ip_command.py b/twilio/rest/supersim/v1/ip_command.py index b7610efec6..72bf78297f 100644 --- a/twilio/rest/supersim/v1/ip_command.py +++ b/twilio/rest/supersim/v1/ip_command.py @@ -156,10 +156,11 @@ def fetch(self) -> IpCommandInstance: :returns: The fetched IpCommandInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return IpCommandInstance( self._version, @@ -175,9 +176,12 @@ async def fetch_async(self) -> IpCommandInstance: :returns: The fetched IpCommandInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return IpCommandInstance( @@ -260,11 +264,14 @@ def create( "CallbackMethod": callback_method, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return IpCommandInstance(self._version, payload) @@ -301,11 +308,14 @@ async def create_async( "CallbackMethod": callback_method, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return IpCommandInstance(self._version, payload) @@ -501,7 +511,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return IpCommandPage(self._version, response) async def page_async( @@ -540,8 +556,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return IpCommandPage(self._version, response) diff --git a/twilio/rest/supersim/v1/network.py b/twilio/rest/supersim/v1/network.py index 0d4f6a94fd..211068d075 100644 --- a/twilio/rest/supersim/v1/network.py +++ b/twilio/rest/supersim/v1/network.py @@ -114,10 +114,11 @@ def fetch(self) -> NetworkInstance: :returns: The fetched NetworkInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return NetworkInstance( self._version, @@ -133,9 +134,12 @@ async def fetch_async(self) -> NetworkInstance: :returns: The fetched NetworkInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return NetworkInstance( @@ -356,7 +360,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return NetworkPage(self._version, response) async def page_async( @@ -392,8 +402,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return NetworkPage(self._version, response) diff --git a/twilio/rest/supersim/v1/network_access_profile/__init__.py b/twilio/rest/supersim/v1/network_access_profile/__init__.py index d0b5374699..15b0cc5695 100644 --- a/twilio/rest/supersim/v1/network_access_profile/__init__.py +++ b/twilio/rest/supersim/v1/network_access_profile/__init__.py @@ -163,10 +163,11 @@ def fetch(self) -> NetworkAccessProfileInstance: :returns: The fetched NetworkAccessProfileInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return NetworkAccessProfileInstance( self._version, @@ -182,9 +183,12 @@ async def fetch_async(self) -> NetworkAccessProfileInstance: :returns: The fetched NetworkAccessProfileInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return NetworkAccessProfileInstance( @@ -203,16 +207,20 @@ def update( :returns: The updated NetworkAccessProfileInstance """ + data = values.of( { "UniqueName": unique_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return NetworkAccessProfileInstance( @@ -229,16 +237,20 @@ async def update_async( :returns: The updated NetworkAccessProfileInstance """ + data = values.of( { "UniqueName": unique_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return NetworkAccessProfileInstance( @@ -319,11 +331,14 @@ def create( "Networks": serialize.map(networks, lambda e: e), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return NetworkAccessProfileInstance(self._version, payload) @@ -348,11 +363,14 @@ async def create_async( "Networks": serialize.map(networks, lambda e: e), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return NetworkAccessProfileInstance(self._version, payload) @@ -484,7 +502,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return NetworkAccessProfilePage(self._version, response) async def page_async( @@ -511,8 +535,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return NetworkAccessProfilePage(self._version, response) diff --git a/twilio/rest/supersim/v1/network_access_profile/network_access_profile_network.py b/twilio/rest/supersim/v1/network_access_profile/network_access_profile_network.py index 50a259550d..c7099b8a7a 100644 --- a/twilio/rest/supersim/v1/network_access_profile/network_access_profile_network.py +++ b/twilio/rest/supersim/v1/network_access_profile/network_access_profile_network.py @@ -149,10 +149,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -161,9 +161,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> NetworkAccessProfileNetworkInstance: @@ -174,10 +176,11 @@ def fetch(self) -> NetworkAccessProfileNetworkInstance: :returns: The fetched NetworkAccessProfileNetworkInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return NetworkAccessProfileNetworkInstance( self._version, @@ -194,9 +197,12 @@ async def fetch_async(self) -> NetworkAccessProfileNetworkInstance: :returns: The fetched NetworkAccessProfileNetworkInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return NetworkAccessProfileNetworkInstance( @@ -279,11 +285,14 @@ def create(self, network: str) -> NetworkAccessProfileNetworkInstance: "Network": network, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return NetworkAccessProfileNetworkInstance( @@ -306,11 +315,14 @@ async def create_async(self, network: str) -> NetworkAccessProfileNetworkInstanc "Network": network, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return NetworkAccessProfileNetworkInstance( @@ -446,7 +458,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return NetworkAccessProfileNetworkPage(self._version, response, self._solution) async def page_async( @@ -473,8 +491,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return NetworkAccessProfileNetworkPage(self._version, response, self._solution) diff --git a/twilio/rest/supersim/v1/settings_update.py b/twilio/rest/supersim/v1/settings_update.py index f946150287..294e1102ce 100644 --- a/twilio/rest/supersim/v1/settings_update.py +++ b/twilio/rest/supersim/v1/settings_update.py @@ -256,7 +256,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return SettingsUpdatePage(self._version, response) async def page_async( @@ -289,8 +295,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return SettingsUpdatePage(self._version, response) diff --git a/twilio/rest/supersim/v1/sim/__init__.py b/twilio/rest/supersim/v1/sim/__init__.py index b1ba647336..fa878a16df 100644 --- a/twilio/rest/supersim/v1/sim/__init__.py +++ b/twilio/rest/supersim/v1/sim/__init__.py @@ -221,10 +221,11 @@ def fetch(self) -> SimInstance: :returns: The fetched SimInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return SimInstance( self._version, @@ -240,9 +241,12 @@ async def fetch_async(self) -> SimInstance: :returns: The fetched SimInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return SimInstance( @@ -272,6 +276,7 @@ def update( :returns: The updated SimInstance """ + data = values.of( { "UniqueName": unique_name, @@ -282,11 +287,14 @@ def update( "AccountSid": account_sid, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SimInstance(self._version, payload, sid=self._solution["sid"]) @@ -312,6 +320,7 @@ async def update_async( :returns: The updated SimInstance """ + data = values.of( { "UniqueName": unique_name, @@ -322,11 +331,14 @@ async def update_async( "AccountSid": account_sid, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SimInstance(self._version, payload, sid=self._solution["sid"]) @@ -413,11 +425,14 @@ def create(self, iccid: str, registration_code: str) -> SimInstance: "RegistrationCode": registration_code, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SimInstance(self._version, payload) @@ -438,11 +453,14 @@ async def create_async(self, iccid: str, registration_code: str) -> SimInstance: "RegistrationCode": registration_code, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SimInstance(self._version, payload) @@ -617,7 +635,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return SimPage(self._version, response) async def page_async( @@ -653,8 +677,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return SimPage(self._version, response) diff --git a/twilio/rest/supersim/v1/sim/billing_period.py b/twilio/rest/supersim/v1/sim/billing_period.py index e6fb961835..27cbe1222e 100644 --- a/twilio/rest/supersim/v1/sim/billing_period.py +++ b/twilio/rest/supersim/v1/sim/billing_period.py @@ -241,7 +241,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return BillingPeriodPage(self._version, response, self._solution) async def page_async( @@ -268,8 +274,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return BillingPeriodPage(self._version, response, self._solution) diff --git a/twilio/rest/supersim/v1/sim/sim_ip_address.py b/twilio/rest/supersim/v1/sim/sim_ip_address.py index 7c2b70e50f..0c4c3163b6 100644 --- a/twilio/rest/supersim/v1/sim/sim_ip_address.py +++ b/twilio/rest/supersim/v1/sim/sim_ip_address.py @@ -220,7 +220,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return SimIpAddressPage(self._version, response, self._solution) async def page_async( @@ -247,8 +253,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return SimIpAddressPage(self._version, response, self._solution) diff --git a/twilio/rest/supersim/v1/sms_command.py b/twilio/rest/supersim/v1/sms_command.py index 0eb2094103..dd70d2425e 100644 --- a/twilio/rest/supersim/v1/sms_command.py +++ b/twilio/rest/supersim/v1/sms_command.py @@ -141,10 +141,11 @@ def fetch(self) -> SmsCommandInstance: :returns: The fetched SmsCommandInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return SmsCommandInstance( self._version, @@ -160,9 +161,12 @@ async def fetch_async(self) -> SmsCommandInstance: :returns: The fetched SmsCommandInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return SmsCommandInstance( @@ -239,11 +243,14 @@ def create( "CallbackUrl": callback_url, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SmsCommandInstance(self._version, payload) @@ -274,11 +281,14 @@ async def create_async( "CallbackUrl": callback_url, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SmsCommandInstance(self._version, payload) @@ -453,7 +463,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return SmsCommandPage(self._version, response) async def page_async( @@ -489,8 +505,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return SmsCommandPage(self._version, response) diff --git a/twilio/rest/supersim/v1/usage_record.py b/twilio/rest/supersim/v1/usage_record.py index 86a335d0de..94072a51fb 100644 --- a/twilio/rest/supersim/v1/usage_record.py +++ b/twilio/rest/supersim/v1/usage_record.py @@ -359,7 +359,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return UsageRecordPage(self._version, response) async def page_async( @@ -410,8 +416,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return UsageRecordPage(self._version, response) diff --git a/twilio/rest/sync/v1/service/__init__.py b/twilio/rest/sync/v1/service/__init__.py index 0bf1045f2b..d17491d3cb 100644 --- a/twilio/rest/sync/v1/service/__init__.py +++ b/twilio/rest/sync/v1/service/__init__.py @@ -265,10 +265,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -277,9 +277,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> ServiceInstance: @@ -290,10 +292,11 @@ def fetch(self) -> ServiceInstance: :returns: The fetched ServiceInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ServiceInstance( self._version, @@ -309,9 +312,12 @@ async def fetch_async(self) -> ServiceInstance: :returns: The fetched ServiceInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ServiceInstance( @@ -343,6 +349,7 @@ def update( :returns: The updated ServiceInstance """ + data = values.of( { "WebhookUrl": webhook_url, @@ -360,11 +367,14 @@ def update( ), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload, sid=self._solution["sid"]) @@ -392,6 +402,7 @@ async def update_async( :returns: The updated ServiceInstance """ + data = values.of( { "WebhookUrl": webhook_url, @@ -409,11 +420,14 @@ async def update_async( ), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload, sid=self._solution["sid"]) @@ -549,11 +563,14 @@ def create( ), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload) @@ -599,11 +616,14 @@ async def create_async( ), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload) @@ -735,7 +755,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ServicePage(self._version, response) async def page_async( @@ -762,8 +788,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ServicePage(self._version, response) diff --git a/twilio/rest/sync/v1/service/document/__init__.py b/twilio/rest/sync/v1/service/document/__init__.py index f3b89cfe67..fe64f629a8 100644 --- a/twilio/rest/sync/v1/service/document/__init__.py +++ b/twilio/rest/sync/v1/service/document/__init__.py @@ -214,10 +214,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -226,9 +226,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> DocumentInstance: @@ -239,10 +241,11 @@ def fetch(self) -> DocumentInstance: :returns: The fetched DocumentInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return DocumentInstance( self._version, @@ -259,9 +262,12 @@ async def fetch_async(self) -> DocumentInstance: :returns: The fetched DocumentInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return DocumentInstance( @@ -286,17 +292,23 @@ def update( :returns: The updated DocumentInstance """ + data = values.of( { "Data": serialize.object(data), "Ttl": ttl, } ) - headers = values.of( - { - "If-Match": if_match, - } - ) + headers = values.of({}) + + if not ( + if_match is values.unset or (isinstance(if_match, str) and not if_match) + ): + headers["If-Match"] = if_match + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( method="POST", uri=self._uri, data=data, headers=headers @@ -324,17 +336,23 @@ async def update_async( :returns: The updated DocumentInstance """ + data = values.of( { "Data": serialize.object(data), "Ttl": ttl, } ) - headers = values.of( - { - "If-Match": if_match, - } - ) + headers = values.of({}) + + if not ( + if_match is values.unset or (isinstance(if_match, str) and not if_match) + ): + headers["If-Match"] = if_match + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( method="POST", uri=self._uri, data=data, headers=headers @@ -432,11 +450,14 @@ def create( "Ttl": ttl, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return DocumentInstance( @@ -466,11 +487,14 @@ async def create_async( "Ttl": ttl, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return DocumentInstance( @@ -604,7 +628,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return DocumentPage(self._version, response, self._solution) async def page_async( @@ -631,8 +661,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return DocumentPage(self._version, response, self._solution) diff --git a/twilio/rest/sync/v1/service/document/document_permission.py b/twilio/rest/sync/v1/service/document/document_permission.py index 40f524832c..75a27c969a 100644 --- a/twilio/rest/sync/v1/service/document/document_permission.py +++ b/twilio/rest/sync/v1/service/document/document_permission.py @@ -190,10 +190,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -202,9 +202,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> DocumentPermissionInstance: @@ -215,10 +217,11 @@ def fetch(self) -> DocumentPermissionInstance: :returns: The fetched DocumentPermissionInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return DocumentPermissionInstance( self._version, @@ -236,9 +239,12 @@ async def fetch_async(self) -> DocumentPermissionInstance: :returns: The fetched DocumentPermissionInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return DocumentPermissionInstance( @@ -261,6 +267,7 @@ def update( :returns: The updated DocumentPermissionInstance """ + data = values.of( { "Read": serialize.boolean_to_string(read), @@ -268,11 +275,14 @@ def update( "Manage": serialize.boolean_to_string(manage), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return DocumentPermissionInstance( @@ -295,6 +305,7 @@ async def update_async( :returns: The updated DocumentPermissionInstance """ + data = values.of( { "Read": serialize.boolean_to_string(read), @@ -302,11 +313,14 @@ async def update_async( "Manage": serialize.boolean_to_string(manage), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return DocumentPermissionInstance( @@ -502,7 +516,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return DocumentPermissionPage(self._version, response, self._solution) async def page_async( @@ -529,8 +549,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return DocumentPermissionPage(self._version, response, self._solution) diff --git a/twilio/rest/sync/v1/service/sync_list/__init__.py b/twilio/rest/sync/v1/service/sync_list/__init__.py index 7e9ca672c4..1b8e54aff8 100644 --- a/twilio/rest/sync/v1/service/sync_list/__init__.py +++ b/twilio/rest/sync/v1/service/sync_list/__init__.py @@ -215,10 +215,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -227,9 +227,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> SyncListInstance: @@ -240,10 +242,11 @@ def fetch(self) -> SyncListInstance: :returns: The fetched SyncListInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return SyncListInstance( self._version, @@ -260,9 +263,12 @@ async def fetch_async(self) -> SyncListInstance: :returns: The fetched SyncListInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return SyncListInstance( @@ -285,17 +291,21 @@ def update( :returns: The updated SyncListInstance """ + data = values.of( { "Ttl": ttl, "CollectionTtl": collection_ttl, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SyncListInstance( @@ -318,17 +328,21 @@ async def update_async( :returns: The updated SyncListInstance """ + data = values.of( { "Ttl": ttl, "CollectionTtl": collection_ttl, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SyncListInstance( @@ -436,11 +450,14 @@ def create( "CollectionTtl": collection_ttl, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SyncListInstance( @@ -470,11 +487,14 @@ async def create_async( "CollectionTtl": collection_ttl, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SyncListInstance( @@ -608,7 +628,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return SyncListPage(self._version, response, self._solution) async def page_async( @@ -635,8 +661,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return SyncListPage(self._version, response, self._solution) diff --git a/twilio/rest/sync/v1/service/sync_list/sync_list_item.py b/twilio/rest/sync/v1/service/sync_list/sync_list_item.py index 02dafcd49b..61783aa525 100644 --- a/twilio/rest/sync/v1/service/sync_list/sync_list_item.py +++ b/twilio/rest/sync/v1/service/sync_list/sync_list_item.py @@ -241,6 +241,8 @@ def delete(self, if_match: Union[str, object] = values.unset) -> bool: } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self, if_match: Union[str, object] = values.unset) -> bool: @@ -257,6 +259,8 @@ async def delete_async(self, if_match: Union[str, object] = values.unset) -> boo } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -269,10 +273,11 @@ def fetch(self) -> SyncListItemInstance: :returns: The fetched SyncListItemInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return SyncListItemInstance( self._version, @@ -290,9 +295,12 @@ async def fetch_async(self) -> SyncListItemInstance: :returns: The fetched SyncListItemInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return SyncListItemInstance( @@ -322,6 +330,7 @@ def update( :returns: The updated SyncListItemInstance """ + data = values.of( { "Data": serialize.object(data), @@ -330,11 +339,16 @@ def update( "CollectionTtl": collection_ttl, } ) - headers = values.of( - { - "If-Match": if_match, - } - ) + headers = values.of({}) + + if not ( + if_match is values.unset or (isinstance(if_match, str) and not if_match) + ): + headers["If-Match"] = if_match + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( method="POST", uri=self._uri, data=data, headers=headers @@ -367,6 +381,7 @@ async def update_async( :returns: The updated SyncListItemInstance """ + data = values.of( { "Data": serialize.object(data), @@ -375,11 +390,16 @@ async def update_async( "CollectionTtl": collection_ttl, } ) - headers = values.of( - { - "If-Match": if_match, - } - ) + headers = values.of({}) + + if not ( + if_match is values.unset or (isinstance(if_match, str) and not if_match) + ): + headers["If-Match"] = if_match + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( method="POST", uri=self._uri, data=data, headers=headers @@ -475,11 +495,14 @@ def create( "CollectionTtl": collection_ttl, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SyncListItemInstance( @@ -515,11 +538,14 @@ async def create_async( "CollectionTtl": collection_ttl, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SyncListItemInstance( @@ -699,7 +725,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return SyncListItemPage(self._version, response, self._solution) async def page_async( @@ -735,8 +767,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return SyncListItemPage(self._version, response, self._solution) diff --git a/twilio/rest/sync/v1/service/sync_list/sync_list_permission.py b/twilio/rest/sync/v1/service/sync_list/sync_list_permission.py index 07fce14b95..f1eb853468 100644 --- a/twilio/rest/sync/v1/service/sync_list/sync_list_permission.py +++ b/twilio/rest/sync/v1/service/sync_list/sync_list_permission.py @@ -192,10 +192,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -204,9 +204,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> SyncListPermissionInstance: @@ -217,10 +219,11 @@ def fetch(self) -> SyncListPermissionInstance: :returns: The fetched SyncListPermissionInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return SyncListPermissionInstance( self._version, @@ -238,9 +241,12 @@ async def fetch_async(self) -> SyncListPermissionInstance: :returns: The fetched SyncListPermissionInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return SyncListPermissionInstance( @@ -263,6 +269,7 @@ def update( :returns: The updated SyncListPermissionInstance """ + data = values.of( { "Read": serialize.boolean_to_string(read), @@ -270,11 +277,14 @@ def update( "Manage": serialize.boolean_to_string(manage), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SyncListPermissionInstance( @@ -297,6 +307,7 @@ async def update_async( :returns: The updated SyncListPermissionInstance """ + data = values.of( { "Read": serialize.boolean_to_string(read), @@ -304,11 +315,14 @@ async def update_async( "Manage": serialize.boolean_to_string(manage), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SyncListPermissionInstance( @@ -502,7 +516,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return SyncListPermissionPage(self._version, response, self._solution) async def page_async( @@ -529,8 +549,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return SyncListPermissionPage(self._version, response, self._solution) diff --git a/twilio/rest/sync/v1/service/sync_map/__init__.py b/twilio/rest/sync/v1/service/sync_map/__init__.py index 1a68e8ef4d..c6bb1ce556 100644 --- a/twilio/rest/sync/v1/service/sync_map/__init__.py +++ b/twilio/rest/sync/v1/service/sync_map/__init__.py @@ -215,10 +215,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -227,9 +227,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> SyncMapInstance: @@ -240,10 +242,11 @@ def fetch(self) -> SyncMapInstance: :returns: The fetched SyncMapInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return SyncMapInstance( self._version, @@ -260,9 +263,12 @@ async def fetch_async(self) -> SyncMapInstance: :returns: The fetched SyncMapInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return SyncMapInstance( @@ -285,17 +291,21 @@ def update( :returns: The updated SyncMapInstance """ + data = values.of( { "Ttl": ttl, "CollectionTtl": collection_ttl, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SyncMapInstance( @@ -318,17 +328,21 @@ async def update_async( :returns: The updated SyncMapInstance """ + data = values.of( { "Ttl": ttl, "CollectionTtl": collection_ttl, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SyncMapInstance( @@ -436,11 +450,14 @@ def create( "CollectionTtl": collection_ttl, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SyncMapInstance( @@ -470,11 +487,14 @@ async def create_async( "CollectionTtl": collection_ttl, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SyncMapInstance( @@ -608,7 +628,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return SyncMapPage(self._version, response, self._solution) async def page_async( @@ -635,8 +661,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return SyncMapPage(self._version, response, self._solution) diff --git a/twilio/rest/sync/v1/service/sync_map/sync_map_item.py b/twilio/rest/sync/v1/service/sync_map/sync_map_item.py index 7c621f8adc..4939694026 100644 --- a/twilio/rest/sync/v1/service/sync_map/sync_map_item.py +++ b/twilio/rest/sync/v1/service/sync_map/sync_map_item.py @@ -241,6 +241,8 @@ def delete(self, if_match: Union[str, object] = values.unset) -> bool: } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self, if_match: Union[str, object] = values.unset) -> bool: @@ -257,6 +259,8 @@ async def delete_async(self, if_match: Union[str, object] = values.unset) -> boo } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -269,10 +273,11 @@ def fetch(self) -> SyncMapItemInstance: :returns: The fetched SyncMapItemInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return SyncMapItemInstance( self._version, @@ -290,9 +295,12 @@ async def fetch_async(self) -> SyncMapItemInstance: :returns: The fetched SyncMapItemInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return SyncMapItemInstance( @@ -322,6 +330,7 @@ def update( :returns: The updated SyncMapItemInstance """ + data = values.of( { "Data": serialize.object(data), @@ -330,11 +339,16 @@ def update( "CollectionTtl": collection_ttl, } ) - headers = values.of( - { - "If-Match": if_match, - } - ) + headers = values.of({}) + + if not ( + if_match is values.unset or (isinstance(if_match, str) and not if_match) + ): + headers["If-Match"] = if_match + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( method="POST", uri=self._uri, data=data, headers=headers @@ -367,6 +381,7 @@ async def update_async( :returns: The updated SyncMapItemInstance """ + data = values.of( { "Data": serialize.object(data), @@ -375,11 +390,16 @@ async def update_async( "CollectionTtl": collection_ttl, } ) - headers = values.of( - { - "If-Match": if_match, - } - ) + headers = values.of({}) + + if not ( + if_match is values.unset or (isinstance(if_match, str) and not if_match) + ): + headers["If-Match"] = if_match + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( method="POST", uri=self._uri, data=data, headers=headers @@ -478,11 +498,14 @@ def create( "CollectionTtl": collection_ttl, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SyncMapItemInstance( @@ -521,11 +544,14 @@ async def create_async( "CollectionTtl": collection_ttl, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SyncMapItemInstance( @@ -705,7 +731,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return SyncMapItemPage(self._version, response, self._solution) async def page_async( @@ -741,8 +773,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return SyncMapItemPage(self._version, response, self._solution) diff --git a/twilio/rest/sync/v1/service/sync_map/sync_map_permission.py b/twilio/rest/sync/v1/service/sync_map/sync_map_permission.py index ba056906c7..910560add0 100644 --- a/twilio/rest/sync/v1/service/sync_map/sync_map_permission.py +++ b/twilio/rest/sync/v1/service/sync_map/sync_map_permission.py @@ -190,10 +190,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -202,9 +202,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> SyncMapPermissionInstance: @@ -215,10 +217,11 @@ def fetch(self) -> SyncMapPermissionInstance: :returns: The fetched SyncMapPermissionInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return SyncMapPermissionInstance( self._version, @@ -236,9 +239,12 @@ async def fetch_async(self) -> SyncMapPermissionInstance: :returns: The fetched SyncMapPermissionInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return SyncMapPermissionInstance( @@ -261,6 +267,7 @@ def update( :returns: The updated SyncMapPermissionInstance """ + data = values.of( { "Read": serialize.boolean_to_string(read), @@ -268,11 +275,14 @@ def update( "Manage": serialize.boolean_to_string(manage), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SyncMapPermissionInstance( @@ -295,6 +305,7 @@ async def update_async( :returns: The updated SyncMapPermissionInstance """ + data = values.of( { "Read": serialize.boolean_to_string(read), @@ -302,11 +313,14 @@ async def update_async( "Manage": serialize.boolean_to_string(manage), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SyncMapPermissionInstance( @@ -500,7 +514,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return SyncMapPermissionPage(self._version, response, self._solution) async def page_async( @@ -527,8 +547,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return SyncMapPermissionPage(self._version, response, self._solution) diff --git a/twilio/rest/sync/v1/service/sync_stream/__init__.py b/twilio/rest/sync/v1/service/sync_stream/__init__.py index aa10d164a6..a7f4128e05 100644 --- a/twilio/rest/sync/v1/service/sync_stream/__init__.py +++ b/twilio/rest/sync/v1/service/sync_stream/__init__.py @@ -192,10 +192,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -204,9 +204,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> SyncStreamInstance: @@ -217,10 +219,11 @@ def fetch(self) -> SyncStreamInstance: :returns: The fetched SyncStreamInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return SyncStreamInstance( self._version, @@ -237,9 +240,12 @@ async def fetch_async(self) -> SyncStreamInstance: :returns: The fetched SyncStreamInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return SyncStreamInstance( @@ -257,16 +263,20 @@ def update(self, ttl: Union[int, object] = values.unset) -> SyncStreamInstance: :returns: The updated SyncStreamInstance """ + data = values.of( { "Ttl": ttl, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SyncStreamInstance( @@ -286,16 +296,20 @@ async def update_async( :returns: The updated SyncStreamInstance """ + data = values.of( { "Ttl": ttl, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SyncStreamInstance( @@ -387,11 +401,14 @@ def create( "Ttl": ttl, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SyncStreamInstance( @@ -418,11 +435,14 @@ async def create_async( "Ttl": ttl, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SyncStreamInstance( @@ -556,7 +576,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return SyncStreamPage(self._version, response, self._solution) async def page_async( @@ -583,8 +609,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return SyncStreamPage(self._version, response, self._solution) diff --git a/twilio/rest/sync/v1/service/sync_stream/stream_message.py b/twilio/rest/sync/v1/service/sync_stream/stream_message.py index 88a7604a7a..bcce239975 100644 --- a/twilio/rest/sync/v1/service/sync_stream/stream_message.py +++ b/twilio/rest/sync/v1/service/sync_stream/stream_message.py @@ -89,11 +89,14 @@ def create(self, data: object) -> StreamMessageInstance: "Data": serialize.object(data), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return StreamMessageInstance( @@ -117,11 +120,14 @@ async def create_async(self, data: object) -> StreamMessageInstance: "Data": serialize.object(data), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return StreamMessageInstance( diff --git a/twilio/rest/taskrouter/v1/workspace/__init__.py b/twilio/rest/taskrouter/v1/workspace/__init__.py index f1202197c4..086e3e1747 100644 --- a/twilio/rest/taskrouter/v1/workspace/__init__.py +++ b/twilio/rest/taskrouter/v1/workspace/__init__.py @@ -330,10 +330,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -342,9 +342,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> WorkspaceInstance: @@ -355,10 +357,11 @@ def fetch(self) -> WorkspaceInstance: :returns: The fetched WorkspaceInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return WorkspaceInstance( self._version, @@ -374,9 +377,12 @@ async def fetch_async(self) -> WorkspaceInstance: :returns: The fetched WorkspaceInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return WorkspaceInstance( @@ -410,6 +416,7 @@ def update( :returns: The updated WorkspaceInstance """ + data = values.of( { "DefaultActivitySid": default_activity_sid, @@ -421,11 +428,14 @@ def update( "PrioritizeQueueOrder": prioritize_queue_order, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WorkspaceInstance(self._version, payload, sid=self._solution["sid"]) @@ -455,6 +465,7 @@ async def update_async( :returns: The updated WorkspaceInstance """ + data = values.of( { "DefaultActivitySid": default_activity_sid, @@ -466,11 +477,14 @@ async def update_async( "PrioritizeQueueOrder": prioritize_queue_order, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WorkspaceInstance(self._version, payload, sid=self._solution["sid"]) @@ -671,11 +685,14 @@ def create( "PrioritizeQueueOrder": prioritize_queue_order, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WorkspaceInstance(self._version, payload) @@ -714,11 +731,14 @@ async def create_async( "PrioritizeQueueOrder": prioritize_queue_order, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WorkspaceInstance(self._version, payload) @@ -865,7 +885,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return WorkspacePage(self._version, response) async def page_async( @@ -895,8 +921,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return WorkspacePage(self._version, response) diff --git a/twilio/rest/taskrouter/v1/workspace/activity.py b/twilio/rest/taskrouter/v1/workspace/activity.py index bae49d5efa..4e3e416af7 100644 --- a/twilio/rest/taskrouter/v1/workspace/activity.py +++ b/twilio/rest/taskrouter/v1/workspace/activity.py @@ -182,10 +182,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -194,9 +194,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> ActivityInstance: @@ -207,10 +209,11 @@ def fetch(self) -> ActivityInstance: :returns: The fetched ActivityInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ActivityInstance( self._version, @@ -227,9 +230,12 @@ async def fetch_async(self) -> ActivityInstance: :returns: The fetched ActivityInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ActivityInstance( @@ -249,16 +255,20 @@ def update( :returns: The updated ActivityInstance """ + data = values.of( { "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ActivityInstance( @@ -278,16 +288,20 @@ async def update_async( :returns: The updated ActivityInstance """ + data = values.of( { "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ActivityInstance( @@ -364,11 +378,14 @@ def create( "Available": serialize.boolean_to_string(available), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ActivityInstance( @@ -393,11 +410,14 @@ async def create_async( "Available": serialize.boolean_to_string(available), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ActivityInstance( @@ -565,7 +585,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ActivityPage(self._version, response, self._solution) async def page_async( @@ -598,8 +624,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ActivityPage(self._version, response, self._solution) diff --git a/twilio/rest/taskrouter/v1/workspace/event.py b/twilio/rest/taskrouter/v1/workspace/event.py index 534d9cd120..1b7f289e5e 100644 --- a/twilio/rest/taskrouter/v1/workspace/event.py +++ b/twilio/rest/taskrouter/v1/workspace/event.py @@ -149,10 +149,11 @@ def fetch(self) -> EventInstance: :returns: The fetched EventInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return EventInstance( self._version, @@ -169,9 +170,12 @@ async def fetch_async(self) -> EventInstance: :returns: The fetched EventInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return EventInstance( @@ -526,7 +530,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return EventPage(self._version, response, self._solution) async def page_async( @@ -586,8 +596,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return EventPage(self._version, response, self._solution) diff --git a/twilio/rest/taskrouter/v1/workspace/task/__init__.py b/twilio/rest/taskrouter/v1/workspace/task/__init__.py index f5c306b65a..2c4516df77 100644 --- a/twilio/rest/taskrouter/v1/workspace/task/__init__.py +++ b/twilio/rest/taskrouter/v1/workspace/task/__init__.py @@ -56,6 +56,8 @@ 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 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 """ def __init__( @@ -105,6 +107,8 @@ def __init__( self.virtual_start_time: Optional[datetime] = deserialize.iso8601_datetime( payload.get("virtual_start_time") ) + self.ignore_capacity: Optional[bool] = payload.get("ignore_capacity") + self.routing_target: Optional[str] = payload.get("routing_target") self._solution = { "workspace_sid": workspace_sid, @@ -189,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 """ @@ -222,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 """ @@ -288,6 +292,8 @@ def delete(self, if_match: Union[str, object] = values.unset) -> bool: } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self, if_match: Union[str, object] = values.unset) -> bool: @@ -304,6 +310,8 @@ async def delete_async(self, if_match: Union[str, object] = values.unset) -> boo } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -316,10 +324,11 @@ def fetch(self) -> TaskInstance: :returns: The fetched TaskInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return TaskInstance( self._version, @@ -336,9 +345,12 @@ async def fetch_async(self) -> TaskInstance: :returns: The fetched TaskInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return TaskInstance( @@ -367,10 +379,11 @@ 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 """ + data = values.of( { "Attributes": attributes, @@ -381,11 +394,16 @@ def update( "VirtualStartTime": serialize.iso8601_datetime(virtual_start_time), } ) - headers = values.of( - { - "If-Match": if_match, - } - ) + headers = values.of({}) + + if not ( + if_match is values.unset or (isinstance(if_match, str) and not if_match) + ): + headers["If-Match"] = if_match + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( method="POST", uri=self._uri, data=data, headers=headers @@ -417,10 +435,11 @@ 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 """ + data = values.of( { "Attributes": attributes, @@ -431,11 +450,16 @@ async def update_async( "VirtualStartTime": serialize.iso8601_datetime(virtual_start_time), } ) - headers = values.of( - { - "If-Match": if_match, - } - ) + headers = values.of({}) + + if not ( + if_match is values.unset or (isinstance(if_match, str) and not if_match) + ): + headers["If-Match"] = if_match + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( method="POST", uri=self._uri, data=data, headers=headers @@ -518,6 +542,9 @@ def create( workflow_sid: Union[str, object] = values.unset, attributes: Union[str, object] = values.unset, virtual_start_time: Union[datetime, object] = values.unset, + routing_target: Union[str, object] = values.unset, + ignore_capacity: Union[str, object] = values.unset, + task_queue_sid: Union[str, object] = values.unset, ) -> TaskInstance: """ Create the TaskInstance @@ -527,7 +554,10 @@ 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 :returns: The created TaskInstance """ @@ -540,13 +570,19 @@ def create( "WorkflowSid": workflow_sid, "Attributes": attributes, "VirtualStartTime": serialize.iso8601_datetime(virtual_start_time), + "RoutingTarget": routing_target, + "IgnoreCapacity": ignore_capacity, + "TaskQueueSid": task_queue_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TaskInstance( @@ -561,6 +597,9 @@ async def create_async( workflow_sid: Union[str, object] = values.unset, attributes: Union[str, object] = values.unset, virtual_start_time: Union[datetime, object] = values.unset, + routing_target: Union[str, object] = values.unset, + ignore_capacity: Union[str, object] = values.unset, + task_queue_sid: Union[str, object] = values.unset, ) -> TaskInstance: """ Asynchronously create the TaskInstance @@ -570,7 +609,10 @@ 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 :returns: The created TaskInstance """ @@ -583,13 +625,19 @@ async def create_async( "WorkflowSid": workflow_sid, "Attributes": attributes, "VirtualStartTime": serialize.iso8601_datetime(virtual_start_time), + "RoutingTarget": routing_target, + "IgnoreCapacity": ignore_capacity, + "TaskQueueSid": task_queue_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TaskInstance( @@ -605,6 +653,7 @@ def stream( task_queue_sid: Union[str, object] = values.unset, task_queue_name: Union[str, object] = values.unset, evaluate_task_attributes: Union[str, object] = values.unset, + routing_target: Union[str, object] = values.unset, ordering: Union[str, object] = values.unset, has_addons: Union[bool, object] = values.unset, limit: Optional[int] = None, @@ -623,6 +672,7 @@ def stream( :param str task_queue_sid: The SID of the TaskQueue with the Tasks to read. Returns the Tasks waiting in the TaskQueue identified by this SID. :param str task_queue_name: The `friendly_name` of the TaskQueue with the Tasks to read. Returns the Tasks waiting in the TaskQueue identified by this friendly name. :param str evaluate_task_attributes: The attributes of the Tasks to read. Returns the Tasks that match the attributes specified in this parameter. + :param str routing_target: A SID of a Worker, Queue, or Workflow to route a Task to :param str ordering: How to order the returned Task resources. By default, Tasks are sorted by ascending DateCreated. This value is specified as: `Attribute:Order`, where `Attribute` can be either `DateCreated`, `Priority`, or `VirtualStartTime` and `Order` can be either `asc` or `desc`. For example, `Priority:desc` returns Tasks ordered in descending order of their Priority. Pairings of sort orders can be specified in a comma-separated list such as `Priority:desc,DateCreated:asc`, which returns the Tasks in descending Priority order and ascending DateCreated Order. The only ordering pairing not allowed is DateCreated and VirtualStartTime. :param bool has_addons: Whether to read Tasks with Add-ons. If `true`, returns only Tasks with Add-ons. If `false`, returns only Tasks without Add-ons. :param limit: Upper limit for the number of records to return. stream() @@ -643,6 +693,7 @@ def stream( task_queue_sid=task_queue_sid, task_queue_name=task_queue_name, evaluate_task_attributes=evaluate_task_attributes, + routing_target=routing_target, ordering=ordering, has_addons=has_addons, page_size=limits["page_size"], @@ -659,6 +710,7 @@ async def stream_async( task_queue_sid: Union[str, object] = values.unset, task_queue_name: Union[str, object] = values.unset, evaluate_task_attributes: Union[str, object] = values.unset, + routing_target: Union[str, object] = values.unset, ordering: Union[str, object] = values.unset, has_addons: Union[bool, object] = values.unset, limit: Optional[int] = None, @@ -677,6 +729,7 @@ async def stream_async( :param str task_queue_sid: The SID of the TaskQueue with the Tasks to read. Returns the Tasks waiting in the TaskQueue identified by this SID. :param str task_queue_name: The `friendly_name` of the TaskQueue with the Tasks to read. Returns the Tasks waiting in the TaskQueue identified by this friendly name. :param str evaluate_task_attributes: The attributes of the Tasks to read. Returns the Tasks that match the attributes specified in this parameter. + :param str routing_target: A SID of a Worker, Queue, or Workflow to route a Task to :param str ordering: How to order the returned Task resources. By default, Tasks are sorted by ascending DateCreated. This value is specified as: `Attribute:Order`, where `Attribute` can be either `DateCreated`, `Priority`, or `VirtualStartTime` and `Order` can be either `asc` or `desc`. For example, `Priority:desc` returns Tasks ordered in descending order of their Priority. Pairings of sort orders can be specified in a comma-separated list such as `Priority:desc,DateCreated:asc`, which returns the Tasks in descending Priority order and ascending DateCreated Order. The only ordering pairing not allowed is DateCreated and VirtualStartTime. :param bool has_addons: Whether to read Tasks with Add-ons. If `true`, returns only Tasks with Add-ons. If `false`, returns only Tasks without Add-ons. :param limit: Upper limit for the number of records to return. stream() @@ -697,6 +750,7 @@ async def stream_async( task_queue_sid=task_queue_sid, task_queue_name=task_queue_name, evaluate_task_attributes=evaluate_task_attributes, + routing_target=routing_target, ordering=ordering, has_addons=has_addons, page_size=limits["page_size"], @@ -713,6 +767,7 @@ def list( task_queue_sid: Union[str, object] = values.unset, task_queue_name: Union[str, object] = values.unset, evaluate_task_attributes: Union[str, object] = values.unset, + routing_target: Union[str, object] = values.unset, ordering: Union[str, object] = values.unset, has_addons: Union[bool, object] = values.unset, limit: Optional[int] = None, @@ -730,6 +785,7 @@ def list( :param str task_queue_sid: The SID of the TaskQueue with the Tasks to read. Returns the Tasks waiting in the TaskQueue identified by this SID. :param str task_queue_name: The `friendly_name` of the TaskQueue with the Tasks to read. Returns the Tasks waiting in the TaskQueue identified by this friendly name. :param str evaluate_task_attributes: The attributes of the Tasks to read. Returns the Tasks that match the attributes specified in this parameter. + :param str routing_target: A SID of a Worker, Queue, or Workflow to route a Task to :param str ordering: How to order the returned Task resources. By default, Tasks are sorted by ascending DateCreated. This value is specified as: `Attribute:Order`, where `Attribute` can be either `DateCreated`, `Priority`, or `VirtualStartTime` and `Order` can be either `asc` or `desc`. For example, `Priority:desc` returns Tasks ordered in descending order of their Priority. Pairings of sort orders can be specified in a comma-separated list such as `Priority:desc,DateCreated:asc`, which returns the Tasks in descending Priority order and ascending DateCreated Order. The only ordering pairing not allowed is DateCreated and VirtualStartTime. :param bool has_addons: Whether to read Tasks with Add-ons. If `true`, returns only Tasks with Add-ons. If `false`, returns only Tasks without Add-ons. :param limit: Upper limit for the number of records to return. list() guarantees @@ -750,6 +806,7 @@ def list( task_queue_sid=task_queue_sid, task_queue_name=task_queue_name, evaluate_task_attributes=evaluate_task_attributes, + routing_target=routing_target, ordering=ordering, has_addons=has_addons, limit=limit, @@ -766,6 +823,7 @@ async def list_async( task_queue_sid: Union[str, object] = values.unset, task_queue_name: Union[str, object] = values.unset, evaluate_task_attributes: Union[str, object] = values.unset, + routing_target: Union[str, object] = values.unset, ordering: Union[str, object] = values.unset, has_addons: Union[bool, object] = values.unset, limit: Optional[int] = None, @@ -783,6 +841,7 @@ async def list_async( :param str task_queue_sid: The SID of the TaskQueue with the Tasks to read. Returns the Tasks waiting in the TaskQueue identified by this SID. :param str task_queue_name: The `friendly_name` of the TaskQueue with the Tasks to read. Returns the Tasks waiting in the TaskQueue identified by this friendly name. :param str evaluate_task_attributes: The attributes of the Tasks to read. Returns the Tasks that match the attributes specified in this parameter. + :param str routing_target: A SID of a Worker, Queue, or Workflow to route a Task to :param str ordering: How to order the returned Task resources. By default, Tasks are sorted by ascending DateCreated. This value is specified as: `Attribute:Order`, where `Attribute` can be either `DateCreated`, `Priority`, or `VirtualStartTime` and `Order` can be either `asc` or `desc`. For example, `Priority:desc` returns Tasks ordered in descending order of their Priority. Pairings of sort orders can be specified in a comma-separated list such as `Priority:desc,DateCreated:asc`, which returns the Tasks in descending Priority order and ascending DateCreated Order. The only ordering pairing not allowed is DateCreated and VirtualStartTime. :param bool has_addons: Whether to read Tasks with Add-ons. If `true`, returns only Tasks with Add-ons. If `false`, returns only Tasks without Add-ons. :param limit: Upper limit for the number of records to return. list() guarantees @@ -804,6 +863,7 @@ async def list_async( task_queue_sid=task_queue_sid, task_queue_name=task_queue_name, evaluate_task_attributes=evaluate_task_attributes, + routing_target=routing_target, ordering=ordering, has_addons=has_addons, limit=limit, @@ -820,6 +880,7 @@ def page( task_queue_sid: Union[str, object] = values.unset, task_queue_name: Union[str, object] = values.unset, evaluate_task_attributes: Union[str, object] = values.unset, + routing_target: Union[str, object] = values.unset, ordering: Union[str, object] = values.unset, has_addons: Union[bool, object] = values.unset, page_token: Union[str, object] = values.unset, @@ -837,6 +898,7 @@ def page( :param task_queue_sid: The SID of the TaskQueue with the Tasks to read. Returns the Tasks waiting in the TaskQueue identified by this SID. :param task_queue_name: The `friendly_name` of the TaskQueue with the Tasks to read. Returns the Tasks waiting in the TaskQueue identified by this friendly name. :param evaluate_task_attributes: The attributes of the Tasks to read. Returns the Tasks that match the attributes specified in this parameter. + :param routing_target: A SID of a Worker, Queue, or Workflow to route a Task to :param ordering: How to order the returned Task resources. By default, Tasks are sorted by ascending DateCreated. This value is specified as: `Attribute:Order`, where `Attribute` can be either `DateCreated`, `Priority`, or `VirtualStartTime` and `Order` can be either `asc` or `desc`. For example, `Priority:desc` returns Tasks ordered in descending order of their Priority. Pairings of sort orders can be specified in a comma-separated list such as `Priority:desc,DateCreated:asc`, which returns the Tasks in descending Priority order and ascending DateCreated Order. The only ordering pairing not allowed is DateCreated and VirtualStartTime. :param has_addons: Whether to read Tasks with Add-ons. If `true`, returns only Tasks with Add-ons. If `false`, returns only Tasks without Add-ons. :param page_token: PageToken provided by the API @@ -854,6 +916,7 @@ def page( "TaskQueueSid": task_queue_sid, "TaskQueueName": task_queue_name, "EvaluateTaskAttributes": evaluate_task_attributes, + "RoutingTarget": routing_target, "Ordering": ordering, "HasAddons": serialize.boolean_to_string(has_addons), "PageToken": page_token, @@ -862,7 +925,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return TaskPage(self._version, response, self._solution) async def page_async( @@ -874,6 +943,7 @@ async def page_async( task_queue_sid: Union[str, object] = values.unset, task_queue_name: Union[str, object] = values.unset, evaluate_task_attributes: Union[str, object] = values.unset, + routing_target: Union[str, object] = values.unset, ordering: Union[str, object] = values.unset, has_addons: Union[bool, object] = values.unset, page_token: Union[str, object] = values.unset, @@ -891,6 +961,7 @@ async def page_async( :param task_queue_sid: The SID of the TaskQueue with the Tasks to read. Returns the Tasks waiting in the TaskQueue identified by this SID. :param task_queue_name: The `friendly_name` of the TaskQueue with the Tasks to read. Returns the Tasks waiting in the TaskQueue identified by this friendly name. :param evaluate_task_attributes: The attributes of the Tasks to read. Returns the Tasks that match the attributes specified in this parameter. + :param routing_target: A SID of a Worker, Queue, or Workflow to route a Task to :param ordering: How to order the returned Task resources. By default, Tasks are sorted by ascending DateCreated. This value is specified as: `Attribute:Order`, where `Attribute` can be either `DateCreated`, `Priority`, or `VirtualStartTime` and `Order` can be either `asc` or `desc`. For example, `Priority:desc` returns Tasks ordered in descending order of their Priority. Pairings of sort orders can be specified in a comma-separated list such as `Priority:desc,DateCreated:asc`, which returns the Tasks in descending Priority order and ascending DateCreated Order. The only ordering pairing not allowed is DateCreated and VirtualStartTime. :param has_addons: Whether to read Tasks with Add-ons. If `true`, returns only Tasks with Add-ons. If `false`, returns only Tasks without Add-ons. :param page_token: PageToken provided by the API @@ -908,6 +979,7 @@ async def page_async( "TaskQueueSid": task_queue_sid, "TaskQueueName": task_queue_name, "EvaluateTaskAttributes": evaluate_task_attributes, + "RoutingTarget": routing_target, "Ordering": ordering, "HasAddons": serialize.boolean_to_string(has_addons), "PageToken": page_token, @@ -916,8 +988,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return TaskPage(self._version, response, self._solution) diff --git a/twilio/rest/taskrouter/v1/workspace/task/reservation.py b/twilio/rest/taskrouter/v1/workspace/task/reservation.py index 50b1ed1273..28cb03339a 100644 --- a/twilio/rest/taskrouter/v1/workspace/task/reservation.py +++ b/twilio/rest/taskrouter/v1/workspace/task/reservation.py @@ -250,7 +250,7 @@ def update( :param recording_status_callback_method: The HTTP method we should use when we call `recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. :param conference_recording_status_callback: The URL we should call using the `conference_recording_status_callback_method` when the conference recording is available. :param conference_recording_status_callback_method: The HTTP method we should use to call `conference_recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. - :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. + :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `us2`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. :param sip_auth_username: The SIP username used for authentication. :param sip_auth_password: The SIP password for authentication. :param dequeue_status_callback_event: The Call progress events sent via webhooks as a result of a Dequeue instruction. @@ -433,7 +433,7 @@ async def update_async( :param recording_status_callback_method: The HTTP method we should use when we call `recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. :param conference_recording_status_callback: The URL we should call using the `conference_recording_status_callback_method` when the conference recording is available. :param conference_recording_status_callback_method: The HTTP method we should use to call `conference_recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. - :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. + :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `us2`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. :param sip_auth_username: The SIP username used for authentication. :param sip_auth_password: The SIP password for authentication. :param dequeue_status_callback_event: The Call progress events sent via webhooks as a result of a Dequeue instruction. @@ -547,10 +547,11 @@ def fetch(self) -> ReservationInstance: :returns: The fetched ReservationInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ReservationInstance( self._version, @@ -568,9 +569,12 @@ async def fetch_async(self) -> ReservationInstance: :returns: The fetched ReservationInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ReservationInstance( @@ -693,7 +697,7 @@ def update( :param recording_status_callback_method: The HTTP method we should use when we call `recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. :param conference_recording_status_callback: The URL we should call using the `conference_recording_status_callback_method` when the conference recording is available. :param conference_recording_status_callback_method: The HTTP method we should use to call `conference_recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. - :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. + :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `us2`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. :param sip_auth_username: The SIP username used for authentication. :param sip_auth_password: The SIP password for authentication. :param dequeue_status_callback_event: The Call progress events sent via webhooks as a result of a Dequeue instruction. @@ -706,6 +710,7 @@ def update( :returns: The updated ReservationInstance """ + data = values.of( { "ReservationStatus": reservation_status, @@ -778,11 +783,16 @@ def update( "JitterBufferSize": jitter_buffer_size, } ) - headers = values.of( - { - "If-Match": if_match, - } - ) + headers = values.of({}) + + if not ( + if_match is values.unset or (isinstance(if_match, str) and not if_match) + ): + headers["If-Match"] = if_match + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( method="POST", uri=self._uri, data=data, headers=headers @@ -908,7 +918,7 @@ async def update_async( :param recording_status_callback_method: The HTTP method we should use when we call `recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. :param conference_recording_status_callback: The URL we should call using the `conference_recording_status_callback_method` when the conference recording is available. :param conference_recording_status_callback_method: The HTTP method we should use to call `conference_recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. - :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. + :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `us2`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. :param sip_auth_username: The SIP username used for authentication. :param sip_auth_password: The SIP password for authentication. :param dequeue_status_callback_event: The Call progress events sent via webhooks as a result of a Dequeue instruction. @@ -921,6 +931,7 @@ async def update_async( :returns: The updated ReservationInstance """ + data = values.of( { "ReservationStatus": reservation_status, @@ -993,11 +1004,16 @@ async def update_async( "JitterBufferSize": jitter_buffer_size, } ) - headers = values.of( - { - "If-Match": if_match, - } - ) + headers = values.of({}) + + if not ( + if_match is values.unset or (isinstance(if_match, str) and not if_match) + ): + headers["If-Match"] = if_match + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( method="POST", uri=self._uri, data=data, headers=headers @@ -1228,7 +1244,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ReservationPage(self._version, response, self._solution) async def page_async( @@ -1261,8 +1283,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ReservationPage(self._version, response, self._solution) diff --git a/twilio/rest/taskrouter/v1/workspace/task_channel.py b/twilio/rest/taskrouter/v1/workspace/task_channel.py index 099f85efb1..3a4b0a6b9e 100644 --- a/twilio/rest/taskrouter/v1/workspace/task_channel.py +++ b/twilio/rest/taskrouter/v1/workspace/task_channel.py @@ -194,10 +194,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -206,9 +206,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> TaskChannelInstance: @@ -219,10 +221,11 @@ def fetch(self) -> TaskChannelInstance: :returns: The fetched TaskChannelInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return TaskChannelInstance( self._version, @@ -239,9 +242,12 @@ async def fetch_async(self) -> TaskChannelInstance: :returns: The fetched TaskChannelInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return TaskChannelInstance( @@ -264,6 +270,7 @@ def update( :returns: The updated TaskChannelInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -272,11 +279,14 @@ def update( ), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TaskChannelInstance( @@ -299,6 +309,7 @@ async def update_async( :returns: The updated TaskChannelInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -307,11 +318,14 @@ async def update_async( ), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TaskChannelInstance( @@ -395,11 +409,14 @@ def create( ), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TaskChannelInstance( @@ -431,11 +448,14 @@ async def create_async( ), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TaskChannelInstance( @@ -569,7 +589,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return TaskChannelPage(self._version, response, self._solution) async def page_async( @@ -596,8 +622,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return TaskChannelPage(self._version, response, self._solution) diff --git a/twilio/rest/taskrouter/v1/workspace/task_queue/__init__.py b/twilio/rest/taskrouter/v1/workspace/task_queue/__init__.py index 794fd216d3..4511a55310 100644 --- a/twilio/rest/taskrouter/v1/workspace/task_queue/__init__.py +++ b/twilio/rest/taskrouter/v1/workspace/task_queue/__init__.py @@ -283,10 +283,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -295,9 +295,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> TaskQueueInstance: @@ -308,10 +310,11 @@ def fetch(self) -> TaskQueueInstance: :returns: The fetched TaskQueueInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return TaskQueueInstance( self._version, @@ -328,9 +331,12 @@ async def fetch_async(self) -> TaskQueueInstance: :returns: The fetched TaskQueueInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return TaskQueueInstance( @@ -361,6 +367,7 @@ def update( :returns: The updated TaskQueueInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -371,11 +378,14 @@ def update( "TaskOrder": task_order, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TaskQueueInstance( @@ -406,6 +416,7 @@ async def update_async( :returns: The updated TaskQueueInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -416,11 +427,14 @@ async def update_async( "TaskOrder": task_order, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TaskQueueInstance( @@ -555,11 +569,14 @@ def create( "AssignmentActivitySid": assignment_activity_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TaskQueueInstance( @@ -598,11 +615,14 @@ async def create_async( "AssignmentActivitySid": assignment_activity_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TaskQueueInstance( @@ -800,7 +820,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return TaskQueuePage(self._version, response, self._solution) async def page_async( @@ -839,8 +865,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return TaskQueuePage(self._version, response, self._solution) diff --git a/twilio/rest/taskrouter/v1/workspace/task_queue/task_queue_bulk_real_time_statistics.py b/twilio/rest/taskrouter/v1/workspace/task_queue/task_queue_bulk_real_time_statistics.py index 0556e6bb4a..90400c7930 100644 --- a/twilio/rest/taskrouter/v1/workspace/task_queue/task_queue_bulk_real_time_statistics.py +++ b/twilio/rest/taskrouter/v1/workspace/task_queue/task_queue_bulk_real_time_statistics.py @@ -92,7 +92,12 @@ def create( """ data = body.to_dict() - headers = {"Content-Type": "application/json"} + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + payload = self._version.create( method="POST", uri=self._uri, data=data, headers=headers ) @@ -111,9 +116,13 @@ async def create_async( :returns: The created TaskQueueBulkRealTimeStatisticsInstance """ - data = body.to_dict() - headers = {"Content-Type": "application/json"} + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" payload = await self._version.create_async( method="POST", uri=self._uri, data=data, headers=headers diff --git a/twilio/rest/taskrouter/v1/workspace/task_queue/task_queue_cumulative_statistics.py b/twilio/rest/taskrouter/v1/workspace/task_queue/task_queue_cumulative_statistics.py index acb8b79a29..ef851c755a 100644 --- a/twilio/rest/taskrouter/v1/workspace/task_queue/task_queue_cumulative_statistics.py +++ b/twilio/rest/taskrouter/v1/workspace/task_queue/task_queue_cumulative_statistics.py @@ -254,7 +254,13 @@ def fetch( } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=data) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) return TaskQueueCumulativeStatisticsInstance( self._version, @@ -293,8 +299,12 @@ async def fetch_async( } ) + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return TaskQueueCumulativeStatisticsInstance( 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 faca804702..c4eb30ddc0 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. @@ -182,7 +182,13 @@ def fetch( } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=data) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) return TaskQueueRealTimeStatisticsInstance( self._version, @@ -208,8 +214,12 @@ async def fetch_async( } ) + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return TaskQueueRealTimeStatisticsInstance( diff --git a/twilio/rest/taskrouter/v1/workspace/task_queue/task_queue_statistics.py b/twilio/rest/taskrouter/v1/workspace/task_queue/task_queue_statistics.py index 2a09f62a68..2d5d631069 100644 --- a/twilio/rest/taskrouter/v1/workspace/task_queue/task_queue_statistics.py +++ b/twilio/rest/taskrouter/v1/workspace/task_queue/task_queue_statistics.py @@ -186,7 +186,13 @@ def fetch( } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=data) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) return TaskQueueStatisticsInstance( self._version, @@ -225,8 +231,12 @@ async def fetch_async( } ) + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return TaskQueueStatisticsInstance( diff --git a/twilio/rest/taskrouter/v1/workspace/task_queue/task_queues_statistics.py b/twilio/rest/taskrouter/v1/workspace/task_queue/task_queues_statistics.py index bec2d81b40..036f6ad92b 100644 --- a/twilio/rest/taskrouter/v1/workspace/task_queue/task_queues_statistics.py +++ b/twilio/rest/taskrouter/v1/workspace/task_queue/task_queues_statistics.py @@ -316,7 +316,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return TaskQueuesStatisticsPage(self._version, response, self._solution) async def page_async( @@ -361,8 +367,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return TaskQueuesStatisticsPage(self._version, response, self._solution) diff --git a/twilio/rest/taskrouter/v1/workspace/worker/__init__.py b/twilio/rest/taskrouter/v1/workspace/worker/__init__.py index a236fcae8d..38aede84bb 100644 --- a/twilio/rest/taskrouter/v1/workspace/worker/__init__.py +++ b/twilio/rest/taskrouter/v1/workspace/worker/__init__.py @@ -268,6 +268,8 @@ def delete(self, if_match: Union[str, object] = values.unset) -> bool: } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self, if_match: Union[str, object] = values.unset) -> bool: @@ -284,6 +286,8 @@ async def delete_async(self, if_match: Union[str, object] = values.unset) -> boo } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -296,10 +300,11 @@ def fetch(self) -> WorkerInstance: :returns: The fetched WorkerInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return WorkerInstance( self._version, @@ -316,9 +321,12 @@ async def fetch_async(self) -> WorkerInstance: :returns: The fetched WorkerInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return WorkerInstance( @@ -347,6 +355,7 @@ def update( :returns: The updated WorkerInstance """ + data = values.of( { "ActivitySid": activity_sid, @@ -357,11 +366,16 @@ def update( ), } ) - headers = values.of( - { - "If-Match": if_match, - } - ) + headers = values.of({}) + + if not ( + if_match is values.unset or (isinstance(if_match, str) and not if_match) + ): + headers["If-Match"] = if_match + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( method="POST", uri=self._uri, data=data, headers=headers @@ -393,6 +407,7 @@ async def update_async( :returns: The updated WorkerInstance """ + data = values.of( { "ActivitySid": activity_sid, @@ -403,11 +418,16 @@ async def update_async( ), } ) - headers = values.of( - { - "If-Match": if_match, - } - ) + headers = values.of({}) + + if not ( + if_match is values.unset or (isinstance(if_match, str) and not if_match) + ): + headers["If-Match"] = if_match + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( method="POST", uri=self._uri, data=data, headers=headers @@ -535,11 +555,14 @@ def create( "Attributes": attributes, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WorkerInstance( @@ -569,11 +592,14 @@ async def create_async( "Attributes": attributes, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WorkerInstance( @@ -831,7 +857,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return WorkerPage(self._version, response, self._solution) async def page_async( @@ -882,8 +914,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return WorkerPage(self._version, response, self._solution) diff --git a/twilio/rest/taskrouter/v1/workspace/worker/reservation.py b/twilio/rest/taskrouter/v1/workspace/worker/reservation.py index b7dc4bca9e..7f24057806 100644 --- a/twilio/rest/taskrouter/v1/workspace/worker/reservation.py +++ b/twilio/rest/taskrouter/v1/workspace/worker/reservation.py @@ -241,7 +241,7 @@ def update( :param recording_status_callback_method: The HTTP method we should use when we call `recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. :param conference_recording_status_callback: The URL we should call using the `conference_recording_status_callback_method` when the conference recording is available. :param conference_recording_status_callback_method: The HTTP method we should use to call `conference_recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. - :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. + :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `us2`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. :param sip_auth_username: The SIP username used for authentication. :param sip_auth_password: The SIP password for authentication. :param dequeue_status_callback_event: The call progress events sent via webhooks as a result of a Dequeue instruction. @@ -416,7 +416,7 @@ async def update_async( :param recording_status_callback_method: The HTTP method we should use when we call `recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. :param conference_recording_status_callback: The URL we should call using the `conference_recording_status_callback_method` when the conference recording is available. :param conference_recording_status_callback_method: The HTTP method we should use to call `conference_recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. - :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. + :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `us2`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. :param sip_auth_username: The SIP username used for authentication. :param sip_auth_password: The SIP password for authentication. :param dequeue_status_callback_event: The call progress events sent via webhooks as a result of a Dequeue instruction. @@ -524,10 +524,11 @@ def fetch(self) -> ReservationInstance: :returns: The fetched ReservationInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ReservationInstance( self._version, @@ -545,9 +546,12 @@ async def fetch_async(self) -> ReservationInstance: :returns: The fetched ReservationInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ReservationInstance( @@ -666,7 +670,7 @@ def update( :param recording_status_callback_method: The HTTP method we should use when we call `recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. :param conference_recording_status_callback: The URL we should call using the `conference_recording_status_callback_method` when the conference recording is available. :param conference_recording_status_callback_method: The HTTP method we should use to call `conference_recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. - :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. + :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `us2`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. :param sip_auth_username: The SIP username used for authentication. :param sip_auth_password: The SIP password for authentication. :param dequeue_status_callback_event: The call progress events sent via webhooks as a result of a Dequeue instruction. @@ -677,6 +681,7 @@ def update( :returns: The updated ReservationInstance """ + data = values.of( { "ReservationStatus": reservation_status, @@ -747,11 +752,16 @@ def update( "JitterBufferSize": jitter_buffer_size, } ) - headers = values.of( - { - "If-Match": if_match, - } - ) + headers = values.of({}) + + if not ( + if_match is values.unset or (isinstance(if_match, str) and not if_match) + ): + headers["If-Match"] = if_match + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( method="POST", uri=self._uri, data=data, headers=headers @@ -873,7 +883,7 @@ async def update_async( :param recording_status_callback_method: The HTTP method we should use when we call `recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. :param conference_recording_status_callback: The URL we should call using the `conference_recording_status_callback_method` when the conference recording is available. :param conference_recording_status_callback_method: The HTTP method we should use to call `conference_recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. - :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. + :param region: The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `us2`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`. :param sip_auth_username: The SIP username used for authentication. :param sip_auth_password: The SIP password for authentication. :param dequeue_status_callback_event: The call progress events sent via webhooks as a result of a Dequeue instruction. @@ -884,6 +894,7 @@ async def update_async( :returns: The updated ReservationInstance """ + data = values.of( { "ReservationStatus": reservation_status, @@ -954,11 +965,16 @@ async def update_async( "JitterBufferSize": jitter_buffer_size, } ) - headers = values.of( - { - "If-Match": if_match, - } - ) + headers = values.of({}) + + if not ( + if_match is values.unset or (isinstance(if_match, str) and not if_match) + ): + headers["If-Match"] = if_match + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( method="POST", uri=self._uri, data=data, headers=headers @@ -1174,7 +1190,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ReservationPage(self._version, response, self._solution) async def page_async( @@ -1204,8 +1226,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ReservationPage(self._version, response, self._solution) diff --git a/twilio/rest/taskrouter/v1/workspace/worker/worker_channel.py b/twilio/rest/taskrouter/v1/workspace/worker/worker_channel.py index f48ebb3a62..6e3cc9c1dd 100644 --- a/twilio/rest/taskrouter/v1/workspace/worker/worker_channel.py +++ b/twilio/rest/taskrouter/v1/workspace/worker/worker_channel.py @@ -196,10 +196,11 @@ def fetch(self) -> WorkerChannelInstance: :returns: The fetched WorkerChannelInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return WorkerChannelInstance( self._version, @@ -217,9 +218,12 @@ async def fetch_async(self) -> WorkerChannelInstance: :returns: The fetched WorkerChannelInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return WorkerChannelInstance( @@ -243,17 +247,21 @@ def update( :returns: The updated WorkerChannelInstance """ + data = values.of( { "Capacity": capacity, "Available": serialize.boolean_to_string(available), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WorkerChannelInstance( @@ -277,17 +285,21 @@ async def update_async( :returns: The updated WorkerChannelInstance """ + data = values.of( { "Capacity": capacity, "Available": serialize.boolean_to_string(available), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WorkerChannelInstance( @@ -481,7 +493,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return WorkerChannelPage(self._version, response, self._solution) async def page_async( @@ -508,8 +526,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return WorkerChannelPage(self._version, response, self._solution) diff --git a/twilio/rest/taskrouter/v1/workspace/worker/worker_statistics.py b/twilio/rest/taskrouter/v1/workspace/worker/worker_statistics.py index 61618d2961..eea670aa7d 100644 --- a/twilio/rest/taskrouter/v1/workspace/worker/worker_statistics.py +++ b/twilio/rest/taskrouter/v1/workspace/worker/worker_statistics.py @@ -175,7 +175,13 @@ def fetch( } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=data) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) return WorkerStatisticsInstance( self._version, @@ -211,8 +217,12 @@ async def fetch_async( } ) + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return WorkerStatisticsInstance( diff --git a/twilio/rest/taskrouter/v1/workspace/worker/workers_cumulative_statistics.py b/twilio/rest/taskrouter/v1/workspace/worker/workers_cumulative_statistics.py index b18e7f123b..48a78710e2 100644 --- a/twilio/rest/taskrouter/v1/workspace/worker/workers_cumulative_statistics.py +++ b/twilio/rest/taskrouter/v1/workspace/worker/workers_cumulative_statistics.py @@ -197,7 +197,13 @@ def fetch( } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=data) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) return WorkersCumulativeStatisticsInstance( self._version, @@ -232,8 +238,12 @@ async def fetch_async( } ) + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return WorkersCumulativeStatisticsInstance( diff --git a/twilio/rest/taskrouter/v1/workspace/worker/workers_real_time_statistics.py b/twilio/rest/taskrouter/v1/workspace/worker/workers_real_time_statistics.py index 277889ae7a..2e9970478e 100644 --- a/twilio/rest/taskrouter/v1/workspace/worker/workers_real_time_statistics.py +++ b/twilio/rest/taskrouter/v1/workspace/worker/workers_real_time_statistics.py @@ -138,7 +138,13 @@ def fetch( } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=data) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) return WorkersRealTimeStatisticsInstance( self._version, @@ -163,8 +169,12 @@ async def fetch_async( } ) + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return WorkersRealTimeStatisticsInstance( diff --git a/twilio/rest/taskrouter/v1/workspace/worker/workers_statistics.py b/twilio/rest/taskrouter/v1/workspace/worker/workers_statistics.py index 0cd09ec124..31c79ee6ba 100644 --- a/twilio/rest/taskrouter/v1/workspace/worker/workers_statistics.py +++ b/twilio/rest/taskrouter/v1/workspace/worker/workers_statistics.py @@ -190,7 +190,13 @@ def fetch( } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=data) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) return WorkersStatisticsInstance( self._version, @@ -234,8 +240,12 @@ async def fetch_async( } ) + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return WorkersStatisticsInstance( diff --git a/twilio/rest/taskrouter/v1/workspace/workflow/__init__.py b/twilio/rest/taskrouter/v1/workspace/workflow/__init__.py index f01e76d379..619ae1bce9 100644 --- a/twilio/rest/taskrouter/v1/workspace/workflow/__init__.py +++ b/twilio/rest/taskrouter/v1/workspace/workflow/__init__.py @@ -262,10 +262,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -274,9 +274,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> WorkflowInstance: @@ -287,10 +289,11 @@ def fetch(self) -> WorkflowInstance: :returns: The fetched WorkflowInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return WorkflowInstance( self._version, @@ -307,9 +310,12 @@ async def fetch_async(self) -> WorkflowInstance: :returns: The fetched WorkflowInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return WorkflowInstance( @@ -340,6 +346,7 @@ def update( :returns: The updated WorkflowInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -350,11 +357,14 @@ def update( "ReEvaluateTasks": re_evaluate_tasks, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WorkflowInstance( @@ -385,6 +395,7 @@ async def update_async( :returns: The updated WorkflowInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -395,11 +406,14 @@ async def update_async( "ReEvaluateTasks": re_evaluate_tasks, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WorkflowInstance( @@ -526,11 +540,14 @@ def create( "TaskReservationTimeout": task_reservation_timeout, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WorkflowInstance( @@ -566,11 +583,14 @@ async def create_async( "TaskReservationTimeout": task_reservation_timeout, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WorkflowInstance( @@ -719,7 +739,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return WorkflowPage(self._version, response, self._solution) async def page_async( @@ -749,8 +775,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return WorkflowPage(self._version, response, self._solution) diff --git a/twilio/rest/taskrouter/v1/workspace/workflow/workflow_cumulative_statistics.py b/twilio/rest/taskrouter/v1/workspace/workflow/workflow_cumulative_statistics.py index e06cab0114..d6d7c094cc 100644 --- a/twilio/rest/taskrouter/v1/workspace/workflow/workflow_cumulative_statistics.py +++ b/twilio/rest/taskrouter/v1/workspace/workflow/workflow_cumulative_statistics.py @@ -254,7 +254,13 @@ def fetch( } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=data) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) return WorkflowCumulativeStatisticsInstance( self._version, @@ -293,8 +299,12 @@ async def fetch_async( } ) + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return WorkflowCumulativeStatisticsInstance( diff --git a/twilio/rest/taskrouter/v1/workspace/workflow/workflow_real_time_statistics.py b/twilio/rest/taskrouter/v1/workspace/workflow/workflow_real_time_statistics.py index 415d4223e4..9387622518 100644 --- a/twilio/rest/taskrouter/v1/workspace/workflow/workflow_real_time_statistics.py +++ b/twilio/rest/taskrouter/v1/workspace/workflow/workflow_real_time_statistics.py @@ -162,7 +162,13 @@ def fetch( } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=data) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) return WorkflowRealTimeStatisticsInstance( self._version, @@ -188,8 +194,12 @@ async def fetch_async( } ) + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return WorkflowRealTimeStatisticsInstance( diff --git a/twilio/rest/taskrouter/v1/workspace/workflow/workflow_statistics.py b/twilio/rest/taskrouter/v1/workspace/workflow/workflow_statistics.py index f86590e40f..e49bd32d6e 100644 --- a/twilio/rest/taskrouter/v1/workspace/workflow/workflow_statistics.py +++ b/twilio/rest/taskrouter/v1/workspace/workflow/workflow_statistics.py @@ -186,7 +186,13 @@ def fetch( } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=data) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) return WorkflowStatisticsInstance( self._version, @@ -225,8 +231,12 @@ async def fetch_async( } ) + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return WorkflowStatisticsInstance( diff --git a/twilio/rest/taskrouter/v1/workspace/workspace_cumulative_statistics.py b/twilio/rest/taskrouter/v1/workspace/workspace_cumulative_statistics.py index 2b223641ae..3747b395d2 100644 --- a/twilio/rest/taskrouter/v1/workspace/workspace_cumulative_statistics.py +++ b/twilio/rest/taskrouter/v1/workspace/workspace_cumulative_statistics.py @@ -242,7 +242,13 @@ def fetch( } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=data) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) return WorkspaceCumulativeStatisticsInstance( self._version, @@ -280,8 +286,12 @@ async def fetch_async( } ) + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return WorkspaceCumulativeStatisticsInstance( diff --git a/twilio/rest/taskrouter/v1/workspace/workspace_real_time_statistics.py b/twilio/rest/taskrouter/v1/workspace/workspace_real_time_statistics.py index 35b50c0b21..923a94bf3a 100644 --- a/twilio/rest/taskrouter/v1/workspace/workspace_real_time_statistics.py +++ b/twilio/rest/taskrouter/v1/workspace/workspace_real_time_statistics.py @@ -158,7 +158,13 @@ def fetch( } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=data) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) return WorkspaceRealTimeStatisticsInstance( self._version, @@ -183,8 +189,12 @@ async def fetch_async( } ) + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return WorkspaceRealTimeStatisticsInstance( diff --git a/twilio/rest/taskrouter/v1/workspace/workspace_statistics.py b/twilio/rest/taskrouter/v1/workspace/workspace_statistics.py index 19eb885675..b8414a5c6c 100644 --- a/twilio/rest/taskrouter/v1/workspace/workspace_statistics.py +++ b/twilio/rest/taskrouter/v1/workspace/workspace_statistics.py @@ -170,7 +170,13 @@ def fetch( } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=data) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) return WorkspaceStatisticsInstance( self._version, @@ -208,8 +214,12 @@ async def fetch_async( } ) + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return WorkspaceStatisticsInstance( diff --git a/twilio/rest/trunking/v1/trunk/__init__.py b/twilio/rest/trunking/v1/trunk/__init__.py index 16125ead02..6a93a83233 100644 --- a/twilio/rest/trunking/v1/trunk/__init__.py +++ b/twilio/rest/trunking/v1/trunk/__init__.py @@ -298,10 +298,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -310,9 +310,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> TrunkInstance: @@ -323,10 +325,11 @@ def fetch(self) -> TrunkInstance: :returns: The fetched TrunkInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return TrunkInstance( self._version, @@ -342,9 +345,12 @@ async def fetch_async(self) -> TrunkInstance: :returns: The fetched TrunkInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return TrunkInstance( @@ -380,6 +386,7 @@ def update( :returns: The updated TrunkInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -392,11 +399,14 @@ def update( "TransferCallerId": transfer_caller_id, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TrunkInstance(self._version, payload, sid=self._solution["sid"]) @@ -428,6 +438,7 @@ async def update_async( :returns: The updated TrunkInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -440,11 +451,14 @@ async def update_async( "TransferCallerId": transfer_caller_id, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TrunkInstance(self._version, payload, sid=self._solution["sid"]) @@ -591,11 +605,14 @@ def create( "TransferCallerId": transfer_caller_id, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TrunkInstance(self._version, payload) @@ -640,11 +657,14 @@ async def create_async( "TransferCallerId": transfer_caller_id, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TrunkInstance(self._version, payload) @@ -776,7 +796,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return TrunkPage(self._version, response) async def page_async( @@ -803,8 +829,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return TrunkPage(self._version, response) diff --git a/twilio/rest/trunking/v1/trunk/credential_list.py b/twilio/rest/trunking/v1/trunk/credential_list.py index 7dc043d286..09ffc99260 100644 --- a/twilio/rest/trunking/v1/trunk/credential_list.py +++ b/twilio/rest/trunking/v1/trunk/credential_list.py @@ -148,10 +148,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -160,9 +160,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> CredentialListInstance: @@ -173,10 +175,11 @@ def fetch(self) -> CredentialListInstance: :returns: The fetched CredentialListInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return CredentialListInstance( self._version, @@ -193,9 +196,12 @@ async def fetch_async(self) -> CredentialListInstance: :returns: The fetched CredentialListInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return CredentialListInstance( @@ -268,11 +274,14 @@ def create(self, credential_list_sid: str) -> CredentialListInstance: "CredentialListSid": credential_list_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CredentialListInstance( @@ -293,11 +302,14 @@ async def create_async(self, credential_list_sid: str) -> CredentialListInstance "CredentialListSid": credential_list_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CredentialListInstance( @@ -431,7 +443,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return CredentialListPage(self._version, response, self._solution) async def page_async( @@ -458,8 +476,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return CredentialListPage(self._version, response, self._solution) diff --git a/twilio/rest/trunking/v1/trunk/ip_access_control_list.py b/twilio/rest/trunking/v1/trunk/ip_access_control_list.py index b361e7fe9f..ec5a59de69 100644 --- a/twilio/rest/trunking/v1/trunk/ip_access_control_list.py +++ b/twilio/rest/trunking/v1/trunk/ip_access_control_list.py @@ -150,10 +150,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -162,9 +162,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> IpAccessControlListInstance: @@ -175,10 +177,11 @@ def fetch(self) -> IpAccessControlListInstance: :returns: The fetched IpAccessControlListInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return IpAccessControlListInstance( self._version, @@ -195,9 +198,12 @@ async def fetch_async(self) -> IpAccessControlListInstance: :returns: The fetched IpAccessControlListInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return IpAccessControlListInstance( @@ -270,11 +276,14 @@ def create(self, ip_access_control_list_sid: str) -> IpAccessControlListInstance "IpAccessControlListSid": ip_access_control_list_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return IpAccessControlListInstance( @@ -297,11 +306,14 @@ async def create_async( "IpAccessControlListSid": ip_access_control_list_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return IpAccessControlListInstance( @@ -435,7 +447,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return IpAccessControlListPage(self._version, response, self._solution) async def page_async( @@ -462,8 +480,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return IpAccessControlListPage(self._version, response, self._solution) diff --git a/twilio/rest/trunking/v1/trunk/origination_url.py b/twilio/rest/trunking/v1/trunk/origination_url.py index bcf0c5205f..082fa34beb 100644 --- a/twilio/rest/trunking/v1/trunk/origination_url.py +++ b/twilio/rest/trunking/v1/trunk/origination_url.py @@ -210,10 +210,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -222,9 +222,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> OriginationUrlInstance: @@ -235,10 +237,11 @@ def fetch(self) -> OriginationUrlInstance: :returns: The fetched OriginationUrlInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return OriginationUrlInstance( self._version, @@ -255,9 +258,12 @@ async def fetch_async(self) -> OriginationUrlInstance: :returns: The fetched OriginationUrlInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return OriginationUrlInstance( @@ -286,6 +292,7 @@ def update( :returns: The updated OriginationUrlInstance """ + data = values.of( { "Weight": weight, @@ -295,11 +302,14 @@ def update( "SipUrl": sip_url, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return OriginationUrlInstance( @@ -328,6 +338,7 @@ async def update_async( :returns: The updated OriginationUrlInstance """ + data = values.of( { "Weight": weight, @@ -337,11 +348,14 @@ async def update_async( "SipUrl": sip_url, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return OriginationUrlInstance( @@ -429,11 +443,14 @@ def create( "SipUrl": sip_url, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return OriginationUrlInstance( @@ -469,11 +486,14 @@ async def create_async( "SipUrl": sip_url, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return OriginationUrlInstance( @@ -607,7 +627,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return OriginationUrlPage(self._version, response, self._solution) async def page_async( @@ -634,8 +660,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return OriginationUrlPage(self._version, response, self._solution) diff --git a/twilio/rest/trunking/v1/trunk/phone_number.py b/twilio/rest/trunking/v1/trunk/phone_number.py index 7f0adbeef1..a7c3dbe20d 100644 --- a/twilio/rest/trunking/v1/trunk/phone_number.py +++ b/twilio/rest/trunking/v1/trunk/phone_number.py @@ -199,10 +199,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -211,9 +211,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> PhoneNumberInstance: @@ -224,10 +226,11 @@ def fetch(self) -> PhoneNumberInstance: :returns: The fetched PhoneNumberInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return PhoneNumberInstance( self._version, @@ -244,9 +247,12 @@ async def fetch_async(self) -> PhoneNumberInstance: :returns: The fetched PhoneNumberInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return PhoneNumberInstance( @@ -319,11 +325,14 @@ def create(self, phone_number_sid: str) -> PhoneNumberInstance: "PhoneNumberSid": phone_number_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return PhoneNumberInstance( @@ -344,11 +353,14 @@ async def create_async(self, phone_number_sid: str) -> PhoneNumberInstance: "PhoneNumberSid": phone_number_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return PhoneNumberInstance( @@ -482,7 +494,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return PhoneNumberPage(self._version, response, self._solution) async def page_async( @@ -509,8 +527,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return PhoneNumberPage(self._version, response, self._solution) diff --git a/twilio/rest/trunking/v1/trunk/recording.py b/twilio/rest/trunking/v1/trunk/recording.py index 1a431b496b..0507662f24 100644 --- a/twilio/rest/trunking/v1/trunk/recording.py +++ b/twilio/rest/trunking/v1/trunk/recording.py @@ -153,10 +153,11 @@ def fetch(self) -> RecordingInstance: :returns: The fetched RecordingInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return RecordingInstance( self._version, @@ -172,9 +173,12 @@ async def fetch_async(self) -> RecordingInstance: :returns: The fetched RecordingInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return RecordingInstance( @@ -196,17 +200,21 @@ def update( :returns: The updated RecordingInstance """ + data = values.of( { "Mode": mode, "Trim": trim, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RecordingInstance( @@ -226,17 +234,21 @@ async def update_async( :returns: The updated RecordingInstance """ + data = values.of( { "Mode": mode, "Trim": trim, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RecordingInstance( diff --git a/twilio/rest/trusthub/v1/compliance_inquiries.py b/twilio/rest/trusthub/v1/compliance_inquiries.py index b1b52a4f78..3c1abd596a 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,24 +122,32 @@ 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, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ComplianceInquiriesInstance( @@ -141,25 +155,31 @@ 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, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ComplianceInquiriesInstance( @@ -193,12 +213,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,13 +229,17 @@ def create( { "PrimaryProfileSid": primary_profile_sid, "NotificationEmail": notification_email, + "ThemeSetId": theme_set_id, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ComplianceInquiriesInstance(self._version, payload) @@ -222,12 +248,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 """ @@ -236,13 +264,17 @@ 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"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ComplianceInquiriesInstance(self._version, payload) diff --git a/twilio/rest/trusthub/v1/compliance_registration_inquiries.py b/twilio/rest/trusthub/v1/compliance_registration_inquiries.py index d86b72db01..eccd1ac8cf 100644 --- a/twilio/rest/trusthub/v1/compliance_registration_inquiries.py +++ b/twilio/rest/trusthub/v1/compliance_registration_inquiries.py @@ -14,7 +14,7 @@ from typing import Any, Dict, Optional, Union from twilio.base import serialize, values - +from twilio.base.instance_context import InstanceContext from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.version import Version @@ -51,7 +51,12 @@ class PhoneNumberType(object): :ivar url: The URL of this resource. """ - def __init__(self, version: Version, payload: Dict[str, Any]): + def __init__( + self, + version: Version, + payload: Dict[str, Any], + registration_id: Optional[str] = None, + ): super().__init__(version) self.inquiry_id: Optional[str] = payload.get("inquiry_id") @@ -59,14 +64,171 @@ def __init__(self, version: Version, payload: Dict[str, Any]): self.registration_id: Optional[str] = payload.get("registration_id") self.url: Optional[str] = payload.get("url") + self._solution = { + "registration_id": registration_id or self.registration_id, + } + self._context: Optional[ComplianceRegistrationInquiriesContext] = None + + @property + def _proxy(self) -> "ComplianceRegistrationInquiriesContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: ComplianceRegistrationInquiriesContext for this ComplianceRegistrationInquiriesInstance + """ + if self._context is None: + self._context = ComplianceRegistrationInquiriesContext( + self._version, + registration_id=self._solution["registration_id"], + ) + return self._context + + def update( + self, + is_isv_embed: Union[bool, object] = values.unset, + theme_set_id: Union[str, object] = values.unset, + ) -> "ComplianceRegistrationInquiriesInstance": + """ + Update the ComplianceRegistrationInquiriesInstance + + :param is_isv_embed: Indicates if the inquiry is being started from an ISV embedded component. + :param theme_set_id: Theme id for styling the inquiry form. + + :returns: The updated ComplianceRegistrationInquiriesInstance + """ + return self._proxy.update( + is_isv_embed=is_isv_embed, + theme_set_id=theme_set_id, + ) + + async def update_async( + self, + is_isv_embed: Union[bool, object] = values.unset, + theme_set_id: Union[str, object] = values.unset, + ) -> "ComplianceRegistrationInquiriesInstance": + """ + Asynchronous coroutine to update the ComplianceRegistrationInquiriesInstance + + :param is_isv_embed: Indicates if the inquiry is being started from an ISV embedded component. + :param theme_set_id: Theme id for styling the inquiry form. + + :returns: The updated ComplianceRegistrationInquiriesInstance + """ + return await self._proxy.update_async( + is_isv_embed=is_isv_embed, + theme_set_id=theme_set_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 ComplianceRegistrationInquiriesContext(InstanceContext): + + def __init__(self, version: Version, registration_id: str): + """ + Initialize the ComplianceRegistrationInquiriesContext + + :param version: Version that contains the resource + :param registration_id: The unique RegistrationId matching the Regulatory Compliance Inquiry that should be resumed or resubmitted. This value will have been returned by the initial Regulatory Compliance Inquiry creation call. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "registration_id": registration_id, + } + self._uri = "/ComplianceInquiries/Registration/{registration_id}/RegulatoryCompliance/GB/Initialize".format( + **self._solution + ) + + def update( + self, + is_isv_embed: Union[bool, object] = values.unset, + theme_set_id: Union[str, object] = values.unset, + ) -> ComplianceRegistrationInquiriesInstance: + """ + Update the ComplianceRegistrationInquiriesInstance + + :param is_isv_embed: Indicates if the inquiry is being started from an ISV embedded component. + :param theme_set_id: Theme id for styling the inquiry form. + + :returns: The updated ComplianceRegistrationInquiriesInstance + """ + + data = values.of( + { + "IsIsvEmbed": serialize.boolean_to_string(is_isv_embed), + "ThemeSetId": theme_set_id, + } + ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = self._version.update( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return ComplianceRegistrationInquiriesInstance( + self._version, payload, registration_id=self._solution["registration_id"] + ) + + async def update_async( + self, + is_isv_embed: Union[bool, object] = values.unset, + theme_set_id: Union[str, object] = values.unset, + ) -> ComplianceRegistrationInquiriesInstance: + """ + Asynchronous coroutine to update the ComplianceRegistrationInquiriesInstance - return "" + :param is_isv_embed: Indicates if the inquiry is being started from an ISV embedded component. + :param theme_set_id: Theme id for styling the inquiry form. + + :returns: The updated ComplianceRegistrationInquiriesInstance + """ + + data = values.of( + { + "IsIsvEmbed": serialize.boolean_to_string(is_isv_embed), + "ThemeSetId": theme_set_id, + } + ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + payload = await self._version.update_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return ComplianceRegistrationInquiriesInstance( + self._version, payload, registration_id=self._solution["registration_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 ComplianceRegistrationInquiriesList(ListResource): @@ -129,6 +291,7 @@ def create( is_isv_embed: Union[bool, object] = values.unset, isv_registering_for_self_or_tenant: Union[str, object] = values.unset, status_callback_url: Union[str, object] = values.unset, + theme_set_id: Union[str, object] = values.unset, ) -> ComplianceRegistrationInquiriesInstance: """ Create the ComplianceRegistrationInquiriesInstance @@ -171,6 +334,7 @@ def create( :param is_isv_embed: Indicates if the inquiry is being started from an ISV embedded component. :param isv_registering_for_self_or_tenant: Indicates if the isv registering for self or tenant. :param status_callback_url: The url we call to inform you of bundle changes. + :param theme_set_id: Theme id for styling the inquiry form. :returns: The created ComplianceRegistrationInquiriesInstance """ @@ -219,13 +383,17 @@ def create( "IsIsvEmbed": serialize.boolean_to_string(is_isv_embed), "IsvRegisteringForSelfOrTenant": isv_registering_for_self_or_tenant, "StatusCallbackUrl": status_callback_url, + "ThemeSetId": theme_set_id, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ComplianceRegistrationInquiriesInstance(self._version, payload) @@ -275,6 +443,7 @@ async def create_async( is_isv_embed: Union[bool, object] = values.unset, isv_registering_for_self_or_tenant: Union[str, object] = values.unset, status_callback_url: Union[str, object] = values.unset, + theme_set_id: Union[str, object] = values.unset, ) -> ComplianceRegistrationInquiriesInstance: """ Asynchronously create the ComplianceRegistrationInquiriesInstance @@ -317,6 +486,7 @@ async def create_async( :param is_isv_embed: Indicates if the inquiry is being started from an ISV embedded component. :param isv_registering_for_self_or_tenant: Indicates if the isv registering for self or tenant. :param status_callback_url: The url we call to inform you of bundle changes. + :param theme_set_id: Theme id for styling the inquiry form. :returns: The created ComplianceRegistrationInquiriesInstance """ @@ -365,17 +535,41 @@ async def create_async( "IsIsvEmbed": serialize.boolean_to_string(is_isv_embed), "IsvRegisteringForSelfOrTenant": isv_registering_for_self_or_tenant, "StatusCallbackUrl": status_callback_url, + "ThemeSetId": theme_set_id, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ComplianceRegistrationInquiriesInstance(self._version, payload) + def get(self, registration_id: str) -> ComplianceRegistrationInquiriesContext: + """ + Constructs a ComplianceRegistrationInquiriesContext + + :param registration_id: The unique RegistrationId matching the Regulatory Compliance Inquiry that should be resumed or resubmitted. This value will have been returned by the initial Regulatory Compliance Inquiry creation call. + """ + return ComplianceRegistrationInquiriesContext( + self._version, registration_id=registration_id + ) + + def __call__(self, registration_id: str) -> ComplianceRegistrationInquiriesContext: + """ + Constructs a ComplianceRegistrationInquiriesContext + + :param registration_id: The unique RegistrationId matching the Regulatory Compliance Inquiry that should be resumed or resubmitted. This value will have been returned by the initial Regulatory Compliance Inquiry creation call. + """ + return ComplianceRegistrationInquiriesContext( + self._version, registration_id=registration_id + ) + def __repr__(self) -> str: """ Provide a friendly representation diff --git a/twilio/rest/trusthub/v1/compliance_tollfree_inquiries.py b/twilio/rest/trusthub/v1/compliance_tollfree_inquiries.py index 6c9d5b3d9b..9cf259a318 100644 --- a/twilio/rest/trusthub/v1/compliance_tollfree_inquiries.py +++ b/twilio/rest/trusthub/v1/compliance_tollfree_inquiries.py @@ -92,6 +92,8 @@ def create( business_contact_last_name: Union[str, object] = values.unset, business_contact_email: Union[str, object] = values.unset, business_contact_phone: Union[str, object] = values.unset, + theme_set_id: Union[str, object] = values.unset, + skip_messaging_use_case: Union[bool, object] = values.unset, ) -> ComplianceTollfreeInquiriesInstance: """ Create the ComplianceTollfreeInquiriesInstance @@ -117,6 +119,8 @@ def create( :param business_contact_last_name: The last name of the contact for the business or organization using the Tollfree number. :param business_contact_email: The email address of the contact for the business or organization using the Tollfree number. :param business_contact_phone: The phone number of the contact for the business or organization using the Tollfree number. + :param theme_set_id: Theme id for styling the inquiry form. + :param skip_messaging_use_case: Skip the messaging use case screen of the inquiry form. :returns: The created ComplianceTollfreeInquiriesInstance """ @@ -144,13 +148,20 @@ def create( "BusinessContactLastName": business_contact_last_name, "BusinessContactEmail": business_contact_email, "BusinessContactPhone": business_contact_phone, + "ThemeSetId": theme_set_id, + "SkipMessagingUseCase": serialize.boolean_to_string( + skip_messaging_use_case + ), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ComplianceTollfreeInquiriesInstance(self._version, payload) @@ -180,6 +191,8 @@ async def create_async( business_contact_last_name: Union[str, object] = values.unset, business_contact_email: Union[str, object] = values.unset, business_contact_phone: Union[str, object] = values.unset, + theme_set_id: Union[str, object] = values.unset, + skip_messaging_use_case: Union[bool, object] = values.unset, ) -> ComplianceTollfreeInquiriesInstance: """ Asynchronously create the ComplianceTollfreeInquiriesInstance @@ -205,6 +218,8 @@ async def create_async( :param business_contact_last_name: The last name of the contact for the business or organization using the Tollfree number. :param business_contact_email: The email address of the contact for the business or organization using the Tollfree number. :param business_contact_phone: The phone number of the contact for the business or organization using the Tollfree number. + :param theme_set_id: Theme id for styling the inquiry form. + :param skip_messaging_use_case: Skip the messaging use case screen of the inquiry form. :returns: The created ComplianceTollfreeInquiriesInstance """ @@ -232,13 +247,20 @@ async def create_async( "BusinessContactLastName": business_contact_last_name, "BusinessContactEmail": business_contact_email, "BusinessContactPhone": business_contact_phone, + "ThemeSetId": theme_set_id, + "SkipMessagingUseCase": serialize.boolean_to_string( + skip_messaging_use_case + ), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ComplianceTollfreeInquiriesInstance(self._version, payload) diff --git a/twilio/rest/trusthub/v1/customer_profiles/__init__.py b/twilio/rest/trusthub/v1/customer_profiles/__init__.py index a16ae0e73b..bf5264e31d 100644 --- a/twilio/rest/trusthub/v1/customer_profiles/__init__.py +++ b/twilio/rest/trusthub/v1/customer_profiles/__init__.py @@ -53,6 +53,7 @@ class Status(object): :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 absolute URL of the Customer-Profile resource. :ivar links: The URLs of the Assigned Items of the Customer-Profile resource. + :ivar errors: The error codes associated with the rejection of the Customer-Profile. """ def __init__( @@ -78,6 +79,7 @@ def __init__( ) self.url: Optional[str] = payload.get("url") self.links: Optional[Dict[str, object]] = payload.get("links") + self.errors: Optional[List[Dict[str, object]]] = payload.get("errors") self._solution = { "sid": sid or self.sid, @@ -252,10 +254,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -264,9 +266,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> CustomerProfilesInstance: @@ -277,10 +281,11 @@ def fetch(self) -> CustomerProfilesInstance: :returns: The fetched CustomerProfilesInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return CustomerProfilesInstance( self._version, @@ -296,9 +301,12 @@ async def fetch_async(self) -> CustomerProfilesInstance: :returns: The fetched CustomerProfilesInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return CustomerProfilesInstance( @@ -324,6 +332,7 @@ def update( :returns: The updated CustomerProfilesInstance """ + data = values.of( { "Status": status, @@ -332,11 +341,14 @@ def update( "Email": email, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CustomerProfilesInstance( @@ -360,6 +372,7 @@ async def update_async( :returns: The updated CustomerProfilesInstance """ + data = values.of( { "Status": status, @@ -368,11 +381,14 @@ async def update_async( "Email": email, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CustomerProfilesInstance( @@ -491,11 +507,14 @@ def create( "StatusCallback": status_callback, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CustomerProfilesInstance(self._version, payload) @@ -526,11 +545,14 @@ async def create_async( "StatusCallback": status_callback, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CustomerProfilesInstance(self._version, payload) @@ -711,7 +733,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return CustomerProfilesPage(self._version, response) async def page_async( @@ -747,8 +775,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return CustomerProfilesPage(self._version, response) diff --git a/twilio/rest/trusthub/v1/customer_profiles/customer_profiles_channel_endpoint_assignment.py b/twilio/rest/trusthub/v1/customer_profiles/customer_profiles_channel_endpoint_assignment.py index 4cb14c5ccd..1adca541a8 100644 --- a/twilio/rest/trusthub/v1/customer_profiles/customer_profiles_channel_endpoint_assignment.py +++ b/twilio/rest/trusthub/v1/customer_profiles/customer_profiles_channel_endpoint_assignment.py @@ -150,10 +150,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -162,9 +162,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> CustomerProfilesChannelEndpointAssignmentInstance: @@ -175,10 +177,11 @@ def fetch(self) -> CustomerProfilesChannelEndpointAssignmentInstance: :returns: The fetched CustomerProfilesChannelEndpointAssignmentInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return CustomerProfilesChannelEndpointAssignmentInstance( self._version, @@ -195,9 +198,12 @@ async def fetch_async(self) -> CustomerProfilesChannelEndpointAssignmentInstance :returns: The fetched CustomerProfilesChannelEndpointAssignmentInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return CustomerProfilesChannelEndpointAssignmentInstance( @@ -282,11 +288,14 @@ def create( "ChannelEndpointSid": channel_endpoint_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CustomerProfilesChannelEndpointAssignmentInstance( @@ -313,11 +322,14 @@ async def create_async( "ChannelEndpointSid": channel_endpoint_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CustomerProfilesChannelEndpointAssignmentInstance( @@ -487,7 +499,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return CustomerProfilesChannelEndpointAssignmentPage( self._version, response, self._solution ) @@ -522,8 +540,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return CustomerProfilesChannelEndpointAssignmentPage( self._version, response, self._solution diff --git a/twilio/rest/trusthub/v1/customer_profiles/customer_profiles_entity_assignments.py b/twilio/rest/trusthub/v1/customer_profiles/customer_profiles_entity_assignments.py index 5a19ccaabe..f8710b9cd8 100644 --- a/twilio/rest/trusthub/v1/customer_profiles/customer_profiles_entity_assignments.py +++ b/twilio/rest/trusthub/v1/customer_profiles/customer_profiles_entity_assignments.py @@ -152,10 +152,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -164,9 +164,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> CustomerProfilesEntityAssignmentsInstance: @@ -177,10 +179,11 @@ def fetch(self) -> CustomerProfilesEntityAssignmentsInstance: :returns: The fetched CustomerProfilesEntityAssignmentsInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return CustomerProfilesEntityAssignmentsInstance( self._version, @@ -197,9 +200,12 @@ async def fetch_async(self) -> CustomerProfilesEntityAssignmentsInstance: :returns: The fetched CustomerProfilesEntityAssignmentsInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return CustomerProfilesEntityAssignmentsInstance( @@ -282,11 +288,14 @@ def create(self, object_sid: str) -> CustomerProfilesEntityAssignmentsInstance: "ObjectSid": object_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CustomerProfilesEntityAssignmentsInstance( @@ -311,11 +320,14 @@ async def create_async( "ObjectSid": object_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CustomerProfilesEntityAssignmentsInstance( @@ -466,7 +478,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return CustomerProfilesEntityAssignmentsPage( self._version, response, self._solution ) @@ -498,8 +516,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return CustomerProfilesEntityAssignmentsPage( self._version, response, self._solution diff --git a/twilio/rest/trusthub/v1/customer_profiles/customer_profiles_evaluations.py b/twilio/rest/trusthub/v1/customer_profiles/customer_profiles_evaluations.py index 60538ee22e..648467aac6 100644 --- a/twilio/rest/trusthub/v1/customer_profiles/customer_profiles_evaluations.py +++ b/twilio/rest/trusthub/v1/customer_profiles/customer_profiles_evaluations.py @@ -142,10 +142,11 @@ def fetch(self) -> CustomerProfilesEvaluationsInstance: :returns: The fetched CustomerProfilesEvaluationsInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return CustomerProfilesEvaluationsInstance( self._version, @@ -162,9 +163,12 @@ async def fetch_async(self) -> CustomerProfilesEvaluationsInstance: :returns: The fetched CustomerProfilesEvaluationsInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return CustomerProfilesEvaluationsInstance( @@ -245,11 +249,14 @@ def create(self, policy_sid: str) -> CustomerProfilesEvaluationsInstance: "PolicySid": policy_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CustomerProfilesEvaluationsInstance( @@ -274,11 +281,14 @@ async def create_async( "PolicySid": policy_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CustomerProfilesEvaluationsInstance( @@ -414,7 +424,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return CustomerProfilesEvaluationsPage(self._version, response, self._solution) async def page_async( @@ -441,8 +457,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return CustomerProfilesEvaluationsPage(self._version, response, self._solution) diff --git a/twilio/rest/trusthub/v1/end_user.py b/twilio/rest/trusthub/v1/end_user.py index b8b08d65ca..5ce3b819d9 100644 --- a/twilio/rest/trusthub/v1/end_user.py +++ b/twilio/rest/trusthub/v1/end_user.py @@ -178,10 +178,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -190,9 +190,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> EndUserInstance: @@ -203,10 +205,11 @@ def fetch(self) -> EndUserInstance: :returns: The fetched EndUserInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return EndUserInstance( self._version, @@ -222,9 +225,12 @@ async def fetch_async(self) -> EndUserInstance: :returns: The fetched EndUserInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return EndUserInstance( @@ -246,17 +252,21 @@ def update( :returns: The updated EndUserInstance """ + data = values.of( { "FriendlyName": friendly_name, "Attributes": serialize.object(attributes), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return EndUserInstance(self._version, payload, sid=self._solution["sid"]) @@ -274,17 +284,21 @@ async def update_async( :returns: The updated EndUserInstance """ + data = values.of( { "FriendlyName": friendly_name, "Attributes": serialize.object(attributes), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return EndUserInstance(self._version, payload, sid=self._solution["sid"]) @@ -354,11 +368,14 @@ def create( "Attributes": serialize.object(attributes), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return EndUserInstance(self._version, payload) @@ -386,11 +403,14 @@ async def create_async( "Attributes": serialize.object(attributes), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return EndUserInstance(self._version, payload) @@ -522,7 +542,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return EndUserPage(self._version, response) async def page_async( @@ -549,8 +575,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return EndUserPage(self._version, response) diff --git a/twilio/rest/trusthub/v1/end_user_type.py b/twilio/rest/trusthub/v1/end_user_type.py index d336385b25..0eb2957e0a 100644 --- a/twilio/rest/trusthub/v1/end_user_type.py +++ b/twilio/rest/trusthub/v1/end_user_type.py @@ -114,10 +114,11 @@ def fetch(self) -> EndUserTypeInstance: :returns: The fetched EndUserTypeInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return EndUserTypeInstance( self._version, @@ -133,9 +134,12 @@ async def fetch_async(self) -> EndUserTypeInstance: :returns: The fetched EndUserTypeInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return EndUserTypeInstance( @@ -313,7 +317,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return EndUserTypePage(self._version, response) async def page_async( @@ -340,8 +350,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return EndUserTypePage(self._version, response) diff --git a/twilio/rest/trusthub/v1/policies.py b/twilio/rest/trusthub/v1/policies.py index a39b1e0e65..36a0916c51 100644 --- a/twilio/rest/trusthub/v1/policies.py +++ b/twilio/rest/trusthub/v1/policies.py @@ -112,10 +112,11 @@ def fetch(self) -> PoliciesInstance: :returns: The fetched PoliciesInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return PoliciesInstance( self._version, @@ -131,9 +132,12 @@ async def fetch_async(self) -> PoliciesInstance: :returns: The fetched PoliciesInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return PoliciesInstance( @@ -311,7 +315,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return PoliciesPage(self._version, response) async def page_async( @@ -338,8 +348,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return PoliciesPage(self._version, response) diff --git a/twilio/rest/trusthub/v1/supporting_document.py b/twilio/rest/trusthub/v1/supporting_document.py index a18293fd8e..f2fd3b7e1c 100644 --- a/twilio/rest/trusthub/v1/supporting_document.py +++ b/twilio/rest/trusthub/v1/supporting_document.py @@ -25,12 +25,12 @@ class SupportingDocumentInstance(InstanceResource): class Status(object): - DRAFT = "draft" - PENDING_REVIEW = "pending-review" - REJECTED = "rejected" - APPROVED = "approved" - EXPIRED = "expired" - PROVISIONALLY_APPROVED = "provisionally-approved" + DRAFT = "DRAFT" + PENDING_REVIEW = "PENDING_REVIEW" + REJECTED = "REJECTED" + APPROVED = "APPROVED" + EXPIRED = "EXPIRED" + PROVISIONALLY_APPROVED = "PROVISIONALLY_APPROVED" """ :ivar sid: The unique string created by Twilio to identify the Supporting Document resource. @@ -193,10 +193,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -205,9 +205,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> SupportingDocumentInstance: @@ -218,10 +220,11 @@ def fetch(self) -> SupportingDocumentInstance: :returns: The fetched SupportingDocumentInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return SupportingDocumentInstance( self._version, @@ -237,9 +240,12 @@ async def fetch_async(self) -> SupportingDocumentInstance: :returns: The fetched SupportingDocumentInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return SupportingDocumentInstance( @@ -261,17 +267,21 @@ def update( :returns: The updated SupportingDocumentInstance """ + data = values.of( { "FriendlyName": friendly_name, "Attributes": serialize.object(attributes), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SupportingDocumentInstance( @@ -291,17 +301,21 @@ async def update_async( :returns: The updated SupportingDocumentInstance """ + data = values.of( { "FriendlyName": friendly_name, "Attributes": serialize.object(attributes), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SupportingDocumentInstance( @@ -373,11 +387,14 @@ def create( "Attributes": serialize.object(attributes), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SupportingDocumentInstance(self._version, payload) @@ -405,11 +422,14 @@ async def create_async( "Attributes": serialize.object(attributes), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SupportingDocumentInstance(self._version, payload) @@ -541,7 +561,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return SupportingDocumentPage(self._version, response) async def page_async( @@ -568,8 +594,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return SupportingDocumentPage(self._version, response) diff --git a/twilio/rest/trusthub/v1/supporting_document_type.py b/twilio/rest/trusthub/v1/supporting_document_type.py index f1a93c59b7..f107397a4c 100644 --- a/twilio/rest/trusthub/v1/supporting_document_type.py +++ b/twilio/rest/trusthub/v1/supporting_document_type.py @@ -114,10 +114,11 @@ def fetch(self) -> SupportingDocumentTypeInstance: :returns: The fetched SupportingDocumentTypeInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return SupportingDocumentTypeInstance( self._version, @@ -133,9 +134,12 @@ async def fetch_async(self) -> SupportingDocumentTypeInstance: :returns: The fetched SupportingDocumentTypeInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return SupportingDocumentTypeInstance( @@ -313,7 +317,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return SupportingDocumentTypePage(self._version, response) async def page_async( @@ -340,8 +350,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return SupportingDocumentTypePage(self._version, response) diff --git a/twilio/rest/trusthub/v1/trust_products/__init__.py b/twilio/rest/trusthub/v1/trust_products/__init__.py index a638f680f0..6bb01d61dc 100644 --- a/twilio/rest/trusthub/v1/trust_products/__init__.py +++ b/twilio/rest/trusthub/v1/trust_products/__init__.py @@ -41,18 +41,19 @@ class Status(object): TWILIO_APPROVED = "twilio-approved" """ - :ivar sid: The unique string that we created to identify the Customer-Profile resource. - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Customer-Profile resource. - :ivar policy_sid: The unique string of a policy that is associated to the Customer-Profile resource. + :ivar sid: The unique string that we created to identify the Trust Product resource. + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Trust Product resource. + :ivar policy_sid: The unique string of the policy that is associated with the Trust Product 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 Customer-Profile resource changes status. + :ivar valid_until: The date and time in GMT in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format until which the resource will be valid. + :ivar email: The email address that will receive updates when the Trust Product resource changes status. :ivar status_callback: The URL we call to inform your application of status changes. :ivar 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 absolute URL of the Customer-Profile resource. - :ivar links: The URLs of the Assigned Items of the Customer-Profile resource. + :ivar url: The absolute URL of the Trust Product resource. + :ivar links: The URLs of the Assigned Items of the Trust Product resource. + :ivar errors: The error codes associated with the rejection of the Trust Product. """ def __init__( @@ -78,6 +79,7 @@ def __init__( ) self.url: Optional[str] = payload.get("url") self.links: Optional[Dict[str, object]] = payload.get("links") + self.errors: Optional[List[Dict[str, object]]] = payload.get("errors") self._solution = { "sid": sid or self.sid, @@ -148,7 +150,7 @@ def update( :param status: :param status_callback: The URL we call to inform your application of status changes. :param friendly_name: The string that you assigned to describe the resource. - :param email: The email address that will receive updates when the Customer-Profile resource changes status. + :param email: The email address that will receive updates when the Trust Product resource changes status. :returns: The updated TrustProductsInstance """ @@ -172,7 +174,7 @@ async def update_async( :param status: :param status_callback: The URL we call to inform your application of status changes. :param friendly_name: The string that you assigned to describe the resource. - :param email: The email address that will receive updates when the Customer-Profile resource changes status. + :param email: The email address that will receive updates when the Trust Product resource changes status. :returns: The updated TrustProductsInstance """ @@ -223,7 +225,7 @@ def __init__(self, version: Version, sid: str): Initialize the TrustProductsContext :param version: Version that contains the resource - :param sid: The unique string that we created to identify the Customer-Profile resource. + :param sid: The unique string that we created to identify the Trust Product resource. """ super().__init__(version) @@ -248,10 +250,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -260,9 +262,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> TrustProductsInstance: @@ -273,10 +277,11 @@ def fetch(self) -> TrustProductsInstance: :returns: The fetched TrustProductsInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return TrustProductsInstance( self._version, @@ -292,9 +297,12 @@ async def fetch_async(self) -> TrustProductsInstance: :returns: The fetched TrustProductsInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return TrustProductsInstance( @@ -316,10 +324,11 @@ def update( :param status: :param status_callback: The URL we call to inform your application of status changes. :param friendly_name: The string that you assigned to describe the resource. - :param email: The email address that will receive updates when the Customer-Profile resource changes status. + :param email: The email address that will receive updates when the Trust Product resource changes status. :returns: The updated TrustProductsInstance """ + data = values.of( { "Status": status, @@ -328,11 +337,14 @@ def update( "Email": email, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TrustProductsInstance(self._version, payload, sid=self._solution["sid"]) @@ -350,10 +362,11 @@ async def update_async( :param status: :param status_callback: The URL we call to inform your application of status changes. :param friendly_name: The string that you assigned to describe the resource. - :param email: The email address that will receive updates when the Customer-Profile resource changes status. + :param email: The email address that will receive updates when the Trust Product resource changes status. :returns: The updated TrustProductsInstance """ + data = values.of( { "Status": status, @@ -362,11 +375,14 @@ async def update_async( "Email": email, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TrustProductsInstance(self._version, payload, sid=self._solution["sid"]) @@ -466,8 +482,8 @@ def create( Create the TrustProductsInstance :param friendly_name: The string that you assigned to describe the resource. - :param email: The email address that will receive updates when the Customer-Profile resource changes status. - :param policy_sid: The unique string of a policy that is associated to the Customer-Profile resource. + :param email: The email address that will receive updates when the Trust Product resource changes status. + :param policy_sid: The unique string of a policy that is associated to the Trust Product resource. :param status_callback: The URL we call to inform your application of status changes. :returns: The created TrustProductsInstance @@ -481,11 +497,14 @@ def create( "StatusCallback": status_callback, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TrustProductsInstance(self._version, payload) @@ -501,8 +520,8 @@ async def create_async( Asynchronously create the TrustProductsInstance :param friendly_name: The string that you assigned to describe the resource. - :param email: The email address that will receive updates when the Customer-Profile resource changes status. - :param policy_sid: The unique string of a policy that is associated to the Customer-Profile resource. + :param email: The email address that will receive updates when the Trust Product resource changes status. + :param policy_sid: The unique string of a policy that is associated to the Trust Product resource. :param status_callback: The URL we call to inform your application of status changes. :returns: The created TrustProductsInstance @@ -516,11 +535,14 @@ async def create_async( "StatusCallback": status_callback, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TrustProductsInstance(self._version, payload) @@ -539,9 +561,9 @@ def stream( is reached. The results are returned as a generator, so this operation is memory efficient. - :param "TrustProductsInstance.Status" status: The verification status of the Customer-Profile resource. + :param "TrustProductsInstance.Status" status: The verification status of the Trust Product resource. :param str friendly_name: The string that you assigned to describe the resource. - :param str policy_sid: The unique string of a policy that is associated to the Customer-Profile resource. + :param str policy_sid: The unique string of a policy that is associated to the Trust Product 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 @@ -575,9 +597,9 @@ async def stream_async( is reached. The results are returned as a generator, so this operation is memory efficient. - :param "TrustProductsInstance.Status" status: The verification status of the Customer-Profile resource. + :param "TrustProductsInstance.Status" status: The verification status of the Trust Product resource. :param str friendly_name: The string that you assigned to describe the resource. - :param str policy_sid: The unique string of a policy that is associated to the Customer-Profile resource. + :param str policy_sid: The unique string of a policy that is associated to the Trust Product 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 @@ -610,9 +632,9 @@ def list( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param "TrustProductsInstance.Status" status: The verification status of the Customer-Profile resource. + :param "TrustProductsInstance.Status" status: The verification status of the Trust Product resource. :param str friendly_name: The string that you assigned to describe the resource. - :param str policy_sid: The unique string of a policy that is associated to the Customer-Profile resource. + :param str policy_sid: The unique string of a policy that is associated to the Trust Product 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 @@ -645,9 +667,9 @@ async def list_async( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param "TrustProductsInstance.Status" status: The verification status of the Customer-Profile resource. + :param "TrustProductsInstance.Status" status: The verification status of the Trust Product resource. :param str friendly_name: The string that you assigned to describe the resource. - :param str policy_sid: The unique string of a policy that is associated to the Customer-Profile resource. + :param str policy_sid: The unique string of a policy that is associated to the Trust Product 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 @@ -681,9 +703,9 @@ def page( Retrieve a single page of TrustProductsInstance records from the API. Request is executed immediately - :param status: The verification status of the Customer-Profile resource. + :param status: The verification status of the Trust Product resource. :param friendly_name: The string that you assigned to describe the resource. - :param policy_sid: The unique string of a policy that is associated to the Customer-Profile resource. + :param policy_sid: The unique string of a policy that is associated to the Trust Product 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 @@ -701,7 +723,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return TrustProductsPage(self._version, response) async def page_async( @@ -717,9 +745,9 @@ async def page_async( Asynchronously retrieve a single page of TrustProductsInstance records from the API. Request is executed immediately - :param status: The verification status of the Customer-Profile resource. + :param status: The verification status of the Trust Product resource. :param friendly_name: The string that you assigned to describe the resource. - :param policy_sid: The unique string of a policy that is associated to the Customer-Profile resource. + :param policy_sid: The unique string of a policy that is associated to the Trust Product 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 @@ -737,8 +765,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return TrustProductsPage(self._version, response) @@ -770,7 +802,7 @@ def get(self, sid: str) -> TrustProductsContext: """ Constructs a TrustProductsContext - :param sid: The unique string that we created to identify the Customer-Profile resource. + :param sid: The unique string that we created to identify the Trust Product resource. """ return TrustProductsContext(self._version, sid=sid) @@ -778,7 +810,7 @@ def __call__(self, sid: str) -> TrustProductsContext: """ Constructs a TrustProductsContext - :param sid: The unique string that we created to identify the Customer-Profile resource. + :param sid: The unique string that we created to identify the Trust Product resource. """ return TrustProductsContext(self._version, sid=sid) diff --git a/twilio/rest/trusthub/v1/trust_products/trust_products_channel_endpoint_assignment.py b/twilio/rest/trusthub/v1/trust_products/trust_products_channel_endpoint_assignment.py index ef2b589ffb..adf9c51f51 100644 --- a/twilio/rest/trusthub/v1/trust_products/trust_products_channel_endpoint_assignment.py +++ b/twilio/rest/trusthub/v1/trust_products/trust_products_channel_endpoint_assignment.py @@ -150,10 +150,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -162,9 +162,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> TrustProductsChannelEndpointAssignmentInstance: @@ -175,10 +177,11 @@ def fetch(self) -> TrustProductsChannelEndpointAssignmentInstance: :returns: The fetched TrustProductsChannelEndpointAssignmentInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return TrustProductsChannelEndpointAssignmentInstance( self._version, @@ -195,9 +198,12 @@ async def fetch_async(self) -> TrustProductsChannelEndpointAssignmentInstance: :returns: The fetched TrustProductsChannelEndpointAssignmentInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return TrustProductsChannelEndpointAssignmentInstance( @@ -284,11 +290,14 @@ def create( "ChannelEndpointSid": channel_endpoint_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TrustProductsChannelEndpointAssignmentInstance( @@ -315,11 +324,14 @@ async def create_async( "ChannelEndpointSid": channel_endpoint_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TrustProductsChannelEndpointAssignmentInstance( @@ -489,7 +501,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return TrustProductsChannelEndpointAssignmentPage( self._version, response, self._solution ) @@ -524,8 +542,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return TrustProductsChannelEndpointAssignmentPage( self._version, response, self._solution diff --git a/twilio/rest/trusthub/v1/trust_products/trust_products_entity_assignments.py b/twilio/rest/trusthub/v1/trust_products/trust_products_entity_assignments.py index 16f07a8927..ebda7ee8c0 100644 --- a/twilio/rest/trusthub/v1/trust_products/trust_products_entity_assignments.py +++ b/twilio/rest/trusthub/v1/trust_products/trust_products_entity_assignments.py @@ -148,10 +148,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -160,9 +160,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> TrustProductsEntityAssignmentsInstance: @@ -173,10 +175,11 @@ def fetch(self) -> TrustProductsEntityAssignmentsInstance: :returns: The fetched TrustProductsEntityAssignmentsInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return TrustProductsEntityAssignmentsInstance( self._version, @@ -193,9 +196,12 @@ async def fetch_async(self) -> TrustProductsEntityAssignmentsInstance: :returns: The fetched TrustProductsEntityAssignmentsInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return TrustProductsEntityAssignmentsInstance( @@ -276,11 +282,14 @@ def create(self, object_sid: str) -> TrustProductsEntityAssignmentsInstance: "ObjectSid": object_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TrustProductsEntityAssignmentsInstance( @@ -305,11 +314,14 @@ async def create_async( "ObjectSid": object_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TrustProductsEntityAssignmentsInstance( @@ -460,7 +472,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return TrustProductsEntityAssignmentsPage( self._version, response, self._solution ) @@ -492,8 +510,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return TrustProductsEntityAssignmentsPage( self._version, response, self._solution diff --git a/twilio/rest/trusthub/v1/trust_products/trust_products_evaluations.py b/twilio/rest/trusthub/v1/trust_products/trust_products_evaluations.py index dfb929bac0..3691aa017b 100644 --- a/twilio/rest/trusthub/v1/trust_products/trust_products_evaluations.py +++ b/twilio/rest/trusthub/v1/trust_products/trust_products_evaluations.py @@ -142,10 +142,11 @@ def fetch(self) -> TrustProductsEvaluationsInstance: :returns: The fetched TrustProductsEvaluationsInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return TrustProductsEvaluationsInstance( self._version, @@ -162,9 +163,12 @@ async def fetch_async(self) -> TrustProductsEvaluationsInstance: :returns: The fetched TrustProductsEvaluationsInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return TrustProductsEvaluationsInstance( @@ -241,11 +245,14 @@ def create(self, policy_sid: str) -> TrustProductsEvaluationsInstance: "PolicySid": policy_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TrustProductsEvaluationsInstance( @@ -268,11 +275,14 @@ async def create_async(self, policy_sid: str) -> TrustProductsEvaluationsInstanc "PolicySid": policy_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return TrustProductsEvaluationsInstance( @@ -408,7 +418,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return TrustProductsEvaluationsPage(self._version, response, self._solution) async def page_async( @@ -435,8 +451,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return TrustProductsEvaluationsPage(self._version, response, self._solution) diff --git a/twilio/rest/verify/v2/form.py b/twilio/rest/verify/v2/form.py index 6e3231fcda..454030208d 100644 --- a/twilio/rest/verify/v2/form.py +++ b/twilio/rest/verify/v2/form.py @@ -13,6 +13,7 @@ """ 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 @@ -117,10 +118,11 @@ def fetch(self) -> FormInstance: :returns: The fetched FormInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return FormInstance( self._version, @@ -136,9 +138,12 @@ async def fetch_async(self) -> FormInstance: :returns: The fetched FormInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return FormInstance( diff --git a/twilio/rest/verify/v2/safelist.py b/twilio/rest/verify/v2/safelist.py index fb71369fb1..00fc0976f7 100644 --- a/twilio/rest/verify/v2/safelist.py +++ b/twilio/rest/verify/v2/safelist.py @@ -129,10 +129,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -141,9 +141,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> SafelistInstance: @@ -154,10 +156,11 @@ def fetch(self) -> SafelistInstance: :returns: The fetched SafelistInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return SafelistInstance( self._version, @@ -173,9 +176,12 @@ async def fetch_async(self) -> SafelistInstance: :returns: The fetched SafelistInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return SafelistInstance( @@ -221,11 +227,14 @@ def create(self, phone_number: str) -> SafelistInstance: "PhoneNumber": phone_number, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SafelistInstance(self._version, payload) @@ -244,11 +253,14 @@ async def create_async(self, phone_number: str) -> SafelistInstance: "PhoneNumber": phone_number, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SafelistInstance(self._version, payload) diff --git a/twilio/rest/verify/v2/service/__init__.py b/twilio/rest/verify/v2/service/__init__.py index 9e4d69d52b..207e8e7b53 100644 --- a/twilio/rest/verify/v2/service/__init__.py +++ b/twilio/rest/verify/v2/service/__init__.py @@ -35,7 +35,7 @@ class ServiceInstance(InstanceResource): """ :ivar sid: The unique string that we created to identify the Service resource. :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Service resource. - :ivar friendly_name: The string that you assigned to describe the verification service. It can be up to 32 characters long. **This value should not contain PII.** + :ivar friendly_name: The name that appears in the body of your verification messages. It can be up to 30 characters long and can include letters, numbers, spaces, dashes, underscores. Phone numbers, special characters or links are NOT allowed. **This value should not contain PII.** :ivar code_length: The length of the verification code to generate. :ivar lookup_enabled: Whether to perform a lookup with each verification started and return info about the phone number. :ivar psd2_enabled: Whether to pass PSD2 transaction parameters when starting a verification. @@ -43,10 +43,11 @@ 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: + :ivar whatsapp: :ivar verify_event_subscription_enabled: Whether to allow verifications from the service to reach the stream-events sinks if configured :ivar date_created: The date and time in GMT when 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 when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. @@ -79,6 +80,7 @@ def __init__( self.push: Optional[Dict[str, object]] = payload.get("push") self.totp: Optional[Dict[str, object]] = payload.get("totp") self.default_template_sid: Optional[str] = payload.get("default_template_sid") + self.whatsapp: Optional[Dict[str, object]] = payload.get("whatsapp") self.verify_event_subscription_enabled: Optional[bool] = payload.get( "verify_event_subscription_enabled" ) @@ -166,6 +168,8 @@ def update( totp_code_length: Union[int, object] = values.unset, totp_skew: Union[int, object] = values.unset, default_template_sid: Union[str, object] = values.unset, + whatsapp_msg_service_sid: Union[str, object] = values.unset, + whatsapp_from: Union[str, object] = values.unset, verify_event_subscription_enabled: Union[bool, object] = values.unset, ) -> "ServiceInstance": """ @@ -179,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) @@ -188,6 +192,8 @@ def update( :param totp_code_length: Optional configuration for the TOTP factors. Number of digits for generated TOTP codes. Must be between 3 and 8, inclusive. Defaults to 6 :param totp_skew: Optional configuration for the TOTP factors. The number of time-steps, past and future, that are valid for validation of TOTP codes. Must be between 0 and 2, inclusive. Defaults to 1 :param default_template_sid: The default message [template](https://www.twilio.com/docs/verify/api/templates). Will be used for all SMS verifications unless explicitly overriden. SMS channel only. + :param whatsapp_msg_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/services) to associate with the Verification Service. + :param whatsapp_from: The WhatsApp number to use as the sender of the verification messages. This number must be associated with the WhatsApp Message Service. :param verify_event_subscription_enabled: Whether to allow verifications from the service to reach the stream-events sinks if configured :returns: The updated ServiceInstance @@ -210,6 +216,8 @@ def update( totp_code_length=totp_code_length, totp_skew=totp_skew, default_template_sid=default_template_sid, + whatsapp_msg_service_sid=whatsapp_msg_service_sid, + whatsapp_from=whatsapp_from, verify_event_subscription_enabled=verify_event_subscription_enabled, ) @@ -232,6 +240,8 @@ async def update_async( totp_code_length: Union[int, object] = values.unset, totp_skew: Union[int, object] = values.unset, default_template_sid: Union[str, object] = values.unset, + whatsapp_msg_service_sid: Union[str, object] = values.unset, + whatsapp_from: Union[str, object] = values.unset, verify_event_subscription_enabled: Union[bool, object] = values.unset, ) -> "ServiceInstance": """ @@ -245,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) @@ -254,6 +264,8 @@ async def update_async( :param totp_code_length: Optional configuration for the TOTP factors. Number of digits for generated TOTP codes. Must be between 3 and 8, inclusive. Defaults to 6 :param totp_skew: Optional configuration for the TOTP factors. The number of time-steps, past and future, that are valid for validation of TOTP codes. Must be between 0 and 2, inclusive. Defaults to 1 :param default_template_sid: The default message [template](https://www.twilio.com/docs/verify/api/templates). Will be used for all SMS verifications unless explicitly overriden. SMS channel only. + :param whatsapp_msg_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/services) to associate with the Verification Service. + :param whatsapp_from: The WhatsApp number to use as the sender of the verification messages. This number must be associated with the WhatsApp Message Service. :param verify_event_subscription_enabled: Whether to allow verifications from the service to reach the stream-events sinks if configured :returns: The updated ServiceInstance @@ -276,6 +288,8 @@ async def update_async( totp_code_length=totp_code_length, totp_skew=totp_skew, default_template_sid=default_template_sid, + whatsapp_msg_service_sid=whatsapp_msg_service_sid, + whatsapp_from=whatsapp_from, verify_event_subscription_enabled=verify_event_subscription_enabled, ) @@ -370,10 +384,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -382,9 +396,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> ServiceInstance: @@ -395,10 +411,11 @@ def fetch(self) -> ServiceInstance: :returns: The fetched ServiceInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ServiceInstance( self._version, @@ -414,9 +431,12 @@ async def fetch_async(self) -> ServiceInstance: :returns: The fetched ServiceInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ServiceInstance( @@ -444,6 +464,8 @@ def update( totp_code_length: Union[int, object] = values.unset, totp_skew: Union[int, object] = values.unset, default_template_sid: Union[str, object] = values.unset, + whatsapp_msg_service_sid: Union[str, object] = values.unset, + whatsapp_from: Union[str, object] = values.unset, verify_event_subscription_enabled: Union[bool, object] = values.unset, ) -> ServiceInstance: """ @@ -457,7 +479,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) @@ -466,10 +488,13 @@ def update( :param totp_code_length: Optional configuration for the TOTP factors. Number of digits for generated TOTP codes. Must be between 3 and 8, inclusive. Defaults to 6 :param totp_skew: Optional configuration for the TOTP factors. The number of time-steps, past and future, that are valid for validation of TOTP codes. Must be between 0 and 2, inclusive. Defaults to 1 :param default_template_sid: The default message [template](https://www.twilio.com/docs/verify/api/templates). Will be used for all SMS verifications unless explicitly overriden. SMS channel only. + :param whatsapp_msg_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/services) to associate with the Verification Service. + :param whatsapp_from: The WhatsApp number to use as the sender of the verification messages. This number must be associated with the WhatsApp Message Service. :param verify_event_subscription_enabled: Whether to allow verifications from the service to reach the stream-events sinks if configured :returns: The updated ServiceInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -493,16 +518,21 @@ def update( "Totp.CodeLength": totp_code_length, "Totp.Skew": totp_skew, "DefaultTemplateSid": default_template_sid, + "Whatsapp.MsgServiceSid": whatsapp_msg_service_sid, + "Whatsapp.From": whatsapp_from, "VerifyEventSubscriptionEnabled": serialize.boolean_to_string( verify_event_subscription_enabled ), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload, sid=self._solution["sid"]) @@ -526,6 +556,8 @@ async def update_async( totp_code_length: Union[int, object] = values.unset, totp_skew: Union[int, object] = values.unset, default_template_sid: Union[str, object] = values.unset, + whatsapp_msg_service_sid: Union[str, object] = values.unset, + whatsapp_from: Union[str, object] = values.unset, verify_event_subscription_enabled: Union[bool, object] = values.unset, ) -> ServiceInstance: """ @@ -539,7 +571,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) @@ -548,10 +580,13 @@ async def update_async( :param totp_code_length: Optional configuration for the TOTP factors. Number of digits for generated TOTP codes. Must be between 3 and 8, inclusive. Defaults to 6 :param totp_skew: Optional configuration for the TOTP factors. The number of time-steps, past and future, that are valid for validation of TOTP codes. Must be between 0 and 2, inclusive. Defaults to 1 :param default_template_sid: The default message [template](https://www.twilio.com/docs/verify/api/templates). Will be used for all SMS verifications unless explicitly overriden. SMS channel only. + :param whatsapp_msg_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/services) to associate with the Verification Service. + :param whatsapp_from: The WhatsApp number to use as the sender of the verification messages. This number must be associated with the WhatsApp Message Service. :param verify_event_subscription_enabled: Whether to allow verifications from the service to reach the stream-events sinks if configured :returns: The updated ServiceInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -575,16 +610,21 @@ async def update_async( "Totp.CodeLength": totp_code_length, "Totp.Skew": totp_skew, "DefaultTemplateSid": default_template_sid, + "Whatsapp.MsgServiceSid": whatsapp_msg_service_sid, + "Whatsapp.From": whatsapp_from, "VerifyEventSubscriptionEnabled": serialize.boolean_to_string( verify_event_subscription_enabled ), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload, sid=self._solution["sid"]) @@ -734,6 +774,8 @@ def create( totp_code_length: Union[int, object] = values.unset, totp_skew: Union[int, object] = values.unset, default_template_sid: Union[str, object] = values.unset, + whatsapp_msg_service_sid: Union[str, object] = values.unset, + whatsapp_from: Union[str, object] = values.unset, verify_event_subscription_enabled: Union[bool, object] = values.unset, ) -> ServiceInstance: """ @@ -747,7 +789,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) @@ -756,6 +798,8 @@ def create( :param totp_code_length: Optional configuration for the TOTP factors. Number of digits for generated TOTP codes. Must be between 3 and 8, inclusive. Defaults to 6 :param totp_skew: Optional configuration for the TOTP factors. The number of time-steps, past and future, that are valid for validation of TOTP codes. Must be between 0 and 2, inclusive. Defaults to 1 :param default_template_sid: The default message [template](https://www.twilio.com/docs/verify/api/templates). Will be used for all SMS verifications unless explicitly overriden. SMS channel only. + :param whatsapp_msg_service_sid: The SID of the Messaging Service containing WhatsApp Sender(s) that Verify will use to send WhatsApp messages to your users. + :param whatsapp_from: The number to use as the WhatsApp Sender that Verify will use to send WhatsApp messages to your users.This WhatsApp Sender must be associated with a Messaging Service SID. :param verify_event_subscription_enabled: Whether to allow verifications from the service to reach the stream-events sinks if configured :returns: The created ServiceInstance @@ -784,16 +828,21 @@ def create( "Totp.CodeLength": totp_code_length, "Totp.Skew": totp_skew, "DefaultTemplateSid": default_template_sid, + "Whatsapp.MsgServiceSid": whatsapp_msg_service_sid, + "Whatsapp.From": whatsapp_from, "VerifyEventSubscriptionEnabled": serialize.boolean_to_string( verify_event_subscription_enabled ), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload) @@ -817,6 +866,8 @@ async def create_async( totp_code_length: Union[int, object] = values.unset, totp_skew: Union[int, object] = values.unset, default_template_sid: Union[str, object] = values.unset, + whatsapp_msg_service_sid: Union[str, object] = values.unset, + whatsapp_from: Union[str, object] = values.unset, verify_event_subscription_enabled: Union[bool, object] = values.unset, ) -> ServiceInstance: """ @@ -830,7 +881,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) @@ -839,6 +890,8 @@ async def create_async( :param totp_code_length: Optional configuration for the TOTP factors. Number of digits for generated TOTP codes. Must be between 3 and 8, inclusive. Defaults to 6 :param totp_skew: Optional configuration for the TOTP factors. The number of time-steps, past and future, that are valid for validation of TOTP codes. Must be between 0 and 2, inclusive. Defaults to 1 :param default_template_sid: The default message [template](https://www.twilio.com/docs/verify/api/templates). Will be used for all SMS verifications unless explicitly overriden. SMS channel only. + :param whatsapp_msg_service_sid: The SID of the Messaging Service containing WhatsApp Sender(s) that Verify will use to send WhatsApp messages to your users. + :param whatsapp_from: The number to use as the WhatsApp Sender that Verify will use to send WhatsApp messages to your users.This WhatsApp Sender must be associated with a Messaging Service SID. :param verify_event_subscription_enabled: Whether to allow verifications from the service to reach the stream-events sinks if configured :returns: The created ServiceInstance @@ -867,16 +920,21 @@ async def create_async( "Totp.CodeLength": totp_code_length, "Totp.Skew": totp_skew, "DefaultTemplateSid": default_template_sid, + "Whatsapp.MsgServiceSid": whatsapp_msg_service_sid, + "Whatsapp.From": whatsapp_from, "VerifyEventSubscriptionEnabled": serialize.boolean_to_string( verify_event_subscription_enabled ), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ServiceInstance(self._version, payload) @@ -1008,7 +1066,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ServicePage(self._version, response) async def page_async( @@ -1035,8 +1099,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ServicePage(self._version, response) diff --git a/twilio/rest/verify/v2/service/access_token.py b/twilio/rest/verify/v2/service/access_token.py index 0bb888a08f..45a0094e52 100644 --- a/twilio/rest/verify/v2/service/access_token.py +++ b/twilio/rest/verify/v2/service/access_token.py @@ -142,10 +142,11 @@ def fetch(self) -> AccessTokenInstance: :returns: The fetched AccessTokenInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return AccessTokenInstance( self._version, @@ -162,9 +163,12 @@ async def fetch_async(self) -> AccessTokenInstance: :returns: The fetched AccessTokenInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return AccessTokenInstance( @@ -228,11 +232,14 @@ def create( "Ttl": ttl, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AccessTokenInstance( @@ -265,11 +272,14 @@ async def create_async( "Ttl": ttl, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AccessTokenInstance( diff --git a/twilio/rest/verify/v2/service/entity/__init__.py b/twilio/rest/verify/v2/service/entity/__init__.py index 41541a4ca6..fa4bc1df12 100644 --- a/twilio/rest/verify/v2/service/entity/__init__.py +++ b/twilio/rest/verify/v2/service/entity/__init__.py @@ -180,10 +180,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -192,9 +192,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> EntityInstance: @@ -205,10 +207,11 @@ def fetch(self) -> EntityInstance: :returns: The fetched EntityInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return EntityInstance( self._version, @@ -225,9 +228,12 @@ async def fetch_async(self) -> EntityInstance: :returns: The fetched EntityInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return EntityInstance( @@ -339,11 +345,14 @@ def create(self, identity: str) -> EntityInstance: "Identity": identity, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return EntityInstance( @@ -364,11 +373,14 @@ async def create_async(self, identity: str) -> EntityInstance: "Identity": identity, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return EntityInstance( @@ -502,7 +514,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return EntityPage(self._version, response, self._solution) async def page_async( @@ -529,8 +547,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return EntityPage(self._version, response, self._solution) diff --git a/twilio/rest/verify/v2/service/entity/challenge/__init__.py b/twilio/rest/verify/v2/service/entity/challenge/__init__.py index ab8c7f8d11..146a95d959 100644 --- a/twilio/rest/verify/v2/service/entity/challenge/__init__.py +++ b/twilio/rest/verify/v2/service/entity/challenge/__init__.py @@ -238,10 +238,11 @@ def fetch(self) -> ChallengeInstance: :returns: The fetched ChallengeInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ChallengeInstance( self._version, @@ -259,9 +260,12 @@ async def fetch_async(self) -> ChallengeInstance: :returns: The fetched ChallengeInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ChallengeInstance( @@ -285,17 +289,21 @@ def update( :returns: The updated ChallengeInstance """ + data = values.of( { "AuthPayload": auth_payload, "Metadata": serialize.object(metadata), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ChallengeInstance( @@ -319,17 +327,21 @@ async def update_async( :returns: The updated ChallengeInstance """ + data = values.of( { "AuthPayload": auth_payload, "Metadata": serialize.object(metadata), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ChallengeInstance( @@ -444,11 +456,14 @@ def create( "AuthPayload": auth_payload, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ChallengeInstance( @@ -492,11 +507,14 @@ async def create_async( "AuthPayload": auth_payload, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ChallengeInstance( @@ -682,7 +700,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ChallengePage(self._version, response, self._solution) async def page_async( @@ -718,8 +742,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ChallengePage(self._version, response, self._solution) diff --git a/twilio/rest/verify/v2/service/entity/challenge/notification.py b/twilio/rest/verify/v2/service/entity/challenge/notification.py index 0cfae0a60f..3802cc1a08 100644 --- a/twilio/rest/verify/v2/service/entity/challenge/notification.py +++ b/twilio/rest/verify/v2/service/entity/challenge/notification.py @@ -112,11 +112,14 @@ def create(self, ttl: Union[int, object] = values.unset) -> NotificationInstance "Ttl": ttl, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return NotificationInstance( @@ -143,11 +146,14 @@ async def create_async( "Ttl": ttl, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return NotificationInstance( diff --git a/twilio/rest/verify/v2/service/entity/factor.py b/twilio/rest/verify/v2/service/entity/factor.py index 8900fcbfc2..7bf91cd870 100644 --- a/twilio/rest/verify/v2/service/entity/factor.py +++ b/twilio/rest/verify/v2/service/entity/factor.py @@ -261,10 +261,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -273,9 +273,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> FactorInstance: @@ -286,10 +288,11 @@ def fetch(self) -> FactorInstance: :returns: The fetched FactorInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return FactorInstance( self._version, @@ -307,9 +310,12 @@ async def fetch_async(self) -> FactorInstance: :returns: The fetched FactorInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return FactorInstance( @@ -347,6 +353,7 @@ def update( :returns: The updated FactorInstance """ + data = values.of( { "AuthPayload": auth_payload, @@ -360,11 +367,14 @@ def update( "Config.NotificationPlatform": config_notification_platform, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return FactorInstance( @@ -402,6 +412,7 @@ async def update_async( :returns: The updated FactorInstance """ + data = values.of( { "AuthPayload": auth_payload, @@ -415,11 +426,14 @@ async def update_async( "Config.NotificationPlatform": config_notification_platform, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return FactorInstance( @@ -613,7 +627,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return FactorPage(self._version, response, self._solution) async def page_async( @@ -640,8 +660,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return FactorPage(self._version, response, self._solution) diff --git a/twilio/rest/verify/v2/service/entity/new_factor.py b/twilio/rest/verify/v2/service/entity/new_factor.py index 7b260a4a3d..2a2d77d512 100644 --- a/twilio/rest/verify/v2/service/entity/new_factor.py +++ b/twilio/rest/verify/v2/service/entity/new_factor.py @@ -181,11 +181,14 @@ def create( "Metadata": serialize.object(metadata), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return NewFactorInstance( @@ -253,11 +256,14 @@ async def create_async( "Metadata": serialize.object(metadata), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return NewFactorInstance( diff --git a/twilio/rest/verify/v2/service/messaging_configuration.py b/twilio/rest/verify/v2/service/messaging_configuration.py index f412aba1ee..03f494f6e9 100644 --- a/twilio/rest/verify/v2/service/messaging_configuration.py +++ b/twilio/rest/verify/v2/service/messaging_configuration.py @@ -176,10 +176,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -188,9 +188,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> MessagingConfigurationInstance: @@ -201,10 +203,11 @@ def fetch(self) -> MessagingConfigurationInstance: :returns: The fetched MessagingConfigurationInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return MessagingConfigurationInstance( self._version, @@ -221,9 +224,12 @@ async def fetch_async(self) -> MessagingConfigurationInstance: :returns: The fetched MessagingConfigurationInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return MessagingConfigurationInstance( @@ -241,16 +247,20 @@ def update(self, messaging_service_sid: str) -> MessagingConfigurationInstance: :returns: The updated MessagingConfigurationInstance """ + data = values.of( { "MessagingServiceSid": messaging_service_sid, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return MessagingConfigurationInstance( @@ -270,16 +280,20 @@ async def update_async( :returns: The updated MessagingConfigurationInstance """ + data = values.of( { "MessagingServiceSid": messaging_service_sid, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return MessagingConfigurationInstance( @@ -358,11 +372,14 @@ def create( "MessagingServiceSid": messaging_service_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return MessagingConfigurationInstance( @@ -387,11 +404,14 @@ async def create_async( "MessagingServiceSid": messaging_service_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return MessagingConfigurationInstance( @@ -525,7 +545,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return MessagingConfigurationPage(self._version, response, self._solution) async def page_async( @@ -552,8 +578,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return MessagingConfigurationPage(self._version, response, self._solution) diff --git a/twilio/rest/verify/v2/service/rate_limit/__init__.py b/twilio/rest/verify/v2/service/rate_limit/__init__.py index 2d4a18bf0f..ced5ab6a64 100644 --- a/twilio/rest/verify/v2/service/rate_limit/__init__.py +++ b/twilio/rest/verify/v2/service/rate_limit/__init__.py @@ -190,10 +190,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -202,9 +202,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> RateLimitInstance: @@ -215,10 +217,11 @@ def fetch(self) -> RateLimitInstance: :returns: The fetched RateLimitInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return RateLimitInstance( self._version, @@ -235,9 +238,12 @@ async def fetch_async(self) -> RateLimitInstance: :returns: The fetched RateLimitInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return RateLimitInstance( @@ -257,16 +263,20 @@ def update( :returns: The updated RateLimitInstance """ + data = values.of( { "Description": description, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RateLimitInstance( @@ -286,16 +296,20 @@ async def update_async( :returns: The updated RateLimitInstance """ + data = values.of( { "Description": description, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RateLimitInstance( @@ -385,11 +399,14 @@ def create( "Description": description, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RateLimitInstance( @@ -414,11 +431,14 @@ async def create_async( "Description": description, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RateLimitInstance( @@ -552,7 +572,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return RateLimitPage(self._version, response, self._solution) async def page_async( @@ -579,8 +605,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return RateLimitPage(self._version, response, self._solution) diff --git a/twilio/rest/verify/v2/service/rate_limit/bucket.py b/twilio/rest/verify/v2/service/rate_limit/bucket.py index ca4ffaf775..4ac50cfc2f 100644 --- a/twilio/rest/verify/v2/service/rate_limit/bucket.py +++ b/twilio/rest/verify/v2/service/rate_limit/bucket.py @@ -199,10 +199,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -211,9 +211,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> BucketInstance: @@ -224,10 +226,11 @@ def fetch(self) -> BucketInstance: :returns: The fetched BucketInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return BucketInstance( self._version, @@ -245,9 +248,12 @@ async def fetch_async(self) -> BucketInstance: :returns: The fetched BucketInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return BucketInstance( @@ -271,17 +277,21 @@ def update( :returns: The updated BucketInstance """ + data = values.of( { "Max": max, "Interval": interval, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return BucketInstance( @@ -305,17 +315,21 @@ async def update_async( :returns: The updated BucketInstance """ + data = values.of( { "Max": max, "Interval": interval, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return BucketInstance( @@ -400,11 +414,14 @@ def create(self, max: int, interval: int) -> BucketInstance: "Interval": interval, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return BucketInstance( @@ -430,11 +447,14 @@ async def create_async(self, max: int, interval: int) -> BucketInstance: "Interval": interval, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return BucketInstance( @@ -571,7 +591,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return BucketPage(self._version, response, self._solution) async def page_async( @@ -598,8 +624,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return BucketPage(self._version, response, self._solution) diff --git a/twilio/rest/verify/v2/service/verification.py b/twilio/rest/verify/v2/service/verification.py index 1c42043a3d..64988a5983 100644 --- a/twilio/rest/verify/v2/service/verification.py +++ b/twilio/rest/verify/v2/service/verification.py @@ -44,7 +44,7 @@ class Status(object): :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Verification resource. :ivar to: The phone number or [email](https://www.twilio.com/docs/verify/email) being verified. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). :ivar channel: - :ivar status: The status of the verification. One of: `pending`, `approved`, or `canceled` + :ivar status: The status of the verification. Can be: `pending`, `approved`, `canceled`, `max_attempts_reached`, `deleted`, `failed` or `expired`. :ivar valid: Use \"status\" instead. Legacy property indicating whether the verification was successful. :ivar lookup: Information about the phone number being verified. :ivar amount: The amount of the associated PSD2 compliant transaction. Requires the PSD2 Service flag enabled. @@ -192,10 +192,11 @@ def fetch(self) -> VerificationInstance: :returns: The fetched VerificationInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return VerificationInstance( self._version, @@ -212,9 +213,12 @@ async def fetch_async(self) -> VerificationInstance: :returns: The fetched VerificationInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return VerificationInstance( @@ -232,16 +236,20 @@ def update(self, status: "VerificationInstance.Status") -> VerificationInstance: :returns: The updated VerificationInstance """ + data = values.of( { "Status": status, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return VerificationInstance( @@ -261,16 +269,20 @@ async def update_async( :returns: The updated VerificationInstance """ + data = values.of( { "Status": status, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return VerificationInstance( @@ -325,6 +337,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 +359,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,15 +383,21 @@ 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, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return VerificationInstance( @@ -401,6 +421,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: @@ -422,6 +443,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. @@ -445,15 +467,21 @@ 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, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return VerificationInstance( diff --git a/twilio/rest/verify/v2/service/verification_check.py b/twilio/rest/verify/v2/service/verification_check.py index 9cd92487e4..c09057ebe1 100644 --- a/twilio/rest/verify/v2/service/verification_check.py +++ b/twilio/rest/verify/v2/service/verification_check.py @@ -36,7 +36,7 @@ class Channel(object): :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the VerificationCheck resource. :ivar to: The phone number or [email](https://www.twilio.com/docs/verify/email) being verified. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). :ivar channel: - :ivar status: The status of the verification. Can be: `pending`, `approved`, or `canceled`. + :ivar status: The status of the verification. Can be: `pending`, `approved`, `canceled`, `max_attempts_reached`, `deleted`, `failed` or `expired`. :ivar valid: Use \"status\" instead. Legacy property indicating whether the verification was successful. :ivar amount: The amount of the associated PSD2 compliant transaction. Requires the PSD2 Service flag enabled. :ivar payee: The payee of the associated PSD2 compliant transaction. Requires the PSD2 Service flag enabled. @@ -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,13 +130,17 @@ def create( "VerificationSid": verification_sid, "Amount": amount, "Payee": payee, + "SnaClientToken": sna_client_token, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return VerificationCheckInstance( @@ -148,6 +154,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 @@ -157,6 +164,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 """ @@ -168,13 +176,17 @@ 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"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return VerificationCheckInstance( diff --git a/twilio/rest/verify/v2/service/webhook.py b/twilio/rest/verify/v2/service/webhook.py index 4f8772574c..dd68cf301b 100644 --- a/twilio/rest/verify/v2/service/webhook.py +++ b/twilio/rest/verify/v2/service/webhook.py @@ -227,10 +227,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -239,9 +239,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> WebhookInstance: @@ -252,10 +254,11 @@ def fetch(self) -> WebhookInstance: :returns: The fetched WebhookInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return WebhookInstance( self._version, @@ -272,9 +275,12 @@ async def fetch_async(self) -> WebhookInstance: :returns: The fetched WebhookInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return WebhookInstance( @@ -303,6 +309,7 @@ def update( :returns: The updated WebhookInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -312,11 +319,14 @@ def update( "Version": version, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WebhookInstance( @@ -345,6 +355,7 @@ async def update_async( :returns: The updated WebhookInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -354,11 +365,14 @@ async def update_async( "Version": version, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WebhookInstance( @@ -446,11 +460,14 @@ def create( "Version": version, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WebhookInstance( @@ -486,11 +503,14 @@ async def create_async( "Version": version, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return WebhookInstance( @@ -624,7 +644,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return WebhookPage(self._version, response, self._solution) async def page_async( @@ -651,8 +677,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return WebhookPage(self._version, response, self._solution) diff --git a/twilio/rest/verify/v2/template.py b/twilio/rest/verify/v2/template.py index b9968eec87..5a242c153e 100644 --- a/twilio/rest/verify/v2/template.py +++ b/twilio/rest/verify/v2/template.py @@ -223,7 +223,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return TemplatePage(self._version, response) async def page_async( @@ -253,8 +259,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return TemplatePage(self._version, response) diff --git a/twilio/rest/verify/v2/verification_attempt.py b/twilio/rest/verify/v2/verification_attempt.py index 2c1f914d32..5c6989348a 100644 --- a/twilio/rest/verify/v2/verification_attempt.py +++ b/twilio/rest/verify/v2/verification_attempt.py @@ -146,10 +146,11 @@ def fetch(self) -> VerificationAttemptInstance: :returns: The fetched VerificationAttemptInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return VerificationAttemptInstance( self._version, @@ -165,9 +166,12 @@ async def fetch_async(self) -> VerificationAttemptInstance: :returns: The fetched VerificationAttemptInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return VerificationAttemptInstance( @@ -479,7 +483,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return VerificationAttemptPage(self._version, response) async def page_async( @@ -532,8 +542,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return VerificationAttemptPage(self._version, response) diff --git a/twilio/rest/verify/v2/verification_attempts_summary.py b/twilio/rest/verify/v2/verification_attempts_summary.py index 1f2d3d3955..429e9f70bc 100644 --- a/twilio/rest/verify/v2/verification_attempts_summary.py +++ b/twilio/rest/verify/v2/verification_attempts_summary.py @@ -191,7 +191,13 @@ def fetch( } ) - payload = self._version.fetch(method="GET", uri=self._uri, params=data) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) return VerificationAttemptsSummaryInstance( self._version, @@ -233,8 +239,12 @@ async def fetch_async( } ) + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return VerificationAttemptsSummaryInstance( diff --git a/twilio/rest/video/v1/composition.py b/twilio/rest/video/v1/composition.py index 30aa33fff8..06f4d05f5f 100644 --- a/twilio/rest/video/v1/composition.py +++ b/twilio/rest/video/v1/composition.py @@ -188,10 +188,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -200,9 +200,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> CompositionInstance: @@ -213,10 +215,11 @@ def fetch(self) -> CompositionInstance: :returns: The fetched CompositionInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return CompositionInstance( self._version, @@ -232,9 +235,12 @@ async def fetch_async(self) -> CompositionInstance: :returns: The fetched CompositionInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return CompositionInstance( @@ -328,11 +334,14 @@ def create( "Trim": serialize.boolean_to_string(trim), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CompositionInstance(self._version, payload) @@ -380,11 +389,14 @@ async def create_async( "Trim": serialize.boolean_to_string(trim), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CompositionInstance(self._version, payload) @@ -580,7 +592,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return CompositionPage(self._version, response) async def page_async( @@ -619,8 +637,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return CompositionPage(self._version, response) diff --git a/twilio/rest/video/v1/composition_hook.py b/twilio/rest/video/v1/composition_hook.py index 027a27f740..30fead17b0 100644 --- a/twilio/rest/video/v1/composition_hook.py +++ b/twilio/rest/video/v1/composition_hook.py @@ -249,10 +249,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -261,9 +261,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> CompositionHookInstance: @@ -274,10 +276,11 @@ def fetch(self) -> CompositionHookInstance: :returns: The fetched CompositionHookInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return CompositionHookInstance( self._version, @@ -293,9 +296,12 @@ async def fetch_async(self) -> CompositionHookInstance: :returns: The fetched CompositionHookInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return CompositionHookInstance( @@ -333,6 +339,7 @@ def update( :returns: The updated CompositionHookInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -349,11 +356,14 @@ def update( "StatusCallbackMethod": status_callback_method, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CompositionHookInstance( @@ -389,6 +399,7 @@ async def update_async( :returns: The updated CompositionHookInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -405,11 +416,14 @@ async def update_async( "StatusCallbackMethod": status_callback_method, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CompositionHookInstance( @@ -504,11 +518,14 @@ def create( "Trim": serialize.boolean_to_string(trim), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CompositionHookInstance(self._version, payload) @@ -559,11 +576,14 @@ async def create_async( "Trim": serialize.boolean_to_string(trim), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CompositionHookInstance(self._version, payload) @@ -759,7 +779,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return CompositionHookPage(self._version, response) async def page_async( @@ -798,8 +824,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return CompositionHookPage(self._version, response) diff --git a/twilio/rest/video/v1/composition_settings.py b/twilio/rest/video/v1/composition_settings.py index 366ec727cf..384ae692e8 100644 --- a/twilio/rest/video/v1/composition_settings.py +++ b/twilio/rest/video/v1/composition_settings.py @@ -242,10 +242,11 @@ def fetch(self) -> CompositionSettingsInstance: :returns: The fetched CompositionSettingsInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return CompositionSettingsInstance( self._version, @@ -260,9 +261,12 @@ async def fetch_async(self) -> CompositionSettingsInstance: :returns: The fetched CompositionSettingsInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return CompositionSettingsInstance( diff --git a/twilio/rest/video/v1/recording.py b/twilio/rest/video/v1/recording.py index 20c836d2b0..f474345fe0 100644 --- a/twilio/rest/video/v1/recording.py +++ b/twilio/rest/video/v1/recording.py @@ -188,10 +188,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -200,9 +200,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> RecordingInstance: @@ -213,10 +215,11 @@ def fetch(self) -> RecordingInstance: :returns: The fetched RecordingInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return RecordingInstance( self._version, @@ -232,9 +235,12 @@ async def fetch_async(self) -> RecordingInstance: :returns: The fetched RecordingInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return RecordingInstance( @@ -506,7 +512,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return RecordingPage(self._version, response) async def page_async( @@ -551,8 +563,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return RecordingPage(self._version, response) diff --git a/twilio/rest/video/v1/recording_settings.py b/twilio/rest/video/v1/recording_settings.py index 3895b9d4ba..46259b6cf8 100644 --- a/twilio/rest/video/v1/recording_settings.py +++ b/twilio/rest/video/v1/recording_settings.py @@ -242,10 +242,11 @@ def fetch(self) -> RecordingSettingsInstance: :returns: The fetched RecordingSettingsInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return RecordingSettingsInstance( self._version, @@ -260,9 +261,12 @@ async def fetch_async(self) -> RecordingSettingsInstance: :returns: The fetched RecordingSettingsInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return RecordingSettingsInstance( diff --git a/twilio/rest/video/v1/room/__init__.py b/twilio/rest/video/v1/room/__init__.py index a8ffdb895c..d51b8b8711 100644 --- a/twilio/rest/video/v1/room/__init__.py +++ b/twilio/rest/video/v1/room/__init__.py @@ -43,25 +43,25 @@ class VideoCodec(object): H264 = "H264" """ - :ivar sid: The unique string that we created to identify the Room resource. + :ivar sid: The unique string that Twilio created to identify the Room resource. :ivar status: :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 account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Room resource. :ivar enable_turn: Deprecated, now always considered to be true. :ivar unique_name: An application-defined string that uniquely identifies the resource. It can be used as a `room_sid` in place of the resource's `sid` in the URL to address the resource, assuming it does not contain any [reserved characters](https://tools.ietf.org/html/rfc3986#section-2.2) that would need to be URL encoded. This value is unique for `in-progress` rooms. SDK clients can use this name to connect to the room. REST API clients can use this name in place of the Room SID to interact with the room as long as the room is `in-progress`. - :ivar status_callback: The URL we call using the `status_callback_method` to send status information to your application on every room event. See [Status Callbacks](https://www.twilio.com/docs/video/api/status-callbacks) for more info. - :ivar status_callback_method: The HTTP method we use to call `status_callback`. Can be `POST` or `GET` and defaults to `POST`. + :ivar status_callback: The URL Twilio calls using the `status_callback_method` to send status information to your application on every room event. See [Status Callbacks](https://www.twilio.com/docs/video/api/status-callbacks) for more info. + :ivar status_callback_method: The HTTP method Twilio uses to call `status_callback`. Can be `POST` or `GET` and defaults to `POST`. :ivar end_time: The UTC end time of the room in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#UTC) format. :ivar duration: The duration of the room in seconds. :ivar type: :ivar max_participants: The maximum number of concurrent Participants allowed in the room. :ivar max_participant_duration: The maximum number of seconds a Participant can be connected to the room. The maximum possible value is 86400 seconds (24 hours). The default is 14400 seconds (4 hours). :ivar max_concurrent_published_tracks: The maximum number of published audio, video, and data tracks all participants combined are allowed to publish in the room at the same time. Check [Programmable Video Limits](https://www.twilio.com/docs/video/programmable-video-limits) for more details. If it is set to 0 it means unconstrained. - :ivar record_participants_on_connect: Whether to start recording when Participants connect. ***This feature is not available in `peer-to-peer` rooms.*** - :ivar video_codecs: An array of the video codecs that are supported when publishing a track in the room. Can be: `VP8` and `H264`. ***This feature is not available in `peer-to-peer` rooms*** - :ivar media_region: The region for the media server in Group Rooms. Can be: one of the [available Media Regions](https://www.twilio.com/docs/video/ip-addresses#media-servers). ***This feature is not available in `peer-to-peer` rooms.*** - :ivar audio_only: When set to true, indicates that the participants in the room will only publish audio. No video tracks will be allowed. Group rooms only. + :ivar record_participants_on_connect: Whether to start recording when Participants connect. + :ivar video_codecs: An array of the video codecs that are supported when publishing a track in the room. Can be: `VP8` and `H264`. + :ivar media_region: The region for the Room's media server. Can be one of the [available Media Regions](https://www.twilio.com/docs/video/ip-addresses#media-servers). + :ivar audio_only: When set to true, indicates that the participants in the room will only publish audio. No video tracks will be allowed. :ivar empty_room_timeout: Specifies how long (in minutes) a room will remain active after last participant leaves. Can be configured when creating a room via REST API. For Ad-Hoc rooms this value cannot be changed. :ivar unused_room_timeout: Specifies how long (in minutes) a room will remain active if no one joins. Can be configured when creating a room via REST API. For Ad-Hoc rooms this value cannot be changed. :ivar large_room: Indicates if this is a large room. @@ -243,10 +243,11 @@ def fetch(self) -> RoomInstance: :returns: The fetched RoomInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return RoomInstance( self._version, @@ -262,9 +263,12 @@ async def fetch_async(self) -> RoomInstance: :returns: The fetched RoomInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return RoomInstance( @@ -281,16 +285,20 @@ def update(self, status: "RoomInstance.RoomStatus") -> RoomInstance: :returns: The updated RoomInstance """ + data = values.of( { "Status": status, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RoomInstance(self._version, payload, sid=self._solution["sid"]) @@ -303,16 +311,20 @@ async def update_async(self, status: "RoomInstance.RoomStatus") -> RoomInstance: :returns: The updated RoomInstance """ + data = values.of( { "Status": status, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RoomInstance(self._version, payload, sid=self._solution["sid"]) @@ -404,9 +416,11 @@ def create( status_callback_method: Union[str, object] = values.unset, max_participants: Union[int, object] = values.unset, record_participants_on_connect: Union[bool, object] = values.unset, + transcribe_participants_on_connect: Union[bool, object] = values.unset, video_codecs: Union[List["RoomInstance.VideoCodec"], object] = values.unset, media_region: Union[str, object] = values.unset, recording_rules: Union[object, object] = values.unset, + transcriptions_configuration: Union[object, object] = values.unset, audio_only: Union[bool, object] = values.unset, max_participant_duration: Union[int, object] = values.unset, empty_room_timeout: Union[int, object] = values.unset, @@ -419,14 +433,16 @@ def create( :param enable_turn: Deprecated, now always considered to be true. :param type: :param unique_name: An application-defined string that uniquely identifies the resource. It can be used as a `room_sid` in place of the resource's `sid` in the URL to address the resource, assuming it does not contain any [reserved characters](https://tools.ietf.org/html/rfc3986#section-2.2) that would need to be URL encoded. This value is unique for `in-progress` rooms. SDK clients can use this name to connect to the room. REST API clients can use this name in place of the Room SID to interact with the room as long as the room is `in-progress`. - :param status_callback: The URL we should call using the `status_callback_method` to send status information to your application on every room event. See [Status Callbacks](https://www.twilio.com/docs/video/api/status-callbacks) for more info. - :param status_callback_method: The HTTP method we should use to call `status_callback`. Can be `POST` or `GET`. - :param max_participants: The maximum number of concurrent Participants allowed in the room. Peer-to-peer rooms can have up to 10 Participants. Small Group rooms can have up to 4 Participants. Group rooms can have up to 50 Participants. - :param record_participants_on_connect: Whether to start recording when Participants connect. ***This feature is not available in `peer-to-peer` rooms.*** - :param video_codecs: An array of the video codecs that are supported when publishing a track in the room. Can be: `VP8` and `H264`. ***This feature is not available in `peer-to-peer` rooms*** - :param media_region: The region for the media server in Group Rooms. Can be: one of the [available Media Regions](https://www.twilio.com/docs/video/ip-addresses#group-rooms-media-servers). ***This feature is not available in `peer-to-peer` rooms.*** + :param status_callback: The URL Twilio should call using the `status_callback_method` to send status information to your application on every room event. See [Status Callbacks](https://www.twilio.com/docs/video/api/status-callbacks) for more info. + :param status_callback_method: The HTTP method Twilio should use to call `status_callback`. Can be `POST` or `GET`. + :param max_participants: The maximum number of concurrent Participants allowed in the room. The maximum allowed value is 50. + :param record_participants_on_connect: Whether to start recording when Participants connect. + :param transcribe_participants_on_connect: Whether to start transcriptions when Participants connect. If TranscriptionsConfiguration is not provided, default settings will be used. + :param video_codecs: An array of the video codecs that are supported when publishing a track in the room. Can be: `VP8` and `H264`. + :param media_region: The region for the Room's media server. Can be one of the [available Media Regions](https://www.twilio.com/docs/video/ip-addresses#group-rooms-media-servers). :param recording_rules: A collection of Recording Rules that describe how to include or exclude matching tracks for recording - :param audio_only: When set to true, indicates that the participants in the room will only publish audio. No video tracks will be allowed. Group rooms only. + :param transcriptions_configuration: A collection of properties that describe transcription behaviour. If TranscribeParticipantsOnConnect is set to true and TranscriptionsConfiguration is not provided, default settings will be used. + :param audio_only: When set to true, indicates that the participants in the room will only publish audio. No video tracks will be allowed. :param max_participant_duration: The maximum number of seconds a Participant can be connected to the room. The maximum possible value is 86400 seconds (24 hours). The default is 14400 seconds (4 hours). :param empty_room_timeout: Configures how long (in minutes) a room will remain active after last participant leaves. Valid values range from 1 to 60 minutes (no fractions). :param unused_room_timeout: Configures how long (in minutes) a room will remain active if no one joins. Valid values range from 1 to 60 minutes (no fractions). @@ -446,9 +462,15 @@ def create( "RecordParticipantsOnConnect": serialize.boolean_to_string( record_participants_on_connect ), + "TranscribeParticipantsOnConnect": serialize.boolean_to_string( + transcribe_participants_on_connect + ), "VideoCodecs": serialize.map(video_codecs, lambda e: e), "MediaRegion": media_region, "RecordingRules": serialize.object(recording_rules), + "TranscriptionsConfiguration": serialize.object( + transcriptions_configuration + ), "AudioOnly": serialize.boolean_to_string(audio_only), "MaxParticipantDuration": max_participant_duration, "EmptyRoomTimeout": empty_room_timeout, @@ -456,11 +478,14 @@ def create( "LargeRoom": serialize.boolean_to_string(large_room), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RoomInstance(self._version, payload) @@ -474,9 +499,11 @@ async def create_async( status_callback_method: Union[str, object] = values.unset, max_participants: Union[int, object] = values.unset, record_participants_on_connect: Union[bool, object] = values.unset, + transcribe_participants_on_connect: Union[bool, object] = values.unset, video_codecs: Union[List["RoomInstance.VideoCodec"], object] = values.unset, media_region: Union[str, object] = values.unset, recording_rules: Union[object, object] = values.unset, + transcriptions_configuration: Union[object, object] = values.unset, audio_only: Union[bool, object] = values.unset, max_participant_duration: Union[int, object] = values.unset, empty_room_timeout: Union[int, object] = values.unset, @@ -489,14 +516,16 @@ async def create_async( :param enable_turn: Deprecated, now always considered to be true. :param type: :param unique_name: An application-defined string that uniquely identifies the resource. It can be used as a `room_sid` in place of the resource's `sid` in the URL to address the resource, assuming it does not contain any [reserved characters](https://tools.ietf.org/html/rfc3986#section-2.2) that would need to be URL encoded. This value is unique for `in-progress` rooms. SDK clients can use this name to connect to the room. REST API clients can use this name in place of the Room SID to interact with the room as long as the room is `in-progress`. - :param status_callback: The URL we should call using the `status_callback_method` to send status information to your application on every room event. See [Status Callbacks](https://www.twilio.com/docs/video/api/status-callbacks) for more info. - :param status_callback_method: The HTTP method we should use to call `status_callback`. Can be `POST` or `GET`. - :param max_participants: The maximum number of concurrent Participants allowed in the room. Peer-to-peer rooms can have up to 10 Participants. Small Group rooms can have up to 4 Participants. Group rooms can have up to 50 Participants. - :param record_participants_on_connect: Whether to start recording when Participants connect. ***This feature is not available in `peer-to-peer` rooms.*** - :param video_codecs: An array of the video codecs that are supported when publishing a track in the room. Can be: `VP8` and `H264`. ***This feature is not available in `peer-to-peer` rooms*** - :param media_region: The region for the media server in Group Rooms. Can be: one of the [available Media Regions](https://www.twilio.com/docs/video/ip-addresses#group-rooms-media-servers). ***This feature is not available in `peer-to-peer` rooms.*** + :param status_callback: The URL Twilio should call using the `status_callback_method` to send status information to your application on every room event. See [Status Callbacks](https://www.twilio.com/docs/video/api/status-callbacks) for more info. + :param status_callback_method: The HTTP method Twilio should use to call `status_callback`. Can be `POST` or `GET`. + :param max_participants: The maximum number of concurrent Participants allowed in the room. The maximum allowed value is 50. + :param record_participants_on_connect: Whether to start recording when Participants connect. + :param transcribe_participants_on_connect: Whether to start transcriptions when Participants connect. If TranscriptionsConfiguration is not provided, default settings will be used. + :param video_codecs: An array of the video codecs that are supported when publishing a track in the room. Can be: `VP8` and `H264`. + :param media_region: The region for the Room's media server. Can be one of the [available Media Regions](https://www.twilio.com/docs/video/ip-addresses#group-rooms-media-servers). :param recording_rules: A collection of Recording Rules that describe how to include or exclude matching tracks for recording - :param audio_only: When set to true, indicates that the participants in the room will only publish audio. No video tracks will be allowed. Group rooms only. + :param transcriptions_configuration: A collection of properties that describe transcription behaviour. If TranscribeParticipantsOnConnect is set to true and TranscriptionsConfiguration is not provided, default settings will be used. + :param audio_only: When set to true, indicates that the participants in the room will only publish audio. No video tracks will be allowed. :param max_participant_duration: The maximum number of seconds a Participant can be connected to the room. The maximum possible value is 86400 seconds (24 hours). The default is 14400 seconds (4 hours). :param empty_room_timeout: Configures how long (in minutes) a room will remain active after last participant leaves. Valid values range from 1 to 60 minutes (no fractions). :param unused_room_timeout: Configures how long (in minutes) a room will remain active if no one joins. Valid values range from 1 to 60 minutes (no fractions). @@ -516,9 +545,15 @@ async def create_async( "RecordParticipantsOnConnect": serialize.boolean_to_string( record_participants_on_connect ), + "TranscribeParticipantsOnConnect": serialize.boolean_to_string( + transcribe_participants_on_connect + ), "VideoCodecs": serialize.map(video_codecs, lambda e: e), "MediaRegion": media_region, "RecordingRules": serialize.object(recording_rules), + "TranscriptionsConfiguration": serialize.object( + transcriptions_configuration + ), "AudioOnly": serialize.boolean_to_string(audio_only), "MaxParticipantDuration": max_participant_duration, "EmptyRoomTimeout": empty_room_timeout, @@ -526,11 +561,14 @@ async def create_async( "LargeRoom": serialize.boolean_to_string(large_room), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RoomInstance(self._version, payload) @@ -726,7 +764,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return RoomPage(self._version, response) async def page_async( @@ -765,8 +809,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return RoomPage(self._version, response) diff --git a/twilio/rest/video/v1/room/participant/__init__.py b/twilio/rest/video/v1/room/participant/__init__.py index 145d95429a..7e012e8d37 100644 --- a/twilio/rest/video/v1/room/participant/__init__.py +++ b/twilio/rest/video/v1/room/participant/__init__.py @@ -31,6 +31,7 @@ class ParticipantInstance(InstanceResource): class Status(object): CONNECTED = "connected" DISCONNECTED = "disconnected" + RECONNECTING = "reconnecting" """ :ivar sid: The unique string that we created to identify the RoomParticipant resource. @@ -215,10 +216,11 @@ def fetch(self) -> ParticipantInstance: :returns: The fetched ParticipantInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ParticipantInstance( self._version, @@ -235,9 +237,12 @@ async def fetch_async(self) -> ParticipantInstance: :returns: The fetched ParticipantInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ParticipantInstance( @@ -257,16 +262,20 @@ def update( :returns: The updated ParticipantInstance """ + data = values.of( { "Status": status, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ParticipantInstance( @@ -286,16 +295,20 @@ async def update_async( :returns: The updated ParticipantInstance """ + data = values.of( { "Status": status, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ParticipantInstance( @@ -597,7 +610,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ParticipantPage(self._version, response, self._solution) async def page_async( @@ -636,8 +655,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ParticipantPage(self._version, response, self._solution) diff --git a/twilio/rest/video/v1/room/participant/anonymize.py b/twilio/rest/video/v1/room/participant/anonymize.py index e9a7f1383e..0560d3eff4 100644 --- a/twilio/rest/video/v1/room/participant/anonymize.py +++ b/twilio/rest/video/v1/room/participant/anonymize.py @@ -144,12 +144,14 @@ def update(self) -> AnonymizeInstance: :returns: The updated AnonymizeInstance """ + data = values.of({}) + headers = values.of({}) + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AnonymizeInstance( @@ -166,12 +168,14 @@ async def update_async(self) -> AnonymizeInstance: :returns: The updated AnonymizeInstance """ + data = values.of({}) + headers = values.of({}) + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return AnonymizeInstance( diff --git a/twilio/rest/video/v1/room/participant/published_track.py b/twilio/rest/video/v1/room/participant/published_track.py index 1fa84827b6..a766b276ab 100644 --- a/twilio/rest/video/v1/room/participant/published_track.py +++ b/twilio/rest/video/v1/room/participant/published_track.py @@ -148,10 +148,11 @@ def fetch(self) -> PublishedTrackInstance: :returns: The fetched PublishedTrackInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return PublishedTrackInstance( self._version, @@ -169,9 +170,12 @@ async def fetch_async(self) -> PublishedTrackInstance: :returns: The fetched PublishedTrackInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return PublishedTrackInstance( @@ -367,7 +371,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return PublishedTrackPage(self._version, response, self._solution) async def page_async( @@ -394,8 +404,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return PublishedTrackPage(self._version, response, self._solution) diff --git a/twilio/rest/video/v1/room/participant/subscribe_rules.py b/twilio/rest/video/v1/room/participant/subscribe_rules.py index 3015163e6d..992f8a374b 100644 --- a/twilio/rest/video/v1/room/participant/subscribe_rules.py +++ b/twilio/rest/video/v1/room/participant/subscribe_rules.py @@ -95,8 +95,11 @@ def fetch(self) -> SubscribeRulesInstance: :returns: The fetched SubscribeRulesInstance """ + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - payload = self._version.fetch(method="GET", uri=self._uri) + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return SubscribeRulesInstance( self._version, @@ -112,8 +115,13 @@ async def fetch_async(self) -> SubscribeRulesInstance: :returns: The fetched SubscribeRulesInstance """ + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" - payload = await self._version.fetch_async(method="GET", uri=self._uri) + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) return SubscribeRulesInstance( self._version, @@ -132,16 +140,20 @@ def update( :returns: The created SubscribeRulesInstance """ + data = values.of( { "Rules": serialize.object(rules), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SubscribeRulesInstance( @@ -161,16 +173,20 @@ async def update_async( :returns: The created SubscribeRulesInstance """ + data = values.of( { "Rules": serialize.object(rules), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SubscribeRulesInstance( diff --git a/twilio/rest/video/v1/room/participant/subscribed_track.py b/twilio/rest/video/v1/room/participant/subscribed_track.py index 7c915095ec..8baea148dc 100644 --- a/twilio/rest/video/v1/room/participant/subscribed_track.py +++ b/twilio/rest/video/v1/room/participant/subscribed_track.py @@ -150,10 +150,11 @@ def fetch(self) -> SubscribedTrackInstance: :returns: The fetched SubscribedTrackInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return SubscribedTrackInstance( self._version, @@ -171,9 +172,12 @@ async def fetch_async(self) -> SubscribedTrackInstance: :returns: The fetched SubscribedTrackInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return SubscribedTrackInstance( @@ -369,7 +373,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return SubscribedTrackPage(self._version, response, self._solution) async def page_async( @@ -396,8 +406,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return SubscribedTrackPage(self._version, response, self._solution) diff --git a/twilio/rest/video/v1/room/recording_rules.py b/twilio/rest/video/v1/room/recording_rules.py index 6e731a1458..d79d465c28 100644 --- a/twilio/rest/video/v1/room/recording_rules.py +++ b/twilio/rest/video/v1/room/recording_rules.py @@ -80,8 +80,11 @@ def fetch(self) -> RecordingRulesInstance: :returns: The fetched RecordingRulesInstance """ + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - payload = self._version.fetch(method="GET", uri=self._uri) + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return RecordingRulesInstance( self._version, payload, room_sid=self._solution["room_sid"] @@ -94,8 +97,13 @@ async def fetch_async(self) -> RecordingRulesInstance: :returns: The fetched RecordingRulesInstance """ + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" - payload = await self._version.fetch_async(method="GET", uri=self._uri) + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) return RecordingRulesInstance( self._version, payload, room_sid=self._solution["room_sid"] @@ -111,16 +119,20 @@ def update( :returns: The created RecordingRulesInstance """ + data = values.of( { "Rules": serialize.object(rules), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RecordingRulesInstance( @@ -137,16 +149,20 @@ async def update_async( :returns: The created RecordingRulesInstance """ + data = values.of( { "Rules": serialize.object(rules), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RecordingRulesInstance( diff --git a/twilio/rest/video/v1/room/room_recording.py b/twilio/rest/video/v1/room/room_recording.py index db67f29947..21d433ce38 100644 --- a/twilio/rest/video/v1/room/room_recording.py +++ b/twilio/rest/video/v1/room/room_recording.py @@ -192,10 +192,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -204,9 +204,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> RoomRecordingInstance: @@ -217,10 +219,11 @@ def fetch(self) -> RoomRecordingInstance: :returns: The fetched RoomRecordingInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return RoomRecordingInstance( self._version, @@ -237,9 +240,12 @@ async def fetch_async(self) -> RoomRecordingInstance: :returns: The fetched RoomRecordingInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return RoomRecordingInstance( @@ -489,7 +495,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return RoomRecordingPage(self._version, response, self._solution) async def page_async( @@ -528,8 +540,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return RoomRecordingPage(self._version, response, self._solution) diff --git a/twilio/rest/voice/v1/archived_call.py b/twilio/rest/voice/v1/archived_call.py index ec8a5bb68e..939f1a03e2 100644 --- a/twilio/rest/voice/v1/archived_call.py +++ b/twilio/rest/voice/v1/archived_call.py @@ -13,6 +13,7 @@ """ from datetime import date +from twilio.base import values from twilio.base.instance_context import InstanceContext from twilio.base.list_resource import ListResource @@ -45,10 +46,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -57,9 +58,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def __repr__(self) -> str: diff --git a/twilio/rest/voice/v1/byoc_trunk.py b/twilio/rest/voice/v1/byoc_trunk.py index a85cae660a..304bdd78a5 100644 --- a/twilio/rest/voice/v1/byoc_trunk.py +++ b/twilio/rest/voice/v1/byoc_trunk.py @@ -242,10 +242,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -254,9 +254,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> ByocTrunkInstance: @@ -267,10 +269,11 @@ def fetch(self) -> ByocTrunkInstance: :returns: The fetched ByocTrunkInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ByocTrunkInstance( self._version, @@ -286,9 +289,12 @@ async def fetch_async(self) -> ByocTrunkInstance: :returns: The fetched ByocTrunkInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ByocTrunkInstance( @@ -326,6 +332,7 @@ def update( :returns: The updated ByocTrunkInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -340,11 +347,14 @@ def update( "FromDomainSid": from_domain_sid, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ByocTrunkInstance(self._version, payload, sid=self._solution["sid"]) @@ -378,6 +388,7 @@ async def update_async( :returns: The updated ByocTrunkInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -392,11 +403,14 @@ async def update_async( "FromDomainSid": from_domain_sid, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ByocTrunkInstance(self._version, payload, sid=self._solution["sid"]) @@ -487,11 +501,14 @@ def create( "FromDomainSid": from_domain_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ByocTrunkInstance(self._version, payload) @@ -540,11 +557,14 @@ async def create_async( "FromDomainSid": from_domain_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ByocTrunkInstance(self._version, payload) @@ -676,7 +696,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ByocTrunkPage(self._version, response) async def page_async( @@ -703,8 +729,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ByocTrunkPage(self._version, response) diff --git a/twilio/rest/voice/v1/connection_policy/__init__.py b/twilio/rest/voice/v1/connection_policy/__init__.py index d1d8aac893..e2a56929c7 100644 --- a/twilio/rest/voice/v1/connection_policy/__init__.py +++ b/twilio/rest/voice/v1/connection_policy/__init__.py @@ -180,10 +180,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -192,9 +192,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> ConnectionPolicyInstance: @@ -205,10 +207,11 @@ def fetch(self) -> ConnectionPolicyInstance: :returns: The fetched ConnectionPolicyInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ConnectionPolicyInstance( self._version, @@ -224,9 +227,12 @@ async def fetch_async(self) -> ConnectionPolicyInstance: :returns: The fetched ConnectionPolicyInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ConnectionPolicyInstance( @@ -245,16 +251,20 @@ def update( :returns: The updated ConnectionPolicyInstance """ + data = values.of( { "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ConnectionPolicyInstance( @@ -271,16 +281,20 @@ async def update_async( :returns: The updated ConnectionPolicyInstance """ + data = values.of( { "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ConnectionPolicyInstance( @@ -357,11 +371,14 @@ def create( "FriendlyName": friendly_name, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ConnectionPolicyInstance(self._version, payload) @@ -382,11 +399,14 @@ async def create_async( "FriendlyName": friendly_name, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ConnectionPolicyInstance(self._version, payload) @@ -518,7 +538,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ConnectionPolicyPage(self._version, response) async def page_async( @@ -545,8 +571,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ConnectionPolicyPage(self._version, response) diff --git a/twilio/rest/voice/v1/connection_policy/connection_policy_target.py b/twilio/rest/voice/v1/connection_policy/connection_policy_target.py index 2fa490880a..03f4fd607d 100644 --- a/twilio/rest/voice/v1/connection_policy/connection_policy_target.py +++ b/twilio/rest/voice/v1/connection_policy/connection_policy_target.py @@ -212,10 +212,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -224,9 +224,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> ConnectionPolicyTargetInstance: @@ -237,10 +239,11 @@ def fetch(self) -> ConnectionPolicyTargetInstance: :returns: The fetched ConnectionPolicyTargetInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return ConnectionPolicyTargetInstance( self._version, @@ -257,9 +260,12 @@ async def fetch_async(self) -> ConnectionPolicyTargetInstance: :returns: The fetched ConnectionPolicyTargetInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return ConnectionPolicyTargetInstance( @@ -288,6 +294,7 @@ def update( :returns: The updated ConnectionPolicyTargetInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -297,11 +304,14 @@ def update( "Enabled": serialize.boolean_to_string(enabled), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ConnectionPolicyTargetInstance( @@ -330,6 +340,7 @@ async def update_async( :returns: The updated ConnectionPolicyTargetInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -339,11 +350,14 @@ async def update_async( "Enabled": serialize.boolean_to_string(enabled), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ConnectionPolicyTargetInstance( @@ -435,11 +449,14 @@ def create( "Enabled": serialize.boolean_to_string(enabled), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ConnectionPolicyTargetInstance( @@ -477,11 +494,14 @@ async def create_async( "Enabled": serialize.boolean_to_string(enabled), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return ConnectionPolicyTargetInstance( @@ -617,7 +637,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return ConnectionPolicyTargetPage(self._version, response, self._solution) async def page_async( @@ -644,8 +670,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return ConnectionPolicyTargetPage(self._version, response, self._solution) diff --git a/twilio/rest/voice/v1/dialing_permissions/bulk_country_update.py b/twilio/rest/voice/v1/dialing_permissions/bulk_country_update.py index 60aa2642f0..4059be8dd7 100644 --- a/twilio/rest/voice/v1/dialing_permissions/bulk_country_update.py +++ b/twilio/rest/voice/v1/dialing_permissions/bulk_country_update.py @@ -71,11 +71,14 @@ def create(self, update_request: str) -> BulkCountryUpdateInstance: "UpdateRequest": update_request, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return BulkCountryUpdateInstance(self._version, payload) @@ -94,11 +97,14 @@ async def create_async(self, update_request: str) -> BulkCountryUpdateInstance: "UpdateRequest": update_request, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return BulkCountryUpdateInstance(self._version, payload) diff --git a/twilio/rest/voice/v1/dialing_permissions/country/__init__.py b/twilio/rest/voice/v1/dialing_permissions/country/__init__.py index 2b9285c112..6a60c23a2f 100644 --- a/twilio/rest/voice/v1/dialing_permissions/country/__init__.py +++ b/twilio/rest/voice/v1/dialing_permissions/country/__init__.py @@ -140,10 +140,11 @@ def fetch(self) -> CountryInstance: :returns: The fetched CountryInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return CountryInstance( self._version, @@ -159,9 +160,12 @@ async def fetch_async(self) -> CountryInstance: :returns: The fetched CountryInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return CountryInstance( @@ -451,7 +455,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return CountryPage(self._version, response) async def page_async( @@ -502,8 +512,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return CountryPage(self._version, response) diff --git a/twilio/rest/voice/v1/dialing_permissions/country/highrisk_special_prefix.py b/twilio/rest/voice/v1/dialing_permissions/country/highrisk_special_prefix.py index 9303f2c9ae..75300e928c 100644 --- a/twilio/rest/voice/v1/dialing_permissions/country/highrisk_special_prefix.py +++ b/twilio/rest/voice/v1/dialing_permissions/country/highrisk_special_prefix.py @@ -215,7 +215,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return HighriskSpecialPrefixPage(self._version, response, self._solution) async def page_async( @@ -242,8 +248,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return HighriskSpecialPrefixPage(self._version, response, self._solution) diff --git a/twilio/rest/voice/v1/dialing_permissions/settings.py b/twilio/rest/voice/v1/dialing_permissions/settings.py index 20d845673a..9e7aa0babb 100644 --- a/twilio/rest/voice/v1/dialing_permissions/settings.py +++ b/twilio/rest/voice/v1/dialing_permissions/settings.py @@ -126,10 +126,11 @@ def fetch(self) -> SettingsInstance: :returns: The fetched SettingsInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return SettingsInstance( self._version, @@ -144,9 +145,12 @@ async def fetch_async(self) -> SettingsInstance: :returns: The fetched SettingsInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return SettingsInstance( @@ -164,6 +168,7 @@ def update( :returns: The updated SettingsInstance """ + data = values.of( { "DialingPermissionsInheritance": serialize.boolean_to_string( @@ -171,11 +176,14 @@ def update( ), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SettingsInstance(self._version, payload) @@ -190,6 +198,7 @@ async def update_async( :returns: The updated SettingsInstance """ + data = values.of( { "DialingPermissionsInheritance": serialize.boolean_to_string( @@ -197,11 +206,14 @@ async def update_async( ), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SettingsInstance(self._version, payload) diff --git a/twilio/rest/voice/v1/ip_record.py b/twilio/rest/voice/v1/ip_record.py index ee409ba78c..05e9741fa5 100644 --- a/twilio/rest/voice/v1/ip_record.py +++ b/twilio/rest/voice/v1/ip_record.py @@ -172,10 +172,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -184,9 +184,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> IpRecordInstance: @@ -197,10 +199,11 @@ def fetch(self) -> IpRecordInstance: :returns: The fetched IpRecordInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return IpRecordInstance( self._version, @@ -216,9 +219,12 @@ async def fetch_async(self) -> IpRecordInstance: :returns: The fetched IpRecordInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return IpRecordInstance( @@ -237,16 +243,20 @@ def update( :returns: The updated IpRecordInstance """ + data = values.of( { "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return IpRecordInstance(self._version, payload, sid=self._solution["sid"]) @@ -261,16 +271,20 @@ async def update_async( :returns: The updated IpRecordInstance """ + data = values.of( { "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return IpRecordInstance(self._version, payload, sid=self._solution["sid"]) @@ -340,11 +354,14 @@ def create( "CidrPrefixLength": cidr_prefix_length, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return IpRecordInstance(self._version, payload) @@ -372,11 +389,14 @@ async def create_async( "CidrPrefixLength": cidr_prefix_length, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return IpRecordInstance(self._version, payload) @@ -508,7 +528,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return IpRecordPage(self._version, response) async def page_async( @@ -535,8 +561,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return IpRecordPage(self._version, response) diff --git a/twilio/rest/voice/v1/source_ip_mapping.py b/twilio/rest/voice/v1/source_ip_mapping.py index 8a0d4a9126..749d2b0034 100644 --- a/twilio/rest/voice/v1/source_ip_mapping.py +++ b/twilio/rest/voice/v1/source_ip_mapping.py @@ -162,10 +162,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -174,9 +174,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> SourceIpMappingInstance: @@ -187,10 +189,11 @@ def fetch(self) -> SourceIpMappingInstance: :returns: The fetched SourceIpMappingInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return SourceIpMappingInstance( self._version, @@ -206,9 +209,12 @@ async def fetch_async(self) -> SourceIpMappingInstance: :returns: The fetched SourceIpMappingInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return SourceIpMappingInstance( @@ -225,16 +231,20 @@ def update(self, sip_domain_sid: str) -> SourceIpMappingInstance: :returns: The updated SourceIpMappingInstance """ + data = values.of( { "SipDomainSid": sip_domain_sid, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SourceIpMappingInstance( @@ -249,16 +259,20 @@ async def update_async(self, sip_domain_sid: str) -> SourceIpMappingInstance: :returns: The updated SourceIpMappingInstance """ + data = values.of( { "SipDomainSid": sip_domain_sid, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SourceIpMappingInstance( @@ -325,11 +339,14 @@ def create( "SipDomainSid": sip_domain_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SourceIpMappingInstance(self._version, payload) @@ -352,11 +369,14 @@ async def create_async( "SipDomainSid": sip_domain_sid, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SourceIpMappingInstance(self._version, payload) @@ -488,7 +508,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return SourceIpMappingPage(self._version, response) async def page_async( @@ -515,8 +541,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return SourceIpMappingPage(self._version, response) diff --git a/twilio/rest/wireless/v1/command.py b/twilio/rest/wireless/v1/command.py index f310db8918..a6e8f0b39d 100644 --- a/twilio/rest/wireless/v1/command.py +++ b/twilio/rest/wireless/v1/command.py @@ -174,10 +174,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -186,9 +186,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> CommandInstance: @@ -199,10 +201,11 @@ def fetch(self) -> CommandInstance: :returns: The fetched CommandInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return CommandInstance( self._version, @@ -218,9 +221,12 @@ async def fetch_async(self) -> CommandInstance: :returns: The fetched CommandInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return CommandInstance( @@ -308,11 +314,14 @@ def create( ), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CommandInstance(self._version, payload) @@ -354,11 +363,14 @@ async def create_async( ), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return CommandInstance(self._version, payload) @@ -554,7 +566,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return CommandPage(self._version, response) async def page_async( @@ -593,8 +611,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return CommandPage(self._version, response) diff --git a/twilio/rest/wireless/v1/rate_plan.py b/twilio/rest/wireless/v1/rate_plan.py index 0ee1e205a2..23efabe9b0 100644 --- a/twilio/rest/wireless/v1/rate_plan.py +++ b/twilio/rest/wireless/v1/rate_plan.py @@ -23,6 +23,11 @@ class RatePlanInstance(InstanceResource): + + class DataLimitStrategy(object): + BLOCK = "block" + THROTTLE = "throttle" + """ :ivar sid: The unique string that we created to identify the RatePlan resource. :ivar unique_name: An application-defined string that uniquely identifies the resource. It can be used in place of the resource's `sid` in the URL to address the resource. @@ -202,10 +207,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -214,9 +219,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> RatePlanInstance: @@ -227,10 +234,11 @@ def fetch(self) -> RatePlanInstance: :returns: The fetched RatePlanInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return RatePlanInstance( self._version, @@ -246,9 +254,12 @@ async def fetch_async(self) -> RatePlanInstance: :returns: The fetched RatePlanInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return RatePlanInstance( @@ -270,17 +281,21 @@ def update( :returns: The updated RatePlanInstance """ + data = values.of( { "UniqueName": unique_name, "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RatePlanInstance(self._version, payload, sid=self._solution["sid"]) @@ -298,17 +313,21 @@ async def update_async( :returns: The updated RatePlanInstance """ + data = values.of( { "UniqueName": unique_name, "FriendlyName": friendly_name, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RatePlanInstance(self._version, payload, sid=self._solution["sid"]) @@ -368,6 +387,9 @@ def create( international_roaming: Union[List[str], object] = values.unset, national_roaming_data_limit: Union[int, object] = values.unset, international_roaming_data_limit: Union[int, object] = values.unset, + data_limit_strategy: Union[ + "RatePlanInstance.DataLimitStrategy", object + ] = values.unset, ) -> RatePlanInstance: """ Create the RatePlanInstance @@ -383,6 +405,7 @@ def create( :param international_roaming: The list of services that SIMs capable of using GPRS/3G/4G/LTE data connectivity can use outside of the United States. Can contain: `data` and `messaging`. :param national_roaming_data_limit: The total data usage (download and upload combined) in Megabytes that the Network allows during one month on non-home networks in the United States. The metering period begins the day of activation and ends on the same day in the following month. Can be up to 2TB. See [national roaming](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource#national-roaming) for more info. :param international_roaming_data_limit: The total data usage (download and upload combined) in Megabytes that the Network allows during one month when roaming outside the United States. Can be up to 2TB. + :param data_limit_strategy: :returns: The created RatePlanInstance """ @@ -404,13 +427,17 @@ def create( ), "NationalRoamingDataLimit": national_roaming_data_limit, "InternationalRoamingDataLimit": international_roaming_data_limit, + "DataLimitStrategy": data_limit_strategy, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RatePlanInstance(self._version, payload) @@ -428,6 +455,9 @@ async def create_async( international_roaming: Union[List[str], object] = values.unset, national_roaming_data_limit: Union[int, object] = values.unset, international_roaming_data_limit: Union[int, object] = values.unset, + data_limit_strategy: Union[ + "RatePlanInstance.DataLimitStrategy", object + ] = values.unset, ) -> RatePlanInstance: """ Asynchronously create the RatePlanInstance @@ -443,6 +473,7 @@ async def create_async( :param international_roaming: The list of services that SIMs capable of using GPRS/3G/4G/LTE data connectivity can use outside of the United States. Can contain: `data` and `messaging`. :param national_roaming_data_limit: The total data usage (download and upload combined) in Megabytes that the Network allows during one month on non-home networks in the United States. The metering period begins the day of activation and ends on the same day in the following month. Can be up to 2TB. See [national roaming](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource#national-roaming) for more info. :param international_roaming_data_limit: The total data usage (download and upload combined) in Megabytes that the Network allows during one month when roaming outside the United States. Can be up to 2TB. + :param data_limit_strategy: :returns: The created RatePlanInstance """ @@ -464,13 +495,17 @@ async def create_async( ), "NationalRoamingDataLimit": national_roaming_data_limit, "InternationalRoamingDataLimit": international_roaming_data_limit, + "DataLimitStrategy": data_limit_strategy, } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return RatePlanInstance(self._version, payload) @@ -602,7 +637,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return RatePlanPage(self._version, response) async def page_async( @@ -629,8 +670,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return RatePlanPage(self._version, response) diff --git a/twilio/rest/wireless/v1/sim/__init__.py b/twilio/rest/wireless/v1/sim/__init__.py index f0d21c447e..cba0eeec71 100644 --- a/twilio/rest/wireless/v1/sim/__init__.py +++ b/twilio/rest/wireless/v1/sim/__init__.py @@ -343,10 +343,10 @@ def delete(self) -> bool: :returns: True if delete succeeds, False otherwise """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async(self) -> bool: """ @@ -355,9 +355,11 @@ async def delete_async(self) -> bool: :returns: True if delete succeeds, False otherwise """ + + headers = values.of({}) + return await self._version.delete_async( - method="DELETE", - uri=self._uri, + method="DELETE", uri=self._uri, headers=headers ) def fetch(self) -> SimInstance: @@ -368,10 +370,11 @@ def fetch(self) -> SimInstance: :returns: The fetched SimInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) return SimInstance( self._version, @@ -387,9 +390,12 @@ async def fetch_async(self) -> SimInstance: :returns: The fetched SimInstance """ + headers = values.of({}) + + headers["Accept"] = "application/json" + payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + method="GET", uri=self._uri, headers=headers ) return SimInstance( @@ -443,6 +449,7 @@ def update( :returns: The updated SimInstance """ + data = values.of( { "UniqueName": unique_name, @@ -465,11 +472,14 @@ def update( "AccountSid": account_sid, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SimInstance(self._version, payload, sid=self._solution["sid"]) @@ -519,6 +529,7 @@ async def update_async( :returns: The updated SimInstance """ + data = values.of( { "UniqueName": unique_name, @@ -541,11 +552,14 @@ async def update_async( "AccountSid": account_sid, } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SimInstance(self._version, payload, sid=self._solution["sid"]) @@ -822,7 +836,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return SimPage(self._version, response) async def page_async( @@ -864,8 +884,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return SimPage(self._version, response) diff --git a/twilio/rest/wireless/v1/sim/data_session.py b/twilio/rest/wireless/v1/sim/data_session.py index 649eb49631..b4c50d608d 100644 --- a/twilio/rest/wireless/v1/sim/data_session.py +++ b/twilio/rest/wireless/v1/sim/data_session.py @@ -252,7 +252,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return DataSessionPage(self._version, response, self._solution) async def page_async( @@ -279,8 +285,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return DataSessionPage(self._version, response, self._solution) diff --git a/twilio/rest/wireless/v1/sim/usage_record.py b/twilio/rest/wireless/v1/sim/usage_record.py index 8b1db6d0da..1cd26b6c2e 100644 --- a/twilio/rest/wireless/v1/sim/usage_record.py +++ b/twilio/rest/wireless/v1/sim/usage_record.py @@ -269,7 +269,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return UsageRecordPage(self._version, response, self._solution) async def page_async( @@ -305,8 +311,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return UsageRecordPage(self._version, response, self._solution) diff --git a/twilio/rest/wireless/v1/usage_record.py b/twilio/rest/wireless/v1/usage_record.py index 43e34469ce..07135cf98b 100644 --- a/twilio/rest/wireless/v1/usage_record.py +++ b/twilio/rest/wireless/v1/usage_record.py @@ -256,7 +256,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) return UsageRecordPage(self._version, response) async def page_async( @@ -292,8 +298,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) return UsageRecordPage(self._version, response) diff --git a/twilio/twiml/voice_response.py b/twilio/twiml/voice_response.py index 6beb109dc5..6f3d17e92c 100644 --- a/twilio/twiml/voice_response.py +++ b/twilio/twiml/voice_response.py @@ -50,6 +50,7 @@ def dial( sequential=None, refer_url=None, refer_method=None, + events=None, **kwargs ): """ @@ -73,6 +74,7 @@ def dial( :param sequential: Used to determine if child TwiML nouns should be dialed in order, one after the other (sequential) or dial all at once (parallel). Default is false, parallel :param refer_url: Webhook that will receive future SIP REFER requests :param refer_method: The HTTP method to use for the refer Webhook + :param events: Subscription to events :param kwargs: additional attributes :returns: element @@ -97,6 +99,7 @@ def dial( sequential=sequential, refer_url=refer_url, refer_method=refer_method, + events=events, **kwargs ) ) @@ -663,13 +666,84 @@ def siprec( ) ) + def transcription( + self, + name=None, + track=None, + status_callback_url=None, + status_callback_method=None, + inbound_track_label=None, + outbound_track_label=None, + partial_results=None, + language_code=None, + transcription_engine=None, + profanity_filter=None, + speech_model=None, + hints=None, + enable_automatic_punctuation=None, + intelligence_service=None, + **kwargs + ): + """ + Create a element + + :param name: Friendly name given to the Transcription + :param track: Track to be analyze by the provider + :param status_callback_url: Status Callback URL + :param status_callback_method: Status Callback URL method + :param inbound_track_label: Friendly name given to the Inbound Track + :param outbound_track_label: Friendly name given to the Outbound Track Label + :param partial_results: Indicates if partial results are going to be send to the customer + :param language_code: Language Code used by the transcription engine + :param transcription_engine: Transcription Engine to be used + :param profanity_filter: Enable Profanity Filter + :param speech_model: Speech Model used by the transcription engine + :param hints: Hints to be provided to the transcription engine + :param enable_automatic_punctuation: Enable Automatic Punctuation + :param intelligence_service: The SID or the unique name of the Intelligence Service to be used + :param kwargs: additional attributes + + :returns: element + """ + return self.nest( + Transcription( + name=name, + track=track, + status_callback_url=status_callback_url, + status_callback_method=status_callback_method, + inbound_track_label=inbound_track_label, + outbound_track_label=outbound_track_label, + partial_results=partial_results, + language_code=language_code, + transcription_engine=transcription_engine, + profanity_filter=profanity_filter, + speech_model=speech_model, + hints=hints, + enable_automatic_punctuation=enable_automatic_punctuation, + intelligence_service=intelligence_service, + **kwargs + ) + ) -class Siprec(TwiML): - """ TwiML Noun""" + +class Transcription(TwiML): + """ TwiML Noun""" def __init__(self, **kwargs): - super(Siprec, self).__init__(**kwargs) - self.name = "Siprec" + super(Transcription, self).__init__(**kwargs) + self.name = "Transcription" + + def config(self, name=None, value=None, **kwargs): + """ + Create a element + + :param name: The name of the custom config + :param value: The value of the custom config + :param kwargs: additional attributes + + :returns: element + """ + return self.nest(Config(name=name, value=value, **kwargs)) def parameter(self, name=None, value=None, **kwargs): """ @@ -692,6 +766,34 @@ def __init__(self, **kwargs): self.name = "Parameter" +class Config(TwiML): + """ TwiML Noun""" + + def __init__(self, **kwargs): + super(Config, self).__init__(**kwargs) + self.name = "Config" + + +class Siprec(TwiML): + """ TwiML Noun""" + + def __init__(self, **kwargs): + super(Siprec, self).__init__(**kwargs) + self.name = "Siprec" + + def parameter(self, name=None, value=None, **kwargs): + """ + Create a element + + :param name: The name of the custom parameter + :param value: The value of the custom parameter + :param kwargs: additional attributes + + :returns: element + """ + return self.nest(Parameter(name=name, value=value, **kwargs)) + + class Stream(TwiML): """ TwiML Noun""" @@ -786,6 +888,65 @@ def siprec( ) ) + def transcription( + self, + name=None, + track=None, + status_callback_url=None, + status_callback_method=None, + inbound_track_label=None, + outbound_track_label=None, + partial_results=None, + language_code=None, + transcription_engine=None, + profanity_filter=None, + speech_model=None, + hints=None, + enable_automatic_punctuation=None, + intelligence_service=None, + **kwargs + ): + """ + Create a element + + :param name: Friendly name given to the Transcription + :param track: Track to be analyze by the provider + :param status_callback_url: Status Callback URL + :param status_callback_method: Status Callback URL method + :param inbound_track_label: Friendly name given to the Inbound Track + :param outbound_track_label: Friendly name given to the Outbound Track Label + :param partial_results: Indicates if partial results are going to be send to the customer + :param language_code: Language Code used by the transcription engine + :param transcription_engine: Transcription Engine to be used + :param profanity_filter: Enable Profanity Filter + :param speech_model: Speech Model used by the transcription engine + :param hints: Hints to be provided to the transcription engine + :param enable_automatic_punctuation: Enable Automatic Punctuation + :param intelligence_service: The SID or the unique name of the Intelligence Service to be used + :param kwargs: additional attributes + + :returns: element + """ + return self.nest( + Transcription( + name=name, + track=track, + status_callback_url=status_callback_url, + status_callback_method=status_callback_method, + inbound_track_label=inbound_track_label, + outbound_track_label=outbound_track_label, + partial_results=partial_results, + language_code=language_code, + transcription_engine=transcription_engine, + profanity_filter=profanity_filter, + speech_model=speech_model, + hints=hints, + enable_automatic_punctuation=enable_automatic_punctuation, + intelligence_service=intelligence_service, + **kwargs + ) + ) + class Prompt(TwiML): """ Twiml Verb""" @@ -2573,6 +2734,248 @@ def conversation( ) ) + def conversation_relay( + self, + url=None, + language=None, + tts_language=None, + transcription_language=None, + tts_provider=None, + voice=None, + transcription_provider=None, + speech_model=None, + profanity_filter=None, + dtmf_detection=None, + welcome_greeting=None, + partial_prompts=None, + interruptible=None, + interrupt_by_dtmf=None, + welcome_greeting_interruptible=None, + debug=None, + **kwargs + ): + """ + Create a element + + :param url: URL of the remote service where the session is connected to + :param language: Language to be used for both text-to-speech and transcription + :param tts_language: Language to be used for text-to-speech + :param transcription_language: Language to be used for transcription + :param tts_provider: Provider to be used for text-to-speech + :param voice: Voice to be used for text-to-speech + :param transcription_provider: Provider to be used for transcription + :param speech_model: Speech model to be used for transcription + :param profanity_filter: Whether profanities should be filtered out of the speech transcription + :param dtmf_detection: Whether DTMF tones should be detected and reported in speech transcription + :param welcome_greeting: The sentence to be played automatically when the session is connected + :param partial_prompts: Whether partial prompts should be reported to WebSocket server before the caller finishes speaking + :param interruptible: Whether caller's speaking can interrupt the play of text-to-speech + :param interrupt_by_dtmf: Whether DTMF tone can interrupt the play of text-to-speech + :param welcome_greeting_interruptible: Whether caller's speaking can interrupt the welcome greeting + :param debug: Whether debugging on the session is enabled + :param kwargs: additional attributes + + :returns: element + """ + return self.nest( + ConversationRelay( + url=url, + language=language, + tts_language=tts_language, + transcription_language=transcription_language, + tts_provider=tts_provider, + voice=voice, + transcription_provider=transcription_provider, + speech_model=speech_model, + profanity_filter=profanity_filter, + dtmf_detection=dtmf_detection, + welcome_greeting=welcome_greeting, + partial_prompts=partial_prompts, + interruptible=interruptible, + interrupt_by_dtmf=interrupt_by_dtmf, + welcome_greeting_interruptible=welcome_greeting_interruptible, + debug=debug, + **kwargs + ) + ) + + def assistant( + self, + id=None, + language=None, + tts_language=None, + transcription_language=None, + tts_provider=None, + voice=None, + transcription_provider=None, + speech_model=None, + profanity_filter=None, + dtmf_detection=None, + welcome_greeting=None, + partial_prompts=None, + interruptible=None, + interrupt_by_dtmf=None, + welcome_greeting_interruptible=None, + debug=None, + **kwargs + ): + """ + Create a element + + :param id: The assistant ID of the AI Assistant + :param language: Language to be used for both text-to-speech and transcription + :param tts_language: Language to be used for text-to-speech + :param transcription_language: Language to be used for transcription + :param tts_provider: Provider to be used for text-to-speech + :param voice: Voice to be used for text-to-speech + :param transcription_provider: Provider to be used for transcription + :param speech_model: Speech model to be used for transcription + :param profanity_filter: Whether profanities should be filtered out of the speech transcription + :param dtmf_detection: Whether DTMF tones should be detected and reported in speech transcription + :param welcome_greeting: The sentence to be played automatically when the session is connected + :param partial_prompts: Whether partial prompts should be reported to WebSocket server before the caller finishes speaking + :param interruptible: Whether caller's speaking can interrupt the play of text-to-speech + :param interrupt_by_dtmf: Whether DTMF tone can interrupt the play of text-to-speech + :param welcome_greeting_interruptible: Whether caller's speaking can interrupt the welcome greeting + :param debug: Whether debugging on the session is enabled + :param kwargs: additional attributes + + :returns: element + """ + return self.nest( + Assistant( + id=id, + language=language, + tts_language=tts_language, + transcription_language=transcription_language, + tts_provider=tts_provider, + voice=voice, + transcription_provider=transcription_provider, + speech_model=speech_model, + profanity_filter=profanity_filter, + dtmf_detection=dtmf_detection, + welcome_greeting=welcome_greeting, + partial_prompts=partial_prompts, + interruptible=interruptible, + interrupt_by_dtmf=interrupt_by_dtmf, + welcome_greeting_interruptible=welcome_greeting_interruptible, + debug=debug, + **kwargs + ) + ) + + +class Assistant(TwiML): + """ TwiML Noun""" + + def __init__(self, **kwargs): + super(Assistant, self).__init__(**kwargs) + self.name = "Assistant" + + def language( + self, + code=None, + tts_provider=None, + voice=None, + transcription_provider=None, + speech_model=None, + **kwargs + ): + """ + Create a element + + :param code: Language code of this language setting is for + :param tts_provider: Provider to be used for text-to-speech of this language + :param voice: Voice to be used for text-to-speech of this language + :param transcription_provider: Provider to be used for transcription of this language + :param speech_model: Speech model to be used for transcription of this language + :param kwargs: additional attributes + + :returns: element + """ + return self.nest( + Language( + code=code, + tts_provider=tts_provider, + voice=voice, + transcription_provider=transcription_provider, + speech_model=speech_model, + **kwargs + ) + ) + + def parameter(self, name=None, value=None, **kwargs): + """ + Create a element + + :param name: The name of the custom parameter + :param value: The value of the custom parameter + :param kwargs: additional attributes + + :returns: element + """ + return self.nest(Parameter(name=name, value=value, **kwargs)) + + +class Language(TwiML): + """ TwiML Noun""" + + def __init__(self, **kwargs): + super(Language, self).__init__(**kwargs) + self.name = "Language" + + +class ConversationRelay(TwiML): + """ TwiML Noun""" + + def __init__(self, **kwargs): + super(ConversationRelay, self).__init__(**kwargs) + self.name = "ConversationRelay" + + def language( + self, + code=None, + tts_provider=None, + voice=None, + transcription_provider=None, + speech_model=None, + **kwargs + ): + """ + Create a element + + :param code: Language code of this language setting is for + :param tts_provider: Provider to be used for text-to-speech of this language + :param voice: Voice to be used for text-to-speech of this language + :param transcription_provider: Provider to be used for transcription of this language + :param speech_model: Speech model to be used for transcription of this language + :param kwargs: additional attributes + + :returns: element + """ + return self.nest( + Language( + code=code, + tts_provider=tts_provider, + voice=voice, + transcription_provider=transcription_provider, + speech_model=speech_model, + **kwargs + ) + ) + + def parameter(self, name=None, value=None, **kwargs): + """ + Create a element + + :param name: The name of the custom parameter + :param value: The value of the custom parameter + :param kwargs: additional attributes + + :returns: element + """ + return self.nest(Parameter(name=name, value=value, **kwargs)) + class Conversation(TwiML): """ TwiML Noun""" @@ -2614,14 +3017,6 @@ def parameter(self, name=None, value=None, **kwargs): return self.nest(Parameter(name=name, value=value, **kwargs)) -class Config(TwiML): - """ TwiML Noun""" - - def __init__(self, **kwargs): - super(Config, self).__init__(**kwargs) - self.name = "Config" - - class Autopilot(TwiML): """ TwiML Noun"""