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 9bba6d8bac..f5bd133256 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' ] + python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12', '3.13' ] steps: - name: Checkout twilio-python uses: actions/checkout@v3 @@ -33,6 +33,7 @@ jobs: run: | pip install virtualenv --upgrade make install test-install + make prettier - name: Run the tests run: make test-with-coverage @@ -46,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 bd1ce355ca..d6e5e522d3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,1040 @@ twilio-python Changelog Here you can see the full list of changes between each twilio-python release. +[2025-07-10] Version 9.6.5 +-------------------------- +**Library - Fix** +- [PR #874](https://github.com/twilio/twilio-python/pull/874): delete non existing import in rest/preview. Thanks to [@lopenchi](https://github.com/lopenchi)! + +**Flex** +- update team name for web_channel, webchat_init_token, webchat_refresh_token + + +[2025-07-03] Version 9.6.4 +-------------------------- +**Library - Chore** +- [PR #865](https://github.com/twilio/twilio-python/pull/865): Remove references to microvisor. Thanks to [@akhani18](https://github.com/akhani18)! +- [PR #872](https://github.com/twilio/twilio-python/pull/872): support Python 3.13. Thanks to [@tiwarishubham635](https://github.com/tiwarishubham635)! +- [PR #870](https://github.com/twilio/twilio-python/pull/870): remove knowledge domain. Thanks to [@tiwarishubham635](https://github.com/tiwarishubham635)! + +**Bulkexports** +- Changed the type of 'details' field to be a list of objects instead of a single object + +**Conversations** +- Updates to `method` casing for ConfgurationAddress, ConversationScopedWebhook, and ServiceConversationScopedWebhook for RestProxy compatibility + +**Proxy** +- remove shortcodes resource as its no longer used + +**Serverless** +- Change log field level from type `ienum` to `string` in Logs api + +**Taskrouter** +- Remove `URL-encoded` from attributes param definition in tasks + +**Trunking** +- Added `symmetric_rtp_enabled` property on Trunks. + +**Twiml** +- Add support for `` noun under `` verb + + +[2025-06-12] Version 9.6.3 +-------------------------- +**Library - Chore** +- [PR #869](https://github.com/twilio/twilio-python/pull/869): Remove knowledge files. Thanks to [@krishnakalluri](https://github.com/krishnakalluri)! + +**Api** +- Change DependentPhoneNumber `capabilities` type `object` and `date_created`, `date_updated` to `date_time` +- Updated the `Default` value from 0 to 1 in the Recordings Resource `channels` property + +**Serverless** +- Update `ienum` type level in Logs api + +**Verify** +- Update Channel list in Verify Attempst API +- Update `ienum` type for Conversion_Status in Verify Attempts API + +**Twiml** +- Add `us2` to the list of supported values for the region attribute in the `` TwiML noun. + + +[2025-05-29] Version 9.6.2 +-------------------------- +**Library - Chore** +- [PR #862](https://github.com/twilio/twilio-python/pull/862): update iam token endpoint. Thanks to [@manisha1997](https://github.com/manisha1997)! + +**Api** +- Added several usage category enums to `usage_record` API + +**Numbers** +- Update the porting documentation + +**Verify** +- Update `ienum` type for Channels in Verify Attempts API + + +[2025-05-13] Version 9.6.1 +-------------------------- +**Accounts** +- Changes to add date_of_consent param in Bulk Consent API + +**Api** +- Change `friendly_name`, `date_created` and `date_updated` properties to type `string`. + +**Twiml** +- Update twiml definition for `` and `` + + +[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** +- Add new APIs for vendor authorize and token endpoints + + +[2024-03-12] Version 9.0.1 +-------------------------- +**Library - Chore** +- [PR #775](https://github.com/twilio/twilio-python/pull/775): removing preview.understand references. Thanks to [@tiwarishubham635](https://github.com/tiwarishubham635)! + +**Api** +- Correct precedence documentation for application_sid vs status_callback in message creation +- Mark MaxPrice as deprecated + +**Flex** +- Making `plugins` visibility to public + +**Messaging** +- Add new `errors` attribute to the Brand Registration resource. +- Mark `brand_feedback` attribute as deprecated. +- Mark `failure_reason` attribute as deprecated. +- The new `errors` attribute is expected to provide additional information about Brand registration failures and feedback (if any has been provided by The Campaign Registry). Consumers should use this attribute instead of `brand_feedback` and `failure_reason`. + +**Numbers** +- Correcting mount_name for porting port in fetch API + +**Trusthub** +- Add new field in statusCallbackUrl in compliance_registration. +- Add new field in isvRegisteringForSelfOrTenant in compliance_registration. + +**Twiml** +- Expanded description of Action parameter for Message verb + + +[2024-02-27] Version 9.0.0 +-------------------------- +**Note:** This release contains breaking changes, check our [upgrade guide](./UPGRADE.md###-2024-02-20-8xx-to-9xx) for detailed migration notes. + +**Library - Feature** +- [PR #767](https://github.com/twilio/twilio-python/pull/767): Merge branch '9.0.0-rc' into main. Thanks to [@tiwarishubham635](https://github.com/tiwarishubham635)! **(breaking change)** + +**Library - Chore** +- [PR #771](https://github.com/twilio/twilio-python/pull/771): added check for unset values. Thanks to [@tiwarishubham635](https://github.com/tiwarishubham635)! +- [PR #768](https://github.com/twilio/twilio-python/pull/768): cluster tests enabled. Thanks to [@sbansla](https://github.com/sbansla)! + +**Api** +- remove feedback and feedback summary from call resource + +**Flex** +- Adding `routing_properties` to Interactions Channels Participant + +**Lookups** +- Add new `line_status` package to the lookup response +- Remove `live_activity` package from the lookup response **(breaking change)** + +**Messaging** +- Add tollfree multiple rejection reasons response array + +**Trusthub** +- Add ENUM for businessRegistrationAuthority in compliance_registration. **(breaking change)** +- Add new field in isIsvEmbed in compliance_registration. +- Add additional optional fields in compliance_registration for Individual business type. + +**Twiml** +- Add support for new Amazon Polly and Google voices (Q1 2024) for `Say` verb + + +[2024-02-09] Version 8.13.0 +--------------------------- +**Library - Fix** +- [PR #753](https://github.com/twilio/twilio-python/pull/753): added boolean_to_string converter. Thanks to [@tiwarishubham635](https://github.com/tiwarishubham635)! + +**Library - Chore** +- [PR #758](https://github.com/twilio/twilio-python/pull/758): disable cluster test. Thanks to [@sbansla](https://github.com/sbansla)! +- [PR #760](https://github.com/twilio/twilio-python/pull/760): run make prettier. Thanks to [@tiwarishubham635](https://github.com/tiwarishubham635)! + +**Api** +- Updated service base url for connect apps and authorized connect apps APIs **(breaking change)** +- Update documentation to reflect RiskCheck GA +- Added optional parameter `CallToken` for create participant api + +**Events** +- Marked as GA + +**Flex** +- Adding `flex_instance_sid` to Flex Configuration +- Adding `provisioning_status` for Email Manager +- Adding `offline_config` to Flex Configuration + +**Insights** +- add flag to restrict access to unapid customers +- decommission voice-qualitystats-endpoint role + +**Intelligence** +- Add text-generation operator (for example conversation summary) results to existing OperatorResults collection. + +**Lookups** +- Remove `carrier` field from `sms_pumping_risk` and leave `carrier_risk_category` **(breaking change)** +- Remove carrier information from call forwarding package **(breaking change)** + +**Messaging** +- Add update instance endpoints to us_app_to_person api +- Add tollfree edit_allowed and edit_reason fields +- Update Phone Number, Short Code, Alpha Sender, US A2P and Channel Sender documentation +- Add DELETE support to Tollfree Verification resource + +**Numbers** +- Add Get Port In request api + +**Push** +- Migrated to new Push API V4 with Resilient Notification Delivery. + +**Serverless** +- Add node18 as a valid Build runtime + +**Taskrouter** +- Add `jitter_buffer_size` param in update reservation +- Add container attribute to task_queue_bulk_real_time_statistics endpoint +- Remove beta_feature check on task_queue_bulk_real_time_statistics endpoint + +**Trusthub** +- Add optional field NotificationEmail to the POST /v1/ComplianceInquiries/Customers/Initialize API +- Add additional optional fields in compliance_tollfree_inquiry.json +- Rename did to tollfree_phone_number in compliance_tollfree_inquiry.json +- Add new optional field notification_email to compliance_tollfree_inquiry.json + +**Verify** +- `Tags` property added again to Public Docs **(breaking change)** +- Remove `Tags` from Public Docs **(breaking change)** +- Add `VerifyEventSubscriptionEnabled` parameter to service create and update endpoints. +- Add `Tags` optional parameter on Verification creation. +- Update Verify TOTP maturity to GA. + + +[2024-01-25] Version 8.12.0 +--------------------------- +**Oauth** +- updated openid discovery endpoint uri **(breaking change)** +- Added device code authorization endpoint +- added oauth JWKS endpoint +- Get userinfo resource +- OpenID discovery resource +- Add new API for token endpoint + + +[2024-01-14] Version 8.11.1 +--------------------------- +**Library - Chore** +- [PR #749](https://github.com/twilio/twilio-python/pull/749): removing webhook test. Thanks to [@tiwarishubham635](https://github.com/tiwarishubham635)! + +**Push** +- Migrated to new Push API V4 with Resilient Notification Delivery. + + +[2023-12-14] Version 8.11.0 +--------------------------- +**Library - Chore** +- [PR #741](https://github.com/twilio/twilio-python/pull/741): upgrade to python 3.12. Thanks to [@tiwarishubham635](https://github.com/tiwarishubham635)! +- [PR #740](https://github.com/twilio/twilio-python/pull/740): bump aiohttp. Thanks to [@tiwarishubham635](https://github.com/tiwarishubham635)! + +**Api** +- Updated service base url for connect apps and authorized connect apps APIs **(breaking change)** + +**Events** +- Marked as GA + +**Insights** +- decommission voice-qualitystats-endpoint role + +**Numbers** +- Add Get Port In request api + +**Taskrouter** +- Add `jitter_buffer_size` param in update reservation + +**Trusthub** +- Add additional optional fields in compliance_tollfree_inquiry.json + +**Verify** +- Remove `Tags` from Public Docs **(breaking change)** + + +[2023-12-01] Version 8.10.3 +--------------------------- +**Verify** +- Add `VerifyEventSubscriptionEnabled` parameter to service create and update endpoints. + + +[2023-11-17] Version 8.10.2 +--------------------------- +**Library - Chore** +- [PR #733](https://github.com/twilio/twilio-python/pull/733): bumping aiohttp from 3.8.5 to 3.8.6. Thanks to [@tiwarishubham635](https://github.com/tiwarishubham635)! + +**Api** +- Update documentation to reflect RiskCheck GA + +**Messaging** +- Add tollfree edit_allowed and edit_reason fields +- Update Phone Number, Short Code, Alpha Sender, US A2P and Channel Sender documentation + +**Taskrouter** +- Add container attribute to task_queue_bulk_real_time_statistics endpoint + +**Trusthub** +- Rename did to tollfree_phone_number in compliance_tollfree_inquiry.json +- Add new optional field notification_email to compliance_tollfree_inquiry.json + +**Verify** +- Add `Tags` optional parameter on Verification creation. + + +[2023-11-06] Version 8.10.1 +--------------------------- +**Flex** +- Adding `provisioning_status` for Email Manager + +**Intelligence** +- Add text-generation operator (for example conversation summary) results to existing OperatorResults collection. + +**Messaging** +- Add DELETE support to Tollfree Verification resource + +**Serverless** +- Add node18 as a valid Build runtime + +**Verify** +- Update Verify TOTP maturity to GA. + + +[2023-10-19] Version 8.10.0 +--------------------------- +**Library - Fix** +- [PR #730](https://github.com/twilio/twilio-python/pull/730): Requirement changes. Thanks to [@tiwarishubham635](https://github.com/tiwarishubham635)! +- [PR #727](https://github.com/twilio/twilio-python/pull/727): Requirement changes. Thanks to [@tiwarishubham635](https://github.com/tiwarishubham635)! +- [PR #726](https://github.com/twilio/twilio-python/pull/726): requirements changes. Thanks to [@tiwarishubham635](https://github.com/tiwarishubham635)! + +**Accounts** +- Updated Safelist metadata to correct the docs. +- Add Global SafeList API changes + +**Api** +- Added optional parameter `CallToken` for create participant api + +**Flex** +- Adding `offline_config` to Flex Configuration + +**Intelligence** +- Deleted `redacted` parameter from fetching transcript in v2 **(breaking change)** + +**Lookups** +- Add new `phone_number_quality_score` package to the lookup response +- Remove `disposable_phone_number_risk` package **(breaking change)** + +**Messaging** +- Update US App To Person documentation with current `message_samples` requirements + +**Taskrouter** +- Remove beta_feature check on task_queue_bulk_real_time_statistics endpoint +- Add `virtual_start_time` property to tasks +- Updating `task_queue_data` format from `map` to `array` in the response of bulk get endpoint of TaskQueue Real Time Statistics API **(breaking change)** + + +[2023-10-05] Version 8.9.1 +-------------------------- +**Library - Chore** +- [PR #721](https://github.com/twilio/twilio-python/pull/721): Drop dependency on `pytz` by using stdlib `datetime.timezone.utc`. Thanks to [@Zac-HD](https://github.com/Zac-HD)! +- [PR #723](https://github.com/twilio/twilio-python/pull/723): twilio help changes. Thanks to [@kridai](https://github.com/kridai)! + +**Library - Fix** +- [PR #724](https://github.com/twilio/twilio-python/pull/724): Update ValidateSslCertificate method. Thanks to [@AsabuHere](https://github.com/AsabuHere)! + +**Lookups** +- Add test api support for Lookup v2 + + +[2023-09-21] Version 8.9.0 +-------------------------- +**Conversations** +- Enable conversation email bindings, email address configurations and email message subjects + +**Flex** +- Adding `console_errors_included` to Flex Configuration field `debugger_integrations` +- Introducing new channel status as `inactive` in modify channel endpoint for leave functionality **(breaking change)** +- Adding `citrix_voice_vdi` to Flex Configuration + +**Taskrouter** +- Add Update Queues, Workers, Workflow Real Time Statistics API to flex-rt-data-api-v2 endpoint +- Add Update Workspace Real Time Statistics API to flex-rt-data-api-v2 endpoint + + +[2023-09-07] Version 8.8.0 +-------------------------- +**Api** +- Make message tagging parameters public **(breaking change)** + +**Flex** +- Adding `agent_conv_end_methods` to Flex Configuration + +**Messaging** +- Mark Mesasging Services fallback_to_long_code feature obsolete + +**Numbers** +- Add Create Port In request api +- Renaming sid for bulk_hosting_sid and remove account_sid response field in numbers/v2/BulkHostedNumberOrders **(breaking change)** + +**Pricing** +- gate resources behind a beta_feature + + +[2023-08-24] Version 8.7.0 +-------------------------- +**Library - Test** +- [PR #719](https://github.com/twilio/twilio-python/pull/719): Update test_webhook.py. Thanks to [@kridai](https://github.com/kridai)! + +**Api** +- Add new property `RiskCheck` for SMS pumping protection feature only (public beta to be available soon): Include this parameter with a value of `disable` to skip any kind of risk check on the respective message request + +**Flex** +- Changing `sid` path param to `sid` in interaction channel participant update endpoint **(breaking change)** + +**Messaging** +- Add Channel Sender api +- Fixing country code docs and removing Zipwhip references + +**Numbers** +- Request status changed in numbers/v2/BulkHostedNumberOrders **(breaking change)** +- Add bulk hosting orders API under version `/v2 + + +[2023-08-10] Version 8.6.0 +-------------------------- +**Insights** +- Normalize annotations parameters in list summary api to be prefixed + +**Numbers** +- Change Bulk_hosted_sid from BHR to BH prefix in HNO and dependent under version `/v2` API's. **(breaking change)** +- Added parameter target_account_sid to portability and account_sid to response body + +**Verify** +- Remove beta feature flag to list attempts API. +- Remove beta feature flag to verifications summary attempts API. + + +[2023-07-27] Version 8.5.1 +-------------------------- +**Api** +- Added `voice-intelligence`, `voice-intelligence-transcription` and `voice-intelligence-operators` to `usage_record` API. +- Added `tts-google` to `usage_record` API. + +**Lookups** +- Add new `disposable_phone_number_risk` package to the lookup response + +**Verify** +- Documentation of list attempts API was improved by correcting `date_created_after` and `date_created_before` expected date format. +- Documentation was improved by correcting `date_created_after` and `date_created_before` expected date format parameter on attempts summary API. +- Documentation was improved by adding `WHATSAPP` as optional valid parameter on attempts summary API. + +**Twiml** +- Added support for he-il inside of ssm_lang.json that was missing +- Added support for he-il language in say.json that was missing +- Add `statusCallback` and `statusCallbackMethod` attributes to ``. + + +[2023-07-13] Version 8.5.0 +-------------------------- +**Library - Fix** +- [PR #718](https://github.com/twilio/twilio-python/pull/718): Create __init__.py for intelligence domain. Thanks to [@AsabuHere](https://github.com/AsabuHere)! + +**Flex** +- Adding `interaction_context_sid` as optional parameter in Interactions API + +**Messaging** +- Making visiblity public for tollfree_verification API + +**Numbers** +- Remove Sms capability property from HNO creation under version `/v2` of HNO API. **(breaking change)** +- Update required properties in LOA creation under version `/v2` of Authorization document API. **(breaking change)** + +**Taskrouter** +- Add api to fetch task queue statistics for multiple TaskQueues + +**Verify** +- Add `RiskCheck` optional parameter on Verification creation. + +**Twiml** +- Add Google Voices and languages + + +[2023-06-28] Version 8.4.0 +-------------------------- +**Lookups** +- Add `reassigned_number` package to the lookup response + +**Numbers** +- Add hosted_number_order under version `/v2`. +- Update properties in Porting and Bulk Porting APIs. **(breaking change)** +- Added bulk Portability API under version `/v1`. +- Added Portability API under version `/v1`. + + +[2023-06-15] Version 8.3.0 +-------------------------- +**Api** +- Added `content_sid` as conditional parameter +- Removed `content_sid` as optional field **(breaking change)** + +**Insights** +- Added `annotation` to list summary output + + +[2023-06-01] Version 8.2.2 +-------------------------- +**Api** +- Add `Trim` to create Conference Participant API + +**Intelligence** +- First public beta release for Voice Intelligence APIs with client libraries + +**Messaging** +- Add new `errors` attribute to us_app_to_person resource. This attribute will provide additional information about campaign registration errors. + + +[2023-05-18] Version 8.2.1 +-------------------------- +**Conversations** +- Added `AddressCountry` parameter to Address Configuration endpoint, to support regional short code addresses +- Added query parameters `start_date`, `end_date` and `state` in list Conversations resource for filtering + +**Insights** +- Added annotations parameters to list summary api + +**Messaging** +- Add GET domainByMessagingService endpoint to linkShortening service +- Add `disable_https` to link shortening domain_config properties + +**Numbers** +- Add bulk_eligibility api under version `/v1`. + + +[2023-05-04] Version 8.2.0 +-------------------------- +**Conversations** +- Remove `start_date`, `end_date` and `state` query parameters from list operation on Conversations resource **(breaking change)** + +**Twiml** +- Add support for new Amazon Polly voices (Q1 2023) for `Say` verb + + +[2023-04-19] Version 8.1.0 +-------------------------- +**Library - Chore** +- [PR #709](https://github.com/twilio/twilio-python/pull/709): Drop `asyncio` from requirements. Thanks to [@setu4993](https://github.com/setu4993)! + +**Library - Docs** +- [PR #705](https://github.com/twilio/twilio-python/pull/705): consolidate. Thanks to [@stern-shawn](https://github.com/stern-shawn)! + +**Messaging** +- Remove `messaging_service_sids` and `messaging_service_sid_action` from domain config endpoint **(breaking change)** +- Add error_code and rejection_reason properties to tollfree verification API response + +**Numbers** +- Added the new Eligibility API under version `/v1`. + + [2023-04-05] Version 8.0.0 -------------------------- **Note:** This release contains breaking changes, check our [upgrade guide](./UPGRADE.md###-2023-04-05-7xx-to-8xx) for detailed migration notes. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a76a0bf826..41cb4474d0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -23,7 +23,7 @@ it can be. If you have questions about how to use `twilio-python`, please see our [docs](./README.md), and if you don't find the answer there, please contact -[help@twilio.com](mailto:help@twilio.com) with any issues you have. +[Twilio Support](https://www.twilio.com/help/contact) with any issues you have. ## Found an Issue? diff --git a/LICENSE b/LICENSE index ca16167a61..6485c1f845 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (C) 2023, Twilio, Inc. +Copyright (C) 2023, Twilio, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/README.md b/README.md index 50cc5509e1..ed277788d1 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,8 @@ This library supports the following Python implementations: - Python 3.9 - Python 3.10 - Python 3.11 +- Python 3.12 +- Python 3.13 ## Installation @@ -86,6 +88,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 +137,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 +195,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 +210,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/UPGRADE.md b/UPGRADE.md index 79bdb48cc5..03c196bf5b 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -3,6 +3,15 @@ _`MAJOR` version bumps will have upgrade notes posted here._ +## [2024-02-20] 8.x.x to 9.x.x +### Overview + +##### Twilio Python Helper Library’s major version 9.0.0 is now available. We ensured that you can upgrade to Python helper Library 9.0.0 version without any breaking changes of existing apis + +Behind the scenes Python Helper is now auto-generated via OpenAPI with this release. This enables us to rapidly add new features and enhance consistency across versions and languages. +We're pleased to inform you that version 9.0.0 adds support for the application/json content type in the request body. + + ## [2023-04-05] 7.x.x to 8.x.x - **Supported Python versions updated** 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 71730f9278..7bc9e41806 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,8 @@ pygments>=2.7.4 # not directly required, pinned by Snyk to avoid a vulnerability -pytz -requests>=2.0.0 +requests>=2.32.2 PyJWT>=2.0.0, <3.0.0 -aiohttp>=3.8.4 -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 old mode 100755 new mode 100644 index 0216c02d3e..c2eb466aac --- a/setup.py +++ b/setup.py @@ -13,15 +13,14 @@ setup( name="twilio", - version="8.0.0", + version="9.6.5", description="Twilio API client and TwiML generator", author="Twilio", - author_email="help@twilio.com", + help_center="https://www.twilio.com/help/contact", url="https://github.com/twilio/twilio-python/", keywords=["twilio", "twiml"], python_requires=">=3.7.0", install_requires=[ - "pytz", "requests >= 2.0.0", "PyJWT >= 2.0.0, < 3.0.0", "aiohttp>=3.8.4", @@ -40,6 +39,8 @@ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Programming Language :: Python :: Implementation :: CPython", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Communications :: Telephony", diff --git a/tests/cluster/test_cluster.py b/tests/cluster/test_cluster.py index 0ebec8d0bd..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, @@ -24,7 +25,7 @@ def test_send_text_message(self): to=self.to_number, from_=self.from_number, body="hello world" ) self.assertEqual(msg.to, self.to_number) - self.assertEqual(msg._from, self.from_number) + self.assertEqual(msg.from_, self.from_number) self.assertEqual(msg.body, "hello world") self.assertIsNotNone(msg.sid) @@ -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/cluster/test_webhook.py b/tests/cluster/test_webhook.py index 4ac07bad94..307cf3d397 100644 --- a/tests/cluster/test_webhook.py +++ b/tests/cluster/test_webhook.py @@ -1,12 +1,7 @@ import os -import unittest -import time -import _thread -from http.server import BaseHTTPRequestHandler, HTTPServer -from pyngrok import ngrok +from http.server import BaseHTTPRequestHandler from twilio.request_validator import RequestValidator -from twilio.rest import Client class RequestHandler(BaseHTTPRequestHandler): @@ -34,80 +29,81 @@ def process_request(self): ) -class WebhookTest(unittest.TestCase): - def setUp(self): - api_key = os.environ["TWILIO_API_KEY"] - api_secret = os.environ["TWILIO_API_SECRET"] - account_sid = os.environ["TWILIO_ACCOUNT_SID"] - self.client = Client(api_key, api_secret, account_sid) - - portNumber = 7777 - self.validation_server = HTTPServer(("", portNumber), RequestHandler) - self.tunnel = ngrok.connect(portNumber) - self.flow_sid = "" - _thread.start_new_thread(self.start_http_server, ()) - - def start_http_server(self): - self.validation_server.serve_forever() - - def tearDown(self): - self.client.studio.v2.flows(self.flow_sid).delete() - ngrok.kill() - self.validation_server.shutdown() - self.validation_server.server_close() - - def create_studio_flow(self, url, method): - flow = self.client.studio.v2.flows.create( - friendly_name="Python Cluster Test Flow", - status="published", - definition={ - "description": "Studio Flow", - "states": [ - { - "name": "Trigger", - "type": "trigger", - "transitions": [ - { - "next": "httpRequest", - "event": "incomingRequest", - }, - ], - "properties": {}, - }, - { - "name": "httpRequest", - "type": "make-http-request", - "transitions": [], - "properties": { - "method": method, - "content_type": "application/x-www-form-urlencoded;charset=utf-8", - "url": url, - }, - }, - ], - "initial_state": "Trigger", - "flags": { - "allow_concurrent_calls": True, - }, - }, - ) - return flow - - def validate(self, method): - flow = self.create_studio_flow(url=self.tunnel.public_url, method=method) - self.flow_sid = flow.sid - self.client.studio.v2.flows(self.flow_sid).executions.create( - to="to", from_="from" - ) - - def test_get(self): - time.sleep(5) - self.validate("GET") - time.sleep(5) - self.assertEqual(RequestHandler.is_request_valid, True) - - def test_post(self): - time.sleep(5) - self.validate("POST") - time.sleep(5) - self.assertEqual(RequestHandler.is_request_valid, True) +# class WebhookTest(unittest.TestCase): +# def setUp(self): +# api_key = os.environ["TWILIO_API_KEY"] +# api_secret = os.environ["TWILIO_API_SECRET"] +# account_sid = os.environ["TWILIO_ACCOUNT_SID"] +# self.client = Client(api_key, api_secret, account_sid) +# +# portNumber = 7777 +# self.validation_server = HTTPServer(("", portNumber), RequestHandler) +# self.tunnel = ngrok.connect(portNumber) +# self.flow_sid = "" +# _thread.start_new_thread(self.start_http_server, ()) +# +# def start_http_server(self): +# self.validation_server.serve_forever() +# +# def tearDown(self): +# self.client.studio.v2.flows(self.flow_sid).delete() +# ngrok.kill() +# self.validation_server.shutdown() +# self.validation_server.server_close() +# +# def create_studio_flow(self, url, method): +# flow = self.client.studio.v2.flows.create( +# friendly_name="Python Cluster Test Flow", +# status="published", +# definition={ +# "description": "Studio Flow", +# "states": [ +# { +# "name": "Trigger", +# "type": "trigger", +# "transitions": [ +# { +# "next": "httpRequest", +# "event": "incomingRequest", +# }, +# ], +# "properties": {}, +# }, +# { +# "name": "httpRequest", +# "type": "make-http-request", +# "transitions": [], +# "properties": { +# "method": method, +# "content_type": "application/x-www-form-urlencoded;charset=utf-8", +# "url": url, +# }, +# }, +# ], +# "initial_state": "Trigger", +# "flags": { +# "allow_concurrent_calls": True, +# }, +# }, +# ) +# return flow +# +# def validate(self, method): +# flow = self.create_studio_flow(url=self.tunnel.public_url, method=method) +# self.flow_sid = flow.sid +# time.sleep(5) +# self.client.studio.v2.flows(self.flow_sid).executions.create( +# to="to", from_="from" +# ) +# +# def test_get(self): +# time.sleep(5) +# self.validate("GET") +# time.sleep(5) +# self.assertEqual(RequestHandler.is_request_valid, True) +# +# def test_post(self): +# time.sleep(5) +# self.validate("POST") +# time.sleep(5) +# self.assertEqual(RequestHandler.is_request_valid, True) diff --git a/tests/unit/base/test_deserialize.py b/tests/unit/base/test_deserialize.py index 9953772471..33f627e838 100644 --- a/tests/unit/base/test_deserialize.py +++ b/tests/unit/base/test_deserialize.py @@ -2,8 +2,6 @@ import unittest from decimal import Decimal -import pytz - from twilio.base import deserialize @@ -21,7 +19,7 @@ def test_not_parsable(self): class Iso8601DateTimeTestCase(unittest.TestCase): def test_parsable(self): actual = deserialize.iso8601_datetime("2015-01-02T03:04:05Z") - expected = datetime.datetime(2015, 1, 2, 3, 4, 5, 0, pytz.utc) + expected = datetime.datetime(2015, 1, 2, 3, 4, 5, 0, datetime.timezone.utc) self.assertEqual(expected, actual) def test_not_parsable(self): diff --git a/tests/unit/base/test_serialize.py b/tests/unit/base/test_serialize.py index 204fe2c2a0..57891a65b7 100644 --- a/tests/unit/base/test_serialize.py +++ b/tests/unit/base/test_serialize.py @@ -90,6 +90,28 @@ def test_list(self): self.assertEqual({}, actual) +class BooleanTestCase(unittest.TestCase): + def test_none(self): + value = None + actual = serialize.boolean_to_string(value) + self.assertIsNone(actual) + + def test_string(self): + value = "True" + actual = serialize.boolean_to_string(value) + self.assertEqual("true", actual) + + def test_bool_true(self): + value = True + actual = serialize.boolean_to_string(value) + self.assertEqual("true", actual) + + def test_bool_false(self): + value = False + actual = serialize.boolean_to_string(value) + self.assertEqual("false", actual) + + class ObjectTestCase(unittest.TestCase): def test_object(self): actual = serialize.object({"twilio": "rocks"}) 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/tests/unit/http/test_http_client.py b/tests/unit/http/test_http_client.py index e599aaaf00..8484e57b17 100644 --- a/tests/unit/http/test_http_client.py +++ b/tests/unit/http/test_http_client.py @@ -145,6 +145,32 @@ def test_last_request_last_response_exist(self): "testing-unicode: Ω≈ç√, 💩", self.client._test_only_last_response.text ) + def test_request_with_json(self): + self.request_mock.url = "https://api.twilio.com/" + self.request_mock.headers = {"Host": "other.twilio.com"} + + self.client.request( + "doesnt-matter-method", + "doesnt-matter-url", + {"params-value": "params-key"}, + {"json-key": "json-value"}, + {"Content-Type": "application/json"}, + ) + + self.assertIsNotNone(self.client._test_only_last_request) + self.assertEqual( + {"Content-Type": "application/json"}, + self.client._test_only_last_request.headers, + ) + + self.assertIsNotNone(self.client._test_only_last_response) + + if self.client._test_only_last_response is not None: + self.assertEqual(200, self.client._test_only_last_response.status_code) + self.assertEqual( + "testing-unicode: Ω≈ç√, 💩", self.client._test_only_last_response.text + ) + def test_last_response_empty_on_error(self): self.session_mock.send.side_effect = Exception("voltron") diff --git a/twilio/__init__.py b/twilio/__init__.py index d971c18395..f28471b91a 100644 --- a/twilio/__init__.py +++ b/twilio/__init__.py @@ -1,2 +1,2 @@ -__version_info__ = ("8", "0", "0") +__version_info__ = ("9", "6", "5") __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/deserialize.py b/twilio/base/deserialize.py index e70ac57390..71226c08f8 100644 --- a/twilio/base/deserialize.py +++ b/twilio/base/deserialize.py @@ -3,13 +3,11 @@ from email.utils import parsedate from typing import Optional, Union -import pytz - ISO8601_DATE_FORMAT = "%Y-%m-%d" ISO8601_DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ" -def iso8601_date(s: str) -> Optional[Union[datetime.date, str]]: +def iso8601_date(s: str) -> Union[datetime.date, str]: """ Parses an ISO 8601 date string and returns a UTC date object or the string if the parsing failed. @@ -19,7 +17,7 @@ def iso8601_date(s: str) -> Optional[Union[datetime.date, str]]: try: return ( datetime.datetime.strptime(s, ISO8601_DATE_FORMAT) - .replace(tzinfo=pytz.utc) + .replace(tzinfo=datetime.timezone.utc) .date() ) except (TypeError, ValueError): @@ -28,7 +26,7 @@ def iso8601_date(s: str) -> Optional[Union[datetime.date, str]]: def iso8601_datetime( s: str, -) -> Optional[Union[datetime.datetime, str]]: +) -> Union[datetime.datetime, str]: """ Parses an ISO 8601 datetime string and returns a UTC datetime object, or the string if parsing failed. @@ -36,7 +34,7 @@ def iso8601_datetime( """ try: return datetime.datetime.strptime(s, ISO8601_DATETIME_FORMAT).replace( - tzinfo=pytz.utc + tzinfo=datetime.timezone.utc ) except (TypeError, ValueError): return s @@ -52,10 +50,10 @@ def rfc2822_datetime(s: str) -> Optional[datetime.datetime]: date_tuple = parsedate(s) if date_tuple is None: return None - return datetime.datetime(*date_tuple[:6]).replace(tzinfo=pytz.utc) + return datetime.datetime(*date_tuple[:6]).replace(tzinfo=datetime.timezone.utc) -def decimal(d: Optional[str]) -> Optional[Union[Decimal, str]]: +def decimal(d: Optional[str]) -> Union[Decimal, str]: """ Parses a decimal string into a Decimal :param d: decimal string @@ -65,7 +63,7 @@ def decimal(d: Optional[str]) -> Optional[Union[Decimal, str]]: return Decimal(d, BasicContext) -def integer(i: str) -> Optional[Union[int, str]]: +def integer(i: str) -> Union[int, str]: """ Parses an integer string into an int :param i: integer string 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/serialize.py b/twilio/base/serialize.py index 3abc0defef..cea91b04c7 100644 --- a/twilio/base/serialize.py +++ b/twilio/base/serialize.py @@ -61,6 +61,19 @@ def flatten_dict(d, result=None, prv_keys=None): return {} +def boolean_to_string(bool_or_str): + if bool_or_str == values.unset: + return bool_or_str + + if bool_or_str is None: + return bool_or_str + + if isinstance(bool_or_str, str): + return bool_or_str.lower() + + return "true" if bool_or_str else "false" + + def object(obj): """ Return a jsonified string represenation of obj if obj is jsonifiable else 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..0d42428a2f --- /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.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 bfc38feaf7..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 @@ -27,11 +28,10 @@ def __init__( ): """ Constructor for the TwilioHttpClient - :param pool_connections :param request_hooks :param timeout: Timeout for the requests. - Timeout should never be zero (0) or less. + Timeout should never be zero (0) or less :param logger :param proxy: Http proxy for the requests session :param max_retries: Maximum number of retries each request should attempt @@ -40,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 {} @@ -65,10 +68,10 @@ def request( :param headers: HTTP Headers to send with the request :param auth: Basic Auth arguments :param timeout: Socket/Read timeout for the request - :param allow_redirects: Whether or not to allow redirects + :param allow_redirects: Whether to allow redirects See the requests documentation for explanation of all these parameters - :return: An http response + :return: An HTTP response """ if timeout is None: timeout = self.timeout @@ -79,14 +82,17 @@ def request( "method": method.upper(), "url": url, "params": params, - "data": data, "headers": headers, "auth": auth, "hooks": self.request_hooks, } - + 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) @@ -97,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..76fad5213f --- /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.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/http/validation_client.py b/twilio/http/validation_client.py index c8e211ddf1..1a4a83f0a5 100644 --- a/twilio/http/validation_client.py +++ b/twilio/http/validation_client.py @@ -128,11 +128,11 @@ def validate_ssl_certificate(self, client): Validate that a request to the new SSL certificate is successful :return: null on success, raise TwilioRestException if the request fails """ - response = client.request("GET", "https://api.twilio.com:8443") + response = client.request("GET", "https://tls-test.twilio.com:443") if response.status_code < 200 or response.status_code >= 300: raise TwilioRestException( response.status_code, - "https://api.twilio.com:8443", + "https://tls-test.twilio.com:443", "Failed to validate SSL certificate", ) diff --git a/twilio/rest/__init__.py b/twilio/rest/__init__.py index 774c0c7adc..823cbbfaa0 100644 --- a/twilio/rest/__init__.py +++ b/twilio/rest/__init__.py @@ -8,6 +8,7 @@ https://openapi-generator.tech Do not edit the class manually. """ + from typing import TYPE_CHECKING, Optional from twilio.base.client_base import ClientBase @@ -15,7 +16,7 @@ if TYPE_CHECKING: from twilio.rest.accounts import Accounts from twilio.rest.api import Api - from twilio.rest.autopilot import Autopilot + 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.lookups import Lookups - from twilio.rest.media import Media + from twilio.rest.marketplace import Marketplace from twilio.rest.messaging import Messaging - from twilio.rest.microvisor import Microvisor from twilio.rest.monitor import Monitor from twilio.rest.notify import Notify from twilio.rest.numbers import Numbers @@ -93,6 +96,7 @@ def __init__( environment=None, edge=None, user_agent_extensions=None, + credential_provider=None, ): """ Initializes the Twilio Client @@ -118,12 +122,13 @@ def __init__( environment, edge, user_agent_extensions, + credential_provider, ) # Domains self._accounts: Optional["Accounts"] = None self._api: Optional["Api"] = None - self._autopilot: Optional["Autopilot"] = None + self._assistants: Optional["Assistants"] = None self._bulkexports: Optional["Bulkexports"] = None self._chat: Optional["Chat"] = None self._content: Optional["Content"] = None @@ -131,12 +136,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._lookups: Optional["Lookups"] = None - self._media: Optional["Media"] = None + self._marketplace: Optional["Marketplace"] = None self._messaging: Optional["Messaging"] = None - self._microvisor: Optional["Microvisor"] = None self._monitor: Optional["Monitor"] = None self._notify: Optional["Notify"] = None self._numbers: Optional["Numbers"] = None @@ -184,17 +191,17 @@ def api(self) -> "Api": return self._api @property - def autopilot(self) -> "Autopilot": + def assistants(self) -> "Assistants": """ - Access the Autopilot Twilio Domain + Access the Assistants Twilio Domain - :returns: Autopilot Twilio Domain + :returns: Assistants Twilio Domain """ - if self._autopilot is None: - from twilio.rest.autopilot import Autopilot + if self._assistants is None: + from twilio.rest.assistants import Assistants - self._autopilot = Autopilot(self) - return self._autopilot + self._assistants = Assistants(self) + return self._assistants @property def bulkexports(self) -> "Bulkexports": @@ -287,6 +294,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": """ @@ -300,6 +333,19 @@ def insights(self) -> "Insights": self._insights = Insights(self) return self._insights + @property + def intelligence(self) -> "Intelligence": + """ + Access the Intelligence Twilio Domain + + :returns: Intelligence Twilio Domain + """ + if self._intelligence is None: + from twilio.rest.intelligence import Intelligence + + self._intelligence = Intelligence(self) + return self._intelligence + @property def ip_messaging(self) -> "IpMessaging": """ @@ -327,17 +373,17 @@ def lookups(self) -> "Lookups": return self._lookups @property - def media(self) -> "Media": + def marketplace(self) -> "Marketplace": """ - Access the Media Twilio Domain + Access the Marketplace Twilio Domain - :returns: Media Twilio Domain + :returns: Marketplace Twilio Domain """ - if self._media is None: - from twilio.rest.media import Media + if self._marketplace is None: + from twilio.rest.marketplace import Marketplace - self._media = Media(self) - return self._media + self._marketplace = Marketplace(self) + return self._marketplace @property def messaging(self) -> "Messaging": @@ -352,19 +398,6 @@ def messaging(self) -> "Messaging": self._messaging = Messaging(self) return self._messaging - @property - def microvisor(self) -> "Microvisor": - """ - Access the Microvisor Twilio Domain - - :returns: Microvisor Twilio Domain - """ - if self._microvisor is None: - from twilio.rest.microvisor import Microvisor - - self._microvisor = Microvisor(self) - return self._microvisor - @property def monitor(self) -> "Monitor": """ diff --git a/twilio/rest/accounts/AccountsBase.py b/twilio/rest/accounts/AccountsBase.py index a89be84161..e9ac0d589d 100644 --- a/twilio/rest/accounts/AccountsBase.py +++ b/twilio/rest/accounts/AccountsBase.py @@ -17,6 +17,7 @@ class AccountsBase(Domain): + def __init__(self, twilio: Client): """ Initialize the Accounts Domain diff --git a/twilio/rest/accounts/v1/__init__.py b/twilio/rest/accounts/v1/__init__.py index c4b24d0391..6f5012d0fa 100644 --- a/twilio/rest/accounts/v1/__init__.py +++ b/twilio/rest/accounts/v1/__init__.py @@ -16,11 +16,15 @@ 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 class V1(Version): + def __init__(self, domain: Domain): """ Initialize the V1 version of Accounts @@ -29,7 +33,10 @@ 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 @property @@ -38,12 +45,30 @@ 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: self._credentials = CredentialList(self) return self._credentials + @property + def safelist(self) -> SafelistList: + if self._safelist is None: + self._safelist = SafelistList(self) + return self._safelist + @property def secondary_auth_token(self) -> SecondaryAuthTokenList: if self._secondary_auth_token is None: diff --git a/twilio/rest/accounts/v1/auth_token_promotion.py b/twilio/rest/accounts/v1/auth_token_promotion.py index 0dbf1eb752..8580538a9b 100644 --- a/twilio/rest/accounts/v1/auth_token_promotion.py +++ b/twilio/rest/accounts/v1/auth_token_promotion.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import datetime from typing import Any, Dict, Optional from twilio.base import deserialize, values @@ -23,7 +22,6 @@ class AuthTokenPromotionInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that the secondary Auth Token was created for. :ivar auth_token: The promoted Auth Token that must be used to authenticate future API requests. @@ -90,6 +88,7 @@ def __repr__(self) -> str: class AuthTokenPromotionContext(InstanceContext): + def __init__(self, version: Version): """ Initialize the AuthTokenPromotionContext @@ -107,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) @@ -124,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) @@ -145,6 +148,7 @@ def __repr__(self) -> str: class AuthTokenPromotionList(ListResource): + def __init__(self, version: Version): """ Initialize the AuthTokenPromotionList diff --git a/twilio/rest/accounts/v1/bulk_consents.py b/twilio/rest/accounts/v1/bulk_consents.py new file mode 100644 index 0000000000..9e242552ee --- /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`]; `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`]; `date_of_consent`, an optional datetime string field in ISO-8601 format that captures the exact date and time when the user gave or revoked consent. If not provided, it will be empty. + + :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`]; `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`]; `date_of_consent`, an optional datetime string field in ISO-8601 format that captures the exact date and time when the user gave or revoked consent. If not provided, it will be empty. + + :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/__init__.py b/twilio/rest/accounts/v1/credential/__init__.py index d76ce584f3..e9c4653f0c 100644 --- a/twilio/rest/accounts/v1/credential/__init__.py +++ b/twilio/rest/accounts/v1/credential/__init__.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Optional @@ -24,6 +23,7 @@ class CredentialList(ListResource): + def __init__(self, version: Version): """ Initialize the CredentialList diff --git a/twilio/rest/accounts/v1/credential/aws.py b/twilio/rest/accounts/v1/credential/aws.py index 0e17164ecb..ba5335accd 100644 --- a/twilio/rest/accounts/v1/credential/aws.py +++ b/twilio/rest/accounts/v1/credential/aws.py @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class AwsInstance(InstanceResource): - """ :ivar sid: The unique string that we created to identify the AWS resource. :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the AWS resource. @@ -143,6 +141,7 @@ def __repr__(self) -> str: class AwsContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the AwsContext @@ -165,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: """ @@ -177,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: @@ -190,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, @@ -209,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( @@ -228,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"]) @@ -252,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"]) @@ -277,6 +290,7 @@ def __repr__(self) -> str: class AwsPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> AwsInstance: """ Build an instance of AwsInstance @@ -295,6 +309,7 @@ def __repr__(self) -> str: class AwsList(ListResource): + def __init__(self, version: Version): """ Initialize the AwsList @@ -321,6 +336,7 @@ def create( :returns: The created AwsInstance """ + data = values.of( { "Credentials": credentials, @@ -328,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) @@ -352,6 +371,7 @@ async def create_async( :returns: The created AwsInstance """ + data = values.of( { "Credentials": credentials, @@ -359,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) @@ -495,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( @@ -522,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 f78a6728c1..c2b4f9bbee 100644 --- a/twilio/rest/accounts/v1/credential/public_key.py +++ b/twilio/rest/accounts/v1/credential/public_key.py @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class PublicKeyInstance(InstanceResource): - """ :ivar sid: The unique string that that we created to identify the PublicKey resource. :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Credential that the PublicKey resource belongs to. @@ -145,6 +143,7 @@ def __repr__(self) -> str: class PublicKeyContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the PublicKeyContext @@ -167,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: """ @@ -179,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: @@ -192,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, @@ -211,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( @@ -232,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"]) @@ -256,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"]) @@ -281,6 +294,7 @@ def __repr__(self) -> str: class PublicKeyPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> PublicKeyInstance: """ Build an instance of PublicKeyInstance @@ -299,6 +313,7 @@ def __repr__(self) -> str: class PublicKeyList(ListResource): + def __init__(self, version: Version): """ Initialize the PublicKeyList @@ -325,6 +340,7 @@ def create( :returns: The created PublicKeyInstance """ + data = values.of( { "PublicKey": public_key, @@ -332,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) @@ -356,6 +375,7 @@ async def create_async( :returns: The created PublicKeyInstance """ + data = values.of( { "PublicKey": public_key, @@ -363,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) @@ -499,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( @@ -526,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 new file mode 100644 index 0000000000..be8fe416af --- /dev/null +++ b/twilio/rest/accounts/v1/safelist.py @@ -0,0 +1,204 @@ +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, 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 SafelistInstance(InstanceResource): + """ + :ivar sid: The unique string that we created to identify the SafeList resource. + :ivar phone_number: The phone number or phone number 1k prefix in SafeList. + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.sid: Optional[str] = payload.get("sid") + self.phone_number: Optional[str] = payload.get("phone_number") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class SafelistList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the SafelistList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/SafeList/Numbers" + + def create(self, phone_number: str) -> SafelistInstance: + """ + Create the SafelistInstance + + :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 + """ + + data = values.of( + { + "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, headers=headers + ) + + return SafelistInstance(self._version, payload) + + async def create_async(self, phone_number: str) -> SafelistInstance: + """ + Asynchronously create the SafelistInstance + + :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 + """ + + data = values.of( + { + "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, headers=headers + ) + + return SafelistInstance(self._version, payload) + + def delete(self, phone_number: Union[str, object] = values.unset) -> bool: + """ + Asynchronously delete the SafelistInstance + + :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, headers=headers, params=params + ) + + async def delete_async( + self, phone_number: Union[str, object] = values.unset + ) -> bool: + """ + Asynchronously delete the SafelistInstance + + :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 await self._version.delete_async( + method="DELETE", uri=self._uri, headers=headers, params=params + ) + + def fetch( + self, phone_number: Union[str, object] = values.unset + ) -> SafelistInstance: + """ + Asynchronously fetch the SafelistInstance + + :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( + { + "PhoneNumber": phone_number, + } + ) + + payload = self._version.fetch( + method="GET", uri=self._uri, headers=headers, params=params + ) + + return SafelistInstance(self._version, payload) + + async def fetch_async( + self, phone_number: Union[str, object] = values.unset + ) -> SafelistInstance: + """ + Asynchronously fetch the SafelistInstance + + :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( + { + "PhoneNumber": phone_number, + } + ) + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers, params=params + ) + + return SafelistInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/accounts/v1/secondary_auth_token.py b/twilio/rest/accounts/v1/secondary_auth_token.py index 76b09a764e..f5e2b5c1a3 100644 --- a/twilio/rest/accounts/v1/secondary_auth_token.py +++ b/twilio/rest/accounts/v1/secondary_auth_token.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import datetime from typing import Any, Dict, Optional from twilio.base import deserialize, values @@ -23,7 +22,6 @@ class SecondaryAuthTokenInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that the secondary Auth Token was created for. :ivar date_created: The date and time in UTC when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. @@ -108,6 +106,7 @@ def __repr__(self) -> str: class SecondaryAuthTokenContext(InstanceContext): + def __init__(self, version: Version): """ Initialize the SecondaryAuthTokenContext @@ -153,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: """ @@ -165,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: @@ -181,6 +182,7 @@ def __repr__(self) -> str: class SecondaryAuthTokenList(ListResource): + def __init__(self, version: Version): """ Initialize the SecondaryAuthTokenList diff --git a/twilio/rest/api/ApiBase.py b/twilio/rest/api/ApiBase.py index 417bc0d0df..e53535ab3f 100644 --- a/twilio/rest/api/ApiBase.py +++ b/twilio/rest/api/ApiBase.py @@ -17,6 +17,7 @@ class ApiBase(Domain): + def __init__(self, twilio: Client): """ Initialize the Api Domain diff --git a/twilio/rest/api/v2010/__init__.py b/twilio/rest/api/v2010/__init__.py index fe5c45c51e..2efb4ff3d0 100644 --- a/twilio/rest/api/v2010/__init__.py +++ b/twilio/rest/api/v2010/__init__.py @@ -20,6 +20,7 @@ class V2010(Version): + def __init__(self, domain: Domain): """ Initialize the V2010 version of Api diff --git a/twilio/rest/api/v2010/account/__init__.py b/twilio/rest/api/v2010/account/__init__.py index fafb4f573c..7c7e2c1069 100644 --- a/twilio/rest/api/v2010/account/__init__.py +++ b/twilio/rest/api/v2010/account/__init__.py @@ -12,7 +12,6 @@ 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 @@ -52,6 +51,7 @@ class AccountInstance(InstanceResource): + class Status(object): ACTIVE = "active" SUSPENDED = "suspended" @@ -349,6 +349,7 @@ def __repr__(self) -> str: class AccountContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the AccountContext @@ -397,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, @@ -416,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( @@ -440,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"]) @@ -468,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"]) @@ -782,6 +795,7 @@ def __repr__(self) -> str: class AccountPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> AccountInstance: """ Build an instance of AccountInstance @@ -800,6 +814,7 @@ def __repr__(self) -> str: class AccountList(ListResource): + def __init__(self, version: Version): """ Initialize the AccountList @@ -821,16 +836,20 @@ def create( :returns: The created AccountInstance """ + data = values.of( { "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) @@ -845,16 +864,20 @@ async def create_async( :returns: The created AccountInstance """ + data = values.of( { "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) @@ -1016,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( @@ -1049,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 224601e270..77fc702ccc 100644 --- a/twilio/rest/api/v2010/account/address/__init__.py +++ b/twilio/rest/api/v2010/account/address/__init__.py @@ -12,10 +12,9 @@ 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 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 @@ -27,7 +26,6 @@ class AddressInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that is responsible for the Address resource. :ivar city: The city in which the address is located. @@ -150,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. @@ -189,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. @@ -231,6 +229,7 @@ def __repr__(self) -> str: class AddressContext(InstanceContext): + def __init__(self, version: Version, account_sid: str, sid: str): """ Initialize the AddressContext @@ -259,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: """ @@ -271,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: @@ -284,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, @@ -304,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( @@ -331,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. @@ -343,6 +348,7 @@ def update( :returns: The updated AddressInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -351,16 +357,19 @@ def update( "City": city, "Region": region, "PostalCode": postal_code, - "EmergencyEnabled": emergency_enabled, - "AutoCorrectAddress": auto_correct_address, + "EmergencyEnabled": serialize.boolean_to_string(emergency_enabled), + "AutoCorrectAddress": serialize.boolean_to_string(auto_correct_address), "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( @@ -385,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. @@ -397,6 +406,7 @@ async def update_async( :returns: The updated AddressInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -405,16 +415,19 @@ async def update_async( "City": city, "Region": region, "PostalCode": postal_code, - "EmergencyEnabled": emergency_enabled, - "AutoCorrectAddress": auto_correct_address, + "EmergencyEnabled": serialize.boolean_to_string(emergency_enabled), + "AutoCorrectAddress": serialize.boolean_to_string(auto_correct_address), "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( @@ -448,6 +461,7 @@ def __repr__(self) -> str: class AddressPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> AddressInstance: """ Build an instance of AddressInstance @@ -468,6 +482,7 @@ def __repr__(self) -> str: class AddressList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the AddressList @@ -513,6 +528,7 @@ def create( :returns: The created AddressInstance """ + data = values.of( { "CustomerName": customer_name, @@ -522,16 +538,19 @@ def create( "PostalCode": postal_code, "IsoCountry": iso_country, "FriendlyName": friendly_name, - "EmergencyEnabled": emergency_enabled, - "AutoCorrectAddress": auto_correct_address, + "EmergencyEnabled": serialize.boolean_to_string(emergency_enabled), + "AutoCorrectAddress": serialize.boolean_to_string(auto_correct_address), "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( @@ -567,6 +586,7 @@ async def create_async( :returns: The created AddressInstance """ + data = values.of( { "CustomerName": customer_name, @@ -576,16 +596,19 @@ async def create_async( "PostalCode": postal_code, "IsoCountry": iso_country, "FriendlyName": friendly_name, - "EmergencyEnabled": emergency_enabled, - "AutoCorrectAddress": auto_correct_address, + "EmergencyEnabled": serialize.boolean_to_string(emergency_enabled), + "AutoCorrectAddress": serialize.boolean_to_string(auto_correct_address), "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( @@ -596,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, @@ -608,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 @@ -622,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"], ) @@ -632,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, @@ -644,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 @@ -658,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"], ) @@ -668,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, @@ -679,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 @@ -693,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, @@ -703,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, @@ -714,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 @@ -729,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, @@ -739,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, @@ -750,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 @@ -761,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, @@ -768,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, @@ -786,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 @@ -797,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, @@ -804,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 6e9ff957a0..504e69bc92 100644 --- a/twilio/rest/api/v2010/account/address/dependent_phone_number.py +++ b/twilio/rest/api/v2010/account/address/dependent_phone_number.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class DependentPhoneNumberInstance(InstanceResource): + class AddressRequirement(object): NONE = "none" ANY = "any" @@ -127,6 +127,7 @@ def __repr__(self) -> str: class DependentPhoneNumberPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> DependentPhoneNumberInstance: """ Build an instance of DependentPhoneNumberInstance @@ -150,6 +151,7 @@ def __repr__(self) -> str: class DependentPhoneNumberList(ListResource): + def __init__(self, version: Version, account_sid: str, address_sid: str): """ Initialize the DependentPhoneNumberList @@ -297,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( @@ -324,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 5179d5d55b..555ab72b4a 100644 --- a/twilio/rest/api/v2010/account/application.py +++ b/twilio/rest/api/v2010/account/application.py @@ -12,10 +12,9 @@ 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 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 @@ -24,7 +23,6 @@ class ApplicationInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Application resource. :ivar api_version: The API version used to start a new TwiML session. @@ -281,6 +279,7 @@ def __repr__(self) -> str: class ApplicationContext(InstanceContext): + def __init__(self, version: Version, account_sid: str, sid: str): """ Initialize the ApplicationContext @@ -307,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: """ @@ -319,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: @@ -332,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, @@ -352,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( @@ -405,6 +410,7 @@ def update( :returns: The updated ApplicationInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -415,21 +421,28 @@ def update( "VoiceFallbackMethod": voice_fallback_method, "StatusCallback": status_callback, "StatusCallbackMethod": status_callback_method, - "VoiceCallerIdLookup": voice_caller_id_lookup, + "VoiceCallerIdLookup": serialize.boolean_to_string( + voice_caller_id_lookup + ), "SmsUrl": sms_url, "SmsMethod": sms_method, "SmsFallbackUrl": sms_fallback_url, "SmsFallbackMethod": sms_fallback_method, "SmsStatusCallback": sms_status_callback, "MessageStatusCallback": message_status_callback, - "PublicApplicationConnectEnabled": public_application_connect_enabled, + "PublicApplicationConnectEnabled": serialize.boolean_to_string( + public_application_connect_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 ApplicationInstance( @@ -480,6 +493,7 @@ async def update_async( :returns: The updated ApplicationInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -490,21 +504,28 @@ async def update_async( "VoiceFallbackMethod": voice_fallback_method, "StatusCallback": status_callback, "StatusCallbackMethod": status_callback_method, - "VoiceCallerIdLookup": voice_caller_id_lookup, + "VoiceCallerIdLookup": serialize.boolean_to_string( + voice_caller_id_lookup + ), "SmsUrl": sms_url, "SmsMethod": sms_method, "SmsFallbackUrl": sms_fallback_url, "SmsFallbackMethod": sms_fallback_method, "SmsStatusCallback": sms_status_callback, "MessageStatusCallback": message_status_callback, - "PublicApplicationConnectEnabled": public_application_connect_enabled, + "PublicApplicationConnectEnabled": serialize.boolean_to_string( + public_application_connect_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 ApplicationInstance( @@ -525,6 +546,7 @@ def __repr__(self) -> str: class ApplicationPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ApplicationInstance: """ Build an instance of ApplicationInstance @@ -545,6 +567,7 @@ def __repr__(self) -> str: class ApplicationList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the ApplicationList @@ -602,6 +625,7 @@ def create( :returns: The created ApplicationInstance """ + data = values.of( { "ApiVersion": api_version, @@ -611,7 +635,9 @@ def create( "VoiceFallbackMethod": voice_fallback_method, "StatusCallback": status_callback, "StatusCallbackMethod": status_callback_method, - "VoiceCallerIdLookup": voice_caller_id_lookup, + "VoiceCallerIdLookup": serialize.boolean_to_string( + voice_caller_id_lookup + ), "SmsUrl": sms_url, "SmsMethod": sms_method, "SmsFallbackUrl": sms_fallback_url, @@ -619,14 +645,19 @@ def create( "SmsStatusCallback": sms_status_callback, "MessageStatusCallback": message_status_callback, "FriendlyName": friendly_name, - "PublicApplicationConnectEnabled": public_application_connect_enabled, + "PublicApplicationConnectEnabled": serialize.boolean_to_string( + public_application_connect_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 ApplicationInstance( @@ -674,6 +705,7 @@ async def create_async( :returns: The created ApplicationInstance """ + data = values.of( { "ApiVersion": api_version, @@ -683,7 +715,9 @@ async def create_async( "VoiceFallbackMethod": voice_fallback_method, "StatusCallback": status_callback, "StatusCallbackMethod": status_callback_method, - "VoiceCallerIdLookup": voice_caller_id_lookup, + "VoiceCallerIdLookup": serialize.boolean_to_string( + voice_caller_id_lookup + ), "SmsUrl": sms_url, "SmsMethod": sms_method, "SmsFallbackUrl": sms_fallback_url, @@ -691,14 +725,19 @@ async def create_async( "SmsStatusCallback": sms_status_callback, "MessageStatusCallback": message_status_callback, "FriendlyName": friendly_name, - "PublicApplicationConnectEnabled": public_application_connect_enabled, + "PublicApplicationConnectEnabled": serialize.boolean_to_string( + public_application_connect_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 ApplicationInstance( @@ -847,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( @@ -877,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 4d71766b62..cceb694c10 100644 --- a/twilio/rest/api/v2010/account/authorized_connect_app.py +++ b/twilio/rest/api/v2010/account/authorized_connect_app.py @@ -12,10 +12,8 @@ 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 import values from twilio.base.instance_context import InstanceContext from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource @@ -24,6 +22,7 @@ class AuthorizedConnectAppInstance(InstanceResource): + class Permission(object): GET_ALL = "get-all" POST_ALL = "post-all" @@ -35,8 +34,6 @@ class Permission(object): :ivar connect_app_friendly_name: The name of the Connect App. :ivar connect_app_homepage_url: The public URL for the Connect App. :ivar connect_app_sid: The SID that we assigned to the Connect App. - :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 permissions: The set of permissions that you authorized for the Connect App. Can be: `get-all` or `post-all`. :ivar uri: The URI of the resource, relative to `https://api.twilio.com`. """ @@ -64,15 +61,9 @@ def __init__( "connect_app_homepage_url" ) self.connect_app_sid: Optional[str] = payload.get("connect_app_sid") - self.date_created: Optional[datetime] = deserialize.rfc2822_datetime( - payload.get("date_created") + self.permissions: Optional[List["AuthorizedConnectAppInstance.Permission"]] = ( + payload.get("permissions") ) - self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime( - payload.get("date_updated") - ) - self.permissions: Optional[ - List["AuthorizedConnectAppInstance.Permission"] - ] = payload.get("permissions") self.uri: Optional[str] = payload.get("uri") self._solution = { @@ -126,6 +117,7 @@ def __repr__(self) -> str: class AuthorizedConnectAppContext(InstanceContext): + def __init__(self, version: Version, account_sid: str, connect_app_sid: str): """ Initialize the AuthorizedConnectAppContext @@ -153,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, @@ -173,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( @@ -196,6 +192,7 @@ def __repr__(self) -> str: class AuthorizedConnectAppPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> AuthorizedConnectAppInstance: """ Build an instance of AuthorizedConnectAppInstance @@ -216,6 +213,7 @@ def __repr__(self) -> str: class AuthorizedConnectAppList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the AuthorizedConnectAppList @@ -361,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( @@ -388,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 5645844cfb..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 @@ -12,7 +12,6 @@ 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 @@ -40,7 +39,6 @@ class AvailablePhoneNumberCountryInstance(InstanceResource): - """ :ivar country_code: The [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of the country. :ivar country: The name of the country. @@ -168,6 +166,7 @@ def __repr__(self) -> str: class AvailablePhoneNumberCountryContext(InstanceContext): + def __init__(self, version: Version, account_sid: str, country_code: str): """ Initialize the AvailablePhoneNumberCountryContext @@ -205,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, @@ -225,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( @@ -341,6 +344,7 @@ def __repr__(self) -> str: class AvailablePhoneNumberCountryPage(Page): + def get_instance( self, payload: Dict[str, Any] ) -> AvailablePhoneNumberCountryInstance: @@ -363,6 +367,7 @@ def __repr__(self) -> str: class AvailablePhoneNumberCountryList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the AvailablePhoneNumberCountryList @@ -508,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( @@ -535,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 b8e0cee71a..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 @@ -12,9 +12,8 @@ Do not edit the class manually. """ - 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_resource import InstanceResource from twilio.base.list_resource import ListResource @@ -23,7 +22,6 @@ class LocalInstance(InstanceResource): - """ :ivar friendly_name: A formatted version of the phone number. :ivar phone_number: The phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number. @@ -79,6 +77,7 @@ def __repr__(self) -> str: class LocalPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> LocalInstance: """ Build an instance of LocalInstance @@ -102,6 +101,7 @@ def __repr__(self) -> str: class LocalList(ListResource): + def __init__(self, version: Version, account_sid: str, country_code: str): """ Initialize the LocalList @@ -501,13 +501,19 @@ def page( { "AreaCode": area_code, "Contains": contains, - "SmsEnabled": sms_enabled, - "MmsEnabled": mms_enabled, - "VoiceEnabled": voice_enabled, - "ExcludeAllAddressRequired": exclude_all_address_required, - "ExcludeLocalAddressRequired": exclude_local_address_required, - "ExcludeForeignAddressRequired": exclude_foreign_address_required, - "Beta": beta, + "SmsEnabled": serialize.boolean_to_string(sms_enabled), + "MmsEnabled": serialize.boolean_to_string(mms_enabled), + "VoiceEnabled": serialize.boolean_to_string(voice_enabled), + "ExcludeAllAddressRequired": serialize.boolean_to_string( + exclude_all_address_required + ), + "ExcludeLocalAddressRequired": serialize.boolean_to_string( + exclude_local_address_required + ), + "ExcludeForeignAddressRequired": serialize.boolean_to_string( + exclude_foreign_address_required + ), + "Beta": serialize.boolean_to_string(beta), "NearNumber": near_number, "NearLatLong": near_lat_long, "Distance": distance, @@ -516,14 +522,20 @@ def page( "InRateCenter": in_rate_center, "InLata": in_lata, "InLocality": in_locality, - "FaxEnabled": fax_enabled, + "FaxEnabled": serialize.boolean_to_string(fax_enabled), "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 LocalPage(self._version, response, self._solution) async def page_async( @@ -582,13 +594,19 @@ async def page_async( { "AreaCode": area_code, "Contains": contains, - "SmsEnabled": sms_enabled, - "MmsEnabled": mms_enabled, - "VoiceEnabled": voice_enabled, - "ExcludeAllAddressRequired": exclude_all_address_required, - "ExcludeLocalAddressRequired": exclude_local_address_required, - "ExcludeForeignAddressRequired": exclude_foreign_address_required, - "Beta": beta, + "SmsEnabled": serialize.boolean_to_string(sms_enabled), + "MmsEnabled": serialize.boolean_to_string(mms_enabled), + "VoiceEnabled": serialize.boolean_to_string(voice_enabled), + "ExcludeAllAddressRequired": serialize.boolean_to_string( + exclude_all_address_required + ), + "ExcludeLocalAddressRequired": serialize.boolean_to_string( + exclude_local_address_required + ), + "ExcludeForeignAddressRequired": serialize.boolean_to_string( + exclude_foreign_address_required + ), + "Beta": serialize.boolean_to_string(beta), "NearNumber": near_number, "NearLatLong": near_lat_long, "Distance": distance, @@ -597,15 +615,19 @@ async def page_async( "InRateCenter": in_rate_center, "InLata": in_lata, "InLocality": in_locality, - "FaxEnabled": fax_enabled, + "FaxEnabled": serialize.boolean_to_string(fax_enabled), "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 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 65e0be2b88..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 @@ -12,9 +12,8 @@ Do not edit the class manually. """ - 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_resource import InstanceResource from twilio.base.list_resource import ListResource @@ -23,7 +22,6 @@ class MachineToMachineInstance(InstanceResource): - """ :ivar friendly_name: A formatted version of the phone number. :ivar phone_number: The phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number. @@ -79,6 +77,7 @@ def __repr__(self) -> str: class MachineToMachinePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> MachineToMachineInstance: """ Build an instance of MachineToMachineInstance @@ -102,6 +101,7 @@ def __repr__(self) -> str: class MachineToMachineList(ListResource): + def __init__(self, version: Version, account_sid: str, country_code: str): """ Initialize the MachineToMachineList @@ -501,13 +501,19 @@ def page( { "AreaCode": area_code, "Contains": contains, - "SmsEnabled": sms_enabled, - "MmsEnabled": mms_enabled, - "VoiceEnabled": voice_enabled, - "ExcludeAllAddressRequired": exclude_all_address_required, - "ExcludeLocalAddressRequired": exclude_local_address_required, - "ExcludeForeignAddressRequired": exclude_foreign_address_required, - "Beta": beta, + "SmsEnabled": serialize.boolean_to_string(sms_enabled), + "MmsEnabled": serialize.boolean_to_string(mms_enabled), + "VoiceEnabled": serialize.boolean_to_string(voice_enabled), + "ExcludeAllAddressRequired": serialize.boolean_to_string( + exclude_all_address_required + ), + "ExcludeLocalAddressRequired": serialize.boolean_to_string( + exclude_local_address_required + ), + "ExcludeForeignAddressRequired": serialize.boolean_to_string( + exclude_foreign_address_required + ), + "Beta": serialize.boolean_to_string(beta), "NearNumber": near_number, "NearLatLong": near_lat_long, "Distance": distance, @@ -516,14 +522,20 @@ def page( "InRateCenter": in_rate_center, "InLata": in_lata, "InLocality": in_locality, - "FaxEnabled": fax_enabled, + "FaxEnabled": serialize.boolean_to_string(fax_enabled), "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 MachineToMachinePage(self._version, response, self._solution) async def page_async( @@ -582,13 +594,19 @@ async def page_async( { "AreaCode": area_code, "Contains": contains, - "SmsEnabled": sms_enabled, - "MmsEnabled": mms_enabled, - "VoiceEnabled": voice_enabled, - "ExcludeAllAddressRequired": exclude_all_address_required, - "ExcludeLocalAddressRequired": exclude_local_address_required, - "ExcludeForeignAddressRequired": exclude_foreign_address_required, - "Beta": beta, + "SmsEnabled": serialize.boolean_to_string(sms_enabled), + "MmsEnabled": serialize.boolean_to_string(mms_enabled), + "VoiceEnabled": serialize.boolean_to_string(voice_enabled), + "ExcludeAllAddressRequired": serialize.boolean_to_string( + exclude_all_address_required + ), + "ExcludeLocalAddressRequired": serialize.boolean_to_string( + exclude_local_address_required + ), + "ExcludeForeignAddressRequired": serialize.boolean_to_string( + exclude_foreign_address_required + ), + "Beta": serialize.boolean_to_string(beta), "NearNumber": near_number, "NearLatLong": near_lat_long, "Distance": distance, @@ -597,15 +615,19 @@ async def page_async( "InRateCenter": in_rate_center, "InLata": in_lata, "InLocality": in_locality, - "FaxEnabled": fax_enabled, + "FaxEnabled": serialize.boolean_to_string(fax_enabled), "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 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 5ef6f891d3..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 @@ -12,9 +12,8 @@ Do not edit the class manually. """ - 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_resource import InstanceResource from twilio.base.list_resource import ListResource @@ -23,7 +22,6 @@ class MobileInstance(InstanceResource): - """ :ivar friendly_name: A formatted version of the phone number. :ivar phone_number: The phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number. @@ -79,6 +77,7 @@ def __repr__(self) -> str: class MobilePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> MobileInstance: """ Build an instance of MobileInstance @@ -102,6 +101,7 @@ def __repr__(self) -> str: class MobileList(ListResource): + def __init__(self, version: Version, account_sid: str, country_code: str): """ Initialize the MobileList @@ -501,13 +501,19 @@ def page( { "AreaCode": area_code, "Contains": contains, - "SmsEnabled": sms_enabled, - "MmsEnabled": mms_enabled, - "VoiceEnabled": voice_enabled, - "ExcludeAllAddressRequired": exclude_all_address_required, - "ExcludeLocalAddressRequired": exclude_local_address_required, - "ExcludeForeignAddressRequired": exclude_foreign_address_required, - "Beta": beta, + "SmsEnabled": serialize.boolean_to_string(sms_enabled), + "MmsEnabled": serialize.boolean_to_string(mms_enabled), + "VoiceEnabled": serialize.boolean_to_string(voice_enabled), + "ExcludeAllAddressRequired": serialize.boolean_to_string( + exclude_all_address_required + ), + "ExcludeLocalAddressRequired": serialize.boolean_to_string( + exclude_local_address_required + ), + "ExcludeForeignAddressRequired": serialize.boolean_to_string( + exclude_foreign_address_required + ), + "Beta": serialize.boolean_to_string(beta), "NearNumber": near_number, "NearLatLong": near_lat_long, "Distance": distance, @@ -516,14 +522,20 @@ def page( "InRateCenter": in_rate_center, "InLata": in_lata, "InLocality": in_locality, - "FaxEnabled": fax_enabled, + "FaxEnabled": serialize.boolean_to_string(fax_enabled), "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 MobilePage(self._version, response, self._solution) async def page_async( @@ -582,13 +594,19 @@ async def page_async( { "AreaCode": area_code, "Contains": contains, - "SmsEnabled": sms_enabled, - "MmsEnabled": mms_enabled, - "VoiceEnabled": voice_enabled, - "ExcludeAllAddressRequired": exclude_all_address_required, - "ExcludeLocalAddressRequired": exclude_local_address_required, - "ExcludeForeignAddressRequired": exclude_foreign_address_required, - "Beta": beta, + "SmsEnabled": serialize.boolean_to_string(sms_enabled), + "MmsEnabled": serialize.boolean_to_string(mms_enabled), + "VoiceEnabled": serialize.boolean_to_string(voice_enabled), + "ExcludeAllAddressRequired": serialize.boolean_to_string( + exclude_all_address_required + ), + "ExcludeLocalAddressRequired": serialize.boolean_to_string( + exclude_local_address_required + ), + "ExcludeForeignAddressRequired": serialize.boolean_to_string( + exclude_foreign_address_required + ), + "Beta": serialize.boolean_to_string(beta), "NearNumber": near_number, "NearLatLong": near_lat_long, "Distance": distance, @@ -597,15 +615,19 @@ async def page_async( "InRateCenter": in_rate_center, "InLata": in_lata, "InLocality": in_locality, - "FaxEnabled": fax_enabled, + "FaxEnabled": serialize.boolean_to_string(fax_enabled), "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 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 8b2edb640c..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 @@ -12,9 +12,8 @@ Do not edit the class manually. """ - 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_resource import InstanceResource from twilio.base.list_resource import ListResource @@ -23,7 +22,6 @@ class NationalInstance(InstanceResource): - """ :ivar friendly_name: A formatted version of the phone number. :ivar phone_number: The phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number. @@ -79,6 +77,7 @@ def __repr__(self) -> str: class NationalPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> NationalInstance: """ Build an instance of NationalInstance @@ -102,6 +101,7 @@ def __repr__(self) -> str: class NationalList(ListResource): + def __init__(self, version: Version, account_sid: str, country_code: str): """ Initialize the NationalList @@ -501,13 +501,19 @@ def page( { "AreaCode": area_code, "Contains": contains, - "SmsEnabled": sms_enabled, - "MmsEnabled": mms_enabled, - "VoiceEnabled": voice_enabled, - "ExcludeAllAddressRequired": exclude_all_address_required, - "ExcludeLocalAddressRequired": exclude_local_address_required, - "ExcludeForeignAddressRequired": exclude_foreign_address_required, - "Beta": beta, + "SmsEnabled": serialize.boolean_to_string(sms_enabled), + "MmsEnabled": serialize.boolean_to_string(mms_enabled), + "VoiceEnabled": serialize.boolean_to_string(voice_enabled), + "ExcludeAllAddressRequired": serialize.boolean_to_string( + exclude_all_address_required + ), + "ExcludeLocalAddressRequired": serialize.boolean_to_string( + exclude_local_address_required + ), + "ExcludeForeignAddressRequired": serialize.boolean_to_string( + exclude_foreign_address_required + ), + "Beta": serialize.boolean_to_string(beta), "NearNumber": near_number, "NearLatLong": near_lat_long, "Distance": distance, @@ -516,14 +522,20 @@ def page( "InRateCenter": in_rate_center, "InLata": in_lata, "InLocality": in_locality, - "FaxEnabled": fax_enabled, + "FaxEnabled": serialize.boolean_to_string(fax_enabled), "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 NationalPage(self._version, response, self._solution) async def page_async( @@ -582,13 +594,19 @@ async def page_async( { "AreaCode": area_code, "Contains": contains, - "SmsEnabled": sms_enabled, - "MmsEnabled": mms_enabled, - "VoiceEnabled": voice_enabled, - "ExcludeAllAddressRequired": exclude_all_address_required, - "ExcludeLocalAddressRequired": exclude_local_address_required, - "ExcludeForeignAddressRequired": exclude_foreign_address_required, - "Beta": beta, + "SmsEnabled": serialize.boolean_to_string(sms_enabled), + "MmsEnabled": serialize.boolean_to_string(mms_enabled), + "VoiceEnabled": serialize.boolean_to_string(voice_enabled), + "ExcludeAllAddressRequired": serialize.boolean_to_string( + exclude_all_address_required + ), + "ExcludeLocalAddressRequired": serialize.boolean_to_string( + exclude_local_address_required + ), + "ExcludeForeignAddressRequired": serialize.boolean_to_string( + exclude_foreign_address_required + ), + "Beta": serialize.boolean_to_string(beta), "NearNumber": near_number, "NearLatLong": near_lat_long, "Distance": distance, @@ -597,15 +615,19 @@ async def page_async( "InRateCenter": in_rate_center, "InLata": in_lata, "InLocality": in_locality, - "FaxEnabled": fax_enabled, + "FaxEnabled": serialize.boolean_to_string(fax_enabled), "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 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 d167c2f039..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 @@ -12,9 +12,8 @@ Do not edit the class manually. """ - 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_resource import InstanceResource from twilio.base.list_resource import ListResource @@ -23,7 +22,6 @@ class SharedCostInstance(InstanceResource): - """ :ivar friendly_name: A formatted version of the phone number. :ivar phone_number: The phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number. @@ -79,6 +77,7 @@ def __repr__(self) -> str: class SharedCostPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> SharedCostInstance: """ Build an instance of SharedCostInstance @@ -102,6 +101,7 @@ def __repr__(self) -> str: class SharedCostList(ListResource): + def __init__(self, version: Version, account_sid: str, country_code: str): """ Initialize the SharedCostList @@ -501,13 +501,19 @@ def page( { "AreaCode": area_code, "Contains": contains, - "SmsEnabled": sms_enabled, - "MmsEnabled": mms_enabled, - "VoiceEnabled": voice_enabled, - "ExcludeAllAddressRequired": exclude_all_address_required, - "ExcludeLocalAddressRequired": exclude_local_address_required, - "ExcludeForeignAddressRequired": exclude_foreign_address_required, - "Beta": beta, + "SmsEnabled": serialize.boolean_to_string(sms_enabled), + "MmsEnabled": serialize.boolean_to_string(mms_enabled), + "VoiceEnabled": serialize.boolean_to_string(voice_enabled), + "ExcludeAllAddressRequired": serialize.boolean_to_string( + exclude_all_address_required + ), + "ExcludeLocalAddressRequired": serialize.boolean_to_string( + exclude_local_address_required + ), + "ExcludeForeignAddressRequired": serialize.boolean_to_string( + exclude_foreign_address_required + ), + "Beta": serialize.boolean_to_string(beta), "NearNumber": near_number, "NearLatLong": near_lat_long, "Distance": distance, @@ -516,14 +522,20 @@ def page( "InRateCenter": in_rate_center, "InLata": in_lata, "InLocality": in_locality, - "FaxEnabled": fax_enabled, + "FaxEnabled": serialize.boolean_to_string(fax_enabled), "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 SharedCostPage(self._version, response, self._solution) async def page_async( @@ -582,13 +594,19 @@ async def page_async( { "AreaCode": area_code, "Contains": contains, - "SmsEnabled": sms_enabled, - "MmsEnabled": mms_enabled, - "VoiceEnabled": voice_enabled, - "ExcludeAllAddressRequired": exclude_all_address_required, - "ExcludeLocalAddressRequired": exclude_local_address_required, - "ExcludeForeignAddressRequired": exclude_foreign_address_required, - "Beta": beta, + "SmsEnabled": serialize.boolean_to_string(sms_enabled), + "MmsEnabled": serialize.boolean_to_string(mms_enabled), + "VoiceEnabled": serialize.boolean_to_string(voice_enabled), + "ExcludeAllAddressRequired": serialize.boolean_to_string( + exclude_all_address_required + ), + "ExcludeLocalAddressRequired": serialize.boolean_to_string( + exclude_local_address_required + ), + "ExcludeForeignAddressRequired": serialize.boolean_to_string( + exclude_foreign_address_required + ), + "Beta": serialize.boolean_to_string(beta), "NearNumber": near_number, "NearLatLong": near_lat_long, "Distance": distance, @@ -597,15 +615,19 @@ async def page_async( "InRateCenter": in_rate_center, "InLata": in_lata, "InLocality": in_locality, - "FaxEnabled": fax_enabled, + "FaxEnabled": serialize.boolean_to_string(fax_enabled), "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 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 aea21d7017..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 @@ -12,9 +12,8 @@ Do not edit the class manually. """ - 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_resource import InstanceResource from twilio.base.list_resource import ListResource @@ -23,7 +22,6 @@ class TollFreeInstance(InstanceResource): - """ :ivar friendly_name: A formatted version of the phone number. :ivar phone_number: The phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number. @@ -79,6 +77,7 @@ def __repr__(self) -> str: class TollFreePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> TollFreeInstance: """ Build an instance of TollFreeInstance @@ -102,6 +101,7 @@ def __repr__(self) -> str: class TollFreeList(ListResource): + def __init__(self, version: Version, account_sid: str, country_code: str): """ Initialize the TollFreeList @@ -501,13 +501,19 @@ def page( { "AreaCode": area_code, "Contains": contains, - "SmsEnabled": sms_enabled, - "MmsEnabled": mms_enabled, - "VoiceEnabled": voice_enabled, - "ExcludeAllAddressRequired": exclude_all_address_required, - "ExcludeLocalAddressRequired": exclude_local_address_required, - "ExcludeForeignAddressRequired": exclude_foreign_address_required, - "Beta": beta, + "SmsEnabled": serialize.boolean_to_string(sms_enabled), + "MmsEnabled": serialize.boolean_to_string(mms_enabled), + "VoiceEnabled": serialize.boolean_to_string(voice_enabled), + "ExcludeAllAddressRequired": serialize.boolean_to_string( + exclude_all_address_required + ), + "ExcludeLocalAddressRequired": serialize.boolean_to_string( + exclude_local_address_required + ), + "ExcludeForeignAddressRequired": serialize.boolean_to_string( + exclude_foreign_address_required + ), + "Beta": serialize.boolean_to_string(beta), "NearNumber": near_number, "NearLatLong": near_lat_long, "Distance": distance, @@ -516,14 +522,20 @@ def page( "InRateCenter": in_rate_center, "InLata": in_lata, "InLocality": in_locality, - "FaxEnabled": fax_enabled, + "FaxEnabled": serialize.boolean_to_string(fax_enabled), "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 TollFreePage(self._version, response, self._solution) async def page_async( @@ -582,13 +594,19 @@ async def page_async( { "AreaCode": area_code, "Contains": contains, - "SmsEnabled": sms_enabled, - "MmsEnabled": mms_enabled, - "VoiceEnabled": voice_enabled, - "ExcludeAllAddressRequired": exclude_all_address_required, - "ExcludeLocalAddressRequired": exclude_local_address_required, - "ExcludeForeignAddressRequired": exclude_foreign_address_required, - "Beta": beta, + "SmsEnabled": serialize.boolean_to_string(sms_enabled), + "MmsEnabled": serialize.boolean_to_string(mms_enabled), + "VoiceEnabled": serialize.boolean_to_string(voice_enabled), + "ExcludeAllAddressRequired": serialize.boolean_to_string( + exclude_all_address_required + ), + "ExcludeLocalAddressRequired": serialize.boolean_to_string( + exclude_local_address_required + ), + "ExcludeForeignAddressRequired": serialize.boolean_to_string( + exclude_foreign_address_required + ), + "Beta": serialize.boolean_to_string(beta), "NearNumber": near_number, "NearLatLong": near_lat_long, "Distance": distance, @@ -597,15 +615,19 @@ async def page_async( "InRateCenter": in_rate_center, "InLata": in_lata, "InLocality": in_locality, - "FaxEnabled": fax_enabled, + "FaxEnabled": serialize.boolean_to_string(fax_enabled), "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 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 fba53f0357..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 @@ -12,9 +12,8 @@ Do not edit the class manually. """ - 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_resource import InstanceResource from twilio.base.list_resource import ListResource @@ -23,7 +22,6 @@ class VoipInstance(InstanceResource): - """ :ivar friendly_name: A formatted version of the phone number. :ivar phone_number: The phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number. @@ -79,6 +77,7 @@ def __repr__(self) -> str: class VoipPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> VoipInstance: """ Build an instance of VoipInstance @@ -102,6 +101,7 @@ def __repr__(self) -> str: class VoipList(ListResource): + def __init__(self, version: Version, account_sid: str, country_code: str): """ Initialize the VoipList @@ -501,13 +501,19 @@ def page( { "AreaCode": area_code, "Contains": contains, - "SmsEnabled": sms_enabled, - "MmsEnabled": mms_enabled, - "VoiceEnabled": voice_enabled, - "ExcludeAllAddressRequired": exclude_all_address_required, - "ExcludeLocalAddressRequired": exclude_local_address_required, - "ExcludeForeignAddressRequired": exclude_foreign_address_required, - "Beta": beta, + "SmsEnabled": serialize.boolean_to_string(sms_enabled), + "MmsEnabled": serialize.boolean_to_string(mms_enabled), + "VoiceEnabled": serialize.boolean_to_string(voice_enabled), + "ExcludeAllAddressRequired": serialize.boolean_to_string( + exclude_all_address_required + ), + "ExcludeLocalAddressRequired": serialize.boolean_to_string( + exclude_local_address_required + ), + "ExcludeForeignAddressRequired": serialize.boolean_to_string( + exclude_foreign_address_required + ), + "Beta": serialize.boolean_to_string(beta), "NearNumber": near_number, "NearLatLong": near_lat_long, "Distance": distance, @@ -516,14 +522,20 @@ def page( "InRateCenter": in_rate_center, "InLata": in_lata, "InLocality": in_locality, - "FaxEnabled": fax_enabled, + "FaxEnabled": serialize.boolean_to_string(fax_enabled), "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 VoipPage(self._version, response, self._solution) async def page_async( @@ -582,13 +594,19 @@ async def page_async( { "AreaCode": area_code, "Contains": contains, - "SmsEnabled": sms_enabled, - "MmsEnabled": mms_enabled, - "VoiceEnabled": voice_enabled, - "ExcludeAllAddressRequired": exclude_all_address_required, - "ExcludeLocalAddressRequired": exclude_local_address_required, - "ExcludeForeignAddressRequired": exclude_foreign_address_required, - "Beta": beta, + "SmsEnabled": serialize.boolean_to_string(sms_enabled), + "MmsEnabled": serialize.boolean_to_string(mms_enabled), + "VoiceEnabled": serialize.boolean_to_string(voice_enabled), + "ExcludeAllAddressRequired": serialize.boolean_to_string( + exclude_all_address_required + ), + "ExcludeLocalAddressRequired": serialize.boolean_to_string( + exclude_local_address_required + ), + "ExcludeForeignAddressRequired": serialize.boolean_to_string( + exclude_foreign_address_required + ), + "Beta": serialize.boolean_to_string(beta), "NearNumber": near_number, "NearLatLong": near_lat_long, "Distance": distance, @@ -597,15 +615,19 @@ async def page_async( "InRateCenter": in_rate_center, "InLata": in_lata, "InLocality": in_locality, - "FaxEnabled": fax_enabled, + "FaxEnabled": serialize.boolean_to_string(fax_enabled), "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 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 e3c2d5e7e4..66bb91e9f9 100644 --- a/twilio/rest/api/v2010/account/balance.py +++ b/twilio/rest/api/v2010/account/balance.py @@ -12,8 +12,8 @@ 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 @@ -21,7 +21,6 @@ class BalanceInstance(InstanceResource): - """ :ivar account_sid: The unique SID identifier of the Account. :ivar balance: The balance of the Account, in units specified by the unit parameter. Balance changes may not be reflected immediately. Child accounts do not contain balance information @@ -50,6 +49,7 @@ def __repr__(self) -> str: class BalanceList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the BalanceList @@ -70,9 +70,14 @@ def fetch(self) -> BalanceInstance: """ Asynchronously fetch the BalanceInstance + :returns: The fetched BalanceInstance """ - payload = self._version.fetch(method="GET", uri=self._uri) + 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 BalanceInstance( self._version, payload, account_sid=self._solution["account_sid"] @@ -82,9 +87,16 @@ async def fetch_async(self) -> BalanceInstance: """ Asynchronously fetch the BalanceInstance + :returns: The fetched BalanceInstance """ - payload = await self._version.fetch_async(method="GET", uri=self._uri) + 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 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 7c969eff7d..f7756c40ec 100644 --- a/twilio/rest/api/v2010/account/call/__init__.py +++ b/twilio/rest/api/v2010/account/call/__init__.py @@ -12,7 +12,6 @@ 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 @@ -22,13 +21,12 @@ from twilio.base.version import Version from twilio.base.page import Page from twilio.rest.api.v2010.account.call.event import EventList -from twilio.rest.api.v2010.account.call.feedback import FeedbackList -from twilio.rest.api.v2010.account.call.feedback_summary import FeedbackSummaryList from twilio.rest.api.v2010.account.call.notification import NotificationList from twilio.rest.api.v2010.account.call.payment import PaymentList 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, ) @@ -38,6 +36,7 @@ class CallInstance(InstanceResource): + class Status(object): QUEUED = "queued" RINGING = "ringing" @@ -54,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`. @@ -64,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. @@ -270,13 +269,6 @@ def events(self) -> EventList: """ return self._proxy.events - @property - def feedback(self) -> FeedbackList: - """ - Access the feedback - """ - return self._proxy.feedback - @property def notifications(self) -> NotificationList: """ @@ -312,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: """ @@ -337,6 +336,7 @@ def __repr__(self) -> str: class CallContext(InstanceContext): + def __init__(self, version: Version, account_sid: str, sid: str): """ Initialize the CallContext @@ -355,12 +355,12 @@ def __init__(self, version: Version, account_sid: str, sid: str): self._uri = "/Accounts/{account_sid}/Calls/{sid}.json".format(**self._solution) self._events: Optional[EventList] = None - self._feedback: Optional[FeedbackList] = None self._notifications: Optional[NotificationList] = None self._payments: Optional[PaymentList] = None 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 @@ -373,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: """ @@ -385,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: @@ -398,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, @@ -418,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( @@ -457,6 +463,7 @@ def update( :returns: The updated CallInstance """ + data = values.of( { "Url": url, @@ -470,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( @@ -511,6 +521,7 @@ async def update_async( :returns: The updated CallInstance """ + data = values.of( { "Url": url, @@ -524,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( @@ -551,19 +565,6 @@ def events(self) -> EventList: ) return self._events - @property - def feedback(self) -> FeedbackList: - """ - Access the feedback - """ - if self._feedback is None: - self._feedback = FeedbackList( - self._version, - self._solution["account_sid"], - self._solution["sid"], - ) - return self._feedback - @property def notifications(self) -> NotificationList: """ @@ -629,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: """ @@ -668,6 +682,7 @@ def __repr__(self) -> str: class CallPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> CallInstance: """ Build an instance of CallInstance @@ -688,6 +703,7 @@ def __repr__(self) -> str: class CallList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the CallList @@ -704,8 +720,6 @@ def __init__(self, version: Version, account_sid: str): } self._uri = "/Accounts/{account_sid}/Calls.json".format(**self._solution) - self._feedback_summaries: Optional[FeedbackSummaryList] = None - def create( self, to: str, @@ -755,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. @@ -785,6 +799,7 @@ def create( :returns: The created CallInstance """ + data = values.of( { "To": to, @@ -799,7 +814,7 @@ def create( "StatusCallbackMethod": status_callback_method, "SendDigits": send_digits, "Timeout": timeout, - "Record": record, + "Record": serialize.boolean_to_string(record), "RecordingChannels": recording_channels, "RecordingStatusCallback": recording_status_callback, "RecordingStatusCallbackMethod": recording_status_callback_method, @@ -828,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( @@ -888,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. @@ -918,6 +936,7 @@ async def create_async( :returns: The created CallInstance """ + data = values.of( { "To": to, @@ -932,7 +951,7 @@ async def create_async( "StatusCallbackMethod": status_callback_method, "SendDigits": send_digits, "Timeout": timeout, - "Record": record, + "Record": serialize.boolean_to_string(record), "RecordingChannels": recording_channels, "RecordingStatusCallback": recording_status_callback, "RecordingStatusCallbackMethod": recording_status_callback_method, @@ -961,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( @@ -997,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 @@ -1054,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 @@ -1110,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 @@ -1166,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 @@ -1223,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 @@ -1253,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( @@ -1280,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 @@ -1310,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) @@ -1339,17 +1371,6 @@ async def get_page_async(self, target_url: str) -> CallPage: response = await self._version.domain.twilio.request_async("GET", target_url) return CallPage(self._version, response, self._solution) - @property - def feedback_summaries(self) -> FeedbackSummaryList: - """ - Access the feedback_summaries - """ - if self._feedback_summaries is None: - self._feedback_summaries = FeedbackSummaryList( - self._version, account_sid=self._solution["account_sid"] - ) - return self._feedback_summaries - def get(self, sid: str) -> CallContext: """ Constructs a CallContext diff --git a/twilio/rest/api/v2010/account/call/event.py b/twilio/rest/api/v2010/account/call/event.py index bb77d6510a..80eb8aa8ba 100644 --- a/twilio/rest/api/v2010/account/call/event.py +++ b/twilio/rest/api/v2010/account/call/event.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import values @@ -23,7 +22,6 @@ class EventInstance(InstanceResource): - """ :ivar request: Contains a dictionary representing the request of the call. :ivar response: Contains a dictionary representing the call response, including a list of the call events. @@ -53,6 +51,7 @@ def __repr__(self) -> str: class EventPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> EventInstance: """ Build an instance of EventInstance @@ -76,6 +75,7 @@ def __repr__(self) -> str: class EventList(ListResource): + def __init__(self, version: Version, account_sid: str, call_sid: str): """ Initialize the EventList @@ -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/feedback.py b/twilio/rest/api/v2010/account/call/feedback.py deleted file mode 100644 index 8eb84a966a..0000000000 --- a/twilio/rest/api/v2010/account/call/feedback.py +++ /dev/null @@ -1,331 +0,0 @@ -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, List, 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 FeedbackInstance(InstanceResource): - class Issues(object): - AUDIO_LATENCY = "audio-latency" - DIGITS_NOT_CAPTURED = "digits-not-captured" - DROPPED_CALL = "dropped-call" - IMPERFECT_AUDIO = "imperfect-audio" - INCORRECT_CALLER_ID = "incorrect-caller-id" - ONE_WAY_AUDIO = "one-way-audio" - POST_DIAL_DELAY = "post-dial-delay" - UNSOLICITED_CALL = "unsolicited-call" - - """ - :ivar account_sid: The unique id of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this resource. - :ivar date_created: The date that this resource was created, given in [RFC 2822](https://www.php.net/manual/en/class.datetime.php#datetime.constants.rfc2822) format. - :ivar date_updated: The date that this resource was last updated, given in [RFC 2822](https://www.php.net/manual/en/class.datetime.php#datetime.constants.rfc2822) format. - :ivar issues: A list of issues experienced during the call. The issues can be: `imperfect-audio`, `dropped-call`, `incorrect-caller-id`, `post-dial-delay`, `digits-not-captured`, `audio-latency`, `unsolicited-call`, or `one-way-audio`. - :ivar quality_score: `1` to `5` quality score where `1` represents imperfect experience and `5` represents a perfect call. - :ivar sid: A 34 character string that uniquely identifies this resource. - """ - - def __init__( - self, version: Version, payload: Dict[str, Any], account_sid: str, call_sid: str - ): - super().__init__(version) - - self.account_sid: Optional[str] = payload.get("account_sid") - 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.issues: Optional[List["FeedbackInstance.Issues"]] = payload.get("issues") - self.quality_score: Optional[int] = deserialize.integer( - payload.get("quality_score") - ) - self.sid: Optional[str] = payload.get("sid") - - self._solution = { - "account_sid": account_sid, - "call_sid": call_sid, - } - self._context: Optional[FeedbackContext] = None - - @property - def _proxy(self) -> "FeedbackContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: FeedbackContext for this FeedbackInstance - """ - if self._context is None: - self._context = FeedbackContext( - self._version, - account_sid=self._solution["account_sid"], - call_sid=self._solution["call_sid"], - ) - return self._context - - def fetch(self) -> "FeedbackInstance": - """ - Fetch the FeedbackInstance - - - :returns: The fetched FeedbackInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "FeedbackInstance": - """ - Asynchronous coroutine to fetch the FeedbackInstance - - - :returns: The fetched FeedbackInstance - """ - return await self._proxy.fetch_async() - - def update( - self, - quality_score: Union[int, object] = values.unset, - issue: Union[List["FeedbackInstance.Issues"], object] = values.unset, - ) -> "FeedbackInstance": - """ - Update the FeedbackInstance - - :param quality_score: The call quality expressed as an integer from `1` to `5` where `1` represents very poor call quality and `5` represents a perfect call. - :param issue: One or more issues experienced during the call. The issues can be: `imperfect-audio`, `dropped-call`, `incorrect-caller-id`, `post-dial-delay`, `digits-not-captured`, `audio-latency`, `unsolicited-call`, or `one-way-audio`. - - :returns: The updated FeedbackInstance - """ - return self._proxy.update( - quality_score=quality_score, - issue=issue, - ) - - async def update_async( - self, - quality_score: Union[int, object] = values.unset, - issue: Union[List["FeedbackInstance.Issues"], object] = values.unset, - ) -> "FeedbackInstance": - """ - Asynchronous coroutine to update the FeedbackInstance - - :param quality_score: The call quality expressed as an integer from `1` to `5` where `1` represents very poor call quality and `5` represents a perfect call. - :param issue: One or more issues experienced during the call. The issues can be: `imperfect-audio`, `dropped-call`, `incorrect-caller-id`, `post-dial-delay`, `digits-not-captured`, `audio-latency`, `unsolicited-call`, or `one-way-audio`. - - :returns: The updated FeedbackInstance - """ - return await self._proxy.update_async( - quality_score=quality_score, - issue=issue, - ) - - 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 FeedbackContext(InstanceContext): - def __init__(self, version: Version, account_sid: str, call_sid: str): - """ - Initialize the FeedbackContext - - :param version: Version that contains the resource - :param account_sid: The unique id of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this resource. - :param call_sid: The call sid that uniquely identifies the call - """ - super().__init__(version) - - # Path Solution - self._solution = { - "account_sid": account_sid, - "call_sid": call_sid, - } - self._uri = "/Accounts/{account_sid}/Calls/{call_sid}/Feedback.json".format( - **self._solution - ) - - def fetch(self) -> FeedbackInstance: - """ - Fetch the FeedbackInstance - - - :returns: The fetched FeedbackInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return FeedbackInstance( - self._version, - payload, - account_sid=self._solution["account_sid"], - call_sid=self._solution["call_sid"], - ) - - async def fetch_async(self) -> FeedbackInstance: - """ - Asynchronous coroutine to fetch the FeedbackInstance - - - :returns: The fetched FeedbackInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return FeedbackInstance( - self._version, - payload, - account_sid=self._solution["account_sid"], - call_sid=self._solution["call_sid"], - ) - - def update( - self, - quality_score: Union[int, object] = values.unset, - issue: Union[List["FeedbackInstance.Issues"], object] = values.unset, - ) -> FeedbackInstance: - """ - Update the FeedbackInstance - - :param quality_score: The call quality expressed as an integer from `1` to `5` where `1` represents very poor call quality and `5` represents a perfect call. - :param issue: One or more issues experienced during the call. The issues can be: `imperfect-audio`, `dropped-call`, `incorrect-caller-id`, `post-dial-delay`, `digits-not-captured`, `audio-latency`, `unsolicited-call`, or `one-way-audio`. - - :returns: The updated FeedbackInstance - """ - data = values.of( - { - "QualityScore": quality_score, - "Issue": serialize.map(issue, lambda e: e), - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return FeedbackInstance( - self._version, - payload, - account_sid=self._solution["account_sid"], - call_sid=self._solution["call_sid"], - ) - - async def update_async( - self, - quality_score: Union[int, object] = values.unset, - issue: Union[List["FeedbackInstance.Issues"], object] = values.unset, - ) -> FeedbackInstance: - """ - Asynchronous coroutine to update the FeedbackInstance - - :param quality_score: The call quality expressed as an integer from `1` to `5` where `1` represents very poor call quality and `5` represents a perfect call. - :param issue: One or more issues experienced during the call. The issues can be: `imperfect-audio`, `dropped-call`, `incorrect-caller-id`, `post-dial-delay`, `digits-not-captured`, `audio-latency`, `unsolicited-call`, or `one-way-audio`. - - :returns: The updated FeedbackInstance - """ - data = values.of( - { - "QualityScore": quality_score, - "Issue": serialize.map(issue, lambda e: e), - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return FeedbackInstance( - self._version, - payload, - account_sid=self._solution["account_sid"], - call_sid=self._solution["call_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 FeedbackList(ListResource): - def __init__(self, version: Version, account_sid: str, call_sid: str): - """ - Initialize the FeedbackList - - :param version: Version that contains the resource - :param account_sid: The unique id of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this resource. - :param call_sid: The call sid that uniquely identifies the call - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "account_sid": account_sid, - "call_sid": call_sid, - } - - def get(self) -> FeedbackContext: - """ - Constructs a FeedbackContext - - """ - return FeedbackContext( - self._version, - account_sid=self._solution["account_sid"], - call_sid=self._solution["call_sid"], - ) - - def __call__(self) -> FeedbackContext: - """ - Constructs a FeedbackContext - - """ - return FeedbackContext( - self._version, - account_sid=self._solution["account_sid"], - call_sid=self._solution["call_sid"], - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/api/v2010/account/call/feedback_summary.py b/twilio/rest/api/v2010/account/call/feedback_summary.py deleted file mode 100644 index fcfb4e0ab1..0000000000 --- a/twilio/rest/api/v2010/account/call/feedback_summary.py +++ /dev/null @@ -1,374 +0,0 @@ -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 date, datetime -from typing import Any, Dict, List, 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 FeedbackSummaryInstance(InstanceResource): - class Status(object): - QUEUED = "queued" - IN_PROGRESS = "in-progress" - COMPLETED = "completed" - FAILED = "failed" - - """ - :ivar account_sid: The unique id of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this resource. - :ivar call_count: The total number of calls. - :ivar call_feedback_count: The total number of calls with a feedback entry. - :ivar date_created: The date that this resource was created, given in [RFC 2822](https://www.php.net/manual/en/class.datetime.php#datetime.constants.rfc2822) format. - :ivar date_updated: The date that this resource was last updated, given in [RFC 2822](https://www.php.net/manual/en/class.datetime.php#datetime.constants.rfc2822) format. - :ivar end_date: The last date for which feedback entries are included in this Feedback Summary, formatted as `YYYY-MM-DD` and specified in UTC. - :ivar include_subaccounts: Whether the feedback summary includes subaccounts; `true` if it does, otherwise `false`. - :ivar issues: A list of issues experienced during the call. The issues can be: `imperfect-audio`, `dropped-call`, `incorrect-caller-id`, `post-dial-delay`, `digits-not-captured`, `audio-latency`, or `one-way-audio`. - :ivar quality_score_average: The average QualityScore of the feedback entries. - :ivar quality_score_median: The median QualityScore of the feedback entries. - :ivar quality_score_standard_deviation: The standard deviation of the quality scores. - :ivar sid: A 34 character string that uniquely identifies this resource. - :ivar start_date: The first date for which feedback entries are included in this feedback summary, formatted as `YYYY-MM-DD` and specified in UTC. - :ivar status: - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - account_sid: str, - sid: Optional[str] = None, - ): - super().__init__(version) - - self.account_sid: Optional[str] = payload.get("account_sid") - self.call_count: Optional[int] = deserialize.integer(payload.get("call_count")) - self.call_feedback_count: Optional[int] = deserialize.integer( - payload.get("call_feedback_count") - ) - 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.end_date: Optional[date] = deserialize.iso8601_date( - payload.get("end_date") - ) - self.include_subaccounts: Optional[bool] = payload.get("include_subaccounts") - self.issues: Optional[List[object]] = payload.get("issues") - self.quality_score_average: Optional[float] = deserialize.decimal( - payload.get("quality_score_average") - ) - self.quality_score_median: Optional[float] = deserialize.decimal( - payload.get("quality_score_median") - ) - self.quality_score_standard_deviation: Optional[float] = deserialize.decimal( - payload.get("quality_score_standard_deviation") - ) - self.sid: Optional[str] = payload.get("sid") - self.start_date: Optional[date] = deserialize.iso8601_date( - payload.get("start_date") - ) - self.status: Optional["FeedbackSummaryInstance.Status"] = payload.get("status") - - self._solution = { - "account_sid": account_sid, - "sid": sid or self.sid, - } - self._context: Optional[FeedbackSummaryContext] = None - - @property - def _proxy(self) -> "FeedbackSummaryContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: FeedbackSummaryContext for this FeedbackSummaryInstance - """ - if self._context is None: - self._context = FeedbackSummaryContext( - self._version, - account_sid=self._solution["account_sid"], - sid=self._solution["sid"], - ) - return self._context - - def delete(self) -> bool: - """ - Deletes the FeedbackSummaryInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the FeedbackSummaryInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def fetch(self) -> "FeedbackSummaryInstance": - """ - Fetch the FeedbackSummaryInstance - - - :returns: The fetched FeedbackSummaryInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "FeedbackSummaryInstance": - """ - Asynchronous coroutine to fetch the FeedbackSummaryInstance - - - :returns: The fetched FeedbackSummaryInstance - """ - 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 FeedbackSummaryContext(InstanceContext): - def __init__(self, version: Version, account_sid: str, sid: str): - """ - Initialize the FeedbackSummaryContext - - :param version: Version that contains the resource - :param account_sid: The unique id of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this resource. - :param sid: A 34 character string that uniquely identifies this resource. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "account_sid": account_sid, - "sid": sid, - } - self._uri = "/Accounts/{account_sid}/Calls/FeedbackSummary/{sid}.json".format( - **self._solution - ) - - def delete(self) -> bool: - """ - Deletes the FeedbackSummaryInstance - - - :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 FeedbackSummaryInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._version.delete_async( - method="DELETE", - uri=self._uri, - ) - - def fetch(self) -> FeedbackSummaryInstance: - """ - Fetch the FeedbackSummaryInstance - - - :returns: The fetched FeedbackSummaryInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return FeedbackSummaryInstance( - self._version, - payload, - account_sid=self._solution["account_sid"], - sid=self._solution["sid"], - ) - - async def fetch_async(self) -> FeedbackSummaryInstance: - """ - Asynchronous coroutine to fetch the FeedbackSummaryInstance - - - :returns: The fetched FeedbackSummaryInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return FeedbackSummaryInstance( - self._version, - payload, - account_sid=self._solution["account_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 FeedbackSummaryList(ListResource): - def __init__(self, version: Version, account_sid: str): - """ - Initialize the FeedbackSummaryList - - :param version: Version that contains the resource - :param account_sid: The unique id of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this resource. - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "account_sid": account_sid, - } - self._uri = "/Accounts/{account_sid}/Calls/FeedbackSummary.json".format( - **self._solution - ) - - def create( - self, - start_date: date, - end_date: date, - include_subaccounts: Union[bool, object] = values.unset, - status_callback: Union[str, object] = values.unset, - status_callback_method: Union[str, object] = values.unset, - ) -> FeedbackSummaryInstance: - """ - Create the FeedbackSummaryInstance - - :param start_date: Only include feedback given on or after this date. Format is `YYYY-MM-DD` and specified in UTC. - :param end_date: Only include feedback given on or before this date. Format is `YYYY-MM-DD` and specified in UTC. - :param include_subaccounts: Whether to also include Feedback resources from all subaccounts. `true` includes feedback from all subaccounts and `false`, the default, includes feedback from only the specified account. - :param status_callback: The URL that we will request when the feedback summary is complete. - :param status_callback_method: The HTTP method (`GET` or `POST`) we use to make the request to the `StatusCallback` URL. - - :returns: The created FeedbackSummaryInstance - """ - data = values.of( - { - "StartDate": serialize.iso8601_date(start_date), - "EndDate": serialize.iso8601_date(end_date), - "IncludeSubaccounts": include_subaccounts, - "StatusCallback": status_callback, - "StatusCallbackMethod": status_callback_method, - } - ) - - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) - - return FeedbackSummaryInstance( - self._version, payload, account_sid=self._solution["account_sid"] - ) - - async def create_async( - self, - start_date: date, - end_date: date, - include_subaccounts: Union[bool, object] = values.unset, - status_callback: Union[str, object] = values.unset, - status_callback_method: Union[str, object] = values.unset, - ) -> FeedbackSummaryInstance: - """ - Asynchronously create the FeedbackSummaryInstance - - :param start_date: Only include feedback given on or after this date. Format is `YYYY-MM-DD` and specified in UTC. - :param end_date: Only include feedback given on or before this date. Format is `YYYY-MM-DD` and specified in UTC. - :param include_subaccounts: Whether to also include Feedback resources from all subaccounts. `true` includes feedback from all subaccounts and `false`, the default, includes feedback from only the specified account. - :param status_callback: The URL that we will request when the feedback summary is complete. - :param status_callback_method: The HTTP method (`GET` or `POST`) we use to make the request to the `StatusCallback` URL. - - :returns: The created FeedbackSummaryInstance - """ - data = values.of( - { - "StartDate": serialize.iso8601_date(start_date), - "EndDate": serialize.iso8601_date(end_date), - "IncludeSubaccounts": include_subaccounts, - "StatusCallback": status_callback, - "StatusCallbackMethod": status_callback_method, - } - ) - - payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, - ) - - return FeedbackSummaryInstance( - self._version, payload, account_sid=self._solution["account_sid"] - ) - - def get(self, sid: str) -> FeedbackSummaryContext: - """ - Constructs a FeedbackSummaryContext - - :param sid: A 34 character string that uniquely identifies this resource. - """ - return FeedbackSummaryContext( - self._version, account_sid=self._solution["account_sid"], sid=sid - ) - - def __call__(self, sid: str) -> FeedbackSummaryContext: - """ - Constructs a FeedbackSummaryContext - - :param sid: A 34 character string that uniquely identifies this resource. - """ - return FeedbackSummaryContext( - self._version, account_sid=self._solution["account_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/notification.py b/twilio/rest/api/v2010/account/call/notification.py index 5db223c859..fd9e8c0d00 100644 --- a/twilio/rest/api/v2010/account/call/notification.py +++ b/twilio/rest/api/v2010/account/call/notification.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import date, datetime from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import deserialize, serialize, values @@ -24,7 +23,6 @@ class NotificationInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Call Notification resource. :ivar api_version: The API version used to create the Call Notification resource. @@ -132,6 +130,7 @@ def __repr__(self) -> str: class NotificationContext(InstanceContext): + def __init__(self, version: Version, account_sid: str, call_sid: str, sid: str): """ Initialize the NotificationContext @@ -163,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, @@ -184,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( @@ -208,6 +211,7 @@ def __repr__(self) -> str: class NotificationPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> NotificationInstance: """ Build an instance of NotificationInstance @@ -231,6 +235,7 @@ def __repr__(self) -> str: class NotificationList(ListResource): + def __init__(self, version: Version, account_sid: str, call_sid: str): """ Initialize the NotificationList @@ -444,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( @@ -483,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 10d00441ba..0f91860987 100644 --- a/twilio/rest/api/v2010/account/call/payment.py +++ b/twilio/rest/api/v2010/account/call/payment.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import datetime from typing import Any, Dict, Optional, Union from twilio.base import deserialize, serialize, values @@ -23,6 +22,7 @@ class PaymentInstance(InstanceResource): + class BankAccountType(object): CONSUMER_CHECKING = "consumer-checking" CONSUMER_SAVINGS = "consumer-savings" @@ -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. @@ -161,6 +162,7 @@ def __repr__(self) -> str: class PaymentContext(InstanceContext): + def __init__(self, version: Version, account_sid: str, call_sid: str, sid: str): """ Initialize the PaymentContext @@ -201,6 +203,7 @@ def update( :returns: The updated PaymentInstance """ + data = values.of( { "IdempotencyKey": idempotency_key, @@ -209,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( @@ -241,6 +247,7 @@ async def update_async( :returns: The updated PaymentInstance """ + data = values.of( { "IdempotencyKey": idempotency_key, @@ -249,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( @@ -275,6 +285,7 @@ def __repr__(self) -> str: class PaymentList(ListResource): + def __init__(self, version: Version, account_sid: str, call_sid: str): """ Initialize the PaymentList @@ -338,6 +349,7 @@ def create( :returns: The created PaymentInstance """ + data = values.of( { "IdempotencyKey": idempotency_key, @@ -351,18 +363,21 @@ def create( "Parameter": serialize.object(parameter), "PaymentConnector": payment_connector, "PaymentMethod": payment_method, - "PostalCode": postal_code, - "SecurityCode": security_code, + "PostalCode": serialize.boolean_to_string(postal_code), + "SecurityCode": serialize.boolean_to_string(security_code), "Timeout": timeout, "TokenType": token_type, "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( @@ -415,6 +430,7 @@ async def create_async( :returns: The created PaymentInstance """ + data = values.of( { "IdempotencyKey": idempotency_key, @@ -428,18 +444,21 @@ async def create_async( "Parameter": serialize.object(parameter), "PaymentConnector": payment_connector, "PaymentMethod": payment_method, - "PostalCode": postal_code, - "SecurityCode": security_code, + "PostalCode": serialize.boolean_to_string(postal_code), + "SecurityCode": serialize.boolean_to_string(security_code), "Timeout": timeout, "TokenType": token_type, "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 7ca36f3e00..5b93ec6c95 100644 --- a/twilio/rest/api/v2010/account/call/recording.py +++ b/twilio/rest/api/v2010/account/call/recording.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import date, datetime from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import deserialize, serialize, values @@ -24,6 +23,7 @@ class RecordingInstance(InstanceResource): + class Source(object): DIALVERB = "DialVerb" CONFERENCE = "Conference" @@ -206,6 +206,7 @@ def __repr__(self) -> str: class RecordingContext(InstanceContext): + def __init__(self, version: Version, account_sid: str, call_sid: str, sid: str): """ Initialize the RecordingContext @@ -236,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: """ @@ -248,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: @@ -261,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, @@ -282,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( @@ -308,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( @@ -342,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( @@ -374,6 +389,7 @@ def __repr__(self) -> str: class RecordingPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> RecordingInstance: """ Build an instance of RecordingInstance @@ -397,6 +413,7 @@ def __repr__(self) -> str: class RecordingList(ListResource): + def __init__(self, version: Version, account_sid: str, call_sid: str): """ Initialize the RecordingList @@ -438,6 +455,7 @@ def create( :returns: The created RecordingInstance """ + data = values.of( { "RecordingStatusCallbackEvent": serialize.map( @@ -450,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( @@ -485,6 +506,7 @@ async def create_async( :returns: The created RecordingInstance """ + data = values.of( { "RecordingStatusCallbackEvent": serialize.map( @@ -497,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( @@ -687,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( @@ -723,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 86bfd5c6bc..d808331c64 100644 --- a/twilio/rest/api/v2010/account/call/siprec.py +++ b/twilio/rest/api/v2010/account/call/siprec.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import datetime from typing import Any, Dict, Optional, Union from twilio.base import deserialize, values @@ -23,6 +22,7 @@ class SiprecInstance(InstanceResource): + class Status(object): IN_PROGRESS = "in-progress" STOPPED = "stopped" @@ -126,6 +126,7 @@ def __repr__(self) -> str: class SiprecContext(InstanceContext): + def __init__(self, version: Version, account_sid: str, call_sid: str, sid: str): """ Initialize the SiprecContext @@ -155,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( @@ -185,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( @@ -216,6 +225,7 @@ def __repr__(self) -> str: class SiprecList(ListResource): + def __init__(self, version: Version, account_sid: str, call_sid: str): """ Initialize the SiprecList @@ -651,6 +661,7 @@ def create( :returns: The created SiprecInstance """ + data = values.of( { "Name": name, @@ -858,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( @@ -1287,6 +1301,7 @@ async def create_async( :returns: The created SiprecInstance """ + data = values.of( { "Name": name, @@ -1494,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 1999e9379b..1a506e6684 100644 --- a/twilio/rest/api/v2010/account/call/stream.py +++ b/twilio/rest/api/v2010/account/call/stream.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import datetime from typing import Any, Dict, Optional, Union from twilio.base import deserialize, values @@ -23,6 +22,7 @@ class StreamInstance(InstanceResource): + class Status(object): IN_PROGRESS = "in-progress" STOPPED = "stopped" @@ -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`. @@ -126,6 +126,7 @@ def __repr__(self) -> str: class StreamContext(InstanceContext): + def __init__(self, version: Version, account_sid: str, call_sid: str, sid: str): """ Initialize the StreamContext @@ -133,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) @@ -157,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( @@ -187,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( @@ -218,6 +227,7 @@ def __repr__(self) -> str: class StreamList(ListResource): + def __init__(self, version: Version, account_sid: str, call_sid: str): """ Initialize the StreamList @@ -447,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 @@ -653,6 +663,7 @@ def create( :returns: The created StreamInstance """ + data = values.of( { "Url": url, @@ -860,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( @@ -1083,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 @@ -1289,6 +1303,7 @@ async def create_async( :returns: The created StreamInstance """ + data = values.of( { "Url": url, @@ -1496,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( @@ -1514,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, @@ -1527,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..4f8f9125b6 --- /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 [Intelligence Service](https://www.twilio.com/docs/conversational-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 [Intelligence Service](https://www.twilio.com/docs/conversational-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 0beef389d7..bc66f8b8e1 100644 --- a/twilio/rest/api/v2010/account/call/user_defined_message.py +++ b/twilio/rest/api/v2010/account/call/user_defined_message.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import datetime from typing import Any, Dict, Optional, Union from twilio.base import deserialize, values @@ -23,7 +22,6 @@ class UserDefinedMessageInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created User Defined Message. :ivar call_sid: The SID of the [Call](https://www.twilio.com/docs/voice/api/call-resource) the User Defined Message is associated with. @@ -59,6 +57,7 @@ def __repr__(self) -> str: class UserDefinedMessageList(ListResource): + def __init__(self, version: Version, account_sid: str, call_sid: str): """ Initialize the UserDefinedMessageList @@ -92,17 +91,21 @@ def create( :returns: The created UserDefinedMessageInstance """ + data = values.of( { "Content": content, "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( @@ -123,17 +126,21 @@ async def create_async( :returns: The created UserDefinedMessageInstance """ + data = values.of( { "Content": content, "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 c34905dcdb..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 @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import datetime from typing import Any, Dict, Optional, Union from twilio.base import deserialize, values @@ -23,7 +22,6 @@ class UserDefinedMessageSubscriptionInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that subscribed to the User Defined Messages. :ivar call_sid: The SID of the [Call](https://www.twilio.com/docs/voice/api/call-resource) the User Defined Message Subscription is associated with. This refers to the Call SID that is producing the User Defined Messages. @@ -105,6 +103,7 @@ def __repr__(self) -> str: class UserDefinedMessageSubscriptionContext(InstanceContext): + def __init__(self, version: Version, account_sid: str, call_sid: str, sid: str): """ Initialize the UserDefinedMessageSubscriptionContext @@ -133,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: """ @@ -145,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: @@ -163,6 +164,7 @@ def __repr__(self) -> str: class UserDefinedMessageSubscriptionList(ListResource): + def __init__(self, version: Version, account_sid: str, call_sid: str): """ Initialize the UserDefinedMessageSubscriptionList @@ -198,6 +200,7 @@ def create( :returns: The created UserDefinedMessageSubscriptionInstance """ + data = values.of( { "Callback": callback, @@ -205,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( @@ -234,6 +240,7 @@ async def create_async( :returns: The created UserDefinedMessageSubscriptionInstance """ + data = values.of( { "Callback": callback, @@ -241,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 062c7013ed..672d9d0fea 100644 --- a/twilio/rest/api/v2010/account/conference/__init__.py +++ b/twilio/rest/api/v2010/account/conference/__init__.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import date, datetime from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import deserialize, serialize, values @@ -26,6 +25,7 @@ class ConferenceInstance(InstanceResource): + class ReasonConferenceEnded(object): CONFERENCE_ENDED_VIA_API = "conference-ended-via-api" PARTICIPANT_WITH_END_CONFERENCE_ON_EXIT_LEFT = ( @@ -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`. @@ -199,6 +199,7 @@ def __repr__(self) -> str: class ConferenceContext(InstanceContext): + def __init__(self, version: Version, account_sid: str, sid: str): """ Initialize the ConferenceContext @@ -229,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, @@ -249,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( @@ -276,6 +281,7 @@ def update( :returns: The updated ConferenceInstance """ + data = values.of( { "Status": status, @@ -283,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( @@ -312,6 +321,7 @@ async def update_async( :returns: The updated ConferenceInstance """ + data = values.of( { "Status": status, @@ -319,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( @@ -370,6 +383,7 @@ def __repr__(self) -> str: class ConferencePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ConferenceInstance: """ Build an instance of ConferenceInstance @@ -390,6 +404,7 @@ def __repr__(self) -> str: class ConferenceList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the ConferenceList @@ -425,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() @@ -476,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() @@ -526,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 @@ -576,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 @@ -627,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 @@ -657,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( @@ -678,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 @@ -708,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 c4eee73400..3c49e5387c 100644 --- a/twilio/rest/api/v2010/account/conference/participant.py +++ b/twilio/rest/api/v2010/account/conference/participant.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class ParticipantInstance(InstanceResource): + class Status(object): QUEUED = "queued" CONNECTING = "connecting" @@ -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`. @@ -249,6 +251,7 @@ def __repr__(self) -> str: class ParticipantContext(InstanceContext): + def __init__( self, version: Version, account_sid: str, conference_sid: str, call_sid: str ): @@ -279,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: """ @@ -291,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: @@ -304,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, @@ -325,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( @@ -362,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`. @@ -371,27 +380,33 @@ def update( :returns: The updated ParticipantInstance """ + data = values.of( { - "Muted": muted, - "Hold": hold, + "Muted": serialize.boolean_to_string(muted), + "Hold": serialize.boolean_to_string(hold), "HoldUrl": hold_url, "HoldMethod": hold_method, "AnnounceUrl": announce_url, "AnnounceMethod": announce_method, "WaitUrl": wait_url, "WaitMethod": wait_method, - "BeepOnExit": beep_on_exit, - "EndConferenceOnExit": end_conference_on_exit, - "Coaching": coaching, + "BeepOnExit": serialize.boolean_to_string(beep_on_exit), + "EndConferenceOnExit": serialize.boolean_to_string( + end_conference_on_exit + ), + "Coaching": serialize.boolean_to_string(coaching), "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( @@ -426,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`. @@ -435,27 +450,33 @@ async def update_async( :returns: The updated ParticipantInstance """ + data = values.of( { - "Muted": muted, - "Hold": hold, + "Muted": serialize.boolean_to_string(muted), + "Hold": serialize.boolean_to_string(hold), "HoldUrl": hold_url, "HoldMethod": hold_method, "AnnounceUrl": announce_url, "AnnounceMethod": announce_method, "WaitUrl": wait_url, "WaitMethod": wait_method, - "BeepOnExit": beep_on_exit, - "EndConferenceOnExit": end_conference_on_exit, - "Coaching": coaching, + "BeepOnExit": serialize.boolean_to_string(beep_on_exit), + "EndConferenceOnExit": serialize.boolean_to_string( + end_conference_on_exit + ), + "Coaching": serialize.boolean_to_string(coaching), "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( @@ -477,6 +498,7 @@ def __repr__(self) -> str: class ParticipantPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ParticipantInstance: """ Build an instance of ParticipantInstance @@ -500,6 +522,7 @@ def __repr__(self) -> str: class ParticipantList(ListResource): + def __init__(self, version: Version, account_sid: str, conference_sid: str): """ Initialize the ParticipantList @@ -570,6 +593,8 @@ def create( machine_detection_silence_timeout: Union[int, object] = values.unset, amd_status_callback: Union[str, object] = values.unset, amd_status_callback_method: Union[str, object] = values.unset, + trim: Union[str, object] = values.unset, + call_token: Union[str, object] = values.unset, ) -> ParticipantInstance: """ Create the ParticipantInstance @@ -586,12 +611,12 @@ 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`. :param conference_record: Whether to record the conference the participant is joining. Can be: `true`, `false`, `record-from-start`, and `do-not-record`. The default value is `false`. - :param conference_trim: Whether to trim leading and trailing silence from your recorded conference audio files. Can be: `trim-silence` or `do-not-trim` and defaults to `trim-silence`. + :param conference_trim: Whether to trim leading and trailing silence from the conference recording. Can be: `trim-silence` or `do-not-trim` and defaults to `trim-silence`. :param conference_status_callback: The URL we should call using the `conference_status_callback_method` when the conference events in `conference_status_callback_event` occur. Only the value set by the first participant to join the conference is used. Subsequent `conference_status_callback` values are ignored. :param conference_status_callback_method: The HTTP method we should use to call `conference_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. :param conference_status_callback_event: The conference state changes that should generate a call to `conference_status_callback`. Can be: `start`, `end`, `join`, `leave`, `mute`, `hold`, `modify`, `speaker`, and `announcement`. Separate multiple values with a space. Defaults to `start end`. @@ -600,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'`. @@ -613,16 +638,19 @@ def create( :param call_reason: The Reason for the outgoing call. Use it to specify the purpose of the call that is presented on the called party's phone. (Branded Calls Beta) :param recording_track: The audio track to record for the call. Can be: `inbound`, `outbound` or `both`. The default is `both`. `inbound` records the audio that is received by Twilio. `outbound` records the audio that is sent from Twilio. `both` records the audio that is received and sent by Twilio. :param time_limit: The maximum duration of the call in seconds. Constraints depend on account and configuration. - :param machine_detection: Whether to detect if a human, answering machine, or fax has picked up the call. Can be: `Enable` or `DetectMessageEnd`. Use `Enable` if you would like us to return `AnsweredBy` as soon as the called party is identified. Use `DetectMessageEnd`, if you would like to leave a message on an answering machine. If `send_digits` is provided, this parameter is ignored. For more information, see [Answering Machine Detection](https://www.twilio.com/docs/voice/answering-machine-detection). + :param machine_detection: Whether to detect if a human, answering machine, or fax has picked up the call. Can be: `Enable` or `DetectMessageEnd`. Use `Enable` if you would like us to return `AnsweredBy` as soon as the called party is identified. Use `DetectMessageEnd`, if you would like to leave a message on an answering machine. For more information, see [Answering Machine Detection](https://www.twilio.com/docs/voice/answering-machine-detection). :param machine_detection_timeout: The number of seconds that we should attempt to detect an answering machine before timing out and sending a voice request with `AnsweredBy` of `unknown`. The default timeout is 30 seconds. :param machine_detection_speech_threshold: The number of milliseconds that is used as the measuring stick for the length of the speech activity, where durations lower than this value will be interpreted as a human and longer than this value as a machine. Possible Values: 1000-6000. Default: 2400. :param machine_detection_speech_end_threshold: The number of milliseconds of silence after speech activity at which point the speech activity is considered complete. Possible Values: 500-5000. Default: 1200. :param machine_detection_silence_timeout: The number of milliseconds of initial silence after which an `unknown` AnsweredBy result will be returned. Possible Values: 2000-10000. Default: 5000. :param amd_status_callback: The URL that we should call using the `amd_status_callback_method` to notify customer application whether the call was answered by human, machine or fax. :param amd_status_callback_method: The HTTP method we should use when calling the `amd_status_callback` URL. Can be: `GET` or `POST` and the default is `POST`. + :param trim: Whether to trim any leading and trailing silence from the participant recording. Can be: `trim-silence` or `do-not-trim` and the default is `trim-silence`. + :param call_token: A token string needed to invoke a forwarded call. A call_token is generated when an incoming call is received on a Twilio number. Pass an incoming call's call_token value to a forwarded call via the call_token parameter when creating a new call. A forwarded call should bear the same CallerID of the original incoming call. :returns: The created ParticipantInstance """ + data = values.of( { "From": from_, @@ -634,14 +662,18 @@ def create( ), "Label": label, "Timeout": timeout, - "Record": record, - "Muted": muted, + "Record": serialize.boolean_to_string(record), + "Muted": serialize.boolean_to_string(muted), "Beep": beep, - "StartConferenceOnEnter": start_conference_on_enter, - "EndConferenceOnExit": end_conference_on_exit, + "StartConferenceOnEnter": serialize.boolean_to_string( + start_conference_on_enter + ), + "EndConferenceOnExit": serialize.boolean_to_string( + end_conference_on_exit + ), "WaitUrl": wait_url, "WaitMethod": wait_method, - "EarlyMedia": early_media, + "EarlyMedia": serialize.boolean_to_string(early_media), "MaxParticipants": max_participants, "ConferenceRecord": conference_record, "ConferenceTrim": conference_trim, @@ -664,7 +696,7 @@ def create( "ConferenceRecordingStatusCallbackEvent": serialize.map( conference_recording_status_callback_event, lambda e: e ), - "Coaching": coaching, + "Coaching": serialize.boolean_to_string(coaching), "CallSidToCoach": call_sid_to_coach, "JitterBufferSize": jitter_buffer_size, "Byoc": byoc, @@ -679,13 +711,18 @@ def create( "MachineDetectionSilenceTimeout": machine_detection_silence_timeout, "AmdStatusCallback": amd_status_callback, "AmdStatusCallbackMethod": amd_status_callback_method, + "Trim": trim, + "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( @@ -745,6 +782,8 @@ async def create_async( machine_detection_silence_timeout: Union[int, object] = values.unset, amd_status_callback: Union[str, object] = values.unset, amd_status_callback_method: Union[str, object] = values.unset, + trim: Union[str, object] = values.unset, + call_token: Union[str, object] = values.unset, ) -> ParticipantInstance: """ Asynchronously create the ParticipantInstance @@ -761,12 +800,12 @@ 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`. :param conference_record: Whether to record the conference the participant is joining. Can be: `true`, `false`, `record-from-start`, and `do-not-record`. The default value is `false`. - :param conference_trim: Whether to trim leading and trailing silence from your recorded conference audio files. Can be: `trim-silence` or `do-not-trim` and defaults to `trim-silence`. + :param conference_trim: Whether to trim leading and trailing silence from the conference recording. Can be: `trim-silence` or `do-not-trim` and defaults to `trim-silence`. :param conference_status_callback: The URL we should call using the `conference_status_callback_method` when the conference events in `conference_status_callback_event` occur. Only the value set by the first participant to join the conference is used. Subsequent `conference_status_callback` values are ignored. :param conference_status_callback_method: The HTTP method we should use to call `conference_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. :param conference_status_callback_event: The conference state changes that should generate a call to `conference_status_callback`. Can be: `start`, `end`, `join`, `leave`, `mute`, `hold`, `modify`, `speaker`, and `announcement`. Separate multiple values with a space. Defaults to `start end`. @@ -775,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'`. @@ -788,16 +827,19 @@ async def create_async( :param call_reason: The Reason for the outgoing call. Use it to specify the purpose of the call that is presented on the called party's phone. (Branded Calls Beta) :param recording_track: The audio track to record for the call. Can be: `inbound`, `outbound` or `both`. The default is `both`. `inbound` records the audio that is received by Twilio. `outbound` records the audio that is sent from Twilio. `both` records the audio that is received and sent by Twilio. :param time_limit: The maximum duration of the call in seconds. Constraints depend on account and configuration. - :param machine_detection: Whether to detect if a human, answering machine, or fax has picked up the call. Can be: `Enable` or `DetectMessageEnd`. Use `Enable` if you would like us to return `AnsweredBy` as soon as the called party is identified. Use `DetectMessageEnd`, if you would like to leave a message on an answering machine. If `send_digits` is provided, this parameter is ignored. For more information, see [Answering Machine Detection](https://www.twilio.com/docs/voice/answering-machine-detection). + :param machine_detection: Whether to detect if a human, answering machine, or fax has picked up the call. Can be: `Enable` or `DetectMessageEnd`. Use `Enable` if you would like us to return `AnsweredBy` as soon as the called party is identified. Use `DetectMessageEnd`, if you would like to leave a message on an answering machine. For more information, see [Answering Machine Detection](https://www.twilio.com/docs/voice/answering-machine-detection). :param machine_detection_timeout: The number of seconds that we should attempt to detect an answering machine before timing out and sending a voice request with `AnsweredBy` of `unknown`. The default timeout is 30 seconds. :param machine_detection_speech_threshold: The number of milliseconds that is used as the measuring stick for the length of the speech activity, where durations lower than this value will be interpreted as a human and longer than this value as a machine. Possible Values: 1000-6000. Default: 2400. :param machine_detection_speech_end_threshold: The number of milliseconds of silence after speech activity at which point the speech activity is considered complete. Possible Values: 500-5000. Default: 1200. :param machine_detection_silence_timeout: The number of milliseconds of initial silence after which an `unknown` AnsweredBy result will be returned. Possible Values: 2000-10000. Default: 5000. :param amd_status_callback: The URL that we should call using the `amd_status_callback_method` to notify customer application whether the call was answered by human, machine or fax. :param amd_status_callback_method: The HTTP method we should use when calling the `amd_status_callback` URL. Can be: `GET` or `POST` and the default is `POST`. + :param trim: Whether to trim any leading and trailing silence from the participant recording. Can be: `trim-silence` or `do-not-trim` and the default is `trim-silence`. + :param call_token: A token string needed to invoke a forwarded call. A call_token is generated when an incoming call is received on a Twilio number. Pass an incoming call's call_token value to a forwarded call via the call_token parameter when creating a new call. A forwarded call should bear the same CallerID of the original incoming call. :returns: The created ParticipantInstance """ + data = values.of( { "From": from_, @@ -809,14 +851,18 @@ async def create_async( ), "Label": label, "Timeout": timeout, - "Record": record, - "Muted": muted, + "Record": serialize.boolean_to_string(record), + "Muted": serialize.boolean_to_string(muted), "Beep": beep, - "StartConferenceOnEnter": start_conference_on_enter, - "EndConferenceOnExit": end_conference_on_exit, + "StartConferenceOnEnter": serialize.boolean_to_string( + start_conference_on_enter + ), + "EndConferenceOnExit": serialize.boolean_to_string( + end_conference_on_exit + ), "WaitUrl": wait_url, "WaitMethod": wait_method, - "EarlyMedia": early_media, + "EarlyMedia": serialize.boolean_to_string(early_media), "MaxParticipants": max_participants, "ConferenceRecord": conference_record, "ConferenceTrim": conference_trim, @@ -839,7 +885,7 @@ async def create_async( "ConferenceRecordingStatusCallbackEvent": serialize.map( conference_recording_status_callback_event, lambda e: e ), - "Coaching": coaching, + "Coaching": serialize.boolean_to_string(coaching), "CallSidToCoach": call_sid_to_coach, "JitterBufferSize": jitter_buffer_size, "Byoc": byoc, @@ -854,13 +900,18 @@ async def create_async( "MachineDetectionSilenceTimeout": machine_detection_silence_timeout, "AmdStatusCallback": amd_status_callback, "AmdStatusCallbackMethod": amd_status_callback_method, + "Trim": trim, + "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( @@ -1031,16 +1082,22 @@ def page( """ data = values.of( { - "Muted": muted, - "Hold": hold, - "Coaching": coaching, + "Muted": serialize.boolean_to_string(muted), + "Hold": serialize.boolean_to_string(hold), + "Coaching": serialize.boolean_to_string(coaching), "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 ParticipantPage(self._version, response, self._solution) async def page_async( @@ -1067,17 +1124,21 @@ async def page_async( """ data = values.of( { - "Muted": muted, - "Hold": hold, - "Coaching": coaching, + "Muted": serialize.boolean_to_string(muted), + "Hold": serialize.boolean_to_string(hold), + "Coaching": serialize.boolean_to_string(coaching), "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 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 e9ac5789cb..12008ed37f 100644 --- a/twilio/rest/api/v2010/account/conference/recording.py +++ b/twilio/rest/api/v2010/account/conference/recording.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import date, datetime from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import deserialize, serialize, values @@ -24,6 +23,7 @@ class RecordingInstance(InstanceResource): + class Source(object): DIALVERB = "DialVerb" CONFERENCE = "Conference" @@ -204,6 +204,7 @@ def __repr__(self) -> str: class RecordingContext(InstanceContext): + def __init__( self, version: Version, account_sid: str, conference_sid: str, sid: str ): @@ -234,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: """ @@ -246,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: @@ -259,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, @@ -280,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( @@ -306,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( @@ -340,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( @@ -372,6 +387,7 @@ def __repr__(self) -> str: class RecordingPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> RecordingInstance: """ Build an instance of RecordingInstance @@ -395,6 +411,7 @@ def __repr__(self) -> str: class RecordingList(ListResource): + def __init__(self, version: Version, account_sid: str, conference_sid: str): """ Initialize the RecordingList @@ -591,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( @@ -627,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 e34fbeae4d..689a2b184a 100644 --- a/twilio/rest/api/v2010/account/connect_app.py +++ b/twilio/rest/api/v2010/account/connect_app.py @@ -12,7 +12,6 @@ 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 @@ -23,6 +22,7 @@ class ConnectAppInstance(InstanceResource): + class Permission(object): GET_ALL = "get-all" POST_ALL = "post-all" @@ -215,6 +215,7 @@ def __repr__(self) -> str: class ConnectAppContext(InstanceContext): + def __init__(self, version: Version, account_sid: str, sid: str): """ Initialize the ConnectAppContext @@ -241,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: """ @@ -253,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: @@ -266,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, @@ -286,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( @@ -325,6 +332,7 @@ def update( :returns: The updated ConnectAppInstance """ + data = values.of( { "AuthorizeRedirectUrl": authorize_redirect_url, @@ -337,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( @@ -378,6 +389,7 @@ async def update_async( :returns: The updated ConnectAppInstance """ + data = values.of( { "AuthorizeRedirectUrl": authorize_redirect_url, @@ -390,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( @@ -415,6 +430,7 @@ def __repr__(self) -> str: class ConnectAppPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ConnectAppInstance: """ Build an instance of ConnectAppInstance @@ -435,6 +451,7 @@ def __repr__(self) -> str: class ConnectAppList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the ConnectAppList @@ -578,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( @@ -605,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 121d2f03c8..c7c1eebcfd 100644 --- a/twilio/rest/api/v2010/account/incoming_phone_number/__init__.py +++ b/twilio/rest/api/v2010/account/incoming_phone_number/__init__.py @@ -12,10 +12,9 @@ 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 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 @@ -30,6 +29,7 @@ class IncomingPhoneNumberInstance(InstanceResource): + class AddressRequirement(object): NONE = "none" ANY = "any" @@ -395,6 +395,7 @@ def __repr__(self) -> str: class IncomingPhoneNumberContext(InstanceContext): + def __init__(self, version: Version, account_sid: str, sid: str): """ Initialize the IncomingPhoneNumberContext @@ -423,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: """ @@ -435,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: @@ -448,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, @@ -468,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( @@ -539,6 +546,7 @@ def update( :returns: The updated IncomingPhoneNumberInstance """ + data = values.of( { "AccountSid": account_sid, @@ -552,7 +560,9 @@ def update( "StatusCallback": status_callback, "StatusCallbackMethod": status_callback_method, "VoiceApplicationSid": voice_application_sid, - "VoiceCallerIdLookup": voice_caller_id_lookup, + "VoiceCallerIdLookup": serialize.boolean_to_string( + voice_caller_id_lookup + ), "VoiceFallbackMethod": voice_fallback_method, "VoiceFallbackUrl": voice_fallback_url, "VoiceMethod": voice_method, @@ -566,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( @@ -639,6 +652,7 @@ async def update_async( :returns: The updated IncomingPhoneNumberInstance """ + data = values.of( { "AccountSid": account_sid, @@ -652,7 +666,9 @@ async def update_async( "StatusCallback": status_callback, "StatusCallbackMethod": status_callback_method, "VoiceApplicationSid": voice_application_sid, - "VoiceCallerIdLookup": voice_caller_id_lookup, + "VoiceCallerIdLookup": serialize.boolean_to_string( + voice_caller_id_lookup + ), "VoiceFallbackMethod": voice_fallback_method, "VoiceFallbackUrl": voice_fallback_url, "VoiceMethod": voice_method, @@ -666,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( @@ -704,6 +723,7 @@ def __repr__(self) -> str: class IncomingPhoneNumberPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> IncomingPhoneNumberInstance: """ Build an instance of IncomingPhoneNumberInstance @@ -724,6 +744,7 @@ def __repr__(self) -> str: class IncomingPhoneNumberList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the IncomingPhoneNumberList @@ -807,6 +828,7 @@ def create( :returns: The created IncomingPhoneNumberInstance """ + data = values.of( { "ApiVersion": api_version, @@ -819,7 +841,9 @@ def create( "StatusCallback": status_callback, "StatusCallbackMethod": status_callback_method, "VoiceApplicationSid": voice_application_sid, - "VoiceCallerIdLookup": voice_caller_id_lookup, + "VoiceCallerIdLookup": serialize.boolean_to_string( + voice_caller_id_lookup + ), "VoiceFallbackMethod": voice_fallback_method, "VoiceFallbackUrl": voice_fallback_url, "VoiceMethod": voice_method, @@ -835,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( @@ -907,6 +934,7 @@ async def create_async( :returns: The created IncomingPhoneNumberInstance """ + data = values.of( { "ApiVersion": api_version, @@ -919,7 +947,9 @@ async def create_async( "StatusCallback": status_callback, "StatusCallbackMethod": status_callback_method, "VoiceApplicationSid": voice_application_sid, - "VoiceCallerIdLookup": voice_caller_id_lookup, + "VoiceCallerIdLookup": serialize.boolean_to_string( + voice_caller_id_lookup + ), "VoiceFallbackMethod": voice_fallback_method, "VoiceFallbackUrl": voice_fallback_url, "VoiceMethod": voice_method, @@ -935,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( @@ -1127,7 +1160,7 @@ def page( """ data = values.of( { - "Beta": beta, + "Beta": serialize.boolean_to_string(beta), "FriendlyName": friendly_name, "PhoneNumber": phone_number, "Origin": origin, @@ -1137,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( @@ -1166,7 +1205,7 @@ async def page_async( """ data = values.of( { - "Beta": beta, + "Beta": serialize.boolean_to_string(beta), "FriendlyName": friendly_name, "PhoneNumber": phone_number, "Origin": origin, @@ -1176,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 4b04d75256..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 @@ -12,7 +12,6 @@ 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 @@ -27,7 +26,6 @@ class AssignedAddOnInstance(InstanceResource): - """ :ivar sid: The unique string that that we created to identify the resource. :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the resource. @@ -148,6 +146,7 @@ def __repr__(self) -> str: class AssignedAddOnContext(InstanceContext): + def __init__(self, version: Version, account_sid: str, resource_sid: str, sid: str): """ Initialize the AssignedAddOnContext @@ -178,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: """ @@ -190,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: @@ -203,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, @@ -224,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( @@ -262,6 +267,7 @@ def __repr__(self) -> str: class AssignedAddOnPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> AssignedAddOnInstance: """ Build an instance of AssignedAddOnInstance @@ -285,6 +291,7 @@ def __repr__(self) -> str: class AssignedAddOnList(ListResource): + def __init__(self, version: Version, account_sid: str, resource_sid: str): """ Initialize the AssignedAddOnList @@ -313,16 +320,20 @@ def create(self, installed_add_on_sid: str) -> AssignedAddOnInstance: :returns: The created AssignedAddOnInstance """ + data = values.of( { "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( @@ -340,16 +351,20 @@ async def create_async(self, installed_add_on_sid: str) -> AssignedAddOnInstance :returns: The created AssignedAddOnInstance """ + data = values.of( { "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( @@ -486,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( @@ -513,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 54b1c2a80b..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 @@ -12,7 +12,6 @@ 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 @@ -23,7 +22,6 @@ class AssignedAddOnExtensionInstance(InstanceResource): - """ :ivar sid: The unique string that that we created to identify the resource. :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the resource. @@ -112,6 +110,7 @@ def __repr__(self) -> str: class AssignedAddOnExtensionContext(InstanceContext): + def __init__( self, version: Version, @@ -150,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, @@ -172,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( @@ -197,6 +200,7 @@ def __repr__(self) -> str: class AssignedAddOnExtensionPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> AssignedAddOnExtensionInstance: """ Build an instance of AssignedAddOnExtensionInstance @@ -221,6 +225,7 @@ def __repr__(self) -> str: class AssignedAddOnExtensionList(ListResource): + def __init__( self, version: Version, @@ -376,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( @@ -403,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 4af79dcf8a..af67fb0a2d 100644 --- a/twilio/rest/api/v2010/account/incoming_phone_number/local.py +++ b/twilio/rest/api/v2010/account/incoming_phone_number/local.py @@ -12,10 +12,9 @@ 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 import deserialize, serialize, values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource @@ -24,6 +23,7 @@ class LocalInstance(InstanceResource): + class AddressRequirement(object): NONE = "none" ANY = "any" @@ -88,9 +88,9 @@ def __init__(self, version: Version, payload: Dict[str, Any], account_sid: str): self.account_sid: Optional[str] = payload.get("account_sid") self.address_sid: Optional[str] = payload.get("address_sid") - self.address_requirements: Optional[ - "LocalInstance.AddressRequirement" - ] = payload.get("address_requirements") + self.address_requirements: Optional["LocalInstance.AddressRequirement"] = ( + payload.get("address_requirements") + ) self.api_version: Optional[str] = payload.get("api_version") self.beta: Optional[bool] = payload.get("beta") self.capabilities: Optional[str] = payload.get("capabilities") @@ -116,9 +116,9 @@ def __init__(self, version: Version, payload: Dict[str, Any], account_sid: str): ) self.trunk_sid: Optional[str] = payload.get("trunk_sid") self.uri: Optional[str] = payload.get("uri") - self.voice_receive_mode: Optional[ - "LocalInstance.VoiceReceiveMode" - ] = payload.get("voice_receive_mode") + self.voice_receive_mode: Optional["LocalInstance.VoiceReceiveMode"] = ( + payload.get("voice_receive_mode") + ) self.voice_application_sid: Optional[str] = payload.get("voice_application_sid") self.voice_caller_id_lookup: Optional[bool] = payload.get( "voice_caller_id_lookup" @@ -152,6 +152,7 @@ def __repr__(self) -> str: class LocalPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> LocalInstance: """ Build an instance of LocalInstance @@ -172,6 +173,7 @@ def __repr__(self) -> str: class LocalList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the LocalList @@ -247,6 +249,7 @@ def create( :returns: The created LocalInstance """ + data = values.of( { "PhoneNumber": phone_number, @@ -260,7 +263,9 @@ def create( "StatusCallback": status_callback, "StatusCallbackMethod": status_callback_method, "VoiceApplicationSid": voice_application_sid, - "VoiceCallerIdLookup": voice_caller_id_lookup, + "VoiceCallerIdLookup": serialize.boolean_to_string( + voice_caller_id_lookup + ), "VoiceFallbackMethod": voice_fallback_method, "VoiceFallbackUrl": voice_fallback_url, "VoiceMethod": voice_method, @@ -274,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( @@ -342,6 +350,7 @@ async def create_async( :returns: The created LocalInstance """ + data = values.of( { "PhoneNumber": phone_number, @@ -355,7 +364,9 @@ async def create_async( "StatusCallback": status_callback, "StatusCallbackMethod": status_callback_method, "VoiceApplicationSid": voice_application_sid, - "VoiceCallerIdLookup": voice_caller_id_lookup, + "VoiceCallerIdLookup": serialize.boolean_to_string( + voice_caller_id_lookup + ), "VoiceFallbackMethod": voice_fallback_method, "VoiceFallbackUrl": voice_fallback_url, "VoiceMethod": voice_method, @@ -369,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( @@ -561,7 +575,7 @@ def page( """ data = values.of( { - "Beta": beta, + "Beta": serialize.boolean_to_string(beta), "FriendlyName": friendly_name, "PhoneNumber": phone_number, "Origin": origin, @@ -571,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( @@ -600,7 +620,7 @@ async def page_async( """ data = values.of( { - "Beta": beta, + "Beta": serialize.boolean_to_string(beta), "FriendlyName": friendly_name, "PhoneNumber": phone_number, "Origin": origin, @@ -610,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 2ab5a652c5..27fc8a0e9f 100644 --- a/twilio/rest/api/v2010/account/incoming_phone_number/mobile.py +++ b/twilio/rest/api/v2010/account/incoming_phone_number/mobile.py @@ -12,10 +12,9 @@ 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 import deserialize, serialize, values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource @@ -24,6 +23,7 @@ class MobileInstance(InstanceResource): + class AddressRequirement(object): NONE = "none" ANY = "any" @@ -88,9 +88,9 @@ def __init__(self, version: Version, payload: Dict[str, Any], account_sid: str): self.account_sid: Optional[str] = payload.get("account_sid") self.address_sid: Optional[str] = payload.get("address_sid") - self.address_requirements: Optional[ - "MobileInstance.AddressRequirement" - ] = payload.get("address_requirements") + self.address_requirements: Optional["MobileInstance.AddressRequirement"] = ( + payload.get("address_requirements") + ) self.api_version: Optional[str] = payload.get("api_version") self.beta: Optional[bool] = payload.get("beta") self.capabilities: Optional[str] = payload.get("capabilities") @@ -116,9 +116,9 @@ def __init__(self, version: Version, payload: Dict[str, Any], account_sid: str): ) self.trunk_sid: Optional[str] = payload.get("trunk_sid") self.uri: Optional[str] = payload.get("uri") - self.voice_receive_mode: Optional[ - "MobileInstance.VoiceReceiveMode" - ] = payload.get("voice_receive_mode") + self.voice_receive_mode: Optional["MobileInstance.VoiceReceiveMode"] = ( + payload.get("voice_receive_mode") + ) self.voice_application_sid: Optional[str] = payload.get("voice_application_sid") self.voice_caller_id_lookup: Optional[bool] = payload.get( "voice_caller_id_lookup" @@ -152,6 +152,7 @@ def __repr__(self) -> str: class MobilePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> MobileInstance: """ Build an instance of MobileInstance @@ -172,6 +173,7 @@ def __repr__(self) -> str: class MobileList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the MobileList @@ -249,6 +251,7 @@ def create( :returns: The created MobileInstance """ + data = values.of( { "PhoneNumber": phone_number, @@ -262,7 +265,9 @@ def create( "StatusCallback": status_callback, "StatusCallbackMethod": status_callback_method, "VoiceApplicationSid": voice_application_sid, - "VoiceCallerIdLookup": voice_caller_id_lookup, + "VoiceCallerIdLookup": serialize.boolean_to_string( + voice_caller_id_lookup + ), "VoiceFallbackMethod": voice_fallback_method, "VoiceFallbackUrl": voice_fallback_url, "VoiceMethod": voice_method, @@ -276,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( @@ -346,6 +354,7 @@ async def create_async( :returns: The created MobileInstance """ + data = values.of( { "PhoneNumber": phone_number, @@ -359,7 +368,9 @@ async def create_async( "StatusCallback": status_callback, "StatusCallbackMethod": status_callback_method, "VoiceApplicationSid": voice_application_sid, - "VoiceCallerIdLookup": voice_caller_id_lookup, + "VoiceCallerIdLookup": serialize.boolean_to_string( + voice_caller_id_lookup + ), "VoiceFallbackMethod": voice_fallback_method, "VoiceFallbackUrl": voice_fallback_url, "VoiceMethod": voice_method, @@ -373,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( @@ -565,7 +579,7 @@ def page( """ data = values.of( { - "Beta": beta, + "Beta": serialize.boolean_to_string(beta), "FriendlyName": friendly_name, "PhoneNumber": phone_number, "Origin": origin, @@ -575,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( @@ -604,7 +624,7 @@ async def page_async( """ data = values.of( { - "Beta": beta, + "Beta": serialize.boolean_to_string(beta), "FriendlyName": friendly_name, "PhoneNumber": phone_number, "Origin": origin, @@ -614,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 3b995504a5..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 @@ -12,10 +12,9 @@ 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 import deserialize, serialize, values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource @@ -24,6 +23,7 @@ class TollFreeInstance(InstanceResource): + class AddressRequirement(object): NONE = "none" ANY = "any" @@ -88,9 +88,9 @@ def __init__(self, version: Version, payload: Dict[str, Any], account_sid: str): self.account_sid: Optional[str] = payload.get("account_sid") self.address_sid: Optional[str] = payload.get("address_sid") - self.address_requirements: Optional[ - "TollFreeInstance.AddressRequirement" - ] = payload.get("address_requirements") + self.address_requirements: Optional["TollFreeInstance.AddressRequirement"] = ( + payload.get("address_requirements") + ) self.api_version: Optional[str] = payload.get("api_version") self.beta: Optional[bool] = payload.get("beta") self.capabilities: Optional[str] = payload.get("capabilities") @@ -116,9 +116,9 @@ def __init__(self, version: Version, payload: Dict[str, Any], account_sid: str): ) self.trunk_sid: Optional[str] = payload.get("trunk_sid") self.uri: Optional[str] = payload.get("uri") - self.voice_receive_mode: Optional[ - "TollFreeInstance.VoiceReceiveMode" - ] = payload.get("voice_receive_mode") + self.voice_receive_mode: Optional["TollFreeInstance.VoiceReceiveMode"] = ( + payload.get("voice_receive_mode") + ) self.voice_application_sid: Optional[str] = payload.get("voice_application_sid") self.voice_caller_id_lookup: Optional[bool] = payload.get( "voice_caller_id_lookup" @@ -127,9 +127,9 @@ def __init__(self, version: Version, payload: Dict[str, Any], account_sid: str): self.voice_fallback_url: Optional[str] = payload.get("voice_fallback_url") self.voice_method: Optional[str] = payload.get("voice_method") self.voice_url: Optional[str] = payload.get("voice_url") - self.emergency_status: Optional[ - "TollFreeInstance.EmergencyStatus" - ] = payload.get("emergency_status") + self.emergency_status: Optional["TollFreeInstance.EmergencyStatus"] = ( + payload.get("emergency_status") + ) self.emergency_address_sid: Optional[str] = payload.get("emergency_address_sid") self.emergency_address_status: Optional[ "TollFreeInstance.EmergencyAddressStatus" @@ -152,6 +152,7 @@ def __repr__(self) -> str: class TollFreePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> TollFreeInstance: """ Build an instance of TollFreeInstance @@ -172,6 +173,7 @@ def __repr__(self) -> str: class TollFreeList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the TollFreeList @@ -249,6 +251,7 @@ def create( :returns: The created TollFreeInstance """ + data = values.of( { "PhoneNumber": phone_number, @@ -262,7 +265,9 @@ def create( "StatusCallback": status_callback, "StatusCallbackMethod": status_callback_method, "VoiceApplicationSid": voice_application_sid, - "VoiceCallerIdLookup": voice_caller_id_lookup, + "VoiceCallerIdLookup": serialize.boolean_to_string( + voice_caller_id_lookup + ), "VoiceFallbackMethod": voice_fallback_method, "VoiceFallbackUrl": voice_fallback_url, "VoiceMethod": voice_method, @@ -276,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( @@ -346,6 +354,7 @@ async def create_async( :returns: The created TollFreeInstance """ + data = values.of( { "PhoneNumber": phone_number, @@ -359,7 +368,9 @@ async def create_async( "StatusCallback": status_callback, "StatusCallbackMethod": status_callback_method, "VoiceApplicationSid": voice_application_sid, - "VoiceCallerIdLookup": voice_caller_id_lookup, + "VoiceCallerIdLookup": serialize.boolean_to_string( + voice_caller_id_lookup + ), "VoiceFallbackMethod": voice_fallback_method, "VoiceFallbackUrl": voice_fallback_url, "VoiceMethod": voice_method, @@ -373,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( @@ -565,7 +579,7 @@ def page( """ data = values.of( { - "Beta": beta, + "Beta": serialize.boolean_to_string(beta), "FriendlyName": friendly_name, "PhoneNumber": phone_number, "Origin": origin, @@ -575,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( @@ -604,7 +624,7 @@ async def page_async( """ data = values.of( { - "Beta": beta, + "Beta": serialize.boolean_to_string(beta), "FriendlyName": friendly_name, "PhoneNumber": phone_number, "Origin": origin, @@ -614,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 76c8f1d55c..8b18dbd4ba 100644 --- a/twilio/rest/api/v2010/account/key.py +++ b/twilio/rest/api/v2010/account/key.py @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class KeyInstance(InstanceResource): - """ :ivar sid: The unique string that that we created to identify the Key resource. :ivar friendly_name: The string that you assigned to describe the resource. @@ -145,6 +143,7 @@ def __repr__(self) -> str: class KeyContext(InstanceContext): + def __init__(self, version: Version, account_sid: str, sid: str): """ Initialize the KeyContext @@ -169,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: """ @@ -181,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: @@ -194,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, @@ -214,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( @@ -234,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( @@ -263,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( @@ -293,6 +306,7 @@ def __repr__(self) -> str: class KeyPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> KeyInstance: """ Build an instance of KeyInstance @@ -313,6 +327,7 @@ def __repr__(self) -> str: class KeyList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the KeyList @@ -456,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( @@ -483,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 476c023605..d5369d11ce 100644 --- a/twilio/rest/api/v2010/account/message/__init__.py +++ b/twilio/rest/api/v2010/account/message/__init__.py @@ -12,7 +12,6 @@ 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 @@ -26,11 +25,14 @@ class MessageInstance(InstanceResource): + class AddressRetention(object): RETAIN = "retain" + OBFUSCATE = "obfuscate" class ContentRetention(object): RETAIN = "retain" + DISCARD = "discard" class Direction(object): INBOUND = "inbound" @@ -38,6 +40,10 @@ class Direction(object): OUTBOUND_CALL = "outbound-call" OUTBOUND_REPLY = "outbound-reply" + class RiskCheck(object): + ENABLE = "enable" + DISABLE = "disable" + class ScheduleType(object): FIXED = "fixed" @@ -56,29 +62,32 @@ class Status(object): PARTIALLY_DELIVERED = "partially_delivered" CANCELED = "canceled" + class TrafficType(object): + FREE = "free" + class UpdateStatus(object): CANCELED = "canceled" """ - :ivar body: The message text. Can be up to 1,600 characters long. - :ivar num_segments: The number of segments that make up the complete message. A message body that is too large to be sent in a single SMS message is segmented and charged as multiple messages. Inbound messages over 160 characters are reassembled when the message is received. Note: When using a Messaging Service to send messages, `num_segments` will always be 0 in Twilio's response to your API request. + :ivar body: The text content of the message + :ivar num_segments: The number of segments that make up the complete message. SMS message bodies that exceed the [character limit](https://www.twilio.com/docs/glossary/what-sms-character-limit) are segmented and charged as multiple messages. Note: For messages sent via a Messaging Service, `num_segments` is initially `0`, since a sender hasn't yet been assigned. :ivar direction: - :ivar _from: The phone number (in [E.164](https://en.wikipedia.org/wiki/E.164) format), [alphanumeric sender ID](https://www.twilio.com/docs/sms/send-messages#use-an-alphanumeric-sender-id), or [Wireless SIM](https://www.twilio.com/docs/wireless/tutorials/communications-guides/how-to-send-and-receive-text-messages) that initiated the message. For incoming messages, this will be the number of the sending phone. For outgoing messages, this value will be one of your Twilio phone numbers or the alphanumeric sender ID used. - :ivar to: The phone number in [E.164](https://en.wikipedia.org/wiki/E.164) format that received the message. For incoming messages, this will be one of your Twilio phone numbers. For outgoing messages, this will be the sending phone. - :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 price: The amount billed for the message, in the currency specified by `price_unit`. Note that your account is charged for each segment we send to the handset. Populated after the message has been sent. May not be immediately available. - :ivar error_message: The description of the `error_code` if your message `status` is `failed` or `undelivered`. If the message was successful, this value is null. - :ivar uri: The URI of the resource, relative to `https://api.twilio.com`. - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that sent the message that created the resource. - :ivar num_media: The number of media files associated with the message. A message can send up to 10 media files. + :ivar from_: The sender's phone number (in [E.164](https://en.wikipedia.org/wiki/E.164) format), [alphanumeric sender ID](https://www.twilio.com/docs/sms/quickstart), [Wireless SIM](https://www.twilio.com/docs/iot/wireless/programmable-wireless-send-machine-machine-sms-commands), [short code](https://www.twilio.com/en-us/messaging/channels/sms/short-codes), or [channel address](https://www.twilio.com/docs/messaging/channels) (e.g., `whatsapp:+15554449999`). For incoming messages, this is the number or channel address of the sender. For outgoing messages, this value is a Twilio phone number, alphanumeric sender ID, short code, or channel address from which the message is sent. + :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`. 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/sms/services/api) used with the message. The value is null if a Messaging Service was not used. - :ivar sid: The unique string that that we created to identify the Message resource. - :ivar date_sent: The date and time in GMT that the resource was sent specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. For outgoing messages, this is when we sent the message. For incoming messages, this is when we made the HTTP request to your application. - :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 error_code: The error code returned if your message `status` is `failed` or `undelivered`. The error_code provides more information about the failure. If the message was successful, this value is null. + :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`. 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 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` """ @@ -94,7 +103,7 @@ def __init__( self.body: Optional[str] = payload.get("body") self.num_segments: Optional[str] = payload.get("num_segments") self.direction: Optional["MessageInstance.Direction"] = payload.get("direction") - self._from: Optional[str] = payload.get("from") + self.from_: Optional[str] = payload.get("from") self.to: Optional[str] = payload.get("to") self.date_updated: Optional[datetime] = deserialize.rfc2822_datetime( payload.get("date_updated") @@ -186,7 +195,7 @@ def update( """ Update the MessageInstance - :param body: The text of the message you want to send. Can be up to 1,600 characters long. + :param body: The new `body` of the Message resource. To redact the text content of a Message, this parameter's value must be an empty string :param status: :returns: The updated MessageInstance @@ -204,7 +213,7 @@ async def update_async( """ Asynchronous coroutine to update the MessageInstance - :param body: The text of the message you want to send. Can be up to 1,600 characters long. + :param body: The new `body` of the Message resource. To redact the text content of a Message, this parameter's value must be an empty string :param status: :returns: The updated MessageInstance @@ -239,13 +248,14 @@ def __repr__(self) -> str: class MessageContext(InstanceContext): + def __init__(self, version: Version, account_sid: str, sid: str): """ Initialize the MessageContext :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 Message resources to update. - :param sid: The Twilio-provided string that uniquely identifies the Message resource to update. + :param sid: The SID of the Message resource to be updated """ super().__init__(version) @@ -268,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: """ @@ -280,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: @@ -293,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, @@ -313,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( @@ -333,22 +349,26 @@ def update( """ Update the MessageInstance - :param body: The text of the message you want to send. Can be up to 1,600 characters long. + :param body: The new `body` of the Message resource. To redact the text content of a Message, this parameter's value must be an empty string :param status: :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( @@ -366,22 +386,26 @@ async def update_async( """ Asynchronous coroutine to update the MessageInstance - :param body: The text of the message you want to send. Can be up to 1,600 characters long. + :param body: The new `body` of the Message resource. To redact the text content of a Message, this parameter's value must be an empty string :param status: :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( @@ -428,6 +452,7 @@ def __repr__(self) -> str: class MessagePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> MessageInstance: """ Build an instance of MessageInstance @@ -448,12 +473,13 @@ def __repr__(self) -> str: class MessageList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the MessageList :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 Message resources to read. + :param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) associated with the Message resources. """ super().__init__(version) @@ -482,76 +508,86 @@ 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, send_as_mms: Union[bool, object] = values.unset, - content_sid: Union[str, object] = values.unset, content_variables: Union[str, object] = values.unset, + risk_check: Union["MessageInstance.RiskCheck", object] = values.unset, from_: Union[str, object] = values.unset, messaging_service_sid: Union[str, object] = values.unset, body: Union[str, object] = values.unset, media_url: Union[List[str], object] = values.unset, + content_sid: Union[str, object] = values.unset, ) -> MessageInstance: """ Create the MessageInstance - :param 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. - :param 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/sms/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/sms/services/api). URLs must contain a valid hostname and underscores are not allowed. - :param 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](https://www.twilio.com/docs/usage/api/applications)'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. - :param 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. - :param provide_feedback: Whether to confirm delivery of the message. Set this value to `true` if you are sending messages that have a trackable user action and you intend to confirm delivery of the message using the [Message Feedback API](https://www.twilio.com/docs/sms/api/message-feedback-resource). This parameter is `false` by default. - :param attempt: Total number of attempts made ( including this ) to send out the message regardless of the provider used - :param 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. + :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: [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 `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 Channels Messages. - :param 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`. + :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. - :param send_as_mms: If set to True, Twilio will deliver the message as a single MMS message, regardless of the presence of media. - :param content_sid: The SID of the Content object returned at Content API content create time (https://www.twilio.com/docs/content-api/create-and-send-your-first-content-api-template#create-a-template). If this parameter is not specified, then the Content API will not be utilized. - :param content_variables: Key-value pairs of variable names to substitution values, used alongside a content_sid. If not specified, Content API will default to the default variables defined at create time. - :param 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. - :param 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. - :param body: The text of the message you want to send. Can be up to 1,600 characters in length. - :param 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. + :param send_as_mms: If set to `true`, Twilio delivers the message as a single MMS message, regardless of the presence of media. + :param content_variables: For [Content Editor/API](https://www.twilio.com/docs/content) only: Key-value pairs of [Template variables](https://www.twilio.com/docs/content/using-variables-with-content-api) and their substitution values. `content_sid` parameter must also be provided. If values are not defined in the `content_variables` parameter, the [Template's default placeholder values](https://www.twilio.com/docs/content/content-api-resources#create-templates) are used. + :param risk_check: + :param from_: The sender's Twilio phone number (in [E.164](https://en.wikipedia.org/wiki/E.164) format), [alphanumeric sender ID](https://www.twilio.com/docs/sms/quickstart), [Wireless SIM](https://www.twilio.com/docs/iot/wireless/programmable-wireless-send-machine-machine-sms-commands), [short code](https://www.twilio.com/en-us/messaging/channels/sms/short-codes), or [channel address](https://www.twilio.com/docs/messaging/channels) (e.g., `whatsapp:+15554449999`). The value of the `from` parameter must be a sender that is hosted within Twilio and belongs to the Account creating the Message. If you are using `messaging_service_sid`, this parameter can be empty (Twilio assigns a `from` value from the Messaging Service's Sender Pool) or you can provide a specific sender from your Sender Pool. + :param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/services) you want to associate with the Message. When this parameter is provided and the `from` parameter is omitted, Twilio selects the optimal sender from the Messaging Service's Sender Pool. You may also provide a `from` parameter if you want to use a specific Sender from the Sender Pool. + :param body: The text content of the outgoing message. Can be up to 1,600 characters in length. SMS only: If the `body` contains more than 160 [GSM-7](https://www.twilio.com/docs/glossary/what-is-gsm-7-character-encoding) characters (or 70 [UCS-2](https://www.twilio.com/docs/glossary/what-is-ucs-2-character-encoding) characters), the message is segmented and charged accordingly. For long `body` text, consider using the [send_as_mms parameter](https://www.twilio.com/blog/mms-for-long-text-messages). + :param media_url: The URL of media to include in the Message content. `jpeg`, `jpg`, `gif`, and `png` file types are fully supported by Twilio and content is formatted for delivery on destination devices. The media size limit is 5 MB for supported file types (`jpeg`, `jpg`, `png`, `gif`) and 500 KB for [other types](https://www.twilio.com/docs/messaging/guides/accepted-mime-types) of accepted media. To send more than one image in the message, provide multiple `media_url` parameters in the POST request. You can include up to ten `media_url` parameters per message. [International](https://support.twilio.com/hc/en-us/articles/223179808-Sending-and-receiving-MMS-messages) and [carrier](https://support.twilio.com/hc/en-us/articles/223133707-Is-MMS-supported-for-all-carriers-in-US-and-Canada-) limits apply. + :param content_sid: For [Content Editor/API](https://www.twilio.com/docs/content) only: The SID of the Content Template to be used with the Message, e.g., `HXXXXXXXXXXXXXXXXXXXXXXXXXXXXX`. If this parameter is not provided, a Content Template is not used. Find the SID in the Console on the Content Editor page. For Content API users, the SID is found in Twilio's response when [creating the Template](https://www.twilio.com/docs/content/content-api-resources#create-templates) or by [fetching your Templates](https://www.twilio.com/docs/content/content-api-resources#fetch-all-content-resources). :returns: The created MessageInstance """ + data = values.of( { "To": to, "StatusCallback": status_callback, "ApplicationSid": application_sid, "MaxPrice": max_price, - "ProvideFeedback": provide_feedback, + "ProvideFeedback": serialize.boolean_to_string(provide_feedback), "Attempt": attempt, "ValidityPeriod": validity_period, - "ForceDelivery": force_delivery, + "ForceDelivery": serialize.boolean_to_string(force_delivery), "ContentRetention": content_retention, "AddressRetention": address_retention, - "SmartEncoded": smart_encoded, + "SmartEncoded": serialize.boolean_to_string(smart_encoded), "PersistentAction": serialize.map(persistent_action, lambda e: e), - "ShortenUrls": shorten_urls, + "TrafficType": traffic_type, + "ShortenUrls": serialize.boolean_to_string(shorten_urls), "ScheduleType": schedule_type, "SendAt": serialize.iso8601_datetime(send_at), - "SendAsMms": send_as_mms, - "ContentSid": content_sid, + "SendAsMms": serialize.boolean_to_string(send_as_mms), "ContentVariables": content_variables, + "RiskCheck": risk_check, "From": from_, "MessagingServiceSid": messaging_service_sid, "Body": body, "MediaUrl": serialize.map(media_url, lambda e: e), + "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( @@ -576,76 +612,86 @@ 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, send_as_mms: Union[bool, object] = values.unset, - content_sid: Union[str, object] = values.unset, content_variables: Union[str, object] = values.unset, + risk_check: Union["MessageInstance.RiskCheck", object] = values.unset, from_: Union[str, object] = values.unset, messaging_service_sid: Union[str, object] = values.unset, body: Union[str, object] = values.unset, media_url: Union[List[str], object] = values.unset, + content_sid: Union[str, object] = values.unset, ) -> MessageInstance: """ Asynchronously create the MessageInstance - :param 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. - :param 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/sms/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/sms/services/api). URLs must contain a valid hostname and underscores are not allowed. - :param 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](https://www.twilio.com/docs/usage/api/applications)'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. - :param 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. - :param provide_feedback: Whether to confirm delivery of the message. Set this value to `true` if you are sending messages that have a trackable user action and you intend to confirm delivery of the message using the [Message Feedback API](https://www.twilio.com/docs/sms/api/message-feedback-resource). This parameter is `false` by default. - :param attempt: Total number of attempts made ( including this ) to send out the message regardless of the provider used - :param 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. + :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: [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 `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 Channels Messages. - :param 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`. + :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. - :param send_as_mms: If set to True, Twilio will deliver the message as a single MMS message, regardless of the presence of media. - :param content_sid: The SID of the Content object returned at Content API content create time (https://www.twilio.com/docs/content-api/create-and-send-your-first-content-api-template#create-a-template). If this parameter is not specified, then the Content API will not be utilized. - :param content_variables: Key-value pairs of variable names to substitution values, used alongside a content_sid. If not specified, Content API will default to the default variables defined at create time. - :param 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. - :param 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. - :param body: The text of the message you want to send. Can be up to 1,600 characters in length. - :param 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. + :param send_as_mms: If set to `true`, Twilio delivers the message as a single MMS message, regardless of the presence of media. + :param content_variables: For [Content Editor/API](https://www.twilio.com/docs/content) only: Key-value pairs of [Template variables](https://www.twilio.com/docs/content/using-variables-with-content-api) and their substitution values. `content_sid` parameter must also be provided. If values are not defined in the `content_variables` parameter, the [Template's default placeholder values](https://www.twilio.com/docs/content/content-api-resources#create-templates) are used. + :param risk_check: + :param from_: The sender's Twilio phone number (in [E.164](https://en.wikipedia.org/wiki/E.164) format), [alphanumeric sender ID](https://www.twilio.com/docs/sms/quickstart), [Wireless SIM](https://www.twilio.com/docs/iot/wireless/programmable-wireless-send-machine-machine-sms-commands), [short code](https://www.twilio.com/en-us/messaging/channels/sms/short-codes), or [channel address](https://www.twilio.com/docs/messaging/channels) (e.g., `whatsapp:+15554449999`). The value of the `from` parameter must be a sender that is hosted within Twilio and belongs to the Account creating the Message. If you are using `messaging_service_sid`, this parameter can be empty (Twilio assigns a `from` value from the Messaging Service's Sender Pool) or you can provide a specific sender from your Sender Pool. + :param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/services) you want to associate with the Message. When this parameter is provided and the `from` parameter is omitted, Twilio selects the optimal sender from the Messaging Service's Sender Pool. You may also provide a `from` parameter if you want to use a specific Sender from the Sender Pool. + :param body: The text content of the outgoing message. Can be up to 1,600 characters in length. SMS only: If the `body` contains more than 160 [GSM-7](https://www.twilio.com/docs/glossary/what-is-gsm-7-character-encoding) characters (or 70 [UCS-2](https://www.twilio.com/docs/glossary/what-is-ucs-2-character-encoding) characters), the message is segmented and charged accordingly. For long `body` text, consider using the [send_as_mms parameter](https://www.twilio.com/blog/mms-for-long-text-messages). + :param media_url: The URL of media to include in the Message content. `jpeg`, `jpg`, `gif`, and `png` file types are fully supported by Twilio and content is formatted for delivery on destination devices. The media size limit is 5 MB for supported file types (`jpeg`, `jpg`, `png`, `gif`) and 500 KB for [other types](https://www.twilio.com/docs/messaging/guides/accepted-mime-types) of accepted media. To send more than one image in the message, provide multiple `media_url` parameters in the POST request. You can include up to ten `media_url` parameters per message. [International](https://support.twilio.com/hc/en-us/articles/223179808-Sending-and-receiving-MMS-messages) and [carrier](https://support.twilio.com/hc/en-us/articles/223133707-Is-MMS-supported-for-all-carriers-in-US-and-Canada-) limits apply. + :param content_sid: For [Content Editor/API](https://www.twilio.com/docs/content) only: The SID of the Content Template to be used with the Message, e.g., `HXXXXXXXXXXXXXXXXXXXXXXXXXXXXX`. If this parameter is not provided, a Content Template is not used. Find the SID in the Console on the Content Editor page. For Content API users, the SID is found in Twilio's response when [creating the Template](https://www.twilio.com/docs/content/content-api-resources#create-templates) or by [fetching your Templates](https://www.twilio.com/docs/content/content-api-resources#fetch-all-content-resources). :returns: The created MessageInstance """ + data = values.of( { "To": to, "StatusCallback": status_callback, "ApplicationSid": application_sid, "MaxPrice": max_price, - "ProvideFeedback": provide_feedback, + "ProvideFeedback": serialize.boolean_to_string(provide_feedback), "Attempt": attempt, "ValidityPeriod": validity_period, - "ForceDelivery": force_delivery, + "ForceDelivery": serialize.boolean_to_string(force_delivery), "ContentRetention": content_retention, "AddressRetention": address_retention, - "SmartEncoded": smart_encoded, + "SmartEncoded": serialize.boolean_to_string(smart_encoded), "PersistentAction": serialize.map(persistent_action, lambda e: e), - "ShortenUrls": shorten_urls, + "TrafficType": traffic_type, + "ShortenUrls": serialize.boolean_to_string(shorten_urls), "ScheduleType": schedule_type, "SendAt": serialize.iso8601_datetime(send_at), - "SendAsMms": send_as_mms, - "ContentSid": content_sid, + "SendAsMms": serialize.boolean_to_string(send_as_mms), "ContentVariables": content_variables, + "RiskCheck": risk_check, "From": from_, "MessagingServiceSid": messaging_service_sid, "Body": body, "MediaUrl": serialize.map(media_url, lambda e: e), + "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( @@ -668,11 +714,11 @@ def stream( is reached. The results are returned as a generator, so this operation is memory efficient. - :param str to: Read messages sent to only this phone number. - :param str from_: Read messages sent from only this phone number or alphanumeric sender ID. - :param datetime date_sent: The date of the messages to show. Specify a date as `YYYY-MM-DD` in GMT to read only messages sent on this date. For example: `2009-07-06`. You can also specify an inequality, such as `DateSent<=YYYY-MM-DD`, to read messages sent on or before midnight on a date, and `DateSent>=YYYY-MM-DD` to read messages sent on or after midnight on a date. - :param datetime date_sent_before: The date of the messages to show. Specify a date as `YYYY-MM-DD` in GMT to read only messages sent on this date. For example: `2009-07-06`. You can also specify an inequality, such as `DateSent<=YYYY-MM-DD`, to read messages sent on or before midnight on a date, and `DateSent>=YYYY-MM-DD` to read messages sent on or after midnight on a date. - :param datetime date_sent_after: The date of the messages to show. Specify a date as `YYYY-MM-DD` in GMT to read only messages sent on this date. For example: `2009-07-06`. You can also specify an inequality, such as `DateSent<=YYYY-MM-DD`, to read messages sent on or before midnight on a date, and `DateSent>=YYYY-MM-DD` to read messages sent on or after midnight on a date. + :param str to: Filter by recipient. For example: Set this `to` parameter to `+15558881111` to retrieve a list of Message resources with `to` properties of `+15558881111` + :param str from_: Filter by sender. For example: Set this `from` parameter to `+15552229999` to retrieve a list of Message resources with `from` properties of `+15552229999` + :param datetime date_sent: Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific date). + :param datetime date_sent_before: Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific date). + :param datetime date_sent_after: Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific 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 @@ -710,11 +756,11 @@ async def stream_async( is reached. The results are returned as a generator, so this operation is memory efficient. - :param str to: Read messages sent to only this phone number. - :param str from_: Read messages sent from only this phone number or alphanumeric sender ID. - :param datetime date_sent: The date of the messages to show. Specify a date as `YYYY-MM-DD` in GMT to read only messages sent on this date. For example: `2009-07-06`. You can also specify an inequality, such as `DateSent<=YYYY-MM-DD`, to read messages sent on or before midnight on a date, and `DateSent>=YYYY-MM-DD` to read messages sent on or after midnight on a date. - :param datetime date_sent_before: The date of the messages to show. Specify a date as `YYYY-MM-DD` in GMT to read only messages sent on this date. For example: `2009-07-06`. You can also specify an inequality, such as `DateSent<=YYYY-MM-DD`, to read messages sent on or before midnight on a date, and `DateSent>=YYYY-MM-DD` to read messages sent on or after midnight on a date. - :param datetime date_sent_after: The date of the messages to show. Specify a date as `YYYY-MM-DD` in GMT to read only messages sent on this date. For example: `2009-07-06`. You can also specify an inequality, such as `DateSent<=YYYY-MM-DD`, to read messages sent on or before midnight on a date, and `DateSent>=YYYY-MM-DD` to read messages sent on or after midnight on a date. + :param str to: Filter by recipient. For example: Set this `to` parameter to `+15558881111` to retrieve a list of Message resources with `to` properties of `+15558881111` + :param str from_: Filter by sender. For example: Set this `from` parameter to `+15552229999` to retrieve a list of Message resources with `from` properties of `+15552229999` + :param datetime date_sent: Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific date). + :param datetime date_sent_before: Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific date). + :param datetime date_sent_after: Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific 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 @@ -751,11 +797,11 @@ def list( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param str to: Read messages sent to only this phone number. - :param str from_: Read messages sent from only this phone number or alphanumeric sender ID. - :param datetime date_sent: The date of the messages to show. Specify a date as `YYYY-MM-DD` in GMT to read only messages sent on this date. For example: `2009-07-06`. You can also specify an inequality, such as `DateSent<=YYYY-MM-DD`, to read messages sent on or before midnight on a date, and `DateSent>=YYYY-MM-DD` to read messages sent on or after midnight on a date. - :param datetime date_sent_before: The date of the messages to show. Specify a date as `YYYY-MM-DD` in GMT to read only messages sent on this date. For example: `2009-07-06`. You can also specify an inequality, such as `DateSent<=YYYY-MM-DD`, to read messages sent on or before midnight on a date, and `DateSent>=YYYY-MM-DD` to read messages sent on or after midnight on a date. - :param datetime date_sent_after: The date of the messages to show. Specify a date as `YYYY-MM-DD` in GMT to read only messages sent on this date. For example: `2009-07-06`. You can also specify an inequality, such as `DateSent<=YYYY-MM-DD`, to read messages sent on or before midnight on a date, and `DateSent>=YYYY-MM-DD` to read messages sent on or after midnight on a date. + :param str to: Filter by recipient. For example: Set this `to` parameter to `+15558881111` to retrieve a list of Message resources with `to` properties of `+15558881111` + :param str from_: Filter by sender. For example: Set this `from` parameter to `+15552229999` to retrieve a list of Message resources with `from` properties of `+15552229999` + :param datetime date_sent: Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific date). + :param datetime date_sent_before: Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific date). + :param datetime date_sent_after: Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific 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 @@ -792,11 +838,11 @@ async def list_async( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param str to: Read messages sent to only this phone number. - :param str from_: Read messages sent from only this phone number or alphanumeric sender ID. - :param datetime date_sent: The date of the messages to show. Specify a date as `YYYY-MM-DD` in GMT to read only messages sent on this date. For example: `2009-07-06`. You can also specify an inequality, such as `DateSent<=YYYY-MM-DD`, to read messages sent on or before midnight on a date, and `DateSent>=YYYY-MM-DD` to read messages sent on or after midnight on a date. - :param datetime date_sent_before: The date of the messages to show. Specify a date as `YYYY-MM-DD` in GMT to read only messages sent on this date. For example: `2009-07-06`. You can also specify an inequality, such as `DateSent<=YYYY-MM-DD`, to read messages sent on or before midnight on a date, and `DateSent>=YYYY-MM-DD` to read messages sent on or after midnight on a date. - :param datetime date_sent_after: The date of the messages to show. Specify a date as `YYYY-MM-DD` in GMT to read only messages sent on this date. For example: `2009-07-06`. You can also specify an inequality, such as `DateSent<=YYYY-MM-DD`, to read messages sent on or before midnight on a date, and `DateSent>=YYYY-MM-DD` to read messages sent on or after midnight on a date. + :param str to: Filter by recipient. For example: Set this `to` parameter to `+15558881111` to retrieve a list of Message resources with `to` properties of `+15558881111` + :param str from_: Filter by sender. For example: Set this `from` parameter to `+15552229999` to retrieve a list of Message resources with `from` properties of `+15552229999` + :param datetime date_sent: Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific date). + :param datetime date_sent_before: Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific date). + :param datetime date_sent_after: Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific 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 @@ -834,11 +880,11 @@ def page( Retrieve a single page of MessageInstance records from the API. Request is executed immediately - :param to: Read messages sent to only this phone number. - :param from_: Read messages sent from only this phone number or alphanumeric sender ID. - :param date_sent: The date of the messages to show. Specify a date as `YYYY-MM-DD` in GMT to read only messages sent on this date. For example: `2009-07-06`. You can also specify an inequality, such as `DateSent<=YYYY-MM-DD`, to read messages sent on or before midnight on a date, and `DateSent>=YYYY-MM-DD` to read messages sent on or after midnight on a date. - :param date_sent_before: The date of the messages to show. Specify a date as `YYYY-MM-DD` in GMT to read only messages sent on this date. For example: `2009-07-06`. You can also specify an inequality, such as `DateSent<=YYYY-MM-DD`, to read messages sent on or before midnight on a date, and `DateSent>=YYYY-MM-DD` to read messages sent on or after midnight on a date. - :param date_sent_after: The date of the messages to show. Specify a date as `YYYY-MM-DD` in GMT to read only messages sent on this date. For example: `2009-07-06`. You can also specify an inequality, such as `DateSent<=YYYY-MM-DD`, to read messages sent on or before midnight on a date, and `DateSent>=YYYY-MM-DD` to read messages sent on or after midnight on a date. + :param to: Filter by recipient. For example: Set this `to` parameter to `+15558881111` to retrieve a list of Message resources with `to` properties of `+15558881111` + :param from_: Filter by sender. For example: Set this `from` parameter to `+15552229999` to retrieve a list of Message resources with `from` properties of `+15552229999` + :param date_sent: Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific date). + :param date_sent_before: Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific date). + :param date_sent_after: Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific 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 @@ -858,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( @@ -876,11 +928,11 @@ async def page_async( Asynchronously retrieve a single page of MessageInstance records from the API. Request is executed immediately - :param to: Read messages sent to only this phone number. - :param from_: Read messages sent from only this phone number or alphanumeric sender ID. - :param date_sent: The date of the messages to show. Specify a date as `YYYY-MM-DD` in GMT to read only messages sent on this date. For example: `2009-07-06`. You can also specify an inequality, such as `DateSent<=YYYY-MM-DD`, to read messages sent on or before midnight on a date, and `DateSent>=YYYY-MM-DD` to read messages sent on or after midnight on a date. - :param date_sent_before: The date of the messages to show. Specify a date as `YYYY-MM-DD` in GMT to read only messages sent on this date. For example: `2009-07-06`. You can also specify an inequality, such as `DateSent<=YYYY-MM-DD`, to read messages sent on or before midnight on a date, and `DateSent>=YYYY-MM-DD` to read messages sent on or after midnight on a date. - :param date_sent_after: The date of the messages to show. Specify a date as `YYYY-MM-DD` in GMT to read only messages sent on this date. For example: `2009-07-06`. You can also specify an inequality, such as `DateSent<=YYYY-MM-DD`, to read messages sent on or before midnight on a date, and `DateSent>=YYYY-MM-DD` to read messages sent on or after midnight on a date. + :param to: Filter by recipient. For example: Set this `to` parameter to `+15558881111` to retrieve a list of Message resources with `to` properties of `+15558881111` + :param from_: Filter by sender. For example: Set this `from` parameter to `+15552229999` to retrieve a list of Message resources with `from` properties of `+15552229999` + :param date_sent: Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific date). + :param date_sent_before: Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific date). + :param date_sent_after: Filter by Message `sent_date`. Accepts GMT dates in the following formats: `YYYY-MM-DD` (to find Messages with a specific `sent_date`), `<=YYYY-MM-DD` (to find Messages with `sent_date`s on and before a specific date), and `>=YYYY-MM-DD` (to find Messages with `sent_dates` on and after a specific 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 @@ -900,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) @@ -933,7 +989,7 @@ def get(self, sid: str) -> MessageContext: """ Constructs a MessageContext - :param sid: The Twilio-provided string that uniquely identifies the Message resource to update. + :param sid: The SID of the Message resource to be updated """ return MessageContext( self._version, account_sid=self._solution["account_sid"], sid=sid @@ -943,7 +999,7 @@ def __call__(self, sid: str) -> MessageContext: """ Constructs a MessageContext - :param sid: The Twilio-provided string that uniquely identifies the Message resource to update. + :param sid: The SID of the Message resource to be updated """ return MessageContext( self._version, account_sid=self._solution["account_sid"], sid=sid diff --git a/twilio/rest/api/v2010/account/message/feedback.py b/twilio/rest/api/v2010/account/message/feedback.py index ea7b38ad92..cda2de2ff6 100644 --- a/twilio/rest/api/v2010/account/message/feedback.py +++ b/twilio/rest/api/v2010/account/message/feedback.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import datetime from typing import Any, Dict, Optional, Union from twilio.base import deserialize, values @@ -23,16 +22,17 @@ class FeedbackInstance(InstanceResource): + class Outcome(object): CONFIRMED = "confirmed" UNCONFIRMED = "unconfirmed" """ - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the MessageFeedback resource. - :ivar message_sid: The SID of the Message resource for which the feedback was provided. + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) associated with this MessageFeedback resource. + :ivar message_sid: The SID of the Message resource associated with this MessageFeedback resource. :ivar outcome: - :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 date_created: The date and time in GMT when this MessageFeedback 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 this MessageFeedback 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`. """ @@ -72,13 +72,14 @@ def __repr__(self) -> str: class FeedbackList(ListResource): + def __init__(self, version: Version, account_sid: str, message_sid: str): """ Initialize the FeedbackList :param version: Version that contains the resource - :param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that will create the resource. - :param message_sid: The SID of the Message resource for which the feedback was provided. + :param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) associated with the Message resource for which to create MessageFeedback. + :param message_sid: The SID of the Message resource for which to create MessageFeedback. """ super().__init__(version) @@ -104,16 +105,20 @@ def create( :returns: The created FeedbackInstance """ + data = values.of( { "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( @@ -133,16 +138,20 @@ async def create_async( :returns: The created FeedbackInstance """ + data = values.of( { "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 33c18d8882..b5d2926d12 100644 --- a/twilio/rest/api/v2010/account/message/media.py +++ b/twilio/rest/api/v2010/account/message/media.py @@ -12,7 +12,6 @@ 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 @@ -24,15 +23,14 @@ class MediaInstance(InstanceResource): - """ - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created this Media resource. - :ivar content_type: The default [mime-type](https://en.wikipedia.org/wiki/Internet_media_type) of the media, for example `image/jpeg`, `image/png`, or `image/gif` - :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 parent_sid: The SID of the resource that created the media. - :ivar sid: The unique string that that we created to identify this Media resource. - :ivar uri: The URI of this 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 this Media resource. + :ivar content_type: The default [MIME type](https://en.wikipedia.org/wiki/Internet_media_type) of the media, for example `image/jpeg`, `image/png`, or `image/gif`. + :ivar date_created: The date and time in GMT when this Media 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 this Media resource was last updated, specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. + :ivar parent_sid: The SID of the Message resource that is associated with this Media resource. + :ivar sid: The unique string that identifies this Media resource. + :ivar uri: The URI of this Media resource, relative to `https://api.twilio.com`. """ def __init__( @@ -128,14 +126,15 @@ def __repr__(self) -> str: class MediaContext(InstanceContext): + def __init__(self, version: Version, account_sid: str, message_sid: str, sid: str): """ Initialize the MediaContext :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 Media resource(s) to fetch. - :param message_sid: The SID of the Message resource that this Media resource belongs to. - :param sid: The Twilio-provided string that uniquely identifies the Media resource to fetch + :param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) associated with the Media resource. + :param message_sid: The SID of the Message resource that is associated with the Media resource. + :param sid: The Twilio-provided string that uniquely identifies the Media resource to fetch. """ super().__init__(version) @@ -158,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: """ @@ -170,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: @@ -183,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, @@ -204,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( @@ -228,6 +233,7 @@ def __repr__(self) -> str: class MediaPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> MediaInstance: """ Build an instance of MediaInstance @@ -251,13 +257,14 @@ def __repr__(self) -> str: class MediaList(ListResource): + def __init__(self, version: Version, account_sid: str, message_sid: str): """ Initialize the MediaList :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 Media resource(s) to read. - :param message_sid: The SID of the Message resource that this Media resource belongs to. + :param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that is associated with the Media resources. + :param message_sid: The SID of the Message resource that is associated with the Media resources. """ super().__init__(version) @@ -285,9 +292,9 @@ def stream( is reached. The results are returned as a generator, so this operation is memory efficient. - :param datetime date_created: Only include media that was created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read media that was created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read media that was created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read media that was created on or after midnight of this date. - :param datetime date_created_before: Only include media that was created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read media that was created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read media that was created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read media that was created on or after midnight of this date. - :param datetime date_created_after: Only include media that was created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read media that was created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read media that was created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read media that was created on or after midnight of this date. + :param datetime date_created: Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created on or after midnight of this date. + :param datetime date_created_before: Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created on or after midnight of this date. + :param datetime date_created_after: Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created 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 @@ -321,9 +328,9 @@ async def stream_async( is reached. The results are returned as a generator, so this operation is memory efficient. - :param datetime date_created: Only include media that was created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read media that was created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read media that was created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read media that was created on or after midnight of this date. - :param datetime date_created_before: Only include media that was created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read media that was created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read media that was created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read media that was created on or after midnight of this date. - :param datetime date_created_after: Only include media that was created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read media that was created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read media that was created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read media that was created on or after midnight of this date. + :param datetime date_created: Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created on or after midnight of this date. + :param datetime date_created_before: Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created on or after midnight of this date. + :param datetime date_created_after: Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created 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 @@ -356,9 +363,9 @@ def list( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param datetime date_created: Only include media that was created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read media that was created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read media that was created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read media that was created on or after midnight of this date. - :param datetime date_created_before: Only include media that was created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read media that was created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read media that was created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read media that was created on or after midnight of this date. - :param datetime date_created_after: Only include media that was created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read media that was created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read media that was created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read media that was created on or after midnight of this date. + :param datetime date_created: Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created on or after midnight of this date. + :param datetime date_created_before: Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created on or after midnight of this date. + :param datetime date_created_after: Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created 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 @@ -391,9 +398,9 @@ async def list_async( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param datetime date_created: Only include media that was created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read media that was created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read media that was created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read media that was created on or after midnight of this date. - :param datetime date_created_before: Only include media that was created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read media that was created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read media that was created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read media that was created on or after midnight of this date. - :param datetime date_created_after: Only include media that was created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read media that was created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read media that was created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read media that was created on or after midnight of this date. + :param datetime date_created: Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created on or after midnight of this date. + :param datetime date_created_before: Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created on or after midnight of this date. + :param datetime date_created_after: Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created 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 @@ -427,9 +434,9 @@ def page( Retrieve a single page of MediaInstance records from the API. Request is executed immediately - :param date_created: Only include media that was created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read media that was created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read media that was created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read media that was created on or after midnight of this date. - :param date_created_before: Only include media that was created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read media that was created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read media that was created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read media that was created on or after midnight of this date. - :param date_created_after: Only include media that was created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read media that was created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read media that was created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read media that was created on or after midnight of this date. + :param date_created: Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created on or after midnight of this date. + :param date_created_before: Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created on or after midnight of this date. + :param date_created_after: Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created 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 @@ -447,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( @@ -463,9 +476,9 @@ async def page_async( Asynchronously retrieve a single page of MediaInstance records from the API. Request is executed immediately - :param date_created: Only include media that was created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read media that was created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read media that was created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read media that was created on or after midnight of this date. - :param date_created_before: Only include media that was created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read media that was created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read media that was created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read media that was created on or after midnight of this date. - :param date_created_after: Only include media that was created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read media that was created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read media that was created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read media that was created on or after midnight of this date. + :param date_created: Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created on or after midnight of this date. + :param date_created_before: Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created on or after midnight of this date. + :param date_created_after: Only include Media resources that were created on this date. Specify a date as `YYYY-MM-DD` in GMT, for example: `2009-07-06`, to read Media that were created on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read Media that were created on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read Media that were created 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 @@ -483,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) @@ -516,7 +533,7 @@ def get(self, sid: str) -> MediaContext: """ Constructs a MediaContext - :param sid: The Twilio-provided string that uniquely identifies the Media resource to fetch + :param sid: The Twilio-provided string that uniquely identifies the Media resource to fetch. """ return MediaContext( self._version, @@ -529,7 +546,7 @@ def __call__(self, sid: str) -> MediaContext: """ Constructs a MediaContext - :param sid: The Twilio-provided string that uniquely identifies the Media resource to fetch + :param sid: The Twilio-provided string that uniquely identifies the Media resource to fetch. """ return MediaContext( self._version, diff --git a/twilio/rest/api/v2010/account/new_key.py b/twilio/rest/api/v2010/account/new_key.py index e7af236ebe..ba811ec14f 100644 --- a/twilio/rest/api/v2010/account/new_key.py +++ b/twilio/rest/api/v2010/account/new_key.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import datetime from typing import Any, Dict, Optional, Union from twilio.base import deserialize, values @@ -23,7 +22,6 @@ class NewKeyInstance(InstanceResource): - """ :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. @@ -60,6 +58,7 @@ def __repr__(self) -> str: class NewKeyList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the NewKeyList @@ -86,16 +85,20 @@ def create( :returns: The created NewKeyInstance """ + data = values.of( { "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( @@ -112,16 +115,20 @@ async def create_async( :returns: The created NewKeyInstance """ + data = values.of( { "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 d24e833b86..95341d31cb 100644 --- a/twilio/rest/api/v2010/account/new_signing_key.py +++ b/twilio/rest/api/v2010/account/new_signing_key.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import datetime from typing import Any, Dict, Optional, Union from twilio.base import deserialize, values @@ -23,7 +22,6 @@ class NewSigningKeyInstance(InstanceResource): - """ :ivar sid: The unique string that that we created to identify the NewSigningKey resource. :ivar friendly_name: The string that you assigned to describe the resource. @@ -60,6 +58,7 @@ def __repr__(self) -> str: class NewSigningKeyList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the NewSigningKeyList @@ -86,16 +85,20 @@ def create( :returns: The created NewSigningKeyInstance """ + data = values.of( { "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( @@ -112,16 +115,20 @@ async def create_async( :returns: The created NewSigningKeyInstance """ + data = values.of( { "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 69e647cd4a..cd35efeabf 100644 --- a/twilio/rest/api/v2010/account/notification.py +++ b/twilio/rest/api/v2010/account/notification.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import date, datetime from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import deserialize, serialize, values @@ -24,7 +23,6 @@ class NotificationInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Notification resource. :ivar api_version: The API version used to generate the notification. Can be empty for events that don't have a specific API version, such as incoming phone calls. @@ -129,6 +127,7 @@ def __repr__(self) -> str: class NotificationContext(InstanceContext): + def __init__(self, version: Version, account_sid: str, sid: str): """ Initialize the NotificationContext @@ -156,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, @@ -176,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( @@ -199,6 +202,7 @@ def __repr__(self) -> str: class NotificationPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> NotificationInstance: """ Build an instance of NotificationInstance @@ -219,6 +223,7 @@ def __repr__(self) -> str: class NotificationList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the NotificationList @@ -428,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( @@ -467,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 90d5e472e4..eeb9954c75 100644 --- a/twilio/rest/api/v2010/account/outgoing_caller_id.py +++ b/twilio/rest/api/v2010/account/outgoing_caller_id.py @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class OutgoingCallerIdInstance(InstanceResource): - """ :ivar sid: The unique string that that we created to identify the OutgoingCallerId 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. @@ -153,6 +151,7 @@ def __repr__(self) -> str: class OutgoingCallerIdContext(InstanceContext): + def __init__(self, version: Version, account_sid: str, sid: str): """ Initialize the OutgoingCallerIdContext @@ -179,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: """ @@ -191,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: @@ -204,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, @@ -224,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( @@ -246,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( @@ -275,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( @@ -305,6 +318,7 @@ def __repr__(self) -> str: class OutgoingCallerIdPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> OutgoingCallerIdInstance: """ Build an instance of OutgoingCallerIdInstance @@ -325,6 +339,7 @@ def __repr__(self) -> str: class OutgoingCallerIdList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the OutgoingCallerIdList @@ -504,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( @@ -537,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 73589708fb..e76fda1259 100644 --- a/twilio/rest/api/v2010/account/queue/__init__.py +++ b/twilio/rest/api/v2010/account/queue/__init__.py @@ -12,7 +12,6 @@ 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 @@ -25,7 +24,6 @@ class QueueInstance(InstanceResource): - """ :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 current_size: The number of calls currently in the queue. @@ -177,6 +175,7 @@ def __repr__(self) -> str: class QueueContext(InstanceContext): + def __init__(self, version: Version, account_sid: str, sid: str): """ Initialize the QueueContext @@ -203,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: """ @@ -215,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: @@ -228,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, @@ -248,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( @@ -273,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( @@ -306,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( @@ -350,6 +363,7 @@ def __repr__(self) -> str: class QueuePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> QueueInstance: """ Build an instance of QueueInstance @@ -370,6 +384,7 @@ def __repr__(self) -> str: class QueueList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the QueueList @@ -397,17 +412,21 @@ def create( :returns: The created QueueInstance """ + data = values.of( { "FriendlyName": friendly_name, "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( @@ -425,17 +444,21 @@ async def create_async( :returns: The created QueueInstance """ + data = values.of( { "FriendlyName": friendly_name, "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( @@ -569,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( @@ -596,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 842a178953..30ff4abbc7 100644 --- a/twilio/rest/api/v2010/account/queue/member.py +++ b/twilio/rest/api/v2010/account/queue/member.py @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class MemberInstance(InstanceResource): - """ :ivar call_sid: The SID of the [Call](https://www.twilio.com/docs/voice/api/call-resource) the Member resource is associated with. :ivar date_enqueued: The date that the member was enqueued, given in RFC 2822 format. @@ -138,6 +136,7 @@ def __repr__(self) -> str: class MemberContext(InstanceContext): + def __init__( self, version: Version, account_sid: str, queue_sid: str, call_sid: str ): @@ -171,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, @@ -192,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( @@ -216,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( @@ -248,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( @@ -280,6 +291,7 @@ def __repr__(self) -> str: class MemberPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> MemberInstance: """ Build an instance of MemberInstance @@ -303,6 +315,7 @@ def __repr__(self) -> str: class MemberList(ListResource): + def __init__(self, version: Version, account_sid: str, queue_sid: str): """ Initialize the MemberList @@ -450,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( @@ -477,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 10ee3e1b90..807fb3ca6e 100644 --- a/twilio/rest/api/v2010/account/recording/__init__.py +++ b/twilio/rest/api/v2010/account/recording/__init__.py @@ -12,7 +12,6 @@ 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 @@ -26,6 +25,7 @@ class RecordingInstance(InstanceResource): + class Source(object): DIALVERB = "DialVerb" CONFERENCE = "Conference" @@ -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`. Default: `1`. :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`. @@ -198,6 +198,7 @@ def __repr__(self) -> str: class RecordingContext(InstanceContext): + def __init__(self, version: Version, account_sid: str, sid: str): """ Initialize the RecordingContext @@ -227,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: """ @@ -239,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( @@ -257,11 +260,17 @@ def fetch( data = values.of( { - "IncludeSoftDeleted": include_soft_deleted, + "IncludeSoftDeleted": serialize.boolean_to_string(include_soft_deleted), } ) - 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, @@ -283,12 +292,16 @@ async def fetch_async( data = values.of( { - "IncludeSoftDeleted": include_soft_deleted, + "IncludeSoftDeleted": serialize.boolean_to_string(include_soft_deleted), } ) + 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( @@ -335,6 +348,7 @@ def __repr__(self) -> str: class RecordingPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> RecordingInstance: """ Build an instance of RecordingInstance @@ -355,6 +369,7 @@ def __repr__(self) -> str: class RecordingList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the RecordingList @@ -585,14 +600,20 @@ def page( "DateCreated>": serialize.iso8601_datetime(date_created_after), "CallSid": call_sid, "ConferenceSid": conference_sid, - "IncludeSoftDeleted": include_soft_deleted, + "IncludeSoftDeleted": serialize.boolean_to_string(include_soft_deleted), "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 RecordingPage(self._version, response, self._solution) async def page_async( @@ -630,15 +651,19 @@ async def page_async( "DateCreated>": serialize.iso8601_datetime(date_created_after), "CallSid": call_sid, "ConferenceSid": conference_sid, - "IncludeSoftDeleted": include_soft_deleted, + "IncludeSoftDeleted": serialize.boolean_to_string(include_soft_deleted), "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 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 79d3a71365..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 @@ -12,7 +12,6 @@ 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 @@ -25,6 +24,7 @@ class AddOnResultInstance(InstanceResource): + class Status(object): CANCELED = "canceled" COMPLETED = "completed" @@ -157,6 +157,7 @@ def __repr__(self) -> str: class AddOnResultContext(InstanceContext): + def __init__( self, version: Version, account_sid: str, reference_sid: str, sid: str ): @@ -189,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: """ @@ -201,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: @@ -214,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, @@ -235,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( @@ -273,6 +280,7 @@ def __repr__(self) -> str: class AddOnResultPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> AddOnResultInstance: """ Build an instance of AddOnResultInstance @@ -296,6 +304,7 @@ def __repr__(self) -> str: class AddOnResultList(ListResource): + def __init__(self, version: Version, account_sid: str, reference_sid: str): """ Initialize the AddOnResultList @@ -443,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( @@ -470,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 08e8822202..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 @@ -12,7 +12,6 @@ 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 @@ -21,10 +20,10 @@ 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): - """ :ivar sid: The unique string that that we created to identify the Recording AddOnResult Payload resource. :ivar add_on_result_sid: The SID of the AddOnResult to which the payload belongs. @@ -132,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 @@ -143,6 +149,7 @@ def __repr__(self) -> str: class PayloadContext(InstanceContext): + def __init__( self, version: Version, @@ -173,6 +180,8 @@ def __init__( **self._solution ) + self._data: Optional[DataList] = None + def delete(self) -> bool: """ Deletes the PayloadInstance @@ -180,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: """ @@ -192,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: @@ -205,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, @@ -227,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( @@ -241,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 @@ -252,6 +282,7 @@ def __repr__(self) -> str: class PayloadPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> PayloadInstance: """ Build an instance of PayloadInstance @@ -276,6 +307,7 @@ def __repr__(self) -> str: class PayloadList(ListResource): + def __init__( self, version: Version, @@ -431,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( @@ -458,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 6aa104d427..472f5b2bff 100644 --- a/twilio/rest/api/v2010/account/recording/transcription.py +++ b/twilio/rest/api/v2010/account/recording/transcription.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class TranscriptionInstance(InstanceResource): + class Status(object): IN_PROGRESS = "in-progress" COMPLETED = "completed" @@ -144,6 +144,7 @@ def __repr__(self) -> str: class TranscriptionContext(InstanceContext): + def __init__( self, version: Version, account_sid: str, recording_sid: str, sid: str ): @@ -174,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: """ @@ -186,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: @@ -199,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, @@ -220,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( @@ -244,6 +251,7 @@ def __repr__(self) -> str: class TranscriptionPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> TranscriptionInstance: """ Build an instance of TranscriptionInstance @@ -267,6 +275,7 @@ def __repr__(self) -> str: class TranscriptionList(ListResource): + def __init__(self, version: Version, account_sid: str, recording_sid: str): """ Initialize the TranscriptionList @@ -414,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( @@ -441,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 831cb770af..eae35c4aa5 100644 --- a/twilio/rest/api/v2010/account/short_code.py +++ b/twilio/rest/api/v2010/account/short_code.py @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class ShortCodeInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created this ShortCode resource. :ivar api_version: The API version used to start a new TwiML session when an SMS message is sent to this short code. @@ -177,6 +175,7 @@ def __repr__(self) -> str: class ShortCodeContext(InstanceContext): + def __init__(self, version: Version, account_sid: str, sid: str): """ Initialize the ShortCodeContext @@ -204,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, @@ -224,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( @@ -257,6 +260,7 @@ def update( :returns: The updated ShortCodeInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -267,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( @@ -302,6 +309,7 @@ async def update_async( :returns: The updated ShortCodeInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -312,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( @@ -337,6 +348,7 @@ def __repr__(self) -> str: class ShortCodePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ShortCodeInstance: """ Build an instance of ShortCodeInstance @@ -357,6 +369,7 @@ def __repr__(self) -> str: class ShortCodeList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the ShortCodeList @@ -536,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( @@ -569,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 e14f42c777..8e33f218f5 100644 --- a/twilio/rest/api/v2010/account/signing_key.py +++ b/twilio/rest/api/v2010/account/signing_key.py @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class SigningKeyInstance(InstanceResource): - """ :ivar sid: :ivar friendly_name: @@ -147,6 +145,7 @@ def __repr__(self) -> str: class SigningKeyContext(InstanceContext): + def __init__(self, version: Version, account_sid: str, sid: str): """ Initialize the SigningKeyContext @@ -173,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: """ @@ -185,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: @@ -198,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, @@ -218,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( @@ -240,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( @@ -269,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( @@ -299,6 +312,7 @@ def __repr__(self) -> str: class SigningKeyPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> SigningKeyInstance: """ Build an instance of SigningKeyInstance @@ -319,6 +333,7 @@ def __repr__(self) -> str: class SigningKeyList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the SigningKeyList @@ -462,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( @@ -489,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/__init__.py b/twilio/rest/api/v2010/account/sip/__init__.py index a0780cb1e4..12c695ff72 100644 --- a/twilio/rest/api/v2010/account/sip/__init__.py +++ b/twilio/rest/api/v2010/account/sip/__init__.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Optional @@ -27,6 +26,7 @@ class SipList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the SipList 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 08ac5bcfe6..d1be747b6d 100644 --- a/twilio/rest/api/v2010/account/sip/credential_list/__init__.py +++ b/twilio/rest/api/v2010/account/sip/credential_list/__init__.py @@ -12,7 +12,6 @@ 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 @@ -25,7 +24,6 @@ class CredentialListInstance(InstanceResource): - """ :ivar account_sid: The unique id of the [Account](https://www.twilio.com/docs/iam/api/account) that owns this resource. :ivar date_created: The date that this resource was created, given as GMT in [RFC 2822](https://www.php.net/manual/en/class.datetime.php#datetime.constants.rfc2822) format. @@ -159,6 +157,7 @@ def __repr__(self) -> str: class CredentialListContext(InstanceContext): + def __init__(self, version: Version, account_sid: str, sid: str): """ Initialize the CredentialListContext @@ -187,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: """ @@ -199,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: @@ -212,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, @@ -232,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( @@ -252,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( @@ -279,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( @@ -322,6 +335,7 @@ def __repr__(self) -> str: class CredentialListPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> CredentialListInstance: """ Build an instance of CredentialListInstance @@ -342,6 +356,7 @@ def __repr__(self) -> str: class CredentialListList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the CredentialListList @@ -368,16 +383,20 @@ def create(self, friendly_name: str) -> CredentialListInstance: :returns: The created CredentialListInstance """ + data = values.of( { "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( @@ -392,16 +411,20 @@ async def create_async(self, friendly_name: str) -> CredentialListInstance: :returns: The created CredentialListInstance """ + data = values.of( { "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( @@ -535,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( @@ -562,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 585950c25c..9c52a110e0 100644 --- a/twilio/rest/api/v2010/account/sip/credential_list/credential.py +++ b/twilio/rest/api/v2010/account/sip/credential_list/credential.py @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class CredentialInstance(InstanceResource): - """ :ivar sid: A 34 character string that uniquely identifies this resource. :ivar account_sid: The unique id of the Account that is responsible for this resource. @@ -156,6 +154,7 @@ def __repr__(self) -> str: class CredentialContext(InstanceContext): + def __init__( self, version: Version, account_sid: str, credential_list_sid: str, sid: str ): @@ -186,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: """ @@ -198,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: @@ -211,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, @@ -232,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( @@ -253,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( @@ -283,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( @@ -314,6 +327,7 @@ def __repr__(self) -> str: class CredentialPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> CredentialInstance: """ Build an instance of CredentialInstance @@ -337,6 +351,7 @@ def __repr__(self) -> str: class CredentialList(ListResource): + def __init__(self, version: Version, account_sid: str, credential_list_sid: str): """ Initialize the CredentialList @@ -366,17 +381,21 @@ def create(self, username: str, password: str) -> CredentialInstance: :returns: The created CredentialInstance """ + data = values.of( { "Username": username, "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( @@ -395,17 +414,21 @@ async def create_async(self, username: str, password: str) -> CredentialInstance :returns: The created CredentialInstance """ + data = values.of( { "Username": username, "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( @@ -542,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( @@ -569,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 29a2aaeb2a..0a45e68273 100644 --- a/twilio/rest/api/v2010/account/sip/domain/__init__.py +++ b/twilio/rest/api/v2010/account/sip/domain/__init__.py @@ -12,10 +12,9 @@ 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 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 @@ -31,7 +30,6 @@ class DomainInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the SipDomain resource. :ivar api_version: The API version used to process the call. @@ -291,6 +289,7 @@ def __repr__(self) -> str: class DomainContext(InstanceContext): + def __init__(self, version: Version, account_sid: str, sid: str): """ Initialize the DomainContext @@ -323,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: """ @@ -335,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: @@ -348,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, @@ -368,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( @@ -415,6 +420,7 @@ def update( :returns: The updated DomainInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -424,19 +430,24 @@ def update( "VoiceStatusCallbackMethod": voice_status_callback_method, "VoiceStatusCallbackUrl": voice_status_callback_url, "VoiceUrl": voice_url, - "SipRegistration": sip_registration, + "SipRegistration": serialize.boolean_to_string(sip_registration), "DomainName": domain_name, - "EmergencyCallingEnabled": emergency_calling_enabled, - "Secure": secure, + "EmergencyCallingEnabled": serialize.boolean_to_string( + emergency_calling_enabled + ), + "Secure": serialize.boolean_to_string(secure), "ByocTrunkSid": byoc_trunk_sid, "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( @@ -481,6 +492,7 @@ async def update_async( :returns: The updated DomainInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -490,19 +502,24 @@ async def update_async( "VoiceStatusCallbackMethod": voice_status_callback_method, "VoiceStatusCallbackUrl": voice_status_callback_url, "VoiceUrl": voice_url, - "SipRegistration": sip_registration, + "SipRegistration": serialize.boolean_to_string(sip_registration), "DomainName": domain_name, - "EmergencyCallingEnabled": emergency_calling_enabled, - "Secure": secure, + "EmergencyCallingEnabled": serialize.boolean_to_string( + emergency_calling_enabled + ), + "Secure": serialize.boolean_to_string(secure), "ByocTrunkSid": byoc_trunk_sid, "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( @@ -562,6 +579,7 @@ def __repr__(self) -> str: class DomainPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> DomainInstance: """ Build an instance of DomainInstance @@ -582,6 +600,7 @@ def __repr__(self) -> str: class DomainList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the DomainList @@ -633,6 +652,7 @@ def create( :returns: The created DomainInstance """ + data = values.of( { "DomainName": domain_name, @@ -643,18 +663,23 @@ def create( "VoiceFallbackMethod": voice_fallback_method, "VoiceStatusCallbackUrl": voice_status_callback_url, "VoiceStatusCallbackMethod": voice_status_callback_method, - "SipRegistration": sip_registration, - "EmergencyCallingEnabled": emergency_calling_enabled, - "Secure": secure, + "SipRegistration": serialize.boolean_to_string(sip_registration), + "EmergencyCallingEnabled": serialize.boolean_to_string( + emergency_calling_enabled + ), + "Secure": serialize.boolean_to_string(secure), "ByocTrunkSid": byoc_trunk_sid, "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( @@ -696,6 +721,7 @@ async def create_async( :returns: The created DomainInstance """ + data = values.of( { "DomainName": domain_name, @@ -706,18 +732,23 @@ async def create_async( "VoiceFallbackMethod": voice_fallback_method, "VoiceStatusCallbackUrl": voice_status_callback_url, "VoiceStatusCallbackMethod": voice_status_callback_method, - "SipRegistration": sip_registration, - "EmergencyCallingEnabled": emergency_calling_enabled, - "Secure": secure, + "SipRegistration": serialize.boolean_to_string(sip_registration), + "EmergencyCallingEnabled": serialize.boolean_to_string( + emergency_calling_enabled + ), + "Secure": serialize.boolean_to_string(secure), "ByocTrunkSid": byoc_trunk_sid, "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( @@ -851,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( @@ -878,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/__init__.py b/twilio/rest/api/v2010/account/sip/domain/auth_types/__init__.py index 282d3b64e5..73a81ac90d 100644 --- a/twilio/rest/api/v2010/account/sip/domain/auth_types/__init__.py +++ b/twilio/rest/api/v2010/account/sip/domain/auth_types/__init__.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Optional @@ -28,6 +27,7 @@ class AuthTypesList(ListResource): + def __init__(self, version: Version, account_sid: str, domain_sid: str): """ Initialize the AuthTypesList diff --git a/twilio/rest/api/v2010/account/sip/domain/auth_types/auth_type_calls/__init__.py b/twilio/rest/api/v2010/account/sip/domain/auth_types/auth_type_calls/__init__.py index 9d822b4fe9..79a42fa01d 100644 --- a/twilio/rest/api/v2010/account/sip/domain/auth_types/auth_type_calls/__init__.py +++ b/twilio/rest/api/v2010/account/sip/domain/auth_types/auth_type_calls/__init__.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Optional @@ -28,6 +27,7 @@ class AuthTypeCallsList(ListResource): + def __init__(self, version: Version, account_sid: str, domain_sid: str): """ Initialize the AuthTypeCallsList @@ -50,9 +50,9 @@ def __init__(self, version: Version, account_sid: str, domain_sid: str): ) ) - self._credential_list_mappings: Optional[ - AuthCallsCredentialListMappingList - ] = None + self._credential_list_mappings: Optional[AuthCallsCredentialListMappingList] = ( + None + ) self._ip_access_control_list_mappings: Optional[ AuthCallsIpAccessControlListMappingList ] = None 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 c9cade64f9..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 @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class AuthCallsCredentialListMappingInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the CredentialListMapping 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. @@ -126,6 +124,7 @@ def __repr__(self) -> str: class AuthCallsCredentialListMappingContext(InstanceContext): + def __init__(self, version: Version, account_sid: str, domain_sid: str, sid: str): """ Initialize the AuthCallsCredentialListMappingContext @@ -154,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: """ @@ -166,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: @@ -179,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, @@ -200,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( @@ -226,6 +231,7 @@ def __repr__(self) -> str: class AuthCallsCredentialListMappingPage(Page): + def get_instance( self, payload: Dict[str, Any] ) -> AuthCallsCredentialListMappingInstance: @@ -251,6 +257,7 @@ def __repr__(self) -> str: class AuthCallsCredentialListMappingList(ListResource): + def __init__(self, version: Version, account_sid: str, domain_sid: str): """ Initialize the AuthCallsCredentialListMappingList @@ -281,16 +288,20 @@ def create( :returns: The created AuthCallsCredentialListMappingInstance """ + data = values.of( { "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( @@ -310,16 +321,20 @@ async def create_async( :returns: The created AuthCallsCredentialListMappingInstance """ + data = values.of( { "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( @@ -456,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 ) @@ -485,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 f83393c377..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 @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class AuthCallsIpAccessControlListMappingInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the IpAccessControlListMapping 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. @@ -128,6 +126,7 @@ def __repr__(self) -> str: class AuthCallsIpAccessControlListMappingContext(InstanceContext): + def __init__(self, version: Version, account_sid: str, domain_sid: str, sid: str): """ Initialize the AuthCallsIpAccessControlListMappingContext @@ -156,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: """ @@ -168,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: @@ -181,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, @@ -202,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( @@ -230,6 +235,7 @@ def __repr__(self) -> str: class AuthCallsIpAccessControlListMappingPage(Page): + def get_instance( self, payload: Dict[str, Any] ) -> AuthCallsIpAccessControlListMappingInstance: @@ -255,6 +261,7 @@ def __repr__(self) -> str: class AuthCallsIpAccessControlListMappingList(ListResource): + def __init__(self, version: Version, account_sid: str, domain_sid: str): """ Initialize the AuthCallsIpAccessControlListMappingList @@ -285,16 +292,20 @@ def create( :returns: The created AuthCallsIpAccessControlListMappingInstance """ + data = values.of( { "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( @@ -314,16 +325,20 @@ async def create_async( :returns: The created AuthCallsIpAccessControlListMappingInstance """ + data = values.of( { "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( @@ -460,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 ) @@ -489,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/__init__.py b/twilio/rest/api/v2010/account/sip/domain/auth_types/auth_type_registrations/__init__.py index 41c1805ff2..c10c747378 100644 --- a/twilio/rest/api/v2010/account/sip/domain/auth_types/auth_type_registrations/__init__.py +++ b/twilio/rest/api/v2010/account/sip/domain/auth_types/auth_type_registrations/__init__.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Optional @@ -25,6 +24,7 @@ class AuthTypeRegistrationsList(ListResource): + def __init__(self, version: Version, account_sid: str, domain_sid: str): """ Initialize the AuthTypeRegistrationsList 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 a63a6e3290..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 @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class AuthRegistrationsCredentialListMappingInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the CredentialListMapping 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. @@ -126,6 +124,7 @@ def __repr__(self) -> str: class AuthRegistrationsCredentialListMappingContext(InstanceContext): + def __init__(self, version: Version, account_sid: str, domain_sid: str, sid: str): """ Initialize the AuthRegistrationsCredentialListMappingContext @@ -154,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: """ @@ -166,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: @@ -179,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, @@ -200,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( @@ -226,6 +231,7 @@ def __repr__(self) -> str: class AuthRegistrationsCredentialListMappingPage(Page): + def get_instance( self, payload: Dict[str, Any] ) -> AuthRegistrationsCredentialListMappingInstance: @@ -251,6 +257,7 @@ def __repr__(self) -> str: class AuthRegistrationsCredentialListMappingList(ListResource): + def __init__(self, version: Version, account_sid: str, domain_sid: str): """ Initialize the AuthRegistrationsCredentialListMappingList @@ -281,16 +288,20 @@ def create( :returns: The created AuthRegistrationsCredentialListMappingInstance """ + data = values.of( { "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( @@ -310,16 +321,20 @@ async def create_async( :returns: The created AuthRegistrationsCredentialListMappingInstance """ + data = values.of( { "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( @@ -456,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 ) @@ -485,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 248e0ca37b..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 @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class CredentialListMappingInstance(InstanceResource): - """ :ivar account_sid: The unique id of the Account that is responsible for this resource. :ivar date_created: The date that this resource was created, given as GMT in [RFC 2822](https://www.php.net/manual/en/class.datetime.php#datetime.constants.rfc2822) format. @@ -128,6 +126,7 @@ def __repr__(self) -> str: class CredentialListMappingContext(InstanceContext): + def __init__(self, version: Version, account_sid: str, domain_sid: str, sid: str): """ Initialize the CredentialListMappingContext @@ -156,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: """ @@ -168,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: @@ -181,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, @@ -202,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( @@ -226,6 +231,7 @@ def __repr__(self) -> str: class CredentialListMappingPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> CredentialListMappingInstance: """ Build an instance of CredentialListMappingInstance @@ -249,6 +255,7 @@ def __repr__(self) -> str: class CredentialListMappingList(ListResource): + def __init__(self, version: Version, account_sid: str, domain_sid: str): """ Initialize the CredentialListMappingList @@ -277,16 +284,20 @@ def create(self, credential_list_sid: str) -> CredentialListMappingInstance: :returns: The created CredentialListMappingInstance """ + data = values.of( { "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( @@ -306,16 +317,20 @@ async def create_async( :returns: The created CredentialListMappingInstance """ + data = values.of( { "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( @@ -452,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( @@ -479,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 cfe65e99dc..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 @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class IpAccessControlListMappingInstance(InstanceResource): - """ :ivar account_sid: The unique id of the Account that is responsible for this resource. :ivar date_created: The date that this resource was created, given as GMT in [RFC 2822](https://www.php.net/manual/en/class.datetime.php#datetime.constants.rfc2822) format. @@ -130,6 +128,7 @@ def __repr__(self) -> str: class IpAccessControlListMappingContext(InstanceContext): + def __init__(self, version: Version, account_sid: str, domain_sid: str, sid: str): """ Initialize the IpAccessControlListMappingContext @@ -158,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: """ @@ -170,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: @@ -183,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, @@ -204,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( @@ -228,6 +233,7 @@ def __repr__(self) -> str: class IpAccessControlListMappingPage(Page): + def get_instance( self, payload: Dict[str, Any] ) -> IpAccessControlListMappingInstance: @@ -253,6 +259,7 @@ def __repr__(self) -> str: class IpAccessControlListMappingList(ListResource): + def __init__(self, version: Version, account_sid: str, domain_sid: str): """ Initialize the IpAccessControlListMappingList @@ -283,16 +290,20 @@ def create( :returns: The created IpAccessControlListMappingInstance """ + data = values.of( { "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( @@ -312,16 +323,20 @@ async def create_async( :returns: The created IpAccessControlListMappingInstance """ + data = values.of( { "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( @@ -458,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( @@ -485,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 fac56d8573..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 @@ -12,7 +12,6 @@ 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 @@ -27,7 +26,6 @@ class IpAccessControlListInstance(InstanceResource): - """ :ivar sid: A 34 character string that uniquely identifies this resource. :ivar account_sid: The unique id of the [Account](https://www.twilio.com/docs/iam/api/account) that owns this resource. @@ -161,6 +159,7 @@ def __repr__(self) -> str: class IpAccessControlListContext(InstanceContext): + def __init__(self, version: Version, account_sid: str, sid: str): """ Initialize the IpAccessControlListContext @@ -191,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: """ @@ -203,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: @@ -216,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, @@ -236,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( @@ -256,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( @@ -283,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( @@ -326,6 +339,7 @@ def __repr__(self) -> str: class IpAccessControlListPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> IpAccessControlListInstance: """ Build an instance of IpAccessControlListInstance @@ -346,6 +360,7 @@ def __repr__(self) -> str: class IpAccessControlListList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the IpAccessControlListList @@ -372,16 +387,20 @@ def create(self, friendly_name: str) -> IpAccessControlListInstance: :returns: The created IpAccessControlListInstance """ + data = values.of( { "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( @@ -396,16 +415,20 @@ async def create_async(self, friendly_name: str) -> IpAccessControlListInstance: :returns: The created IpAccessControlListInstance """ + data = values.of( { "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( @@ -539,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( @@ -566,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 2ce7f69f18..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 @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class IpAddressInstance(InstanceResource): - """ :ivar sid: A 34 character string that uniquely identifies this resource. :ivar account_sid: The unique id of the Account that is responsible for this resource. @@ -178,6 +176,7 @@ def __repr__(self) -> str: class IpAddressContext(InstanceContext): + def __init__( self, version: Version, @@ -212,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: """ @@ -224,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: @@ -237,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, @@ -258,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( @@ -286,6 +291,7 @@ def update( :returns: The updated IpAddressInstance """ + data = values.of( { "IpAddress": ip_address, @@ -293,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( @@ -323,6 +332,7 @@ async def update_async( :returns: The updated IpAddressInstance """ + data = values.of( { "IpAddress": ip_address, @@ -330,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( @@ -356,6 +369,7 @@ def __repr__(self) -> str: class IpAddressPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> IpAddressInstance: """ Build an instance of IpAddressInstance @@ -379,6 +393,7 @@ def __repr__(self) -> str: class IpAddressList(ListResource): + def __init__( self, version: Version, account_sid: str, ip_access_control_list_sid: str ): @@ -416,6 +431,7 @@ def create( :returns: The created IpAddressInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -423,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( @@ -452,6 +471,7 @@ async def create_async( :returns: The created IpAddressInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -459,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( @@ -600,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( @@ -627,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 744bedd295..fa43360fb1 100644 --- a/twilio/rest/api/v2010/account/token.py +++ b/twilio/rest/api/v2010/account/token.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import datetime from typing import Any, Dict, List, Optional, Union from twilio.base import deserialize, values @@ -23,7 +22,6 @@ class TokenInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Token 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. @@ -64,6 +62,7 @@ def __repr__(self) -> str: class TokenList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the TokenList @@ -88,16 +87,20 @@ def create(self, ttl: Union[int, object] = values.unset) -> TokenInstance: :returns: The created TokenInstance """ + data = values.of( { "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( @@ -114,16 +117,20 @@ async def create_async( :returns: The created TokenInstance """ + data = values.of( { "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 2baa8af865..386ff9ee74 100644 --- a/twilio/rest/api/v2010/account/transcription.py +++ b/twilio/rest/api/v2010/account/transcription.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class TranscriptionInstance(InstanceResource): + class Status(object): IN_PROGRESS = "in-progress" COMPLETED = "completed" @@ -141,6 +141,7 @@ def __repr__(self) -> str: class TranscriptionContext(InstanceContext): + def __init__(self, version: Version, account_sid: str, sid: str): """ Initialize the TranscriptionContext @@ -167,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: """ @@ -179,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: @@ -192,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, @@ -212,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( @@ -235,6 +242,7 @@ def __repr__(self) -> str: class TranscriptionPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> TranscriptionInstance: """ Build an instance of TranscriptionInstance @@ -255,6 +263,7 @@ def __repr__(self) -> str: class TranscriptionList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the TranscriptionList @@ -400,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( @@ -427,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/__init__.py b/twilio/rest/api/v2010/account/usage/__init__.py index 3f3f2c76fb..8fe80f64ba 100644 --- a/twilio/rest/api/v2010/account/usage/__init__.py +++ b/twilio/rest/api/v2010/account/usage/__init__.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Optional @@ -24,6 +23,7 @@ class UsageList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the UsageList diff --git a/twilio/rest/api/v2010/account/usage/record/__init__.py b/twilio/rest/api/v2010/account/usage/record/__init__.py index cc22602658..d60bde9b6b 100644 --- a/twilio/rest/api/v2010/account/usage/record/__init__.py +++ b/twilio/rest/api/v2010/account/usage/record/__init__.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import date from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import deserialize, serialize, values @@ -32,34 +31,103 @@ class RecordInstance(InstanceResource): + class Category(object): + A2P_10DLC_REGISTRATIONFEES_BRANDREGISTRATION = ( + "a2p-10dlc-registrationfees-brandregistration" + ) + A2P_10DLC_REGISTRATIONFEES_BV = "a2p-10dlc-registrationfees-bv" + A2P_10DLC_REGISTRATIONFEES_CAMPAIGNCHARGES = ( + "a2p-10dlc-registrationfees-campaigncharges" + ) + A2P_10DLC_REGISTRATIONFEES_CAMPAIGNREGISTRATION = ( + "a2p-10dlc-registrationfees-campaignregistration" + ) + A2P_10DLC_REGISTRATIONFEES_CAMPAIGNVETTING = ( + "a2p-10dlc-registrationfees-campaignvetting" + ) + A2P_10DLC_REGISTRATIONFEES_MONTHLY = "a2p-10dlc-registrationfees-monthly" + A2P_10DLC_REGISTRATIONFEES_ONETIME = "a2p-10dlc-registrationfees-onetime" A2P_REGISTRATION_FEES = "a2p-registration-fees" + ACCOUNT_SECURITY = "account-security" AGENT_CONFERENCE = "agent-conference" + AGENT_COPILOT = "agent-copilot" + AGENT_COPILOT_MESSAGES = "agent-copilot-messages" + AGENT_COPILOT_PARTICIPANT_MINUTES = "agent-copilot-participant-minutes" + AI_ASSISTANTS = "ai-assistants" + AI_ASSISTANTS_VOICE = "ai-assistants-voice" AMAZON_POLLY = "amazon-polly" ANSWERING_MACHINE_DETECTION = "answering-machine-detection" + ASSETS = "assets" + AUDIENCE_MINUTES = "audience-minutes" + AUDIENCE_MINUTES_AUDIO = "audience-minutes-audio" AUTHY_AUTHENTICATIONS = "authy-authentications" AUTHY_CALLS_OUTBOUND = "authy-calls-outbound" + AUTHY_EMAIL_AUTHENTICATIONS = "authy-email-authentications" AUTHY_MONTHLY_FEES = "authy-monthly-fees" + AUTHY_OUTBOUND_EMAIL = "authy-outbound-email" AUTHY_PHONE_INTELLIGENCE = "authy-phone-intelligence" AUTHY_PHONE_VERIFICATIONS = "authy-phone-verifications" AUTHY_SMS_OUTBOUND = "authy-sms-outbound" + AUTHY_VERIFY_EMAIL_VERIFICATIONS = "authy-verify-email-verifications" + AUTHY_VERIFY_OUTBOUND_EMAIL = "authy-verify-outbound-email" + AUTOPILOT = "autopilot" + AUTOPILOT_HOME_ASSISTANTS = "autopilot-home-assistants" + AUTOPILOT_MESSAGING = "autopilot-messaging" + AUTOPILOT_OTHER = "autopilot-other" + AUTOPILOT_VOICE = "autopilot-voice" + BASIC_PEER_TO_PEER_ROOMS_PARTICIPANT_MINUTES = ( + "basic-peer-to-peer-rooms-participant-minutes" + ) + BRANDED_CALLING = "branded-calling" + BUNDLE_SMS_BUCKET = "bundle-sms-bucket" + BUNDLE_SUBSCRIPTION_FEES = "bundle-subscription-fees" + CALL_FORWARDING_LOOKUPS = "call-forwarding-lookups" CALL_PROGESS_EVENTS = "call-progess-events" CALLERIDLOOKUPS = "calleridlookups" CALLS = "calls" CALLS_CLIENT = "calls-client" + CALLS_EMERGENCY = "calls-emergency" CALLS_GLOBALCONFERENCE = "calls-globalconference" CALLS_INBOUND = "calls-inbound" CALLS_INBOUND_LOCAL = "calls-inbound-local" CALLS_INBOUND_MOBILE = "calls-inbound-mobile" CALLS_INBOUND_TOLLFREE = "calls-inbound-tollfree" + CALLS_INBOUND_TOLLFREE_LOCAL = "calls-inbound-tollfree-local" + CALLS_INBOUND_TOLLFREE_MOBILE = "calls-inbound-tollfree-mobile" + CALLS_MEDIA_STREAM_MINUTES = "calls-media-stream-minutes" CALLS_OUTBOUND = "calls-outbound" CALLS_PAY_VERB_TRANSACTIONS = "calls-pay-verb-transactions" CALLS_RECORDINGS = "calls-recordings" CALLS_SIP = "calls-sip" CALLS_SIP_INBOUND = "calls-sip-inbound" CALLS_SIP_OUTBOUND = "calls-sip-outbound" + CALLS_TEXT_TO_SPEECH = "calls-text-to-speech" CALLS_TRANSFERS = "calls-transfers" CARRIER_LOOKUPS = "carrier-lookups" + CATEGORY = "category" + CHANNELS = "channels" + CHANNELS_MESSAGING = "channels-messaging" + CHANNELS_MESSAGING_INBOUND = "channels-messaging-inbound" + CHANNELS_MESSAGING_OUTBOUND = "channels-messaging-outbound" + CHANNELS_WHATSAPP = "channels-whatsapp" + CHANNELS_WHATSAPP_CONVERSATION_AUTHENTICATION = ( + "channels-whatsapp-conversation-authentication" + ) + CHANNELS_WHATSAPP_CONVERSATION_FREE = "channels-whatsapp-conversation-free" + CHANNELS_WHATSAPP_CONVERSATION_MARKETING = ( + "channels-whatsapp-conversation-marketing" + ) + CHANNELS_WHATSAPP_CONVERSATION_SERVICE = ( + "channels-whatsapp-conversation-service" + ) + CHANNELS_WHATSAPP_CONVERSATION_UTILITY = ( + "channels-whatsapp-conversation-utility" + ) + CHANNELS_WHATSAPP_INBOUND = "channels-whatsapp-inbound" + CHANNELS_WHATSAPP_OUTBOUND = "channels-whatsapp-outbound" + CHAT_VIRTUAL_AGENT = "chat-virtual-agent" + CONVERSATION_RELAY = "conversation-relay" CONVERSATIONS = "conversations" CONVERSATIONS_API_REQUESTS = "conversations-api-requests" CONVERSATIONS_CONVERSATION_EVENTS = "conversations-conversation-events" @@ -68,8 +136,40 @@ class Category(object): CONVERSATIONS_PARTICIPANT_EVENTS = "conversations-participant-events" CONVERSATIONS_PARTICIPANTS = "conversations-participants" CPS = "cps" + CREDIT_TRANSFER = "credit-transfer" + EMAIL = "email" + EMERGING_TECH = "emerging-tech" + ENGAGEMENT_SUITE_PACKAGED_PLANS = "engagement-suite-packaged-plans" + ENHANCED_LINE_TYPE_LOOKUPS = "enhanced-line-type-lookups" + ENTERPRISE = "enterprise" + EVENTS = "events" + EXPERIMENT_FRANCE_SMS = "experiment-france-sms" + EXPERIMENT_INDIA_SMS = "experiment-india-sms" + EXPERIMENT_UK_SMS = "experiment-uk-sms" + FAILED_MESSAGE_PROCESSING_FEE = "failed-message-processing-fee" + FLEX = "flex" + FLEX_ACTIVE_USER_HOURS = "flex-active-user-hours" + FLEX_CONCURRENT_USERS = "flex-concurrent-users" + FLEX_CONVERSATIONAL_INSIGHTS = "flex-conversational-insights" + FLEX_CONVERSATIONAL_INSIGHTS_MESSAGES = "flex-conversational-insights-messages" + FLEX_CONVERSATIONAL_INSIGHTS_VOICE_MINUTES = ( + "flex-conversational-insights-voice-minutes" + ) + FLEX_EMAIL_USAGE = "flex-email-usage" + FLEX_MESSAGING_USAGE = "flex-messaging-usage" + FLEX_PARTNER_SPINSCI = "flex-partner-spinsci" + FLEX_PARTNER_XCELERATE = "flex-partner-xcelerate" + FLEX_RESELLER_ECOSYSTEM = "flex-reseller-ecosystem" + FLEX_UNIQUE_USER = "flex-unique-user" FLEX_USAGE = "flex-usage" + FLEX_USERS = "flex-users" + FLEX_VOICE_MINUTE = "flex-voice-minute" + FLEX_YTICA = "flex-ytica" FRAUD_LOOKUPS = "fraud-lookups" + FRONTLINE = "frontline" + FRONTLINE_USERS = "frontline-users" + FUNCTIONS = "functions" + GENERIC_PAY_TRANSACTIONS = "generic-pay-transactions" GROUP_ROOMS = "group-rooms" GROUP_ROOMS_DATA_TRACK = "group-rooms-data-track" GROUP_ROOMS_ENCRYPTED_MEDIA_RECORDED = "group-rooms-encrypted-media-recorded" @@ -79,7 +179,17 @@ class Category(object): GROUP_ROOMS_MEDIA_STORED = "group-rooms-media-stored" GROUP_ROOMS_PARTICIPANT_MINUTES = "group-rooms-participant-minutes" GROUP_ROOMS_RECORDED_MINUTES = "group-rooms-recorded-minutes" - IMP_V1_USAGE = "imp-v1-usage" + IP_MESSAGING = "ip-messaging" + IP_MESSAGING_COMMANDS = "ip-messaging-commands" + IP_MESSAGING_DATA_STORAGE = "ip-messaging-data-storage" + IP_MESSAGING_DATA_TRANSFER = "ip-messaging-data-transfer" + IP_MESSAGING_ENDPOINT_CONNECTIVITY = "ip-messaging-endpoint-connectivity" + IVR_VIRTUAL_AGENT_CUSTOM_VOICES = "ivr-virtual-agent-custom-voices" + IVR_VIRTUAL_AGENT_GENAI = "ivr-virtual-agent-genai" + LINE_STATUS_LOOKUPS = "line-status-lookups" + LIVE_ACTIVITY_LOOKUPS = "live-activity-lookups" + LOOKUP_BUCKET_ADJUSTMENT = "lookup-bucket-adjustment" + LOOKUP_IDENTITY_MATCH = "lookup-identity-match" LOOKUPS = "lookups" MARKETPLACE = "marketplace" MARKETPLACE_ALGORITHMIA_NAMED_ENTITY_RECOGNITION = ( @@ -90,6 +200,13 @@ class Category(object): MARKETPLACE_CAPIO_SPEECH_TO_TEXT = "marketplace-capio-speech-to-text" MARKETPLACE_CONVRIZA_ABABA = "marketplace-convriza-ababa" MARKETPLACE_DEEPGRAM_PHRASE_DETECTOR = "marketplace-deepgram-phrase-detector" + MARKETPLACE_DEEPGRAM_TRANSCRIPTION = "marketplace-deepgram-transcription" + MARKETPLACE_DEEPGRAM_TRANSCRIPTION_BASE = ( + "marketplace-deepgram-transcription-base" + ) + MARKETPLACE_DEEPGRAM_TRANSSCRIPTION_ENHANCED = ( + "marketplace-deepgram-transscription-enhanced" + ) MARKETPLACE_DIGITAL_SEGMENT_BUSINESS_INFO = ( "marketplace-digital-segment-business-info" ) @@ -115,6 +232,9 @@ class Category(object): "marketplace-keen-io-contact-center-analytics" ) MARKETPLACE_MARCHEX_CLEANCALL = "marketplace-marchex-cleancall" + MARKETPLACE_MARCHEX_RECORDING_ANALYSIS = ( + "marketplace-marchex-recording-analysis" + ) MARKETPLACE_MARCHEX_SENTIMENT_ANALYSIS_FOR_SMS = ( "marketplace-marchex-sentiment-analysis-for-sms" ) @@ -131,14 +251,42 @@ class Category(object): "marketplace-nextcaller-advanced-caller-identification" ) MARKETPLACE_NOMOROBO_SPAM_SCORE = "marketplace-nomorobo-spam-score" + MARKETPLACE_PAY_ADDONS = "marketplace-pay-addons" + MARKETPLACE_PAY_ADDONS_BASECOMMERCE_PAY_CONNECTOR = ( + "marketplace-pay-addons-basecommerce-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_BRAINTREE_PAY_CONNECTOR = ( + "marketplace-pay-addons-braintree-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_CARDCONNECT_PAY_CONNECTOR = ( + "marketplace-pay-addons-cardconnect-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_CHASE_PAY_CONNECTOR = ( + "marketplace-pay-addons-chase-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_SHUTTLE_PAY_CONNECTOR = ( + "marketplace-pay-addons-shuttle-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_STRIPE_PAY_CONNECTOR = ( + "marketplace-pay-addons-stripe-pay-connector" + ) MARKETPLACE_PAYFONE_TCPA_COMPLIANCE = "marketplace-payfone-tcpa-compliance" + MARKETPLACE_POLY_AI_CONNECTOR = "marketplace-poly-ai-connector" + MARKETPLACE_REALPHONEVALIDATION = "marketplace-realphonevalidation" MARKETPLACE_REMEETING_AUTOMATIC_SPEECH_RECOGNITION = ( "marketplace-remeeting-automatic-speech-recognition" ) + MARKETPLACE_SPOKE_PHONE_LICENSE_PRO = "marketplace-spoke-phone-license-pro" + MARKETPLACE_SPOKE_PHONE_LICENSE_STANDARD = ( + "marketplace-spoke-phone-license-standard" + ) MARKETPLACE_TCPA_DEFENSE_SOLUTIONS_BLACKLIST_FEED = ( "marketplace-tcpa-defense-solutions-blacklist-feed" ) MARKETPLACE_TELO_OPENCNAM = "marketplace-telo-opencnam" + MARKETPLACE_TRESTLE_SOLUTIONS_CALLER_IDENTIFICATION = ( + "marketplace-trestle-solutions-caller-identification" + ) MARKETPLACE_TRUECNAM_TRUE_SPAM = "marketplace-truecnam-true-spam" MARKETPLACE_TWILIO_CALLER_NAME_LOOKUP_US = ( "marketplace-twilio-caller-name-lookup-us" @@ -151,6 +299,9 @@ class Category(object): MARKETPLACE_VOICEBASE_TRANSCRIPTION_CUSTOM_VOCABULARY = ( "marketplace-voicebase-transcription-custom-vocabulary" ) + MARKETPLACE_WEB_PURIFY_PROFANITY_FILTER = ( + "marketplace-web-purify-profanity-filter" + ) MARKETPLACE_WHITEPAGES_PRO_CALLER_IDENTIFICATION = ( "marketplace-whitepages-pro-caller-identification" ) @@ -165,15 +316,23 @@ class Category(object): MARKETPLACE_YTICA_CONTACT_CENTER_REPORTING_ANALYTICS = ( "marketplace-ytica-contact-center-reporting-analytics" ) + MARKETPLAY_PAY_ADDONS_SHUTTLE_PAY_CONNECTOR = ( + "marketplay-pay-addons-shuttle-pay-connector" + ) + MEDIA_COMPOSER_MINUTES = "media-composer-minutes" MEDIASTORAGE = "mediastorage" + MIN_SPEND_ADJUSTMENTS = "min-spend-adjustments" MMS = "mms" MMS_INBOUND = "mms-inbound" MMS_INBOUND_LONGCODE = "mms-inbound-longcode" MMS_INBOUND_SHORTCODE = "mms-inbound-shortcode" + MMS_INBOUND_TOLL_FREE = "mms-inbound-toll-free" MMS_MESSAGES_CARRIERFEES = "mms-messages-carrierfees" MMS_OUTBOUND = "mms-outbound" MMS_OUTBOUND_LONGCODE = "mms-outbound-longcode" MMS_OUTBOUND_SHORTCODE = "mms-outbound-shortcode" + MMS_OUTBOUND_TOLLFREE = "mms-outbound-tollfree" + MONITOR = "monitor" MONITOR_READS = "monitor-reads" MONITOR_STORAGE = "monitor-storage" MONITOR_WRITES = "monitor-writes" @@ -182,6 +341,12 @@ class Category(object): NOTIFY_CHANNELS = "notify-channels" NUMBER_FORMAT_LOOKUPS = "number-format-lookups" PCHAT = "pchat" + PCHAT_ACTIONS = "pchat-actions" + PCHAT_APS = "pchat-aps" + PCHAT_CONV_MED_STORAGE = "pchat-conv-med-storage" + PCHAT_MESSAGES = "pchat-messages" + PCHAT_NOTIFICATIONS = "pchat-notifications" + PCHAT_READS = "pchat-reads" PCHAT_USERS = "pchat-users" PEER_TO_PEER_ROOMS_PARTICIPANT_MINUTES = ( "peer-to-peer-rooms-participant-minutes" @@ -191,18 +356,41 @@ class Category(object): PFAX_MINUTES_INBOUND = "pfax-minutes-inbound" PFAX_MINUTES_OUTBOUND = "pfax-minutes-outbound" PFAX_PAGES = "pfax-pages" + PHONE_QUALITY_SCORE_LOOKUPS = "phone-quality-score-lookups" PHONENUMBERS = "phonenumbers" PHONENUMBERS_CPS = "phonenumbers-cps" PHONENUMBERS_EMERGENCY = "phonenumbers-emergency" PHONENUMBERS_LOCAL = "phonenumbers-local" PHONENUMBERS_MOBILE = "phonenumbers-mobile" + PHONENUMBERS_PORTING = "phonenumbers-porting" PHONENUMBERS_SETUPS = "phonenumbers-setups" PHONENUMBERS_TOLLFREE = "phonenumbers-tollfree" PREMIUMSUPPORT = "premiumsupport" + PREMIUMSUPPORT_PERCENTAGE_SPEND = "premiumsupport-percentage-spend" + PROGRAMMABLEVOICE_PLATFORM = "programmablevoice-platform" + PROGRAMMABLEVOICECONN_CLIENTSDK = "programmablevoiceconn-clientsdk" + PROGRAMMABLEVOICECONN_CLIENTSDK_INBOUND = ( + "programmablevoiceconn-clientsdk-inbound" + ) + PROGRAMMABLEVOICECONN_CLIENTSDK_OUTBOUND = ( + "programmablevoiceconn-clientsdk-outbound" + ) + PROGRAMMABLEVOICECONN_ONNET = "programmablevoiceconn-onnet" + PROGRAMMABLEVOICECONN_ONNET_INBOUND = "programmablevoiceconn-onnet-inbound" + PROGRAMMABLEVOICECONN_ONNET_OUTBOUND = "programmablevoiceconn-onnet-outbound" + PROGRAMMABLEVOICECONN_SIP = "programmablevoiceconn-sip" + PROGRAMMABLEVOICECONN_SIP_INBOUND = "programmablevoiceconn-sip-inbound" + PROGRAMMABLEVOICECONN_SIP_OUTBOUND = "programmablevoiceconn-sip-outbound" + PROGRAMMABLEVOICECONNECTIVITY = "programmablevoiceconnectivity" PROXY = "proxy" PROXY_ACTIVE_SESSIONS = "proxy-active-sessions" + PROXY_BUCKET_ADJUSTMENT = "proxy-bucket-adjustment" + PROXY_LICENSES = "proxy-licenses" PSTNCONNECTIVITY = "pstnconnectivity" + PSTNCONNECTIVITY_INBOUND = "pstnconnectivity-inbound" + PSTNCONNECTIVITY_OUTBOUND = "pstnconnectivity-outbound" PV = "pv" + PV_BASIC_ROOMS = "pv-basic-rooms" PV_COMPOSITION_MEDIA_DOWNLOADED = "pv-composition-media-downloaded" PV_COMPOSITION_MEDIA_ENCRYPTED = "pv-composition-media-encrypted" PV_COMPOSITION_MEDIA_STORED = "pv-composition-media-stored" @@ -218,18 +406,20 @@ class Category(object): PV_ROOM_PARTICIPANTS_US2 = "pv-room-participants-us2" PV_ROOMS = "pv-rooms" PV_SIP_ENDPOINT_REGISTRATIONS = "pv-sip-endpoint-registrations" + RCS_MESSAGES = "rcs-messages" + REASSIGNED_NUMBER = "reassigned-number" RECORDINGS = "recordings" RECORDINGSTORAGE = "recordingstorage" - ROOMS_GROUP_BANDWIDTH = "rooms-group-bandwidth" - ROOMS_GROUP_MINUTES = "rooms-group-minutes" - ROOMS_PEER_TO_PEER_MINUTES = "rooms-peer-to-peer-minutes" SHORTCODES = "shortcodes" SHORTCODES_CUSTOMEROWNED = "shortcodes-customerowned" SHORTCODES_MMS_ENABLEMENT = "shortcodes-mms-enablement" SHORTCODES_MPS = "shortcodes-mps" SHORTCODES_RANDOM = "shortcodes-random" + SHORTCODES_SETUP_FEES = "shortcodes-setup-fees" SHORTCODES_UK = "shortcodes-uk" SHORTCODES_VANITY = "shortcodes-vanity" + SIM_SWAP_LOOKUPS = "sim-swap-lookups" + SIP_SECURE_MEDIA = "sip-secure-media" SMALL_GROUP_ROOMS = "small-group-rooms" SMALL_GROUP_ROOMS_DATA_TRACK = "small-group-rooms-data-track" SMALL_GROUP_ROOMS_PARTICIPANT_MINUTES = "small-group-rooms-participant-minutes" @@ -237,13 +427,30 @@ class Category(object): SMS_INBOUND = "sms-inbound" SMS_INBOUND_LONGCODE = "sms-inbound-longcode" SMS_INBOUND_SHORTCODE = "sms-inbound-shortcode" + SMS_INBOUND_TOLLFREE = "sms-inbound-tollfree" SMS_MESSAGES_CARRIERFEES = "sms-messages-carrierfees" SMS_MESSAGES_FEATURES = "sms-messages-features" + SMS_MESSAGES_FEATURES_ENGAGEMENT_SUITE = ( + "sms-messages-features-engagement-suite" + ) + SMS_MESSAGES_FEATURES_MESSAGE_REDACTION = ( + "sms-messages-features-message-redaction" + ) SMS_MESSAGES_FEATURES_SENDERID = "sms-messages-features-senderid" + SMS_MPS = "sms-mps" + SMS_MPS_SHORTCODE = "sms-mps-shortcode" + SMS_MPS_TOLLFREE = "sms-mps-tollfree" + SMS_MPS_TOLLFREE_SETUP = "sms-mps-tollfree-setup" + SMS_NATIONAL_REGULATORY_PROTECTION = "sms-national-regulatory-protection" SMS_OUTBOUND = "sms-outbound" SMS_OUTBOUND_CONTENT_INSPECTION = "sms-outbound-content-inspection" SMS_OUTBOUND_LONGCODE = "sms-outbound-longcode" SMS_OUTBOUND_SHORTCODE = "sms-outbound-shortcode" + SMS_OUTBOUND_TOLLFREE = "sms-outbound-tollfree" + SMS_PUMPING_PROTECTION = "sms-pumping-protection" + SMS_PUMPING_RISK = "sms-pumping-risk" + SMSMESSAGES_BUCKET_ADJUSTMENTS = "smsmessages-bucket-adjustments" + SMSMESSAGES_OUTBOUND_DOMESTIC = "smsmessages-outbound-domestic" SPEECH_RECOGNITION = "speech-recognition" STUDIO_ENGAGEMENTS = "studio-engagements" SYNC = "sync" @@ -262,6 +469,7 @@ class Category(object): TRUNKING_RECORDINGS = "trunking-recordings" TRUNKING_SECURE = "trunking-secure" TRUNKING_TERMINATION = "trunking-termination" + TTS_GOOGLE = "tts-google" TURNMEGABYTES = "turnmegabytes" TURNMEGABYTES_AUSTRALIA = "turnmegabytes-australia" TURNMEGABYTES_BRASIL = "turnmegabytes-brasil" @@ -272,13 +480,27 @@ class Category(object): TURNMEGABYTES_SINGAPORE = "turnmegabytes-singapore" TURNMEGABYTES_USEAST = "turnmegabytes-useast" TURNMEGABYTES_USWEST = "turnmegabytes-uswest" + TWILIO_FOR_SALESFORCE = "twilio-for-salesforce" + TWILIO_FOR_SALESFORCE_LICENSES = "twilio-for-salesforce-licenses" TWILIO_INTERCONNECT = "twilio-interconnect" + TWIML = "twiml" + USAGE_FLEX_VIDEO = "usage-flex-video" + USAGE_FUNCTIONS = "usage-functions" + USAGE_RCS_BASIC_MESSAGES_OUTBOUND = "usage-rcs-basic-messages-outbound" + USAGE_RCS_MESSAGES = "usage-rcs-messages" + USAGE_RCS_MESSAGES_INBOUND = "usage-rcs-messages-inbound" + USAGE_RCS_MESSAGING_CARRIER_FEES = "usage-rcs-messaging-carrier-fees" + USAGE_RCS_SINGLE_MESSAGES_OUTBOUND = "usage-rcs-single-messages-outbound" + VERIFY_PACKAGE_PLANS = "verify-package-plans" VERIFY_PUSH = "verify-push" + VERIFY_SNA = "verify-sna" VERIFY_TOTP = "verify-totp" + VERIFY_VOICE_SMS = "verify-voice-sms" VERIFY_WHATSAPP_CONVERSATIONS_BUSINESS_INITIATED = ( "verify-whatsapp-conversations-business-initiated" ) VIDEO_RECORDINGS = "video-recordings" + VIDEO_ROOMS_TURN_MEGABYTES = "video-rooms-turn-megabytes" VIRTUAL_AGENT = "virtual-agent" VOICE_INSIGHTS = "voice-insights" VOICE_INSIGHTS_CLIENT_INSIGHTS_ON_DEMAND_MINUTE = ( @@ -293,12 +515,104 @@ class Category(object): VOICE_INSIGHTS_SIP_TRUNKING_INSIGHTS_ON_DEMAND_MINUTE = ( "voice-insights-sip-trunking-insights-on-demand-minute" ) + VOICE_INTELLIGENCE = "voice-intelligence" + VOICE_INTELLIGENCE_EIP_OPERATORS = "voice-intelligence-eip-operators" + VOICE_INTELLIGENCE_OPERATORS = "voice-intelligence-operators" + VOICE_INTELLIGENCE_TRANSCRIPTION = "voice-intelligence-transcription" + WDS = "wds" WIRELESS = "wireless" + WIRELESS_DATA = "wireless-data" + WIRELESS_DATA_PAYG = "wireless-data-payg" + WIRELESS_DATA_PAYG_AFRICA = "wireless-data-payg-africa" + WIRELESS_DATA_PAYG_ASIA = "wireless-data-payg-asia" + WIRELESS_DATA_PAYG_CENTRALANDSOUTHAMERICA = ( + "wireless-data-payg-centralandsouthamerica" + ) + WIRELESS_DATA_PAYG_EUROPE = "wireless-data-payg-europe" + WIRELESS_DATA_PAYG_NORTHAMERICA = "wireless-data-payg-northamerica" + WIRELESS_DATA_PAYG_OCEANIA = "wireless-data-payg-oceania" + WIRELESS_DATA_QUOTA1 = "wireless-data-quota1" + WIRELESS_DATA_QUOTA1_AFRICA = "wireless-data-quota1-africa" + WIRELESS_DATA_QUOTA1_ASIA = "wireless-data-quota1-asia" + WIRELESS_DATA_QUOTA1_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quota1-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTA1_EUROPE = "wireless-data-quota1-europe" + WIRELESS_DATA_QUOTA1_NORTHAMERICA = "wireless-data-quota1-northamerica" + WIRELESS_DATA_QUOTA1_OCEANIA = "wireless-data-quota1-oceania" + WIRELESS_DATA_QUOTA10 = "wireless-data-quota10" + WIRELESS_DATA_QUOTA10_AFRICA = "wireless-data-quota10-africa" + WIRELESS_DATA_QUOTA10_ASIA = "wireless-data-quota10-asia" + WIRELESS_DATA_QUOTA10_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quota10-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTA10_EUROPE = "wireless-data-quota10-europe" + WIRELESS_DATA_QUOTA10_NORTHAMERICA = "wireless-data-quota10-northamerica" + WIRELESS_DATA_QUOTA10_OCEANIA = "wireless-data-quota10-oceania" + WIRELESS_DATA_QUOTA50 = "wireless-data-quota50" + WIRELESS_DATA_QUOTA50_AFRICA = "wireless-data-quota50-africa" + WIRELESS_DATA_QUOTA50_ASIA = "wireless-data-quota50-asia" + WIRELESS_DATA_QUOTA50_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quota50-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTA50_EUROPE = "wireless-data-quota50-europe" + WIRELESS_DATA_QUOTA50_NORTHAMERICA = "wireless-data-quota50-northamerica" + WIRELESS_DATA_QUOTA50_OCEANIA = "wireless-data-quota50-oceania" + WIRELESS_DATA_QUOTACUSTOM = "wireless-data-quotacustom" + WIRELESS_DATA_QUOTACUSTOM_AFRICA = "wireless-data-quotacustom-africa" + WIRELESS_DATA_QUOTACUSTOM_ASIA = "wireless-data-quotacustom-asia" + WIRELESS_DATA_QUOTACUSTOM_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quotacustom-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTACUSTOM_EUROPE = "wireless-data-quotacustom-europe" + WIRELESS_DATA_QUOTACUSTOM_NORTHAMERICA = ( + "wireless-data-quotacustom-northamerica" + ) + WIRELESS_DATA_QUOTACUSTOM_OCEANIA = "wireless-data-quotacustom-oceania" + WIRELESS_MRC_PAYG = "wireless-mrc-payg" + WIRELESS_MRC_QUOTA1 = "wireless-mrc-quota1" + WIRELESS_MRC_QUOTA10 = "wireless-mrc-quota10" + WIRELESS_MRC_QUOTA50 = "wireless-mrc-quota50" + WIRELESS_MRC_QUOTACUSTOM = "wireless-mrc-quotacustom" WIRELESS_ORDERS = "wireless-orders" WIRELESS_ORDERS_ARTWORK = "wireless-orders-artwork" WIRELESS_ORDERS_BULK = "wireless-orders-bulk" WIRELESS_ORDERS_ESIM = "wireless-orders-esim" WIRELESS_ORDERS_STARTER = "wireless-orders-starter" + WIRELESS_QUOTAS = "wireless-quotas" + WIRELESS_SMS_AFRICA = "wireless-sms-africa" + WIRELESS_SMS_ASIA = "wireless-sms-asia" + WIRELESS_SMS_CENTRALANDSOUTHAMERICA = "wireless-sms-centralandsouthamerica" + WIRELESS_SMS_EUROPE = "wireless-sms-europe" + WIRELESS_SMS_NORTHAMERICA = "wireless-sms-northamerica" + WIRELESS_SMS_OCEANIA = "wireless-sms-oceania" + WIRELESS_SUPER_SIM = "wireless-super-sim" + WIRELESS_SUPER_SIM_DATA = "wireless-super-sim-data" + WIRELESS_SUPER_SIM_DATA_NORTH_AMERICA_USA = ( + "wireless-super-sim-data-north-america-usa" + ) + WIRELESS_SUPER_SIM_DATA_PAYG = "wireless-super-sim-data-payg" + WIRELESS_SUPER_SIM_DATA_PAYG_EUROPE = "wireless-super-sim-data-payg-europe" + WIRELESS_SUPER_SIM_DATA_PAYG_NORTH_AMERICA = ( + "wireless-super-sim-data-payg-north-america" + ) + WIRELESS_SUPER_SIM_HARDWARE = "wireless-super-sim-hardware" + WIRELESS_SUPER_SIM_HARDWARE_BULK = "wireless-super-sim-hardware-bulk" + WIRELESS_SUPER_SIM_SMSCOMMANDS = "wireless-super-sim-smscommands" + WIRELESS_SUPER_SIM_SMSCOMMANDS_AFRICA = "wireless-super-sim-smscommands-africa" + WIRELESS_SUPER_SIM_SMSCOMMANDS_ASIA = "wireless-super-sim-smscommands-asia" + WIRELESS_SUPER_SIM_SMSCOMMANDS_CENT_AND_SOUTH_AMERICA = ( + "wireless-super-sim-smscommands-cent-and-south-america" + ) + WIRELESS_SUPER_SIM_SMSCOMMANDS_EUROPE = "wireless-super-sim-smscommands-europe" + WIRELESS_SUPER_SIM_SMSCOMMANDS_NORTH_AMERICA = ( + "wireless-super-sim-smscommands-north-america" + ) + WIRELESS_SUPER_SIM_SMSCOMMANDS_OCEANIA = ( + "wireless-super-sim-smscommands-oceania" + ) + WIRELESS_SUPER_SIM_SUBSCRIPTION = "wireless-super-sim-subscription" + WIRELESS_SUPER_SIM_SUBSCRIPTION_PAYG = "wireless-super-sim-subscription-payg" WIRELESS_USAGE = "wireless-usage" WIRELESS_USAGE_COMMANDS = "wireless-usage-commands" WIRELESS_USAGE_COMMANDS_AFRICA = "wireless-usage-commands-africa" @@ -350,6 +664,184 @@ class Category(object): WIRELESS_USAGE_MRC_SUSPENDED = "wireless-usage-mrc-suspended" WIRELESS_USAGE_SMS = "wireless-usage-sms" WIRELESS_USAGE_VOICE = "wireless-usage-voice" + A2P_FAST_TRACK_ONBOARDING = "a2p-fast-track-onboarding" + ADVISORY_SERVICES = "advisory-services" + ADVISORY_SERVICES_BILLED = "advisory-services-billed" + ADVISORY_SERVICES_CALL_TRACKING = "advisory-services-call-tracking" + ADVISORY_SERVICES_DATA_SERVICES = "advisory-services-data-services" + ADVISORY_SERVICES_EXPENSES = "advisory-services-expenses" + ADVISORY_SERVICES_SIP_TRUNKING = "advisory-services-sip-trunking" + ASSETS_REQUESTS = "assets-requests" + AUDIENCE_MINUTES_VIDEO = "audience-minutes-video" + AUTHY_BUCKET_ADJUSTMENT = "authy-bucket-adjustment" + AUTHY_SOFTWARE = "authy-software" + CALLERIDLOOKUPS_API = "calleridlookups-api" + CALLERIDLOOKUPS_PROGRAMMABLEVOICE = "calleridlookups-programmablevoice" + CALLERIDLOOKUPS_TRUNKING = "calleridlookups-trunking" + CALLS_TRUNKING_INBOUND_TOLLFREE_LOCAL = "calls-trunking-inbound-tollfree-local" + CALLS_TRUNKING_INBOUND_TOLLFREE_MOBILE = ( + "calls-trunking-inbound-tollfree-mobile" + ) + CHANNELS_WHATSAPP_CONVERSATION_FREE_1 = "channels-whatsapp-conversation-free-1" + CONFERENCE = "conference" + CONVERSATIONAL_INSIGHTS = "conversational-insights" + CONVERSATIONAL_INSIGHTS_MESSAGES = "conversational-insights-messages" + CONVERSATIONAL_INSIGHTS_VOICE_MINUTES = "conversational-insights-voice-minutes" + DEMO = "demo" + DEMO_UC_SCRIPT_TEST = "demo-uc-script-test" + ELASTIC_SIP_TRUNKING = "elastic-sip-trunking" + ELASTIC_SIP_TRUNKING_CALL_TRANSFERS = "elastic-sip-trunking-call-transfers" + ENTERPRISE_HIPPA = "enterprise-hippa" + FLEX_NAMED_USERS = "flex-named-users" + FLEX_SPINSCI = "flex-spinsci" + FLEX_USERS_1 = "flex-users-1" + FLEX_WFO_PREMIUM_SPEECH_ANALYTICS = "flex-wfo-premium-speech-analytics" + FLEX_XCELERATE = "flex-xcelerate" + FUNCTIONS_ROLLUP = "functions-rollup" + IMP_V1_USAGE = "imp-v1-usage" + IP_MESSAGING_ADDONS = "ip-messaging-addons" + IVR = "ivr" + IVR_CONVERSATIONAL = "ivr-conversational" + IVR_DTMF = "ivr-dtmf" + IVR_VIRTUALAGENT = "ivr-virtualagent" + LIVE = "live" + LIVE_MEDIA_RECORDING_MINUTES = "live-media-recording-minutes" + LONGCODE_MPS = "longcode-mps" + MARKETPLACE_ANALYTICS_ADDONS = "marketplace-analytics-addons" + MARKETPLACE_ISV_ADDONS = "marketplace-isv-addons" + MARKETPLACE_MESSAGING_ADDONS = "marketplace-messaging-addons" + MARKETPLACE_PHONENUMBERS_ADDONS = "marketplace-phonenumbers-addons" + MARKETPLACE_RECORDING_ADDONS = "marketplace-recording-addons" + MARKETPLACE_VIRTUALAGENT_ADDONS = "marketplace-virtualagent-addons" + MARKETPLAY_PAY_ADDONS_SHUTTLE_PAY_CONNECTOR_1 = ( + "marketplay-pay-addons-shuttle-pay-connector-1" + ) + MARKETPLAY_PAY_ADDONS_STRIPE_PAY_CONNECTOR = ( + "marketplay-pay-addons-stripe-pay-connector" + ) + MMS_INBOUND_LONGCODE_CANADA = "mms-inbound-longcode-canada" + MMS_INBOUND_LONGCODE_UNITEDSTATES = "mms-inbound-longcode-unitedstates" + MMS_OUTBOUND_LONGCODE_CANADA = "mms-outbound-longcode-canada" + MMS_OUTBOUND_LONGCODE_UNITEDSTATES = "mms-outbound-longcode-unitedstates" + MMS_OUTBOUND_TOLL_FREE = "mms-outbound-toll-free" + NOTIFY_CHATAPPSANDOTHERCHANNELS = "notify-chatappsandotherchannels" + NOTIFY_NOTIFYSERVICES = "notify-notifyservices" + NOTIFY_PUSHNOTIFICATIONS = "notify-pushnotifications" + PAYMENT_GATEWAY_CONNECTORS = "payment-gateway-connectors" + PAYMENT_SOLUTIONS = "payment-solutions" + PCHAT_BUCKET_ADJUSTMENT = "pchat-bucket-adjustment" + PHONENUMBERS_NUMBERS = "phonenumbers-numbers" + PROG_VOICE_CLIENT_ANDROID = "prog-voice-client-android" + PROG_VOICE_CLIENT_ANDROID_INBOUND = "prog-voice-client-android-inbound" + PROG_VOICE_CLIENT_ANDROID_OUTBOUND = "prog-voice-client-android-outbound" + PROG_VOICE_CLIENT_IOS = "prog-voice-client-ios" + PROG_VOICE_CLIENT_IOS_INBOUND = "prog-voice-client-ios-inbound" + PROG_VOICE_CLIENT_IOS_OUTBOUND = "prog-voice-client-ios-outbound" + PROG_VOICE_CLIENT_SDK = "prog-voice-client-sdk" + PROG_VOICE_CLIENT_WEB = "prog-voice-client-web" + PROG_VOICE_CLIENT_WEB_INBOUND = "prog-voice-client-web-inbound" + PROG_VOICE_CLIENT_WEB_OUTBOUND = "prog-voice-client-web-outbound" + PROGRAMMABLEVOICECONNECTIVITY_MEDIA_STREAMS = ( + "programmablevoiceconnectivity-media-streams" + ) + PSTNCONNECTIVITY_BYOC = "pstnconnectivity-byoc" + PSTNCONNECTIVITY_EMERGENCY = "pstnconnectivity-emergency" + PSTNCONNECTIVITY_MINUTES = "pstnconnectivity-minutes" + PSTNCONNECTIVITY_MINUTES_1 = "pstnconnectivity-minutes-1" + PSTNCONNECTIVITY_MINUTESINBOUNDLOCAL = "pstnconnectivity-minutesinboundlocal" + PSTNCONNECTIVITY_MINUTESINBOUNDMOBILE = "pstnconnectivity-minutesinboundmobile" + PSTNCONNECTIVITY_MINUTESINBOUNDTOLLFREE = ( + "pstnconnectivity-minutesinboundtollfree" + ) + PSTNCONNECTIVITY_MINUTESINBOUNDTOLLFREELOCAL = ( + "pstnconnectivity-minutesinboundtollfreelocal" + ) + PSTNCONNECTIVITY_MINUTESINBOUNDTOLLFREEMOBILE = ( + "pstnconnectivity-minutesinboundtollfreemobile" + ) + PV_ROOM_HOURS = "pv-room-hours" + PV_ROOM_SIMULTANEOUS_PARTICIPANT_CONNECTIONS = ( + "pv-room-simultaneous-participant-connections" + ) + PVIDEO_ROOM_HOURS_AU1 = "pvideo-room-hours-au1" + PVIDEO_ROOM_HOURS_BR1 = "pvideo-room-hours-br1" + PVIDEO_ROOM_HOURS_IE1 = "pvideo-room-hours-ie1" + PVIDEO_ROOM_HOURS_JP1 = "pvideo-room-hours-jp1" + PVIDEO_ROOM_HOURS_SG1 = "pvideo-room-hours-sg1" + PVIDEO_ROOM_HOURS_US1 = "pvideo-room-hours-us1" + PVIDEO_ROOM_HOURS_US2 = "pvideo-room-hours-us2" + RECORDINGS_ENCRYPTED = "recordings-encrypted" + SHORT_CODE_SETUP_FEES = "short-code-setup-fees" + SHORTCODES_MESSAGES_INBOUND = "shortcodes-messages-inbound" + SHORTCODES_MESSAGES_OUTBOUND = "shortcodes-messages-outbound" + SMS_MESSAGES_REGISTRATIONFEES = "sms-messages-registrationfees" + SMS_MMS_PENALTY_FEES = "sms-mms-penalty-fees" + SMS_MMS_PENALTY_FEES_1 = "sms-mms-penalty-fees-1" + SMS_PUMPING_PROTECTION_NON_USCA = "sms-pumping-protection-non-usca" + SMS_PUMPING_PROTECTION_USCA = "sms-pumping-protection-usca" + STUDIO = "studio" + STUDIO_MONTHLY_FEES = "studio-monthly-fees" + SUPERSIM = "supersim" + TASK_ROUTER = "task-router" + TASK_ROUTER_WORKERS = "task-router-workers" + TEST_QUOTA_BUCKETS = "test-quota-buckets" + TEST_UC_SCRIPT_1 = "test-uc-script-1" + TEST_UC_SCRIPT_DEMO_2 = "test-uc-script-demo-2" + TEXT_TO_SPEECH = "text-to-speech" + TME = "tme" + TTS_BASIC = "tts-basic" + TWILIO_EDITIONS = "twilio-editions" + TWILIO_INTERCONNECT_CALIFORNIA = "twilio-interconnect-california" + TWILIO_INTERCONNECT_CALIFORNIA_MONTHLY = ( + "twilio-interconnect-california-monthly" + ) + TWILIO_INTERCONNECT_CALIFORNIA_SETUP = "twilio-interconnect-california-setup" + TWILIO_INTERCONNECT_FRANKFURT = "twilio-interconnect-frankfurt" + TWILIO_INTERCONNECT_FRANKFURT_MO = "twilio-interconnect-frankfurt-mo" + TWILIO_INTERCONNECT_FRANKFURT_SETUP = "twilio-interconnect-frankfurt-setup" + TWILIO_INTERCONNECT_LONDON = "twilio-interconnect-london" + TWILIO_INTERCONNECT_LONDON_MO = "twilio-interconnect-london-mo" + TWILIO_INTERCONNECT_LONDON_SETUP = "twilio-interconnect-london-setup" + TWILIO_INTERCONNECT_SAO_PAULO = "twilio-interconnect-sao-paulo" + TWILIO_INTERCONNECT_SAO_PAULO_MONTHLY = "twilio-interconnect-sao-paulo-monthly" + TWILIO_INTERCONNECT_SAO_PAULO_SETUP = "twilio-interconnect-sao-paulo-setup" + TWILIO_INTERCONNECT_SINGAPORE = "twilio-interconnect-singapore" + TWILIO_INTERCONNECT_SINGAPORE_MO = "twilio-interconnect-singapore-mo" + TWILIO_INTERCONNECT_SINGAPORE_SETUP = "twilio-interconnect-singapore-setup" + TWILIO_INTERCONNECT_SYDNEY = "twilio-interconnect-sydney" + TWILIO_INTERCONNECT_SYDNEY_MO = "twilio-interconnect-sydney-mo" + TWILIO_INTERCONNECT_SYDNEY_SETUP = "twilio-interconnect-sydney-setup" + TWILIO_INTERCONNECT_TOKYO = "twilio-interconnect-tokyo" + TWILIO_INTERCONNECT_TOKYO_MO = "twilio-interconnect-tokyo-mo" + TWILIO_INTERCONNECT_TOKYO_SETUP = "twilio-interconnect-tokyo-setup" + TWILIO_INTERCONNECT_VA = "twilio-interconnect-va" + TWILIO_INTERCONNECT_VA_MO = "twilio-interconnect-va-mo" + TWILIO_INTERCONNECT_VA_SETUP = "twilio-interconnect-va-setup" + TWIML_VERBS = "twiml-verbs" + TWIML_VERBS_SAY = "twiml-verbs-say" + USAGE_PROGRAMMABLE_MESSAGING_ENGAGEMENT_SUITE = ( + "usage-programmable-messaging-engagement-suite" + ) + USAGE_PROGRAMMABLE_MESSAGING_FEES_SERVICES = ( + "usage-programmable-messaging-fees-services" + ) + VERIFY_OUTBOUND_EMAIL = "verify-outbound-email" + VERIFY_PACKAGED_PLANS = "verify-packaged-plans" + VERIFY_SILENT_NETWORK_AUTH = "verify-silent-network-auth" + VERIFY_VOICE_AND_SMS = "verify-voice-and-sms" + VOICE_INSIGHTS_CLIENT_INSIGHTS_MONTHY_COMMIT = ( + "voice-insights-client-insights-monthy-commit" + ) + WIRELESS_DATA_PAYG_ASIA_AFG = "wireless-data-payg-asia-afg" + WIRELESS_MULTI_IMSI_SIM_COMMANDS = "wireless-multi-imsi-sim-commands" + WIRELESS_MULTI_IMSI_SIM_COMMANDS_USA = "wireless-multi-imsi-sim-commands-usa" + WIRELESS_MULTI_IMSI_SIM_DATA = "wireless-multi-imsi-sim-data" + WIRELESS_MULTI_IMSI_SIM_DATA_EU28 = "wireless-multi-imsi-sim-data-eu28" + WIRELESS_MULTI_IMSI_SIM_DATA_USA = "wireless-multi-imsi-sim-data-usa" + WIRELESS_MULTI_IMSI_SIM_MONTHLY_FEES = "wireless-multi-imsi-sim-monthly-fees" + WIRELESS_MULTI_IMSI_SIM_USAGE = "wireless-multi-imsi-sim-usage" + WIRELESS_SUPER_SIM_DATA_NORTH_AMERICA = "wireless-super-sim-data-north-america" + WIRELESS_SUPER_SIM_USAGE = "wireless-super-sim-usage" """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that accrued the usage. @@ -409,6 +901,7 @@ def __repr__(self) -> str: class RecordPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> RecordInstance: """ Build an instance of RecordInstance @@ -429,6 +922,7 @@ def __repr__(self) -> str: class RecordList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the RecordList @@ -640,14 +1134,20 @@ def page( "Category": category, "StartDate": serialize.iso8601_date(start_date), "EndDate": serialize.iso8601_date(end_date), - "IncludeSubaccounts": include_subaccounts, + "IncludeSubaccounts": serialize.boolean_to_string(include_subaccounts), "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 RecordPage(self._version, response, self._solution) async def page_async( @@ -679,15 +1179,19 @@ async def page_async( "Category": category, "StartDate": serialize.iso8601_date(start_date), "EndDate": serialize.iso8601_date(end_date), - "IncludeSubaccounts": include_subaccounts, + "IncludeSubaccounts": serialize.boolean_to_string(include_subaccounts), "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 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 0086997c79..991f4a0b70 100644 --- a/twilio/rest/api/v2010/account/usage/record/all_time.py +++ b/twilio/rest/api/v2010/account/usage/record/all_time.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import date from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import deserialize, serialize, values @@ -24,34 +23,103 @@ class AllTimeInstance(InstanceResource): + class Category(object): + A2P_10DLC_REGISTRATIONFEES_BRANDREGISTRATION = ( + "a2p-10dlc-registrationfees-brandregistration" + ) + A2P_10DLC_REGISTRATIONFEES_BV = "a2p-10dlc-registrationfees-bv" + A2P_10DLC_REGISTRATIONFEES_CAMPAIGNCHARGES = ( + "a2p-10dlc-registrationfees-campaigncharges" + ) + A2P_10DLC_REGISTRATIONFEES_CAMPAIGNREGISTRATION = ( + "a2p-10dlc-registrationfees-campaignregistration" + ) + A2P_10DLC_REGISTRATIONFEES_CAMPAIGNVETTING = ( + "a2p-10dlc-registrationfees-campaignvetting" + ) + A2P_10DLC_REGISTRATIONFEES_MONTHLY = "a2p-10dlc-registrationfees-monthly" + A2P_10DLC_REGISTRATIONFEES_ONETIME = "a2p-10dlc-registrationfees-onetime" A2P_REGISTRATION_FEES = "a2p-registration-fees" + ACCOUNT_SECURITY = "account-security" AGENT_CONFERENCE = "agent-conference" + AGENT_COPILOT = "agent-copilot" + AGENT_COPILOT_MESSAGES = "agent-copilot-messages" + AGENT_COPILOT_PARTICIPANT_MINUTES = "agent-copilot-participant-minutes" + AI_ASSISTANTS = "ai-assistants" + AI_ASSISTANTS_VOICE = "ai-assistants-voice" AMAZON_POLLY = "amazon-polly" ANSWERING_MACHINE_DETECTION = "answering-machine-detection" + ASSETS = "assets" + AUDIENCE_MINUTES = "audience-minutes" + AUDIENCE_MINUTES_AUDIO = "audience-minutes-audio" AUTHY_AUTHENTICATIONS = "authy-authentications" AUTHY_CALLS_OUTBOUND = "authy-calls-outbound" + AUTHY_EMAIL_AUTHENTICATIONS = "authy-email-authentications" AUTHY_MONTHLY_FEES = "authy-monthly-fees" + AUTHY_OUTBOUND_EMAIL = "authy-outbound-email" AUTHY_PHONE_INTELLIGENCE = "authy-phone-intelligence" AUTHY_PHONE_VERIFICATIONS = "authy-phone-verifications" AUTHY_SMS_OUTBOUND = "authy-sms-outbound" + AUTHY_VERIFY_EMAIL_VERIFICATIONS = "authy-verify-email-verifications" + AUTHY_VERIFY_OUTBOUND_EMAIL = "authy-verify-outbound-email" + AUTOPILOT = "autopilot" + AUTOPILOT_HOME_ASSISTANTS = "autopilot-home-assistants" + AUTOPILOT_MESSAGING = "autopilot-messaging" + AUTOPILOT_OTHER = "autopilot-other" + AUTOPILOT_VOICE = "autopilot-voice" + BASIC_PEER_TO_PEER_ROOMS_PARTICIPANT_MINUTES = ( + "basic-peer-to-peer-rooms-participant-minutes" + ) + BRANDED_CALLING = "branded-calling" + BUNDLE_SMS_BUCKET = "bundle-sms-bucket" + BUNDLE_SUBSCRIPTION_FEES = "bundle-subscription-fees" + CALL_FORWARDING_LOOKUPS = "call-forwarding-lookups" CALL_PROGESS_EVENTS = "call-progess-events" CALLERIDLOOKUPS = "calleridlookups" CALLS = "calls" CALLS_CLIENT = "calls-client" + CALLS_EMERGENCY = "calls-emergency" CALLS_GLOBALCONFERENCE = "calls-globalconference" CALLS_INBOUND = "calls-inbound" CALLS_INBOUND_LOCAL = "calls-inbound-local" CALLS_INBOUND_MOBILE = "calls-inbound-mobile" CALLS_INBOUND_TOLLFREE = "calls-inbound-tollfree" + CALLS_INBOUND_TOLLFREE_LOCAL = "calls-inbound-tollfree-local" + CALLS_INBOUND_TOLLFREE_MOBILE = "calls-inbound-tollfree-mobile" + CALLS_MEDIA_STREAM_MINUTES = "calls-media-stream-minutes" CALLS_OUTBOUND = "calls-outbound" CALLS_PAY_VERB_TRANSACTIONS = "calls-pay-verb-transactions" CALLS_RECORDINGS = "calls-recordings" CALLS_SIP = "calls-sip" CALLS_SIP_INBOUND = "calls-sip-inbound" CALLS_SIP_OUTBOUND = "calls-sip-outbound" + CALLS_TEXT_TO_SPEECH = "calls-text-to-speech" CALLS_TRANSFERS = "calls-transfers" CARRIER_LOOKUPS = "carrier-lookups" + CATEGORY = "category" + CHANNELS = "channels" + CHANNELS_MESSAGING = "channels-messaging" + CHANNELS_MESSAGING_INBOUND = "channels-messaging-inbound" + CHANNELS_MESSAGING_OUTBOUND = "channels-messaging-outbound" + CHANNELS_WHATSAPP = "channels-whatsapp" + CHANNELS_WHATSAPP_CONVERSATION_AUTHENTICATION = ( + "channels-whatsapp-conversation-authentication" + ) + CHANNELS_WHATSAPP_CONVERSATION_FREE = "channels-whatsapp-conversation-free" + CHANNELS_WHATSAPP_CONVERSATION_MARKETING = ( + "channels-whatsapp-conversation-marketing" + ) + CHANNELS_WHATSAPP_CONVERSATION_SERVICE = ( + "channels-whatsapp-conversation-service" + ) + CHANNELS_WHATSAPP_CONVERSATION_UTILITY = ( + "channels-whatsapp-conversation-utility" + ) + CHANNELS_WHATSAPP_INBOUND = "channels-whatsapp-inbound" + CHANNELS_WHATSAPP_OUTBOUND = "channels-whatsapp-outbound" + CHAT_VIRTUAL_AGENT = "chat-virtual-agent" + CONVERSATION_RELAY = "conversation-relay" CONVERSATIONS = "conversations" CONVERSATIONS_API_REQUESTS = "conversations-api-requests" CONVERSATIONS_CONVERSATION_EVENTS = "conversations-conversation-events" @@ -60,8 +128,40 @@ class Category(object): CONVERSATIONS_PARTICIPANT_EVENTS = "conversations-participant-events" CONVERSATIONS_PARTICIPANTS = "conversations-participants" CPS = "cps" + CREDIT_TRANSFER = "credit-transfer" + EMAIL = "email" + EMERGING_TECH = "emerging-tech" + ENGAGEMENT_SUITE_PACKAGED_PLANS = "engagement-suite-packaged-plans" + ENHANCED_LINE_TYPE_LOOKUPS = "enhanced-line-type-lookups" + ENTERPRISE = "enterprise" + EVENTS = "events" + EXPERIMENT_FRANCE_SMS = "experiment-france-sms" + EXPERIMENT_INDIA_SMS = "experiment-india-sms" + EXPERIMENT_UK_SMS = "experiment-uk-sms" + FAILED_MESSAGE_PROCESSING_FEE = "failed-message-processing-fee" + FLEX = "flex" + FLEX_ACTIVE_USER_HOURS = "flex-active-user-hours" + FLEX_CONCURRENT_USERS = "flex-concurrent-users" + FLEX_CONVERSATIONAL_INSIGHTS = "flex-conversational-insights" + FLEX_CONVERSATIONAL_INSIGHTS_MESSAGES = "flex-conversational-insights-messages" + FLEX_CONVERSATIONAL_INSIGHTS_VOICE_MINUTES = ( + "flex-conversational-insights-voice-minutes" + ) + FLEX_EMAIL_USAGE = "flex-email-usage" + FLEX_MESSAGING_USAGE = "flex-messaging-usage" + FLEX_PARTNER_SPINSCI = "flex-partner-spinsci" + FLEX_PARTNER_XCELERATE = "flex-partner-xcelerate" + FLEX_RESELLER_ECOSYSTEM = "flex-reseller-ecosystem" + FLEX_UNIQUE_USER = "flex-unique-user" FLEX_USAGE = "flex-usage" + FLEX_USERS = "flex-users" + FLEX_VOICE_MINUTE = "flex-voice-minute" + FLEX_YTICA = "flex-ytica" FRAUD_LOOKUPS = "fraud-lookups" + FRONTLINE = "frontline" + FRONTLINE_USERS = "frontline-users" + FUNCTIONS = "functions" + GENERIC_PAY_TRANSACTIONS = "generic-pay-transactions" GROUP_ROOMS = "group-rooms" GROUP_ROOMS_DATA_TRACK = "group-rooms-data-track" GROUP_ROOMS_ENCRYPTED_MEDIA_RECORDED = "group-rooms-encrypted-media-recorded" @@ -71,7 +171,17 @@ class Category(object): GROUP_ROOMS_MEDIA_STORED = "group-rooms-media-stored" GROUP_ROOMS_PARTICIPANT_MINUTES = "group-rooms-participant-minutes" GROUP_ROOMS_RECORDED_MINUTES = "group-rooms-recorded-minutes" - IMP_V1_USAGE = "imp-v1-usage" + IP_MESSAGING = "ip-messaging" + IP_MESSAGING_COMMANDS = "ip-messaging-commands" + IP_MESSAGING_DATA_STORAGE = "ip-messaging-data-storage" + IP_MESSAGING_DATA_TRANSFER = "ip-messaging-data-transfer" + IP_MESSAGING_ENDPOINT_CONNECTIVITY = "ip-messaging-endpoint-connectivity" + IVR_VIRTUAL_AGENT_CUSTOM_VOICES = "ivr-virtual-agent-custom-voices" + IVR_VIRTUAL_AGENT_GENAI = "ivr-virtual-agent-genai" + LINE_STATUS_LOOKUPS = "line-status-lookups" + LIVE_ACTIVITY_LOOKUPS = "live-activity-lookups" + LOOKUP_BUCKET_ADJUSTMENT = "lookup-bucket-adjustment" + LOOKUP_IDENTITY_MATCH = "lookup-identity-match" LOOKUPS = "lookups" MARKETPLACE = "marketplace" MARKETPLACE_ALGORITHMIA_NAMED_ENTITY_RECOGNITION = ( @@ -82,6 +192,13 @@ class Category(object): MARKETPLACE_CAPIO_SPEECH_TO_TEXT = "marketplace-capio-speech-to-text" MARKETPLACE_CONVRIZA_ABABA = "marketplace-convriza-ababa" MARKETPLACE_DEEPGRAM_PHRASE_DETECTOR = "marketplace-deepgram-phrase-detector" + MARKETPLACE_DEEPGRAM_TRANSCRIPTION = "marketplace-deepgram-transcription" + MARKETPLACE_DEEPGRAM_TRANSCRIPTION_BASE = ( + "marketplace-deepgram-transcription-base" + ) + MARKETPLACE_DEEPGRAM_TRANSSCRIPTION_ENHANCED = ( + "marketplace-deepgram-transscription-enhanced" + ) MARKETPLACE_DIGITAL_SEGMENT_BUSINESS_INFO = ( "marketplace-digital-segment-business-info" ) @@ -107,6 +224,9 @@ class Category(object): "marketplace-keen-io-contact-center-analytics" ) MARKETPLACE_MARCHEX_CLEANCALL = "marketplace-marchex-cleancall" + MARKETPLACE_MARCHEX_RECORDING_ANALYSIS = ( + "marketplace-marchex-recording-analysis" + ) MARKETPLACE_MARCHEX_SENTIMENT_ANALYSIS_FOR_SMS = ( "marketplace-marchex-sentiment-analysis-for-sms" ) @@ -123,14 +243,42 @@ class Category(object): "marketplace-nextcaller-advanced-caller-identification" ) MARKETPLACE_NOMOROBO_SPAM_SCORE = "marketplace-nomorobo-spam-score" + MARKETPLACE_PAY_ADDONS = "marketplace-pay-addons" + MARKETPLACE_PAY_ADDONS_BASECOMMERCE_PAY_CONNECTOR = ( + "marketplace-pay-addons-basecommerce-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_BRAINTREE_PAY_CONNECTOR = ( + "marketplace-pay-addons-braintree-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_CARDCONNECT_PAY_CONNECTOR = ( + "marketplace-pay-addons-cardconnect-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_CHASE_PAY_CONNECTOR = ( + "marketplace-pay-addons-chase-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_SHUTTLE_PAY_CONNECTOR = ( + "marketplace-pay-addons-shuttle-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_STRIPE_PAY_CONNECTOR = ( + "marketplace-pay-addons-stripe-pay-connector" + ) MARKETPLACE_PAYFONE_TCPA_COMPLIANCE = "marketplace-payfone-tcpa-compliance" + MARKETPLACE_POLY_AI_CONNECTOR = "marketplace-poly-ai-connector" + MARKETPLACE_REALPHONEVALIDATION = "marketplace-realphonevalidation" MARKETPLACE_REMEETING_AUTOMATIC_SPEECH_RECOGNITION = ( "marketplace-remeeting-automatic-speech-recognition" ) + MARKETPLACE_SPOKE_PHONE_LICENSE_PRO = "marketplace-spoke-phone-license-pro" + MARKETPLACE_SPOKE_PHONE_LICENSE_STANDARD = ( + "marketplace-spoke-phone-license-standard" + ) MARKETPLACE_TCPA_DEFENSE_SOLUTIONS_BLACKLIST_FEED = ( "marketplace-tcpa-defense-solutions-blacklist-feed" ) MARKETPLACE_TELO_OPENCNAM = "marketplace-telo-opencnam" + MARKETPLACE_TRESTLE_SOLUTIONS_CALLER_IDENTIFICATION = ( + "marketplace-trestle-solutions-caller-identification" + ) MARKETPLACE_TRUECNAM_TRUE_SPAM = "marketplace-truecnam-true-spam" MARKETPLACE_TWILIO_CALLER_NAME_LOOKUP_US = ( "marketplace-twilio-caller-name-lookup-us" @@ -143,6 +291,9 @@ class Category(object): MARKETPLACE_VOICEBASE_TRANSCRIPTION_CUSTOM_VOCABULARY = ( "marketplace-voicebase-transcription-custom-vocabulary" ) + MARKETPLACE_WEB_PURIFY_PROFANITY_FILTER = ( + "marketplace-web-purify-profanity-filter" + ) MARKETPLACE_WHITEPAGES_PRO_CALLER_IDENTIFICATION = ( "marketplace-whitepages-pro-caller-identification" ) @@ -157,15 +308,23 @@ class Category(object): MARKETPLACE_YTICA_CONTACT_CENTER_REPORTING_ANALYTICS = ( "marketplace-ytica-contact-center-reporting-analytics" ) + MARKETPLAY_PAY_ADDONS_SHUTTLE_PAY_CONNECTOR = ( + "marketplay-pay-addons-shuttle-pay-connector" + ) + MEDIA_COMPOSER_MINUTES = "media-composer-minutes" MEDIASTORAGE = "mediastorage" + MIN_SPEND_ADJUSTMENTS = "min-spend-adjustments" MMS = "mms" MMS_INBOUND = "mms-inbound" MMS_INBOUND_LONGCODE = "mms-inbound-longcode" MMS_INBOUND_SHORTCODE = "mms-inbound-shortcode" + MMS_INBOUND_TOLL_FREE = "mms-inbound-toll-free" MMS_MESSAGES_CARRIERFEES = "mms-messages-carrierfees" MMS_OUTBOUND = "mms-outbound" MMS_OUTBOUND_LONGCODE = "mms-outbound-longcode" MMS_OUTBOUND_SHORTCODE = "mms-outbound-shortcode" + MMS_OUTBOUND_TOLLFREE = "mms-outbound-tollfree" + MONITOR = "monitor" MONITOR_READS = "monitor-reads" MONITOR_STORAGE = "monitor-storage" MONITOR_WRITES = "monitor-writes" @@ -174,6 +333,12 @@ class Category(object): NOTIFY_CHANNELS = "notify-channels" NUMBER_FORMAT_LOOKUPS = "number-format-lookups" PCHAT = "pchat" + PCHAT_ACTIONS = "pchat-actions" + PCHAT_APS = "pchat-aps" + PCHAT_CONV_MED_STORAGE = "pchat-conv-med-storage" + PCHAT_MESSAGES = "pchat-messages" + PCHAT_NOTIFICATIONS = "pchat-notifications" + PCHAT_READS = "pchat-reads" PCHAT_USERS = "pchat-users" PEER_TO_PEER_ROOMS_PARTICIPANT_MINUTES = ( "peer-to-peer-rooms-participant-minutes" @@ -183,18 +348,41 @@ class Category(object): PFAX_MINUTES_INBOUND = "pfax-minutes-inbound" PFAX_MINUTES_OUTBOUND = "pfax-minutes-outbound" PFAX_PAGES = "pfax-pages" + PHONE_QUALITY_SCORE_LOOKUPS = "phone-quality-score-lookups" PHONENUMBERS = "phonenumbers" PHONENUMBERS_CPS = "phonenumbers-cps" PHONENUMBERS_EMERGENCY = "phonenumbers-emergency" PHONENUMBERS_LOCAL = "phonenumbers-local" PHONENUMBERS_MOBILE = "phonenumbers-mobile" + PHONENUMBERS_PORTING = "phonenumbers-porting" PHONENUMBERS_SETUPS = "phonenumbers-setups" PHONENUMBERS_TOLLFREE = "phonenumbers-tollfree" PREMIUMSUPPORT = "premiumsupport" + PREMIUMSUPPORT_PERCENTAGE_SPEND = "premiumsupport-percentage-spend" + PROGRAMMABLEVOICE_PLATFORM = "programmablevoice-platform" + PROGRAMMABLEVOICECONN_CLIENTSDK = "programmablevoiceconn-clientsdk" + PROGRAMMABLEVOICECONN_CLIENTSDK_INBOUND = ( + "programmablevoiceconn-clientsdk-inbound" + ) + PROGRAMMABLEVOICECONN_CLIENTSDK_OUTBOUND = ( + "programmablevoiceconn-clientsdk-outbound" + ) + PROGRAMMABLEVOICECONN_ONNET = "programmablevoiceconn-onnet" + PROGRAMMABLEVOICECONN_ONNET_INBOUND = "programmablevoiceconn-onnet-inbound" + PROGRAMMABLEVOICECONN_ONNET_OUTBOUND = "programmablevoiceconn-onnet-outbound" + PROGRAMMABLEVOICECONN_SIP = "programmablevoiceconn-sip" + PROGRAMMABLEVOICECONN_SIP_INBOUND = "programmablevoiceconn-sip-inbound" + PROGRAMMABLEVOICECONN_SIP_OUTBOUND = "programmablevoiceconn-sip-outbound" + PROGRAMMABLEVOICECONNECTIVITY = "programmablevoiceconnectivity" PROXY = "proxy" PROXY_ACTIVE_SESSIONS = "proxy-active-sessions" + PROXY_BUCKET_ADJUSTMENT = "proxy-bucket-adjustment" + PROXY_LICENSES = "proxy-licenses" PSTNCONNECTIVITY = "pstnconnectivity" + PSTNCONNECTIVITY_INBOUND = "pstnconnectivity-inbound" + PSTNCONNECTIVITY_OUTBOUND = "pstnconnectivity-outbound" PV = "pv" + PV_BASIC_ROOMS = "pv-basic-rooms" PV_COMPOSITION_MEDIA_DOWNLOADED = "pv-composition-media-downloaded" PV_COMPOSITION_MEDIA_ENCRYPTED = "pv-composition-media-encrypted" PV_COMPOSITION_MEDIA_STORED = "pv-composition-media-stored" @@ -210,18 +398,20 @@ class Category(object): PV_ROOM_PARTICIPANTS_US2 = "pv-room-participants-us2" PV_ROOMS = "pv-rooms" PV_SIP_ENDPOINT_REGISTRATIONS = "pv-sip-endpoint-registrations" + RCS_MESSAGES = "rcs-messages" + REASSIGNED_NUMBER = "reassigned-number" RECORDINGS = "recordings" RECORDINGSTORAGE = "recordingstorage" - ROOMS_GROUP_BANDWIDTH = "rooms-group-bandwidth" - ROOMS_GROUP_MINUTES = "rooms-group-minutes" - ROOMS_PEER_TO_PEER_MINUTES = "rooms-peer-to-peer-minutes" SHORTCODES = "shortcodes" SHORTCODES_CUSTOMEROWNED = "shortcodes-customerowned" SHORTCODES_MMS_ENABLEMENT = "shortcodes-mms-enablement" SHORTCODES_MPS = "shortcodes-mps" SHORTCODES_RANDOM = "shortcodes-random" + SHORTCODES_SETUP_FEES = "shortcodes-setup-fees" SHORTCODES_UK = "shortcodes-uk" SHORTCODES_VANITY = "shortcodes-vanity" + SIM_SWAP_LOOKUPS = "sim-swap-lookups" + SIP_SECURE_MEDIA = "sip-secure-media" SMALL_GROUP_ROOMS = "small-group-rooms" SMALL_GROUP_ROOMS_DATA_TRACK = "small-group-rooms-data-track" SMALL_GROUP_ROOMS_PARTICIPANT_MINUTES = "small-group-rooms-participant-minutes" @@ -229,13 +419,30 @@ class Category(object): SMS_INBOUND = "sms-inbound" SMS_INBOUND_LONGCODE = "sms-inbound-longcode" SMS_INBOUND_SHORTCODE = "sms-inbound-shortcode" + SMS_INBOUND_TOLLFREE = "sms-inbound-tollfree" SMS_MESSAGES_CARRIERFEES = "sms-messages-carrierfees" SMS_MESSAGES_FEATURES = "sms-messages-features" + SMS_MESSAGES_FEATURES_ENGAGEMENT_SUITE = ( + "sms-messages-features-engagement-suite" + ) + SMS_MESSAGES_FEATURES_MESSAGE_REDACTION = ( + "sms-messages-features-message-redaction" + ) SMS_MESSAGES_FEATURES_SENDERID = "sms-messages-features-senderid" + SMS_MPS = "sms-mps" + SMS_MPS_SHORTCODE = "sms-mps-shortcode" + SMS_MPS_TOLLFREE = "sms-mps-tollfree" + SMS_MPS_TOLLFREE_SETUP = "sms-mps-tollfree-setup" + SMS_NATIONAL_REGULATORY_PROTECTION = "sms-national-regulatory-protection" SMS_OUTBOUND = "sms-outbound" SMS_OUTBOUND_CONTENT_INSPECTION = "sms-outbound-content-inspection" SMS_OUTBOUND_LONGCODE = "sms-outbound-longcode" SMS_OUTBOUND_SHORTCODE = "sms-outbound-shortcode" + SMS_OUTBOUND_TOLLFREE = "sms-outbound-tollfree" + SMS_PUMPING_PROTECTION = "sms-pumping-protection" + SMS_PUMPING_RISK = "sms-pumping-risk" + SMSMESSAGES_BUCKET_ADJUSTMENTS = "smsmessages-bucket-adjustments" + SMSMESSAGES_OUTBOUND_DOMESTIC = "smsmessages-outbound-domestic" SPEECH_RECOGNITION = "speech-recognition" STUDIO_ENGAGEMENTS = "studio-engagements" SYNC = "sync" @@ -254,6 +461,7 @@ class Category(object): TRUNKING_RECORDINGS = "trunking-recordings" TRUNKING_SECURE = "trunking-secure" TRUNKING_TERMINATION = "trunking-termination" + TTS_GOOGLE = "tts-google" TURNMEGABYTES = "turnmegabytes" TURNMEGABYTES_AUSTRALIA = "turnmegabytes-australia" TURNMEGABYTES_BRASIL = "turnmegabytes-brasil" @@ -264,13 +472,27 @@ class Category(object): TURNMEGABYTES_SINGAPORE = "turnmegabytes-singapore" TURNMEGABYTES_USEAST = "turnmegabytes-useast" TURNMEGABYTES_USWEST = "turnmegabytes-uswest" + TWILIO_FOR_SALESFORCE = "twilio-for-salesforce" + TWILIO_FOR_SALESFORCE_LICENSES = "twilio-for-salesforce-licenses" TWILIO_INTERCONNECT = "twilio-interconnect" + TWIML = "twiml" + USAGE_FLEX_VIDEO = "usage-flex-video" + USAGE_FUNCTIONS = "usage-functions" + USAGE_RCS_BASIC_MESSAGES_OUTBOUND = "usage-rcs-basic-messages-outbound" + USAGE_RCS_MESSAGES = "usage-rcs-messages" + USAGE_RCS_MESSAGES_INBOUND = "usage-rcs-messages-inbound" + USAGE_RCS_MESSAGING_CARRIER_FEES = "usage-rcs-messaging-carrier-fees" + USAGE_RCS_SINGLE_MESSAGES_OUTBOUND = "usage-rcs-single-messages-outbound" + VERIFY_PACKAGE_PLANS = "verify-package-plans" VERIFY_PUSH = "verify-push" + VERIFY_SNA = "verify-sna" VERIFY_TOTP = "verify-totp" + VERIFY_VOICE_SMS = "verify-voice-sms" VERIFY_WHATSAPP_CONVERSATIONS_BUSINESS_INITIATED = ( "verify-whatsapp-conversations-business-initiated" ) VIDEO_RECORDINGS = "video-recordings" + VIDEO_ROOMS_TURN_MEGABYTES = "video-rooms-turn-megabytes" VIRTUAL_AGENT = "virtual-agent" VOICE_INSIGHTS = "voice-insights" VOICE_INSIGHTS_CLIENT_INSIGHTS_ON_DEMAND_MINUTE = ( @@ -285,12 +507,104 @@ class Category(object): VOICE_INSIGHTS_SIP_TRUNKING_INSIGHTS_ON_DEMAND_MINUTE = ( "voice-insights-sip-trunking-insights-on-demand-minute" ) + VOICE_INTELLIGENCE = "voice-intelligence" + VOICE_INTELLIGENCE_EIP_OPERATORS = "voice-intelligence-eip-operators" + VOICE_INTELLIGENCE_OPERATORS = "voice-intelligence-operators" + VOICE_INTELLIGENCE_TRANSCRIPTION = "voice-intelligence-transcription" + WDS = "wds" WIRELESS = "wireless" + WIRELESS_DATA = "wireless-data" + WIRELESS_DATA_PAYG = "wireless-data-payg" + WIRELESS_DATA_PAYG_AFRICA = "wireless-data-payg-africa" + WIRELESS_DATA_PAYG_ASIA = "wireless-data-payg-asia" + WIRELESS_DATA_PAYG_CENTRALANDSOUTHAMERICA = ( + "wireless-data-payg-centralandsouthamerica" + ) + WIRELESS_DATA_PAYG_EUROPE = "wireless-data-payg-europe" + WIRELESS_DATA_PAYG_NORTHAMERICA = "wireless-data-payg-northamerica" + WIRELESS_DATA_PAYG_OCEANIA = "wireless-data-payg-oceania" + WIRELESS_DATA_QUOTA1 = "wireless-data-quota1" + WIRELESS_DATA_QUOTA1_AFRICA = "wireless-data-quota1-africa" + WIRELESS_DATA_QUOTA1_ASIA = "wireless-data-quota1-asia" + WIRELESS_DATA_QUOTA1_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quota1-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTA1_EUROPE = "wireless-data-quota1-europe" + WIRELESS_DATA_QUOTA1_NORTHAMERICA = "wireless-data-quota1-northamerica" + WIRELESS_DATA_QUOTA1_OCEANIA = "wireless-data-quota1-oceania" + WIRELESS_DATA_QUOTA10 = "wireless-data-quota10" + WIRELESS_DATA_QUOTA10_AFRICA = "wireless-data-quota10-africa" + WIRELESS_DATA_QUOTA10_ASIA = "wireless-data-quota10-asia" + WIRELESS_DATA_QUOTA10_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quota10-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTA10_EUROPE = "wireless-data-quota10-europe" + WIRELESS_DATA_QUOTA10_NORTHAMERICA = "wireless-data-quota10-northamerica" + WIRELESS_DATA_QUOTA10_OCEANIA = "wireless-data-quota10-oceania" + WIRELESS_DATA_QUOTA50 = "wireless-data-quota50" + WIRELESS_DATA_QUOTA50_AFRICA = "wireless-data-quota50-africa" + WIRELESS_DATA_QUOTA50_ASIA = "wireless-data-quota50-asia" + WIRELESS_DATA_QUOTA50_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quota50-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTA50_EUROPE = "wireless-data-quota50-europe" + WIRELESS_DATA_QUOTA50_NORTHAMERICA = "wireless-data-quota50-northamerica" + WIRELESS_DATA_QUOTA50_OCEANIA = "wireless-data-quota50-oceania" + WIRELESS_DATA_QUOTACUSTOM = "wireless-data-quotacustom" + WIRELESS_DATA_QUOTACUSTOM_AFRICA = "wireless-data-quotacustom-africa" + WIRELESS_DATA_QUOTACUSTOM_ASIA = "wireless-data-quotacustom-asia" + WIRELESS_DATA_QUOTACUSTOM_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quotacustom-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTACUSTOM_EUROPE = "wireless-data-quotacustom-europe" + WIRELESS_DATA_QUOTACUSTOM_NORTHAMERICA = ( + "wireless-data-quotacustom-northamerica" + ) + WIRELESS_DATA_QUOTACUSTOM_OCEANIA = "wireless-data-quotacustom-oceania" + WIRELESS_MRC_PAYG = "wireless-mrc-payg" + WIRELESS_MRC_QUOTA1 = "wireless-mrc-quota1" + WIRELESS_MRC_QUOTA10 = "wireless-mrc-quota10" + WIRELESS_MRC_QUOTA50 = "wireless-mrc-quota50" + WIRELESS_MRC_QUOTACUSTOM = "wireless-mrc-quotacustom" WIRELESS_ORDERS = "wireless-orders" WIRELESS_ORDERS_ARTWORK = "wireless-orders-artwork" WIRELESS_ORDERS_BULK = "wireless-orders-bulk" WIRELESS_ORDERS_ESIM = "wireless-orders-esim" WIRELESS_ORDERS_STARTER = "wireless-orders-starter" + WIRELESS_QUOTAS = "wireless-quotas" + WIRELESS_SMS_AFRICA = "wireless-sms-africa" + WIRELESS_SMS_ASIA = "wireless-sms-asia" + WIRELESS_SMS_CENTRALANDSOUTHAMERICA = "wireless-sms-centralandsouthamerica" + WIRELESS_SMS_EUROPE = "wireless-sms-europe" + WIRELESS_SMS_NORTHAMERICA = "wireless-sms-northamerica" + WIRELESS_SMS_OCEANIA = "wireless-sms-oceania" + WIRELESS_SUPER_SIM = "wireless-super-sim" + WIRELESS_SUPER_SIM_DATA = "wireless-super-sim-data" + WIRELESS_SUPER_SIM_DATA_NORTH_AMERICA_USA = ( + "wireless-super-sim-data-north-america-usa" + ) + WIRELESS_SUPER_SIM_DATA_PAYG = "wireless-super-sim-data-payg" + WIRELESS_SUPER_SIM_DATA_PAYG_EUROPE = "wireless-super-sim-data-payg-europe" + WIRELESS_SUPER_SIM_DATA_PAYG_NORTH_AMERICA = ( + "wireless-super-sim-data-payg-north-america" + ) + WIRELESS_SUPER_SIM_HARDWARE = "wireless-super-sim-hardware" + WIRELESS_SUPER_SIM_HARDWARE_BULK = "wireless-super-sim-hardware-bulk" + WIRELESS_SUPER_SIM_SMSCOMMANDS = "wireless-super-sim-smscommands" + WIRELESS_SUPER_SIM_SMSCOMMANDS_AFRICA = "wireless-super-sim-smscommands-africa" + WIRELESS_SUPER_SIM_SMSCOMMANDS_ASIA = "wireless-super-sim-smscommands-asia" + WIRELESS_SUPER_SIM_SMSCOMMANDS_CENT_AND_SOUTH_AMERICA = ( + "wireless-super-sim-smscommands-cent-and-south-america" + ) + WIRELESS_SUPER_SIM_SMSCOMMANDS_EUROPE = "wireless-super-sim-smscommands-europe" + WIRELESS_SUPER_SIM_SMSCOMMANDS_NORTH_AMERICA = ( + "wireless-super-sim-smscommands-north-america" + ) + WIRELESS_SUPER_SIM_SMSCOMMANDS_OCEANIA = ( + "wireless-super-sim-smscommands-oceania" + ) + WIRELESS_SUPER_SIM_SUBSCRIPTION = "wireless-super-sim-subscription" + WIRELESS_SUPER_SIM_SUBSCRIPTION_PAYG = "wireless-super-sim-subscription-payg" WIRELESS_USAGE = "wireless-usage" WIRELESS_USAGE_COMMANDS = "wireless-usage-commands" WIRELESS_USAGE_COMMANDS_AFRICA = "wireless-usage-commands-africa" @@ -342,6 +656,184 @@ class Category(object): WIRELESS_USAGE_MRC_SUSPENDED = "wireless-usage-mrc-suspended" WIRELESS_USAGE_SMS = "wireless-usage-sms" WIRELESS_USAGE_VOICE = "wireless-usage-voice" + A2P_FAST_TRACK_ONBOARDING = "a2p-fast-track-onboarding" + ADVISORY_SERVICES = "advisory-services" + ADVISORY_SERVICES_BILLED = "advisory-services-billed" + ADVISORY_SERVICES_CALL_TRACKING = "advisory-services-call-tracking" + ADVISORY_SERVICES_DATA_SERVICES = "advisory-services-data-services" + ADVISORY_SERVICES_EXPENSES = "advisory-services-expenses" + ADVISORY_SERVICES_SIP_TRUNKING = "advisory-services-sip-trunking" + ASSETS_REQUESTS = "assets-requests" + AUDIENCE_MINUTES_VIDEO = "audience-minutes-video" + AUTHY_BUCKET_ADJUSTMENT = "authy-bucket-adjustment" + AUTHY_SOFTWARE = "authy-software" + CALLERIDLOOKUPS_API = "calleridlookups-api" + CALLERIDLOOKUPS_PROGRAMMABLEVOICE = "calleridlookups-programmablevoice" + CALLERIDLOOKUPS_TRUNKING = "calleridlookups-trunking" + CALLS_TRUNKING_INBOUND_TOLLFREE_LOCAL = "calls-trunking-inbound-tollfree-local" + CALLS_TRUNKING_INBOUND_TOLLFREE_MOBILE = ( + "calls-trunking-inbound-tollfree-mobile" + ) + CHANNELS_WHATSAPP_CONVERSATION_FREE_1 = "channels-whatsapp-conversation-free-1" + CONFERENCE = "conference" + CONVERSATIONAL_INSIGHTS = "conversational-insights" + CONVERSATIONAL_INSIGHTS_MESSAGES = "conversational-insights-messages" + CONVERSATIONAL_INSIGHTS_VOICE_MINUTES = "conversational-insights-voice-minutes" + DEMO = "demo" + DEMO_UC_SCRIPT_TEST = "demo-uc-script-test" + ELASTIC_SIP_TRUNKING = "elastic-sip-trunking" + ELASTIC_SIP_TRUNKING_CALL_TRANSFERS = "elastic-sip-trunking-call-transfers" + ENTERPRISE_HIPPA = "enterprise-hippa" + FLEX_NAMED_USERS = "flex-named-users" + FLEX_SPINSCI = "flex-spinsci" + FLEX_USERS_1 = "flex-users-1" + FLEX_WFO_PREMIUM_SPEECH_ANALYTICS = "flex-wfo-premium-speech-analytics" + FLEX_XCELERATE = "flex-xcelerate" + FUNCTIONS_ROLLUP = "functions-rollup" + IMP_V1_USAGE = "imp-v1-usage" + IP_MESSAGING_ADDONS = "ip-messaging-addons" + IVR = "ivr" + IVR_CONVERSATIONAL = "ivr-conversational" + IVR_DTMF = "ivr-dtmf" + IVR_VIRTUALAGENT = "ivr-virtualagent" + LIVE = "live" + LIVE_MEDIA_RECORDING_MINUTES = "live-media-recording-minutes" + LONGCODE_MPS = "longcode-mps" + MARKETPLACE_ANALYTICS_ADDONS = "marketplace-analytics-addons" + MARKETPLACE_ISV_ADDONS = "marketplace-isv-addons" + MARKETPLACE_MESSAGING_ADDONS = "marketplace-messaging-addons" + MARKETPLACE_PHONENUMBERS_ADDONS = "marketplace-phonenumbers-addons" + MARKETPLACE_RECORDING_ADDONS = "marketplace-recording-addons" + MARKETPLACE_VIRTUALAGENT_ADDONS = "marketplace-virtualagent-addons" + MARKETPLAY_PAY_ADDONS_SHUTTLE_PAY_CONNECTOR_1 = ( + "marketplay-pay-addons-shuttle-pay-connector-1" + ) + MARKETPLAY_PAY_ADDONS_STRIPE_PAY_CONNECTOR = ( + "marketplay-pay-addons-stripe-pay-connector" + ) + MMS_INBOUND_LONGCODE_CANADA = "mms-inbound-longcode-canada" + MMS_INBOUND_LONGCODE_UNITEDSTATES = "mms-inbound-longcode-unitedstates" + MMS_OUTBOUND_LONGCODE_CANADA = "mms-outbound-longcode-canada" + MMS_OUTBOUND_LONGCODE_UNITEDSTATES = "mms-outbound-longcode-unitedstates" + MMS_OUTBOUND_TOLL_FREE = "mms-outbound-toll-free" + NOTIFY_CHATAPPSANDOTHERCHANNELS = "notify-chatappsandotherchannels" + NOTIFY_NOTIFYSERVICES = "notify-notifyservices" + NOTIFY_PUSHNOTIFICATIONS = "notify-pushnotifications" + PAYMENT_GATEWAY_CONNECTORS = "payment-gateway-connectors" + PAYMENT_SOLUTIONS = "payment-solutions" + PCHAT_BUCKET_ADJUSTMENT = "pchat-bucket-adjustment" + PHONENUMBERS_NUMBERS = "phonenumbers-numbers" + PROG_VOICE_CLIENT_ANDROID = "prog-voice-client-android" + PROG_VOICE_CLIENT_ANDROID_INBOUND = "prog-voice-client-android-inbound" + PROG_VOICE_CLIENT_ANDROID_OUTBOUND = "prog-voice-client-android-outbound" + PROG_VOICE_CLIENT_IOS = "prog-voice-client-ios" + PROG_VOICE_CLIENT_IOS_INBOUND = "prog-voice-client-ios-inbound" + PROG_VOICE_CLIENT_IOS_OUTBOUND = "prog-voice-client-ios-outbound" + PROG_VOICE_CLIENT_SDK = "prog-voice-client-sdk" + PROG_VOICE_CLIENT_WEB = "prog-voice-client-web" + PROG_VOICE_CLIENT_WEB_INBOUND = "prog-voice-client-web-inbound" + PROG_VOICE_CLIENT_WEB_OUTBOUND = "prog-voice-client-web-outbound" + PROGRAMMABLEVOICECONNECTIVITY_MEDIA_STREAMS = ( + "programmablevoiceconnectivity-media-streams" + ) + PSTNCONNECTIVITY_BYOC = "pstnconnectivity-byoc" + PSTNCONNECTIVITY_EMERGENCY = "pstnconnectivity-emergency" + PSTNCONNECTIVITY_MINUTES = "pstnconnectivity-minutes" + PSTNCONNECTIVITY_MINUTES_1 = "pstnconnectivity-minutes-1" + PSTNCONNECTIVITY_MINUTESINBOUNDLOCAL = "pstnconnectivity-minutesinboundlocal" + PSTNCONNECTIVITY_MINUTESINBOUNDMOBILE = "pstnconnectivity-minutesinboundmobile" + PSTNCONNECTIVITY_MINUTESINBOUNDTOLLFREE = ( + "pstnconnectivity-minutesinboundtollfree" + ) + PSTNCONNECTIVITY_MINUTESINBOUNDTOLLFREELOCAL = ( + "pstnconnectivity-minutesinboundtollfreelocal" + ) + PSTNCONNECTIVITY_MINUTESINBOUNDTOLLFREEMOBILE = ( + "pstnconnectivity-minutesinboundtollfreemobile" + ) + PV_ROOM_HOURS = "pv-room-hours" + PV_ROOM_SIMULTANEOUS_PARTICIPANT_CONNECTIONS = ( + "pv-room-simultaneous-participant-connections" + ) + PVIDEO_ROOM_HOURS_AU1 = "pvideo-room-hours-au1" + PVIDEO_ROOM_HOURS_BR1 = "pvideo-room-hours-br1" + PVIDEO_ROOM_HOURS_IE1 = "pvideo-room-hours-ie1" + PVIDEO_ROOM_HOURS_JP1 = "pvideo-room-hours-jp1" + PVIDEO_ROOM_HOURS_SG1 = "pvideo-room-hours-sg1" + PVIDEO_ROOM_HOURS_US1 = "pvideo-room-hours-us1" + PVIDEO_ROOM_HOURS_US2 = "pvideo-room-hours-us2" + RECORDINGS_ENCRYPTED = "recordings-encrypted" + SHORT_CODE_SETUP_FEES = "short-code-setup-fees" + SHORTCODES_MESSAGES_INBOUND = "shortcodes-messages-inbound" + SHORTCODES_MESSAGES_OUTBOUND = "shortcodes-messages-outbound" + SMS_MESSAGES_REGISTRATIONFEES = "sms-messages-registrationfees" + SMS_MMS_PENALTY_FEES = "sms-mms-penalty-fees" + SMS_MMS_PENALTY_FEES_1 = "sms-mms-penalty-fees-1" + SMS_PUMPING_PROTECTION_NON_USCA = "sms-pumping-protection-non-usca" + SMS_PUMPING_PROTECTION_USCA = "sms-pumping-protection-usca" + STUDIO = "studio" + STUDIO_MONTHLY_FEES = "studio-monthly-fees" + SUPERSIM = "supersim" + TASK_ROUTER = "task-router" + TASK_ROUTER_WORKERS = "task-router-workers" + TEST_QUOTA_BUCKETS = "test-quota-buckets" + TEST_UC_SCRIPT_1 = "test-uc-script-1" + TEST_UC_SCRIPT_DEMO_2 = "test-uc-script-demo-2" + TEXT_TO_SPEECH = "text-to-speech" + TME = "tme" + TTS_BASIC = "tts-basic" + TWILIO_EDITIONS = "twilio-editions" + TWILIO_INTERCONNECT_CALIFORNIA = "twilio-interconnect-california" + TWILIO_INTERCONNECT_CALIFORNIA_MONTHLY = ( + "twilio-interconnect-california-monthly" + ) + TWILIO_INTERCONNECT_CALIFORNIA_SETUP = "twilio-interconnect-california-setup" + TWILIO_INTERCONNECT_FRANKFURT = "twilio-interconnect-frankfurt" + TWILIO_INTERCONNECT_FRANKFURT_MO = "twilio-interconnect-frankfurt-mo" + TWILIO_INTERCONNECT_FRANKFURT_SETUP = "twilio-interconnect-frankfurt-setup" + TWILIO_INTERCONNECT_LONDON = "twilio-interconnect-london" + TWILIO_INTERCONNECT_LONDON_MO = "twilio-interconnect-london-mo" + TWILIO_INTERCONNECT_LONDON_SETUP = "twilio-interconnect-london-setup" + TWILIO_INTERCONNECT_SAO_PAULO = "twilio-interconnect-sao-paulo" + TWILIO_INTERCONNECT_SAO_PAULO_MONTHLY = "twilio-interconnect-sao-paulo-monthly" + TWILIO_INTERCONNECT_SAO_PAULO_SETUP = "twilio-interconnect-sao-paulo-setup" + TWILIO_INTERCONNECT_SINGAPORE = "twilio-interconnect-singapore" + TWILIO_INTERCONNECT_SINGAPORE_MO = "twilio-interconnect-singapore-mo" + TWILIO_INTERCONNECT_SINGAPORE_SETUP = "twilio-interconnect-singapore-setup" + TWILIO_INTERCONNECT_SYDNEY = "twilio-interconnect-sydney" + TWILIO_INTERCONNECT_SYDNEY_MO = "twilio-interconnect-sydney-mo" + TWILIO_INTERCONNECT_SYDNEY_SETUP = "twilio-interconnect-sydney-setup" + TWILIO_INTERCONNECT_TOKYO = "twilio-interconnect-tokyo" + TWILIO_INTERCONNECT_TOKYO_MO = "twilio-interconnect-tokyo-mo" + TWILIO_INTERCONNECT_TOKYO_SETUP = "twilio-interconnect-tokyo-setup" + TWILIO_INTERCONNECT_VA = "twilio-interconnect-va" + TWILIO_INTERCONNECT_VA_MO = "twilio-interconnect-va-mo" + TWILIO_INTERCONNECT_VA_SETUP = "twilio-interconnect-va-setup" + TWIML_VERBS = "twiml-verbs" + TWIML_VERBS_SAY = "twiml-verbs-say" + USAGE_PROGRAMMABLE_MESSAGING_ENGAGEMENT_SUITE = ( + "usage-programmable-messaging-engagement-suite" + ) + USAGE_PROGRAMMABLE_MESSAGING_FEES_SERVICES = ( + "usage-programmable-messaging-fees-services" + ) + VERIFY_OUTBOUND_EMAIL = "verify-outbound-email" + VERIFY_PACKAGED_PLANS = "verify-packaged-plans" + VERIFY_SILENT_NETWORK_AUTH = "verify-silent-network-auth" + VERIFY_VOICE_AND_SMS = "verify-voice-and-sms" + VOICE_INSIGHTS_CLIENT_INSIGHTS_MONTHY_COMMIT = ( + "voice-insights-client-insights-monthy-commit" + ) + WIRELESS_DATA_PAYG_ASIA_AFG = "wireless-data-payg-asia-afg" + WIRELESS_MULTI_IMSI_SIM_COMMANDS = "wireless-multi-imsi-sim-commands" + WIRELESS_MULTI_IMSI_SIM_COMMANDS_USA = "wireless-multi-imsi-sim-commands-usa" + WIRELESS_MULTI_IMSI_SIM_DATA = "wireless-multi-imsi-sim-data" + WIRELESS_MULTI_IMSI_SIM_DATA_EU28 = "wireless-multi-imsi-sim-data-eu28" + WIRELESS_MULTI_IMSI_SIM_DATA_USA = "wireless-multi-imsi-sim-data-usa" + WIRELESS_MULTI_IMSI_SIM_MONTHLY_FEES = "wireless-multi-imsi-sim-monthly-fees" + WIRELESS_MULTI_IMSI_SIM_USAGE = "wireless-multi-imsi-sim-usage" + WIRELESS_SUPER_SIM_DATA_NORTH_AMERICA = "wireless-super-sim-data-north-america" + WIRELESS_SUPER_SIM_USAGE = "wireless-super-sim-usage" """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that accrued the usage. @@ -401,6 +893,7 @@ def __repr__(self) -> str: class AllTimePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> AllTimeInstance: """ Build an instance of AllTimeInstance @@ -421,6 +914,7 @@ def __repr__(self) -> str: class AllTimeList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the AllTimeList @@ -623,14 +1117,20 @@ def page( "Category": category, "StartDate": serialize.iso8601_date(start_date), "EndDate": serialize.iso8601_date(end_date), - "IncludeSubaccounts": include_subaccounts, + "IncludeSubaccounts": serialize.boolean_to_string(include_subaccounts), "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 AllTimePage(self._version, response, self._solution) async def page_async( @@ -662,15 +1162,19 @@ async def page_async( "Category": category, "StartDate": serialize.iso8601_date(start_date), "EndDate": serialize.iso8601_date(end_date), - "IncludeSubaccounts": include_subaccounts, + "IncludeSubaccounts": serialize.boolean_to_string(include_subaccounts), "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 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 3fa0739ae3..e89c75cb39 100644 --- a/twilio/rest/api/v2010/account/usage/record/daily.py +++ b/twilio/rest/api/v2010/account/usage/record/daily.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import date from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import deserialize, serialize, values @@ -24,34 +23,103 @@ class DailyInstance(InstanceResource): + class Category(object): + A2P_10DLC_REGISTRATIONFEES_BRANDREGISTRATION = ( + "a2p-10dlc-registrationfees-brandregistration" + ) + A2P_10DLC_REGISTRATIONFEES_BV = "a2p-10dlc-registrationfees-bv" + A2P_10DLC_REGISTRATIONFEES_CAMPAIGNCHARGES = ( + "a2p-10dlc-registrationfees-campaigncharges" + ) + A2P_10DLC_REGISTRATIONFEES_CAMPAIGNREGISTRATION = ( + "a2p-10dlc-registrationfees-campaignregistration" + ) + A2P_10DLC_REGISTRATIONFEES_CAMPAIGNVETTING = ( + "a2p-10dlc-registrationfees-campaignvetting" + ) + A2P_10DLC_REGISTRATIONFEES_MONTHLY = "a2p-10dlc-registrationfees-monthly" + A2P_10DLC_REGISTRATIONFEES_ONETIME = "a2p-10dlc-registrationfees-onetime" A2P_REGISTRATION_FEES = "a2p-registration-fees" + ACCOUNT_SECURITY = "account-security" AGENT_CONFERENCE = "agent-conference" + AGENT_COPILOT = "agent-copilot" + AGENT_COPILOT_MESSAGES = "agent-copilot-messages" + AGENT_COPILOT_PARTICIPANT_MINUTES = "agent-copilot-participant-minutes" + AI_ASSISTANTS = "ai-assistants" + AI_ASSISTANTS_VOICE = "ai-assistants-voice" AMAZON_POLLY = "amazon-polly" ANSWERING_MACHINE_DETECTION = "answering-machine-detection" + ASSETS = "assets" + AUDIENCE_MINUTES = "audience-minutes" + AUDIENCE_MINUTES_AUDIO = "audience-minutes-audio" AUTHY_AUTHENTICATIONS = "authy-authentications" AUTHY_CALLS_OUTBOUND = "authy-calls-outbound" + AUTHY_EMAIL_AUTHENTICATIONS = "authy-email-authentications" AUTHY_MONTHLY_FEES = "authy-monthly-fees" + AUTHY_OUTBOUND_EMAIL = "authy-outbound-email" AUTHY_PHONE_INTELLIGENCE = "authy-phone-intelligence" AUTHY_PHONE_VERIFICATIONS = "authy-phone-verifications" AUTHY_SMS_OUTBOUND = "authy-sms-outbound" + AUTHY_VERIFY_EMAIL_VERIFICATIONS = "authy-verify-email-verifications" + AUTHY_VERIFY_OUTBOUND_EMAIL = "authy-verify-outbound-email" + AUTOPILOT = "autopilot" + AUTOPILOT_HOME_ASSISTANTS = "autopilot-home-assistants" + AUTOPILOT_MESSAGING = "autopilot-messaging" + AUTOPILOT_OTHER = "autopilot-other" + AUTOPILOT_VOICE = "autopilot-voice" + BASIC_PEER_TO_PEER_ROOMS_PARTICIPANT_MINUTES = ( + "basic-peer-to-peer-rooms-participant-minutes" + ) + BRANDED_CALLING = "branded-calling" + BUNDLE_SMS_BUCKET = "bundle-sms-bucket" + BUNDLE_SUBSCRIPTION_FEES = "bundle-subscription-fees" + CALL_FORWARDING_LOOKUPS = "call-forwarding-lookups" CALL_PROGESS_EVENTS = "call-progess-events" CALLERIDLOOKUPS = "calleridlookups" CALLS = "calls" CALLS_CLIENT = "calls-client" + CALLS_EMERGENCY = "calls-emergency" CALLS_GLOBALCONFERENCE = "calls-globalconference" CALLS_INBOUND = "calls-inbound" CALLS_INBOUND_LOCAL = "calls-inbound-local" CALLS_INBOUND_MOBILE = "calls-inbound-mobile" CALLS_INBOUND_TOLLFREE = "calls-inbound-tollfree" + CALLS_INBOUND_TOLLFREE_LOCAL = "calls-inbound-tollfree-local" + CALLS_INBOUND_TOLLFREE_MOBILE = "calls-inbound-tollfree-mobile" + CALLS_MEDIA_STREAM_MINUTES = "calls-media-stream-minutes" CALLS_OUTBOUND = "calls-outbound" CALLS_PAY_VERB_TRANSACTIONS = "calls-pay-verb-transactions" CALLS_RECORDINGS = "calls-recordings" CALLS_SIP = "calls-sip" CALLS_SIP_INBOUND = "calls-sip-inbound" CALLS_SIP_OUTBOUND = "calls-sip-outbound" + CALLS_TEXT_TO_SPEECH = "calls-text-to-speech" CALLS_TRANSFERS = "calls-transfers" CARRIER_LOOKUPS = "carrier-lookups" + CATEGORY = "category" + CHANNELS = "channels" + CHANNELS_MESSAGING = "channels-messaging" + CHANNELS_MESSAGING_INBOUND = "channels-messaging-inbound" + CHANNELS_MESSAGING_OUTBOUND = "channels-messaging-outbound" + CHANNELS_WHATSAPP = "channels-whatsapp" + CHANNELS_WHATSAPP_CONVERSATION_AUTHENTICATION = ( + "channels-whatsapp-conversation-authentication" + ) + CHANNELS_WHATSAPP_CONVERSATION_FREE = "channels-whatsapp-conversation-free" + CHANNELS_WHATSAPP_CONVERSATION_MARKETING = ( + "channels-whatsapp-conversation-marketing" + ) + CHANNELS_WHATSAPP_CONVERSATION_SERVICE = ( + "channels-whatsapp-conversation-service" + ) + CHANNELS_WHATSAPP_CONVERSATION_UTILITY = ( + "channels-whatsapp-conversation-utility" + ) + CHANNELS_WHATSAPP_INBOUND = "channels-whatsapp-inbound" + CHANNELS_WHATSAPP_OUTBOUND = "channels-whatsapp-outbound" + CHAT_VIRTUAL_AGENT = "chat-virtual-agent" + CONVERSATION_RELAY = "conversation-relay" CONVERSATIONS = "conversations" CONVERSATIONS_API_REQUESTS = "conversations-api-requests" CONVERSATIONS_CONVERSATION_EVENTS = "conversations-conversation-events" @@ -60,8 +128,40 @@ class Category(object): CONVERSATIONS_PARTICIPANT_EVENTS = "conversations-participant-events" CONVERSATIONS_PARTICIPANTS = "conversations-participants" CPS = "cps" + CREDIT_TRANSFER = "credit-transfer" + EMAIL = "email" + EMERGING_TECH = "emerging-tech" + ENGAGEMENT_SUITE_PACKAGED_PLANS = "engagement-suite-packaged-plans" + ENHANCED_LINE_TYPE_LOOKUPS = "enhanced-line-type-lookups" + ENTERPRISE = "enterprise" + EVENTS = "events" + EXPERIMENT_FRANCE_SMS = "experiment-france-sms" + EXPERIMENT_INDIA_SMS = "experiment-india-sms" + EXPERIMENT_UK_SMS = "experiment-uk-sms" + FAILED_MESSAGE_PROCESSING_FEE = "failed-message-processing-fee" + FLEX = "flex" + FLEX_ACTIVE_USER_HOURS = "flex-active-user-hours" + FLEX_CONCURRENT_USERS = "flex-concurrent-users" + FLEX_CONVERSATIONAL_INSIGHTS = "flex-conversational-insights" + FLEX_CONVERSATIONAL_INSIGHTS_MESSAGES = "flex-conversational-insights-messages" + FLEX_CONVERSATIONAL_INSIGHTS_VOICE_MINUTES = ( + "flex-conversational-insights-voice-minutes" + ) + FLEX_EMAIL_USAGE = "flex-email-usage" + FLEX_MESSAGING_USAGE = "flex-messaging-usage" + FLEX_PARTNER_SPINSCI = "flex-partner-spinsci" + FLEX_PARTNER_XCELERATE = "flex-partner-xcelerate" + FLEX_RESELLER_ECOSYSTEM = "flex-reseller-ecosystem" + FLEX_UNIQUE_USER = "flex-unique-user" FLEX_USAGE = "flex-usage" + FLEX_USERS = "flex-users" + FLEX_VOICE_MINUTE = "flex-voice-minute" + FLEX_YTICA = "flex-ytica" FRAUD_LOOKUPS = "fraud-lookups" + FRONTLINE = "frontline" + FRONTLINE_USERS = "frontline-users" + FUNCTIONS = "functions" + GENERIC_PAY_TRANSACTIONS = "generic-pay-transactions" GROUP_ROOMS = "group-rooms" GROUP_ROOMS_DATA_TRACK = "group-rooms-data-track" GROUP_ROOMS_ENCRYPTED_MEDIA_RECORDED = "group-rooms-encrypted-media-recorded" @@ -71,7 +171,17 @@ class Category(object): GROUP_ROOMS_MEDIA_STORED = "group-rooms-media-stored" GROUP_ROOMS_PARTICIPANT_MINUTES = "group-rooms-participant-minutes" GROUP_ROOMS_RECORDED_MINUTES = "group-rooms-recorded-minutes" - IMP_V1_USAGE = "imp-v1-usage" + IP_MESSAGING = "ip-messaging" + IP_MESSAGING_COMMANDS = "ip-messaging-commands" + IP_MESSAGING_DATA_STORAGE = "ip-messaging-data-storage" + IP_MESSAGING_DATA_TRANSFER = "ip-messaging-data-transfer" + IP_MESSAGING_ENDPOINT_CONNECTIVITY = "ip-messaging-endpoint-connectivity" + IVR_VIRTUAL_AGENT_CUSTOM_VOICES = "ivr-virtual-agent-custom-voices" + IVR_VIRTUAL_AGENT_GENAI = "ivr-virtual-agent-genai" + LINE_STATUS_LOOKUPS = "line-status-lookups" + LIVE_ACTIVITY_LOOKUPS = "live-activity-lookups" + LOOKUP_BUCKET_ADJUSTMENT = "lookup-bucket-adjustment" + LOOKUP_IDENTITY_MATCH = "lookup-identity-match" LOOKUPS = "lookups" MARKETPLACE = "marketplace" MARKETPLACE_ALGORITHMIA_NAMED_ENTITY_RECOGNITION = ( @@ -82,6 +192,13 @@ class Category(object): MARKETPLACE_CAPIO_SPEECH_TO_TEXT = "marketplace-capio-speech-to-text" MARKETPLACE_CONVRIZA_ABABA = "marketplace-convriza-ababa" MARKETPLACE_DEEPGRAM_PHRASE_DETECTOR = "marketplace-deepgram-phrase-detector" + MARKETPLACE_DEEPGRAM_TRANSCRIPTION = "marketplace-deepgram-transcription" + MARKETPLACE_DEEPGRAM_TRANSCRIPTION_BASE = ( + "marketplace-deepgram-transcription-base" + ) + MARKETPLACE_DEEPGRAM_TRANSSCRIPTION_ENHANCED = ( + "marketplace-deepgram-transscription-enhanced" + ) MARKETPLACE_DIGITAL_SEGMENT_BUSINESS_INFO = ( "marketplace-digital-segment-business-info" ) @@ -107,6 +224,9 @@ class Category(object): "marketplace-keen-io-contact-center-analytics" ) MARKETPLACE_MARCHEX_CLEANCALL = "marketplace-marchex-cleancall" + MARKETPLACE_MARCHEX_RECORDING_ANALYSIS = ( + "marketplace-marchex-recording-analysis" + ) MARKETPLACE_MARCHEX_SENTIMENT_ANALYSIS_FOR_SMS = ( "marketplace-marchex-sentiment-analysis-for-sms" ) @@ -123,14 +243,42 @@ class Category(object): "marketplace-nextcaller-advanced-caller-identification" ) MARKETPLACE_NOMOROBO_SPAM_SCORE = "marketplace-nomorobo-spam-score" + MARKETPLACE_PAY_ADDONS = "marketplace-pay-addons" + MARKETPLACE_PAY_ADDONS_BASECOMMERCE_PAY_CONNECTOR = ( + "marketplace-pay-addons-basecommerce-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_BRAINTREE_PAY_CONNECTOR = ( + "marketplace-pay-addons-braintree-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_CARDCONNECT_PAY_CONNECTOR = ( + "marketplace-pay-addons-cardconnect-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_CHASE_PAY_CONNECTOR = ( + "marketplace-pay-addons-chase-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_SHUTTLE_PAY_CONNECTOR = ( + "marketplace-pay-addons-shuttle-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_STRIPE_PAY_CONNECTOR = ( + "marketplace-pay-addons-stripe-pay-connector" + ) MARKETPLACE_PAYFONE_TCPA_COMPLIANCE = "marketplace-payfone-tcpa-compliance" + MARKETPLACE_POLY_AI_CONNECTOR = "marketplace-poly-ai-connector" + MARKETPLACE_REALPHONEVALIDATION = "marketplace-realphonevalidation" MARKETPLACE_REMEETING_AUTOMATIC_SPEECH_RECOGNITION = ( "marketplace-remeeting-automatic-speech-recognition" ) + MARKETPLACE_SPOKE_PHONE_LICENSE_PRO = "marketplace-spoke-phone-license-pro" + MARKETPLACE_SPOKE_PHONE_LICENSE_STANDARD = ( + "marketplace-spoke-phone-license-standard" + ) MARKETPLACE_TCPA_DEFENSE_SOLUTIONS_BLACKLIST_FEED = ( "marketplace-tcpa-defense-solutions-blacklist-feed" ) MARKETPLACE_TELO_OPENCNAM = "marketplace-telo-opencnam" + MARKETPLACE_TRESTLE_SOLUTIONS_CALLER_IDENTIFICATION = ( + "marketplace-trestle-solutions-caller-identification" + ) MARKETPLACE_TRUECNAM_TRUE_SPAM = "marketplace-truecnam-true-spam" MARKETPLACE_TWILIO_CALLER_NAME_LOOKUP_US = ( "marketplace-twilio-caller-name-lookup-us" @@ -143,6 +291,9 @@ class Category(object): MARKETPLACE_VOICEBASE_TRANSCRIPTION_CUSTOM_VOCABULARY = ( "marketplace-voicebase-transcription-custom-vocabulary" ) + MARKETPLACE_WEB_PURIFY_PROFANITY_FILTER = ( + "marketplace-web-purify-profanity-filter" + ) MARKETPLACE_WHITEPAGES_PRO_CALLER_IDENTIFICATION = ( "marketplace-whitepages-pro-caller-identification" ) @@ -157,15 +308,23 @@ class Category(object): MARKETPLACE_YTICA_CONTACT_CENTER_REPORTING_ANALYTICS = ( "marketplace-ytica-contact-center-reporting-analytics" ) + MARKETPLAY_PAY_ADDONS_SHUTTLE_PAY_CONNECTOR = ( + "marketplay-pay-addons-shuttle-pay-connector" + ) + MEDIA_COMPOSER_MINUTES = "media-composer-minutes" MEDIASTORAGE = "mediastorage" + MIN_SPEND_ADJUSTMENTS = "min-spend-adjustments" MMS = "mms" MMS_INBOUND = "mms-inbound" MMS_INBOUND_LONGCODE = "mms-inbound-longcode" MMS_INBOUND_SHORTCODE = "mms-inbound-shortcode" + MMS_INBOUND_TOLL_FREE = "mms-inbound-toll-free" MMS_MESSAGES_CARRIERFEES = "mms-messages-carrierfees" MMS_OUTBOUND = "mms-outbound" MMS_OUTBOUND_LONGCODE = "mms-outbound-longcode" MMS_OUTBOUND_SHORTCODE = "mms-outbound-shortcode" + MMS_OUTBOUND_TOLLFREE = "mms-outbound-tollfree" + MONITOR = "monitor" MONITOR_READS = "monitor-reads" MONITOR_STORAGE = "monitor-storage" MONITOR_WRITES = "monitor-writes" @@ -174,6 +333,12 @@ class Category(object): NOTIFY_CHANNELS = "notify-channels" NUMBER_FORMAT_LOOKUPS = "number-format-lookups" PCHAT = "pchat" + PCHAT_ACTIONS = "pchat-actions" + PCHAT_APS = "pchat-aps" + PCHAT_CONV_MED_STORAGE = "pchat-conv-med-storage" + PCHAT_MESSAGES = "pchat-messages" + PCHAT_NOTIFICATIONS = "pchat-notifications" + PCHAT_READS = "pchat-reads" PCHAT_USERS = "pchat-users" PEER_TO_PEER_ROOMS_PARTICIPANT_MINUTES = ( "peer-to-peer-rooms-participant-minutes" @@ -183,18 +348,41 @@ class Category(object): PFAX_MINUTES_INBOUND = "pfax-minutes-inbound" PFAX_MINUTES_OUTBOUND = "pfax-minutes-outbound" PFAX_PAGES = "pfax-pages" + PHONE_QUALITY_SCORE_LOOKUPS = "phone-quality-score-lookups" PHONENUMBERS = "phonenumbers" PHONENUMBERS_CPS = "phonenumbers-cps" PHONENUMBERS_EMERGENCY = "phonenumbers-emergency" PHONENUMBERS_LOCAL = "phonenumbers-local" PHONENUMBERS_MOBILE = "phonenumbers-mobile" + PHONENUMBERS_PORTING = "phonenumbers-porting" PHONENUMBERS_SETUPS = "phonenumbers-setups" PHONENUMBERS_TOLLFREE = "phonenumbers-tollfree" PREMIUMSUPPORT = "premiumsupport" + PREMIUMSUPPORT_PERCENTAGE_SPEND = "premiumsupport-percentage-spend" + PROGRAMMABLEVOICE_PLATFORM = "programmablevoice-platform" + PROGRAMMABLEVOICECONN_CLIENTSDK = "programmablevoiceconn-clientsdk" + PROGRAMMABLEVOICECONN_CLIENTSDK_INBOUND = ( + "programmablevoiceconn-clientsdk-inbound" + ) + PROGRAMMABLEVOICECONN_CLIENTSDK_OUTBOUND = ( + "programmablevoiceconn-clientsdk-outbound" + ) + PROGRAMMABLEVOICECONN_ONNET = "programmablevoiceconn-onnet" + PROGRAMMABLEVOICECONN_ONNET_INBOUND = "programmablevoiceconn-onnet-inbound" + PROGRAMMABLEVOICECONN_ONNET_OUTBOUND = "programmablevoiceconn-onnet-outbound" + PROGRAMMABLEVOICECONN_SIP = "programmablevoiceconn-sip" + PROGRAMMABLEVOICECONN_SIP_INBOUND = "programmablevoiceconn-sip-inbound" + PROGRAMMABLEVOICECONN_SIP_OUTBOUND = "programmablevoiceconn-sip-outbound" + PROGRAMMABLEVOICECONNECTIVITY = "programmablevoiceconnectivity" PROXY = "proxy" PROXY_ACTIVE_SESSIONS = "proxy-active-sessions" + PROXY_BUCKET_ADJUSTMENT = "proxy-bucket-adjustment" + PROXY_LICENSES = "proxy-licenses" PSTNCONNECTIVITY = "pstnconnectivity" + PSTNCONNECTIVITY_INBOUND = "pstnconnectivity-inbound" + PSTNCONNECTIVITY_OUTBOUND = "pstnconnectivity-outbound" PV = "pv" + PV_BASIC_ROOMS = "pv-basic-rooms" PV_COMPOSITION_MEDIA_DOWNLOADED = "pv-composition-media-downloaded" PV_COMPOSITION_MEDIA_ENCRYPTED = "pv-composition-media-encrypted" PV_COMPOSITION_MEDIA_STORED = "pv-composition-media-stored" @@ -210,18 +398,20 @@ class Category(object): PV_ROOM_PARTICIPANTS_US2 = "pv-room-participants-us2" PV_ROOMS = "pv-rooms" PV_SIP_ENDPOINT_REGISTRATIONS = "pv-sip-endpoint-registrations" + RCS_MESSAGES = "rcs-messages" + REASSIGNED_NUMBER = "reassigned-number" RECORDINGS = "recordings" RECORDINGSTORAGE = "recordingstorage" - ROOMS_GROUP_BANDWIDTH = "rooms-group-bandwidth" - ROOMS_GROUP_MINUTES = "rooms-group-minutes" - ROOMS_PEER_TO_PEER_MINUTES = "rooms-peer-to-peer-minutes" SHORTCODES = "shortcodes" SHORTCODES_CUSTOMEROWNED = "shortcodes-customerowned" SHORTCODES_MMS_ENABLEMENT = "shortcodes-mms-enablement" SHORTCODES_MPS = "shortcodes-mps" SHORTCODES_RANDOM = "shortcodes-random" + SHORTCODES_SETUP_FEES = "shortcodes-setup-fees" SHORTCODES_UK = "shortcodes-uk" SHORTCODES_VANITY = "shortcodes-vanity" + SIM_SWAP_LOOKUPS = "sim-swap-lookups" + SIP_SECURE_MEDIA = "sip-secure-media" SMALL_GROUP_ROOMS = "small-group-rooms" SMALL_GROUP_ROOMS_DATA_TRACK = "small-group-rooms-data-track" SMALL_GROUP_ROOMS_PARTICIPANT_MINUTES = "small-group-rooms-participant-minutes" @@ -229,13 +419,30 @@ class Category(object): SMS_INBOUND = "sms-inbound" SMS_INBOUND_LONGCODE = "sms-inbound-longcode" SMS_INBOUND_SHORTCODE = "sms-inbound-shortcode" + SMS_INBOUND_TOLLFREE = "sms-inbound-tollfree" SMS_MESSAGES_CARRIERFEES = "sms-messages-carrierfees" SMS_MESSAGES_FEATURES = "sms-messages-features" + SMS_MESSAGES_FEATURES_ENGAGEMENT_SUITE = ( + "sms-messages-features-engagement-suite" + ) + SMS_MESSAGES_FEATURES_MESSAGE_REDACTION = ( + "sms-messages-features-message-redaction" + ) SMS_MESSAGES_FEATURES_SENDERID = "sms-messages-features-senderid" + SMS_MPS = "sms-mps" + SMS_MPS_SHORTCODE = "sms-mps-shortcode" + SMS_MPS_TOLLFREE = "sms-mps-tollfree" + SMS_MPS_TOLLFREE_SETUP = "sms-mps-tollfree-setup" + SMS_NATIONAL_REGULATORY_PROTECTION = "sms-national-regulatory-protection" SMS_OUTBOUND = "sms-outbound" SMS_OUTBOUND_CONTENT_INSPECTION = "sms-outbound-content-inspection" SMS_OUTBOUND_LONGCODE = "sms-outbound-longcode" SMS_OUTBOUND_SHORTCODE = "sms-outbound-shortcode" + SMS_OUTBOUND_TOLLFREE = "sms-outbound-tollfree" + SMS_PUMPING_PROTECTION = "sms-pumping-protection" + SMS_PUMPING_RISK = "sms-pumping-risk" + SMSMESSAGES_BUCKET_ADJUSTMENTS = "smsmessages-bucket-adjustments" + SMSMESSAGES_OUTBOUND_DOMESTIC = "smsmessages-outbound-domestic" SPEECH_RECOGNITION = "speech-recognition" STUDIO_ENGAGEMENTS = "studio-engagements" SYNC = "sync" @@ -254,6 +461,7 @@ class Category(object): TRUNKING_RECORDINGS = "trunking-recordings" TRUNKING_SECURE = "trunking-secure" TRUNKING_TERMINATION = "trunking-termination" + TTS_GOOGLE = "tts-google" TURNMEGABYTES = "turnmegabytes" TURNMEGABYTES_AUSTRALIA = "turnmegabytes-australia" TURNMEGABYTES_BRASIL = "turnmegabytes-brasil" @@ -264,13 +472,27 @@ class Category(object): TURNMEGABYTES_SINGAPORE = "turnmegabytes-singapore" TURNMEGABYTES_USEAST = "turnmegabytes-useast" TURNMEGABYTES_USWEST = "turnmegabytes-uswest" + TWILIO_FOR_SALESFORCE = "twilio-for-salesforce" + TWILIO_FOR_SALESFORCE_LICENSES = "twilio-for-salesforce-licenses" TWILIO_INTERCONNECT = "twilio-interconnect" + TWIML = "twiml" + USAGE_FLEX_VIDEO = "usage-flex-video" + USAGE_FUNCTIONS = "usage-functions" + USAGE_RCS_BASIC_MESSAGES_OUTBOUND = "usage-rcs-basic-messages-outbound" + USAGE_RCS_MESSAGES = "usage-rcs-messages" + USAGE_RCS_MESSAGES_INBOUND = "usage-rcs-messages-inbound" + USAGE_RCS_MESSAGING_CARRIER_FEES = "usage-rcs-messaging-carrier-fees" + USAGE_RCS_SINGLE_MESSAGES_OUTBOUND = "usage-rcs-single-messages-outbound" + VERIFY_PACKAGE_PLANS = "verify-package-plans" VERIFY_PUSH = "verify-push" + VERIFY_SNA = "verify-sna" VERIFY_TOTP = "verify-totp" + VERIFY_VOICE_SMS = "verify-voice-sms" VERIFY_WHATSAPP_CONVERSATIONS_BUSINESS_INITIATED = ( "verify-whatsapp-conversations-business-initiated" ) VIDEO_RECORDINGS = "video-recordings" + VIDEO_ROOMS_TURN_MEGABYTES = "video-rooms-turn-megabytes" VIRTUAL_AGENT = "virtual-agent" VOICE_INSIGHTS = "voice-insights" VOICE_INSIGHTS_CLIENT_INSIGHTS_ON_DEMAND_MINUTE = ( @@ -285,12 +507,104 @@ class Category(object): VOICE_INSIGHTS_SIP_TRUNKING_INSIGHTS_ON_DEMAND_MINUTE = ( "voice-insights-sip-trunking-insights-on-demand-minute" ) + VOICE_INTELLIGENCE = "voice-intelligence" + VOICE_INTELLIGENCE_EIP_OPERATORS = "voice-intelligence-eip-operators" + VOICE_INTELLIGENCE_OPERATORS = "voice-intelligence-operators" + VOICE_INTELLIGENCE_TRANSCRIPTION = "voice-intelligence-transcription" + WDS = "wds" WIRELESS = "wireless" + WIRELESS_DATA = "wireless-data" + WIRELESS_DATA_PAYG = "wireless-data-payg" + WIRELESS_DATA_PAYG_AFRICA = "wireless-data-payg-africa" + WIRELESS_DATA_PAYG_ASIA = "wireless-data-payg-asia" + WIRELESS_DATA_PAYG_CENTRALANDSOUTHAMERICA = ( + "wireless-data-payg-centralandsouthamerica" + ) + WIRELESS_DATA_PAYG_EUROPE = "wireless-data-payg-europe" + WIRELESS_DATA_PAYG_NORTHAMERICA = "wireless-data-payg-northamerica" + WIRELESS_DATA_PAYG_OCEANIA = "wireless-data-payg-oceania" + WIRELESS_DATA_QUOTA1 = "wireless-data-quota1" + WIRELESS_DATA_QUOTA1_AFRICA = "wireless-data-quota1-africa" + WIRELESS_DATA_QUOTA1_ASIA = "wireless-data-quota1-asia" + WIRELESS_DATA_QUOTA1_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quota1-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTA1_EUROPE = "wireless-data-quota1-europe" + WIRELESS_DATA_QUOTA1_NORTHAMERICA = "wireless-data-quota1-northamerica" + WIRELESS_DATA_QUOTA1_OCEANIA = "wireless-data-quota1-oceania" + WIRELESS_DATA_QUOTA10 = "wireless-data-quota10" + WIRELESS_DATA_QUOTA10_AFRICA = "wireless-data-quota10-africa" + WIRELESS_DATA_QUOTA10_ASIA = "wireless-data-quota10-asia" + WIRELESS_DATA_QUOTA10_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quota10-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTA10_EUROPE = "wireless-data-quota10-europe" + WIRELESS_DATA_QUOTA10_NORTHAMERICA = "wireless-data-quota10-northamerica" + WIRELESS_DATA_QUOTA10_OCEANIA = "wireless-data-quota10-oceania" + WIRELESS_DATA_QUOTA50 = "wireless-data-quota50" + WIRELESS_DATA_QUOTA50_AFRICA = "wireless-data-quota50-africa" + WIRELESS_DATA_QUOTA50_ASIA = "wireless-data-quota50-asia" + WIRELESS_DATA_QUOTA50_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quota50-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTA50_EUROPE = "wireless-data-quota50-europe" + WIRELESS_DATA_QUOTA50_NORTHAMERICA = "wireless-data-quota50-northamerica" + WIRELESS_DATA_QUOTA50_OCEANIA = "wireless-data-quota50-oceania" + WIRELESS_DATA_QUOTACUSTOM = "wireless-data-quotacustom" + WIRELESS_DATA_QUOTACUSTOM_AFRICA = "wireless-data-quotacustom-africa" + WIRELESS_DATA_QUOTACUSTOM_ASIA = "wireless-data-quotacustom-asia" + WIRELESS_DATA_QUOTACUSTOM_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quotacustom-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTACUSTOM_EUROPE = "wireless-data-quotacustom-europe" + WIRELESS_DATA_QUOTACUSTOM_NORTHAMERICA = ( + "wireless-data-quotacustom-northamerica" + ) + WIRELESS_DATA_QUOTACUSTOM_OCEANIA = "wireless-data-quotacustom-oceania" + WIRELESS_MRC_PAYG = "wireless-mrc-payg" + WIRELESS_MRC_QUOTA1 = "wireless-mrc-quota1" + WIRELESS_MRC_QUOTA10 = "wireless-mrc-quota10" + WIRELESS_MRC_QUOTA50 = "wireless-mrc-quota50" + WIRELESS_MRC_QUOTACUSTOM = "wireless-mrc-quotacustom" WIRELESS_ORDERS = "wireless-orders" WIRELESS_ORDERS_ARTWORK = "wireless-orders-artwork" WIRELESS_ORDERS_BULK = "wireless-orders-bulk" WIRELESS_ORDERS_ESIM = "wireless-orders-esim" WIRELESS_ORDERS_STARTER = "wireless-orders-starter" + WIRELESS_QUOTAS = "wireless-quotas" + WIRELESS_SMS_AFRICA = "wireless-sms-africa" + WIRELESS_SMS_ASIA = "wireless-sms-asia" + WIRELESS_SMS_CENTRALANDSOUTHAMERICA = "wireless-sms-centralandsouthamerica" + WIRELESS_SMS_EUROPE = "wireless-sms-europe" + WIRELESS_SMS_NORTHAMERICA = "wireless-sms-northamerica" + WIRELESS_SMS_OCEANIA = "wireless-sms-oceania" + WIRELESS_SUPER_SIM = "wireless-super-sim" + WIRELESS_SUPER_SIM_DATA = "wireless-super-sim-data" + WIRELESS_SUPER_SIM_DATA_NORTH_AMERICA_USA = ( + "wireless-super-sim-data-north-america-usa" + ) + WIRELESS_SUPER_SIM_DATA_PAYG = "wireless-super-sim-data-payg" + WIRELESS_SUPER_SIM_DATA_PAYG_EUROPE = "wireless-super-sim-data-payg-europe" + WIRELESS_SUPER_SIM_DATA_PAYG_NORTH_AMERICA = ( + "wireless-super-sim-data-payg-north-america" + ) + WIRELESS_SUPER_SIM_HARDWARE = "wireless-super-sim-hardware" + WIRELESS_SUPER_SIM_HARDWARE_BULK = "wireless-super-sim-hardware-bulk" + WIRELESS_SUPER_SIM_SMSCOMMANDS = "wireless-super-sim-smscommands" + WIRELESS_SUPER_SIM_SMSCOMMANDS_AFRICA = "wireless-super-sim-smscommands-africa" + WIRELESS_SUPER_SIM_SMSCOMMANDS_ASIA = "wireless-super-sim-smscommands-asia" + WIRELESS_SUPER_SIM_SMSCOMMANDS_CENT_AND_SOUTH_AMERICA = ( + "wireless-super-sim-smscommands-cent-and-south-america" + ) + WIRELESS_SUPER_SIM_SMSCOMMANDS_EUROPE = "wireless-super-sim-smscommands-europe" + WIRELESS_SUPER_SIM_SMSCOMMANDS_NORTH_AMERICA = ( + "wireless-super-sim-smscommands-north-america" + ) + WIRELESS_SUPER_SIM_SMSCOMMANDS_OCEANIA = ( + "wireless-super-sim-smscommands-oceania" + ) + WIRELESS_SUPER_SIM_SUBSCRIPTION = "wireless-super-sim-subscription" + WIRELESS_SUPER_SIM_SUBSCRIPTION_PAYG = "wireless-super-sim-subscription-payg" WIRELESS_USAGE = "wireless-usage" WIRELESS_USAGE_COMMANDS = "wireless-usage-commands" WIRELESS_USAGE_COMMANDS_AFRICA = "wireless-usage-commands-africa" @@ -342,6 +656,184 @@ class Category(object): WIRELESS_USAGE_MRC_SUSPENDED = "wireless-usage-mrc-suspended" WIRELESS_USAGE_SMS = "wireless-usage-sms" WIRELESS_USAGE_VOICE = "wireless-usage-voice" + A2P_FAST_TRACK_ONBOARDING = "a2p-fast-track-onboarding" + ADVISORY_SERVICES = "advisory-services" + ADVISORY_SERVICES_BILLED = "advisory-services-billed" + ADVISORY_SERVICES_CALL_TRACKING = "advisory-services-call-tracking" + ADVISORY_SERVICES_DATA_SERVICES = "advisory-services-data-services" + ADVISORY_SERVICES_EXPENSES = "advisory-services-expenses" + ADVISORY_SERVICES_SIP_TRUNKING = "advisory-services-sip-trunking" + ASSETS_REQUESTS = "assets-requests" + AUDIENCE_MINUTES_VIDEO = "audience-minutes-video" + AUTHY_BUCKET_ADJUSTMENT = "authy-bucket-adjustment" + AUTHY_SOFTWARE = "authy-software" + CALLERIDLOOKUPS_API = "calleridlookups-api" + CALLERIDLOOKUPS_PROGRAMMABLEVOICE = "calleridlookups-programmablevoice" + CALLERIDLOOKUPS_TRUNKING = "calleridlookups-trunking" + CALLS_TRUNKING_INBOUND_TOLLFREE_LOCAL = "calls-trunking-inbound-tollfree-local" + CALLS_TRUNKING_INBOUND_TOLLFREE_MOBILE = ( + "calls-trunking-inbound-tollfree-mobile" + ) + CHANNELS_WHATSAPP_CONVERSATION_FREE_1 = "channels-whatsapp-conversation-free-1" + CONFERENCE = "conference" + CONVERSATIONAL_INSIGHTS = "conversational-insights" + CONVERSATIONAL_INSIGHTS_MESSAGES = "conversational-insights-messages" + CONVERSATIONAL_INSIGHTS_VOICE_MINUTES = "conversational-insights-voice-minutes" + DEMO = "demo" + DEMO_UC_SCRIPT_TEST = "demo-uc-script-test" + ELASTIC_SIP_TRUNKING = "elastic-sip-trunking" + ELASTIC_SIP_TRUNKING_CALL_TRANSFERS = "elastic-sip-trunking-call-transfers" + ENTERPRISE_HIPPA = "enterprise-hippa" + FLEX_NAMED_USERS = "flex-named-users" + FLEX_SPINSCI = "flex-spinsci" + FLEX_USERS_1 = "flex-users-1" + FLEX_WFO_PREMIUM_SPEECH_ANALYTICS = "flex-wfo-premium-speech-analytics" + FLEX_XCELERATE = "flex-xcelerate" + FUNCTIONS_ROLLUP = "functions-rollup" + IMP_V1_USAGE = "imp-v1-usage" + IP_MESSAGING_ADDONS = "ip-messaging-addons" + IVR = "ivr" + IVR_CONVERSATIONAL = "ivr-conversational" + IVR_DTMF = "ivr-dtmf" + IVR_VIRTUALAGENT = "ivr-virtualagent" + LIVE = "live" + LIVE_MEDIA_RECORDING_MINUTES = "live-media-recording-minutes" + LONGCODE_MPS = "longcode-mps" + MARKETPLACE_ANALYTICS_ADDONS = "marketplace-analytics-addons" + MARKETPLACE_ISV_ADDONS = "marketplace-isv-addons" + MARKETPLACE_MESSAGING_ADDONS = "marketplace-messaging-addons" + MARKETPLACE_PHONENUMBERS_ADDONS = "marketplace-phonenumbers-addons" + MARKETPLACE_RECORDING_ADDONS = "marketplace-recording-addons" + MARKETPLACE_VIRTUALAGENT_ADDONS = "marketplace-virtualagent-addons" + MARKETPLAY_PAY_ADDONS_SHUTTLE_PAY_CONNECTOR_1 = ( + "marketplay-pay-addons-shuttle-pay-connector-1" + ) + MARKETPLAY_PAY_ADDONS_STRIPE_PAY_CONNECTOR = ( + "marketplay-pay-addons-stripe-pay-connector" + ) + MMS_INBOUND_LONGCODE_CANADA = "mms-inbound-longcode-canada" + MMS_INBOUND_LONGCODE_UNITEDSTATES = "mms-inbound-longcode-unitedstates" + MMS_OUTBOUND_LONGCODE_CANADA = "mms-outbound-longcode-canada" + MMS_OUTBOUND_LONGCODE_UNITEDSTATES = "mms-outbound-longcode-unitedstates" + MMS_OUTBOUND_TOLL_FREE = "mms-outbound-toll-free" + NOTIFY_CHATAPPSANDOTHERCHANNELS = "notify-chatappsandotherchannels" + NOTIFY_NOTIFYSERVICES = "notify-notifyservices" + NOTIFY_PUSHNOTIFICATIONS = "notify-pushnotifications" + PAYMENT_GATEWAY_CONNECTORS = "payment-gateway-connectors" + PAYMENT_SOLUTIONS = "payment-solutions" + PCHAT_BUCKET_ADJUSTMENT = "pchat-bucket-adjustment" + PHONENUMBERS_NUMBERS = "phonenumbers-numbers" + PROG_VOICE_CLIENT_ANDROID = "prog-voice-client-android" + PROG_VOICE_CLIENT_ANDROID_INBOUND = "prog-voice-client-android-inbound" + PROG_VOICE_CLIENT_ANDROID_OUTBOUND = "prog-voice-client-android-outbound" + PROG_VOICE_CLIENT_IOS = "prog-voice-client-ios" + PROG_VOICE_CLIENT_IOS_INBOUND = "prog-voice-client-ios-inbound" + PROG_VOICE_CLIENT_IOS_OUTBOUND = "prog-voice-client-ios-outbound" + PROG_VOICE_CLIENT_SDK = "prog-voice-client-sdk" + PROG_VOICE_CLIENT_WEB = "prog-voice-client-web" + PROG_VOICE_CLIENT_WEB_INBOUND = "prog-voice-client-web-inbound" + PROG_VOICE_CLIENT_WEB_OUTBOUND = "prog-voice-client-web-outbound" + PROGRAMMABLEVOICECONNECTIVITY_MEDIA_STREAMS = ( + "programmablevoiceconnectivity-media-streams" + ) + PSTNCONNECTIVITY_BYOC = "pstnconnectivity-byoc" + PSTNCONNECTIVITY_EMERGENCY = "pstnconnectivity-emergency" + PSTNCONNECTIVITY_MINUTES = "pstnconnectivity-minutes" + PSTNCONNECTIVITY_MINUTES_1 = "pstnconnectivity-minutes-1" + PSTNCONNECTIVITY_MINUTESINBOUNDLOCAL = "pstnconnectivity-minutesinboundlocal" + PSTNCONNECTIVITY_MINUTESINBOUNDMOBILE = "pstnconnectivity-minutesinboundmobile" + PSTNCONNECTIVITY_MINUTESINBOUNDTOLLFREE = ( + "pstnconnectivity-minutesinboundtollfree" + ) + PSTNCONNECTIVITY_MINUTESINBOUNDTOLLFREELOCAL = ( + "pstnconnectivity-minutesinboundtollfreelocal" + ) + PSTNCONNECTIVITY_MINUTESINBOUNDTOLLFREEMOBILE = ( + "pstnconnectivity-minutesinboundtollfreemobile" + ) + PV_ROOM_HOURS = "pv-room-hours" + PV_ROOM_SIMULTANEOUS_PARTICIPANT_CONNECTIONS = ( + "pv-room-simultaneous-participant-connections" + ) + PVIDEO_ROOM_HOURS_AU1 = "pvideo-room-hours-au1" + PVIDEO_ROOM_HOURS_BR1 = "pvideo-room-hours-br1" + PVIDEO_ROOM_HOURS_IE1 = "pvideo-room-hours-ie1" + PVIDEO_ROOM_HOURS_JP1 = "pvideo-room-hours-jp1" + PVIDEO_ROOM_HOURS_SG1 = "pvideo-room-hours-sg1" + PVIDEO_ROOM_HOURS_US1 = "pvideo-room-hours-us1" + PVIDEO_ROOM_HOURS_US2 = "pvideo-room-hours-us2" + RECORDINGS_ENCRYPTED = "recordings-encrypted" + SHORT_CODE_SETUP_FEES = "short-code-setup-fees" + SHORTCODES_MESSAGES_INBOUND = "shortcodes-messages-inbound" + SHORTCODES_MESSAGES_OUTBOUND = "shortcodes-messages-outbound" + SMS_MESSAGES_REGISTRATIONFEES = "sms-messages-registrationfees" + SMS_MMS_PENALTY_FEES = "sms-mms-penalty-fees" + SMS_MMS_PENALTY_FEES_1 = "sms-mms-penalty-fees-1" + SMS_PUMPING_PROTECTION_NON_USCA = "sms-pumping-protection-non-usca" + SMS_PUMPING_PROTECTION_USCA = "sms-pumping-protection-usca" + STUDIO = "studio" + STUDIO_MONTHLY_FEES = "studio-monthly-fees" + SUPERSIM = "supersim" + TASK_ROUTER = "task-router" + TASK_ROUTER_WORKERS = "task-router-workers" + TEST_QUOTA_BUCKETS = "test-quota-buckets" + TEST_UC_SCRIPT_1 = "test-uc-script-1" + TEST_UC_SCRIPT_DEMO_2 = "test-uc-script-demo-2" + TEXT_TO_SPEECH = "text-to-speech" + TME = "tme" + TTS_BASIC = "tts-basic" + TWILIO_EDITIONS = "twilio-editions" + TWILIO_INTERCONNECT_CALIFORNIA = "twilio-interconnect-california" + TWILIO_INTERCONNECT_CALIFORNIA_MONTHLY = ( + "twilio-interconnect-california-monthly" + ) + TWILIO_INTERCONNECT_CALIFORNIA_SETUP = "twilio-interconnect-california-setup" + TWILIO_INTERCONNECT_FRANKFURT = "twilio-interconnect-frankfurt" + TWILIO_INTERCONNECT_FRANKFURT_MO = "twilio-interconnect-frankfurt-mo" + TWILIO_INTERCONNECT_FRANKFURT_SETUP = "twilio-interconnect-frankfurt-setup" + TWILIO_INTERCONNECT_LONDON = "twilio-interconnect-london" + TWILIO_INTERCONNECT_LONDON_MO = "twilio-interconnect-london-mo" + TWILIO_INTERCONNECT_LONDON_SETUP = "twilio-interconnect-london-setup" + TWILIO_INTERCONNECT_SAO_PAULO = "twilio-interconnect-sao-paulo" + TWILIO_INTERCONNECT_SAO_PAULO_MONTHLY = "twilio-interconnect-sao-paulo-monthly" + TWILIO_INTERCONNECT_SAO_PAULO_SETUP = "twilio-interconnect-sao-paulo-setup" + TWILIO_INTERCONNECT_SINGAPORE = "twilio-interconnect-singapore" + TWILIO_INTERCONNECT_SINGAPORE_MO = "twilio-interconnect-singapore-mo" + TWILIO_INTERCONNECT_SINGAPORE_SETUP = "twilio-interconnect-singapore-setup" + TWILIO_INTERCONNECT_SYDNEY = "twilio-interconnect-sydney" + TWILIO_INTERCONNECT_SYDNEY_MO = "twilio-interconnect-sydney-mo" + TWILIO_INTERCONNECT_SYDNEY_SETUP = "twilio-interconnect-sydney-setup" + TWILIO_INTERCONNECT_TOKYO = "twilio-interconnect-tokyo" + TWILIO_INTERCONNECT_TOKYO_MO = "twilio-interconnect-tokyo-mo" + TWILIO_INTERCONNECT_TOKYO_SETUP = "twilio-interconnect-tokyo-setup" + TWILIO_INTERCONNECT_VA = "twilio-interconnect-va" + TWILIO_INTERCONNECT_VA_MO = "twilio-interconnect-va-mo" + TWILIO_INTERCONNECT_VA_SETUP = "twilio-interconnect-va-setup" + TWIML_VERBS = "twiml-verbs" + TWIML_VERBS_SAY = "twiml-verbs-say" + USAGE_PROGRAMMABLE_MESSAGING_ENGAGEMENT_SUITE = ( + "usage-programmable-messaging-engagement-suite" + ) + USAGE_PROGRAMMABLE_MESSAGING_FEES_SERVICES = ( + "usage-programmable-messaging-fees-services" + ) + VERIFY_OUTBOUND_EMAIL = "verify-outbound-email" + VERIFY_PACKAGED_PLANS = "verify-packaged-plans" + VERIFY_SILENT_NETWORK_AUTH = "verify-silent-network-auth" + VERIFY_VOICE_AND_SMS = "verify-voice-and-sms" + VOICE_INSIGHTS_CLIENT_INSIGHTS_MONTHY_COMMIT = ( + "voice-insights-client-insights-monthy-commit" + ) + WIRELESS_DATA_PAYG_ASIA_AFG = "wireless-data-payg-asia-afg" + WIRELESS_MULTI_IMSI_SIM_COMMANDS = "wireless-multi-imsi-sim-commands" + WIRELESS_MULTI_IMSI_SIM_COMMANDS_USA = "wireless-multi-imsi-sim-commands-usa" + WIRELESS_MULTI_IMSI_SIM_DATA = "wireless-multi-imsi-sim-data" + WIRELESS_MULTI_IMSI_SIM_DATA_EU28 = "wireless-multi-imsi-sim-data-eu28" + WIRELESS_MULTI_IMSI_SIM_DATA_USA = "wireless-multi-imsi-sim-data-usa" + WIRELESS_MULTI_IMSI_SIM_MONTHLY_FEES = "wireless-multi-imsi-sim-monthly-fees" + WIRELESS_MULTI_IMSI_SIM_USAGE = "wireless-multi-imsi-sim-usage" + WIRELESS_SUPER_SIM_DATA_NORTH_AMERICA = "wireless-super-sim-data-north-america" + WIRELESS_SUPER_SIM_USAGE = "wireless-super-sim-usage" """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that accrued the usage. @@ -401,6 +893,7 @@ def __repr__(self) -> str: class DailyPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> DailyInstance: """ Build an instance of DailyInstance @@ -421,6 +914,7 @@ def __repr__(self) -> str: class DailyList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the DailyList @@ -623,14 +1117,20 @@ def page( "Category": category, "StartDate": serialize.iso8601_date(start_date), "EndDate": serialize.iso8601_date(end_date), - "IncludeSubaccounts": include_subaccounts, + "IncludeSubaccounts": serialize.boolean_to_string(include_subaccounts), "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 DailyPage(self._version, response, self._solution) async def page_async( @@ -662,15 +1162,19 @@ async def page_async( "Category": category, "StartDate": serialize.iso8601_date(start_date), "EndDate": serialize.iso8601_date(end_date), - "IncludeSubaccounts": include_subaccounts, + "IncludeSubaccounts": serialize.boolean_to_string(include_subaccounts), "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 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 028101a874..4057283e4a 100644 --- a/twilio/rest/api/v2010/account/usage/record/last_month.py +++ b/twilio/rest/api/v2010/account/usage/record/last_month.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import date from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import deserialize, serialize, values @@ -24,34 +23,103 @@ class LastMonthInstance(InstanceResource): + class Category(object): + A2P_10DLC_REGISTRATIONFEES_BRANDREGISTRATION = ( + "a2p-10dlc-registrationfees-brandregistration" + ) + A2P_10DLC_REGISTRATIONFEES_BV = "a2p-10dlc-registrationfees-bv" + A2P_10DLC_REGISTRATIONFEES_CAMPAIGNCHARGES = ( + "a2p-10dlc-registrationfees-campaigncharges" + ) + A2P_10DLC_REGISTRATIONFEES_CAMPAIGNREGISTRATION = ( + "a2p-10dlc-registrationfees-campaignregistration" + ) + A2P_10DLC_REGISTRATIONFEES_CAMPAIGNVETTING = ( + "a2p-10dlc-registrationfees-campaignvetting" + ) + A2P_10DLC_REGISTRATIONFEES_MONTHLY = "a2p-10dlc-registrationfees-monthly" + A2P_10DLC_REGISTRATIONFEES_ONETIME = "a2p-10dlc-registrationfees-onetime" A2P_REGISTRATION_FEES = "a2p-registration-fees" + ACCOUNT_SECURITY = "account-security" AGENT_CONFERENCE = "agent-conference" + AGENT_COPILOT = "agent-copilot" + AGENT_COPILOT_MESSAGES = "agent-copilot-messages" + AGENT_COPILOT_PARTICIPANT_MINUTES = "agent-copilot-participant-minutes" + AI_ASSISTANTS = "ai-assistants" + AI_ASSISTANTS_VOICE = "ai-assistants-voice" AMAZON_POLLY = "amazon-polly" ANSWERING_MACHINE_DETECTION = "answering-machine-detection" + ASSETS = "assets" + AUDIENCE_MINUTES = "audience-minutes" + AUDIENCE_MINUTES_AUDIO = "audience-minutes-audio" AUTHY_AUTHENTICATIONS = "authy-authentications" AUTHY_CALLS_OUTBOUND = "authy-calls-outbound" + AUTHY_EMAIL_AUTHENTICATIONS = "authy-email-authentications" AUTHY_MONTHLY_FEES = "authy-monthly-fees" + AUTHY_OUTBOUND_EMAIL = "authy-outbound-email" AUTHY_PHONE_INTELLIGENCE = "authy-phone-intelligence" AUTHY_PHONE_VERIFICATIONS = "authy-phone-verifications" AUTHY_SMS_OUTBOUND = "authy-sms-outbound" + AUTHY_VERIFY_EMAIL_VERIFICATIONS = "authy-verify-email-verifications" + AUTHY_VERIFY_OUTBOUND_EMAIL = "authy-verify-outbound-email" + AUTOPILOT = "autopilot" + AUTOPILOT_HOME_ASSISTANTS = "autopilot-home-assistants" + AUTOPILOT_MESSAGING = "autopilot-messaging" + AUTOPILOT_OTHER = "autopilot-other" + AUTOPILOT_VOICE = "autopilot-voice" + BASIC_PEER_TO_PEER_ROOMS_PARTICIPANT_MINUTES = ( + "basic-peer-to-peer-rooms-participant-minutes" + ) + BRANDED_CALLING = "branded-calling" + BUNDLE_SMS_BUCKET = "bundle-sms-bucket" + BUNDLE_SUBSCRIPTION_FEES = "bundle-subscription-fees" + CALL_FORWARDING_LOOKUPS = "call-forwarding-lookups" CALL_PROGESS_EVENTS = "call-progess-events" CALLERIDLOOKUPS = "calleridlookups" CALLS = "calls" CALLS_CLIENT = "calls-client" + CALLS_EMERGENCY = "calls-emergency" CALLS_GLOBALCONFERENCE = "calls-globalconference" CALLS_INBOUND = "calls-inbound" CALLS_INBOUND_LOCAL = "calls-inbound-local" CALLS_INBOUND_MOBILE = "calls-inbound-mobile" CALLS_INBOUND_TOLLFREE = "calls-inbound-tollfree" + CALLS_INBOUND_TOLLFREE_LOCAL = "calls-inbound-tollfree-local" + CALLS_INBOUND_TOLLFREE_MOBILE = "calls-inbound-tollfree-mobile" + CALLS_MEDIA_STREAM_MINUTES = "calls-media-stream-minutes" CALLS_OUTBOUND = "calls-outbound" CALLS_PAY_VERB_TRANSACTIONS = "calls-pay-verb-transactions" CALLS_RECORDINGS = "calls-recordings" CALLS_SIP = "calls-sip" CALLS_SIP_INBOUND = "calls-sip-inbound" CALLS_SIP_OUTBOUND = "calls-sip-outbound" + CALLS_TEXT_TO_SPEECH = "calls-text-to-speech" CALLS_TRANSFERS = "calls-transfers" CARRIER_LOOKUPS = "carrier-lookups" + CATEGORY = "category" + CHANNELS = "channels" + CHANNELS_MESSAGING = "channels-messaging" + CHANNELS_MESSAGING_INBOUND = "channels-messaging-inbound" + CHANNELS_MESSAGING_OUTBOUND = "channels-messaging-outbound" + CHANNELS_WHATSAPP = "channels-whatsapp" + CHANNELS_WHATSAPP_CONVERSATION_AUTHENTICATION = ( + "channels-whatsapp-conversation-authentication" + ) + CHANNELS_WHATSAPP_CONVERSATION_FREE = "channels-whatsapp-conversation-free" + CHANNELS_WHATSAPP_CONVERSATION_MARKETING = ( + "channels-whatsapp-conversation-marketing" + ) + CHANNELS_WHATSAPP_CONVERSATION_SERVICE = ( + "channels-whatsapp-conversation-service" + ) + CHANNELS_WHATSAPP_CONVERSATION_UTILITY = ( + "channels-whatsapp-conversation-utility" + ) + CHANNELS_WHATSAPP_INBOUND = "channels-whatsapp-inbound" + CHANNELS_WHATSAPP_OUTBOUND = "channels-whatsapp-outbound" + CHAT_VIRTUAL_AGENT = "chat-virtual-agent" + CONVERSATION_RELAY = "conversation-relay" CONVERSATIONS = "conversations" CONVERSATIONS_API_REQUESTS = "conversations-api-requests" CONVERSATIONS_CONVERSATION_EVENTS = "conversations-conversation-events" @@ -60,8 +128,40 @@ class Category(object): CONVERSATIONS_PARTICIPANT_EVENTS = "conversations-participant-events" CONVERSATIONS_PARTICIPANTS = "conversations-participants" CPS = "cps" + CREDIT_TRANSFER = "credit-transfer" + EMAIL = "email" + EMERGING_TECH = "emerging-tech" + ENGAGEMENT_SUITE_PACKAGED_PLANS = "engagement-suite-packaged-plans" + ENHANCED_LINE_TYPE_LOOKUPS = "enhanced-line-type-lookups" + ENTERPRISE = "enterprise" + EVENTS = "events" + EXPERIMENT_FRANCE_SMS = "experiment-france-sms" + EXPERIMENT_INDIA_SMS = "experiment-india-sms" + EXPERIMENT_UK_SMS = "experiment-uk-sms" + FAILED_MESSAGE_PROCESSING_FEE = "failed-message-processing-fee" + FLEX = "flex" + FLEX_ACTIVE_USER_HOURS = "flex-active-user-hours" + FLEX_CONCURRENT_USERS = "flex-concurrent-users" + FLEX_CONVERSATIONAL_INSIGHTS = "flex-conversational-insights" + FLEX_CONVERSATIONAL_INSIGHTS_MESSAGES = "flex-conversational-insights-messages" + FLEX_CONVERSATIONAL_INSIGHTS_VOICE_MINUTES = ( + "flex-conversational-insights-voice-minutes" + ) + FLEX_EMAIL_USAGE = "flex-email-usage" + FLEX_MESSAGING_USAGE = "flex-messaging-usage" + FLEX_PARTNER_SPINSCI = "flex-partner-spinsci" + FLEX_PARTNER_XCELERATE = "flex-partner-xcelerate" + FLEX_RESELLER_ECOSYSTEM = "flex-reseller-ecosystem" + FLEX_UNIQUE_USER = "flex-unique-user" FLEX_USAGE = "flex-usage" + FLEX_USERS = "flex-users" + FLEX_VOICE_MINUTE = "flex-voice-minute" + FLEX_YTICA = "flex-ytica" FRAUD_LOOKUPS = "fraud-lookups" + FRONTLINE = "frontline" + FRONTLINE_USERS = "frontline-users" + FUNCTIONS = "functions" + GENERIC_PAY_TRANSACTIONS = "generic-pay-transactions" GROUP_ROOMS = "group-rooms" GROUP_ROOMS_DATA_TRACK = "group-rooms-data-track" GROUP_ROOMS_ENCRYPTED_MEDIA_RECORDED = "group-rooms-encrypted-media-recorded" @@ -71,7 +171,17 @@ class Category(object): GROUP_ROOMS_MEDIA_STORED = "group-rooms-media-stored" GROUP_ROOMS_PARTICIPANT_MINUTES = "group-rooms-participant-minutes" GROUP_ROOMS_RECORDED_MINUTES = "group-rooms-recorded-minutes" - IMP_V1_USAGE = "imp-v1-usage" + IP_MESSAGING = "ip-messaging" + IP_MESSAGING_COMMANDS = "ip-messaging-commands" + IP_MESSAGING_DATA_STORAGE = "ip-messaging-data-storage" + IP_MESSAGING_DATA_TRANSFER = "ip-messaging-data-transfer" + IP_MESSAGING_ENDPOINT_CONNECTIVITY = "ip-messaging-endpoint-connectivity" + IVR_VIRTUAL_AGENT_CUSTOM_VOICES = "ivr-virtual-agent-custom-voices" + IVR_VIRTUAL_AGENT_GENAI = "ivr-virtual-agent-genai" + LINE_STATUS_LOOKUPS = "line-status-lookups" + LIVE_ACTIVITY_LOOKUPS = "live-activity-lookups" + LOOKUP_BUCKET_ADJUSTMENT = "lookup-bucket-adjustment" + LOOKUP_IDENTITY_MATCH = "lookup-identity-match" LOOKUPS = "lookups" MARKETPLACE = "marketplace" MARKETPLACE_ALGORITHMIA_NAMED_ENTITY_RECOGNITION = ( @@ -82,6 +192,13 @@ class Category(object): MARKETPLACE_CAPIO_SPEECH_TO_TEXT = "marketplace-capio-speech-to-text" MARKETPLACE_CONVRIZA_ABABA = "marketplace-convriza-ababa" MARKETPLACE_DEEPGRAM_PHRASE_DETECTOR = "marketplace-deepgram-phrase-detector" + MARKETPLACE_DEEPGRAM_TRANSCRIPTION = "marketplace-deepgram-transcription" + MARKETPLACE_DEEPGRAM_TRANSCRIPTION_BASE = ( + "marketplace-deepgram-transcription-base" + ) + MARKETPLACE_DEEPGRAM_TRANSSCRIPTION_ENHANCED = ( + "marketplace-deepgram-transscription-enhanced" + ) MARKETPLACE_DIGITAL_SEGMENT_BUSINESS_INFO = ( "marketplace-digital-segment-business-info" ) @@ -107,6 +224,9 @@ class Category(object): "marketplace-keen-io-contact-center-analytics" ) MARKETPLACE_MARCHEX_CLEANCALL = "marketplace-marchex-cleancall" + MARKETPLACE_MARCHEX_RECORDING_ANALYSIS = ( + "marketplace-marchex-recording-analysis" + ) MARKETPLACE_MARCHEX_SENTIMENT_ANALYSIS_FOR_SMS = ( "marketplace-marchex-sentiment-analysis-for-sms" ) @@ -123,14 +243,42 @@ class Category(object): "marketplace-nextcaller-advanced-caller-identification" ) MARKETPLACE_NOMOROBO_SPAM_SCORE = "marketplace-nomorobo-spam-score" + MARKETPLACE_PAY_ADDONS = "marketplace-pay-addons" + MARKETPLACE_PAY_ADDONS_BASECOMMERCE_PAY_CONNECTOR = ( + "marketplace-pay-addons-basecommerce-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_BRAINTREE_PAY_CONNECTOR = ( + "marketplace-pay-addons-braintree-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_CARDCONNECT_PAY_CONNECTOR = ( + "marketplace-pay-addons-cardconnect-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_CHASE_PAY_CONNECTOR = ( + "marketplace-pay-addons-chase-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_SHUTTLE_PAY_CONNECTOR = ( + "marketplace-pay-addons-shuttle-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_STRIPE_PAY_CONNECTOR = ( + "marketplace-pay-addons-stripe-pay-connector" + ) MARKETPLACE_PAYFONE_TCPA_COMPLIANCE = "marketplace-payfone-tcpa-compliance" + MARKETPLACE_POLY_AI_CONNECTOR = "marketplace-poly-ai-connector" + MARKETPLACE_REALPHONEVALIDATION = "marketplace-realphonevalidation" MARKETPLACE_REMEETING_AUTOMATIC_SPEECH_RECOGNITION = ( "marketplace-remeeting-automatic-speech-recognition" ) + MARKETPLACE_SPOKE_PHONE_LICENSE_PRO = "marketplace-spoke-phone-license-pro" + MARKETPLACE_SPOKE_PHONE_LICENSE_STANDARD = ( + "marketplace-spoke-phone-license-standard" + ) MARKETPLACE_TCPA_DEFENSE_SOLUTIONS_BLACKLIST_FEED = ( "marketplace-tcpa-defense-solutions-blacklist-feed" ) MARKETPLACE_TELO_OPENCNAM = "marketplace-telo-opencnam" + MARKETPLACE_TRESTLE_SOLUTIONS_CALLER_IDENTIFICATION = ( + "marketplace-trestle-solutions-caller-identification" + ) MARKETPLACE_TRUECNAM_TRUE_SPAM = "marketplace-truecnam-true-spam" MARKETPLACE_TWILIO_CALLER_NAME_LOOKUP_US = ( "marketplace-twilio-caller-name-lookup-us" @@ -143,6 +291,9 @@ class Category(object): MARKETPLACE_VOICEBASE_TRANSCRIPTION_CUSTOM_VOCABULARY = ( "marketplace-voicebase-transcription-custom-vocabulary" ) + MARKETPLACE_WEB_PURIFY_PROFANITY_FILTER = ( + "marketplace-web-purify-profanity-filter" + ) MARKETPLACE_WHITEPAGES_PRO_CALLER_IDENTIFICATION = ( "marketplace-whitepages-pro-caller-identification" ) @@ -157,15 +308,23 @@ class Category(object): MARKETPLACE_YTICA_CONTACT_CENTER_REPORTING_ANALYTICS = ( "marketplace-ytica-contact-center-reporting-analytics" ) + MARKETPLAY_PAY_ADDONS_SHUTTLE_PAY_CONNECTOR = ( + "marketplay-pay-addons-shuttle-pay-connector" + ) + MEDIA_COMPOSER_MINUTES = "media-composer-minutes" MEDIASTORAGE = "mediastorage" + MIN_SPEND_ADJUSTMENTS = "min-spend-adjustments" MMS = "mms" MMS_INBOUND = "mms-inbound" MMS_INBOUND_LONGCODE = "mms-inbound-longcode" MMS_INBOUND_SHORTCODE = "mms-inbound-shortcode" + MMS_INBOUND_TOLL_FREE = "mms-inbound-toll-free" MMS_MESSAGES_CARRIERFEES = "mms-messages-carrierfees" MMS_OUTBOUND = "mms-outbound" MMS_OUTBOUND_LONGCODE = "mms-outbound-longcode" MMS_OUTBOUND_SHORTCODE = "mms-outbound-shortcode" + MMS_OUTBOUND_TOLLFREE = "mms-outbound-tollfree" + MONITOR = "monitor" MONITOR_READS = "monitor-reads" MONITOR_STORAGE = "monitor-storage" MONITOR_WRITES = "monitor-writes" @@ -174,6 +333,12 @@ class Category(object): NOTIFY_CHANNELS = "notify-channels" NUMBER_FORMAT_LOOKUPS = "number-format-lookups" PCHAT = "pchat" + PCHAT_ACTIONS = "pchat-actions" + PCHAT_APS = "pchat-aps" + PCHAT_CONV_MED_STORAGE = "pchat-conv-med-storage" + PCHAT_MESSAGES = "pchat-messages" + PCHAT_NOTIFICATIONS = "pchat-notifications" + PCHAT_READS = "pchat-reads" PCHAT_USERS = "pchat-users" PEER_TO_PEER_ROOMS_PARTICIPANT_MINUTES = ( "peer-to-peer-rooms-participant-minutes" @@ -183,18 +348,41 @@ class Category(object): PFAX_MINUTES_INBOUND = "pfax-minutes-inbound" PFAX_MINUTES_OUTBOUND = "pfax-minutes-outbound" PFAX_PAGES = "pfax-pages" + PHONE_QUALITY_SCORE_LOOKUPS = "phone-quality-score-lookups" PHONENUMBERS = "phonenumbers" PHONENUMBERS_CPS = "phonenumbers-cps" PHONENUMBERS_EMERGENCY = "phonenumbers-emergency" PHONENUMBERS_LOCAL = "phonenumbers-local" PHONENUMBERS_MOBILE = "phonenumbers-mobile" + PHONENUMBERS_PORTING = "phonenumbers-porting" PHONENUMBERS_SETUPS = "phonenumbers-setups" PHONENUMBERS_TOLLFREE = "phonenumbers-tollfree" PREMIUMSUPPORT = "premiumsupport" + PREMIUMSUPPORT_PERCENTAGE_SPEND = "premiumsupport-percentage-spend" + PROGRAMMABLEVOICE_PLATFORM = "programmablevoice-platform" + PROGRAMMABLEVOICECONN_CLIENTSDK = "programmablevoiceconn-clientsdk" + PROGRAMMABLEVOICECONN_CLIENTSDK_INBOUND = ( + "programmablevoiceconn-clientsdk-inbound" + ) + PROGRAMMABLEVOICECONN_CLIENTSDK_OUTBOUND = ( + "programmablevoiceconn-clientsdk-outbound" + ) + PROGRAMMABLEVOICECONN_ONNET = "programmablevoiceconn-onnet" + PROGRAMMABLEVOICECONN_ONNET_INBOUND = "programmablevoiceconn-onnet-inbound" + PROGRAMMABLEVOICECONN_ONNET_OUTBOUND = "programmablevoiceconn-onnet-outbound" + PROGRAMMABLEVOICECONN_SIP = "programmablevoiceconn-sip" + PROGRAMMABLEVOICECONN_SIP_INBOUND = "programmablevoiceconn-sip-inbound" + PROGRAMMABLEVOICECONN_SIP_OUTBOUND = "programmablevoiceconn-sip-outbound" + PROGRAMMABLEVOICECONNECTIVITY = "programmablevoiceconnectivity" PROXY = "proxy" PROXY_ACTIVE_SESSIONS = "proxy-active-sessions" + PROXY_BUCKET_ADJUSTMENT = "proxy-bucket-adjustment" + PROXY_LICENSES = "proxy-licenses" PSTNCONNECTIVITY = "pstnconnectivity" + PSTNCONNECTIVITY_INBOUND = "pstnconnectivity-inbound" + PSTNCONNECTIVITY_OUTBOUND = "pstnconnectivity-outbound" PV = "pv" + PV_BASIC_ROOMS = "pv-basic-rooms" PV_COMPOSITION_MEDIA_DOWNLOADED = "pv-composition-media-downloaded" PV_COMPOSITION_MEDIA_ENCRYPTED = "pv-composition-media-encrypted" PV_COMPOSITION_MEDIA_STORED = "pv-composition-media-stored" @@ -210,18 +398,20 @@ class Category(object): PV_ROOM_PARTICIPANTS_US2 = "pv-room-participants-us2" PV_ROOMS = "pv-rooms" PV_SIP_ENDPOINT_REGISTRATIONS = "pv-sip-endpoint-registrations" + RCS_MESSAGES = "rcs-messages" + REASSIGNED_NUMBER = "reassigned-number" RECORDINGS = "recordings" RECORDINGSTORAGE = "recordingstorage" - ROOMS_GROUP_BANDWIDTH = "rooms-group-bandwidth" - ROOMS_GROUP_MINUTES = "rooms-group-minutes" - ROOMS_PEER_TO_PEER_MINUTES = "rooms-peer-to-peer-minutes" SHORTCODES = "shortcodes" SHORTCODES_CUSTOMEROWNED = "shortcodes-customerowned" SHORTCODES_MMS_ENABLEMENT = "shortcodes-mms-enablement" SHORTCODES_MPS = "shortcodes-mps" SHORTCODES_RANDOM = "shortcodes-random" + SHORTCODES_SETUP_FEES = "shortcodes-setup-fees" SHORTCODES_UK = "shortcodes-uk" SHORTCODES_VANITY = "shortcodes-vanity" + SIM_SWAP_LOOKUPS = "sim-swap-lookups" + SIP_SECURE_MEDIA = "sip-secure-media" SMALL_GROUP_ROOMS = "small-group-rooms" SMALL_GROUP_ROOMS_DATA_TRACK = "small-group-rooms-data-track" SMALL_GROUP_ROOMS_PARTICIPANT_MINUTES = "small-group-rooms-participant-minutes" @@ -229,13 +419,30 @@ class Category(object): SMS_INBOUND = "sms-inbound" SMS_INBOUND_LONGCODE = "sms-inbound-longcode" SMS_INBOUND_SHORTCODE = "sms-inbound-shortcode" + SMS_INBOUND_TOLLFREE = "sms-inbound-tollfree" SMS_MESSAGES_CARRIERFEES = "sms-messages-carrierfees" SMS_MESSAGES_FEATURES = "sms-messages-features" + SMS_MESSAGES_FEATURES_ENGAGEMENT_SUITE = ( + "sms-messages-features-engagement-suite" + ) + SMS_MESSAGES_FEATURES_MESSAGE_REDACTION = ( + "sms-messages-features-message-redaction" + ) SMS_MESSAGES_FEATURES_SENDERID = "sms-messages-features-senderid" + SMS_MPS = "sms-mps" + SMS_MPS_SHORTCODE = "sms-mps-shortcode" + SMS_MPS_TOLLFREE = "sms-mps-tollfree" + SMS_MPS_TOLLFREE_SETUP = "sms-mps-tollfree-setup" + SMS_NATIONAL_REGULATORY_PROTECTION = "sms-national-regulatory-protection" SMS_OUTBOUND = "sms-outbound" SMS_OUTBOUND_CONTENT_INSPECTION = "sms-outbound-content-inspection" SMS_OUTBOUND_LONGCODE = "sms-outbound-longcode" SMS_OUTBOUND_SHORTCODE = "sms-outbound-shortcode" + SMS_OUTBOUND_TOLLFREE = "sms-outbound-tollfree" + SMS_PUMPING_PROTECTION = "sms-pumping-protection" + SMS_PUMPING_RISK = "sms-pumping-risk" + SMSMESSAGES_BUCKET_ADJUSTMENTS = "smsmessages-bucket-adjustments" + SMSMESSAGES_OUTBOUND_DOMESTIC = "smsmessages-outbound-domestic" SPEECH_RECOGNITION = "speech-recognition" STUDIO_ENGAGEMENTS = "studio-engagements" SYNC = "sync" @@ -254,6 +461,7 @@ class Category(object): TRUNKING_RECORDINGS = "trunking-recordings" TRUNKING_SECURE = "trunking-secure" TRUNKING_TERMINATION = "trunking-termination" + TTS_GOOGLE = "tts-google" TURNMEGABYTES = "turnmegabytes" TURNMEGABYTES_AUSTRALIA = "turnmegabytes-australia" TURNMEGABYTES_BRASIL = "turnmegabytes-brasil" @@ -264,13 +472,27 @@ class Category(object): TURNMEGABYTES_SINGAPORE = "turnmegabytes-singapore" TURNMEGABYTES_USEAST = "turnmegabytes-useast" TURNMEGABYTES_USWEST = "turnmegabytes-uswest" + TWILIO_FOR_SALESFORCE = "twilio-for-salesforce" + TWILIO_FOR_SALESFORCE_LICENSES = "twilio-for-salesforce-licenses" TWILIO_INTERCONNECT = "twilio-interconnect" + TWIML = "twiml" + USAGE_FLEX_VIDEO = "usage-flex-video" + USAGE_FUNCTIONS = "usage-functions" + USAGE_RCS_BASIC_MESSAGES_OUTBOUND = "usage-rcs-basic-messages-outbound" + USAGE_RCS_MESSAGES = "usage-rcs-messages" + USAGE_RCS_MESSAGES_INBOUND = "usage-rcs-messages-inbound" + USAGE_RCS_MESSAGING_CARRIER_FEES = "usage-rcs-messaging-carrier-fees" + USAGE_RCS_SINGLE_MESSAGES_OUTBOUND = "usage-rcs-single-messages-outbound" + VERIFY_PACKAGE_PLANS = "verify-package-plans" VERIFY_PUSH = "verify-push" + VERIFY_SNA = "verify-sna" VERIFY_TOTP = "verify-totp" + VERIFY_VOICE_SMS = "verify-voice-sms" VERIFY_WHATSAPP_CONVERSATIONS_BUSINESS_INITIATED = ( "verify-whatsapp-conversations-business-initiated" ) VIDEO_RECORDINGS = "video-recordings" + VIDEO_ROOMS_TURN_MEGABYTES = "video-rooms-turn-megabytes" VIRTUAL_AGENT = "virtual-agent" VOICE_INSIGHTS = "voice-insights" VOICE_INSIGHTS_CLIENT_INSIGHTS_ON_DEMAND_MINUTE = ( @@ -285,12 +507,104 @@ class Category(object): VOICE_INSIGHTS_SIP_TRUNKING_INSIGHTS_ON_DEMAND_MINUTE = ( "voice-insights-sip-trunking-insights-on-demand-minute" ) + VOICE_INTELLIGENCE = "voice-intelligence" + VOICE_INTELLIGENCE_EIP_OPERATORS = "voice-intelligence-eip-operators" + VOICE_INTELLIGENCE_OPERATORS = "voice-intelligence-operators" + VOICE_INTELLIGENCE_TRANSCRIPTION = "voice-intelligence-transcription" + WDS = "wds" WIRELESS = "wireless" + WIRELESS_DATA = "wireless-data" + WIRELESS_DATA_PAYG = "wireless-data-payg" + WIRELESS_DATA_PAYG_AFRICA = "wireless-data-payg-africa" + WIRELESS_DATA_PAYG_ASIA = "wireless-data-payg-asia" + WIRELESS_DATA_PAYG_CENTRALANDSOUTHAMERICA = ( + "wireless-data-payg-centralandsouthamerica" + ) + WIRELESS_DATA_PAYG_EUROPE = "wireless-data-payg-europe" + WIRELESS_DATA_PAYG_NORTHAMERICA = "wireless-data-payg-northamerica" + WIRELESS_DATA_PAYG_OCEANIA = "wireless-data-payg-oceania" + WIRELESS_DATA_QUOTA1 = "wireless-data-quota1" + WIRELESS_DATA_QUOTA1_AFRICA = "wireless-data-quota1-africa" + WIRELESS_DATA_QUOTA1_ASIA = "wireless-data-quota1-asia" + WIRELESS_DATA_QUOTA1_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quota1-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTA1_EUROPE = "wireless-data-quota1-europe" + WIRELESS_DATA_QUOTA1_NORTHAMERICA = "wireless-data-quota1-northamerica" + WIRELESS_DATA_QUOTA1_OCEANIA = "wireless-data-quota1-oceania" + WIRELESS_DATA_QUOTA10 = "wireless-data-quota10" + WIRELESS_DATA_QUOTA10_AFRICA = "wireless-data-quota10-africa" + WIRELESS_DATA_QUOTA10_ASIA = "wireless-data-quota10-asia" + WIRELESS_DATA_QUOTA10_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quota10-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTA10_EUROPE = "wireless-data-quota10-europe" + WIRELESS_DATA_QUOTA10_NORTHAMERICA = "wireless-data-quota10-northamerica" + WIRELESS_DATA_QUOTA10_OCEANIA = "wireless-data-quota10-oceania" + WIRELESS_DATA_QUOTA50 = "wireless-data-quota50" + WIRELESS_DATA_QUOTA50_AFRICA = "wireless-data-quota50-africa" + WIRELESS_DATA_QUOTA50_ASIA = "wireless-data-quota50-asia" + WIRELESS_DATA_QUOTA50_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quota50-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTA50_EUROPE = "wireless-data-quota50-europe" + WIRELESS_DATA_QUOTA50_NORTHAMERICA = "wireless-data-quota50-northamerica" + WIRELESS_DATA_QUOTA50_OCEANIA = "wireless-data-quota50-oceania" + WIRELESS_DATA_QUOTACUSTOM = "wireless-data-quotacustom" + WIRELESS_DATA_QUOTACUSTOM_AFRICA = "wireless-data-quotacustom-africa" + WIRELESS_DATA_QUOTACUSTOM_ASIA = "wireless-data-quotacustom-asia" + WIRELESS_DATA_QUOTACUSTOM_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quotacustom-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTACUSTOM_EUROPE = "wireless-data-quotacustom-europe" + WIRELESS_DATA_QUOTACUSTOM_NORTHAMERICA = ( + "wireless-data-quotacustom-northamerica" + ) + WIRELESS_DATA_QUOTACUSTOM_OCEANIA = "wireless-data-quotacustom-oceania" + WIRELESS_MRC_PAYG = "wireless-mrc-payg" + WIRELESS_MRC_QUOTA1 = "wireless-mrc-quota1" + WIRELESS_MRC_QUOTA10 = "wireless-mrc-quota10" + WIRELESS_MRC_QUOTA50 = "wireless-mrc-quota50" + WIRELESS_MRC_QUOTACUSTOM = "wireless-mrc-quotacustom" WIRELESS_ORDERS = "wireless-orders" WIRELESS_ORDERS_ARTWORK = "wireless-orders-artwork" WIRELESS_ORDERS_BULK = "wireless-orders-bulk" WIRELESS_ORDERS_ESIM = "wireless-orders-esim" WIRELESS_ORDERS_STARTER = "wireless-orders-starter" + WIRELESS_QUOTAS = "wireless-quotas" + WIRELESS_SMS_AFRICA = "wireless-sms-africa" + WIRELESS_SMS_ASIA = "wireless-sms-asia" + WIRELESS_SMS_CENTRALANDSOUTHAMERICA = "wireless-sms-centralandsouthamerica" + WIRELESS_SMS_EUROPE = "wireless-sms-europe" + WIRELESS_SMS_NORTHAMERICA = "wireless-sms-northamerica" + WIRELESS_SMS_OCEANIA = "wireless-sms-oceania" + WIRELESS_SUPER_SIM = "wireless-super-sim" + WIRELESS_SUPER_SIM_DATA = "wireless-super-sim-data" + WIRELESS_SUPER_SIM_DATA_NORTH_AMERICA_USA = ( + "wireless-super-sim-data-north-america-usa" + ) + WIRELESS_SUPER_SIM_DATA_PAYG = "wireless-super-sim-data-payg" + WIRELESS_SUPER_SIM_DATA_PAYG_EUROPE = "wireless-super-sim-data-payg-europe" + WIRELESS_SUPER_SIM_DATA_PAYG_NORTH_AMERICA = ( + "wireless-super-sim-data-payg-north-america" + ) + WIRELESS_SUPER_SIM_HARDWARE = "wireless-super-sim-hardware" + WIRELESS_SUPER_SIM_HARDWARE_BULK = "wireless-super-sim-hardware-bulk" + WIRELESS_SUPER_SIM_SMSCOMMANDS = "wireless-super-sim-smscommands" + WIRELESS_SUPER_SIM_SMSCOMMANDS_AFRICA = "wireless-super-sim-smscommands-africa" + WIRELESS_SUPER_SIM_SMSCOMMANDS_ASIA = "wireless-super-sim-smscommands-asia" + WIRELESS_SUPER_SIM_SMSCOMMANDS_CENT_AND_SOUTH_AMERICA = ( + "wireless-super-sim-smscommands-cent-and-south-america" + ) + WIRELESS_SUPER_SIM_SMSCOMMANDS_EUROPE = "wireless-super-sim-smscommands-europe" + WIRELESS_SUPER_SIM_SMSCOMMANDS_NORTH_AMERICA = ( + "wireless-super-sim-smscommands-north-america" + ) + WIRELESS_SUPER_SIM_SMSCOMMANDS_OCEANIA = ( + "wireless-super-sim-smscommands-oceania" + ) + WIRELESS_SUPER_SIM_SUBSCRIPTION = "wireless-super-sim-subscription" + WIRELESS_SUPER_SIM_SUBSCRIPTION_PAYG = "wireless-super-sim-subscription-payg" WIRELESS_USAGE = "wireless-usage" WIRELESS_USAGE_COMMANDS = "wireless-usage-commands" WIRELESS_USAGE_COMMANDS_AFRICA = "wireless-usage-commands-africa" @@ -342,6 +656,184 @@ class Category(object): WIRELESS_USAGE_MRC_SUSPENDED = "wireless-usage-mrc-suspended" WIRELESS_USAGE_SMS = "wireless-usage-sms" WIRELESS_USAGE_VOICE = "wireless-usage-voice" + A2P_FAST_TRACK_ONBOARDING = "a2p-fast-track-onboarding" + ADVISORY_SERVICES = "advisory-services" + ADVISORY_SERVICES_BILLED = "advisory-services-billed" + ADVISORY_SERVICES_CALL_TRACKING = "advisory-services-call-tracking" + ADVISORY_SERVICES_DATA_SERVICES = "advisory-services-data-services" + ADVISORY_SERVICES_EXPENSES = "advisory-services-expenses" + ADVISORY_SERVICES_SIP_TRUNKING = "advisory-services-sip-trunking" + ASSETS_REQUESTS = "assets-requests" + AUDIENCE_MINUTES_VIDEO = "audience-minutes-video" + AUTHY_BUCKET_ADJUSTMENT = "authy-bucket-adjustment" + AUTHY_SOFTWARE = "authy-software" + CALLERIDLOOKUPS_API = "calleridlookups-api" + CALLERIDLOOKUPS_PROGRAMMABLEVOICE = "calleridlookups-programmablevoice" + CALLERIDLOOKUPS_TRUNKING = "calleridlookups-trunking" + CALLS_TRUNKING_INBOUND_TOLLFREE_LOCAL = "calls-trunking-inbound-tollfree-local" + CALLS_TRUNKING_INBOUND_TOLLFREE_MOBILE = ( + "calls-trunking-inbound-tollfree-mobile" + ) + CHANNELS_WHATSAPP_CONVERSATION_FREE_1 = "channels-whatsapp-conversation-free-1" + CONFERENCE = "conference" + CONVERSATIONAL_INSIGHTS = "conversational-insights" + CONVERSATIONAL_INSIGHTS_MESSAGES = "conversational-insights-messages" + CONVERSATIONAL_INSIGHTS_VOICE_MINUTES = "conversational-insights-voice-minutes" + DEMO = "demo" + DEMO_UC_SCRIPT_TEST = "demo-uc-script-test" + ELASTIC_SIP_TRUNKING = "elastic-sip-trunking" + ELASTIC_SIP_TRUNKING_CALL_TRANSFERS = "elastic-sip-trunking-call-transfers" + ENTERPRISE_HIPPA = "enterprise-hippa" + FLEX_NAMED_USERS = "flex-named-users" + FLEX_SPINSCI = "flex-spinsci" + FLEX_USERS_1 = "flex-users-1" + FLEX_WFO_PREMIUM_SPEECH_ANALYTICS = "flex-wfo-premium-speech-analytics" + FLEX_XCELERATE = "flex-xcelerate" + FUNCTIONS_ROLLUP = "functions-rollup" + IMP_V1_USAGE = "imp-v1-usage" + IP_MESSAGING_ADDONS = "ip-messaging-addons" + IVR = "ivr" + IVR_CONVERSATIONAL = "ivr-conversational" + IVR_DTMF = "ivr-dtmf" + IVR_VIRTUALAGENT = "ivr-virtualagent" + LIVE = "live" + LIVE_MEDIA_RECORDING_MINUTES = "live-media-recording-minutes" + LONGCODE_MPS = "longcode-mps" + MARKETPLACE_ANALYTICS_ADDONS = "marketplace-analytics-addons" + MARKETPLACE_ISV_ADDONS = "marketplace-isv-addons" + MARKETPLACE_MESSAGING_ADDONS = "marketplace-messaging-addons" + MARKETPLACE_PHONENUMBERS_ADDONS = "marketplace-phonenumbers-addons" + MARKETPLACE_RECORDING_ADDONS = "marketplace-recording-addons" + MARKETPLACE_VIRTUALAGENT_ADDONS = "marketplace-virtualagent-addons" + MARKETPLAY_PAY_ADDONS_SHUTTLE_PAY_CONNECTOR_1 = ( + "marketplay-pay-addons-shuttle-pay-connector-1" + ) + MARKETPLAY_PAY_ADDONS_STRIPE_PAY_CONNECTOR = ( + "marketplay-pay-addons-stripe-pay-connector" + ) + MMS_INBOUND_LONGCODE_CANADA = "mms-inbound-longcode-canada" + MMS_INBOUND_LONGCODE_UNITEDSTATES = "mms-inbound-longcode-unitedstates" + MMS_OUTBOUND_LONGCODE_CANADA = "mms-outbound-longcode-canada" + MMS_OUTBOUND_LONGCODE_UNITEDSTATES = "mms-outbound-longcode-unitedstates" + MMS_OUTBOUND_TOLL_FREE = "mms-outbound-toll-free" + NOTIFY_CHATAPPSANDOTHERCHANNELS = "notify-chatappsandotherchannels" + NOTIFY_NOTIFYSERVICES = "notify-notifyservices" + NOTIFY_PUSHNOTIFICATIONS = "notify-pushnotifications" + PAYMENT_GATEWAY_CONNECTORS = "payment-gateway-connectors" + PAYMENT_SOLUTIONS = "payment-solutions" + PCHAT_BUCKET_ADJUSTMENT = "pchat-bucket-adjustment" + PHONENUMBERS_NUMBERS = "phonenumbers-numbers" + PROG_VOICE_CLIENT_ANDROID = "prog-voice-client-android" + PROG_VOICE_CLIENT_ANDROID_INBOUND = "prog-voice-client-android-inbound" + PROG_VOICE_CLIENT_ANDROID_OUTBOUND = "prog-voice-client-android-outbound" + PROG_VOICE_CLIENT_IOS = "prog-voice-client-ios" + PROG_VOICE_CLIENT_IOS_INBOUND = "prog-voice-client-ios-inbound" + PROG_VOICE_CLIENT_IOS_OUTBOUND = "prog-voice-client-ios-outbound" + PROG_VOICE_CLIENT_SDK = "prog-voice-client-sdk" + PROG_VOICE_CLIENT_WEB = "prog-voice-client-web" + PROG_VOICE_CLIENT_WEB_INBOUND = "prog-voice-client-web-inbound" + PROG_VOICE_CLIENT_WEB_OUTBOUND = "prog-voice-client-web-outbound" + PROGRAMMABLEVOICECONNECTIVITY_MEDIA_STREAMS = ( + "programmablevoiceconnectivity-media-streams" + ) + PSTNCONNECTIVITY_BYOC = "pstnconnectivity-byoc" + PSTNCONNECTIVITY_EMERGENCY = "pstnconnectivity-emergency" + PSTNCONNECTIVITY_MINUTES = "pstnconnectivity-minutes" + PSTNCONNECTIVITY_MINUTES_1 = "pstnconnectivity-minutes-1" + PSTNCONNECTIVITY_MINUTESINBOUNDLOCAL = "pstnconnectivity-minutesinboundlocal" + PSTNCONNECTIVITY_MINUTESINBOUNDMOBILE = "pstnconnectivity-minutesinboundmobile" + PSTNCONNECTIVITY_MINUTESINBOUNDTOLLFREE = ( + "pstnconnectivity-minutesinboundtollfree" + ) + PSTNCONNECTIVITY_MINUTESINBOUNDTOLLFREELOCAL = ( + "pstnconnectivity-minutesinboundtollfreelocal" + ) + PSTNCONNECTIVITY_MINUTESINBOUNDTOLLFREEMOBILE = ( + "pstnconnectivity-minutesinboundtollfreemobile" + ) + PV_ROOM_HOURS = "pv-room-hours" + PV_ROOM_SIMULTANEOUS_PARTICIPANT_CONNECTIONS = ( + "pv-room-simultaneous-participant-connections" + ) + PVIDEO_ROOM_HOURS_AU1 = "pvideo-room-hours-au1" + PVIDEO_ROOM_HOURS_BR1 = "pvideo-room-hours-br1" + PVIDEO_ROOM_HOURS_IE1 = "pvideo-room-hours-ie1" + PVIDEO_ROOM_HOURS_JP1 = "pvideo-room-hours-jp1" + PVIDEO_ROOM_HOURS_SG1 = "pvideo-room-hours-sg1" + PVIDEO_ROOM_HOURS_US1 = "pvideo-room-hours-us1" + PVIDEO_ROOM_HOURS_US2 = "pvideo-room-hours-us2" + RECORDINGS_ENCRYPTED = "recordings-encrypted" + SHORT_CODE_SETUP_FEES = "short-code-setup-fees" + SHORTCODES_MESSAGES_INBOUND = "shortcodes-messages-inbound" + SHORTCODES_MESSAGES_OUTBOUND = "shortcodes-messages-outbound" + SMS_MESSAGES_REGISTRATIONFEES = "sms-messages-registrationfees" + SMS_MMS_PENALTY_FEES = "sms-mms-penalty-fees" + SMS_MMS_PENALTY_FEES_1 = "sms-mms-penalty-fees-1" + SMS_PUMPING_PROTECTION_NON_USCA = "sms-pumping-protection-non-usca" + SMS_PUMPING_PROTECTION_USCA = "sms-pumping-protection-usca" + STUDIO = "studio" + STUDIO_MONTHLY_FEES = "studio-monthly-fees" + SUPERSIM = "supersim" + TASK_ROUTER = "task-router" + TASK_ROUTER_WORKERS = "task-router-workers" + TEST_QUOTA_BUCKETS = "test-quota-buckets" + TEST_UC_SCRIPT_1 = "test-uc-script-1" + TEST_UC_SCRIPT_DEMO_2 = "test-uc-script-demo-2" + TEXT_TO_SPEECH = "text-to-speech" + TME = "tme" + TTS_BASIC = "tts-basic" + TWILIO_EDITIONS = "twilio-editions" + TWILIO_INTERCONNECT_CALIFORNIA = "twilio-interconnect-california" + TWILIO_INTERCONNECT_CALIFORNIA_MONTHLY = ( + "twilio-interconnect-california-monthly" + ) + TWILIO_INTERCONNECT_CALIFORNIA_SETUP = "twilio-interconnect-california-setup" + TWILIO_INTERCONNECT_FRANKFURT = "twilio-interconnect-frankfurt" + TWILIO_INTERCONNECT_FRANKFURT_MO = "twilio-interconnect-frankfurt-mo" + TWILIO_INTERCONNECT_FRANKFURT_SETUP = "twilio-interconnect-frankfurt-setup" + TWILIO_INTERCONNECT_LONDON = "twilio-interconnect-london" + TWILIO_INTERCONNECT_LONDON_MO = "twilio-interconnect-london-mo" + TWILIO_INTERCONNECT_LONDON_SETUP = "twilio-interconnect-london-setup" + TWILIO_INTERCONNECT_SAO_PAULO = "twilio-interconnect-sao-paulo" + TWILIO_INTERCONNECT_SAO_PAULO_MONTHLY = "twilio-interconnect-sao-paulo-monthly" + TWILIO_INTERCONNECT_SAO_PAULO_SETUP = "twilio-interconnect-sao-paulo-setup" + TWILIO_INTERCONNECT_SINGAPORE = "twilio-interconnect-singapore" + TWILIO_INTERCONNECT_SINGAPORE_MO = "twilio-interconnect-singapore-mo" + TWILIO_INTERCONNECT_SINGAPORE_SETUP = "twilio-interconnect-singapore-setup" + TWILIO_INTERCONNECT_SYDNEY = "twilio-interconnect-sydney" + TWILIO_INTERCONNECT_SYDNEY_MO = "twilio-interconnect-sydney-mo" + TWILIO_INTERCONNECT_SYDNEY_SETUP = "twilio-interconnect-sydney-setup" + TWILIO_INTERCONNECT_TOKYO = "twilio-interconnect-tokyo" + TWILIO_INTERCONNECT_TOKYO_MO = "twilio-interconnect-tokyo-mo" + TWILIO_INTERCONNECT_TOKYO_SETUP = "twilio-interconnect-tokyo-setup" + TWILIO_INTERCONNECT_VA = "twilio-interconnect-va" + TWILIO_INTERCONNECT_VA_MO = "twilio-interconnect-va-mo" + TWILIO_INTERCONNECT_VA_SETUP = "twilio-interconnect-va-setup" + TWIML_VERBS = "twiml-verbs" + TWIML_VERBS_SAY = "twiml-verbs-say" + USAGE_PROGRAMMABLE_MESSAGING_ENGAGEMENT_SUITE = ( + "usage-programmable-messaging-engagement-suite" + ) + USAGE_PROGRAMMABLE_MESSAGING_FEES_SERVICES = ( + "usage-programmable-messaging-fees-services" + ) + VERIFY_OUTBOUND_EMAIL = "verify-outbound-email" + VERIFY_PACKAGED_PLANS = "verify-packaged-plans" + VERIFY_SILENT_NETWORK_AUTH = "verify-silent-network-auth" + VERIFY_VOICE_AND_SMS = "verify-voice-and-sms" + VOICE_INSIGHTS_CLIENT_INSIGHTS_MONTHY_COMMIT = ( + "voice-insights-client-insights-monthy-commit" + ) + WIRELESS_DATA_PAYG_ASIA_AFG = "wireless-data-payg-asia-afg" + WIRELESS_MULTI_IMSI_SIM_COMMANDS = "wireless-multi-imsi-sim-commands" + WIRELESS_MULTI_IMSI_SIM_COMMANDS_USA = "wireless-multi-imsi-sim-commands-usa" + WIRELESS_MULTI_IMSI_SIM_DATA = "wireless-multi-imsi-sim-data" + WIRELESS_MULTI_IMSI_SIM_DATA_EU28 = "wireless-multi-imsi-sim-data-eu28" + WIRELESS_MULTI_IMSI_SIM_DATA_USA = "wireless-multi-imsi-sim-data-usa" + WIRELESS_MULTI_IMSI_SIM_MONTHLY_FEES = "wireless-multi-imsi-sim-monthly-fees" + WIRELESS_MULTI_IMSI_SIM_USAGE = "wireless-multi-imsi-sim-usage" + WIRELESS_SUPER_SIM_DATA_NORTH_AMERICA = "wireless-super-sim-data-north-america" + WIRELESS_SUPER_SIM_USAGE = "wireless-super-sim-usage" """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that accrued the usage. @@ -401,6 +893,7 @@ def __repr__(self) -> str: class LastMonthPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> LastMonthInstance: """ Build an instance of LastMonthInstance @@ -421,6 +914,7 @@ def __repr__(self) -> str: class LastMonthList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the LastMonthList @@ -623,14 +1117,20 @@ def page( "Category": category, "StartDate": serialize.iso8601_date(start_date), "EndDate": serialize.iso8601_date(end_date), - "IncludeSubaccounts": include_subaccounts, + "IncludeSubaccounts": serialize.boolean_to_string(include_subaccounts), "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 LastMonthPage(self._version, response, self._solution) async def page_async( @@ -662,15 +1162,19 @@ async def page_async( "Category": category, "StartDate": serialize.iso8601_date(start_date), "EndDate": serialize.iso8601_date(end_date), - "IncludeSubaccounts": include_subaccounts, + "IncludeSubaccounts": serialize.boolean_to_string(include_subaccounts), "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 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 62590e80ac..117db692bf 100644 --- a/twilio/rest/api/v2010/account/usage/record/monthly.py +++ b/twilio/rest/api/v2010/account/usage/record/monthly.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import date from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import deserialize, serialize, values @@ -24,34 +23,103 @@ class MonthlyInstance(InstanceResource): + class Category(object): + A2P_10DLC_REGISTRATIONFEES_BRANDREGISTRATION = ( + "a2p-10dlc-registrationfees-brandregistration" + ) + A2P_10DLC_REGISTRATIONFEES_BV = "a2p-10dlc-registrationfees-bv" + A2P_10DLC_REGISTRATIONFEES_CAMPAIGNCHARGES = ( + "a2p-10dlc-registrationfees-campaigncharges" + ) + A2P_10DLC_REGISTRATIONFEES_CAMPAIGNREGISTRATION = ( + "a2p-10dlc-registrationfees-campaignregistration" + ) + A2P_10DLC_REGISTRATIONFEES_CAMPAIGNVETTING = ( + "a2p-10dlc-registrationfees-campaignvetting" + ) + A2P_10DLC_REGISTRATIONFEES_MONTHLY = "a2p-10dlc-registrationfees-monthly" + A2P_10DLC_REGISTRATIONFEES_ONETIME = "a2p-10dlc-registrationfees-onetime" A2P_REGISTRATION_FEES = "a2p-registration-fees" + ACCOUNT_SECURITY = "account-security" AGENT_CONFERENCE = "agent-conference" + AGENT_COPILOT = "agent-copilot" + AGENT_COPILOT_MESSAGES = "agent-copilot-messages" + AGENT_COPILOT_PARTICIPANT_MINUTES = "agent-copilot-participant-minutes" + AI_ASSISTANTS = "ai-assistants" + AI_ASSISTANTS_VOICE = "ai-assistants-voice" AMAZON_POLLY = "amazon-polly" ANSWERING_MACHINE_DETECTION = "answering-machine-detection" + ASSETS = "assets" + AUDIENCE_MINUTES = "audience-minutes" + AUDIENCE_MINUTES_AUDIO = "audience-minutes-audio" AUTHY_AUTHENTICATIONS = "authy-authentications" AUTHY_CALLS_OUTBOUND = "authy-calls-outbound" + AUTHY_EMAIL_AUTHENTICATIONS = "authy-email-authentications" AUTHY_MONTHLY_FEES = "authy-monthly-fees" + AUTHY_OUTBOUND_EMAIL = "authy-outbound-email" AUTHY_PHONE_INTELLIGENCE = "authy-phone-intelligence" AUTHY_PHONE_VERIFICATIONS = "authy-phone-verifications" AUTHY_SMS_OUTBOUND = "authy-sms-outbound" + AUTHY_VERIFY_EMAIL_VERIFICATIONS = "authy-verify-email-verifications" + AUTHY_VERIFY_OUTBOUND_EMAIL = "authy-verify-outbound-email" + AUTOPILOT = "autopilot" + AUTOPILOT_HOME_ASSISTANTS = "autopilot-home-assistants" + AUTOPILOT_MESSAGING = "autopilot-messaging" + AUTOPILOT_OTHER = "autopilot-other" + AUTOPILOT_VOICE = "autopilot-voice" + BASIC_PEER_TO_PEER_ROOMS_PARTICIPANT_MINUTES = ( + "basic-peer-to-peer-rooms-participant-minutes" + ) + BRANDED_CALLING = "branded-calling" + BUNDLE_SMS_BUCKET = "bundle-sms-bucket" + BUNDLE_SUBSCRIPTION_FEES = "bundle-subscription-fees" + CALL_FORWARDING_LOOKUPS = "call-forwarding-lookups" CALL_PROGESS_EVENTS = "call-progess-events" CALLERIDLOOKUPS = "calleridlookups" CALLS = "calls" CALLS_CLIENT = "calls-client" + CALLS_EMERGENCY = "calls-emergency" CALLS_GLOBALCONFERENCE = "calls-globalconference" CALLS_INBOUND = "calls-inbound" CALLS_INBOUND_LOCAL = "calls-inbound-local" CALLS_INBOUND_MOBILE = "calls-inbound-mobile" CALLS_INBOUND_TOLLFREE = "calls-inbound-tollfree" + CALLS_INBOUND_TOLLFREE_LOCAL = "calls-inbound-tollfree-local" + CALLS_INBOUND_TOLLFREE_MOBILE = "calls-inbound-tollfree-mobile" + CALLS_MEDIA_STREAM_MINUTES = "calls-media-stream-minutes" CALLS_OUTBOUND = "calls-outbound" CALLS_PAY_VERB_TRANSACTIONS = "calls-pay-verb-transactions" CALLS_RECORDINGS = "calls-recordings" CALLS_SIP = "calls-sip" CALLS_SIP_INBOUND = "calls-sip-inbound" CALLS_SIP_OUTBOUND = "calls-sip-outbound" + CALLS_TEXT_TO_SPEECH = "calls-text-to-speech" CALLS_TRANSFERS = "calls-transfers" CARRIER_LOOKUPS = "carrier-lookups" + CATEGORY = "category" + CHANNELS = "channels" + CHANNELS_MESSAGING = "channels-messaging" + CHANNELS_MESSAGING_INBOUND = "channels-messaging-inbound" + CHANNELS_MESSAGING_OUTBOUND = "channels-messaging-outbound" + CHANNELS_WHATSAPP = "channels-whatsapp" + CHANNELS_WHATSAPP_CONVERSATION_AUTHENTICATION = ( + "channels-whatsapp-conversation-authentication" + ) + CHANNELS_WHATSAPP_CONVERSATION_FREE = "channels-whatsapp-conversation-free" + CHANNELS_WHATSAPP_CONVERSATION_MARKETING = ( + "channels-whatsapp-conversation-marketing" + ) + CHANNELS_WHATSAPP_CONVERSATION_SERVICE = ( + "channels-whatsapp-conversation-service" + ) + CHANNELS_WHATSAPP_CONVERSATION_UTILITY = ( + "channels-whatsapp-conversation-utility" + ) + CHANNELS_WHATSAPP_INBOUND = "channels-whatsapp-inbound" + CHANNELS_WHATSAPP_OUTBOUND = "channels-whatsapp-outbound" + CHAT_VIRTUAL_AGENT = "chat-virtual-agent" + CONVERSATION_RELAY = "conversation-relay" CONVERSATIONS = "conversations" CONVERSATIONS_API_REQUESTS = "conversations-api-requests" CONVERSATIONS_CONVERSATION_EVENTS = "conversations-conversation-events" @@ -60,8 +128,40 @@ class Category(object): CONVERSATIONS_PARTICIPANT_EVENTS = "conversations-participant-events" CONVERSATIONS_PARTICIPANTS = "conversations-participants" CPS = "cps" + CREDIT_TRANSFER = "credit-transfer" + EMAIL = "email" + EMERGING_TECH = "emerging-tech" + ENGAGEMENT_SUITE_PACKAGED_PLANS = "engagement-suite-packaged-plans" + ENHANCED_LINE_TYPE_LOOKUPS = "enhanced-line-type-lookups" + ENTERPRISE = "enterprise" + EVENTS = "events" + EXPERIMENT_FRANCE_SMS = "experiment-france-sms" + EXPERIMENT_INDIA_SMS = "experiment-india-sms" + EXPERIMENT_UK_SMS = "experiment-uk-sms" + FAILED_MESSAGE_PROCESSING_FEE = "failed-message-processing-fee" + FLEX = "flex" + FLEX_ACTIVE_USER_HOURS = "flex-active-user-hours" + FLEX_CONCURRENT_USERS = "flex-concurrent-users" + FLEX_CONVERSATIONAL_INSIGHTS = "flex-conversational-insights" + FLEX_CONVERSATIONAL_INSIGHTS_MESSAGES = "flex-conversational-insights-messages" + FLEX_CONVERSATIONAL_INSIGHTS_VOICE_MINUTES = ( + "flex-conversational-insights-voice-minutes" + ) + FLEX_EMAIL_USAGE = "flex-email-usage" + FLEX_MESSAGING_USAGE = "flex-messaging-usage" + FLEX_PARTNER_SPINSCI = "flex-partner-spinsci" + FLEX_PARTNER_XCELERATE = "flex-partner-xcelerate" + FLEX_RESELLER_ECOSYSTEM = "flex-reseller-ecosystem" + FLEX_UNIQUE_USER = "flex-unique-user" FLEX_USAGE = "flex-usage" + FLEX_USERS = "flex-users" + FLEX_VOICE_MINUTE = "flex-voice-minute" + FLEX_YTICA = "flex-ytica" FRAUD_LOOKUPS = "fraud-lookups" + FRONTLINE = "frontline" + FRONTLINE_USERS = "frontline-users" + FUNCTIONS = "functions" + GENERIC_PAY_TRANSACTIONS = "generic-pay-transactions" GROUP_ROOMS = "group-rooms" GROUP_ROOMS_DATA_TRACK = "group-rooms-data-track" GROUP_ROOMS_ENCRYPTED_MEDIA_RECORDED = "group-rooms-encrypted-media-recorded" @@ -71,7 +171,17 @@ class Category(object): GROUP_ROOMS_MEDIA_STORED = "group-rooms-media-stored" GROUP_ROOMS_PARTICIPANT_MINUTES = "group-rooms-participant-minutes" GROUP_ROOMS_RECORDED_MINUTES = "group-rooms-recorded-minutes" - IMP_V1_USAGE = "imp-v1-usage" + IP_MESSAGING = "ip-messaging" + IP_MESSAGING_COMMANDS = "ip-messaging-commands" + IP_MESSAGING_DATA_STORAGE = "ip-messaging-data-storage" + IP_MESSAGING_DATA_TRANSFER = "ip-messaging-data-transfer" + IP_MESSAGING_ENDPOINT_CONNECTIVITY = "ip-messaging-endpoint-connectivity" + IVR_VIRTUAL_AGENT_CUSTOM_VOICES = "ivr-virtual-agent-custom-voices" + IVR_VIRTUAL_AGENT_GENAI = "ivr-virtual-agent-genai" + LINE_STATUS_LOOKUPS = "line-status-lookups" + LIVE_ACTIVITY_LOOKUPS = "live-activity-lookups" + LOOKUP_BUCKET_ADJUSTMENT = "lookup-bucket-adjustment" + LOOKUP_IDENTITY_MATCH = "lookup-identity-match" LOOKUPS = "lookups" MARKETPLACE = "marketplace" MARKETPLACE_ALGORITHMIA_NAMED_ENTITY_RECOGNITION = ( @@ -82,6 +192,13 @@ class Category(object): MARKETPLACE_CAPIO_SPEECH_TO_TEXT = "marketplace-capio-speech-to-text" MARKETPLACE_CONVRIZA_ABABA = "marketplace-convriza-ababa" MARKETPLACE_DEEPGRAM_PHRASE_DETECTOR = "marketplace-deepgram-phrase-detector" + MARKETPLACE_DEEPGRAM_TRANSCRIPTION = "marketplace-deepgram-transcription" + MARKETPLACE_DEEPGRAM_TRANSCRIPTION_BASE = ( + "marketplace-deepgram-transcription-base" + ) + MARKETPLACE_DEEPGRAM_TRANSSCRIPTION_ENHANCED = ( + "marketplace-deepgram-transscription-enhanced" + ) MARKETPLACE_DIGITAL_SEGMENT_BUSINESS_INFO = ( "marketplace-digital-segment-business-info" ) @@ -107,6 +224,9 @@ class Category(object): "marketplace-keen-io-contact-center-analytics" ) MARKETPLACE_MARCHEX_CLEANCALL = "marketplace-marchex-cleancall" + MARKETPLACE_MARCHEX_RECORDING_ANALYSIS = ( + "marketplace-marchex-recording-analysis" + ) MARKETPLACE_MARCHEX_SENTIMENT_ANALYSIS_FOR_SMS = ( "marketplace-marchex-sentiment-analysis-for-sms" ) @@ -123,14 +243,42 @@ class Category(object): "marketplace-nextcaller-advanced-caller-identification" ) MARKETPLACE_NOMOROBO_SPAM_SCORE = "marketplace-nomorobo-spam-score" + MARKETPLACE_PAY_ADDONS = "marketplace-pay-addons" + MARKETPLACE_PAY_ADDONS_BASECOMMERCE_PAY_CONNECTOR = ( + "marketplace-pay-addons-basecommerce-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_BRAINTREE_PAY_CONNECTOR = ( + "marketplace-pay-addons-braintree-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_CARDCONNECT_PAY_CONNECTOR = ( + "marketplace-pay-addons-cardconnect-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_CHASE_PAY_CONNECTOR = ( + "marketplace-pay-addons-chase-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_SHUTTLE_PAY_CONNECTOR = ( + "marketplace-pay-addons-shuttle-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_STRIPE_PAY_CONNECTOR = ( + "marketplace-pay-addons-stripe-pay-connector" + ) MARKETPLACE_PAYFONE_TCPA_COMPLIANCE = "marketplace-payfone-tcpa-compliance" + MARKETPLACE_POLY_AI_CONNECTOR = "marketplace-poly-ai-connector" + MARKETPLACE_REALPHONEVALIDATION = "marketplace-realphonevalidation" MARKETPLACE_REMEETING_AUTOMATIC_SPEECH_RECOGNITION = ( "marketplace-remeeting-automatic-speech-recognition" ) + MARKETPLACE_SPOKE_PHONE_LICENSE_PRO = "marketplace-spoke-phone-license-pro" + MARKETPLACE_SPOKE_PHONE_LICENSE_STANDARD = ( + "marketplace-spoke-phone-license-standard" + ) MARKETPLACE_TCPA_DEFENSE_SOLUTIONS_BLACKLIST_FEED = ( "marketplace-tcpa-defense-solutions-blacklist-feed" ) MARKETPLACE_TELO_OPENCNAM = "marketplace-telo-opencnam" + MARKETPLACE_TRESTLE_SOLUTIONS_CALLER_IDENTIFICATION = ( + "marketplace-trestle-solutions-caller-identification" + ) MARKETPLACE_TRUECNAM_TRUE_SPAM = "marketplace-truecnam-true-spam" MARKETPLACE_TWILIO_CALLER_NAME_LOOKUP_US = ( "marketplace-twilio-caller-name-lookup-us" @@ -143,6 +291,9 @@ class Category(object): MARKETPLACE_VOICEBASE_TRANSCRIPTION_CUSTOM_VOCABULARY = ( "marketplace-voicebase-transcription-custom-vocabulary" ) + MARKETPLACE_WEB_PURIFY_PROFANITY_FILTER = ( + "marketplace-web-purify-profanity-filter" + ) MARKETPLACE_WHITEPAGES_PRO_CALLER_IDENTIFICATION = ( "marketplace-whitepages-pro-caller-identification" ) @@ -157,15 +308,23 @@ class Category(object): MARKETPLACE_YTICA_CONTACT_CENTER_REPORTING_ANALYTICS = ( "marketplace-ytica-contact-center-reporting-analytics" ) + MARKETPLAY_PAY_ADDONS_SHUTTLE_PAY_CONNECTOR = ( + "marketplay-pay-addons-shuttle-pay-connector" + ) + MEDIA_COMPOSER_MINUTES = "media-composer-minutes" MEDIASTORAGE = "mediastorage" + MIN_SPEND_ADJUSTMENTS = "min-spend-adjustments" MMS = "mms" MMS_INBOUND = "mms-inbound" MMS_INBOUND_LONGCODE = "mms-inbound-longcode" MMS_INBOUND_SHORTCODE = "mms-inbound-shortcode" + MMS_INBOUND_TOLL_FREE = "mms-inbound-toll-free" MMS_MESSAGES_CARRIERFEES = "mms-messages-carrierfees" MMS_OUTBOUND = "mms-outbound" MMS_OUTBOUND_LONGCODE = "mms-outbound-longcode" MMS_OUTBOUND_SHORTCODE = "mms-outbound-shortcode" + MMS_OUTBOUND_TOLLFREE = "mms-outbound-tollfree" + MONITOR = "monitor" MONITOR_READS = "monitor-reads" MONITOR_STORAGE = "monitor-storage" MONITOR_WRITES = "monitor-writes" @@ -174,6 +333,12 @@ class Category(object): NOTIFY_CHANNELS = "notify-channels" NUMBER_FORMAT_LOOKUPS = "number-format-lookups" PCHAT = "pchat" + PCHAT_ACTIONS = "pchat-actions" + PCHAT_APS = "pchat-aps" + PCHAT_CONV_MED_STORAGE = "pchat-conv-med-storage" + PCHAT_MESSAGES = "pchat-messages" + PCHAT_NOTIFICATIONS = "pchat-notifications" + PCHAT_READS = "pchat-reads" PCHAT_USERS = "pchat-users" PEER_TO_PEER_ROOMS_PARTICIPANT_MINUTES = ( "peer-to-peer-rooms-participant-minutes" @@ -183,18 +348,41 @@ class Category(object): PFAX_MINUTES_INBOUND = "pfax-minutes-inbound" PFAX_MINUTES_OUTBOUND = "pfax-minutes-outbound" PFAX_PAGES = "pfax-pages" + PHONE_QUALITY_SCORE_LOOKUPS = "phone-quality-score-lookups" PHONENUMBERS = "phonenumbers" PHONENUMBERS_CPS = "phonenumbers-cps" PHONENUMBERS_EMERGENCY = "phonenumbers-emergency" PHONENUMBERS_LOCAL = "phonenumbers-local" PHONENUMBERS_MOBILE = "phonenumbers-mobile" + PHONENUMBERS_PORTING = "phonenumbers-porting" PHONENUMBERS_SETUPS = "phonenumbers-setups" PHONENUMBERS_TOLLFREE = "phonenumbers-tollfree" PREMIUMSUPPORT = "premiumsupport" + PREMIUMSUPPORT_PERCENTAGE_SPEND = "premiumsupport-percentage-spend" + PROGRAMMABLEVOICE_PLATFORM = "programmablevoice-platform" + PROGRAMMABLEVOICECONN_CLIENTSDK = "programmablevoiceconn-clientsdk" + PROGRAMMABLEVOICECONN_CLIENTSDK_INBOUND = ( + "programmablevoiceconn-clientsdk-inbound" + ) + PROGRAMMABLEVOICECONN_CLIENTSDK_OUTBOUND = ( + "programmablevoiceconn-clientsdk-outbound" + ) + PROGRAMMABLEVOICECONN_ONNET = "programmablevoiceconn-onnet" + PROGRAMMABLEVOICECONN_ONNET_INBOUND = "programmablevoiceconn-onnet-inbound" + PROGRAMMABLEVOICECONN_ONNET_OUTBOUND = "programmablevoiceconn-onnet-outbound" + PROGRAMMABLEVOICECONN_SIP = "programmablevoiceconn-sip" + PROGRAMMABLEVOICECONN_SIP_INBOUND = "programmablevoiceconn-sip-inbound" + PROGRAMMABLEVOICECONN_SIP_OUTBOUND = "programmablevoiceconn-sip-outbound" + PROGRAMMABLEVOICECONNECTIVITY = "programmablevoiceconnectivity" PROXY = "proxy" PROXY_ACTIVE_SESSIONS = "proxy-active-sessions" + PROXY_BUCKET_ADJUSTMENT = "proxy-bucket-adjustment" + PROXY_LICENSES = "proxy-licenses" PSTNCONNECTIVITY = "pstnconnectivity" + PSTNCONNECTIVITY_INBOUND = "pstnconnectivity-inbound" + PSTNCONNECTIVITY_OUTBOUND = "pstnconnectivity-outbound" PV = "pv" + PV_BASIC_ROOMS = "pv-basic-rooms" PV_COMPOSITION_MEDIA_DOWNLOADED = "pv-composition-media-downloaded" PV_COMPOSITION_MEDIA_ENCRYPTED = "pv-composition-media-encrypted" PV_COMPOSITION_MEDIA_STORED = "pv-composition-media-stored" @@ -210,18 +398,20 @@ class Category(object): PV_ROOM_PARTICIPANTS_US2 = "pv-room-participants-us2" PV_ROOMS = "pv-rooms" PV_SIP_ENDPOINT_REGISTRATIONS = "pv-sip-endpoint-registrations" + RCS_MESSAGES = "rcs-messages" + REASSIGNED_NUMBER = "reassigned-number" RECORDINGS = "recordings" RECORDINGSTORAGE = "recordingstorage" - ROOMS_GROUP_BANDWIDTH = "rooms-group-bandwidth" - ROOMS_GROUP_MINUTES = "rooms-group-minutes" - ROOMS_PEER_TO_PEER_MINUTES = "rooms-peer-to-peer-minutes" SHORTCODES = "shortcodes" SHORTCODES_CUSTOMEROWNED = "shortcodes-customerowned" SHORTCODES_MMS_ENABLEMENT = "shortcodes-mms-enablement" SHORTCODES_MPS = "shortcodes-mps" SHORTCODES_RANDOM = "shortcodes-random" + SHORTCODES_SETUP_FEES = "shortcodes-setup-fees" SHORTCODES_UK = "shortcodes-uk" SHORTCODES_VANITY = "shortcodes-vanity" + SIM_SWAP_LOOKUPS = "sim-swap-lookups" + SIP_SECURE_MEDIA = "sip-secure-media" SMALL_GROUP_ROOMS = "small-group-rooms" SMALL_GROUP_ROOMS_DATA_TRACK = "small-group-rooms-data-track" SMALL_GROUP_ROOMS_PARTICIPANT_MINUTES = "small-group-rooms-participant-minutes" @@ -229,13 +419,30 @@ class Category(object): SMS_INBOUND = "sms-inbound" SMS_INBOUND_LONGCODE = "sms-inbound-longcode" SMS_INBOUND_SHORTCODE = "sms-inbound-shortcode" + SMS_INBOUND_TOLLFREE = "sms-inbound-tollfree" SMS_MESSAGES_CARRIERFEES = "sms-messages-carrierfees" SMS_MESSAGES_FEATURES = "sms-messages-features" + SMS_MESSAGES_FEATURES_ENGAGEMENT_SUITE = ( + "sms-messages-features-engagement-suite" + ) + SMS_MESSAGES_FEATURES_MESSAGE_REDACTION = ( + "sms-messages-features-message-redaction" + ) SMS_MESSAGES_FEATURES_SENDERID = "sms-messages-features-senderid" + SMS_MPS = "sms-mps" + SMS_MPS_SHORTCODE = "sms-mps-shortcode" + SMS_MPS_TOLLFREE = "sms-mps-tollfree" + SMS_MPS_TOLLFREE_SETUP = "sms-mps-tollfree-setup" + SMS_NATIONAL_REGULATORY_PROTECTION = "sms-national-regulatory-protection" SMS_OUTBOUND = "sms-outbound" SMS_OUTBOUND_CONTENT_INSPECTION = "sms-outbound-content-inspection" SMS_OUTBOUND_LONGCODE = "sms-outbound-longcode" SMS_OUTBOUND_SHORTCODE = "sms-outbound-shortcode" + SMS_OUTBOUND_TOLLFREE = "sms-outbound-tollfree" + SMS_PUMPING_PROTECTION = "sms-pumping-protection" + SMS_PUMPING_RISK = "sms-pumping-risk" + SMSMESSAGES_BUCKET_ADJUSTMENTS = "smsmessages-bucket-adjustments" + SMSMESSAGES_OUTBOUND_DOMESTIC = "smsmessages-outbound-domestic" SPEECH_RECOGNITION = "speech-recognition" STUDIO_ENGAGEMENTS = "studio-engagements" SYNC = "sync" @@ -254,6 +461,7 @@ class Category(object): TRUNKING_RECORDINGS = "trunking-recordings" TRUNKING_SECURE = "trunking-secure" TRUNKING_TERMINATION = "trunking-termination" + TTS_GOOGLE = "tts-google" TURNMEGABYTES = "turnmegabytes" TURNMEGABYTES_AUSTRALIA = "turnmegabytes-australia" TURNMEGABYTES_BRASIL = "turnmegabytes-brasil" @@ -264,13 +472,27 @@ class Category(object): TURNMEGABYTES_SINGAPORE = "turnmegabytes-singapore" TURNMEGABYTES_USEAST = "turnmegabytes-useast" TURNMEGABYTES_USWEST = "turnmegabytes-uswest" + TWILIO_FOR_SALESFORCE = "twilio-for-salesforce" + TWILIO_FOR_SALESFORCE_LICENSES = "twilio-for-salesforce-licenses" TWILIO_INTERCONNECT = "twilio-interconnect" + TWIML = "twiml" + USAGE_FLEX_VIDEO = "usage-flex-video" + USAGE_FUNCTIONS = "usage-functions" + USAGE_RCS_BASIC_MESSAGES_OUTBOUND = "usage-rcs-basic-messages-outbound" + USAGE_RCS_MESSAGES = "usage-rcs-messages" + USAGE_RCS_MESSAGES_INBOUND = "usage-rcs-messages-inbound" + USAGE_RCS_MESSAGING_CARRIER_FEES = "usage-rcs-messaging-carrier-fees" + USAGE_RCS_SINGLE_MESSAGES_OUTBOUND = "usage-rcs-single-messages-outbound" + VERIFY_PACKAGE_PLANS = "verify-package-plans" VERIFY_PUSH = "verify-push" + VERIFY_SNA = "verify-sna" VERIFY_TOTP = "verify-totp" + VERIFY_VOICE_SMS = "verify-voice-sms" VERIFY_WHATSAPP_CONVERSATIONS_BUSINESS_INITIATED = ( "verify-whatsapp-conversations-business-initiated" ) VIDEO_RECORDINGS = "video-recordings" + VIDEO_ROOMS_TURN_MEGABYTES = "video-rooms-turn-megabytes" VIRTUAL_AGENT = "virtual-agent" VOICE_INSIGHTS = "voice-insights" VOICE_INSIGHTS_CLIENT_INSIGHTS_ON_DEMAND_MINUTE = ( @@ -285,12 +507,104 @@ class Category(object): VOICE_INSIGHTS_SIP_TRUNKING_INSIGHTS_ON_DEMAND_MINUTE = ( "voice-insights-sip-trunking-insights-on-demand-minute" ) + VOICE_INTELLIGENCE = "voice-intelligence" + VOICE_INTELLIGENCE_EIP_OPERATORS = "voice-intelligence-eip-operators" + VOICE_INTELLIGENCE_OPERATORS = "voice-intelligence-operators" + VOICE_INTELLIGENCE_TRANSCRIPTION = "voice-intelligence-transcription" + WDS = "wds" WIRELESS = "wireless" + WIRELESS_DATA = "wireless-data" + WIRELESS_DATA_PAYG = "wireless-data-payg" + WIRELESS_DATA_PAYG_AFRICA = "wireless-data-payg-africa" + WIRELESS_DATA_PAYG_ASIA = "wireless-data-payg-asia" + WIRELESS_DATA_PAYG_CENTRALANDSOUTHAMERICA = ( + "wireless-data-payg-centralandsouthamerica" + ) + WIRELESS_DATA_PAYG_EUROPE = "wireless-data-payg-europe" + WIRELESS_DATA_PAYG_NORTHAMERICA = "wireless-data-payg-northamerica" + WIRELESS_DATA_PAYG_OCEANIA = "wireless-data-payg-oceania" + WIRELESS_DATA_QUOTA1 = "wireless-data-quota1" + WIRELESS_DATA_QUOTA1_AFRICA = "wireless-data-quota1-africa" + WIRELESS_DATA_QUOTA1_ASIA = "wireless-data-quota1-asia" + WIRELESS_DATA_QUOTA1_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quota1-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTA1_EUROPE = "wireless-data-quota1-europe" + WIRELESS_DATA_QUOTA1_NORTHAMERICA = "wireless-data-quota1-northamerica" + WIRELESS_DATA_QUOTA1_OCEANIA = "wireless-data-quota1-oceania" + WIRELESS_DATA_QUOTA10 = "wireless-data-quota10" + WIRELESS_DATA_QUOTA10_AFRICA = "wireless-data-quota10-africa" + WIRELESS_DATA_QUOTA10_ASIA = "wireless-data-quota10-asia" + WIRELESS_DATA_QUOTA10_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quota10-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTA10_EUROPE = "wireless-data-quota10-europe" + WIRELESS_DATA_QUOTA10_NORTHAMERICA = "wireless-data-quota10-northamerica" + WIRELESS_DATA_QUOTA10_OCEANIA = "wireless-data-quota10-oceania" + WIRELESS_DATA_QUOTA50 = "wireless-data-quota50" + WIRELESS_DATA_QUOTA50_AFRICA = "wireless-data-quota50-africa" + WIRELESS_DATA_QUOTA50_ASIA = "wireless-data-quota50-asia" + WIRELESS_DATA_QUOTA50_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quota50-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTA50_EUROPE = "wireless-data-quota50-europe" + WIRELESS_DATA_QUOTA50_NORTHAMERICA = "wireless-data-quota50-northamerica" + WIRELESS_DATA_QUOTA50_OCEANIA = "wireless-data-quota50-oceania" + WIRELESS_DATA_QUOTACUSTOM = "wireless-data-quotacustom" + WIRELESS_DATA_QUOTACUSTOM_AFRICA = "wireless-data-quotacustom-africa" + WIRELESS_DATA_QUOTACUSTOM_ASIA = "wireless-data-quotacustom-asia" + WIRELESS_DATA_QUOTACUSTOM_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quotacustom-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTACUSTOM_EUROPE = "wireless-data-quotacustom-europe" + WIRELESS_DATA_QUOTACUSTOM_NORTHAMERICA = ( + "wireless-data-quotacustom-northamerica" + ) + WIRELESS_DATA_QUOTACUSTOM_OCEANIA = "wireless-data-quotacustom-oceania" + WIRELESS_MRC_PAYG = "wireless-mrc-payg" + WIRELESS_MRC_QUOTA1 = "wireless-mrc-quota1" + WIRELESS_MRC_QUOTA10 = "wireless-mrc-quota10" + WIRELESS_MRC_QUOTA50 = "wireless-mrc-quota50" + WIRELESS_MRC_QUOTACUSTOM = "wireless-mrc-quotacustom" WIRELESS_ORDERS = "wireless-orders" WIRELESS_ORDERS_ARTWORK = "wireless-orders-artwork" WIRELESS_ORDERS_BULK = "wireless-orders-bulk" WIRELESS_ORDERS_ESIM = "wireless-orders-esim" WIRELESS_ORDERS_STARTER = "wireless-orders-starter" + WIRELESS_QUOTAS = "wireless-quotas" + WIRELESS_SMS_AFRICA = "wireless-sms-africa" + WIRELESS_SMS_ASIA = "wireless-sms-asia" + WIRELESS_SMS_CENTRALANDSOUTHAMERICA = "wireless-sms-centralandsouthamerica" + WIRELESS_SMS_EUROPE = "wireless-sms-europe" + WIRELESS_SMS_NORTHAMERICA = "wireless-sms-northamerica" + WIRELESS_SMS_OCEANIA = "wireless-sms-oceania" + WIRELESS_SUPER_SIM = "wireless-super-sim" + WIRELESS_SUPER_SIM_DATA = "wireless-super-sim-data" + WIRELESS_SUPER_SIM_DATA_NORTH_AMERICA_USA = ( + "wireless-super-sim-data-north-america-usa" + ) + WIRELESS_SUPER_SIM_DATA_PAYG = "wireless-super-sim-data-payg" + WIRELESS_SUPER_SIM_DATA_PAYG_EUROPE = "wireless-super-sim-data-payg-europe" + WIRELESS_SUPER_SIM_DATA_PAYG_NORTH_AMERICA = ( + "wireless-super-sim-data-payg-north-america" + ) + WIRELESS_SUPER_SIM_HARDWARE = "wireless-super-sim-hardware" + WIRELESS_SUPER_SIM_HARDWARE_BULK = "wireless-super-sim-hardware-bulk" + WIRELESS_SUPER_SIM_SMSCOMMANDS = "wireless-super-sim-smscommands" + WIRELESS_SUPER_SIM_SMSCOMMANDS_AFRICA = "wireless-super-sim-smscommands-africa" + WIRELESS_SUPER_SIM_SMSCOMMANDS_ASIA = "wireless-super-sim-smscommands-asia" + WIRELESS_SUPER_SIM_SMSCOMMANDS_CENT_AND_SOUTH_AMERICA = ( + "wireless-super-sim-smscommands-cent-and-south-america" + ) + WIRELESS_SUPER_SIM_SMSCOMMANDS_EUROPE = "wireless-super-sim-smscommands-europe" + WIRELESS_SUPER_SIM_SMSCOMMANDS_NORTH_AMERICA = ( + "wireless-super-sim-smscommands-north-america" + ) + WIRELESS_SUPER_SIM_SMSCOMMANDS_OCEANIA = ( + "wireless-super-sim-smscommands-oceania" + ) + WIRELESS_SUPER_SIM_SUBSCRIPTION = "wireless-super-sim-subscription" + WIRELESS_SUPER_SIM_SUBSCRIPTION_PAYG = "wireless-super-sim-subscription-payg" WIRELESS_USAGE = "wireless-usage" WIRELESS_USAGE_COMMANDS = "wireless-usage-commands" WIRELESS_USAGE_COMMANDS_AFRICA = "wireless-usage-commands-africa" @@ -342,6 +656,184 @@ class Category(object): WIRELESS_USAGE_MRC_SUSPENDED = "wireless-usage-mrc-suspended" WIRELESS_USAGE_SMS = "wireless-usage-sms" WIRELESS_USAGE_VOICE = "wireless-usage-voice" + A2P_FAST_TRACK_ONBOARDING = "a2p-fast-track-onboarding" + ADVISORY_SERVICES = "advisory-services" + ADVISORY_SERVICES_BILLED = "advisory-services-billed" + ADVISORY_SERVICES_CALL_TRACKING = "advisory-services-call-tracking" + ADVISORY_SERVICES_DATA_SERVICES = "advisory-services-data-services" + ADVISORY_SERVICES_EXPENSES = "advisory-services-expenses" + ADVISORY_SERVICES_SIP_TRUNKING = "advisory-services-sip-trunking" + ASSETS_REQUESTS = "assets-requests" + AUDIENCE_MINUTES_VIDEO = "audience-minutes-video" + AUTHY_BUCKET_ADJUSTMENT = "authy-bucket-adjustment" + AUTHY_SOFTWARE = "authy-software" + CALLERIDLOOKUPS_API = "calleridlookups-api" + CALLERIDLOOKUPS_PROGRAMMABLEVOICE = "calleridlookups-programmablevoice" + CALLERIDLOOKUPS_TRUNKING = "calleridlookups-trunking" + CALLS_TRUNKING_INBOUND_TOLLFREE_LOCAL = "calls-trunking-inbound-tollfree-local" + CALLS_TRUNKING_INBOUND_TOLLFREE_MOBILE = ( + "calls-trunking-inbound-tollfree-mobile" + ) + CHANNELS_WHATSAPP_CONVERSATION_FREE_1 = "channels-whatsapp-conversation-free-1" + CONFERENCE = "conference" + CONVERSATIONAL_INSIGHTS = "conversational-insights" + CONVERSATIONAL_INSIGHTS_MESSAGES = "conversational-insights-messages" + CONVERSATIONAL_INSIGHTS_VOICE_MINUTES = "conversational-insights-voice-minutes" + DEMO = "demo" + DEMO_UC_SCRIPT_TEST = "demo-uc-script-test" + ELASTIC_SIP_TRUNKING = "elastic-sip-trunking" + ELASTIC_SIP_TRUNKING_CALL_TRANSFERS = "elastic-sip-trunking-call-transfers" + ENTERPRISE_HIPPA = "enterprise-hippa" + FLEX_NAMED_USERS = "flex-named-users" + FLEX_SPINSCI = "flex-spinsci" + FLEX_USERS_1 = "flex-users-1" + FLEX_WFO_PREMIUM_SPEECH_ANALYTICS = "flex-wfo-premium-speech-analytics" + FLEX_XCELERATE = "flex-xcelerate" + FUNCTIONS_ROLLUP = "functions-rollup" + IMP_V1_USAGE = "imp-v1-usage" + IP_MESSAGING_ADDONS = "ip-messaging-addons" + IVR = "ivr" + IVR_CONVERSATIONAL = "ivr-conversational" + IVR_DTMF = "ivr-dtmf" + IVR_VIRTUALAGENT = "ivr-virtualagent" + LIVE = "live" + LIVE_MEDIA_RECORDING_MINUTES = "live-media-recording-minutes" + LONGCODE_MPS = "longcode-mps" + MARKETPLACE_ANALYTICS_ADDONS = "marketplace-analytics-addons" + MARKETPLACE_ISV_ADDONS = "marketplace-isv-addons" + MARKETPLACE_MESSAGING_ADDONS = "marketplace-messaging-addons" + MARKETPLACE_PHONENUMBERS_ADDONS = "marketplace-phonenumbers-addons" + MARKETPLACE_RECORDING_ADDONS = "marketplace-recording-addons" + MARKETPLACE_VIRTUALAGENT_ADDONS = "marketplace-virtualagent-addons" + MARKETPLAY_PAY_ADDONS_SHUTTLE_PAY_CONNECTOR_1 = ( + "marketplay-pay-addons-shuttle-pay-connector-1" + ) + MARKETPLAY_PAY_ADDONS_STRIPE_PAY_CONNECTOR = ( + "marketplay-pay-addons-stripe-pay-connector" + ) + MMS_INBOUND_LONGCODE_CANADA = "mms-inbound-longcode-canada" + MMS_INBOUND_LONGCODE_UNITEDSTATES = "mms-inbound-longcode-unitedstates" + MMS_OUTBOUND_LONGCODE_CANADA = "mms-outbound-longcode-canada" + MMS_OUTBOUND_LONGCODE_UNITEDSTATES = "mms-outbound-longcode-unitedstates" + MMS_OUTBOUND_TOLL_FREE = "mms-outbound-toll-free" + NOTIFY_CHATAPPSANDOTHERCHANNELS = "notify-chatappsandotherchannels" + NOTIFY_NOTIFYSERVICES = "notify-notifyservices" + NOTIFY_PUSHNOTIFICATIONS = "notify-pushnotifications" + PAYMENT_GATEWAY_CONNECTORS = "payment-gateway-connectors" + PAYMENT_SOLUTIONS = "payment-solutions" + PCHAT_BUCKET_ADJUSTMENT = "pchat-bucket-adjustment" + PHONENUMBERS_NUMBERS = "phonenumbers-numbers" + PROG_VOICE_CLIENT_ANDROID = "prog-voice-client-android" + PROG_VOICE_CLIENT_ANDROID_INBOUND = "prog-voice-client-android-inbound" + PROG_VOICE_CLIENT_ANDROID_OUTBOUND = "prog-voice-client-android-outbound" + PROG_VOICE_CLIENT_IOS = "prog-voice-client-ios" + PROG_VOICE_CLIENT_IOS_INBOUND = "prog-voice-client-ios-inbound" + PROG_VOICE_CLIENT_IOS_OUTBOUND = "prog-voice-client-ios-outbound" + PROG_VOICE_CLIENT_SDK = "prog-voice-client-sdk" + PROG_VOICE_CLIENT_WEB = "prog-voice-client-web" + PROG_VOICE_CLIENT_WEB_INBOUND = "prog-voice-client-web-inbound" + PROG_VOICE_CLIENT_WEB_OUTBOUND = "prog-voice-client-web-outbound" + PROGRAMMABLEVOICECONNECTIVITY_MEDIA_STREAMS = ( + "programmablevoiceconnectivity-media-streams" + ) + PSTNCONNECTIVITY_BYOC = "pstnconnectivity-byoc" + PSTNCONNECTIVITY_EMERGENCY = "pstnconnectivity-emergency" + PSTNCONNECTIVITY_MINUTES = "pstnconnectivity-minutes" + PSTNCONNECTIVITY_MINUTES_1 = "pstnconnectivity-minutes-1" + PSTNCONNECTIVITY_MINUTESINBOUNDLOCAL = "pstnconnectivity-minutesinboundlocal" + PSTNCONNECTIVITY_MINUTESINBOUNDMOBILE = "pstnconnectivity-minutesinboundmobile" + PSTNCONNECTIVITY_MINUTESINBOUNDTOLLFREE = ( + "pstnconnectivity-minutesinboundtollfree" + ) + PSTNCONNECTIVITY_MINUTESINBOUNDTOLLFREELOCAL = ( + "pstnconnectivity-minutesinboundtollfreelocal" + ) + PSTNCONNECTIVITY_MINUTESINBOUNDTOLLFREEMOBILE = ( + "pstnconnectivity-minutesinboundtollfreemobile" + ) + PV_ROOM_HOURS = "pv-room-hours" + PV_ROOM_SIMULTANEOUS_PARTICIPANT_CONNECTIONS = ( + "pv-room-simultaneous-participant-connections" + ) + PVIDEO_ROOM_HOURS_AU1 = "pvideo-room-hours-au1" + PVIDEO_ROOM_HOURS_BR1 = "pvideo-room-hours-br1" + PVIDEO_ROOM_HOURS_IE1 = "pvideo-room-hours-ie1" + PVIDEO_ROOM_HOURS_JP1 = "pvideo-room-hours-jp1" + PVIDEO_ROOM_HOURS_SG1 = "pvideo-room-hours-sg1" + PVIDEO_ROOM_HOURS_US1 = "pvideo-room-hours-us1" + PVIDEO_ROOM_HOURS_US2 = "pvideo-room-hours-us2" + RECORDINGS_ENCRYPTED = "recordings-encrypted" + SHORT_CODE_SETUP_FEES = "short-code-setup-fees" + SHORTCODES_MESSAGES_INBOUND = "shortcodes-messages-inbound" + SHORTCODES_MESSAGES_OUTBOUND = "shortcodes-messages-outbound" + SMS_MESSAGES_REGISTRATIONFEES = "sms-messages-registrationfees" + SMS_MMS_PENALTY_FEES = "sms-mms-penalty-fees" + SMS_MMS_PENALTY_FEES_1 = "sms-mms-penalty-fees-1" + SMS_PUMPING_PROTECTION_NON_USCA = "sms-pumping-protection-non-usca" + SMS_PUMPING_PROTECTION_USCA = "sms-pumping-protection-usca" + STUDIO = "studio" + STUDIO_MONTHLY_FEES = "studio-monthly-fees" + SUPERSIM = "supersim" + TASK_ROUTER = "task-router" + TASK_ROUTER_WORKERS = "task-router-workers" + TEST_QUOTA_BUCKETS = "test-quota-buckets" + TEST_UC_SCRIPT_1 = "test-uc-script-1" + TEST_UC_SCRIPT_DEMO_2 = "test-uc-script-demo-2" + TEXT_TO_SPEECH = "text-to-speech" + TME = "tme" + TTS_BASIC = "tts-basic" + TWILIO_EDITIONS = "twilio-editions" + TWILIO_INTERCONNECT_CALIFORNIA = "twilio-interconnect-california" + TWILIO_INTERCONNECT_CALIFORNIA_MONTHLY = ( + "twilio-interconnect-california-monthly" + ) + TWILIO_INTERCONNECT_CALIFORNIA_SETUP = "twilio-interconnect-california-setup" + TWILIO_INTERCONNECT_FRANKFURT = "twilio-interconnect-frankfurt" + TWILIO_INTERCONNECT_FRANKFURT_MO = "twilio-interconnect-frankfurt-mo" + TWILIO_INTERCONNECT_FRANKFURT_SETUP = "twilio-interconnect-frankfurt-setup" + TWILIO_INTERCONNECT_LONDON = "twilio-interconnect-london" + TWILIO_INTERCONNECT_LONDON_MO = "twilio-interconnect-london-mo" + TWILIO_INTERCONNECT_LONDON_SETUP = "twilio-interconnect-london-setup" + TWILIO_INTERCONNECT_SAO_PAULO = "twilio-interconnect-sao-paulo" + TWILIO_INTERCONNECT_SAO_PAULO_MONTHLY = "twilio-interconnect-sao-paulo-monthly" + TWILIO_INTERCONNECT_SAO_PAULO_SETUP = "twilio-interconnect-sao-paulo-setup" + TWILIO_INTERCONNECT_SINGAPORE = "twilio-interconnect-singapore" + TWILIO_INTERCONNECT_SINGAPORE_MO = "twilio-interconnect-singapore-mo" + TWILIO_INTERCONNECT_SINGAPORE_SETUP = "twilio-interconnect-singapore-setup" + TWILIO_INTERCONNECT_SYDNEY = "twilio-interconnect-sydney" + TWILIO_INTERCONNECT_SYDNEY_MO = "twilio-interconnect-sydney-mo" + TWILIO_INTERCONNECT_SYDNEY_SETUP = "twilio-interconnect-sydney-setup" + TWILIO_INTERCONNECT_TOKYO = "twilio-interconnect-tokyo" + TWILIO_INTERCONNECT_TOKYO_MO = "twilio-interconnect-tokyo-mo" + TWILIO_INTERCONNECT_TOKYO_SETUP = "twilio-interconnect-tokyo-setup" + TWILIO_INTERCONNECT_VA = "twilio-interconnect-va" + TWILIO_INTERCONNECT_VA_MO = "twilio-interconnect-va-mo" + TWILIO_INTERCONNECT_VA_SETUP = "twilio-interconnect-va-setup" + TWIML_VERBS = "twiml-verbs" + TWIML_VERBS_SAY = "twiml-verbs-say" + USAGE_PROGRAMMABLE_MESSAGING_ENGAGEMENT_SUITE = ( + "usage-programmable-messaging-engagement-suite" + ) + USAGE_PROGRAMMABLE_MESSAGING_FEES_SERVICES = ( + "usage-programmable-messaging-fees-services" + ) + VERIFY_OUTBOUND_EMAIL = "verify-outbound-email" + VERIFY_PACKAGED_PLANS = "verify-packaged-plans" + VERIFY_SILENT_NETWORK_AUTH = "verify-silent-network-auth" + VERIFY_VOICE_AND_SMS = "verify-voice-and-sms" + VOICE_INSIGHTS_CLIENT_INSIGHTS_MONTHY_COMMIT = ( + "voice-insights-client-insights-monthy-commit" + ) + WIRELESS_DATA_PAYG_ASIA_AFG = "wireless-data-payg-asia-afg" + WIRELESS_MULTI_IMSI_SIM_COMMANDS = "wireless-multi-imsi-sim-commands" + WIRELESS_MULTI_IMSI_SIM_COMMANDS_USA = "wireless-multi-imsi-sim-commands-usa" + WIRELESS_MULTI_IMSI_SIM_DATA = "wireless-multi-imsi-sim-data" + WIRELESS_MULTI_IMSI_SIM_DATA_EU28 = "wireless-multi-imsi-sim-data-eu28" + WIRELESS_MULTI_IMSI_SIM_DATA_USA = "wireless-multi-imsi-sim-data-usa" + WIRELESS_MULTI_IMSI_SIM_MONTHLY_FEES = "wireless-multi-imsi-sim-monthly-fees" + WIRELESS_MULTI_IMSI_SIM_USAGE = "wireless-multi-imsi-sim-usage" + WIRELESS_SUPER_SIM_DATA_NORTH_AMERICA = "wireless-super-sim-data-north-america" + WIRELESS_SUPER_SIM_USAGE = "wireless-super-sim-usage" """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that accrued the usage. @@ -401,6 +893,7 @@ def __repr__(self) -> str: class MonthlyPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> MonthlyInstance: """ Build an instance of MonthlyInstance @@ -421,6 +914,7 @@ def __repr__(self) -> str: class MonthlyList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the MonthlyList @@ -623,14 +1117,20 @@ def page( "Category": category, "StartDate": serialize.iso8601_date(start_date), "EndDate": serialize.iso8601_date(end_date), - "IncludeSubaccounts": include_subaccounts, + "IncludeSubaccounts": serialize.boolean_to_string(include_subaccounts), "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 MonthlyPage(self._version, response, self._solution) async def page_async( @@ -662,15 +1162,19 @@ async def page_async( "Category": category, "StartDate": serialize.iso8601_date(start_date), "EndDate": serialize.iso8601_date(end_date), - "IncludeSubaccounts": include_subaccounts, + "IncludeSubaccounts": serialize.boolean_to_string(include_subaccounts), "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 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 7b5d792525..ab65a177d3 100644 --- a/twilio/rest/api/v2010/account/usage/record/this_month.py +++ b/twilio/rest/api/v2010/account/usage/record/this_month.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import date from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import deserialize, serialize, values @@ -24,34 +23,103 @@ class ThisMonthInstance(InstanceResource): + class Category(object): + A2P_10DLC_REGISTRATIONFEES_BRANDREGISTRATION = ( + "a2p-10dlc-registrationfees-brandregistration" + ) + A2P_10DLC_REGISTRATIONFEES_BV = "a2p-10dlc-registrationfees-bv" + A2P_10DLC_REGISTRATIONFEES_CAMPAIGNCHARGES = ( + "a2p-10dlc-registrationfees-campaigncharges" + ) + A2P_10DLC_REGISTRATIONFEES_CAMPAIGNREGISTRATION = ( + "a2p-10dlc-registrationfees-campaignregistration" + ) + A2P_10DLC_REGISTRATIONFEES_CAMPAIGNVETTING = ( + "a2p-10dlc-registrationfees-campaignvetting" + ) + A2P_10DLC_REGISTRATIONFEES_MONTHLY = "a2p-10dlc-registrationfees-monthly" + A2P_10DLC_REGISTRATIONFEES_ONETIME = "a2p-10dlc-registrationfees-onetime" A2P_REGISTRATION_FEES = "a2p-registration-fees" + ACCOUNT_SECURITY = "account-security" AGENT_CONFERENCE = "agent-conference" + AGENT_COPILOT = "agent-copilot" + AGENT_COPILOT_MESSAGES = "agent-copilot-messages" + AGENT_COPILOT_PARTICIPANT_MINUTES = "agent-copilot-participant-minutes" + AI_ASSISTANTS = "ai-assistants" + AI_ASSISTANTS_VOICE = "ai-assistants-voice" AMAZON_POLLY = "amazon-polly" ANSWERING_MACHINE_DETECTION = "answering-machine-detection" + ASSETS = "assets" + AUDIENCE_MINUTES = "audience-minutes" + AUDIENCE_MINUTES_AUDIO = "audience-minutes-audio" AUTHY_AUTHENTICATIONS = "authy-authentications" AUTHY_CALLS_OUTBOUND = "authy-calls-outbound" + AUTHY_EMAIL_AUTHENTICATIONS = "authy-email-authentications" AUTHY_MONTHLY_FEES = "authy-monthly-fees" + AUTHY_OUTBOUND_EMAIL = "authy-outbound-email" AUTHY_PHONE_INTELLIGENCE = "authy-phone-intelligence" AUTHY_PHONE_VERIFICATIONS = "authy-phone-verifications" AUTHY_SMS_OUTBOUND = "authy-sms-outbound" + AUTHY_VERIFY_EMAIL_VERIFICATIONS = "authy-verify-email-verifications" + AUTHY_VERIFY_OUTBOUND_EMAIL = "authy-verify-outbound-email" + AUTOPILOT = "autopilot" + AUTOPILOT_HOME_ASSISTANTS = "autopilot-home-assistants" + AUTOPILOT_MESSAGING = "autopilot-messaging" + AUTOPILOT_OTHER = "autopilot-other" + AUTOPILOT_VOICE = "autopilot-voice" + BASIC_PEER_TO_PEER_ROOMS_PARTICIPANT_MINUTES = ( + "basic-peer-to-peer-rooms-participant-minutes" + ) + BRANDED_CALLING = "branded-calling" + BUNDLE_SMS_BUCKET = "bundle-sms-bucket" + BUNDLE_SUBSCRIPTION_FEES = "bundle-subscription-fees" + CALL_FORWARDING_LOOKUPS = "call-forwarding-lookups" CALL_PROGESS_EVENTS = "call-progess-events" CALLERIDLOOKUPS = "calleridlookups" CALLS = "calls" CALLS_CLIENT = "calls-client" + CALLS_EMERGENCY = "calls-emergency" CALLS_GLOBALCONFERENCE = "calls-globalconference" CALLS_INBOUND = "calls-inbound" CALLS_INBOUND_LOCAL = "calls-inbound-local" CALLS_INBOUND_MOBILE = "calls-inbound-mobile" CALLS_INBOUND_TOLLFREE = "calls-inbound-tollfree" + CALLS_INBOUND_TOLLFREE_LOCAL = "calls-inbound-tollfree-local" + CALLS_INBOUND_TOLLFREE_MOBILE = "calls-inbound-tollfree-mobile" + CALLS_MEDIA_STREAM_MINUTES = "calls-media-stream-minutes" CALLS_OUTBOUND = "calls-outbound" CALLS_PAY_VERB_TRANSACTIONS = "calls-pay-verb-transactions" CALLS_RECORDINGS = "calls-recordings" CALLS_SIP = "calls-sip" CALLS_SIP_INBOUND = "calls-sip-inbound" CALLS_SIP_OUTBOUND = "calls-sip-outbound" + CALLS_TEXT_TO_SPEECH = "calls-text-to-speech" CALLS_TRANSFERS = "calls-transfers" CARRIER_LOOKUPS = "carrier-lookups" + CATEGORY = "category" + CHANNELS = "channels" + CHANNELS_MESSAGING = "channels-messaging" + CHANNELS_MESSAGING_INBOUND = "channels-messaging-inbound" + CHANNELS_MESSAGING_OUTBOUND = "channels-messaging-outbound" + CHANNELS_WHATSAPP = "channels-whatsapp" + CHANNELS_WHATSAPP_CONVERSATION_AUTHENTICATION = ( + "channels-whatsapp-conversation-authentication" + ) + CHANNELS_WHATSAPP_CONVERSATION_FREE = "channels-whatsapp-conversation-free" + CHANNELS_WHATSAPP_CONVERSATION_MARKETING = ( + "channels-whatsapp-conversation-marketing" + ) + CHANNELS_WHATSAPP_CONVERSATION_SERVICE = ( + "channels-whatsapp-conversation-service" + ) + CHANNELS_WHATSAPP_CONVERSATION_UTILITY = ( + "channels-whatsapp-conversation-utility" + ) + CHANNELS_WHATSAPP_INBOUND = "channels-whatsapp-inbound" + CHANNELS_WHATSAPP_OUTBOUND = "channels-whatsapp-outbound" + CHAT_VIRTUAL_AGENT = "chat-virtual-agent" + CONVERSATION_RELAY = "conversation-relay" CONVERSATIONS = "conversations" CONVERSATIONS_API_REQUESTS = "conversations-api-requests" CONVERSATIONS_CONVERSATION_EVENTS = "conversations-conversation-events" @@ -60,8 +128,40 @@ class Category(object): CONVERSATIONS_PARTICIPANT_EVENTS = "conversations-participant-events" CONVERSATIONS_PARTICIPANTS = "conversations-participants" CPS = "cps" + CREDIT_TRANSFER = "credit-transfer" + EMAIL = "email" + EMERGING_TECH = "emerging-tech" + ENGAGEMENT_SUITE_PACKAGED_PLANS = "engagement-suite-packaged-plans" + ENHANCED_LINE_TYPE_LOOKUPS = "enhanced-line-type-lookups" + ENTERPRISE = "enterprise" + EVENTS = "events" + EXPERIMENT_FRANCE_SMS = "experiment-france-sms" + EXPERIMENT_INDIA_SMS = "experiment-india-sms" + EXPERIMENT_UK_SMS = "experiment-uk-sms" + FAILED_MESSAGE_PROCESSING_FEE = "failed-message-processing-fee" + FLEX = "flex" + FLEX_ACTIVE_USER_HOURS = "flex-active-user-hours" + FLEX_CONCURRENT_USERS = "flex-concurrent-users" + FLEX_CONVERSATIONAL_INSIGHTS = "flex-conversational-insights" + FLEX_CONVERSATIONAL_INSIGHTS_MESSAGES = "flex-conversational-insights-messages" + FLEX_CONVERSATIONAL_INSIGHTS_VOICE_MINUTES = ( + "flex-conversational-insights-voice-minutes" + ) + FLEX_EMAIL_USAGE = "flex-email-usage" + FLEX_MESSAGING_USAGE = "flex-messaging-usage" + FLEX_PARTNER_SPINSCI = "flex-partner-spinsci" + FLEX_PARTNER_XCELERATE = "flex-partner-xcelerate" + FLEX_RESELLER_ECOSYSTEM = "flex-reseller-ecosystem" + FLEX_UNIQUE_USER = "flex-unique-user" FLEX_USAGE = "flex-usage" + FLEX_USERS = "flex-users" + FLEX_VOICE_MINUTE = "flex-voice-minute" + FLEX_YTICA = "flex-ytica" FRAUD_LOOKUPS = "fraud-lookups" + FRONTLINE = "frontline" + FRONTLINE_USERS = "frontline-users" + FUNCTIONS = "functions" + GENERIC_PAY_TRANSACTIONS = "generic-pay-transactions" GROUP_ROOMS = "group-rooms" GROUP_ROOMS_DATA_TRACK = "group-rooms-data-track" GROUP_ROOMS_ENCRYPTED_MEDIA_RECORDED = "group-rooms-encrypted-media-recorded" @@ -71,7 +171,17 @@ class Category(object): GROUP_ROOMS_MEDIA_STORED = "group-rooms-media-stored" GROUP_ROOMS_PARTICIPANT_MINUTES = "group-rooms-participant-minutes" GROUP_ROOMS_RECORDED_MINUTES = "group-rooms-recorded-minutes" - IMP_V1_USAGE = "imp-v1-usage" + IP_MESSAGING = "ip-messaging" + IP_MESSAGING_COMMANDS = "ip-messaging-commands" + IP_MESSAGING_DATA_STORAGE = "ip-messaging-data-storage" + IP_MESSAGING_DATA_TRANSFER = "ip-messaging-data-transfer" + IP_MESSAGING_ENDPOINT_CONNECTIVITY = "ip-messaging-endpoint-connectivity" + IVR_VIRTUAL_AGENT_CUSTOM_VOICES = "ivr-virtual-agent-custom-voices" + IVR_VIRTUAL_AGENT_GENAI = "ivr-virtual-agent-genai" + LINE_STATUS_LOOKUPS = "line-status-lookups" + LIVE_ACTIVITY_LOOKUPS = "live-activity-lookups" + LOOKUP_BUCKET_ADJUSTMENT = "lookup-bucket-adjustment" + LOOKUP_IDENTITY_MATCH = "lookup-identity-match" LOOKUPS = "lookups" MARKETPLACE = "marketplace" MARKETPLACE_ALGORITHMIA_NAMED_ENTITY_RECOGNITION = ( @@ -82,6 +192,13 @@ class Category(object): MARKETPLACE_CAPIO_SPEECH_TO_TEXT = "marketplace-capio-speech-to-text" MARKETPLACE_CONVRIZA_ABABA = "marketplace-convriza-ababa" MARKETPLACE_DEEPGRAM_PHRASE_DETECTOR = "marketplace-deepgram-phrase-detector" + MARKETPLACE_DEEPGRAM_TRANSCRIPTION = "marketplace-deepgram-transcription" + MARKETPLACE_DEEPGRAM_TRANSCRIPTION_BASE = ( + "marketplace-deepgram-transcription-base" + ) + MARKETPLACE_DEEPGRAM_TRANSSCRIPTION_ENHANCED = ( + "marketplace-deepgram-transscription-enhanced" + ) MARKETPLACE_DIGITAL_SEGMENT_BUSINESS_INFO = ( "marketplace-digital-segment-business-info" ) @@ -107,6 +224,9 @@ class Category(object): "marketplace-keen-io-contact-center-analytics" ) MARKETPLACE_MARCHEX_CLEANCALL = "marketplace-marchex-cleancall" + MARKETPLACE_MARCHEX_RECORDING_ANALYSIS = ( + "marketplace-marchex-recording-analysis" + ) MARKETPLACE_MARCHEX_SENTIMENT_ANALYSIS_FOR_SMS = ( "marketplace-marchex-sentiment-analysis-for-sms" ) @@ -123,14 +243,42 @@ class Category(object): "marketplace-nextcaller-advanced-caller-identification" ) MARKETPLACE_NOMOROBO_SPAM_SCORE = "marketplace-nomorobo-spam-score" + MARKETPLACE_PAY_ADDONS = "marketplace-pay-addons" + MARKETPLACE_PAY_ADDONS_BASECOMMERCE_PAY_CONNECTOR = ( + "marketplace-pay-addons-basecommerce-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_BRAINTREE_PAY_CONNECTOR = ( + "marketplace-pay-addons-braintree-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_CARDCONNECT_PAY_CONNECTOR = ( + "marketplace-pay-addons-cardconnect-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_CHASE_PAY_CONNECTOR = ( + "marketplace-pay-addons-chase-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_SHUTTLE_PAY_CONNECTOR = ( + "marketplace-pay-addons-shuttle-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_STRIPE_PAY_CONNECTOR = ( + "marketplace-pay-addons-stripe-pay-connector" + ) MARKETPLACE_PAYFONE_TCPA_COMPLIANCE = "marketplace-payfone-tcpa-compliance" + MARKETPLACE_POLY_AI_CONNECTOR = "marketplace-poly-ai-connector" + MARKETPLACE_REALPHONEVALIDATION = "marketplace-realphonevalidation" MARKETPLACE_REMEETING_AUTOMATIC_SPEECH_RECOGNITION = ( "marketplace-remeeting-automatic-speech-recognition" ) + MARKETPLACE_SPOKE_PHONE_LICENSE_PRO = "marketplace-spoke-phone-license-pro" + MARKETPLACE_SPOKE_PHONE_LICENSE_STANDARD = ( + "marketplace-spoke-phone-license-standard" + ) MARKETPLACE_TCPA_DEFENSE_SOLUTIONS_BLACKLIST_FEED = ( "marketplace-tcpa-defense-solutions-blacklist-feed" ) MARKETPLACE_TELO_OPENCNAM = "marketplace-telo-opencnam" + MARKETPLACE_TRESTLE_SOLUTIONS_CALLER_IDENTIFICATION = ( + "marketplace-trestle-solutions-caller-identification" + ) MARKETPLACE_TRUECNAM_TRUE_SPAM = "marketplace-truecnam-true-spam" MARKETPLACE_TWILIO_CALLER_NAME_LOOKUP_US = ( "marketplace-twilio-caller-name-lookup-us" @@ -143,6 +291,9 @@ class Category(object): MARKETPLACE_VOICEBASE_TRANSCRIPTION_CUSTOM_VOCABULARY = ( "marketplace-voicebase-transcription-custom-vocabulary" ) + MARKETPLACE_WEB_PURIFY_PROFANITY_FILTER = ( + "marketplace-web-purify-profanity-filter" + ) MARKETPLACE_WHITEPAGES_PRO_CALLER_IDENTIFICATION = ( "marketplace-whitepages-pro-caller-identification" ) @@ -157,15 +308,23 @@ class Category(object): MARKETPLACE_YTICA_CONTACT_CENTER_REPORTING_ANALYTICS = ( "marketplace-ytica-contact-center-reporting-analytics" ) + MARKETPLAY_PAY_ADDONS_SHUTTLE_PAY_CONNECTOR = ( + "marketplay-pay-addons-shuttle-pay-connector" + ) + MEDIA_COMPOSER_MINUTES = "media-composer-minutes" MEDIASTORAGE = "mediastorage" + MIN_SPEND_ADJUSTMENTS = "min-spend-adjustments" MMS = "mms" MMS_INBOUND = "mms-inbound" MMS_INBOUND_LONGCODE = "mms-inbound-longcode" MMS_INBOUND_SHORTCODE = "mms-inbound-shortcode" + MMS_INBOUND_TOLL_FREE = "mms-inbound-toll-free" MMS_MESSAGES_CARRIERFEES = "mms-messages-carrierfees" MMS_OUTBOUND = "mms-outbound" MMS_OUTBOUND_LONGCODE = "mms-outbound-longcode" MMS_OUTBOUND_SHORTCODE = "mms-outbound-shortcode" + MMS_OUTBOUND_TOLLFREE = "mms-outbound-tollfree" + MONITOR = "monitor" MONITOR_READS = "monitor-reads" MONITOR_STORAGE = "monitor-storage" MONITOR_WRITES = "monitor-writes" @@ -174,6 +333,12 @@ class Category(object): NOTIFY_CHANNELS = "notify-channels" NUMBER_FORMAT_LOOKUPS = "number-format-lookups" PCHAT = "pchat" + PCHAT_ACTIONS = "pchat-actions" + PCHAT_APS = "pchat-aps" + PCHAT_CONV_MED_STORAGE = "pchat-conv-med-storage" + PCHAT_MESSAGES = "pchat-messages" + PCHAT_NOTIFICATIONS = "pchat-notifications" + PCHAT_READS = "pchat-reads" PCHAT_USERS = "pchat-users" PEER_TO_PEER_ROOMS_PARTICIPANT_MINUTES = ( "peer-to-peer-rooms-participant-minutes" @@ -183,18 +348,41 @@ class Category(object): PFAX_MINUTES_INBOUND = "pfax-minutes-inbound" PFAX_MINUTES_OUTBOUND = "pfax-minutes-outbound" PFAX_PAGES = "pfax-pages" + PHONE_QUALITY_SCORE_LOOKUPS = "phone-quality-score-lookups" PHONENUMBERS = "phonenumbers" PHONENUMBERS_CPS = "phonenumbers-cps" PHONENUMBERS_EMERGENCY = "phonenumbers-emergency" PHONENUMBERS_LOCAL = "phonenumbers-local" PHONENUMBERS_MOBILE = "phonenumbers-mobile" + PHONENUMBERS_PORTING = "phonenumbers-porting" PHONENUMBERS_SETUPS = "phonenumbers-setups" PHONENUMBERS_TOLLFREE = "phonenumbers-tollfree" PREMIUMSUPPORT = "premiumsupport" + PREMIUMSUPPORT_PERCENTAGE_SPEND = "premiumsupport-percentage-spend" + PROGRAMMABLEVOICE_PLATFORM = "programmablevoice-platform" + PROGRAMMABLEVOICECONN_CLIENTSDK = "programmablevoiceconn-clientsdk" + PROGRAMMABLEVOICECONN_CLIENTSDK_INBOUND = ( + "programmablevoiceconn-clientsdk-inbound" + ) + PROGRAMMABLEVOICECONN_CLIENTSDK_OUTBOUND = ( + "programmablevoiceconn-clientsdk-outbound" + ) + PROGRAMMABLEVOICECONN_ONNET = "programmablevoiceconn-onnet" + PROGRAMMABLEVOICECONN_ONNET_INBOUND = "programmablevoiceconn-onnet-inbound" + PROGRAMMABLEVOICECONN_ONNET_OUTBOUND = "programmablevoiceconn-onnet-outbound" + PROGRAMMABLEVOICECONN_SIP = "programmablevoiceconn-sip" + PROGRAMMABLEVOICECONN_SIP_INBOUND = "programmablevoiceconn-sip-inbound" + PROGRAMMABLEVOICECONN_SIP_OUTBOUND = "programmablevoiceconn-sip-outbound" + PROGRAMMABLEVOICECONNECTIVITY = "programmablevoiceconnectivity" PROXY = "proxy" PROXY_ACTIVE_SESSIONS = "proxy-active-sessions" + PROXY_BUCKET_ADJUSTMENT = "proxy-bucket-adjustment" + PROXY_LICENSES = "proxy-licenses" PSTNCONNECTIVITY = "pstnconnectivity" + PSTNCONNECTIVITY_INBOUND = "pstnconnectivity-inbound" + PSTNCONNECTIVITY_OUTBOUND = "pstnconnectivity-outbound" PV = "pv" + PV_BASIC_ROOMS = "pv-basic-rooms" PV_COMPOSITION_MEDIA_DOWNLOADED = "pv-composition-media-downloaded" PV_COMPOSITION_MEDIA_ENCRYPTED = "pv-composition-media-encrypted" PV_COMPOSITION_MEDIA_STORED = "pv-composition-media-stored" @@ -210,18 +398,20 @@ class Category(object): PV_ROOM_PARTICIPANTS_US2 = "pv-room-participants-us2" PV_ROOMS = "pv-rooms" PV_SIP_ENDPOINT_REGISTRATIONS = "pv-sip-endpoint-registrations" + RCS_MESSAGES = "rcs-messages" + REASSIGNED_NUMBER = "reassigned-number" RECORDINGS = "recordings" RECORDINGSTORAGE = "recordingstorage" - ROOMS_GROUP_BANDWIDTH = "rooms-group-bandwidth" - ROOMS_GROUP_MINUTES = "rooms-group-minutes" - ROOMS_PEER_TO_PEER_MINUTES = "rooms-peer-to-peer-minutes" SHORTCODES = "shortcodes" SHORTCODES_CUSTOMEROWNED = "shortcodes-customerowned" SHORTCODES_MMS_ENABLEMENT = "shortcodes-mms-enablement" SHORTCODES_MPS = "shortcodes-mps" SHORTCODES_RANDOM = "shortcodes-random" + SHORTCODES_SETUP_FEES = "shortcodes-setup-fees" SHORTCODES_UK = "shortcodes-uk" SHORTCODES_VANITY = "shortcodes-vanity" + SIM_SWAP_LOOKUPS = "sim-swap-lookups" + SIP_SECURE_MEDIA = "sip-secure-media" SMALL_GROUP_ROOMS = "small-group-rooms" SMALL_GROUP_ROOMS_DATA_TRACK = "small-group-rooms-data-track" SMALL_GROUP_ROOMS_PARTICIPANT_MINUTES = "small-group-rooms-participant-minutes" @@ -229,13 +419,30 @@ class Category(object): SMS_INBOUND = "sms-inbound" SMS_INBOUND_LONGCODE = "sms-inbound-longcode" SMS_INBOUND_SHORTCODE = "sms-inbound-shortcode" + SMS_INBOUND_TOLLFREE = "sms-inbound-tollfree" SMS_MESSAGES_CARRIERFEES = "sms-messages-carrierfees" SMS_MESSAGES_FEATURES = "sms-messages-features" + SMS_MESSAGES_FEATURES_ENGAGEMENT_SUITE = ( + "sms-messages-features-engagement-suite" + ) + SMS_MESSAGES_FEATURES_MESSAGE_REDACTION = ( + "sms-messages-features-message-redaction" + ) SMS_MESSAGES_FEATURES_SENDERID = "sms-messages-features-senderid" + SMS_MPS = "sms-mps" + SMS_MPS_SHORTCODE = "sms-mps-shortcode" + SMS_MPS_TOLLFREE = "sms-mps-tollfree" + SMS_MPS_TOLLFREE_SETUP = "sms-mps-tollfree-setup" + SMS_NATIONAL_REGULATORY_PROTECTION = "sms-national-regulatory-protection" SMS_OUTBOUND = "sms-outbound" SMS_OUTBOUND_CONTENT_INSPECTION = "sms-outbound-content-inspection" SMS_OUTBOUND_LONGCODE = "sms-outbound-longcode" SMS_OUTBOUND_SHORTCODE = "sms-outbound-shortcode" + SMS_OUTBOUND_TOLLFREE = "sms-outbound-tollfree" + SMS_PUMPING_PROTECTION = "sms-pumping-protection" + SMS_PUMPING_RISK = "sms-pumping-risk" + SMSMESSAGES_BUCKET_ADJUSTMENTS = "smsmessages-bucket-adjustments" + SMSMESSAGES_OUTBOUND_DOMESTIC = "smsmessages-outbound-domestic" SPEECH_RECOGNITION = "speech-recognition" STUDIO_ENGAGEMENTS = "studio-engagements" SYNC = "sync" @@ -254,6 +461,7 @@ class Category(object): TRUNKING_RECORDINGS = "trunking-recordings" TRUNKING_SECURE = "trunking-secure" TRUNKING_TERMINATION = "trunking-termination" + TTS_GOOGLE = "tts-google" TURNMEGABYTES = "turnmegabytes" TURNMEGABYTES_AUSTRALIA = "turnmegabytes-australia" TURNMEGABYTES_BRASIL = "turnmegabytes-brasil" @@ -264,13 +472,27 @@ class Category(object): TURNMEGABYTES_SINGAPORE = "turnmegabytes-singapore" TURNMEGABYTES_USEAST = "turnmegabytes-useast" TURNMEGABYTES_USWEST = "turnmegabytes-uswest" + TWILIO_FOR_SALESFORCE = "twilio-for-salesforce" + TWILIO_FOR_SALESFORCE_LICENSES = "twilio-for-salesforce-licenses" TWILIO_INTERCONNECT = "twilio-interconnect" + TWIML = "twiml" + USAGE_FLEX_VIDEO = "usage-flex-video" + USAGE_FUNCTIONS = "usage-functions" + USAGE_RCS_BASIC_MESSAGES_OUTBOUND = "usage-rcs-basic-messages-outbound" + USAGE_RCS_MESSAGES = "usage-rcs-messages" + USAGE_RCS_MESSAGES_INBOUND = "usage-rcs-messages-inbound" + USAGE_RCS_MESSAGING_CARRIER_FEES = "usage-rcs-messaging-carrier-fees" + USAGE_RCS_SINGLE_MESSAGES_OUTBOUND = "usage-rcs-single-messages-outbound" + VERIFY_PACKAGE_PLANS = "verify-package-plans" VERIFY_PUSH = "verify-push" + VERIFY_SNA = "verify-sna" VERIFY_TOTP = "verify-totp" + VERIFY_VOICE_SMS = "verify-voice-sms" VERIFY_WHATSAPP_CONVERSATIONS_BUSINESS_INITIATED = ( "verify-whatsapp-conversations-business-initiated" ) VIDEO_RECORDINGS = "video-recordings" + VIDEO_ROOMS_TURN_MEGABYTES = "video-rooms-turn-megabytes" VIRTUAL_AGENT = "virtual-agent" VOICE_INSIGHTS = "voice-insights" VOICE_INSIGHTS_CLIENT_INSIGHTS_ON_DEMAND_MINUTE = ( @@ -285,12 +507,104 @@ class Category(object): VOICE_INSIGHTS_SIP_TRUNKING_INSIGHTS_ON_DEMAND_MINUTE = ( "voice-insights-sip-trunking-insights-on-demand-minute" ) + VOICE_INTELLIGENCE = "voice-intelligence" + VOICE_INTELLIGENCE_EIP_OPERATORS = "voice-intelligence-eip-operators" + VOICE_INTELLIGENCE_OPERATORS = "voice-intelligence-operators" + VOICE_INTELLIGENCE_TRANSCRIPTION = "voice-intelligence-transcription" + WDS = "wds" WIRELESS = "wireless" + WIRELESS_DATA = "wireless-data" + WIRELESS_DATA_PAYG = "wireless-data-payg" + WIRELESS_DATA_PAYG_AFRICA = "wireless-data-payg-africa" + WIRELESS_DATA_PAYG_ASIA = "wireless-data-payg-asia" + WIRELESS_DATA_PAYG_CENTRALANDSOUTHAMERICA = ( + "wireless-data-payg-centralandsouthamerica" + ) + WIRELESS_DATA_PAYG_EUROPE = "wireless-data-payg-europe" + WIRELESS_DATA_PAYG_NORTHAMERICA = "wireless-data-payg-northamerica" + WIRELESS_DATA_PAYG_OCEANIA = "wireless-data-payg-oceania" + WIRELESS_DATA_QUOTA1 = "wireless-data-quota1" + WIRELESS_DATA_QUOTA1_AFRICA = "wireless-data-quota1-africa" + WIRELESS_DATA_QUOTA1_ASIA = "wireless-data-quota1-asia" + WIRELESS_DATA_QUOTA1_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quota1-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTA1_EUROPE = "wireless-data-quota1-europe" + WIRELESS_DATA_QUOTA1_NORTHAMERICA = "wireless-data-quota1-northamerica" + WIRELESS_DATA_QUOTA1_OCEANIA = "wireless-data-quota1-oceania" + WIRELESS_DATA_QUOTA10 = "wireless-data-quota10" + WIRELESS_DATA_QUOTA10_AFRICA = "wireless-data-quota10-africa" + WIRELESS_DATA_QUOTA10_ASIA = "wireless-data-quota10-asia" + WIRELESS_DATA_QUOTA10_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quota10-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTA10_EUROPE = "wireless-data-quota10-europe" + WIRELESS_DATA_QUOTA10_NORTHAMERICA = "wireless-data-quota10-northamerica" + WIRELESS_DATA_QUOTA10_OCEANIA = "wireless-data-quota10-oceania" + WIRELESS_DATA_QUOTA50 = "wireless-data-quota50" + WIRELESS_DATA_QUOTA50_AFRICA = "wireless-data-quota50-africa" + WIRELESS_DATA_QUOTA50_ASIA = "wireless-data-quota50-asia" + WIRELESS_DATA_QUOTA50_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quota50-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTA50_EUROPE = "wireless-data-quota50-europe" + WIRELESS_DATA_QUOTA50_NORTHAMERICA = "wireless-data-quota50-northamerica" + WIRELESS_DATA_QUOTA50_OCEANIA = "wireless-data-quota50-oceania" + WIRELESS_DATA_QUOTACUSTOM = "wireless-data-quotacustom" + WIRELESS_DATA_QUOTACUSTOM_AFRICA = "wireless-data-quotacustom-africa" + WIRELESS_DATA_QUOTACUSTOM_ASIA = "wireless-data-quotacustom-asia" + WIRELESS_DATA_QUOTACUSTOM_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quotacustom-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTACUSTOM_EUROPE = "wireless-data-quotacustom-europe" + WIRELESS_DATA_QUOTACUSTOM_NORTHAMERICA = ( + "wireless-data-quotacustom-northamerica" + ) + WIRELESS_DATA_QUOTACUSTOM_OCEANIA = "wireless-data-quotacustom-oceania" + WIRELESS_MRC_PAYG = "wireless-mrc-payg" + WIRELESS_MRC_QUOTA1 = "wireless-mrc-quota1" + WIRELESS_MRC_QUOTA10 = "wireless-mrc-quota10" + WIRELESS_MRC_QUOTA50 = "wireless-mrc-quota50" + WIRELESS_MRC_QUOTACUSTOM = "wireless-mrc-quotacustom" WIRELESS_ORDERS = "wireless-orders" WIRELESS_ORDERS_ARTWORK = "wireless-orders-artwork" WIRELESS_ORDERS_BULK = "wireless-orders-bulk" WIRELESS_ORDERS_ESIM = "wireless-orders-esim" WIRELESS_ORDERS_STARTER = "wireless-orders-starter" + WIRELESS_QUOTAS = "wireless-quotas" + WIRELESS_SMS_AFRICA = "wireless-sms-africa" + WIRELESS_SMS_ASIA = "wireless-sms-asia" + WIRELESS_SMS_CENTRALANDSOUTHAMERICA = "wireless-sms-centralandsouthamerica" + WIRELESS_SMS_EUROPE = "wireless-sms-europe" + WIRELESS_SMS_NORTHAMERICA = "wireless-sms-northamerica" + WIRELESS_SMS_OCEANIA = "wireless-sms-oceania" + WIRELESS_SUPER_SIM = "wireless-super-sim" + WIRELESS_SUPER_SIM_DATA = "wireless-super-sim-data" + WIRELESS_SUPER_SIM_DATA_NORTH_AMERICA_USA = ( + "wireless-super-sim-data-north-america-usa" + ) + WIRELESS_SUPER_SIM_DATA_PAYG = "wireless-super-sim-data-payg" + WIRELESS_SUPER_SIM_DATA_PAYG_EUROPE = "wireless-super-sim-data-payg-europe" + WIRELESS_SUPER_SIM_DATA_PAYG_NORTH_AMERICA = ( + "wireless-super-sim-data-payg-north-america" + ) + WIRELESS_SUPER_SIM_HARDWARE = "wireless-super-sim-hardware" + WIRELESS_SUPER_SIM_HARDWARE_BULK = "wireless-super-sim-hardware-bulk" + WIRELESS_SUPER_SIM_SMSCOMMANDS = "wireless-super-sim-smscommands" + WIRELESS_SUPER_SIM_SMSCOMMANDS_AFRICA = "wireless-super-sim-smscommands-africa" + WIRELESS_SUPER_SIM_SMSCOMMANDS_ASIA = "wireless-super-sim-smscommands-asia" + WIRELESS_SUPER_SIM_SMSCOMMANDS_CENT_AND_SOUTH_AMERICA = ( + "wireless-super-sim-smscommands-cent-and-south-america" + ) + WIRELESS_SUPER_SIM_SMSCOMMANDS_EUROPE = "wireless-super-sim-smscommands-europe" + WIRELESS_SUPER_SIM_SMSCOMMANDS_NORTH_AMERICA = ( + "wireless-super-sim-smscommands-north-america" + ) + WIRELESS_SUPER_SIM_SMSCOMMANDS_OCEANIA = ( + "wireless-super-sim-smscommands-oceania" + ) + WIRELESS_SUPER_SIM_SUBSCRIPTION = "wireless-super-sim-subscription" + WIRELESS_SUPER_SIM_SUBSCRIPTION_PAYG = "wireless-super-sim-subscription-payg" WIRELESS_USAGE = "wireless-usage" WIRELESS_USAGE_COMMANDS = "wireless-usage-commands" WIRELESS_USAGE_COMMANDS_AFRICA = "wireless-usage-commands-africa" @@ -342,6 +656,184 @@ class Category(object): WIRELESS_USAGE_MRC_SUSPENDED = "wireless-usage-mrc-suspended" WIRELESS_USAGE_SMS = "wireless-usage-sms" WIRELESS_USAGE_VOICE = "wireless-usage-voice" + A2P_FAST_TRACK_ONBOARDING = "a2p-fast-track-onboarding" + ADVISORY_SERVICES = "advisory-services" + ADVISORY_SERVICES_BILLED = "advisory-services-billed" + ADVISORY_SERVICES_CALL_TRACKING = "advisory-services-call-tracking" + ADVISORY_SERVICES_DATA_SERVICES = "advisory-services-data-services" + ADVISORY_SERVICES_EXPENSES = "advisory-services-expenses" + ADVISORY_SERVICES_SIP_TRUNKING = "advisory-services-sip-trunking" + ASSETS_REQUESTS = "assets-requests" + AUDIENCE_MINUTES_VIDEO = "audience-minutes-video" + AUTHY_BUCKET_ADJUSTMENT = "authy-bucket-adjustment" + AUTHY_SOFTWARE = "authy-software" + CALLERIDLOOKUPS_API = "calleridlookups-api" + CALLERIDLOOKUPS_PROGRAMMABLEVOICE = "calleridlookups-programmablevoice" + CALLERIDLOOKUPS_TRUNKING = "calleridlookups-trunking" + CALLS_TRUNKING_INBOUND_TOLLFREE_LOCAL = "calls-trunking-inbound-tollfree-local" + CALLS_TRUNKING_INBOUND_TOLLFREE_MOBILE = ( + "calls-trunking-inbound-tollfree-mobile" + ) + CHANNELS_WHATSAPP_CONVERSATION_FREE_1 = "channels-whatsapp-conversation-free-1" + CONFERENCE = "conference" + CONVERSATIONAL_INSIGHTS = "conversational-insights" + CONVERSATIONAL_INSIGHTS_MESSAGES = "conversational-insights-messages" + CONVERSATIONAL_INSIGHTS_VOICE_MINUTES = "conversational-insights-voice-minutes" + DEMO = "demo" + DEMO_UC_SCRIPT_TEST = "demo-uc-script-test" + ELASTIC_SIP_TRUNKING = "elastic-sip-trunking" + ELASTIC_SIP_TRUNKING_CALL_TRANSFERS = "elastic-sip-trunking-call-transfers" + ENTERPRISE_HIPPA = "enterprise-hippa" + FLEX_NAMED_USERS = "flex-named-users" + FLEX_SPINSCI = "flex-spinsci" + FLEX_USERS_1 = "flex-users-1" + FLEX_WFO_PREMIUM_SPEECH_ANALYTICS = "flex-wfo-premium-speech-analytics" + FLEX_XCELERATE = "flex-xcelerate" + FUNCTIONS_ROLLUP = "functions-rollup" + IMP_V1_USAGE = "imp-v1-usage" + IP_MESSAGING_ADDONS = "ip-messaging-addons" + IVR = "ivr" + IVR_CONVERSATIONAL = "ivr-conversational" + IVR_DTMF = "ivr-dtmf" + IVR_VIRTUALAGENT = "ivr-virtualagent" + LIVE = "live" + LIVE_MEDIA_RECORDING_MINUTES = "live-media-recording-minutes" + LONGCODE_MPS = "longcode-mps" + MARKETPLACE_ANALYTICS_ADDONS = "marketplace-analytics-addons" + MARKETPLACE_ISV_ADDONS = "marketplace-isv-addons" + MARKETPLACE_MESSAGING_ADDONS = "marketplace-messaging-addons" + MARKETPLACE_PHONENUMBERS_ADDONS = "marketplace-phonenumbers-addons" + MARKETPLACE_RECORDING_ADDONS = "marketplace-recording-addons" + MARKETPLACE_VIRTUALAGENT_ADDONS = "marketplace-virtualagent-addons" + MARKETPLAY_PAY_ADDONS_SHUTTLE_PAY_CONNECTOR_1 = ( + "marketplay-pay-addons-shuttle-pay-connector-1" + ) + MARKETPLAY_PAY_ADDONS_STRIPE_PAY_CONNECTOR = ( + "marketplay-pay-addons-stripe-pay-connector" + ) + MMS_INBOUND_LONGCODE_CANADA = "mms-inbound-longcode-canada" + MMS_INBOUND_LONGCODE_UNITEDSTATES = "mms-inbound-longcode-unitedstates" + MMS_OUTBOUND_LONGCODE_CANADA = "mms-outbound-longcode-canada" + MMS_OUTBOUND_LONGCODE_UNITEDSTATES = "mms-outbound-longcode-unitedstates" + MMS_OUTBOUND_TOLL_FREE = "mms-outbound-toll-free" + NOTIFY_CHATAPPSANDOTHERCHANNELS = "notify-chatappsandotherchannels" + NOTIFY_NOTIFYSERVICES = "notify-notifyservices" + NOTIFY_PUSHNOTIFICATIONS = "notify-pushnotifications" + PAYMENT_GATEWAY_CONNECTORS = "payment-gateway-connectors" + PAYMENT_SOLUTIONS = "payment-solutions" + PCHAT_BUCKET_ADJUSTMENT = "pchat-bucket-adjustment" + PHONENUMBERS_NUMBERS = "phonenumbers-numbers" + PROG_VOICE_CLIENT_ANDROID = "prog-voice-client-android" + PROG_VOICE_CLIENT_ANDROID_INBOUND = "prog-voice-client-android-inbound" + PROG_VOICE_CLIENT_ANDROID_OUTBOUND = "prog-voice-client-android-outbound" + PROG_VOICE_CLIENT_IOS = "prog-voice-client-ios" + PROG_VOICE_CLIENT_IOS_INBOUND = "prog-voice-client-ios-inbound" + PROG_VOICE_CLIENT_IOS_OUTBOUND = "prog-voice-client-ios-outbound" + PROG_VOICE_CLIENT_SDK = "prog-voice-client-sdk" + PROG_VOICE_CLIENT_WEB = "prog-voice-client-web" + PROG_VOICE_CLIENT_WEB_INBOUND = "prog-voice-client-web-inbound" + PROG_VOICE_CLIENT_WEB_OUTBOUND = "prog-voice-client-web-outbound" + PROGRAMMABLEVOICECONNECTIVITY_MEDIA_STREAMS = ( + "programmablevoiceconnectivity-media-streams" + ) + PSTNCONNECTIVITY_BYOC = "pstnconnectivity-byoc" + PSTNCONNECTIVITY_EMERGENCY = "pstnconnectivity-emergency" + PSTNCONNECTIVITY_MINUTES = "pstnconnectivity-minutes" + PSTNCONNECTIVITY_MINUTES_1 = "pstnconnectivity-minutes-1" + PSTNCONNECTIVITY_MINUTESINBOUNDLOCAL = "pstnconnectivity-minutesinboundlocal" + PSTNCONNECTIVITY_MINUTESINBOUNDMOBILE = "pstnconnectivity-minutesinboundmobile" + PSTNCONNECTIVITY_MINUTESINBOUNDTOLLFREE = ( + "pstnconnectivity-minutesinboundtollfree" + ) + PSTNCONNECTIVITY_MINUTESINBOUNDTOLLFREELOCAL = ( + "pstnconnectivity-minutesinboundtollfreelocal" + ) + PSTNCONNECTIVITY_MINUTESINBOUNDTOLLFREEMOBILE = ( + "pstnconnectivity-minutesinboundtollfreemobile" + ) + PV_ROOM_HOURS = "pv-room-hours" + PV_ROOM_SIMULTANEOUS_PARTICIPANT_CONNECTIONS = ( + "pv-room-simultaneous-participant-connections" + ) + PVIDEO_ROOM_HOURS_AU1 = "pvideo-room-hours-au1" + PVIDEO_ROOM_HOURS_BR1 = "pvideo-room-hours-br1" + PVIDEO_ROOM_HOURS_IE1 = "pvideo-room-hours-ie1" + PVIDEO_ROOM_HOURS_JP1 = "pvideo-room-hours-jp1" + PVIDEO_ROOM_HOURS_SG1 = "pvideo-room-hours-sg1" + PVIDEO_ROOM_HOURS_US1 = "pvideo-room-hours-us1" + PVIDEO_ROOM_HOURS_US2 = "pvideo-room-hours-us2" + RECORDINGS_ENCRYPTED = "recordings-encrypted" + SHORT_CODE_SETUP_FEES = "short-code-setup-fees" + SHORTCODES_MESSAGES_INBOUND = "shortcodes-messages-inbound" + SHORTCODES_MESSAGES_OUTBOUND = "shortcodes-messages-outbound" + SMS_MESSAGES_REGISTRATIONFEES = "sms-messages-registrationfees" + SMS_MMS_PENALTY_FEES = "sms-mms-penalty-fees" + SMS_MMS_PENALTY_FEES_1 = "sms-mms-penalty-fees-1" + SMS_PUMPING_PROTECTION_NON_USCA = "sms-pumping-protection-non-usca" + SMS_PUMPING_PROTECTION_USCA = "sms-pumping-protection-usca" + STUDIO = "studio" + STUDIO_MONTHLY_FEES = "studio-monthly-fees" + SUPERSIM = "supersim" + TASK_ROUTER = "task-router" + TASK_ROUTER_WORKERS = "task-router-workers" + TEST_QUOTA_BUCKETS = "test-quota-buckets" + TEST_UC_SCRIPT_1 = "test-uc-script-1" + TEST_UC_SCRIPT_DEMO_2 = "test-uc-script-demo-2" + TEXT_TO_SPEECH = "text-to-speech" + TME = "tme" + TTS_BASIC = "tts-basic" + TWILIO_EDITIONS = "twilio-editions" + TWILIO_INTERCONNECT_CALIFORNIA = "twilio-interconnect-california" + TWILIO_INTERCONNECT_CALIFORNIA_MONTHLY = ( + "twilio-interconnect-california-monthly" + ) + TWILIO_INTERCONNECT_CALIFORNIA_SETUP = "twilio-interconnect-california-setup" + TWILIO_INTERCONNECT_FRANKFURT = "twilio-interconnect-frankfurt" + TWILIO_INTERCONNECT_FRANKFURT_MO = "twilio-interconnect-frankfurt-mo" + TWILIO_INTERCONNECT_FRANKFURT_SETUP = "twilio-interconnect-frankfurt-setup" + TWILIO_INTERCONNECT_LONDON = "twilio-interconnect-london" + TWILIO_INTERCONNECT_LONDON_MO = "twilio-interconnect-london-mo" + TWILIO_INTERCONNECT_LONDON_SETUP = "twilio-interconnect-london-setup" + TWILIO_INTERCONNECT_SAO_PAULO = "twilio-interconnect-sao-paulo" + TWILIO_INTERCONNECT_SAO_PAULO_MONTHLY = "twilio-interconnect-sao-paulo-monthly" + TWILIO_INTERCONNECT_SAO_PAULO_SETUP = "twilio-interconnect-sao-paulo-setup" + TWILIO_INTERCONNECT_SINGAPORE = "twilio-interconnect-singapore" + TWILIO_INTERCONNECT_SINGAPORE_MO = "twilio-interconnect-singapore-mo" + TWILIO_INTERCONNECT_SINGAPORE_SETUP = "twilio-interconnect-singapore-setup" + TWILIO_INTERCONNECT_SYDNEY = "twilio-interconnect-sydney" + TWILIO_INTERCONNECT_SYDNEY_MO = "twilio-interconnect-sydney-mo" + TWILIO_INTERCONNECT_SYDNEY_SETUP = "twilio-interconnect-sydney-setup" + TWILIO_INTERCONNECT_TOKYO = "twilio-interconnect-tokyo" + TWILIO_INTERCONNECT_TOKYO_MO = "twilio-interconnect-tokyo-mo" + TWILIO_INTERCONNECT_TOKYO_SETUP = "twilio-interconnect-tokyo-setup" + TWILIO_INTERCONNECT_VA = "twilio-interconnect-va" + TWILIO_INTERCONNECT_VA_MO = "twilio-interconnect-va-mo" + TWILIO_INTERCONNECT_VA_SETUP = "twilio-interconnect-va-setup" + TWIML_VERBS = "twiml-verbs" + TWIML_VERBS_SAY = "twiml-verbs-say" + USAGE_PROGRAMMABLE_MESSAGING_ENGAGEMENT_SUITE = ( + "usage-programmable-messaging-engagement-suite" + ) + USAGE_PROGRAMMABLE_MESSAGING_FEES_SERVICES = ( + "usage-programmable-messaging-fees-services" + ) + VERIFY_OUTBOUND_EMAIL = "verify-outbound-email" + VERIFY_PACKAGED_PLANS = "verify-packaged-plans" + VERIFY_SILENT_NETWORK_AUTH = "verify-silent-network-auth" + VERIFY_VOICE_AND_SMS = "verify-voice-and-sms" + VOICE_INSIGHTS_CLIENT_INSIGHTS_MONTHY_COMMIT = ( + "voice-insights-client-insights-monthy-commit" + ) + WIRELESS_DATA_PAYG_ASIA_AFG = "wireless-data-payg-asia-afg" + WIRELESS_MULTI_IMSI_SIM_COMMANDS = "wireless-multi-imsi-sim-commands" + WIRELESS_MULTI_IMSI_SIM_COMMANDS_USA = "wireless-multi-imsi-sim-commands-usa" + WIRELESS_MULTI_IMSI_SIM_DATA = "wireless-multi-imsi-sim-data" + WIRELESS_MULTI_IMSI_SIM_DATA_EU28 = "wireless-multi-imsi-sim-data-eu28" + WIRELESS_MULTI_IMSI_SIM_DATA_USA = "wireless-multi-imsi-sim-data-usa" + WIRELESS_MULTI_IMSI_SIM_MONTHLY_FEES = "wireless-multi-imsi-sim-monthly-fees" + WIRELESS_MULTI_IMSI_SIM_USAGE = "wireless-multi-imsi-sim-usage" + WIRELESS_SUPER_SIM_DATA_NORTH_AMERICA = "wireless-super-sim-data-north-america" + WIRELESS_SUPER_SIM_USAGE = "wireless-super-sim-usage" """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that accrued the usage. @@ -401,6 +893,7 @@ def __repr__(self) -> str: class ThisMonthPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ThisMonthInstance: """ Build an instance of ThisMonthInstance @@ -421,6 +914,7 @@ def __repr__(self) -> str: class ThisMonthList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the ThisMonthList @@ -623,14 +1117,20 @@ def page( "Category": category, "StartDate": serialize.iso8601_date(start_date), "EndDate": serialize.iso8601_date(end_date), - "IncludeSubaccounts": include_subaccounts, + "IncludeSubaccounts": serialize.boolean_to_string(include_subaccounts), "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 ThisMonthPage(self._version, response, self._solution) async def page_async( @@ -662,15 +1162,19 @@ async def page_async( "Category": category, "StartDate": serialize.iso8601_date(start_date), "EndDate": serialize.iso8601_date(end_date), - "IncludeSubaccounts": include_subaccounts, + "IncludeSubaccounts": serialize.boolean_to_string(include_subaccounts), "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 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 c499b7f1aa..393238e76f 100644 --- a/twilio/rest/api/v2010/account/usage/record/today.py +++ b/twilio/rest/api/v2010/account/usage/record/today.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import date from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import deserialize, serialize, values @@ -24,34 +23,103 @@ class TodayInstance(InstanceResource): + class Category(object): + A2P_10DLC_REGISTRATIONFEES_BRANDREGISTRATION = ( + "a2p-10dlc-registrationfees-brandregistration" + ) + A2P_10DLC_REGISTRATIONFEES_BV = "a2p-10dlc-registrationfees-bv" + A2P_10DLC_REGISTRATIONFEES_CAMPAIGNCHARGES = ( + "a2p-10dlc-registrationfees-campaigncharges" + ) + A2P_10DLC_REGISTRATIONFEES_CAMPAIGNREGISTRATION = ( + "a2p-10dlc-registrationfees-campaignregistration" + ) + A2P_10DLC_REGISTRATIONFEES_CAMPAIGNVETTING = ( + "a2p-10dlc-registrationfees-campaignvetting" + ) + A2P_10DLC_REGISTRATIONFEES_MONTHLY = "a2p-10dlc-registrationfees-monthly" + A2P_10DLC_REGISTRATIONFEES_ONETIME = "a2p-10dlc-registrationfees-onetime" A2P_REGISTRATION_FEES = "a2p-registration-fees" + ACCOUNT_SECURITY = "account-security" AGENT_CONFERENCE = "agent-conference" + AGENT_COPILOT = "agent-copilot" + AGENT_COPILOT_MESSAGES = "agent-copilot-messages" + AGENT_COPILOT_PARTICIPANT_MINUTES = "agent-copilot-participant-minutes" + AI_ASSISTANTS = "ai-assistants" + AI_ASSISTANTS_VOICE = "ai-assistants-voice" AMAZON_POLLY = "amazon-polly" ANSWERING_MACHINE_DETECTION = "answering-machine-detection" + ASSETS = "assets" + AUDIENCE_MINUTES = "audience-minutes" + AUDIENCE_MINUTES_AUDIO = "audience-minutes-audio" AUTHY_AUTHENTICATIONS = "authy-authentications" AUTHY_CALLS_OUTBOUND = "authy-calls-outbound" + AUTHY_EMAIL_AUTHENTICATIONS = "authy-email-authentications" AUTHY_MONTHLY_FEES = "authy-monthly-fees" + AUTHY_OUTBOUND_EMAIL = "authy-outbound-email" AUTHY_PHONE_INTELLIGENCE = "authy-phone-intelligence" AUTHY_PHONE_VERIFICATIONS = "authy-phone-verifications" AUTHY_SMS_OUTBOUND = "authy-sms-outbound" + AUTHY_VERIFY_EMAIL_VERIFICATIONS = "authy-verify-email-verifications" + AUTHY_VERIFY_OUTBOUND_EMAIL = "authy-verify-outbound-email" + AUTOPILOT = "autopilot" + AUTOPILOT_HOME_ASSISTANTS = "autopilot-home-assistants" + AUTOPILOT_MESSAGING = "autopilot-messaging" + AUTOPILOT_OTHER = "autopilot-other" + AUTOPILOT_VOICE = "autopilot-voice" + BASIC_PEER_TO_PEER_ROOMS_PARTICIPANT_MINUTES = ( + "basic-peer-to-peer-rooms-participant-minutes" + ) + BRANDED_CALLING = "branded-calling" + BUNDLE_SMS_BUCKET = "bundle-sms-bucket" + BUNDLE_SUBSCRIPTION_FEES = "bundle-subscription-fees" + CALL_FORWARDING_LOOKUPS = "call-forwarding-lookups" CALL_PROGESS_EVENTS = "call-progess-events" CALLERIDLOOKUPS = "calleridlookups" CALLS = "calls" CALLS_CLIENT = "calls-client" + CALLS_EMERGENCY = "calls-emergency" CALLS_GLOBALCONFERENCE = "calls-globalconference" CALLS_INBOUND = "calls-inbound" CALLS_INBOUND_LOCAL = "calls-inbound-local" CALLS_INBOUND_MOBILE = "calls-inbound-mobile" CALLS_INBOUND_TOLLFREE = "calls-inbound-tollfree" + CALLS_INBOUND_TOLLFREE_LOCAL = "calls-inbound-tollfree-local" + CALLS_INBOUND_TOLLFREE_MOBILE = "calls-inbound-tollfree-mobile" + CALLS_MEDIA_STREAM_MINUTES = "calls-media-stream-minutes" CALLS_OUTBOUND = "calls-outbound" CALLS_PAY_VERB_TRANSACTIONS = "calls-pay-verb-transactions" CALLS_RECORDINGS = "calls-recordings" CALLS_SIP = "calls-sip" CALLS_SIP_INBOUND = "calls-sip-inbound" CALLS_SIP_OUTBOUND = "calls-sip-outbound" + CALLS_TEXT_TO_SPEECH = "calls-text-to-speech" CALLS_TRANSFERS = "calls-transfers" CARRIER_LOOKUPS = "carrier-lookups" + CATEGORY = "category" + CHANNELS = "channels" + CHANNELS_MESSAGING = "channels-messaging" + CHANNELS_MESSAGING_INBOUND = "channels-messaging-inbound" + CHANNELS_MESSAGING_OUTBOUND = "channels-messaging-outbound" + CHANNELS_WHATSAPP = "channels-whatsapp" + CHANNELS_WHATSAPP_CONVERSATION_AUTHENTICATION = ( + "channels-whatsapp-conversation-authentication" + ) + CHANNELS_WHATSAPP_CONVERSATION_FREE = "channels-whatsapp-conversation-free" + CHANNELS_WHATSAPP_CONVERSATION_MARKETING = ( + "channels-whatsapp-conversation-marketing" + ) + CHANNELS_WHATSAPP_CONVERSATION_SERVICE = ( + "channels-whatsapp-conversation-service" + ) + CHANNELS_WHATSAPP_CONVERSATION_UTILITY = ( + "channels-whatsapp-conversation-utility" + ) + CHANNELS_WHATSAPP_INBOUND = "channels-whatsapp-inbound" + CHANNELS_WHATSAPP_OUTBOUND = "channels-whatsapp-outbound" + CHAT_VIRTUAL_AGENT = "chat-virtual-agent" + CONVERSATION_RELAY = "conversation-relay" CONVERSATIONS = "conversations" CONVERSATIONS_API_REQUESTS = "conversations-api-requests" CONVERSATIONS_CONVERSATION_EVENTS = "conversations-conversation-events" @@ -60,8 +128,40 @@ class Category(object): CONVERSATIONS_PARTICIPANT_EVENTS = "conversations-participant-events" CONVERSATIONS_PARTICIPANTS = "conversations-participants" CPS = "cps" + CREDIT_TRANSFER = "credit-transfer" + EMAIL = "email" + EMERGING_TECH = "emerging-tech" + ENGAGEMENT_SUITE_PACKAGED_PLANS = "engagement-suite-packaged-plans" + ENHANCED_LINE_TYPE_LOOKUPS = "enhanced-line-type-lookups" + ENTERPRISE = "enterprise" + EVENTS = "events" + EXPERIMENT_FRANCE_SMS = "experiment-france-sms" + EXPERIMENT_INDIA_SMS = "experiment-india-sms" + EXPERIMENT_UK_SMS = "experiment-uk-sms" + FAILED_MESSAGE_PROCESSING_FEE = "failed-message-processing-fee" + FLEX = "flex" + FLEX_ACTIVE_USER_HOURS = "flex-active-user-hours" + FLEX_CONCURRENT_USERS = "flex-concurrent-users" + FLEX_CONVERSATIONAL_INSIGHTS = "flex-conversational-insights" + FLEX_CONVERSATIONAL_INSIGHTS_MESSAGES = "flex-conversational-insights-messages" + FLEX_CONVERSATIONAL_INSIGHTS_VOICE_MINUTES = ( + "flex-conversational-insights-voice-minutes" + ) + FLEX_EMAIL_USAGE = "flex-email-usage" + FLEX_MESSAGING_USAGE = "flex-messaging-usage" + FLEX_PARTNER_SPINSCI = "flex-partner-spinsci" + FLEX_PARTNER_XCELERATE = "flex-partner-xcelerate" + FLEX_RESELLER_ECOSYSTEM = "flex-reseller-ecosystem" + FLEX_UNIQUE_USER = "flex-unique-user" FLEX_USAGE = "flex-usage" + FLEX_USERS = "flex-users" + FLEX_VOICE_MINUTE = "flex-voice-minute" + FLEX_YTICA = "flex-ytica" FRAUD_LOOKUPS = "fraud-lookups" + FRONTLINE = "frontline" + FRONTLINE_USERS = "frontline-users" + FUNCTIONS = "functions" + GENERIC_PAY_TRANSACTIONS = "generic-pay-transactions" GROUP_ROOMS = "group-rooms" GROUP_ROOMS_DATA_TRACK = "group-rooms-data-track" GROUP_ROOMS_ENCRYPTED_MEDIA_RECORDED = "group-rooms-encrypted-media-recorded" @@ -71,7 +171,17 @@ class Category(object): GROUP_ROOMS_MEDIA_STORED = "group-rooms-media-stored" GROUP_ROOMS_PARTICIPANT_MINUTES = "group-rooms-participant-minutes" GROUP_ROOMS_RECORDED_MINUTES = "group-rooms-recorded-minutes" - IMP_V1_USAGE = "imp-v1-usage" + IP_MESSAGING = "ip-messaging" + IP_MESSAGING_COMMANDS = "ip-messaging-commands" + IP_MESSAGING_DATA_STORAGE = "ip-messaging-data-storage" + IP_MESSAGING_DATA_TRANSFER = "ip-messaging-data-transfer" + IP_MESSAGING_ENDPOINT_CONNECTIVITY = "ip-messaging-endpoint-connectivity" + IVR_VIRTUAL_AGENT_CUSTOM_VOICES = "ivr-virtual-agent-custom-voices" + IVR_VIRTUAL_AGENT_GENAI = "ivr-virtual-agent-genai" + LINE_STATUS_LOOKUPS = "line-status-lookups" + LIVE_ACTIVITY_LOOKUPS = "live-activity-lookups" + LOOKUP_BUCKET_ADJUSTMENT = "lookup-bucket-adjustment" + LOOKUP_IDENTITY_MATCH = "lookup-identity-match" LOOKUPS = "lookups" MARKETPLACE = "marketplace" MARKETPLACE_ALGORITHMIA_NAMED_ENTITY_RECOGNITION = ( @@ -82,6 +192,13 @@ class Category(object): MARKETPLACE_CAPIO_SPEECH_TO_TEXT = "marketplace-capio-speech-to-text" MARKETPLACE_CONVRIZA_ABABA = "marketplace-convriza-ababa" MARKETPLACE_DEEPGRAM_PHRASE_DETECTOR = "marketplace-deepgram-phrase-detector" + MARKETPLACE_DEEPGRAM_TRANSCRIPTION = "marketplace-deepgram-transcription" + MARKETPLACE_DEEPGRAM_TRANSCRIPTION_BASE = ( + "marketplace-deepgram-transcription-base" + ) + MARKETPLACE_DEEPGRAM_TRANSSCRIPTION_ENHANCED = ( + "marketplace-deepgram-transscription-enhanced" + ) MARKETPLACE_DIGITAL_SEGMENT_BUSINESS_INFO = ( "marketplace-digital-segment-business-info" ) @@ -107,6 +224,9 @@ class Category(object): "marketplace-keen-io-contact-center-analytics" ) MARKETPLACE_MARCHEX_CLEANCALL = "marketplace-marchex-cleancall" + MARKETPLACE_MARCHEX_RECORDING_ANALYSIS = ( + "marketplace-marchex-recording-analysis" + ) MARKETPLACE_MARCHEX_SENTIMENT_ANALYSIS_FOR_SMS = ( "marketplace-marchex-sentiment-analysis-for-sms" ) @@ -123,14 +243,42 @@ class Category(object): "marketplace-nextcaller-advanced-caller-identification" ) MARKETPLACE_NOMOROBO_SPAM_SCORE = "marketplace-nomorobo-spam-score" + MARKETPLACE_PAY_ADDONS = "marketplace-pay-addons" + MARKETPLACE_PAY_ADDONS_BASECOMMERCE_PAY_CONNECTOR = ( + "marketplace-pay-addons-basecommerce-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_BRAINTREE_PAY_CONNECTOR = ( + "marketplace-pay-addons-braintree-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_CARDCONNECT_PAY_CONNECTOR = ( + "marketplace-pay-addons-cardconnect-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_CHASE_PAY_CONNECTOR = ( + "marketplace-pay-addons-chase-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_SHUTTLE_PAY_CONNECTOR = ( + "marketplace-pay-addons-shuttle-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_STRIPE_PAY_CONNECTOR = ( + "marketplace-pay-addons-stripe-pay-connector" + ) MARKETPLACE_PAYFONE_TCPA_COMPLIANCE = "marketplace-payfone-tcpa-compliance" + MARKETPLACE_POLY_AI_CONNECTOR = "marketplace-poly-ai-connector" + MARKETPLACE_REALPHONEVALIDATION = "marketplace-realphonevalidation" MARKETPLACE_REMEETING_AUTOMATIC_SPEECH_RECOGNITION = ( "marketplace-remeeting-automatic-speech-recognition" ) + MARKETPLACE_SPOKE_PHONE_LICENSE_PRO = "marketplace-spoke-phone-license-pro" + MARKETPLACE_SPOKE_PHONE_LICENSE_STANDARD = ( + "marketplace-spoke-phone-license-standard" + ) MARKETPLACE_TCPA_DEFENSE_SOLUTIONS_BLACKLIST_FEED = ( "marketplace-tcpa-defense-solutions-blacklist-feed" ) MARKETPLACE_TELO_OPENCNAM = "marketplace-telo-opencnam" + MARKETPLACE_TRESTLE_SOLUTIONS_CALLER_IDENTIFICATION = ( + "marketplace-trestle-solutions-caller-identification" + ) MARKETPLACE_TRUECNAM_TRUE_SPAM = "marketplace-truecnam-true-spam" MARKETPLACE_TWILIO_CALLER_NAME_LOOKUP_US = ( "marketplace-twilio-caller-name-lookup-us" @@ -143,6 +291,9 @@ class Category(object): MARKETPLACE_VOICEBASE_TRANSCRIPTION_CUSTOM_VOCABULARY = ( "marketplace-voicebase-transcription-custom-vocabulary" ) + MARKETPLACE_WEB_PURIFY_PROFANITY_FILTER = ( + "marketplace-web-purify-profanity-filter" + ) MARKETPLACE_WHITEPAGES_PRO_CALLER_IDENTIFICATION = ( "marketplace-whitepages-pro-caller-identification" ) @@ -157,15 +308,23 @@ class Category(object): MARKETPLACE_YTICA_CONTACT_CENTER_REPORTING_ANALYTICS = ( "marketplace-ytica-contact-center-reporting-analytics" ) + MARKETPLAY_PAY_ADDONS_SHUTTLE_PAY_CONNECTOR = ( + "marketplay-pay-addons-shuttle-pay-connector" + ) + MEDIA_COMPOSER_MINUTES = "media-composer-minutes" MEDIASTORAGE = "mediastorage" + MIN_SPEND_ADJUSTMENTS = "min-spend-adjustments" MMS = "mms" MMS_INBOUND = "mms-inbound" MMS_INBOUND_LONGCODE = "mms-inbound-longcode" MMS_INBOUND_SHORTCODE = "mms-inbound-shortcode" + MMS_INBOUND_TOLL_FREE = "mms-inbound-toll-free" MMS_MESSAGES_CARRIERFEES = "mms-messages-carrierfees" MMS_OUTBOUND = "mms-outbound" MMS_OUTBOUND_LONGCODE = "mms-outbound-longcode" MMS_OUTBOUND_SHORTCODE = "mms-outbound-shortcode" + MMS_OUTBOUND_TOLLFREE = "mms-outbound-tollfree" + MONITOR = "monitor" MONITOR_READS = "monitor-reads" MONITOR_STORAGE = "monitor-storage" MONITOR_WRITES = "monitor-writes" @@ -174,6 +333,12 @@ class Category(object): NOTIFY_CHANNELS = "notify-channels" NUMBER_FORMAT_LOOKUPS = "number-format-lookups" PCHAT = "pchat" + PCHAT_ACTIONS = "pchat-actions" + PCHAT_APS = "pchat-aps" + PCHAT_CONV_MED_STORAGE = "pchat-conv-med-storage" + PCHAT_MESSAGES = "pchat-messages" + PCHAT_NOTIFICATIONS = "pchat-notifications" + PCHAT_READS = "pchat-reads" PCHAT_USERS = "pchat-users" PEER_TO_PEER_ROOMS_PARTICIPANT_MINUTES = ( "peer-to-peer-rooms-participant-minutes" @@ -183,18 +348,41 @@ class Category(object): PFAX_MINUTES_INBOUND = "pfax-minutes-inbound" PFAX_MINUTES_OUTBOUND = "pfax-minutes-outbound" PFAX_PAGES = "pfax-pages" + PHONE_QUALITY_SCORE_LOOKUPS = "phone-quality-score-lookups" PHONENUMBERS = "phonenumbers" PHONENUMBERS_CPS = "phonenumbers-cps" PHONENUMBERS_EMERGENCY = "phonenumbers-emergency" PHONENUMBERS_LOCAL = "phonenumbers-local" PHONENUMBERS_MOBILE = "phonenumbers-mobile" + PHONENUMBERS_PORTING = "phonenumbers-porting" PHONENUMBERS_SETUPS = "phonenumbers-setups" PHONENUMBERS_TOLLFREE = "phonenumbers-tollfree" PREMIUMSUPPORT = "premiumsupport" + PREMIUMSUPPORT_PERCENTAGE_SPEND = "premiumsupport-percentage-spend" + PROGRAMMABLEVOICE_PLATFORM = "programmablevoice-platform" + PROGRAMMABLEVOICECONN_CLIENTSDK = "programmablevoiceconn-clientsdk" + PROGRAMMABLEVOICECONN_CLIENTSDK_INBOUND = ( + "programmablevoiceconn-clientsdk-inbound" + ) + PROGRAMMABLEVOICECONN_CLIENTSDK_OUTBOUND = ( + "programmablevoiceconn-clientsdk-outbound" + ) + PROGRAMMABLEVOICECONN_ONNET = "programmablevoiceconn-onnet" + PROGRAMMABLEVOICECONN_ONNET_INBOUND = "programmablevoiceconn-onnet-inbound" + PROGRAMMABLEVOICECONN_ONNET_OUTBOUND = "programmablevoiceconn-onnet-outbound" + PROGRAMMABLEVOICECONN_SIP = "programmablevoiceconn-sip" + PROGRAMMABLEVOICECONN_SIP_INBOUND = "programmablevoiceconn-sip-inbound" + PROGRAMMABLEVOICECONN_SIP_OUTBOUND = "programmablevoiceconn-sip-outbound" + PROGRAMMABLEVOICECONNECTIVITY = "programmablevoiceconnectivity" PROXY = "proxy" PROXY_ACTIVE_SESSIONS = "proxy-active-sessions" + PROXY_BUCKET_ADJUSTMENT = "proxy-bucket-adjustment" + PROXY_LICENSES = "proxy-licenses" PSTNCONNECTIVITY = "pstnconnectivity" + PSTNCONNECTIVITY_INBOUND = "pstnconnectivity-inbound" + PSTNCONNECTIVITY_OUTBOUND = "pstnconnectivity-outbound" PV = "pv" + PV_BASIC_ROOMS = "pv-basic-rooms" PV_COMPOSITION_MEDIA_DOWNLOADED = "pv-composition-media-downloaded" PV_COMPOSITION_MEDIA_ENCRYPTED = "pv-composition-media-encrypted" PV_COMPOSITION_MEDIA_STORED = "pv-composition-media-stored" @@ -210,18 +398,20 @@ class Category(object): PV_ROOM_PARTICIPANTS_US2 = "pv-room-participants-us2" PV_ROOMS = "pv-rooms" PV_SIP_ENDPOINT_REGISTRATIONS = "pv-sip-endpoint-registrations" + RCS_MESSAGES = "rcs-messages" + REASSIGNED_NUMBER = "reassigned-number" RECORDINGS = "recordings" RECORDINGSTORAGE = "recordingstorage" - ROOMS_GROUP_BANDWIDTH = "rooms-group-bandwidth" - ROOMS_GROUP_MINUTES = "rooms-group-minutes" - ROOMS_PEER_TO_PEER_MINUTES = "rooms-peer-to-peer-minutes" SHORTCODES = "shortcodes" SHORTCODES_CUSTOMEROWNED = "shortcodes-customerowned" SHORTCODES_MMS_ENABLEMENT = "shortcodes-mms-enablement" SHORTCODES_MPS = "shortcodes-mps" SHORTCODES_RANDOM = "shortcodes-random" + SHORTCODES_SETUP_FEES = "shortcodes-setup-fees" SHORTCODES_UK = "shortcodes-uk" SHORTCODES_VANITY = "shortcodes-vanity" + SIM_SWAP_LOOKUPS = "sim-swap-lookups" + SIP_SECURE_MEDIA = "sip-secure-media" SMALL_GROUP_ROOMS = "small-group-rooms" SMALL_GROUP_ROOMS_DATA_TRACK = "small-group-rooms-data-track" SMALL_GROUP_ROOMS_PARTICIPANT_MINUTES = "small-group-rooms-participant-minutes" @@ -229,13 +419,30 @@ class Category(object): SMS_INBOUND = "sms-inbound" SMS_INBOUND_LONGCODE = "sms-inbound-longcode" SMS_INBOUND_SHORTCODE = "sms-inbound-shortcode" + SMS_INBOUND_TOLLFREE = "sms-inbound-tollfree" SMS_MESSAGES_CARRIERFEES = "sms-messages-carrierfees" SMS_MESSAGES_FEATURES = "sms-messages-features" + SMS_MESSAGES_FEATURES_ENGAGEMENT_SUITE = ( + "sms-messages-features-engagement-suite" + ) + SMS_MESSAGES_FEATURES_MESSAGE_REDACTION = ( + "sms-messages-features-message-redaction" + ) SMS_MESSAGES_FEATURES_SENDERID = "sms-messages-features-senderid" + SMS_MPS = "sms-mps" + SMS_MPS_SHORTCODE = "sms-mps-shortcode" + SMS_MPS_TOLLFREE = "sms-mps-tollfree" + SMS_MPS_TOLLFREE_SETUP = "sms-mps-tollfree-setup" + SMS_NATIONAL_REGULATORY_PROTECTION = "sms-national-regulatory-protection" SMS_OUTBOUND = "sms-outbound" SMS_OUTBOUND_CONTENT_INSPECTION = "sms-outbound-content-inspection" SMS_OUTBOUND_LONGCODE = "sms-outbound-longcode" SMS_OUTBOUND_SHORTCODE = "sms-outbound-shortcode" + SMS_OUTBOUND_TOLLFREE = "sms-outbound-tollfree" + SMS_PUMPING_PROTECTION = "sms-pumping-protection" + SMS_PUMPING_RISK = "sms-pumping-risk" + SMSMESSAGES_BUCKET_ADJUSTMENTS = "smsmessages-bucket-adjustments" + SMSMESSAGES_OUTBOUND_DOMESTIC = "smsmessages-outbound-domestic" SPEECH_RECOGNITION = "speech-recognition" STUDIO_ENGAGEMENTS = "studio-engagements" SYNC = "sync" @@ -254,6 +461,7 @@ class Category(object): TRUNKING_RECORDINGS = "trunking-recordings" TRUNKING_SECURE = "trunking-secure" TRUNKING_TERMINATION = "trunking-termination" + TTS_GOOGLE = "tts-google" TURNMEGABYTES = "turnmegabytes" TURNMEGABYTES_AUSTRALIA = "turnmegabytes-australia" TURNMEGABYTES_BRASIL = "turnmegabytes-brasil" @@ -264,13 +472,27 @@ class Category(object): TURNMEGABYTES_SINGAPORE = "turnmegabytes-singapore" TURNMEGABYTES_USEAST = "turnmegabytes-useast" TURNMEGABYTES_USWEST = "turnmegabytes-uswest" + TWILIO_FOR_SALESFORCE = "twilio-for-salesforce" + TWILIO_FOR_SALESFORCE_LICENSES = "twilio-for-salesforce-licenses" TWILIO_INTERCONNECT = "twilio-interconnect" + TWIML = "twiml" + USAGE_FLEX_VIDEO = "usage-flex-video" + USAGE_FUNCTIONS = "usage-functions" + USAGE_RCS_BASIC_MESSAGES_OUTBOUND = "usage-rcs-basic-messages-outbound" + USAGE_RCS_MESSAGES = "usage-rcs-messages" + USAGE_RCS_MESSAGES_INBOUND = "usage-rcs-messages-inbound" + USAGE_RCS_MESSAGING_CARRIER_FEES = "usage-rcs-messaging-carrier-fees" + USAGE_RCS_SINGLE_MESSAGES_OUTBOUND = "usage-rcs-single-messages-outbound" + VERIFY_PACKAGE_PLANS = "verify-package-plans" VERIFY_PUSH = "verify-push" + VERIFY_SNA = "verify-sna" VERIFY_TOTP = "verify-totp" + VERIFY_VOICE_SMS = "verify-voice-sms" VERIFY_WHATSAPP_CONVERSATIONS_BUSINESS_INITIATED = ( "verify-whatsapp-conversations-business-initiated" ) VIDEO_RECORDINGS = "video-recordings" + VIDEO_ROOMS_TURN_MEGABYTES = "video-rooms-turn-megabytes" VIRTUAL_AGENT = "virtual-agent" VOICE_INSIGHTS = "voice-insights" VOICE_INSIGHTS_CLIENT_INSIGHTS_ON_DEMAND_MINUTE = ( @@ -285,12 +507,104 @@ class Category(object): VOICE_INSIGHTS_SIP_TRUNKING_INSIGHTS_ON_DEMAND_MINUTE = ( "voice-insights-sip-trunking-insights-on-demand-minute" ) + VOICE_INTELLIGENCE = "voice-intelligence" + VOICE_INTELLIGENCE_EIP_OPERATORS = "voice-intelligence-eip-operators" + VOICE_INTELLIGENCE_OPERATORS = "voice-intelligence-operators" + VOICE_INTELLIGENCE_TRANSCRIPTION = "voice-intelligence-transcription" + WDS = "wds" WIRELESS = "wireless" + WIRELESS_DATA = "wireless-data" + WIRELESS_DATA_PAYG = "wireless-data-payg" + WIRELESS_DATA_PAYG_AFRICA = "wireless-data-payg-africa" + WIRELESS_DATA_PAYG_ASIA = "wireless-data-payg-asia" + WIRELESS_DATA_PAYG_CENTRALANDSOUTHAMERICA = ( + "wireless-data-payg-centralandsouthamerica" + ) + WIRELESS_DATA_PAYG_EUROPE = "wireless-data-payg-europe" + WIRELESS_DATA_PAYG_NORTHAMERICA = "wireless-data-payg-northamerica" + WIRELESS_DATA_PAYG_OCEANIA = "wireless-data-payg-oceania" + WIRELESS_DATA_QUOTA1 = "wireless-data-quota1" + WIRELESS_DATA_QUOTA1_AFRICA = "wireless-data-quota1-africa" + WIRELESS_DATA_QUOTA1_ASIA = "wireless-data-quota1-asia" + WIRELESS_DATA_QUOTA1_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quota1-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTA1_EUROPE = "wireless-data-quota1-europe" + WIRELESS_DATA_QUOTA1_NORTHAMERICA = "wireless-data-quota1-northamerica" + WIRELESS_DATA_QUOTA1_OCEANIA = "wireless-data-quota1-oceania" + WIRELESS_DATA_QUOTA10 = "wireless-data-quota10" + WIRELESS_DATA_QUOTA10_AFRICA = "wireless-data-quota10-africa" + WIRELESS_DATA_QUOTA10_ASIA = "wireless-data-quota10-asia" + WIRELESS_DATA_QUOTA10_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quota10-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTA10_EUROPE = "wireless-data-quota10-europe" + WIRELESS_DATA_QUOTA10_NORTHAMERICA = "wireless-data-quota10-northamerica" + WIRELESS_DATA_QUOTA10_OCEANIA = "wireless-data-quota10-oceania" + WIRELESS_DATA_QUOTA50 = "wireless-data-quota50" + WIRELESS_DATA_QUOTA50_AFRICA = "wireless-data-quota50-africa" + WIRELESS_DATA_QUOTA50_ASIA = "wireless-data-quota50-asia" + WIRELESS_DATA_QUOTA50_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quota50-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTA50_EUROPE = "wireless-data-quota50-europe" + WIRELESS_DATA_QUOTA50_NORTHAMERICA = "wireless-data-quota50-northamerica" + WIRELESS_DATA_QUOTA50_OCEANIA = "wireless-data-quota50-oceania" + WIRELESS_DATA_QUOTACUSTOM = "wireless-data-quotacustom" + WIRELESS_DATA_QUOTACUSTOM_AFRICA = "wireless-data-quotacustom-africa" + WIRELESS_DATA_QUOTACUSTOM_ASIA = "wireless-data-quotacustom-asia" + WIRELESS_DATA_QUOTACUSTOM_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quotacustom-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTACUSTOM_EUROPE = "wireless-data-quotacustom-europe" + WIRELESS_DATA_QUOTACUSTOM_NORTHAMERICA = ( + "wireless-data-quotacustom-northamerica" + ) + WIRELESS_DATA_QUOTACUSTOM_OCEANIA = "wireless-data-quotacustom-oceania" + WIRELESS_MRC_PAYG = "wireless-mrc-payg" + WIRELESS_MRC_QUOTA1 = "wireless-mrc-quota1" + WIRELESS_MRC_QUOTA10 = "wireless-mrc-quota10" + WIRELESS_MRC_QUOTA50 = "wireless-mrc-quota50" + WIRELESS_MRC_QUOTACUSTOM = "wireless-mrc-quotacustom" WIRELESS_ORDERS = "wireless-orders" WIRELESS_ORDERS_ARTWORK = "wireless-orders-artwork" WIRELESS_ORDERS_BULK = "wireless-orders-bulk" WIRELESS_ORDERS_ESIM = "wireless-orders-esim" WIRELESS_ORDERS_STARTER = "wireless-orders-starter" + WIRELESS_QUOTAS = "wireless-quotas" + WIRELESS_SMS_AFRICA = "wireless-sms-africa" + WIRELESS_SMS_ASIA = "wireless-sms-asia" + WIRELESS_SMS_CENTRALANDSOUTHAMERICA = "wireless-sms-centralandsouthamerica" + WIRELESS_SMS_EUROPE = "wireless-sms-europe" + WIRELESS_SMS_NORTHAMERICA = "wireless-sms-northamerica" + WIRELESS_SMS_OCEANIA = "wireless-sms-oceania" + WIRELESS_SUPER_SIM = "wireless-super-sim" + WIRELESS_SUPER_SIM_DATA = "wireless-super-sim-data" + WIRELESS_SUPER_SIM_DATA_NORTH_AMERICA_USA = ( + "wireless-super-sim-data-north-america-usa" + ) + WIRELESS_SUPER_SIM_DATA_PAYG = "wireless-super-sim-data-payg" + WIRELESS_SUPER_SIM_DATA_PAYG_EUROPE = "wireless-super-sim-data-payg-europe" + WIRELESS_SUPER_SIM_DATA_PAYG_NORTH_AMERICA = ( + "wireless-super-sim-data-payg-north-america" + ) + WIRELESS_SUPER_SIM_HARDWARE = "wireless-super-sim-hardware" + WIRELESS_SUPER_SIM_HARDWARE_BULK = "wireless-super-sim-hardware-bulk" + WIRELESS_SUPER_SIM_SMSCOMMANDS = "wireless-super-sim-smscommands" + WIRELESS_SUPER_SIM_SMSCOMMANDS_AFRICA = "wireless-super-sim-smscommands-africa" + WIRELESS_SUPER_SIM_SMSCOMMANDS_ASIA = "wireless-super-sim-smscommands-asia" + WIRELESS_SUPER_SIM_SMSCOMMANDS_CENT_AND_SOUTH_AMERICA = ( + "wireless-super-sim-smscommands-cent-and-south-america" + ) + WIRELESS_SUPER_SIM_SMSCOMMANDS_EUROPE = "wireless-super-sim-smscommands-europe" + WIRELESS_SUPER_SIM_SMSCOMMANDS_NORTH_AMERICA = ( + "wireless-super-sim-smscommands-north-america" + ) + WIRELESS_SUPER_SIM_SMSCOMMANDS_OCEANIA = ( + "wireless-super-sim-smscommands-oceania" + ) + WIRELESS_SUPER_SIM_SUBSCRIPTION = "wireless-super-sim-subscription" + WIRELESS_SUPER_SIM_SUBSCRIPTION_PAYG = "wireless-super-sim-subscription-payg" WIRELESS_USAGE = "wireless-usage" WIRELESS_USAGE_COMMANDS = "wireless-usage-commands" WIRELESS_USAGE_COMMANDS_AFRICA = "wireless-usage-commands-africa" @@ -342,6 +656,184 @@ class Category(object): WIRELESS_USAGE_MRC_SUSPENDED = "wireless-usage-mrc-suspended" WIRELESS_USAGE_SMS = "wireless-usage-sms" WIRELESS_USAGE_VOICE = "wireless-usage-voice" + A2P_FAST_TRACK_ONBOARDING = "a2p-fast-track-onboarding" + ADVISORY_SERVICES = "advisory-services" + ADVISORY_SERVICES_BILLED = "advisory-services-billed" + ADVISORY_SERVICES_CALL_TRACKING = "advisory-services-call-tracking" + ADVISORY_SERVICES_DATA_SERVICES = "advisory-services-data-services" + ADVISORY_SERVICES_EXPENSES = "advisory-services-expenses" + ADVISORY_SERVICES_SIP_TRUNKING = "advisory-services-sip-trunking" + ASSETS_REQUESTS = "assets-requests" + AUDIENCE_MINUTES_VIDEO = "audience-minutes-video" + AUTHY_BUCKET_ADJUSTMENT = "authy-bucket-adjustment" + AUTHY_SOFTWARE = "authy-software" + CALLERIDLOOKUPS_API = "calleridlookups-api" + CALLERIDLOOKUPS_PROGRAMMABLEVOICE = "calleridlookups-programmablevoice" + CALLERIDLOOKUPS_TRUNKING = "calleridlookups-trunking" + CALLS_TRUNKING_INBOUND_TOLLFREE_LOCAL = "calls-trunking-inbound-tollfree-local" + CALLS_TRUNKING_INBOUND_TOLLFREE_MOBILE = ( + "calls-trunking-inbound-tollfree-mobile" + ) + CHANNELS_WHATSAPP_CONVERSATION_FREE_1 = "channels-whatsapp-conversation-free-1" + CONFERENCE = "conference" + CONVERSATIONAL_INSIGHTS = "conversational-insights" + CONVERSATIONAL_INSIGHTS_MESSAGES = "conversational-insights-messages" + CONVERSATIONAL_INSIGHTS_VOICE_MINUTES = "conversational-insights-voice-minutes" + DEMO = "demo" + DEMO_UC_SCRIPT_TEST = "demo-uc-script-test" + ELASTIC_SIP_TRUNKING = "elastic-sip-trunking" + ELASTIC_SIP_TRUNKING_CALL_TRANSFERS = "elastic-sip-trunking-call-transfers" + ENTERPRISE_HIPPA = "enterprise-hippa" + FLEX_NAMED_USERS = "flex-named-users" + FLEX_SPINSCI = "flex-spinsci" + FLEX_USERS_1 = "flex-users-1" + FLEX_WFO_PREMIUM_SPEECH_ANALYTICS = "flex-wfo-premium-speech-analytics" + FLEX_XCELERATE = "flex-xcelerate" + FUNCTIONS_ROLLUP = "functions-rollup" + IMP_V1_USAGE = "imp-v1-usage" + IP_MESSAGING_ADDONS = "ip-messaging-addons" + IVR = "ivr" + IVR_CONVERSATIONAL = "ivr-conversational" + IVR_DTMF = "ivr-dtmf" + IVR_VIRTUALAGENT = "ivr-virtualagent" + LIVE = "live" + LIVE_MEDIA_RECORDING_MINUTES = "live-media-recording-minutes" + LONGCODE_MPS = "longcode-mps" + MARKETPLACE_ANALYTICS_ADDONS = "marketplace-analytics-addons" + MARKETPLACE_ISV_ADDONS = "marketplace-isv-addons" + MARKETPLACE_MESSAGING_ADDONS = "marketplace-messaging-addons" + MARKETPLACE_PHONENUMBERS_ADDONS = "marketplace-phonenumbers-addons" + MARKETPLACE_RECORDING_ADDONS = "marketplace-recording-addons" + MARKETPLACE_VIRTUALAGENT_ADDONS = "marketplace-virtualagent-addons" + MARKETPLAY_PAY_ADDONS_SHUTTLE_PAY_CONNECTOR_1 = ( + "marketplay-pay-addons-shuttle-pay-connector-1" + ) + MARKETPLAY_PAY_ADDONS_STRIPE_PAY_CONNECTOR = ( + "marketplay-pay-addons-stripe-pay-connector" + ) + MMS_INBOUND_LONGCODE_CANADA = "mms-inbound-longcode-canada" + MMS_INBOUND_LONGCODE_UNITEDSTATES = "mms-inbound-longcode-unitedstates" + MMS_OUTBOUND_LONGCODE_CANADA = "mms-outbound-longcode-canada" + MMS_OUTBOUND_LONGCODE_UNITEDSTATES = "mms-outbound-longcode-unitedstates" + MMS_OUTBOUND_TOLL_FREE = "mms-outbound-toll-free" + NOTIFY_CHATAPPSANDOTHERCHANNELS = "notify-chatappsandotherchannels" + NOTIFY_NOTIFYSERVICES = "notify-notifyservices" + NOTIFY_PUSHNOTIFICATIONS = "notify-pushnotifications" + PAYMENT_GATEWAY_CONNECTORS = "payment-gateway-connectors" + PAYMENT_SOLUTIONS = "payment-solutions" + PCHAT_BUCKET_ADJUSTMENT = "pchat-bucket-adjustment" + PHONENUMBERS_NUMBERS = "phonenumbers-numbers" + PROG_VOICE_CLIENT_ANDROID = "prog-voice-client-android" + PROG_VOICE_CLIENT_ANDROID_INBOUND = "prog-voice-client-android-inbound" + PROG_VOICE_CLIENT_ANDROID_OUTBOUND = "prog-voice-client-android-outbound" + PROG_VOICE_CLIENT_IOS = "prog-voice-client-ios" + PROG_VOICE_CLIENT_IOS_INBOUND = "prog-voice-client-ios-inbound" + PROG_VOICE_CLIENT_IOS_OUTBOUND = "prog-voice-client-ios-outbound" + PROG_VOICE_CLIENT_SDK = "prog-voice-client-sdk" + PROG_VOICE_CLIENT_WEB = "prog-voice-client-web" + PROG_VOICE_CLIENT_WEB_INBOUND = "prog-voice-client-web-inbound" + PROG_VOICE_CLIENT_WEB_OUTBOUND = "prog-voice-client-web-outbound" + PROGRAMMABLEVOICECONNECTIVITY_MEDIA_STREAMS = ( + "programmablevoiceconnectivity-media-streams" + ) + PSTNCONNECTIVITY_BYOC = "pstnconnectivity-byoc" + PSTNCONNECTIVITY_EMERGENCY = "pstnconnectivity-emergency" + PSTNCONNECTIVITY_MINUTES = "pstnconnectivity-minutes" + PSTNCONNECTIVITY_MINUTES_1 = "pstnconnectivity-minutes-1" + PSTNCONNECTIVITY_MINUTESINBOUNDLOCAL = "pstnconnectivity-minutesinboundlocal" + PSTNCONNECTIVITY_MINUTESINBOUNDMOBILE = "pstnconnectivity-minutesinboundmobile" + PSTNCONNECTIVITY_MINUTESINBOUNDTOLLFREE = ( + "pstnconnectivity-minutesinboundtollfree" + ) + PSTNCONNECTIVITY_MINUTESINBOUNDTOLLFREELOCAL = ( + "pstnconnectivity-minutesinboundtollfreelocal" + ) + PSTNCONNECTIVITY_MINUTESINBOUNDTOLLFREEMOBILE = ( + "pstnconnectivity-minutesinboundtollfreemobile" + ) + PV_ROOM_HOURS = "pv-room-hours" + PV_ROOM_SIMULTANEOUS_PARTICIPANT_CONNECTIONS = ( + "pv-room-simultaneous-participant-connections" + ) + PVIDEO_ROOM_HOURS_AU1 = "pvideo-room-hours-au1" + PVIDEO_ROOM_HOURS_BR1 = "pvideo-room-hours-br1" + PVIDEO_ROOM_HOURS_IE1 = "pvideo-room-hours-ie1" + PVIDEO_ROOM_HOURS_JP1 = "pvideo-room-hours-jp1" + PVIDEO_ROOM_HOURS_SG1 = "pvideo-room-hours-sg1" + PVIDEO_ROOM_HOURS_US1 = "pvideo-room-hours-us1" + PVIDEO_ROOM_HOURS_US2 = "pvideo-room-hours-us2" + RECORDINGS_ENCRYPTED = "recordings-encrypted" + SHORT_CODE_SETUP_FEES = "short-code-setup-fees" + SHORTCODES_MESSAGES_INBOUND = "shortcodes-messages-inbound" + SHORTCODES_MESSAGES_OUTBOUND = "shortcodes-messages-outbound" + SMS_MESSAGES_REGISTRATIONFEES = "sms-messages-registrationfees" + SMS_MMS_PENALTY_FEES = "sms-mms-penalty-fees" + SMS_MMS_PENALTY_FEES_1 = "sms-mms-penalty-fees-1" + SMS_PUMPING_PROTECTION_NON_USCA = "sms-pumping-protection-non-usca" + SMS_PUMPING_PROTECTION_USCA = "sms-pumping-protection-usca" + STUDIO = "studio" + STUDIO_MONTHLY_FEES = "studio-monthly-fees" + SUPERSIM = "supersim" + TASK_ROUTER = "task-router" + TASK_ROUTER_WORKERS = "task-router-workers" + TEST_QUOTA_BUCKETS = "test-quota-buckets" + TEST_UC_SCRIPT_1 = "test-uc-script-1" + TEST_UC_SCRIPT_DEMO_2 = "test-uc-script-demo-2" + TEXT_TO_SPEECH = "text-to-speech" + TME = "tme" + TTS_BASIC = "tts-basic" + TWILIO_EDITIONS = "twilio-editions" + TWILIO_INTERCONNECT_CALIFORNIA = "twilio-interconnect-california" + TWILIO_INTERCONNECT_CALIFORNIA_MONTHLY = ( + "twilio-interconnect-california-monthly" + ) + TWILIO_INTERCONNECT_CALIFORNIA_SETUP = "twilio-interconnect-california-setup" + TWILIO_INTERCONNECT_FRANKFURT = "twilio-interconnect-frankfurt" + TWILIO_INTERCONNECT_FRANKFURT_MO = "twilio-interconnect-frankfurt-mo" + TWILIO_INTERCONNECT_FRANKFURT_SETUP = "twilio-interconnect-frankfurt-setup" + TWILIO_INTERCONNECT_LONDON = "twilio-interconnect-london" + TWILIO_INTERCONNECT_LONDON_MO = "twilio-interconnect-london-mo" + TWILIO_INTERCONNECT_LONDON_SETUP = "twilio-interconnect-london-setup" + TWILIO_INTERCONNECT_SAO_PAULO = "twilio-interconnect-sao-paulo" + TWILIO_INTERCONNECT_SAO_PAULO_MONTHLY = "twilio-interconnect-sao-paulo-monthly" + TWILIO_INTERCONNECT_SAO_PAULO_SETUP = "twilio-interconnect-sao-paulo-setup" + TWILIO_INTERCONNECT_SINGAPORE = "twilio-interconnect-singapore" + TWILIO_INTERCONNECT_SINGAPORE_MO = "twilio-interconnect-singapore-mo" + TWILIO_INTERCONNECT_SINGAPORE_SETUP = "twilio-interconnect-singapore-setup" + TWILIO_INTERCONNECT_SYDNEY = "twilio-interconnect-sydney" + TWILIO_INTERCONNECT_SYDNEY_MO = "twilio-interconnect-sydney-mo" + TWILIO_INTERCONNECT_SYDNEY_SETUP = "twilio-interconnect-sydney-setup" + TWILIO_INTERCONNECT_TOKYO = "twilio-interconnect-tokyo" + TWILIO_INTERCONNECT_TOKYO_MO = "twilio-interconnect-tokyo-mo" + TWILIO_INTERCONNECT_TOKYO_SETUP = "twilio-interconnect-tokyo-setup" + TWILIO_INTERCONNECT_VA = "twilio-interconnect-va" + TWILIO_INTERCONNECT_VA_MO = "twilio-interconnect-va-mo" + TWILIO_INTERCONNECT_VA_SETUP = "twilio-interconnect-va-setup" + TWIML_VERBS = "twiml-verbs" + TWIML_VERBS_SAY = "twiml-verbs-say" + USAGE_PROGRAMMABLE_MESSAGING_ENGAGEMENT_SUITE = ( + "usage-programmable-messaging-engagement-suite" + ) + USAGE_PROGRAMMABLE_MESSAGING_FEES_SERVICES = ( + "usage-programmable-messaging-fees-services" + ) + VERIFY_OUTBOUND_EMAIL = "verify-outbound-email" + VERIFY_PACKAGED_PLANS = "verify-packaged-plans" + VERIFY_SILENT_NETWORK_AUTH = "verify-silent-network-auth" + VERIFY_VOICE_AND_SMS = "verify-voice-and-sms" + VOICE_INSIGHTS_CLIENT_INSIGHTS_MONTHY_COMMIT = ( + "voice-insights-client-insights-monthy-commit" + ) + WIRELESS_DATA_PAYG_ASIA_AFG = "wireless-data-payg-asia-afg" + WIRELESS_MULTI_IMSI_SIM_COMMANDS = "wireless-multi-imsi-sim-commands" + WIRELESS_MULTI_IMSI_SIM_COMMANDS_USA = "wireless-multi-imsi-sim-commands-usa" + WIRELESS_MULTI_IMSI_SIM_DATA = "wireless-multi-imsi-sim-data" + WIRELESS_MULTI_IMSI_SIM_DATA_EU28 = "wireless-multi-imsi-sim-data-eu28" + WIRELESS_MULTI_IMSI_SIM_DATA_USA = "wireless-multi-imsi-sim-data-usa" + WIRELESS_MULTI_IMSI_SIM_MONTHLY_FEES = "wireless-multi-imsi-sim-monthly-fees" + WIRELESS_MULTI_IMSI_SIM_USAGE = "wireless-multi-imsi-sim-usage" + WIRELESS_SUPER_SIM_DATA_NORTH_AMERICA = "wireless-super-sim-data-north-america" + WIRELESS_SUPER_SIM_USAGE = "wireless-super-sim-usage" """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that accrued the usage. @@ -401,6 +893,7 @@ def __repr__(self) -> str: class TodayPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> TodayInstance: """ Build an instance of TodayInstance @@ -421,6 +914,7 @@ def __repr__(self) -> str: class TodayList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the TodayList @@ -623,14 +1117,20 @@ def page( "Category": category, "StartDate": serialize.iso8601_date(start_date), "EndDate": serialize.iso8601_date(end_date), - "IncludeSubaccounts": include_subaccounts, + "IncludeSubaccounts": serialize.boolean_to_string(include_subaccounts), "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 TodayPage(self._version, response, self._solution) async def page_async( @@ -662,15 +1162,19 @@ async def page_async( "Category": category, "StartDate": serialize.iso8601_date(start_date), "EndDate": serialize.iso8601_date(end_date), - "IncludeSubaccounts": include_subaccounts, + "IncludeSubaccounts": serialize.boolean_to_string(include_subaccounts), "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 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 88c1082b7b..ad9e5a36d8 100644 --- a/twilio/rest/api/v2010/account/usage/record/yearly.py +++ b/twilio/rest/api/v2010/account/usage/record/yearly.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import date from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import deserialize, serialize, values @@ -24,34 +23,103 @@ class YearlyInstance(InstanceResource): + class Category(object): + A2P_10DLC_REGISTRATIONFEES_BRANDREGISTRATION = ( + "a2p-10dlc-registrationfees-brandregistration" + ) + A2P_10DLC_REGISTRATIONFEES_BV = "a2p-10dlc-registrationfees-bv" + A2P_10DLC_REGISTRATIONFEES_CAMPAIGNCHARGES = ( + "a2p-10dlc-registrationfees-campaigncharges" + ) + A2P_10DLC_REGISTRATIONFEES_CAMPAIGNREGISTRATION = ( + "a2p-10dlc-registrationfees-campaignregistration" + ) + A2P_10DLC_REGISTRATIONFEES_CAMPAIGNVETTING = ( + "a2p-10dlc-registrationfees-campaignvetting" + ) + A2P_10DLC_REGISTRATIONFEES_MONTHLY = "a2p-10dlc-registrationfees-monthly" + A2P_10DLC_REGISTRATIONFEES_ONETIME = "a2p-10dlc-registrationfees-onetime" A2P_REGISTRATION_FEES = "a2p-registration-fees" + ACCOUNT_SECURITY = "account-security" AGENT_CONFERENCE = "agent-conference" + AGENT_COPILOT = "agent-copilot" + AGENT_COPILOT_MESSAGES = "agent-copilot-messages" + AGENT_COPILOT_PARTICIPANT_MINUTES = "agent-copilot-participant-minutes" + AI_ASSISTANTS = "ai-assistants" + AI_ASSISTANTS_VOICE = "ai-assistants-voice" AMAZON_POLLY = "amazon-polly" ANSWERING_MACHINE_DETECTION = "answering-machine-detection" + ASSETS = "assets" + AUDIENCE_MINUTES = "audience-minutes" + AUDIENCE_MINUTES_AUDIO = "audience-minutes-audio" AUTHY_AUTHENTICATIONS = "authy-authentications" AUTHY_CALLS_OUTBOUND = "authy-calls-outbound" + AUTHY_EMAIL_AUTHENTICATIONS = "authy-email-authentications" AUTHY_MONTHLY_FEES = "authy-monthly-fees" + AUTHY_OUTBOUND_EMAIL = "authy-outbound-email" AUTHY_PHONE_INTELLIGENCE = "authy-phone-intelligence" AUTHY_PHONE_VERIFICATIONS = "authy-phone-verifications" AUTHY_SMS_OUTBOUND = "authy-sms-outbound" + AUTHY_VERIFY_EMAIL_VERIFICATIONS = "authy-verify-email-verifications" + AUTHY_VERIFY_OUTBOUND_EMAIL = "authy-verify-outbound-email" + AUTOPILOT = "autopilot" + AUTOPILOT_HOME_ASSISTANTS = "autopilot-home-assistants" + AUTOPILOT_MESSAGING = "autopilot-messaging" + AUTOPILOT_OTHER = "autopilot-other" + AUTOPILOT_VOICE = "autopilot-voice" + BASIC_PEER_TO_PEER_ROOMS_PARTICIPANT_MINUTES = ( + "basic-peer-to-peer-rooms-participant-minutes" + ) + BRANDED_CALLING = "branded-calling" + BUNDLE_SMS_BUCKET = "bundle-sms-bucket" + BUNDLE_SUBSCRIPTION_FEES = "bundle-subscription-fees" + CALL_FORWARDING_LOOKUPS = "call-forwarding-lookups" CALL_PROGESS_EVENTS = "call-progess-events" CALLERIDLOOKUPS = "calleridlookups" CALLS = "calls" CALLS_CLIENT = "calls-client" + CALLS_EMERGENCY = "calls-emergency" CALLS_GLOBALCONFERENCE = "calls-globalconference" CALLS_INBOUND = "calls-inbound" CALLS_INBOUND_LOCAL = "calls-inbound-local" CALLS_INBOUND_MOBILE = "calls-inbound-mobile" CALLS_INBOUND_TOLLFREE = "calls-inbound-tollfree" + CALLS_INBOUND_TOLLFREE_LOCAL = "calls-inbound-tollfree-local" + CALLS_INBOUND_TOLLFREE_MOBILE = "calls-inbound-tollfree-mobile" + CALLS_MEDIA_STREAM_MINUTES = "calls-media-stream-minutes" CALLS_OUTBOUND = "calls-outbound" CALLS_PAY_VERB_TRANSACTIONS = "calls-pay-verb-transactions" CALLS_RECORDINGS = "calls-recordings" CALLS_SIP = "calls-sip" CALLS_SIP_INBOUND = "calls-sip-inbound" CALLS_SIP_OUTBOUND = "calls-sip-outbound" + CALLS_TEXT_TO_SPEECH = "calls-text-to-speech" CALLS_TRANSFERS = "calls-transfers" CARRIER_LOOKUPS = "carrier-lookups" + CATEGORY = "category" + CHANNELS = "channels" + CHANNELS_MESSAGING = "channels-messaging" + CHANNELS_MESSAGING_INBOUND = "channels-messaging-inbound" + CHANNELS_MESSAGING_OUTBOUND = "channels-messaging-outbound" + CHANNELS_WHATSAPP = "channels-whatsapp" + CHANNELS_WHATSAPP_CONVERSATION_AUTHENTICATION = ( + "channels-whatsapp-conversation-authentication" + ) + CHANNELS_WHATSAPP_CONVERSATION_FREE = "channels-whatsapp-conversation-free" + CHANNELS_WHATSAPP_CONVERSATION_MARKETING = ( + "channels-whatsapp-conversation-marketing" + ) + CHANNELS_WHATSAPP_CONVERSATION_SERVICE = ( + "channels-whatsapp-conversation-service" + ) + CHANNELS_WHATSAPP_CONVERSATION_UTILITY = ( + "channels-whatsapp-conversation-utility" + ) + CHANNELS_WHATSAPP_INBOUND = "channels-whatsapp-inbound" + CHANNELS_WHATSAPP_OUTBOUND = "channels-whatsapp-outbound" + CHAT_VIRTUAL_AGENT = "chat-virtual-agent" + CONVERSATION_RELAY = "conversation-relay" CONVERSATIONS = "conversations" CONVERSATIONS_API_REQUESTS = "conversations-api-requests" CONVERSATIONS_CONVERSATION_EVENTS = "conversations-conversation-events" @@ -60,8 +128,40 @@ class Category(object): CONVERSATIONS_PARTICIPANT_EVENTS = "conversations-participant-events" CONVERSATIONS_PARTICIPANTS = "conversations-participants" CPS = "cps" + CREDIT_TRANSFER = "credit-transfer" + EMAIL = "email" + EMERGING_TECH = "emerging-tech" + ENGAGEMENT_SUITE_PACKAGED_PLANS = "engagement-suite-packaged-plans" + ENHANCED_LINE_TYPE_LOOKUPS = "enhanced-line-type-lookups" + ENTERPRISE = "enterprise" + EVENTS = "events" + EXPERIMENT_FRANCE_SMS = "experiment-france-sms" + EXPERIMENT_INDIA_SMS = "experiment-india-sms" + EXPERIMENT_UK_SMS = "experiment-uk-sms" + FAILED_MESSAGE_PROCESSING_FEE = "failed-message-processing-fee" + FLEX = "flex" + FLEX_ACTIVE_USER_HOURS = "flex-active-user-hours" + FLEX_CONCURRENT_USERS = "flex-concurrent-users" + FLEX_CONVERSATIONAL_INSIGHTS = "flex-conversational-insights" + FLEX_CONVERSATIONAL_INSIGHTS_MESSAGES = "flex-conversational-insights-messages" + FLEX_CONVERSATIONAL_INSIGHTS_VOICE_MINUTES = ( + "flex-conversational-insights-voice-minutes" + ) + FLEX_EMAIL_USAGE = "flex-email-usage" + FLEX_MESSAGING_USAGE = "flex-messaging-usage" + FLEX_PARTNER_SPINSCI = "flex-partner-spinsci" + FLEX_PARTNER_XCELERATE = "flex-partner-xcelerate" + FLEX_RESELLER_ECOSYSTEM = "flex-reseller-ecosystem" + FLEX_UNIQUE_USER = "flex-unique-user" FLEX_USAGE = "flex-usage" + FLEX_USERS = "flex-users" + FLEX_VOICE_MINUTE = "flex-voice-minute" + FLEX_YTICA = "flex-ytica" FRAUD_LOOKUPS = "fraud-lookups" + FRONTLINE = "frontline" + FRONTLINE_USERS = "frontline-users" + FUNCTIONS = "functions" + GENERIC_PAY_TRANSACTIONS = "generic-pay-transactions" GROUP_ROOMS = "group-rooms" GROUP_ROOMS_DATA_TRACK = "group-rooms-data-track" GROUP_ROOMS_ENCRYPTED_MEDIA_RECORDED = "group-rooms-encrypted-media-recorded" @@ -71,7 +171,17 @@ class Category(object): GROUP_ROOMS_MEDIA_STORED = "group-rooms-media-stored" GROUP_ROOMS_PARTICIPANT_MINUTES = "group-rooms-participant-minutes" GROUP_ROOMS_RECORDED_MINUTES = "group-rooms-recorded-minutes" - IMP_V1_USAGE = "imp-v1-usage" + IP_MESSAGING = "ip-messaging" + IP_MESSAGING_COMMANDS = "ip-messaging-commands" + IP_MESSAGING_DATA_STORAGE = "ip-messaging-data-storage" + IP_MESSAGING_DATA_TRANSFER = "ip-messaging-data-transfer" + IP_MESSAGING_ENDPOINT_CONNECTIVITY = "ip-messaging-endpoint-connectivity" + IVR_VIRTUAL_AGENT_CUSTOM_VOICES = "ivr-virtual-agent-custom-voices" + IVR_VIRTUAL_AGENT_GENAI = "ivr-virtual-agent-genai" + LINE_STATUS_LOOKUPS = "line-status-lookups" + LIVE_ACTIVITY_LOOKUPS = "live-activity-lookups" + LOOKUP_BUCKET_ADJUSTMENT = "lookup-bucket-adjustment" + LOOKUP_IDENTITY_MATCH = "lookup-identity-match" LOOKUPS = "lookups" MARKETPLACE = "marketplace" MARKETPLACE_ALGORITHMIA_NAMED_ENTITY_RECOGNITION = ( @@ -82,6 +192,13 @@ class Category(object): MARKETPLACE_CAPIO_SPEECH_TO_TEXT = "marketplace-capio-speech-to-text" MARKETPLACE_CONVRIZA_ABABA = "marketplace-convriza-ababa" MARKETPLACE_DEEPGRAM_PHRASE_DETECTOR = "marketplace-deepgram-phrase-detector" + MARKETPLACE_DEEPGRAM_TRANSCRIPTION = "marketplace-deepgram-transcription" + MARKETPLACE_DEEPGRAM_TRANSCRIPTION_BASE = ( + "marketplace-deepgram-transcription-base" + ) + MARKETPLACE_DEEPGRAM_TRANSSCRIPTION_ENHANCED = ( + "marketplace-deepgram-transscription-enhanced" + ) MARKETPLACE_DIGITAL_SEGMENT_BUSINESS_INFO = ( "marketplace-digital-segment-business-info" ) @@ -107,6 +224,9 @@ class Category(object): "marketplace-keen-io-contact-center-analytics" ) MARKETPLACE_MARCHEX_CLEANCALL = "marketplace-marchex-cleancall" + MARKETPLACE_MARCHEX_RECORDING_ANALYSIS = ( + "marketplace-marchex-recording-analysis" + ) MARKETPLACE_MARCHEX_SENTIMENT_ANALYSIS_FOR_SMS = ( "marketplace-marchex-sentiment-analysis-for-sms" ) @@ -123,14 +243,42 @@ class Category(object): "marketplace-nextcaller-advanced-caller-identification" ) MARKETPLACE_NOMOROBO_SPAM_SCORE = "marketplace-nomorobo-spam-score" + MARKETPLACE_PAY_ADDONS = "marketplace-pay-addons" + MARKETPLACE_PAY_ADDONS_BASECOMMERCE_PAY_CONNECTOR = ( + "marketplace-pay-addons-basecommerce-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_BRAINTREE_PAY_CONNECTOR = ( + "marketplace-pay-addons-braintree-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_CARDCONNECT_PAY_CONNECTOR = ( + "marketplace-pay-addons-cardconnect-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_CHASE_PAY_CONNECTOR = ( + "marketplace-pay-addons-chase-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_SHUTTLE_PAY_CONNECTOR = ( + "marketplace-pay-addons-shuttle-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_STRIPE_PAY_CONNECTOR = ( + "marketplace-pay-addons-stripe-pay-connector" + ) MARKETPLACE_PAYFONE_TCPA_COMPLIANCE = "marketplace-payfone-tcpa-compliance" + MARKETPLACE_POLY_AI_CONNECTOR = "marketplace-poly-ai-connector" + MARKETPLACE_REALPHONEVALIDATION = "marketplace-realphonevalidation" MARKETPLACE_REMEETING_AUTOMATIC_SPEECH_RECOGNITION = ( "marketplace-remeeting-automatic-speech-recognition" ) + MARKETPLACE_SPOKE_PHONE_LICENSE_PRO = "marketplace-spoke-phone-license-pro" + MARKETPLACE_SPOKE_PHONE_LICENSE_STANDARD = ( + "marketplace-spoke-phone-license-standard" + ) MARKETPLACE_TCPA_DEFENSE_SOLUTIONS_BLACKLIST_FEED = ( "marketplace-tcpa-defense-solutions-blacklist-feed" ) MARKETPLACE_TELO_OPENCNAM = "marketplace-telo-opencnam" + MARKETPLACE_TRESTLE_SOLUTIONS_CALLER_IDENTIFICATION = ( + "marketplace-trestle-solutions-caller-identification" + ) MARKETPLACE_TRUECNAM_TRUE_SPAM = "marketplace-truecnam-true-spam" MARKETPLACE_TWILIO_CALLER_NAME_LOOKUP_US = ( "marketplace-twilio-caller-name-lookup-us" @@ -143,6 +291,9 @@ class Category(object): MARKETPLACE_VOICEBASE_TRANSCRIPTION_CUSTOM_VOCABULARY = ( "marketplace-voicebase-transcription-custom-vocabulary" ) + MARKETPLACE_WEB_PURIFY_PROFANITY_FILTER = ( + "marketplace-web-purify-profanity-filter" + ) MARKETPLACE_WHITEPAGES_PRO_CALLER_IDENTIFICATION = ( "marketplace-whitepages-pro-caller-identification" ) @@ -157,15 +308,23 @@ class Category(object): MARKETPLACE_YTICA_CONTACT_CENTER_REPORTING_ANALYTICS = ( "marketplace-ytica-contact-center-reporting-analytics" ) + MARKETPLAY_PAY_ADDONS_SHUTTLE_PAY_CONNECTOR = ( + "marketplay-pay-addons-shuttle-pay-connector" + ) + MEDIA_COMPOSER_MINUTES = "media-composer-minutes" MEDIASTORAGE = "mediastorage" + MIN_SPEND_ADJUSTMENTS = "min-spend-adjustments" MMS = "mms" MMS_INBOUND = "mms-inbound" MMS_INBOUND_LONGCODE = "mms-inbound-longcode" MMS_INBOUND_SHORTCODE = "mms-inbound-shortcode" + MMS_INBOUND_TOLL_FREE = "mms-inbound-toll-free" MMS_MESSAGES_CARRIERFEES = "mms-messages-carrierfees" MMS_OUTBOUND = "mms-outbound" MMS_OUTBOUND_LONGCODE = "mms-outbound-longcode" MMS_OUTBOUND_SHORTCODE = "mms-outbound-shortcode" + MMS_OUTBOUND_TOLLFREE = "mms-outbound-tollfree" + MONITOR = "monitor" MONITOR_READS = "monitor-reads" MONITOR_STORAGE = "monitor-storage" MONITOR_WRITES = "monitor-writes" @@ -174,6 +333,12 @@ class Category(object): NOTIFY_CHANNELS = "notify-channels" NUMBER_FORMAT_LOOKUPS = "number-format-lookups" PCHAT = "pchat" + PCHAT_ACTIONS = "pchat-actions" + PCHAT_APS = "pchat-aps" + PCHAT_CONV_MED_STORAGE = "pchat-conv-med-storage" + PCHAT_MESSAGES = "pchat-messages" + PCHAT_NOTIFICATIONS = "pchat-notifications" + PCHAT_READS = "pchat-reads" PCHAT_USERS = "pchat-users" PEER_TO_PEER_ROOMS_PARTICIPANT_MINUTES = ( "peer-to-peer-rooms-participant-minutes" @@ -183,18 +348,41 @@ class Category(object): PFAX_MINUTES_INBOUND = "pfax-minutes-inbound" PFAX_MINUTES_OUTBOUND = "pfax-minutes-outbound" PFAX_PAGES = "pfax-pages" + PHONE_QUALITY_SCORE_LOOKUPS = "phone-quality-score-lookups" PHONENUMBERS = "phonenumbers" PHONENUMBERS_CPS = "phonenumbers-cps" PHONENUMBERS_EMERGENCY = "phonenumbers-emergency" PHONENUMBERS_LOCAL = "phonenumbers-local" PHONENUMBERS_MOBILE = "phonenumbers-mobile" + PHONENUMBERS_PORTING = "phonenumbers-porting" PHONENUMBERS_SETUPS = "phonenumbers-setups" PHONENUMBERS_TOLLFREE = "phonenumbers-tollfree" PREMIUMSUPPORT = "premiumsupport" + PREMIUMSUPPORT_PERCENTAGE_SPEND = "premiumsupport-percentage-spend" + PROGRAMMABLEVOICE_PLATFORM = "programmablevoice-platform" + PROGRAMMABLEVOICECONN_CLIENTSDK = "programmablevoiceconn-clientsdk" + PROGRAMMABLEVOICECONN_CLIENTSDK_INBOUND = ( + "programmablevoiceconn-clientsdk-inbound" + ) + PROGRAMMABLEVOICECONN_CLIENTSDK_OUTBOUND = ( + "programmablevoiceconn-clientsdk-outbound" + ) + PROGRAMMABLEVOICECONN_ONNET = "programmablevoiceconn-onnet" + PROGRAMMABLEVOICECONN_ONNET_INBOUND = "programmablevoiceconn-onnet-inbound" + PROGRAMMABLEVOICECONN_ONNET_OUTBOUND = "programmablevoiceconn-onnet-outbound" + PROGRAMMABLEVOICECONN_SIP = "programmablevoiceconn-sip" + PROGRAMMABLEVOICECONN_SIP_INBOUND = "programmablevoiceconn-sip-inbound" + PROGRAMMABLEVOICECONN_SIP_OUTBOUND = "programmablevoiceconn-sip-outbound" + PROGRAMMABLEVOICECONNECTIVITY = "programmablevoiceconnectivity" PROXY = "proxy" PROXY_ACTIVE_SESSIONS = "proxy-active-sessions" + PROXY_BUCKET_ADJUSTMENT = "proxy-bucket-adjustment" + PROXY_LICENSES = "proxy-licenses" PSTNCONNECTIVITY = "pstnconnectivity" + PSTNCONNECTIVITY_INBOUND = "pstnconnectivity-inbound" + PSTNCONNECTIVITY_OUTBOUND = "pstnconnectivity-outbound" PV = "pv" + PV_BASIC_ROOMS = "pv-basic-rooms" PV_COMPOSITION_MEDIA_DOWNLOADED = "pv-composition-media-downloaded" PV_COMPOSITION_MEDIA_ENCRYPTED = "pv-composition-media-encrypted" PV_COMPOSITION_MEDIA_STORED = "pv-composition-media-stored" @@ -210,18 +398,20 @@ class Category(object): PV_ROOM_PARTICIPANTS_US2 = "pv-room-participants-us2" PV_ROOMS = "pv-rooms" PV_SIP_ENDPOINT_REGISTRATIONS = "pv-sip-endpoint-registrations" + RCS_MESSAGES = "rcs-messages" + REASSIGNED_NUMBER = "reassigned-number" RECORDINGS = "recordings" RECORDINGSTORAGE = "recordingstorage" - ROOMS_GROUP_BANDWIDTH = "rooms-group-bandwidth" - ROOMS_GROUP_MINUTES = "rooms-group-minutes" - ROOMS_PEER_TO_PEER_MINUTES = "rooms-peer-to-peer-minutes" SHORTCODES = "shortcodes" SHORTCODES_CUSTOMEROWNED = "shortcodes-customerowned" SHORTCODES_MMS_ENABLEMENT = "shortcodes-mms-enablement" SHORTCODES_MPS = "shortcodes-mps" SHORTCODES_RANDOM = "shortcodes-random" + SHORTCODES_SETUP_FEES = "shortcodes-setup-fees" SHORTCODES_UK = "shortcodes-uk" SHORTCODES_VANITY = "shortcodes-vanity" + SIM_SWAP_LOOKUPS = "sim-swap-lookups" + SIP_SECURE_MEDIA = "sip-secure-media" SMALL_GROUP_ROOMS = "small-group-rooms" SMALL_GROUP_ROOMS_DATA_TRACK = "small-group-rooms-data-track" SMALL_GROUP_ROOMS_PARTICIPANT_MINUTES = "small-group-rooms-participant-minutes" @@ -229,13 +419,30 @@ class Category(object): SMS_INBOUND = "sms-inbound" SMS_INBOUND_LONGCODE = "sms-inbound-longcode" SMS_INBOUND_SHORTCODE = "sms-inbound-shortcode" + SMS_INBOUND_TOLLFREE = "sms-inbound-tollfree" SMS_MESSAGES_CARRIERFEES = "sms-messages-carrierfees" SMS_MESSAGES_FEATURES = "sms-messages-features" + SMS_MESSAGES_FEATURES_ENGAGEMENT_SUITE = ( + "sms-messages-features-engagement-suite" + ) + SMS_MESSAGES_FEATURES_MESSAGE_REDACTION = ( + "sms-messages-features-message-redaction" + ) SMS_MESSAGES_FEATURES_SENDERID = "sms-messages-features-senderid" + SMS_MPS = "sms-mps" + SMS_MPS_SHORTCODE = "sms-mps-shortcode" + SMS_MPS_TOLLFREE = "sms-mps-tollfree" + SMS_MPS_TOLLFREE_SETUP = "sms-mps-tollfree-setup" + SMS_NATIONAL_REGULATORY_PROTECTION = "sms-national-regulatory-protection" SMS_OUTBOUND = "sms-outbound" SMS_OUTBOUND_CONTENT_INSPECTION = "sms-outbound-content-inspection" SMS_OUTBOUND_LONGCODE = "sms-outbound-longcode" SMS_OUTBOUND_SHORTCODE = "sms-outbound-shortcode" + SMS_OUTBOUND_TOLLFREE = "sms-outbound-tollfree" + SMS_PUMPING_PROTECTION = "sms-pumping-protection" + SMS_PUMPING_RISK = "sms-pumping-risk" + SMSMESSAGES_BUCKET_ADJUSTMENTS = "smsmessages-bucket-adjustments" + SMSMESSAGES_OUTBOUND_DOMESTIC = "smsmessages-outbound-domestic" SPEECH_RECOGNITION = "speech-recognition" STUDIO_ENGAGEMENTS = "studio-engagements" SYNC = "sync" @@ -254,6 +461,7 @@ class Category(object): TRUNKING_RECORDINGS = "trunking-recordings" TRUNKING_SECURE = "trunking-secure" TRUNKING_TERMINATION = "trunking-termination" + TTS_GOOGLE = "tts-google" TURNMEGABYTES = "turnmegabytes" TURNMEGABYTES_AUSTRALIA = "turnmegabytes-australia" TURNMEGABYTES_BRASIL = "turnmegabytes-brasil" @@ -264,13 +472,27 @@ class Category(object): TURNMEGABYTES_SINGAPORE = "turnmegabytes-singapore" TURNMEGABYTES_USEAST = "turnmegabytes-useast" TURNMEGABYTES_USWEST = "turnmegabytes-uswest" + TWILIO_FOR_SALESFORCE = "twilio-for-salesforce" + TWILIO_FOR_SALESFORCE_LICENSES = "twilio-for-salesforce-licenses" TWILIO_INTERCONNECT = "twilio-interconnect" + TWIML = "twiml" + USAGE_FLEX_VIDEO = "usage-flex-video" + USAGE_FUNCTIONS = "usage-functions" + USAGE_RCS_BASIC_MESSAGES_OUTBOUND = "usage-rcs-basic-messages-outbound" + USAGE_RCS_MESSAGES = "usage-rcs-messages" + USAGE_RCS_MESSAGES_INBOUND = "usage-rcs-messages-inbound" + USAGE_RCS_MESSAGING_CARRIER_FEES = "usage-rcs-messaging-carrier-fees" + USAGE_RCS_SINGLE_MESSAGES_OUTBOUND = "usage-rcs-single-messages-outbound" + VERIFY_PACKAGE_PLANS = "verify-package-plans" VERIFY_PUSH = "verify-push" + VERIFY_SNA = "verify-sna" VERIFY_TOTP = "verify-totp" + VERIFY_VOICE_SMS = "verify-voice-sms" VERIFY_WHATSAPP_CONVERSATIONS_BUSINESS_INITIATED = ( "verify-whatsapp-conversations-business-initiated" ) VIDEO_RECORDINGS = "video-recordings" + VIDEO_ROOMS_TURN_MEGABYTES = "video-rooms-turn-megabytes" VIRTUAL_AGENT = "virtual-agent" VOICE_INSIGHTS = "voice-insights" VOICE_INSIGHTS_CLIENT_INSIGHTS_ON_DEMAND_MINUTE = ( @@ -285,12 +507,104 @@ class Category(object): VOICE_INSIGHTS_SIP_TRUNKING_INSIGHTS_ON_DEMAND_MINUTE = ( "voice-insights-sip-trunking-insights-on-demand-minute" ) + VOICE_INTELLIGENCE = "voice-intelligence" + VOICE_INTELLIGENCE_EIP_OPERATORS = "voice-intelligence-eip-operators" + VOICE_INTELLIGENCE_OPERATORS = "voice-intelligence-operators" + VOICE_INTELLIGENCE_TRANSCRIPTION = "voice-intelligence-transcription" + WDS = "wds" WIRELESS = "wireless" + WIRELESS_DATA = "wireless-data" + WIRELESS_DATA_PAYG = "wireless-data-payg" + WIRELESS_DATA_PAYG_AFRICA = "wireless-data-payg-africa" + WIRELESS_DATA_PAYG_ASIA = "wireless-data-payg-asia" + WIRELESS_DATA_PAYG_CENTRALANDSOUTHAMERICA = ( + "wireless-data-payg-centralandsouthamerica" + ) + WIRELESS_DATA_PAYG_EUROPE = "wireless-data-payg-europe" + WIRELESS_DATA_PAYG_NORTHAMERICA = "wireless-data-payg-northamerica" + WIRELESS_DATA_PAYG_OCEANIA = "wireless-data-payg-oceania" + WIRELESS_DATA_QUOTA1 = "wireless-data-quota1" + WIRELESS_DATA_QUOTA1_AFRICA = "wireless-data-quota1-africa" + WIRELESS_DATA_QUOTA1_ASIA = "wireless-data-quota1-asia" + WIRELESS_DATA_QUOTA1_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quota1-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTA1_EUROPE = "wireless-data-quota1-europe" + WIRELESS_DATA_QUOTA1_NORTHAMERICA = "wireless-data-quota1-northamerica" + WIRELESS_DATA_QUOTA1_OCEANIA = "wireless-data-quota1-oceania" + WIRELESS_DATA_QUOTA10 = "wireless-data-quota10" + WIRELESS_DATA_QUOTA10_AFRICA = "wireless-data-quota10-africa" + WIRELESS_DATA_QUOTA10_ASIA = "wireless-data-quota10-asia" + WIRELESS_DATA_QUOTA10_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quota10-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTA10_EUROPE = "wireless-data-quota10-europe" + WIRELESS_DATA_QUOTA10_NORTHAMERICA = "wireless-data-quota10-northamerica" + WIRELESS_DATA_QUOTA10_OCEANIA = "wireless-data-quota10-oceania" + WIRELESS_DATA_QUOTA50 = "wireless-data-quota50" + WIRELESS_DATA_QUOTA50_AFRICA = "wireless-data-quota50-africa" + WIRELESS_DATA_QUOTA50_ASIA = "wireless-data-quota50-asia" + WIRELESS_DATA_QUOTA50_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quota50-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTA50_EUROPE = "wireless-data-quota50-europe" + WIRELESS_DATA_QUOTA50_NORTHAMERICA = "wireless-data-quota50-northamerica" + WIRELESS_DATA_QUOTA50_OCEANIA = "wireless-data-quota50-oceania" + WIRELESS_DATA_QUOTACUSTOM = "wireless-data-quotacustom" + WIRELESS_DATA_QUOTACUSTOM_AFRICA = "wireless-data-quotacustom-africa" + WIRELESS_DATA_QUOTACUSTOM_ASIA = "wireless-data-quotacustom-asia" + WIRELESS_DATA_QUOTACUSTOM_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quotacustom-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTACUSTOM_EUROPE = "wireless-data-quotacustom-europe" + WIRELESS_DATA_QUOTACUSTOM_NORTHAMERICA = ( + "wireless-data-quotacustom-northamerica" + ) + WIRELESS_DATA_QUOTACUSTOM_OCEANIA = "wireless-data-quotacustom-oceania" + WIRELESS_MRC_PAYG = "wireless-mrc-payg" + WIRELESS_MRC_QUOTA1 = "wireless-mrc-quota1" + WIRELESS_MRC_QUOTA10 = "wireless-mrc-quota10" + WIRELESS_MRC_QUOTA50 = "wireless-mrc-quota50" + WIRELESS_MRC_QUOTACUSTOM = "wireless-mrc-quotacustom" WIRELESS_ORDERS = "wireless-orders" WIRELESS_ORDERS_ARTWORK = "wireless-orders-artwork" WIRELESS_ORDERS_BULK = "wireless-orders-bulk" WIRELESS_ORDERS_ESIM = "wireless-orders-esim" WIRELESS_ORDERS_STARTER = "wireless-orders-starter" + WIRELESS_QUOTAS = "wireless-quotas" + WIRELESS_SMS_AFRICA = "wireless-sms-africa" + WIRELESS_SMS_ASIA = "wireless-sms-asia" + WIRELESS_SMS_CENTRALANDSOUTHAMERICA = "wireless-sms-centralandsouthamerica" + WIRELESS_SMS_EUROPE = "wireless-sms-europe" + WIRELESS_SMS_NORTHAMERICA = "wireless-sms-northamerica" + WIRELESS_SMS_OCEANIA = "wireless-sms-oceania" + WIRELESS_SUPER_SIM = "wireless-super-sim" + WIRELESS_SUPER_SIM_DATA = "wireless-super-sim-data" + WIRELESS_SUPER_SIM_DATA_NORTH_AMERICA_USA = ( + "wireless-super-sim-data-north-america-usa" + ) + WIRELESS_SUPER_SIM_DATA_PAYG = "wireless-super-sim-data-payg" + WIRELESS_SUPER_SIM_DATA_PAYG_EUROPE = "wireless-super-sim-data-payg-europe" + WIRELESS_SUPER_SIM_DATA_PAYG_NORTH_AMERICA = ( + "wireless-super-sim-data-payg-north-america" + ) + WIRELESS_SUPER_SIM_HARDWARE = "wireless-super-sim-hardware" + WIRELESS_SUPER_SIM_HARDWARE_BULK = "wireless-super-sim-hardware-bulk" + WIRELESS_SUPER_SIM_SMSCOMMANDS = "wireless-super-sim-smscommands" + WIRELESS_SUPER_SIM_SMSCOMMANDS_AFRICA = "wireless-super-sim-smscommands-africa" + WIRELESS_SUPER_SIM_SMSCOMMANDS_ASIA = "wireless-super-sim-smscommands-asia" + WIRELESS_SUPER_SIM_SMSCOMMANDS_CENT_AND_SOUTH_AMERICA = ( + "wireless-super-sim-smscommands-cent-and-south-america" + ) + WIRELESS_SUPER_SIM_SMSCOMMANDS_EUROPE = "wireless-super-sim-smscommands-europe" + WIRELESS_SUPER_SIM_SMSCOMMANDS_NORTH_AMERICA = ( + "wireless-super-sim-smscommands-north-america" + ) + WIRELESS_SUPER_SIM_SMSCOMMANDS_OCEANIA = ( + "wireless-super-sim-smscommands-oceania" + ) + WIRELESS_SUPER_SIM_SUBSCRIPTION = "wireless-super-sim-subscription" + WIRELESS_SUPER_SIM_SUBSCRIPTION_PAYG = "wireless-super-sim-subscription-payg" WIRELESS_USAGE = "wireless-usage" WIRELESS_USAGE_COMMANDS = "wireless-usage-commands" WIRELESS_USAGE_COMMANDS_AFRICA = "wireless-usage-commands-africa" @@ -342,6 +656,184 @@ class Category(object): WIRELESS_USAGE_MRC_SUSPENDED = "wireless-usage-mrc-suspended" WIRELESS_USAGE_SMS = "wireless-usage-sms" WIRELESS_USAGE_VOICE = "wireless-usage-voice" + A2P_FAST_TRACK_ONBOARDING = "a2p-fast-track-onboarding" + ADVISORY_SERVICES = "advisory-services" + ADVISORY_SERVICES_BILLED = "advisory-services-billed" + ADVISORY_SERVICES_CALL_TRACKING = "advisory-services-call-tracking" + ADVISORY_SERVICES_DATA_SERVICES = "advisory-services-data-services" + ADVISORY_SERVICES_EXPENSES = "advisory-services-expenses" + ADVISORY_SERVICES_SIP_TRUNKING = "advisory-services-sip-trunking" + ASSETS_REQUESTS = "assets-requests" + AUDIENCE_MINUTES_VIDEO = "audience-minutes-video" + AUTHY_BUCKET_ADJUSTMENT = "authy-bucket-adjustment" + AUTHY_SOFTWARE = "authy-software" + CALLERIDLOOKUPS_API = "calleridlookups-api" + CALLERIDLOOKUPS_PROGRAMMABLEVOICE = "calleridlookups-programmablevoice" + CALLERIDLOOKUPS_TRUNKING = "calleridlookups-trunking" + CALLS_TRUNKING_INBOUND_TOLLFREE_LOCAL = "calls-trunking-inbound-tollfree-local" + CALLS_TRUNKING_INBOUND_TOLLFREE_MOBILE = ( + "calls-trunking-inbound-tollfree-mobile" + ) + CHANNELS_WHATSAPP_CONVERSATION_FREE_1 = "channels-whatsapp-conversation-free-1" + CONFERENCE = "conference" + CONVERSATIONAL_INSIGHTS = "conversational-insights" + CONVERSATIONAL_INSIGHTS_MESSAGES = "conversational-insights-messages" + CONVERSATIONAL_INSIGHTS_VOICE_MINUTES = "conversational-insights-voice-minutes" + DEMO = "demo" + DEMO_UC_SCRIPT_TEST = "demo-uc-script-test" + ELASTIC_SIP_TRUNKING = "elastic-sip-trunking" + ELASTIC_SIP_TRUNKING_CALL_TRANSFERS = "elastic-sip-trunking-call-transfers" + ENTERPRISE_HIPPA = "enterprise-hippa" + FLEX_NAMED_USERS = "flex-named-users" + FLEX_SPINSCI = "flex-spinsci" + FLEX_USERS_1 = "flex-users-1" + FLEX_WFO_PREMIUM_SPEECH_ANALYTICS = "flex-wfo-premium-speech-analytics" + FLEX_XCELERATE = "flex-xcelerate" + FUNCTIONS_ROLLUP = "functions-rollup" + IMP_V1_USAGE = "imp-v1-usage" + IP_MESSAGING_ADDONS = "ip-messaging-addons" + IVR = "ivr" + IVR_CONVERSATIONAL = "ivr-conversational" + IVR_DTMF = "ivr-dtmf" + IVR_VIRTUALAGENT = "ivr-virtualagent" + LIVE = "live" + LIVE_MEDIA_RECORDING_MINUTES = "live-media-recording-minutes" + LONGCODE_MPS = "longcode-mps" + MARKETPLACE_ANALYTICS_ADDONS = "marketplace-analytics-addons" + MARKETPLACE_ISV_ADDONS = "marketplace-isv-addons" + MARKETPLACE_MESSAGING_ADDONS = "marketplace-messaging-addons" + MARKETPLACE_PHONENUMBERS_ADDONS = "marketplace-phonenumbers-addons" + MARKETPLACE_RECORDING_ADDONS = "marketplace-recording-addons" + MARKETPLACE_VIRTUALAGENT_ADDONS = "marketplace-virtualagent-addons" + MARKETPLAY_PAY_ADDONS_SHUTTLE_PAY_CONNECTOR_1 = ( + "marketplay-pay-addons-shuttle-pay-connector-1" + ) + MARKETPLAY_PAY_ADDONS_STRIPE_PAY_CONNECTOR = ( + "marketplay-pay-addons-stripe-pay-connector" + ) + MMS_INBOUND_LONGCODE_CANADA = "mms-inbound-longcode-canada" + MMS_INBOUND_LONGCODE_UNITEDSTATES = "mms-inbound-longcode-unitedstates" + MMS_OUTBOUND_LONGCODE_CANADA = "mms-outbound-longcode-canada" + MMS_OUTBOUND_LONGCODE_UNITEDSTATES = "mms-outbound-longcode-unitedstates" + MMS_OUTBOUND_TOLL_FREE = "mms-outbound-toll-free" + NOTIFY_CHATAPPSANDOTHERCHANNELS = "notify-chatappsandotherchannels" + NOTIFY_NOTIFYSERVICES = "notify-notifyservices" + NOTIFY_PUSHNOTIFICATIONS = "notify-pushnotifications" + PAYMENT_GATEWAY_CONNECTORS = "payment-gateway-connectors" + PAYMENT_SOLUTIONS = "payment-solutions" + PCHAT_BUCKET_ADJUSTMENT = "pchat-bucket-adjustment" + PHONENUMBERS_NUMBERS = "phonenumbers-numbers" + PROG_VOICE_CLIENT_ANDROID = "prog-voice-client-android" + PROG_VOICE_CLIENT_ANDROID_INBOUND = "prog-voice-client-android-inbound" + PROG_VOICE_CLIENT_ANDROID_OUTBOUND = "prog-voice-client-android-outbound" + PROG_VOICE_CLIENT_IOS = "prog-voice-client-ios" + PROG_VOICE_CLIENT_IOS_INBOUND = "prog-voice-client-ios-inbound" + PROG_VOICE_CLIENT_IOS_OUTBOUND = "prog-voice-client-ios-outbound" + PROG_VOICE_CLIENT_SDK = "prog-voice-client-sdk" + PROG_VOICE_CLIENT_WEB = "prog-voice-client-web" + PROG_VOICE_CLIENT_WEB_INBOUND = "prog-voice-client-web-inbound" + PROG_VOICE_CLIENT_WEB_OUTBOUND = "prog-voice-client-web-outbound" + PROGRAMMABLEVOICECONNECTIVITY_MEDIA_STREAMS = ( + "programmablevoiceconnectivity-media-streams" + ) + PSTNCONNECTIVITY_BYOC = "pstnconnectivity-byoc" + PSTNCONNECTIVITY_EMERGENCY = "pstnconnectivity-emergency" + PSTNCONNECTIVITY_MINUTES = "pstnconnectivity-minutes" + PSTNCONNECTIVITY_MINUTES_1 = "pstnconnectivity-minutes-1" + PSTNCONNECTIVITY_MINUTESINBOUNDLOCAL = "pstnconnectivity-minutesinboundlocal" + PSTNCONNECTIVITY_MINUTESINBOUNDMOBILE = "pstnconnectivity-minutesinboundmobile" + PSTNCONNECTIVITY_MINUTESINBOUNDTOLLFREE = ( + "pstnconnectivity-minutesinboundtollfree" + ) + PSTNCONNECTIVITY_MINUTESINBOUNDTOLLFREELOCAL = ( + "pstnconnectivity-minutesinboundtollfreelocal" + ) + PSTNCONNECTIVITY_MINUTESINBOUNDTOLLFREEMOBILE = ( + "pstnconnectivity-minutesinboundtollfreemobile" + ) + PV_ROOM_HOURS = "pv-room-hours" + PV_ROOM_SIMULTANEOUS_PARTICIPANT_CONNECTIONS = ( + "pv-room-simultaneous-participant-connections" + ) + PVIDEO_ROOM_HOURS_AU1 = "pvideo-room-hours-au1" + PVIDEO_ROOM_HOURS_BR1 = "pvideo-room-hours-br1" + PVIDEO_ROOM_HOURS_IE1 = "pvideo-room-hours-ie1" + PVIDEO_ROOM_HOURS_JP1 = "pvideo-room-hours-jp1" + PVIDEO_ROOM_HOURS_SG1 = "pvideo-room-hours-sg1" + PVIDEO_ROOM_HOURS_US1 = "pvideo-room-hours-us1" + PVIDEO_ROOM_HOURS_US2 = "pvideo-room-hours-us2" + RECORDINGS_ENCRYPTED = "recordings-encrypted" + SHORT_CODE_SETUP_FEES = "short-code-setup-fees" + SHORTCODES_MESSAGES_INBOUND = "shortcodes-messages-inbound" + SHORTCODES_MESSAGES_OUTBOUND = "shortcodes-messages-outbound" + SMS_MESSAGES_REGISTRATIONFEES = "sms-messages-registrationfees" + SMS_MMS_PENALTY_FEES = "sms-mms-penalty-fees" + SMS_MMS_PENALTY_FEES_1 = "sms-mms-penalty-fees-1" + SMS_PUMPING_PROTECTION_NON_USCA = "sms-pumping-protection-non-usca" + SMS_PUMPING_PROTECTION_USCA = "sms-pumping-protection-usca" + STUDIO = "studio" + STUDIO_MONTHLY_FEES = "studio-monthly-fees" + SUPERSIM = "supersim" + TASK_ROUTER = "task-router" + TASK_ROUTER_WORKERS = "task-router-workers" + TEST_QUOTA_BUCKETS = "test-quota-buckets" + TEST_UC_SCRIPT_1 = "test-uc-script-1" + TEST_UC_SCRIPT_DEMO_2 = "test-uc-script-demo-2" + TEXT_TO_SPEECH = "text-to-speech" + TME = "tme" + TTS_BASIC = "tts-basic" + TWILIO_EDITIONS = "twilio-editions" + TWILIO_INTERCONNECT_CALIFORNIA = "twilio-interconnect-california" + TWILIO_INTERCONNECT_CALIFORNIA_MONTHLY = ( + "twilio-interconnect-california-monthly" + ) + TWILIO_INTERCONNECT_CALIFORNIA_SETUP = "twilio-interconnect-california-setup" + TWILIO_INTERCONNECT_FRANKFURT = "twilio-interconnect-frankfurt" + TWILIO_INTERCONNECT_FRANKFURT_MO = "twilio-interconnect-frankfurt-mo" + TWILIO_INTERCONNECT_FRANKFURT_SETUP = "twilio-interconnect-frankfurt-setup" + TWILIO_INTERCONNECT_LONDON = "twilio-interconnect-london" + TWILIO_INTERCONNECT_LONDON_MO = "twilio-interconnect-london-mo" + TWILIO_INTERCONNECT_LONDON_SETUP = "twilio-interconnect-london-setup" + TWILIO_INTERCONNECT_SAO_PAULO = "twilio-interconnect-sao-paulo" + TWILIO_INTERCONNECT_SAO_PAULO_MONTHLY = "twilio-interconnect-sao-paulo-monthly" + TWILIO_INTERCONNECT_SAO_PAULO_SETUP = "twilio-interconnect-sao-paulo-setup" + TWILIO_INTERCONNECT_SINGAPORE = "twilio-interconnect-singapore" + TWILIO_INTERCONNECT_SINGAPORE_MO = "twilio-interconnect-singapore-mo" + TWILIO_INTERCONNECT_SINGAPORE_SETUP = "twilio-interconnect-singapore-setup" + TWILIO_INTERCONNECT_SYDNEY = "twilio-interconnect-sydney" + TWILIO_INTERCONNECT_SYDNEY_MO = "twilio-interconnect-sydney-mo" + TWILIO_INTERCONNECT_SYDNEY_SETUP = "twilio-interconnect-sydney-setup" + TWILIO_INTERCONNECT_TOKYO = "twilio-interconnect-tokyo" + TWILIO_INTERCONNECT_TOKYO_MO = "twilio-interconnect-tokyo-mo" + TWILIO_INTERCONNECT_TOKYO_SETUP = "twilio-interconnect-tokyo-setup" + TWILIO_INTERCONNECT_VA = "twilio-interconnect-va" + TWILIO_INTERCONNECT_VA_MO = "twilio-interconnect-va-mo" + TWILIO_INTERCONNECT_VA_SETUP = "twilio-interconnect-va-setup" + TWIML_VERBS = "twiml-verbs" + TWIML_VERBS_SAY = "twiml-verbs-say" + USAGE_PROGRAMMABLE_MESSAGING_ENGAGEMENT_SUITE = ( + "usage-programmable-messaging-engagement-suite" + ) + USAGE_PROGRAMMABLE_MESSAGING_FEES_SERVICES = ( + "usage-programmable-messaging-fees-services" + ) + VERIFY_OUTBOUND_EMAIL = "verify-outbound-email" + VERIFY_PACKAGED_PLANS = "verify-packaged-plans" + VERIFY_SILENT_NETWORK_AUTH = "verify-silent-network-auth" + VERIFY_VOICE_AND_SMS = "verify-voice-and-sms" + VOICE_INSIGHTS_CLIENT_INSIGHTS_MONTHY_COMMIT = ( + "voice-insights-client-insights-monthy-commit" + ) + WIRELESS_DATA_PAYG_ASIA_AFG = "wireless-data-payg-asia-afg" + WIRELESS_MULTI_IMSI_SIM_COMMANDS = "wireless-multi-imsi-sim-commands" + WIRELESS_MULTI_IMSI_SIM_COMMANDS_USA = "wireless-multi-imsi-sim-commands-usa" + WIRELESS_MULTI_IMSI_SIM_DATA = "wireless-multi-imsi-sim-data" + WIRELESS_MULTI_IMSI_SIM_DATA_EU28 = "wireless-multi-imsi-sim-data-eu28" + WIRELESS_MULTI_IMSI_SIM_DATA_USA = "wireless-multi-imsi-sim-data-usa" + WIRELESS_MULTI_IMSI_SIM_MONTHLY_FEES = "wireless-multi-imsi-sim-monthly-fees" + WIRELESS_MULTI_IMSI_SIM_USAGE = "wireless-multi-imsi-sim-usage" + WIRELESS_SUPER_SIM_DATA_NORTH_AMERICA = "wireless-super-sim-data-north-america" + WIRELESS_SUPER_SIM_USAGE = "wireless-super-sim-usage" """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that accrued the usage. @@ -401,6 +893,7 @@ def __repr__(self) -> str: class YearlyPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> YearlyInstance: """ Build an instance of YearlyInstance @@ -421,6 +914,7 @@ def __repr__(self) -> str: class YearlyList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the YearlyList @@ -623,14 +1117,20 @@ def page( "Category": category, "StartDate": serialize.iso8601_date(start_date), "EndDate": serialize.iso8601_date(end_date), - "IncludeSubaccounts": include_subaccounts, + "IncludeSubaccounts": serialize.boolean_to_string(include_subaccounts), "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 YearlyPage(self._version, response, self._solution) async def page_async( @@ -662,15 +1162,19 @@ async def page_async( "Category": category, "StartDate": serialize.iso8601_date(start_date), "EndDate": serialize.iso8601_date(end_date), - "IncludeSubaccounts": include_subaccounts, + "IncludeSubaccounts": serialize.boolean_to_string(include_subaccounts), "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 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 b5307b6417..f3aacda8b9 100644 --- a/twilio/rest/api/v2010/account/usage/record/yesterday.py +++ b/twilio/rest/api/v2010/account/usage/record/yesterday.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import date from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import deserialize, serialize, values @@ -24,34 +23,103 @@ class YesterdayInstance(InstanceResource): + class Category(object): + A2P_10DLC_REGISTRATIONFEES_BRANDREGISTRATION = ( + "a2p-10dlc-registrationfees-brandregistration" + ) + A2P_10DLC_REGISTRATIONFEES_BV = "a2p-10dlc-registrationfees-bv" + A2P_10DLC_REGISTRATIONFEES_CAMPAIGNCHARGES = ( + "a2p-10dlc-registrationfees-campaigncharges" + ) + A2P_10DLC_REGISTRATIONFEES_CAMPAIGNREGISTRATION = ( + "a2p-10dlc-registrationfees-campaignregistration" + ) + A2P_10DLC_REGISTRATIONFEES_CAMPAIGNVETTING = ( + "a2p-10dlc-registrationfees-campaignvetting" + ) + A2P_10DLC_REGISTRATIONFEES_MONTHLY = "a2p-10dlc-registrationfees-monthly" + A2P_10DLC_REGISTRATIONFEES_ONETIME = "a2p-10dlc-registrationfees-onetime" A2P_REGISTRATION_FEES = "a2p-registration-fees" + ACCOUNT_SECURITY = "account-security" AGENT_CONFERENCE = "agent-conference" + AGENT_COPILOT = "agent-copilot" + AGENT_COPILOT_MESSAGES = "agent-copilot-messages" + AGENT_COPILOT_PARTICIPANT_MINUTES = "agent-copilot-participant-minutes" + AI_ASSISTANTS = "ai-assistants" + AI_ASSISTANTS_VOICE = "ai-assistants-voice" AMAZON_POLLY = "amazon-polly" ANSWERING_MACHINE_DETECTION = "answering-machine-detection" + ASSETS = "assets" + AUDIENCE_MINUTES = "audience-minutes" + AUDIENCE_MINUTES_AUDIO = "audience-minutes-audio" AUTHY_AUTHENTICATIONS = "authy-authentications" AUTHY_CALLS_OUTBOUND = "authy-calls-outbound" + AUTHY_EMAIL_AUTHENTICATIONS = "authy-email-authentications" AUTHY_MONTHLY_FEES = "authy-monthly-fees" + AUTHY_OUTBOUND_EMAIL = "authy-outbound-email" AUTHY_PHONE_INTELLIGENCE = "authy-phone-intelligence" AUTHY_PHONE_VERIFICATIONS = "authy-phone-verifications" AUTHY_SMS_OUTBOUND = "authy-sms-outbound" + AUTHY_VERIFY_EMAIL_VERIFICATIONS = "authy-verify-email-verifications" + AUTHY_VERIFY_OUTBOUND_EMAIL = "authy-verify-outbound-email" + AUTOPILOT = "autopilot" + AUTOPILOT_HOME_ASSISTANTS = "autopilot-home-assistants" + AUTOPILOT_MESSAGING = "autopilot-messaging" + AUTOPILOT_OTHER = "autopilot-other" + AUTOPILOT_VOICE = "autopilot-voice" + BASIC_PEER_TO_PEER_ROOMS_PARTICIPANT_MINUTES = ( + "basic-peer-to-peer-rooms-participant-minutes" + ) + BRANDED_CALLING = "branded-calling" + BUNDLE_SMS_BUCKET = "bundle-sms-bucket" + BUNDLE_SUBSCRIPTION_FEES = "bundle-subscription-fees" + CALL_FORWARDING_LOOKUPS = "call-forwarding-lookups" CALL_PROGESS_EVENTS = "call-progess-events" CALLERIDLOOKUPS = "calleridlookups" CALLS = "calls" CALLS_CLIENT = "calls-client" + CALLS_EMERGENCY = "calls-emergency" CALLS_GLOBALCONFERENCE = "calls-globalconference" CALLS_INBOUND = "calls-inbound" CALLS_INBOUND_LOCAL = "calls-inbound-local" CALLS_INBOUND_MOBILE = "calls-inbound-mobile" CALLS_INBOUND_TOLLFREE = "calls-inbound-tollfree" + CALLS_INBOUND_TOLLFREE_LOCAL = "calls-inbound-tollfree-local" + CALLS_INBOUND_TOLLFREE_MOBILE = "calls-inbound-tollfree-mobile" + CALLS_MEDIA_STREAM_MINUTES = "calls-media-stream-minutes" CALLS_OUTBOUND = "calls-outbound" CALLS_PAY_VERB_TRANSACTIONS = "calls-pay-verb-transactions" CALLS_RECORDINGS = "calls-recordings" CALLS_SIP = "calls-sip" CALLS_SIP_INBOUND = "calls-sip-inbound" CALLS_SIP_OUTBOUND = "calls-sip-outbound" + CALLS_TEXT_TO_SPEECH = "calls-text-to-speech" CALLS_TRANSFERS = "calls-transfers" CARRIER_LOOKUPS = "carrier-lookups" + CATEGORY = "category" + CHANNELS = "channels" + CHANNELS_MESSAGING = "channels-messaging" + CHANNELS_MESSAGING_INBOUND = "channels-messaging-inbound" + CHANNELS_MESSAGING_OUTBOUND = "channels-messaging-outbound" + CHANNELS_WHATSAPP = "channels-whatsapp" + CHANNELS_WHATSAPP_CONVERSATION_AUTHENTICATION = ( + "channels-whatsapp-conversation-authentication" + ) + CHANNELS_WHATSAPP_CONVERSATION_FREE = "channels-whatsapp-conversation-free" + CHANNELS_WHATSAPP_CONVERSATION_MARKETING = ( + "channels-whatsapp-conversation-marketing" + ) + CHANNELS_WHATSAPP_CONVERSATION_SERVICE = ( + "channels-whatsapp-conversation-service" + ) + CHANNELS_WHATSAPP_CONVERSATION_UTILITY = ( + "channels-whatsapp-conversation-utility" + ) + CHANNELS_WHATSAPP_INBOUND = "channels-whatsapp-inbound" + CHANNELS_WHATSAPP_OUTBOUND = "channels-whatsapp-outbound" + CHAT_VIRTUAL_AGENT = "chat-virtual-agent" + CONVERSATION_RELAY = "conversation-relay" CONVERSATIONS = "conversations" CONVERSATIONS_API_REQUESTS = "conversations-api-requests" CONVERSATIONS_CONVERSATION_EVENTS = "conversations-conversation-events" @@ -60,8 +128,40 @@ class Category(object): CONVERSATIONS_PARTICIPANT_EVENTS = "conversations-participant-events" CONVERSATIONS_PARTICIPANTS = "conversations-participants" CPS = "cps" + CREDIT_TRANSFER = "credit-transfer" + EMAIL = "email" + EMERGING_TECH = "emerging-tech" + ENGAGEMENT_SUITE_PACKAGED_PLANS = "engagement-suite-packaged-plans" + ENHANCED_LINE_TYPE_LOOKUPS = "enhanced-line-type-lookups" + ENTERPRISE = "enterprise" + EVENTS = "events" + EXPERIMENT_FRANCE_SMS = "experiment-france-sms" + EXPERIMENT_INDIA_SMS = "experiment-india-sms" + EXPERIMENT_UK_SMS = "experiment-uk-sms" + FAILED_MESSAGE_PROCESSING_FEE = "failed-message-processing-fee" + FLEX = "flex" + FLEX_ACTIVE_USER_HOURS = "flex-active-user-hours" + FLEX_CONCURRENT_USERS = "flex-concurrent-users" + FLEX_CONVERSATIONAL_INSIGHTS = "flex-conversational-insights" + FLEX_CONVERSATIONAL_INSIGHTS_MESSAGES = "flex-conversational-insights-messages" + FLEX_CONVERSATIONAL_INSIGHTS_VOICE_MINUTES = ( + "flex-conversational-insights-voice-minutes" + ) + FLEX_EMAIL_USAGE = "flex-email-usage" + FLEX_MESSAGING_USAGE = "flex-messaging-usage" + FLEX_PARTNER_SPINSCI = "flex-partner-spinsci" + FLEX_PARTNER_XCELERATE = "flex-partner-xcelerate" + FLEX_RESELLER_ECOSYSTEM = "flex-reseller-ecosystem" + FLEX_UNIQUE_USER = "flex-unique-user" FLEX_USAGE = "flex-usage" + FLEX_USERS = "flex-users" + FLEX_VOICE_MINUTE = "flex-voice-minute" + FLEX_YTICA = "flex-ytica" FRAUD_LOOKUPS = "fraud-lookups" + FRONTLINE = "frontline" + FRONTLINE_USERS = "frontline-users" + FUNCTIONS = "functions" + GENERIC_PAY_TRANSACTIONS = "generic-pay-transactions" GROUP_ROOMS = "group-rooms" GROUP_ROOMS_DATA_TRACK = "group-rooms-data-track" GROUP_ROOMS_ENCRYPTED_MEDIA_RECORDED = "group-rooms-encrypted-media-recorded" @@ -71,7 +171,17 @@ class Category(object): GROUP_ROOMS_MEDIA_STORED = "group-rooms-media-stored" GROUP_ROOMS_PARTICIPANT_MINUTES = "group-rooms-participant-minutes" GROUP_ROOMS_RECORDED_MINUTES = "group-rooms-recorded-minutes" - IMP_V1_USAGE = "imp-v1-usage" + IP_MESSAGING = "ip-messaging" + IP_MESSAGING_COMMANDS = "ip-messaging-commands" + IP_MESSAGING_DATA_STORAGE = "ip-messaging-data-storage" + IP_MESSAGING_DATA_TRANSFER = "ip-messaging-data-transfer" + IP_MESSAGING_ENDPOINT_CONNECTIVITY = "ip-messaging-endpoint-connectivity" + IVR_VIRTUAL_AGENT_CUSTOM_VOICES = "ivr-virtual-agent-custom-voices" + IVR_VIRTUAL_AGENT_GENAI = "ivr-virtual-agent-genai" + LINE_STATUS_LOOKUPS = "line-status-lookups" + LIVE_ACTIVITY_LOOKUPS = "live-activity-lookups" + LOOKUP_BUCKET_ADJUSTMENT = "lookup-bucket-adjustment" + LOOKUP_IDENTITY_MATCH = "lookup-identity-match" LOOKUPS = "lookups" MARKETPLACE = "marketplace" MARKETPLACE_ALGORITHMIA_NAMED_ENTITY_RECOGNITION = ( @@ -82,6 +192,13 @@ class Category(object): MARKETPLACE_CAPIO_SPEECH_TO_TEXT = "marketplace-capio-speech-to-text" MARKETPLACE_CONVRIZA_ABABA = "marketplace-convriza-ababa" MARKETPLACE_DEEPGRAM_PHRASE_DETECTOR = "marketplace-deepgram-phrase-detector" + MARKETPLACE_DEEPGRAM_TRANSCRIPTION = "marketplace-deepgram-transcription" + MARKETPLACE_DEEPGRAM_TRANSCRIPTION_BASE = ( + "marketplace-deepgram-transcription-base" + ) + MARKETPLACE_DEEPGRAM_TRANSSCRIPTION_ENHANCED = ( + "marketplace-deepgram-transscription-enhanced" + ) MARKETPLACE_DIGITAL_SEGMENT_BUSINESS_INFO = ( "marketplace-digital-segment-business-info" ) @@ -107,6 +224,9 @@ class Category(object): "marketplace-keen-io-contact-center-analytics" ) MARKETPLACE_MARCHEX_CLEANCALL = "marketplace-marchex-cleancall" + MARKETPLACE_MARCHEX_RECORDING_ANALYSIS = ( + "marketplace-marchex-recording-analysis" + ) MARKETPLACE_MARCHEX_SENTIMENT_ANALYSIS_FOR_SMS = ( "marketplace-marchex-sentiment-analysis-for-sms" ) @@ -123,14 +243,42 @@ class Category(object): "marketplace-nextcaller-advanced-caller-identification" ) MARKETPLACE_NOMOROBO_SPAM_SCORE = "marketplace-nomorobo-spam-score" + MARKETPLACE_PAY_ADDONS = "marketplace-pay-addons" + MARKETPLACE_PAY_ADDONS_BASECOMMERCE_PAY_CONNECTOR = ( + "marketplace-pay-addons-basecommerce-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_BRAINTREE_PAY_CONNECTOR = ( + "marketplace-pay-addons-braintree-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_CARDCONNECT_PAY_CONNECTOR = ( + "marketplace-pay-addons-cardconnect-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_CHASE_PAY_CONNECTOR = ( + "marketplace-pay-addons-chase-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_SHUTTLE_PAY_CONNECTOR = ( + "marketplace-pay-addons-shuttle-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_STRIPE_PAY_CONNECTOR = ( + "marketplace-pay-addons-stripe-pay-connector" + ) MARKETPLACE_PAYFONE_TCPA_COMPLIANCE = "marketplace-payfone-tcpa-compliance" + MARKETPLACE_POLY_AI_CONNECTOR = "marketplace-poly-ai-connector" + MARKETPLACE_REALPHONEVALIDATION = "marketplace-realphonevalidation" MARKETPLACE_REMEETING_AUTOMATIC_SPEECH_RECOGNITION = ( "marketplace-remeeting-automatic-speech-recognition" ) + MARKETPLACE_SPOKE_PHONE_LICENSE_PRO = "marketplace-spoke-phone-license-pro" + MARKETPLACE_SPOKE_PHONE_LICENSE_STANDARD = ( + "marketplace-spoke-phone-license-standard" + ) MARKETPLACE_TCPA_DEFENSE_SOLUTIONS_BLACKLIST_FEED = ( "marketplace-tcpa-defense-solutions-blacklist-feed" ) MARKETPLACE_TELO_OPENCNAM = "marketplace-telo-opencnam" + MARKETPLACE_TRESTLE_SOLUTIONS_CALLER_IDENTIFICATION = ( + "marketplace-trestle-solutions-caller-identification" + ) MARKETPLACE_TRUECNAM_TRUE_SPAM = "marketplace-truecnam-true-spam" MARKETPLACE_TWILIO_CALLER_NAME_LOOKUP_US = ( "marketplace-twilio-caller-name-lookup-us" @@ -143,6 +291,9 @@ class Category(object): MARKETPLACE_VOICEBASE_TRANSCRIPTION_CUSTOM_VOCABULARY = ( "marketplace-voicebase-transcription-custom-vocabulary" ) + MARKETPLACE_WEB_PURIFY_PROFANITY_FILTER = ( + "marketplace-web-purify-profanity-filter" + ) MARKETPLACE_WHITEPAGES_PRO_CALLER_IDENTIFICATION = ( "marketplace-whitepages-pro-caller-identification" ) @@ -157,15 +308,23 @@ class Category(object): MARKETPLACE_YTICA_CONTACT_CENTER_REPORTING_ANALYTICS = ( "marketplace-ytica-contact-center-reporting-analytics" ) + MARKETPLAY_PAY_ADDONS_SHUTTLE_PAY_CONNECTOR = ( + "marketplay-pay-addons-shuttle-pay-connector" + ) + MEDIA_COMPOSER_MINUTES = "media-composer-minutes" MEDIASTORAGE = "mediastorage" + MIN_SPEND_ADJUSTMENTS = "min-spend-adjustments" MMS = "mms" MMS_INBOUND = "mms-inbound" MMS_INBOUND_LONGCODE = "mms-inbound-longcode" MMS_INBOUND_SHORTCODE = "mms-inbound-shortcode" + MMS_INBOUND_TOLL_FREE = "mms-inbound-toll-free" MMS_MESSAGES_CARRIERFEES = "mms-messages-carrierfees" MMS_OUTBOUND = "mms-outbound" MMS_OUTBOUND_LONGCODE = "mms-outbound-longcode" MMS_OUTBOUND_SHORTCODE = "mms-outbound-shortcode" + MMS_OUTBOUND_TOLLFREE = "mms-outbound-tollfree" + MONITOR = "monitor" MONITOR_READS = "monitor-reads" MONITOR_STORAGE = "monitor-storage" MONITOR_WRITES = "monitor-writes" @@ -174,6 +333,12 @@ class Category(object): NOTIFY_CHANNELS = "notify-channels" NUMBER_FORMAT_LOOKUPS = "number-format-lookups" PCHAT = "pchat" + PCHAT_ACTIONS = "pchat-actions" + PCHAT_APS = "pchat-aps" + PCHAT_CONV_MED_STORAGE = "pchat-conv-med-storage" + PCHAT_MESSAGES = "pchat-messages" + PCHAT_NOTIFICATIONS = "pchat-notifications" + PCHAT_READS = "pchat-reads" PCHAT_USERS = "pchat-users" PEER_TO_PEER_ROOMS_PARTICIPANT_MINUTES = ( "peer-to-peer-rooms-participant-minutes" @@ -183,18 +348,41 @@ class Category(object): PFAX_MINUTES_INBOUND = "pfax-minutes-inbound" PFAX_MINUTES_OUTBOUND = "pfax-minutes-outbound" PFAX_PAGES = "pfax-pages" + PHONE_QUALITY_SCORE_LOOKUPS = "phone-quality-score-lookups" PHONENUMBERS = "phonenumbers" PHONENUMBERS_CPS = "phonenumbers-cps" PHONENUMBERS_EMERGENCY = "phonenumbers-emergency" PHONENUMBERS_LOCAL = "phonenumbers-local" PHONENUMBERS_MOBILE = "phonenumbers-mobile" + PHONENUMBERS_PORTING = "phonenumbers-porting" PHONENUMBERS_SETUPS = "phonenumbers-setups" PHONENUMBERS_TOLLFREE = "phonenumbers-tollfree" PREMIUMSUPPORT = "premiumsupport" + PREMIUMSUPPORT_PERCENTAGE_SPEND = "premiumsupport-percentage-spend" + PROGRAMMABLEVOICE_PLATFORM = "programmablevoice-platform" + PROGRAMMABLEVOICECONN_CLIENTSDK = "programmablevoiceconn-clientsdk" + PROGRAMMABLEVOICECONN_CLIENTSDK_INBOUND = ( + "programmablevoiceconn-clientsdk-inbound" + ) + PROGRAMMABLEVOICECONN_CLIENTSDK_OUTBOUND = ( + "programmablevoiceconn-clientsdk-outbound" + ) + PROGRAMMABLEVOICECONN_ONNET = "programmablevoiceconn-onnet" + PROGRAMMABLEVOICECONN_ONNET_INBOUND = "programmablevoiceconn-onnet-inbound" + PROGRAMMABLEVOICECONN_ONNET_OUTBOUND = "programmablevoiceconn-onnet-outbound" + PROGRAMMABLEVOICECONN_SIP = "programmablevoiceconn-sip" + PROGRAMMABLEVOICECONN_SIP_INBOUND = "programmablevoiceconn-sip-inbound" + PROGRAMMABLEVOICECONN_SIP_OUTBOUND = "programmablevoiceconn-sip-outbound" + PROGRAMMABLEVOICECONNECTIVITY = "programmablevoiceconnectivity" PROXY = "proxy" PROXY_ACTIVE_SESSIONS = "proxy-active-sessions" + PROXY_BUCKET_ADJUSTMENT = "proxy-bucket-adjustment" + PROXY_LICENSES = "proxy-licenses" PSTNCONNECTIVITY = "pstnconnectivity" + PSTNCONNECTIVITY_INBOUND = "pstnconnectivity-inbound" + PSTNCONNECTIVITY_OUTBOUND = "pstnconnectivity-outbound" PV = "pv" + PV_BASIC_ROOMS = "pv-basic-rooms" PV_COMPOSITION_MEDIA_DOWNLOADED = "pv-composition-media-downloaded" PV_COMPOSITION_MEDIA_ENCRYPTED = "pv-composition-media-encrypted" PV_COMPOSITION_MEDIA_STORED = "pv-composition-media-stored" @@ -210,18 +398,20 @@ class Category(object): PV_ROOM_PARTICIPANTS_US2 = "pv-room-participants-us2" PV_ROOMS = "pv-rooms" PV_SIP_ENDPOINT_REGISTRATIONS = "pv-sip-endpoint-registrations" + RCS_MESSAGES = "rcs-messages" + REASSIGNED_NUMBER = "reassigned-number" RECORDINGS = "recordings" RECORDINGSTORAGE = "recordingstorage" - ROOMS_GROUP_BANDWIDTH = "rooms-group-bandwidth" - ROOMS_GROUP_MINUTES = "rooms-group-minutes" - ROOMS_PEER_TO_PEER_MINUTES = "rooms-peer-to-peer-minutes" SHORTCODES = "shortcodes" SHORTCODES_CUSTOMEROWNED = "shortcodes-customerowned" SHORTCODES_MMS_ENABLEMENT = "shortcodes-mms-enablement" SHORTCODES_MPS = "shortcodes-mps" SHORTCODES_RANDOM = "shortcodes-random" + SHORTCODES_SETUP_FEES = "shortcodes-setup-fees" SHORTCODES_UK = "shortcodes-uk" SHORTCODES_VANITY = "shortcodes-vanity" + SIM_SWAP_LOOKUPS = "sim-swap-lookups" + SIP_SECURE_MEDIA = "sip-secure-media" SMALL_GROUP_ROOMS = "small-group-rooms" SMALL_GROUP_ROOMS_DATA_TRACK = "small-group-rooms-data-track" SMALL_GROUP_ROOMS_PARTICIPANT_MINUTES = "small-group-rooms-participant-minutes" @@ -229,13 +419,30 @@ class Category(object): SMS_INBOUND = "sms-inbound" SMS_INBOUND_LONGCODE = "sms-inbound-longcode" SMS_INBOUND_SHORTCODE = "sms-inbound-shortcode" + SMS_INBOUND_TOLLFREE = "sms-inbound-tollfree" SMS_MESSAGES_CARRIERFEES = "sms-messages-carrierfees" SMS_MESSAGES_FEATURES = "sms-messages-features" + SMS_MESSAGES_FEATURES_ENGAGEMENT_SUITE = ( + "sms-messages-features-engagement-suite" + ) + SMS_MESSAGES_FEATURES_MESSAGE_REDACTION = ( + "sms-messages-features-message-redaction" + ) SMS_MESSAGES_FEATURES_SENDERID = "sms-messages-features-senderid" + SMS_MPS = "sms-mps" + SMS_MPS_SHORTCODE = "sms-mps-shortcode" + SMS_MPS_TOLLFREE = "sms-mps-tollfree" + SMS_MPS_TOLLFREE_SETUP = "sms-mps-tollfree-setup" + SMS_NATIONAL_REGULATORY_PROTECTION = "sms-national-regulatory-protection" SMS_OUTBOUND = "sms-outbound" SMS_OUTBOUND_CONTENT_INSPECTION = "sms-outbound-content-inspection" SMS_OUTBOUND_LONGCODE = "sms-outbound-longcode" SMS_OUTBOUND_SHORTCODE = "sms-outbound-shortcode" + SMS_OUTBOUND_TOLLFREE = "sms-outbound-tollfree" + SMS_PUMPING_PROTECTION = "sms-pumping-protection" + SMS_PUMPING_RISK = "sms-pumping-risk" + SMSMESSAGES_BUCKET_ADJUSTMENTS = "smsmessages-bucket-adjustments" + SMSMESSAGES_OUTBOUND_DOMESTIC = "smsmessages-outbound-domestic" SPEECH_RECOGNITION = "speech-recognition" STUDIO_ENGAGEMENTS = "studio-engagements" SYNC = "sync" @@ -254,6 +461,7 @@ class Category(object): TRUNKING_RECORDINGS = "trunking-recordings" TRUNKING_SECURE = "trunking-secure" TRUNKING_TERMINATION = "trunking-termination" + TTS_GOOGLE = "tts-google" TURNMEGABYTES = "turnmegabytes" TURNMEGABYTES_AUSTRALIA = "turnmegabytes-australia" TURNMEGABYTES_BRASIL = "turnmegabytes-brasil" @@ -264,13 +472,27 @@ class Category(object): TURNMEGABYTES_SINGAPORE = "turnmegabytes-singapore" TURNMEGABYTES_USEAST = "turnmegabytes-useast" TURNMEGABYTES_USWEST = "turnmegabytes-uswest" + TWILIO_FOR_SALESFORCE = "twilio-for-salesforce" + TWILIO_FOR_SALESFORCE_LICENSES = "twilio-for-salesforce-licenses" TWILIO_INTERCONNECT = "twilio-interconnect" + TWIML = "twiml" + USAGE_FLEX_VIDEO = "usage-flex-video" + USAGE_FUNCTIONS = "usage-functions" + USAGE_RCS_BASIC_MESSAGES_OUTBOUND = "usage-rcs-basic-messages-outbound" + USAGE_RCS_MESSAGES = "usage-rcs-messages" + USAGE_RCS_MESSAGES_INBOUND = "usage-rcs-messages-inbound" + USAGE_RCS_MESSAGING_CARRIER_FEES = "usage-rcs-messaging-carrier-fees" + USAGE_RCS_SINGLE_MESSAGES_OUTBOUND = "usage-rcs-single-messages-outbound" + VERIFY_PACKAGE_PLANS = "verify-package-plans" VERIFY_PUSH = "verify-push" + VERIFY_SNA = "verify-sna" VERIFY_TOTP = "verify-totp" + VERIFY_VOICE_SMS = "verify-voice-sms" VERIFY_WHATSAPP_CONVERSATIONS_BUSINESS_INITIATED = ( "verify-whatsapp-conversations-business-initiated" ) VIDEO_RECORDINGS = "video-recordings" + VIDEO_ROOMS_TURN_MEGABYTES = "video-rooms-turn-megabytes" VIRTUAL_AGENT = "virtual-agent" VOICE_INSIGHTS = "voice-insights" VOICE_INSIGHTS_CLIENT_INSIGHTS_ON_DEMAND_MINUTE = ( @@ -285,12 +507,104 @@ class Category(object): VOICE_INSIGHTS_SIP_TRUNKING_INSIGHTS_ON_DEMAND_MINUTE = ( "voice-insights-sip-trunking-insights-on-demand-minute" ) + VOICE_INTELLIGENCE = "voice-intelligence" + VOICE_INTELLIGENCE_EIP_OPERATORS = "voice-intelligence-eip-operators" + VOICE_INTELLIGENCE_OPERATORS = "voice-intelligence-operators" + VOICE_INTELLIGENCE_TRANSCRIPTION = "voice-intelligence-transcription" + WDS = "wds" WIRELESS = "wireless" + WIRELESS_DATA = "wireless-data" + WIRELESS_DATA_PAYG = "wireless-data-payg" + WIRELESS_DATA_PAYG_AFRICA = "wireless-data-payg-africa" + WIRELESS_DATA_PAYG_ASIA = "wireless-data-payg-asia" + WIRELESS_DATA_PAYG_CENTRALANDSOUTHAMERICA = ( + "wireless-data-payg-centralandsouthamerica" + ) + WIRELESS_DATA_PAYG_EUROPE = "wireless-data-payg-europe" + WIRELESS_DATA_PAYG_NORTHAMERICA = "wireless-data-payg-northamerica" + WIRELESS_DATA_PAYG_OCEANIA = "wireless-data-payg-oceania" + WIRELESS_DATA_QUOTA1 = "wireless-data-quota1" + WIRELESS_DATA_QUOTA1_AFRICA = "wireless-data-quota1-africa" + WIRELESS_DATA_QUOTA1_ASIA = "wireless-data-quota1-asia" + WIRELESS_DATA_QUOTA1_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quota1-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTA1_EUROPE = "wireless-data-quota1-europe" + WIRELESS_DATA_QUOTA1_NORTHAMERICA = "wireless-data-quota1-northamerica" + WIRELESS_DATA_QUOTA1_OCEANIA = "wireless-data-quota1-oceania" + WIRELESS_DATA_QUOTA10 = "wireless-data-quota10" + WIRELESS_DATA_QUOTA10_AFRICA = "wireless-data-quota10-africa" + WIRELESS_DATA_QUOTA10_ASIA = "wireless-data-quota10-asia" + WIRELESS_DATA_QUOTA10_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quota10-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTA10_EUROPE = "wireless-data-quota10-europe" + WIRELESS_DATA_QUOTA10_NORTHAMERICA = "wireless-data-quota10-northamerica" + WIRELESS_DATA_QUOTA10_OCEANIA = "wireless-data-quota10-oceania" + WIRELESS_DATA_QUOTA50 = "wireless-data-quota50" + WIRELESS_DATA_QUOTA50_AFRICA = "wireless-data-quota50-africa" + WIRELESS_DATA_QUOTA50_ASIA = "wireless-data-quota50-asia" + WIRELESS_DATA_QUOTA50_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quota50-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTA50_EUROPE = "wireless-data-quota50-europe" + WIRELESS_DATA_QUOTA50_NORTHAMERICA = "wireless-data-quota50-northamerica" + WIRELESS_DATA_QUOTA50_OCEANIA = "wireless-data-quota50-oceania" + WIRELESS_DATA_QUOTACUSTOM = "wireless-data-quotacustom" + WIRELESS_DATA_QUOTACUSTOM_AFRICA = "wireless-data-quotacustom-africa" + WIRELESS_DATA_QUOTACUSTOM_ASIA = "wireless-data-quotacustom-asia" + WIRELESS_DATA_QUOTACUSTOM_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quotacustom-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTACUSTOM_EUROPE = "wireless-data-quotacustom-europe" + WIRELESS_DATA_QUOTACUSTOM_NORTHAMERICA = ( + "wireless-data-quotacustom-northamerica" + ) + WIRELESS_DATA_QUOTACUSTOM_OCEANIA = "wireless-data-quotacustom-oceania" + WIRELESS_MRC_PAYG = "wireless-mrc-payg" + WIRELESS_MRC_QUOTA1 = "wireless-mrc-quota1" + WIRELESS_MRC_QUOTA10 = "wireless-mrc-quota10" + WIRELESS_MRC_QUOTA50 = "wireless-mrc-quota50" + WIRELESS_MRC_QUOTACUSTOM = "wireless-mrc-quotacustom" WIRELESS_ORDERS = "wireless-orders" WIRELESS_ORDERS_ARTWORK = "wireless-orders-artwork" WIRELESS_ORDERS_BULK = "wireless-orders-bulk" WIRELESS_ORDERS_ESIM = "wireless-orders-esim" WIRELESS_ORDERS_STARTER = "wireless-orders-starter" + WIRELESS_QUOTAS = "wireless-quotas" + WIRELESS_SMS_AFRICA = "wireless-sms-africa" + WIRELESS_SMS_ASIA = "wireless-sms-asia" + WIRELESS_SMS_CENTRALANDSOUTHAMERICA = "wireless-sms-centralandsouthamerica" + WIRELESS_SMS_EUROPE = "wireless-sms-europe" + WIRELESS_SMS_NORTHAMERICA = "wireless-sms-northamerica" + WIRELESS_SMS_OCEANIA = "wireless-sms-oceania" + WIRELESS_SUPER_SIM = "wireless-super-sim" + WIRELESS_SUPER_SIM_DATA = "wireless-super-sim-data" + WIRELESS_SUPER_SIM_DATA_NORTH_AMERICA_USA = ( + "wireless-super-sim-data-north-america-usa" + ) + WIRELESS_SUPER_SIM_DATA_PAYG = "wireless-super-sim-data-payg" + WIRELESS_SUPER_SIM_DATA_PAYG_EUROPE = "wireless-super-sim-data-payg-europe" + WIRELESS_SUPER_SIM_DATA_PAYG_NORTH_AMERICA = ( + "wireless-super-sim-data-payg-north-america" + ) + WIRELESS_SUPER_SIM_HARDWARE = "wireless-super-sim-hardware" + WIRELESS_SUPER_SIM_HARDWARE_BULK = "wireless-super-sim-hardware-bulk" + WIRELESS_SUPER_SIM_SMSCOMMANDS = "wireless-super-sim-smscommands" + WIRELESS_SUPER_SIM_SMSCOMMANDS_AFRICA = "wireless-super-sim-smscommands-africa" + WIRELESS_SUPER_SIM_SMSCOMMANDS_ASIA = "wireless-super-sim-smscommands-asia" + WIRELESS_SUPER_SIM_SMSCOMMANDS_CENT_AND_SOUTH_AMERICA = ( + "wireless-super-sim-smscommands-cent-and-south-america" + ) + WIRELESS_SUPER_SIM_SMSCOMMANDS_EUROPE = "wireless-super-sim-smscommands-europe" + WIRELESS_SUPER_SIM_SMSCOMMANDS_NORTH_AMERICA = ( + "wireless-super-sim-smscommands-north-america" + ) + WIRELESS_SUPER_SIM_SMSCOMMANDS_OCEANIA = ( + "wireless-super-sim-smscommands-oceania" + ) + WIRELESS_SUPER_SIM_SUBSCRIPTION = "wireless-super-sim-subscription" + WIRELESS_SUPER_SIM_SUBSCRIPTION_PAYG = "wireless-super-sim-subscription-payg" WIRELESS_USAGE = "wireless-usage" WIRELESS_USAGE_COMMANDS = "wireless-usage-commands" WIRELESS_USAGE_COMMANDS_AFRICA = "wireless-usage-commands-africa" @@ -342,6 +656,184 @@ class Category(object): WIRELESS_USAGE_MRC_SUSPENDED = "wireless-usage-mrc-suspended" WIRELESS_USAGE_SMS = "wireless-usage-sms" WIRELESS_USAGE_VOICE = "wireless-usage-voice" + A2P_FAST_TRACK_ONBOARDING = "a2p-fast-track-onboarding" + ADVISORY_SERVICES = "advisory-services" + ADVISORY_SERVICES_BILLED = "advisory-services-billed" + ADVISORY_SERVICES_CALL_TRACKING = "advisory-services-call-tracking" + ADVISORY_SERVICES_DATA_SERVICES = "advisory-services-data-services" + ADVISORY_SERVICES_EXPENSES = "advisory-services-expenses" + ADVISORY_SERVICES_SIP_TRUNKING = "advisory-services-sip-trunking" + ASSETS_REQUESTS = "assets-requests" + AUDIENCE_MINUTES_VIDEO = "audience-minutes-video" + AUTHY_BUCKET_ADJUSTMENT = "authy-bucket-adjustment" + AUTHY_SOFTWARE = "authy-software" + CALLERIDLOOKUPS_API = "calleridlookups-api" + CALLERIDLOOKUPS_PROGRAMMABLEVOICE = "calleridlookups-programmablevoice" + CALLERIDLOOKUPS_TRUNKING = "calleridlookups-trunking" + CALLS_TRUNKING_INBOUND_TOLLFREE_LOCAL = "calls-trunking-inbound-tollfree-local" + CALLS_TRUNKING_INBOUND_TOLLFREE_MOBILE = ( + "calls-trunking-inbound-tollfree-mobile" + ) + CHANNELS_WHATSAPP_CONVERSATION_FREE_1 = "channels-whatsapp-conversation-free-1" + CONFERENCE = "conference" + CONVERSATIONAL_INSIGHTS = "conversational-insights" + CONVERSATIONAL_INSIGHTS_MESSAGES = "conversational-insights-messages" + CONVERSATIONAL_INSIGHTS_VOICE_MINUTES = "conversational-insights-voice-minutes" + DEMO = "demo" + DEMO_UC_SCRIPT_TEST = "demo-uc-script-test" + ELASTIC_SIP_TRUNKING = "elastic-sip-trunking" + ELASTIC_SIP_TRUNKING_CALL_TRANSFERS = "elastic-sip-trunking-call-transfers" + ENTERPRISE_HIPPA = "enterprise-hippa" + FLEX_NAMED_USERS = "flex-named-users" + FLEX_SPINSCI = "flex-spinsci" + FLEX_USERS_1 = "flex-users-1" + FLEX_WFO_PREMIUM_SPEECH_ANALYTICS = "flex-wfo-premium-speech-analytics" + FLEX_XCELERATE = "flex-xcelerate" + FUNCTIONS_ROLLUP = "functions-rollup" + IMP_V1_USAGE = "imp-v1-usage" + IP_MESSAGING_ADDONS = "ip-messaging-addons" + IVR = "ivr" + IVR_CONVERSATIONAL = "ivr-conversational" + IVR_DTMF = "ivr-dtmf" + IVR_VIRTUALAGENT = "ivr-virtualagent" + LIVE = "live" + LIVE_MEDIA_RECORDING_MINUTES = "live-media-recording-minutes" + LONGCODE_MPS = "longcode-mps" + MARKETPLACE_ANALYTICS_ADDONS = "marketplace-analytics-addons" + MARKETPLACE_ISV_ADDONS = "marketplace-isv-addons" + MARKETPLACE_MESSAGING_ADDONS = "marketplace-messaging-addons" + MARKETPLACE_PHONENUMBERS_ADDONS = "marketplace-phonenumbers-addons" + MARKETPLACE_RECORDING_ADDONS = "marketplace-recording-addons" + MARKETPLACE_VIRTUALAGENT_ADDONS = "marketplace-virtualagent-addons" + MARKETPLAY_PAY_ADDONS_SHUTTLE_PAY_CONNECTOR_1 = ( + "marketplay-pay-addons-shuttle-pay-connector-1" + ) + MARKETPLAY_PAY_ADDONS_STRIPE_PAY_CONNECTOR = ( + "marketplay-pay-addons-stripe-pay-connector" + ) + MMS_INBOUND_LONGCODE_CANADA = "mms-inbound-longcode-canada" + MMS_INBOUND_LONGCODE_UNITEDSTATES = "mms-inbound-longcode-unitedstates" + MMS_OUTBOUND_LONGCODE_CANADA = "mms-outbound-longcode-canada" + MMS_OUTBOUND_LONGCODE_UNITEDSTATES = "mms-outbound-longcode-unitedstates" + MMS_OUTBOUND_TOLL_FREE = "mms-outbound-toll-free" + NOTIFY_CHATAPPSANDOTHERCHANNELS = "notify-chatappsandotherchannels" + NOTIFY_NOTIFYSERVICES = "notify-notifyservices" + NOTIFY_PUSHNOTIFICATIONS = "notify-pushnotifications" + PAYMENT_GATEWAY_CONNECTORS = "payment-gateway-connectors" + PAYMENT_SOLUTIONS = "payment-solutions" + PCHAT_BUCKET_ADJUSTMENT = "pchat-bucket-adjustment" + PHONENUMBERS_NUMBERS = "phonenumbers-numbers" + PROG_VOICE_CLIENT_ANDROID = "prog-voice-client-android" + PROG_VOICE_CLIENT_ANDROID_INBOUND = "prog-voice-client-android-inbound" + PROG_VOICE_CLIENT_ANDROID_OUTBOUND = "prog-voice-client-android-outbound" + PROG_VOICE_CLIENT_IOS = "prog-voice-client-ios" + PROG_VOICE_CLIENT_IOS_INBOUND = "prog-voice-client-ios-inbound" + PROG_VOICE_CLIENT_IOS_OUTBOUND = "prog-voice-client-ios-outbound" + PROG_VOICE_CLIENT_SDK = "prog-voice-client-sdk" + PROG_VOICE_CLIENT_WEB = "prog-voice-client-web" + PROG_VOICE_CLIENT_WEB_INBOUND = "prog-voice-client-web-inbound" + PROG_VOICE_CLIENT_WEB_OUTBOUND = "prog-voice-client-web-outbound" + PROGRAMMABLEVOICECONNECTIVITY_MEDIA_STREAMS = ( + "programmablevoiceconnectivity-media-streams" + ) + PSTNCONNECTIVITY_BYOC = "pstnconnectivity-byoc" + PSTNCONNECTIVITY_EMERGENCY = "pstnconnectivity-emergency" + PSTNCONNECTIVITY_MINUTES = "pstnconnectivity-minutes" + PSTNCONNECTIVITY_MINUTES_1 = "pstnconnectivity-minutes-1" + PSTNCONNECTIVITY_MINUTESINBOUNDLOCAL = "pstnconnectivity-minutesinboundlocal" + PSTNCONNECTIVITY_MINUTESINBOUNDMOBILE = "pstnconnectivity-minutesinboundmobile" + PSTNCONNECTIVITY_MINUTESINBOUNDTOLLFREE = ( + "pstnconnectivity-minutesinboundtollfree" + ) + PSTNCONNECTIVITY_MINUTESINBOUNDTOLLFREELOCAL = ( + "pstnconnectivity-minutesinboundtollfreelocal" + ) + PSTNCONNECTIVITY_MINUTESINBOUNDTOLLFREEMOBILE = ( + "pstnconnectivity-minutesinboundtollfreemobile" + ) + PV_ROOM_HOURS = "pv-room-hours" + PV_ROOM_SIMULTANEOUS_PARTICIPANT_CONNECTIONS = ( + "pv-room-simultaneous-participant-connections" + ) + PVIDEO_ROOM_HOURS_AU1 = "pvideo-room-hours-au1" + PVIDEO_ROOM_HOURS_BR1 = "pvideo-room-hours-br1" + PVIDEO_ROOM_HOURS_IE1 = "pvideo-room-hours-ie1" + PVIDEO_ROOM_HOURS_JP1 = "pvideo-room-hours-jp1" + PVIDEO_ROOM_HOURS_SG1 = "pvideo-room-hours-sg1" + PVIDEO_ROOM_HOURS_US1 = "pvideo-room-hours-us1" + PVIDEO_ROOM_HOURS_US2 = "pvideo-room-hours-us2" + RECORDINGS_ENCRYPTED = "recordings-encrypted" + SHORT_CODE_SETUP_FEES = "short-code-setup-fees" + SHORTCODES_MESSAGES_INBOUND = "shortcodes-messages-inbound" + SHORTCODES_MESSAGES_OUTBOUND = "shortcodes-messages-outbound" + SMS_MESSAGES_REGISTRATIONFEES = "sms-messages-registrationfees" + SMS_MMS_PENALTY_FEES = "sms-mms-penalty-fees" + SMS_MMS_PENALTY_FEES_1 = "sms-mms-penalty-fees-1" + SMS_PUMPING_PROTECTION_NON_USCA = "sms-pumping-protection-non-usca" + SMS_PUMPING_PROTECTION_USCA = "sms-pumping-protection-usca" + STUDIO = "studio" + STUDIO_MONTHLY_FEES = "studio-monthly-fees" + SUPERSIM = "supersim" + TASK_ROUTER = "task-router" + TASK_ROUTER_WORKERS = "task-router-workers" + TEST_QUOTA_BUCKETS = "test-quota-buckets" + TEST_UC_SCRIPT_1 = "test-uc-script-1" + TEST_UC_SCRIPT_DEMO_2 = "test-uc-script-demo-2" + TEXT_TO_SPEECH = "text-to-speech" + TME = "tme" + TTS_BASIC = "tts-basic" + TWILIO_EDITIONS = "twilio-editions" + TWILIO_INTERCONNECT_CALIFORNIA = "twilio-interconnect-california" + TWILIO_INTERCONNECT_CALIFORNIA_MONTHLY = ( + "twilio-interconnect-california-monthly" + ) + TWILIO_INTERCONNECT_CALIFORNIA_SETUP = "twilio-interconnect-california-setup" + TWILIO_INTERCONNECT_FRANKFURT = "twilio-interconnect-frankfurt" + TWILIO_INTERCONNECT_FRANKFURT_MO = "twilio-interconnect-frankfurt-mo" + TWILIO_INTERCONNECT_FRANKFURT_SETUP = "twilio-interconnect-frankfurt-setup" + TWILIO_INTERCONNECT_LONDON = "twilio-interconnect-london" + TWILIO_INTERCONNECT_LONDON_MO = "twilio-interconnect-london-mo" + TWILIO_INTERCONNECT_LONDON_SETUP = "twilio-interconnect-london-setup" + TWILIO_INTERCONNECT_SAO_PAULO = "twilio-interconnect-sao-paulo" + TWILIO_INTERCONNECT_SAO_PAULO_MONTHLY = "twilio-interconnect-sao-paulo-monthly" + TWILIO_INTERCONNECT_SAO_PAULO_SETUP = "twilio-interconnect-sao-paulo-setup" + TWILIO_INTERCONNECT_SINGAPORE = "twilio-interconnect-singapore" + TWILIO_INTERCONNECT_SINGAPORE_MO = "twilio-interconnect-singapore-mo" + TWILIO_INTERCONNECT_SINGAPORE_SETUP = "twilio-interconnect-singapore-setup" + TWILIO_INTERCONNECT_SYDNEY = "twilio-interconnect-sydney" + TWILIO_INTERCONNECT_SYDNEY_MO = "twilio-interconnect-sydney-mo" + TWILIO_INTERCONNECT_SYDNEY_SETUP = "twilio-interconnect-sydney-setup" + TWILIO_INTERCONNECT_TOKYO = "twilio-interconnect-tokyo" + TWILIO_INTERCONNECT_TOKYO_MO = "twilio-interconnect-tokyo-mo" + TWILIO_INTERCONNECT_TOKYO_SETUP = "twilio-interconnect-tokyo-setup" + TWILIO_INTERCONNECT_VA = "twilio-interconnect-va" + TWILIO_INTERCONNECT_VA_MO = "twilio-interconnect-va-mo" + TWILIO_INTERCONNECT_VA_SETUP = "twilio-interconnect-va-setup" + TWIML_VERBS = "twiml-verbs" + TWIML_VERBS_SAY = "twiml-verbs-say" + USAGE_PROGRAMMABLE_MESSAGING_ENGAGEMENT_SUITE = ( + "usage-programmable-messaging-engagement-suite" + ) + USAGE_PROGRAMMABLE_MESSAGING_FEES_SERVICES = ( + "usage-programmable-messaging-fees-services" + ) + VERIFY_OUTBOUND_EMAIL = "verify-outbound-email" + VERIFY_PACKAGED_PLANS = "verify-packaged-plans" + VERIFY_SILENT_NETWORK_AUTH = "verify-silent-network-auth" + VERIFY_VOICE_AND_SMS = "verify-voice-and-sms" + VOICE_INSIGHTS_CLIENT_INSIGHTS_MONTHY_COMMIT = ( + "voice-insights-client-insights-monthy-commit" + ) + WIRELESS_DATA_PAYG_ASIA_AFG = "wireless-data-payg-asia-afg" + WIRELESS_MULTI_IMSI_SIM_COMMANDS = "wireless-multi-imsi-sim-commands" + WIRELESS_MULTI_IMSI_SIM_COMMANDS_USA = "wireless-multi-imsi-sim-commands-usa" + WIRELESS_MULTI_IMSI_SIM_DATA = "wireless-multi-imsi-sim-data" + WIRELESS_MULTI_IMSI_SIM_DATA_EU28 = "wireless-multi-imsi-sim-data-eu28" + WIRELESS_MULTI_IMSI_SIM_DATA_USA = "wireless-multi-imsi-sim-data-usa" + WIRELESS_MULTI_IMSI_SIM_MONTHLY_FEES = "wireless-multi-imsi-sim-monthly-fees" + WIRELESS_MULTI_IMSI_SIM_USAGE = "wireless-multi-imsi-sim-usage" + WIRELESS_SUPER_SIM_DATA_NORTH_AMERICA = "wireless-super-sim-data-north-america" + WIRELESS_SUPER_SIM_USAGE = "wireless-super-sim-usage" """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that accrued the usage. @@ -401,6 +893,7 @@ def __repr__(self) -> str: class YesterdayPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> YesterdayInstance: """ Build an instance of YesterdayInstance @@ -421,6 +914,7 @@ def __repr__(self) -> str: class YesterdayList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the YesterdayList @@ -623,14 +1117,20 @@ def page( "Category": category, "StartDate": serialize.iso8601_date(start_date), "EndDate": serialize.iso8601_date(end_date), - "IncludeSubaccounts": include_subaccounts, + "IncludeSubaccounts": serialize.boolean_to_string(include_subaccounts), "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 YesterdayPage(self._version, response, self._solution) async def page_async( @@ -662,15 +1162,19 @@ async def page_async( "Category": category, "StartDate": serialize.iso8601_date(start_date), "EndDate": serialize.iso8601_date(end_date), - "IncludeSubaccounts": include_subaccounts, + "IncludeSubaccounts": serialize.boolean_to_string(include_subaccounts), "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 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 9a5654b3c8..7f182a01b3 100644 --- a/twilio/rest/api/v2010/account/usage/trigger.py +++ b/twilio/rest/api/v2010/account/usage/trigger.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class TriggerInstance(InstanceResource): + class Recurring(object): DAILY = "daily" MONTHLY = "monthly" @@ -36,33 +36,101 @@ class TriggerField(object): PRICE = "price" class UsageCategory(object): + A2P_10DLC_REGISTRATIONFEES_BRANDREGISTRATION = ( + "a2p-10dlc-registrationfees-brandregistration" + ) + A2P_10DLC_REGISTRATIONFEES_BV = "a2p-10dlc-registrationfees-bv" + A2P_10DLC_REGISTRATIONFEES_CAMPAIGNCHARGES = ( + "a2p-10dlc-registrationfees-campaigncharges" + ) + A2P_10DLC_REGISTRATIONFEES_CAMPAIGNREGISTRATION = ( + "a2p-10dlc-registrationfees-campaignregistration" + ) + A2P_10DLC_REGISTRATIONFEES_CAMPAIGNVETTING = ( + "a2p-10dlc-registrationfees-campaignvetting" + ) + A2P_10DLC_REGISTRATIONFEES_MONTHLY = "a2p-10dlc-registrationfees-monthly" + A2P_10DLC_REGISTRATIONFEES_ONETIME = "a2p-10dlc-registrationfees-onetime" A2P_REGISTRATION_FEES = "a2p-registration-fees" + ACCOUNT_SECURITY = "account-security" AGENT_CONFERENCE = "agent-conference" + AGENT_COPILOT = "agent-copilot" + AGENT_COPILOT_MESSAGES = "agent-copilot-messages" + AGENT_COPILOT_PARTICIPANT_MINUTES = "agent-copilot-participant-minutes" + AI_ASSISTANTS = "ai-assistants" + AI_ASSISTANTS_VOICE = "ai-assistants-voice" AMAZON_POLLY = "amazon-polly" ANSWERING_MACHINE_DETECTION = "answering-machine-detection" + ASSETS = "assets" + AUDIENCE_MINUTES = "audience-minutes" + AUDIENCE_MINUTES_AUDIO = "audience-minutes-audio" AUTHY_AUTHENTICATIONS = "authy-authentications" AUTHY_CALLS_OUTBOUND = "authy-calls-outbound" + AUTHY_EMAIL_AUTHENTICATIONS = "authy-email-authentications" AUTHY_MONTHLY_FEES = "authy-monthly-fees" + AUTHY_OUTBOUND_EMAIL = "authy-outbound-email" AUTHY_PHONE_INTELLIGENCE = "authy-phone-intelligence" AUTHY_PHONE_VERIFICATIONS = "authy-phone-verifications" AUTHY_SMS_OUTBOUND = "authy-sms-outbound" + AUTHY_VERIFY_EMAIL_VERIFICATIONS = "authy-verify-email-verifications" + AUTHY_VERIFY_OUTBOUND_EMAIL = "authy-verify-outbound-email" + AUTOPILOT = "autopilot" + AUTOPILOT_HOME_ASSISTANTS = "autopilot-home-assistants" + AUTOPILOT_MESSAGING = "autopilot-messaging" + AUTOPILOT_OTHER = "autopilot-other" + AUTOPILOT_VOICE = "autopilot-voice" + BASIC_PEER_TO_PEER_ROOMS_PARTICIPANT_MINUTES = ( + "basic-peer-to-peer-rooms-participant-minutes" + ) + BRANDED_CALLING = "branded-calling" + BUNDLE_SMS_BUCKET = "bundle-sms-bucket" + BUNDLE_SUBSCRIPTION_FEES = "bundle-subscription-fees" + CALL_FORWARDING_LOOKUPS = "call-forwarding-lookups" CALL_PROGESS_EVENTS = "call-progess-events" CALLERIDLOOKUPS = "calleridlookups" CALLS = "calls" CALLS_CLIENT = "calls-client" + CALLS_EMERGENCY = "calls-emergency" CALLS_GLOBALCONFERENCE = "calls-globalconference" CALLS_INBOUND = "calls-inbound" CALLS_INBOUND_LOCAL = "calls-inbound-local" CALLS_INBOUND_MOBILE = "calls-inbound-mobile" CALLS_INBOUND_TOLLFREE = "calls-inbound-tollfree" + CALLS_INBOUND_TOLLFREE_LOCAL = "calls-inbound-tollfree-local" + CALLS_INBOUND_TOLLFREE_MOBILE = "calls-inbound-tollfree-mobile" + CALLS_MEDIA_STREAM_MINUTES = "calls-media-stream-minutes" CALLS_OUTBOUND = "calls-outbound" CALLS_PAY_VERB_TRANSACTIONS = "calls-pay-verb-transactions" CALLS_RECORDINGS = "calls-recordings" CALLS_SIP = "calls-sip" CALLS_SIP_INBOUND = "calls-sip-inbound" CALLS_SIP_OUTBOUND = "calls-sip-outbound" + CALLS_TEXT_TO_SPEECH = "calls-text-to-speech" CALLS_TRANSFERS = "calls-transfers" CARRIER_LOOKUPS = "carrier-lookups" + CATEGORY = "category" + CHANNELS = "channels" + CHANNELS_MESSAGING = "channels-messaging" + CHANNELS_MESSAGING_INBOUND = "channels-messaging-inbound" + CHANNELS_MESSAGING_OUTBOUND = "channels-messaging-outbound" + CHANNELS_WHATSAPP = "channels-whatsapp" + CHANNELS_WHATSAPP_CONVERSATION_AUTHENTICATION = ( + "channels-whatsapp-conversation-authentication" + ) + CHANNELS_WHATSAPP_CONVERSATION_FREE = "channels-whatsapp-conversation-free" + CHANNELS_WHATSAPP_CONVERSATION_MARKETING = ( + "channels-whatsapp-conversation-marketing" + ) + CHANNELS_WHATSAPP_CONVERSATION_SERVICE = ( + "channels-whatsapp-conversation-service" + ) + CHANNELS_WHATSAPP_CONVERSATION_UTILITY = ( + "channels-whatsapp-conversation-utility" + ) + CHANNELS_WHATSAPP_INBOUND = "channels-whatsapp-inbound" + CHANNELS_WHATSAPP_OUTBOUND = "channels-whatsapp-outbound" + CHAT_VIRTUAL_AGENT = "chat-virtual-agent" + CONVERSATION_RELAY = "conversation-relay" CONVERSATIONS = "conversations" CONVERSATIONS_API_REQUESTS = "conversations-api-requests" CONVERSATIONS_CONVERSATION_EVENTS = "conversations-conversation-events" @@ -71,8 +139,40 @@ class UsageCategory(object): CONVERSATIONS_PARTICIPANT_EVENTS = "conversations-participant-events" CONVERSATIONS_PARTICIPANTS = "conversations-participants" CPS = "cps" + CREDIT_TRANSFER = "credit-transfer" + EMAIL = "email" + EMERGING_TECH = "emerging-tech" + ENGAGEMENT_SUITE_PACKAGED_PLANS = "engagement-suite-packaged-plans" + ENHANCED_LINE_TYPE_LOOKUPS = "enhanced-line-type-lookups" + ENTERPRISE = "enterprise" + EVENTS = "events" + EXPERIMENT_FRANCE_SMS = "experiment-france-sms" + EXPERIMENT_INDIA_SMS = "experiment-india-sms" + EXPERIMENT_UK_SMS = "experiment-uk-sms" + FAILED_MESSAGE_PROCESSING_FEE = "failed-message-processing-fee" + FLEX = "flex" + FLEX_ACTIVE_USER_HOURS = "flex-active-user-hours" + FLEX_CONCURRENT_USERS = "flex-concurrent-users" + FLEX_CONVERSATIONAL_INSIGHTS = "flex-conversational-insights" + FLEX_CONVERSATIONAL_INSIGHTS_MESSAGES = "flex-conversational-insights-messages" + FLEX_CONVERSATIONAL_INSIGHTS_VOICE_MINUTES = ( + "flex-conversational-insights-voice-minutes" + ) + FLEX_EMAIL_USAGE = "flex-email-usage" + FLEX_MESSAGING_USAGE = "flex-messaging-usage" + FLEX_PARTNER_SPINSCI = "flex-partner-spinsci" + FLEX_PARTNER_XCELERATE = "flex-partner-xcelerate" + FLEX_RESELLER_ECOSYSTEM = "flex-reseller-ecosystem" + FLEX_UNIQUE_USER = "flex-unique-user" FLEX_USAGE = "flex-usage" + FLEX_USERS = "flex-users" + FLEX_VOICE_MINUTE = "flex-voice-minute" + FLEX_YTICA = "flex-ytica" FRAUD_LOOKUPS = "fraud-lookups" + FRONTLINE = "frontline" + FRONTLINE_USERS = "frontline-users" + FUNCTIONS = "functions" + GENERIC_PAY_TRANSACTIONS = "generic-pay-transactions" GROUP_ROOMS = "group-rooms" GROUP_ROOMS_DATA_TRACK = "group-rooms-data-track" GROUP_ROOMS_ENCRYPTED_MEDIA_RECORDED = "group-rooms-encrypted-media-recorded" @@ -82,7 +182,17 @@ class UsageCategory(object): GROUP_ROOMS_MEDIA_STORED = "group-rooms-media-stored" GROUP_ROOMS_PARTICIPANT_MINUTES = "group-rooms-participant-minutes" GROUP_ROOMS_RECORDED_MINUTES = "group-rooms-recorded-minutes" - IMP_V1_USAGE = "imp-v1-usage" + IP_MESSAGING = "ip-messaging" + IP_MESSAGING_COMMANDS = "ip-messaging-commands" + IP_MESSAGING_DATA_STORAGE = "ip-messaging-data-storage" + IP_MESSAGING_DATA_TRANSFER = "ip-messaging-data-transfer" + IP_MESSAGING_ENDPOINT_CONNECTIVITY = "ip-messaging-endpoint-connectivity" + IVR_VIRTUAL_AGENT_CUSTOM_VOICES = "ivr-virtual-agent-custom-voices" + IVR_VIRTUAL_AGENT_GENAI = "ivr-virtual-agent-genai" + LINE_STATUS_LOOKUPS = "line-status-lookups" + LIVE_ACTIVITY_LOOKUPS = "live-activity-lookups" + LOOKUP_BUCKET_ADJUSTMENT = "lookup-bucket-adjustment" + LOOKUP_IDENTITY_MATCH = "lookup-identity-match" LOOKUPS = "lookups" MARKETPLACE = "marketplace" MARKETPLACE_ALGORITHMIA_NAMED_ENTITY_RECOGNITION = ( @@ -93,6 +203,13 @@ class UsageCategory(object): MARKETPLACE_CAPIO_SPEECH_TO_TEXT = "marketplace-capio-speech-to-text" MARKETPLACE_CONVRIZA_ABABA = "marketplace-convriza-ababa" MARKETPLACE_DEEPGRAM_PHRASE_DETECTOR = "marketplace-deepgram-phrase-detector" + MARKETPLACE_DEEPGRAM_TRANSCRIPTION = "marketplace-deepgram-transcription" + MARKETPLACE_DEEPGRAM_TRANSCRIPTION_BASE = ( + "marketplace-deepgram-transcription-base" + ) + MARKETPLACE_DEEPGRAM_TRANSSCRIPTION_ENHANCED = ( + "marketplace-deepgram-transscription-enhanced" + ) MARKETPLACE_DIGITAL_SEGMENT_BUSINESS_INFO = ( "marketplace-digital-segment-business-info" ) @@ -118,6 +235,9 @@ class UsageCategory(object): "marketplace-keen-io-contact-center-analytics" ) MARKETPLACE_MARCHEX_CLEANCALL = "marketplace-marchex-cleancall" + MARKETPLACE_MARCHEX_RECORDING_ANALYSIS = ( + "marketplace-marchex-recording-analysis" + ) MARKETPLACE_MARCHEX_SENTIMENT_ANALYSIS_FOR_SMS = ( "marketplace-marchex-sentiment-analysis-for-sms" ) @@ -134,14 +254,42 @@ class UsageCategory(object): "marketplace-nextcaller-advanced-caller-identification" ) MARKETPLACE_NOMOROBO_SPAM_SCORE = "marketplace-nomorobo-spam-score" + MARKETPLACE_PAY_ADDONS = "marketplace-pay-addons" + MARKETPLACE_PAY_ADDONS_BASECOMMERCE_PAY_CONNECTOR = ( + "marketplace-pay-addons-basecommerce-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_BRAINTREE_PAY_CONNECTOR = ( + "marketplace-pay-addons-braintree-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_CARDCONNECT_PAY_CONNECTOR = ( + "marketplace-pay-addons-cardconnect-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_CHASE_PAY_CONNECTOR = ( + "marketplace-pay-addons-chase-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_SHUTTLE_PAY_CONNECTOR = ( + "marketplace-pay-addons-shuttle-pay-connector" + ) + MARKETPLACE_PAY_ADDONS_STRIPE_PAY_CONNECTOR = ( + "marketplace-pay-addons-stripe-pay-connector" + ) MARKETPLACE_PAYFONE_TCPA_COMPLIANCE = "marketplace-payfone-tcpa-compliance" + MARKETPLACE_POLY_AI_CONNECTOR = "marketplace-poly-ai-connector" + MARKETPLACE_REALPHONEVALIDATION = "marketplace-realphonevalidation" MARKETPLACE_REMEETING_AUTOMATIC_SPEECH_RECOGNITION = ( "marketplace-remeeting-automatic-speech-recognition" ) + MARKETPLACE_SPOKE_PHONE_LICENSE_PRO = "marketplace-spoke-phone-license-pro" + MARKETPLACE_SPOKE_PHONE_LICENSE_STANDARD = ( + "marketplace-spoke-phone-license-standard" + ) MARKETPLACE_TCPA_DEFENSE_SOLUTIONS_BLACKLIST_FEED = ( "marketplace-tcpa-defense-solutions-blacklist-feed" ) MARKETPLACE_TELO_OPENCNAM = "marketplace-telo-opencnam" + MARKETPLACE_TRESTLE_SOLUTIONS_CALLER_IDENTIFICATION = ( + "marketplace-trestle-solutions-caller-identification" + ) MARKETPLACE_TRUECNAM_TRUE_SPAM = "marketplace-truecnam-true-spam" MARKETPLACE_TWILIO_CALLER_NAME_LOOKUP_US = ( "marketplace-twilio-caller-name-lookup-us" @@ -154,6 +302,9 @@ class UsageCategory(object): MARKETPLACE_VOICEBASE_TRANSCRIPTION_CUSTOM_VOCABULARY = ( "marketplace-voicebase-transcription-custom-vocabulary" ) + MARKETPLACE_WEB_PURIFY_PROFANITY_FILTER = ( + "marketplace-web-purify-profanity-filter" + ) MARKETPLACE_WHITEPAGES_PRO_CALLER_IDENTIFICATION = ( "marketplace-whitepages-pro-caller-identification" ) @@ -168,15 +319,23 @@ class UsageCategory(object): MARKETPLACE_YTICA_CONTACT_CENTER_REPORTING_ANALYTICS = ( "marketplace-ytica-contact-center-reporting-analytics" ) + MARKETPLAY_PAY_ADDONS_SHUTTLE_PAY_CONNECTOR = ( + "marketplay-pay-addons-shuttle-pay-connector" + ) + MEDIA_COMPOSER_MINUTES = "media-composer-minutes" MEDIASTORAGE = "mediastorage" + MIN_SPEND_ADJUSTMENTS = "min-spend-adjustments" MMS = "mms" MMS_INBOUND = "mms-inbound" MMS_INBOUND_LONGCODE = "mms-inbound-longcode" MMS_INBOUND_SHORTCODE = "mms-inbound-shortcode" + MMS_INBOUND_TOLL_FREE = "mms-inbound-toll-free" MMS_MESSAGES_CARRIERFEES = "mms-messages-carrierfees" MMS_OUTBOUND = "mms-outbound" MMS_OUTBOUND_LONGCODE = "mms-outbound-longcode" MMS_OUTBOUND_SHORTCODE = "mms-outbound-shortcode" + MMS_OUTBOUND_TOLLFREE = "mms-outbound-tollfree" + MONITOR = "monitor" MONITOR_READS = "monitor-reads" MONITOR_STORAGE = "monitor-storage" MONITOR_WRITES = "monitor-writes" @@ -185,6 +344,12 @@ class UsageCategory(object): NOTIFY_CHANNELS = "notify-channels" NUMBER_FORMAT_LOOKUPS = "number-format-lookups" PCHAT = "pchat" + PCHAT_ACTIONS = "pchat-actions" + PCHAT_APS = "pchat-aps" + PCHAT_CONV_MED_STORAGE = "pchat-conv-med-storage" + PCHAT_MESSAGES = "pchat-messages" + PCHAT_NOTIFICATIONS = "pchat-notifications" + PCHAT_READS = "pchat-reads" PCHAT_USERS = "pchat-users" PEER_TO_PEER_ROOMS_PARTICIPANT_MINUTES = ( "peer-to-peer-rooms-participant-minutes" @@ -194,18 +359,41 @@ class UsageCategory(object): PFAX_MINUTES_INBOUND = "pfax-minutes-inbound" PFAX_MINUTES_OUTBOUND = "pfax-minutes-outbound" PFAX_PAGES = "pfax-pages" + PHONE_QUALITY_SCORE_LOOKUPS = "phone-quality-score-lookups" PHONENUMBERS = "phonenumbers" PHONENUMBERS_CPS = "phonenumbers-cps" PHONENUMBERS_EMERGENCY = "phonenumbers-emergency" PHONENUMBERS_LOCAL = "phonenumbers-local" PHONENUMBERS_MOBILE = "phonenumbers-mobile" + PHONENUMBERS_PORTING = "phonenumbers-porting" PHONENUMBERS_SETUPS = "phonenumbers-setups" PHONENUMBERS_TOLLFREE = "phonenumbers-tollfree" PREMIUMSUPPORT = "premiumsupport" + PREMIUMSUPPORT_PERCENTAGE_SPEND = "premiumsupport-percentage-spend" + PROGRAMMABLEVOICE_PLATFORM = "programmablevoice-platform" + PROGRAMMABLEVOICECONN_CLIENTSDK = "programmablevoiceconn-clientsdk" + PROGRAMMABLEVOICECONN_CLIENTSDK_INBOUND = ( + "programmablevoiceconn-clientsdk-inbound" + ) + PROGRAMMABLEVOICECONN_CLIENTSDK_OUTBOUND = ( + "programmablevoiceconn-clientsdk-outbound" + ) + PROGRAMMABLEVOICECONN_ONNET = "programmablevoiceconn-onnet" + PROGRAMMABLEVOICECONN_ONNET_INBOUND = "programmablevoiceconn-onnet-inbound" + PROGRAMMABLEVOICECONN_ONNET_OUTBOUND = "programmablevoiceconn-onnet-outbound" + PROGRAMMABLEVOICECONN_SIP = "programmablevoiceconn-sip" + PROGRAMMABLEVOICECONN_SIP_INBOUND = "programmablevoiceconn-sip-inbound" + PROGRAMMABLEVOICECONN_SIP_OUTBOUND = "programmablevoiceconn-sip-outbound" + PROGRAMMABLEVOICECONNECTIVITY = "programmablevoiceconnectivity" PROXY = "proxy" PROXY_ACTIVE_SESSIONS = "proxy-active-sessions" + PROXY_BUCKET_ADJUSTMENT = "proxy-bucket-adjustment" + PROXY_LICENSES = "proxy-licenses" PSTNCONNECTIVITY = "pstnconnectivity" + PSTNCONNECTIVITY_INBOUND = "pstnconnectivity-inbound" + PSTNCONNECTIVITY_OUTBOUND = "pstnconnectivity-outbound" PV = "pv" + PV_BASIC_ROOMS = "pv-basic-rooms" PV_COMPOSITION_MEDIA_DOWNLOADED = "pv-composition-media-downloaded" PV_COMPOSITION_MEDIA_ENCRYPTED = "pv-composition-media-encrypted" PV_COMPOSITION_MEDIA_STORED = "pv-composition-media-stored" @@ -221,18 +409,20 @@ class UsageCategory(object): PV_ROOM_PARTICIPANTS_US2 = "pv-room-participants-us2" PV_ROOMS = "pv-rooms" PV_SIP_ENDPOINT_REGISTRATIONS = "pv-sip-endpoint-registrations" + RCS_MESSAGES = "rcs-messages" + REASSIGNED_NUMBER = "reassigned-number" RECORDINGS = "recordings" RECORDINGSTORAGE = "recordingstorage" - ROOMS_GROUP_BANDWIDTH = "rooms-group-bandwidth" - ROOMS_GROUP_MINUTES = "rooms-group-minutes" - ROOMS_PEER_TO_PEER_MINUTES = "rooms-peer-to-peer-minutes" SHORTCODES = "shortcodes" SHORTCODES_CUSTOMEROWNED = "shortcodes-customerowned" SHORTCODES_MMS_ENABLEMENT = "shortcodes-mms-enablement" SHORTCODES_MPS = "shortcodes-mps" SHORTCODES_RANDOM = "shortcodes-random" + SHORTCODES_SETUP_FEES = "shortcodes-setup-fees" SHORTCODES_UK = "shortcodes-uk" SHORTCODES_VANITY = "shortcodes-vanity" + SIM_SWAP_LOOKUPS = "sim-swap-lookups" + SIP_SECURE_MEDIA = "sip-secure-media" SMALL_GROUP_ROOMS = "small-group-rooms" SMALL_GROUP_ROOMS_DATA_TRACK = "small-group-rooms-data-track" SMALL_GROUP_ROOMS_PARTICIPANT_MINUTES = "small-group-rooms-participant-minutes" @@ -240,13 +430,30 @@ class UsageCategory(object): SMS_INBOUND = "sms-inbound" SMS_INBOUND_LONGCODE = "sms-inbound-longcode" SMS_INBOUND_SHORTCODE = "sms-inbound-shortcode" + SMS_INBOUND_TOLLFREE = "sms-inbound-tollfree" SMS_MESSAGES_CARRIERFEES = "sms-messages-carrierfees" SMS_MESSAGES_FEATURES = "sms-messages-features" + SMS_MESSAGES_FEATURES_ENGAGEMENT_SUITE = ( + "sms-messages-features-engagement-suite" + ) + SMS_MESSAGES_FEATURES_MESSAGE_REDACTION = ( + "sms-messages-features-message-redaction" + ) SMS_MESSAGES_FEATURES_SENDERID = "sms-messages-features-senderid" + SMS_MPS = "sms-mps" + SMS_MPS_SHORTCODE = "sms-mps-shortcode" + SMS_MPS_TOLLFREE = "sms-mps-tollfree" + SMS_MPS_TOLLFREE_SETUP = "sms-mps-tollfree-setup" + SMS_NATIONAL_REGULATORY_PROTECTION = "sms-national-regulatory-protection" SMS_OUTBOUND = "sms-outbound" SMS_OUTBOUND_CONTENT_INSPECTION = "sms-outbound-content-inspection" SMS_OUTBOUND_LONGCODE = "sms-outbound-longcode" SMS_OUTBOUND_SHORTCODE = "sms-outbound-shortcode" + SMS_OUTBOUND_TOLLFREE = "sms-outbound-tollfree" + SMS_PUMPING_PROTECTION = "sms-pumping-protection" + SMS_PUMPING_RISK = "sms-pumping-risk" + SMSMESSAGES_BUCKET_ADJUSTMENTS = "smsmessages-bucket-adjustments" + SMSMESSAGES_OUTBOUND_DOMESTIC = "smsmessages-outbound-domestic" SPEECH_RECOGNITION = "speech-recognition" STUDIO_ENGAGEMENTS = "studio-engagements" SYNC = "sync" @@ -265,6 +472,7 @@ class UsageCategory(object): TRUNKING_RECORDINGS = "trunking-recordings" TRUNKING_SECURE = "trunking-secure" TRUNKING_TERMINATION = "trunking-termination" + TTS_GOOGLE = "tts-google" TURNMEGABYTES = "turnmegabytes" TURNMEGABYTES_AUSTRALIA = "turnmegabytes-australia" TURNMEGABYTES_BRASIL = "turnmegabytes-brasil" @@ -275,13 +483,27 @@ class UsageCategory(object): TURNMEGABYTES_SINGAPORE = "turnmegabytes-singapore" TURNMEGABYTES_USEAST = "turnmegabytes-useast" TURNMEGABYTES_USWEST = "turnmegabytes-uswest" + TWILIO_FOR_SALESFORCE = "twilio-for-salesforce" + TWILIO_FOR_SALESFORCE_LICENSES = "twilio-for-salesforce-licenses" TWILIO_INTERCONNECT = "twilio-interconnect" + TWIML = "twiml" + USAGE_FLEX_VIDEO = "usage-flex-video" + USAGE_FUNCTIONS = "usage-functions" + USAGE_RCS_BASIC_MESSAGES_OUTBOUND = "usage-rcs-basic-messages-outbound" + USAGE_RCS_MESSAGES = "usage-rcs-messages" + USAGE_RCS_MESSAGES_INBOUND = "usage-rcs-messages-inbound" + USAGE_RCS_MESSAGING_CARRIER_FEES = "usage-rcs-messaging-carrier-fees" + USAGE_RCS_SINGLE_MESSAGES_OUTBOUND = "usage-rcs-single-messages-outbound" + VERIFY_PACKAGE_PLANS = "verify-package-plans" VERIFY_PUSH = "verify-push" + VERIFY_SNA = "verify-sna" VERIFY_TOTP = "verify-totp" + VERIFY_VOICE_SMS = "verify-voice-sms" VERIFY_WHATSAPP_CONVERSATIONS_BUSINESS_INITIATED = ( "verify-whatsapp-conversations-business-initiated" ) VIDEO_RECORDINGS = "video-recordings" + VIDEO_ROOMS_TURN_MEGABYTES = "video-rooms-turn-megabytes" VIRTUAL_AGENT = "virtual-agent" VOICE_INSIGHTS = "voice-insights" VOICE_INSIGHTS_CLIENT_INSIGHTS_ON_DEMAND_MINUTE = ( @@ -296,12 +518,104 @@ class UsageCategory(object): VOICE_INSIGHTS_SIP_TRUNKING_INSIGHTS_ON_DEMAND_MINUTE = ( "voice-insights-sip-trunking-insights-on-demand-minute" ) + VOICE_INTELLIGENCE = "voice-intelligence" + VOICE_INTELLIGENCE_EIP_OPERATORS = "voice-intelligence-eip-operators" + VOICE_INTELLIGENCE_OPERATORS = "voice-intelligence-operators" + VOICE_INTELLIGENCE_TRANSCRIPTION = "voice-intelligence-transcription" + WDS = "wds" WIRELESS = "wireless" + WIRELESS_DATA = "wireless-data" + WIRELESS_DATA_PAYG = "wireless-data-payg" + WIRELESS_DATA_PAYG_AFRICA = "wireless-data-payg-africa" + WIRELESS_DATA_PAYG_ASIA = "wireless-data-payg-asia" + WIRELESS_DATA_PAYG_CENTRALANDSOUTHAMERICA = ( + "wireless-data-payg-centralandsouthamerica" + ) + WIRELESS_DATA_PAYG_EUROPE = "wireless-data-payg-europe" + WIRELESS_DATA_PAYG_NORTHAMERICA = "wireless-data-payg-northamerica" + WIRELESS_DATA_PAYG_OCEANIA = "wireless-data-payg-oceania" + WIRELESS_DATA_QUOTA1 = "wireless-data-quota1" + WIRELESS_DATA_QUOTA1_AFRICA = "wireless-data-quota1-africa" + WIRELESS_DATA_QUOTA1_ASIA = "wireless-data-quota1-asia" + WIRELESS_DATA_QUOTA1_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quota1-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTA1_EUROPE = "wireless-data-quota1-europe" + WIRELESS_DATA_QUOTA1_NORTHAMERICA = "wireless-data-quota1-northamerica" + WIRELESS_DATA_QUOTA1_OCEANIA = "wireless-data-quota1-oceania" + WIRELESS_DATA_QUOTA10 = "wireless-data-quota10" + WIRELESS_DATA_QUOTA10_AFRICA = "wireless-data-quota10-africa" + WIRELESS_DATA_QUOTA10_ASIA = "wireless-data-quota10-asia" + WIRELESS_DATA_QUOTA10_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quota10-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTA10_EUROPE = "wireless-data-quota10-europe" + WIRELESS_DATA_QUOTA10_NORTHAMERICA = "wireless-data-quota10-northamerica" + WIRELESS_DATA_QUOTA10_OCEANIA = "wireless-data-quota10-oceania" + WIRELESS_DATA_QUOTA50 = "wireless-data-quota50" + WIRELESS_DATA_QUOTA50_AFRICA = "wireless-data-quota50-africa" + WIRELESS_DATA_QUOTA50_ASIA = "wireless-data-quota50-asia" + WIRELESS_DATA_QUOTA50_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quota50-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTA50_EUROPE = "wireless-data-quota50-europe" + WIRELESS_DATA_QUOTA50_NORTHAMERICA = "wireless-data-quota50-northamerica" + WIRELESS_DATA_QUOTA50_OCEANIA = "wireless-data-quota50-oceania" + WIRELESS_DATA_QUOTACUSTOM = "wireless-data-quotacustom" + WIRELESS_DATA_QUOTACUSTOM_AFRICA = "wireless-data-quotacustom-africa" + WIRELESS_DATA_QUOTACUSTOM_ASIA = "wireless-data-quotacustom-asia" + WIRELESS_DATA_QUOTACUSTOM_CENTRALANDSOUTHAMERICA = ( + "wireless-data-quotacustom-centralandsouthamerica" + ) + WIRELESS_DATA_QUOTACUSTOM_EUROPE = "wireless-data-quotacustom-europe" + WIRELESS_DATA_QUOTACUSTOM_NORTHAMERICA = ( + "wireless-data-quotacustom-northamerica" + ) + WIRELESS_DATA_QUOTACUSTOM_OCEANIA = "wireless-data-quotacustom-oceania" + WIRELESS_MRC_PAYG = "wireless-mrc-payg" + WIRELESS_MRC_QUOTA1 = "wireless-mrc-quota1" + WIRELESS_MRC_QUOTA10 = "wireless-mrc-quota10" + WIRELESS_MRC_QUOTA50 = "wireless-mrc-quota50" + WIRELESS_MRC_QUOTACUSTOM = "wireless-mrc-quotacustom" WIRELESS_ORDERS = "wireless-orders" WIRELESS_ORDERS_ARTWORK = "wireless-orders-artwork" WIRELESS_ORDERS_BULK = "wireless-orders-bulk" WIRELESS_ORDERS_ESIM = "wireless-orders-esim" WIRELESS_ORDERS_STARTER = "wireless-orders-starter" + WIRELESS_QUOTAS = "wireless-quotas" + WIRELESS_SMS_AFRICA = "wireless-sms-africa" + WIRELESS_SMS_ASIA = "wireless-sms-asia" + WIRELESS_SMS_CENTRALANDSOUTHAMERICA = "wireless-sms-centralandsouthamerica" + WIRELESS_SMS_EUROPE = "wireless-sms-europe" + WIRELESS_SMS_NORTHAMERICA = "wireless-sms-northamerica" + WIRELESS_SMS_OCEANIA = "wireless-sms-oceania" + WIRELESS_SUPER_SIM = "wireless-super-sim" + WIRELESS_SUPER_SIM_DATA = "wireless-super-sim-data" + WIRELESS_SUPER_SIM_DATA_NORTH_AMERICA_USA = ( + "wireless-super-sim-data-north-america-usa" + ) + WIRELESS_SUPER_SIM_DATA_PAYG = "wireless-super-sim-data-payg" + WIRELESS_SUPER_SIM_DATA_PAYG_EUROPE = "wireless-super-sim-data-payg-europe" + WIRELESS_SUPER_SIM_DATA_PAYG_NORTH_AMERICA = ( + "wireless-super-sim-data-payg-north-america" + ) + WIRELESS_SUPER_SIM_HARDWARE = "wireless-super-sim-hardware" + WIRELESS_SUPER_SIM_HARDWARE_BULK = "wireless-super-sim-hardware-bulk" + WIRELESS_SUPER_SIM_SMSCOMMANDS = "wireless-super-sim-smscommands" + WIRELESS_SUPER_SIM_SMSCOMMANDS_AFRICA = "wireless-super-sim-smscommands-africa" + WIRELESS_SUPER_SIM_SMSCOMMANDS_ASIA = "wireless-super-sim-smscommands-asia" + WIRELESS_SUPER_SIM_SMSCOMMANDS_CENT_AND_SOUTH_AMERICA = ( + "wireless-super-sim-smscommands-cent-and-south-america" + ) + WIRELESS_SUPER_SIM_SMSCOMMANDS_EUROPE = "wireless-super-sim-smscommands-europe" + WIRELESS_SUPER_SIM_SMSCOMMANDS_NORTH_AMERICA = ( + "wireless-super-sim-smscommands-north-america" + ) + WIRELESS_SUPER_SIM_SMSCOMMANDS_OCEANIA = ( + "wireless-super-sim-smscommands-oceania" + ) + WIRELESS_SUPER_SIM_SUBSCRIPTION = "wireless-super-sim-subscription" + WIRELESS_SUPER_SIM_SUBSCRIPTION_PAYG = "wireless-super-sim-subscription-payg" WIRELESS_USAGE = "wireless-usage" WIRELESS_USAGE_COMMANDS = "wireless-usage-commands" WIRELESS_USAGE_COMMANDS_AFRICA = "wireless-usage-commands-africa" @@ -353,6 +667,184 @@ class UsageCategory(object): WIRELESS_USAGE_MRC_SUSPENDED = "wireless-usage-mrc-suspended" WIRELESS_USAGE_SMS = "wireless-usage-sms" WIRELESS_USAGE_VOICE = "wireless-usage-voice" + A2P_FAST_TRACK_ONBOARDING = "a2p-fast-track-onboarding" + ADVISORY_SERVICES = "advisory-services" + ADVISORY_SERVICES_BILLED = "advisory-services-billed" + ADVISORY_SERVICES_CALL_TRACKING = "advisory-services-call-tracking" + ADVISORY_SERVICES_DATA_SERVICES = "advisory-services-data-services" + ADVISORY_SERVICES_EXPENSES = "advisory-services-expenses" + ADVISORY_SERVICES_SIP_TRUNKING = "advisory-services-sip-trunking" + ASSETS_REQUESTS = "assets-requests" + AUDIENCE_MINUTES_VIDEO = "audience-minutes-video" + AUTHY_BUCKET_ADJUSTMENT = "authy-bucket-adjustment" + AUTHY_SOFTWARE = "authy-software" + CALLERIDLOOKUPS_API = "calleridlookups-api" + CALLERIDLOOKUPS_PROGRAMMABLEVOICE = "calleridlookups-programmablevoice" + CALLERIDLOOKUPS_TRUNKING = "calleridlookups-trunking" + CALLS_TRUNKING_INBOUND_TOLLFREE_LOCAL = "calls-trunking-inbound-tollfree-local" + CALLS_TRUNKING_INBOUND_TOLLFREE_MOBILE = ( + "calls-trunking-inbound-tollfree-mobile" + ) + CHANNELS_WHATSAPP_CONVERSATION_FREE_1 = "channels-whatsapp-conversation-free-1" + CONFERENCE = "conference" + CONVERSATIONAL_INSIGHTS = "conversational-insights" + CONVERSATIONAL_INSIGHTS_MESSAGES = "conversational-insights-messages" + CONVERSATIONAL_INSIGHTS_VOICE_MINUTES = "conversational-insights-voice-minutes" + DEMO = "demo" + DEMO_UC_SCRIPT_TEST = "demo-uc-script-test" + ELASTIC_SIP_TRUNKING = "elastic-sip-trunking" + ELASTIC_SIP_TRUNKING_CALL_TRANSFERS = "elastic-sip-trunking-call-transfers" + ENTERPRISE_HIPPA = "enterprise-hippa" + FLEX_NAMED_USERS = "flex-named-users" + FLEX_SPINSCI = "flex-spinsci" + FLEX_USERS_1 = "flex-users-1" + FLEX_WFO_PREMIUM_SPEECH_ANALYTICS = "flex-wfo-premium-speech-analytics" + FLEX_XCELERATE = "flex-xcelerate" + FUNCTIONS_ROLLUP = "functions-rollup" + IMP_V1_USAGE = "imp-v1-usage" + IP_MESSAGING_ADDONS = "ip-messaging-addons" + IVR = "ivr" + IVR_CONVERSATIONAL = "ivr-conversational" + IVR_DTMF = "ivr-dtmf" + IVR_VIRTUALAGENT = "ivr-virtualagent" + LIVE = "live" + LIVE_MEDIA_RECORDING_MINUTES = "live-media-recording-minutes" + LONGCODE_MPS = "longcode-mps" + MARKETPLACE_ANALYTICS_ADDONS = "marketplace-analytics-addons" + MARKETPLACE_ISV_ADDONS = "marketplace-isv-addons" + MARKETPLACE_MESSAGING_ADDONS = "marketplace-messaging-addons" + MARKETPLACE_PHONENUMBERS_ADDONS = "marketplace-phonenumbers-addons" + MARKETPLACE_RECORDING_ADDONS = "marketplace-recording-addons" + MARKETPLACE_VIRTUALAGENT_ADDONS = "marketplace-virtualagent-addons" + MARKETPLAY_PAY_ADDONS_SHUTTLE_PAY_CONNECTOR_1 = ( + "marketplay-pay-addons-shuttle-pay-connector-1" + ) + MARKETPLAY_PAY_ADDONS_STRIPE_PAY_CONNECTOR = ( + "marketplay-pay-addons-stripe-pay-connector" + ) + MMS_INBOUND_LONGCODE_CANADA = "mms-inbound-longcode-canada" + MMS_INBOUND_LONGCODE_UNITEDSTATES = "mms-inbound-longcode-unitedstates" + MMS_OUTBOUND_LONGCODE_CANADA = "mms-outbound-longcode-canada" + MMS_OUTBOUND_LONGCODE_UNITEDSTATES = "mms-outbound-longcode-unitedstates" + MMS_OUTBOUND_TOLL_FREE = "mms-outbound-toll-free" + NOTIFY_CHATAPPSANDOTHERCHANNELS = "notify-chatappsandotherchannels" + NOTIFY_NOTIFYSERVICES = "notify-notifyservices" + NOTIFY_PUSHNOTIFICATIONS = "notify-pushnotifications" + PAYMENT_GATEWAY_CONNECTORS = "payment-gateway-connectors" + PAYMENT_SOLUTIONS = "payment-solutions" + PCHAT_BUCKET_ADJUSTMENT = "pchat-bucket-adjustment" + PHONENUMBERS_NUMBERS = "phonenumbers-numbers" + PROG_VOICE_CLIENT_ANDROID = "prog-voice-client-android" + PROG_VOICE_CLIENT_ANDROID_INBOUND = "prog-voice-client-android-inbound" + PROG_VOICE_CLIENT_ANDROID_OUTBOUND = "prog-voice-client-android-outbound" + PROG_VOICE_CLIENT_IOS = "prog-voice-client-ios" + PROG_VOICE_CLIENT_IOS_INBOUND = "prog-voice-client-ios-inbound" + PROG_VOICE_CLIENT_IOS_OUTBOUND = "prog-voice-client-ios-outbound" + PROG_VOICE_CLIENT_SDK = "prog-voice-client-sdk" + PROG_VOICE_CLIENT_WEB = "prog-voice-client-web" + PROG_VOICE_CLIENT_WEB_INBOUND = "prog-voice-client-web-inbound" + PROG_VOICE_CLIENT_WEB_OUTBOUND = "prog-voice-client-web-outbound" + PROGRAMMABLEVOICECONNECTIVITY_MEDIA_STREAMS = ( + "programmablevoiceconnectivity-media-streams" + ) + PSTNCONNECTIVITY_BYOC = "pstnconnectivity-byoc" + PSTNCONNECTIVITY_EMERGENCY = "pstnconnectivity-emergency" + PSTNCONNECTIVITY_MINUTES = "pstnconnectivity-minutes" + PSTNCONNECTIVITY_MINUTES_1 = "pstnconnectivity-minutes-1" + PSTNCONNECTIVITY_MINUTESINBOUNDLOCAL = "pstnconnectivity-minutesinboundlocal" + PSTNCONNECTIVITY_MINUTESINBOUNDMOBILE = "pstnconnectivity-minutesinboundmobile" + PSTNCONNECTIVITY_MINUTESINBOUNDTOLLFREE = ( + "pstnconnectivity-minutesinboundtollfree" + ) + PSTNCONNECTIVITY_MINUTESINBOUNDTOLLFREELOCAL = ( + "pstnconnectivity-minutesinboundtollfreelocal" + ) + PSTNCONNECTIVITY_MINUTESINBOUNDTOLLFREEMOBILE = ( + "pstnconnectivity-minutesinboundtollfreemobile" + ) + PV_ROOM_HOURS = "pv-room-hours" + PV_ROOM_SIMULTANEOUS_PARTICIPANT_CONNECTIONS = ( + "pv-room-simultaneous-participant-connections" + ) + PVIDEO_ROOM_HOURS_AU1 = "pvideo-room-hours-au1" + PVIDEO_ROOM_HOURS_BR1 = "pvideo-room-hours-br1" + PVIDEO_ROOM_HOURS_IE1 = "pvideo-room-hours-ie1" + PVIDEO_ROOM_HOURS_JP1 = "pvideo-room-hours-jp1" + PVIDEO_ROOM_HOURS_SG1 = "pvideo-room-hours-sg1" + PVIDEO_ROOM_HOURS_US1 = "pvideo-room-hours-us1" + PVIDEO_ROOM_HOURS_US2 = "pvideo-room-hours-us2" + RECORDINGS_ENCRYPTED = "recordings-encrypted" + SHORT_CODE_SETUP_FEES = "short-code-setup-fees" + SHORTCODES_MESSAGES_INBOUND = "shortcodes-messages-inbound" + SHORTCODES_MESSAGES_OUTBOUND = "shortcodes-messages-outbound" + SMS_MESSAGES_REGISTRATIONFEES = "sms-messages-registrationfees" + SMS_MMS_PENALTY_FEES = "sms-mms-penalty-fees" + SMS_MMS_PENALTY_FEES_1 = "sms-mms-penalty-fees-1" + SMS_PUMPING_PROTECTION_NON_USCA = "sms-pumping-protection-non-usca" + SMS_PUMPING_PROTECTION_USCA = "sms-pumping-protection-usca" + STUDIO = "studio" + STUDIO_MONTHLY_FEES = "studio-monthly-fees" + SUPERSIM = "supersim" + TASK_ROUTER = "task-router" + TASK_ROUTER_WORKERS = "task-router-workers" + TEST_QUOTA_BUCKETS = "test-quota-buckets" + TEST_UC_SCRIPT_1 = "test-uc-script-1" + TEST_UC_SCRIPT_DEMO_2 = "test-uc-script-demo-2" + TEXT_TO_SPEECH = "text-to-speech" + TME = "tme" + TTS_BASIC = "tts-basic" + TWILIO_EDITIONS = "twilio-editions" + TWILIO_INTERCONNECT_CALIFORNIA = "twilio-interconnect-california" + TWILIO_INTERCONNECT_CALIFORNIA_MONTHLY = ( + "twilio-interconnect-california-monthly" + ) + TWILIO_INTERCONNECT_CALIFORNIA_SETUP = "twilio-interconnect-california-setup" + TWILIO_INTERCONNECT_FRANKFURT = "twilio-interconnect-frankfurt" + TWILIO_INTERCONNECT_FRANKFURT_MO = "twilio-interconnect-frankfurt-mo" + TWILIO_INTERCONNECT_FRANKFURT_SETUP = "twilio-interconnect-frankfurt-setup" + TWILIO_INTERCONNECT_LONDON = "twilio-interconnect-london" + TWILIO_INTERCONNECT_LONDON_MO = "twilio-interconnect-london-mo" + TWILIO_INTERCONNECT_LONDON_SETUP = "twilio-interconnect-london-setup" + TWILIO_INTERCONNECT_SAO_PAULO = "twilio-interconnect-sao-paulo" + TWILIO_INTERCONNECT_SAO_PAULO_MONTHLY = "twilio-interconnect-sao-paulo-monthly" + TWILIO_INTERCONNECT_SAO_PAULO_SETUP = "twilio-interconnect-sao-paulo-setup" + TWILIO_INTERCONNECT_SINGAPORE = "twilio-interconnect-singapore" + TWILIO_INTERCONNECT_SINGAPORE_MO = "twilio-interconnect-singapore-mo" + TWILIO_INTERCONNECT_SINGAPORE_SETUP = "twilio-interconnect-singapore-setup" + TWILIO_INTERCONNECT_SYDNEY = "twilio-interconnect-sydney" + TWILIO_INTERCONNECT_SYDNEY_MO = "twilio-interconnect-sydney-mo" + TWILIO_INTERCONNECT_SYDNEY_SETUP = "twilio-interconnect-sydney-setup" + TWILIO_INTERCONNECT_TOKYO = "twilio-interconnect-tokyo" + TWILIO_INTERCONNECT_TOKYO_MO = "twilio-interconnect-tokyo-mo" + TWILIO_INTERCONNECT_TOKYO_SETUP = "twilio-interconnect-tokyo-setup" + TWILIO_INTERCONNECT_VA = "twilio-interconnect-va" + TWILIO_INTERCONNECT_VA_MO = "twilio-interconnect-va-mo" + TWILIO_INTERCONNECT_VA_SETUP = "twilio-interconnect-va-setup" + TWIML_VERBS = "twiml-verbs" + TWIML_VERBS_SAY = "twiml-verbs-say" + USAGE_PROGRAMMABLE_MESSAGING_ENGAGEMENT_SUITE = ( + "usage-programmable-messaging-engagement-suite" + ) + USAGE_PROGRAMMABLE_MESSAGING_FEES_SERVICES = ( + "usage-programmable-messaging-fees-services" + ) + VERIFY_OUTBOUND_EMAIL = "verify-outbound-email" + VERIFY_PACKAGED_PLANS = "verify-packaged-plans" + VERIFY_SILENT_NETWORK_AUTH = "verify-silent-network-auth" + VERIFY_VOICE_AND_SMS = "verify-voice-and-sms" + VOICE_INSIGHTS_CLIENT_INSIGHTS_MONTHY_COMMIT = ( + "voice-insights-client-insights-monthy-commit" + ) + WIRELESS_DATA_PAYG_ASIA_AFG = "wireless-data-payg-asia-afg" + WIRELESS_MULTI_IMSI_SIM_COMMANDS = "wireless-multi-imsi-sim-commands" + WIRELESS_MULTI_IMSI_SIM_COMMANDS_USA = "wireless-multi-imsi-sim-commands-usa" + WIRELESS_MULTI_IMSI_SIM_DATA = "wireless-multi-imsi-sim-data" + WIRELESS_MULTI_IMSI_SIM_DATA_EU28 = "wireless-multi-imsi-sim-data-eu28" + WIRELESS_MULTI_IMSI_SIM_DATA_USA = "wireless-multi-imsi-sim-data-usa" + WIRELESS_MULTI_IMSI_SIM_MONTHLY_FEES = "wireless-multi-imsi-sim-monthly-fees" + WIRELESS_MULTI_IMSI_SIM_USAGE = "wireless-multi-imsi-sim-usage" + WIRELESS_SUPER_SIM_DATA_NORTH_AMERICA = "wireless-super-sim-data-north-america" + WIRELESS_SUPER_SIM_USAGE = "wireless-super-sim-usage" """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that the trigger monitors. @@ -520,6 +1012,7 @@ def __repr__(self) -> str: class TriggerContext(InstanceContext): + def __init__(self, version: Version, account_sid: str, sid: str): """ Initialize the TriggerContext @@ -546,10 +1039,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: """ @@ -558,9 +1051,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: @@ -571,10 +1066,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, @@ -591,9 +1087,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( @@ -618,6 +1117,7 @@ def update( :returns: The updated TriggerInstance """ + data = values.of( { "CallbackMethod": callback_method, @@ -625,11 +1125,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( @@ -654,6 +1157,7 @@ async def update_async( :returns: The updated TriggerInstance """ + data = values.of( { "CallbackMethod": callback_method, @@ -661,11 +1165,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( @@ -686,6 +1193,7 @@ def __repr__(self) -> str: class TriggerPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> TriggerInstance: """ Build an instance of TriggerInstance @@ -706,6 +1214,7 @@ def __repr__(self) -> str: class TriggerList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the TriggerList @@ -747,6 +1256,7 @@ def create( :returns: The created TriggerInstance """ + data = values.of( { "CallbackUrl": callback_url, @@ -758,11 +1268,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( @@ -792,6 +1305,7 @@ async def create_async( :returns: The created TriggerInstance """ + data = values.of( { "CallbackUrl": callback_url, @@ -803,11 +1317,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( @@ -990,7 +1507,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-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( @@ -1026,8 +1549,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/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 84ef8ee253..d92f840e68 100644 --- a/twilio/rest/api/v2010/account/validation_request.py +++ b/twilio/rest/api/v2010/account/validation_request.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, Optional, Union from twilio.base import values @@ -22,7 +21,6 @@ class ValidationRequestInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for the Caller ID. :ivar call_sid: The SID of the [Call](https://www.twilio.com/docs/voice/api/call-resource) the Caller ID is associated with. @@ -55,6 +53,7 @@ def __repr__(self) -> str: class ValidationRequestList(ListResource): + def __init__(self, version: Version, account_sid: str): """ Initialize the ValidationRequestList @@ -94,6 +93,7 @@ def create( :returns: The created ValidationRequestInstance """ + data = values.of( { "PhoneNumber": phone_number, @@ -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( @@ -136,6 +139,7 @@ async def create_async( :returns: The created ValidationRequestInstance """ + data = values.of( { "PhoneNumber": phone_number, @@ -146,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/microvisor/MicrovisorBase.py b/twilio/rest/assistants/AssistantsBase.py similarity index 75% rename from twilio/rest/microvisor/MicrovisorBase.py rename to twilio/rest/assistants/AssistantsBase.py index 57a4c50f55..a9c9e9afcd 100644 --- a/twilio/rest/microvisor/MicrovisorBase.py +++ b/twilio/rest/assistants/AssistantsBase.py @@ -13,23 +13,24 @@ from twilio.base.domain import Domain from twilio.rest import Client -from twilio.rest.microvisor.v1 import V1 +from twilio.rest.assistants.v1 import V1 -class MicrovisorBase(Domain): +class AssistantsBase(Domain): + def __init__(self, twilio: Client): """ - Initialize the Microvisor Domain + Initialize the Assistants Domain - :returns: Domain for Microvisor + :returns: Domain for Assistants """ - super().__init__(twilio, "https://microvisor.twilio.com") + super().__init__(twilio, "https://assistants.twilio.com") self._v1: Optional[V1] = None @property def v1(self) -> V1: """ - :returns: Versions v1 of Microvisor + :returns: Versions v1 of Assistants """ if self._v1 is None: self._v1 = V1(self) @@ -40,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 d3cd34c547..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. @@ -12,7 +12,6 @@ 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 @@ -21,122 +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: """ @@ -145,119 +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 AssistantsKnowledgeContext(InstanceContext): -class SyncListContext(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, - ) - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the SyncListInstance + data = values.of({}) + 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: """ @@ -266,18 +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 AssistantsKnowledgePage(Page): -class SyncListPage(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,85 +243,68 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ - return "" + return "" + +class AssistantsKnowledgeList(ListResource): -class SyncListList(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, - } - ) - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - return SyncListInstance( - self._version, payload, service_sid=self._solution["service_sid"] + payload = self._version.create(method="POST", uri=self._uri, headers=headers) + + return AssistantsKnowledgeInstance( + self._version, payload, assistant_id=self._solution["assistant_id"] ) - async def create_async( - self, 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. @@ -387,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. @@ -412,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. @@ -438,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. @@ -466,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( { @@ -485,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( { @@ -512,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: @@ -567,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 47235fd80c..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. @@ -12,7 +12,6 @@ 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 @@ -21,122 +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: """ @@ -145,119 +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): - def __init__(self, version: Version, service_sid: str, sid: str): +class AssistantsToolContext(InstanceContext): + + 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._sync_map_items: Optional[SyncMapItemList] = None - self._sync_map_permissions: Optional[SyncMapPermissionList] = None + self._uri = "/Assistants/{assistant_id}/Tools/{id}".format(**self._solution) - 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: """ @@ -266,18 +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): - def get_instance(self, payload: Dict[str, Any]) -> SyncMapInstance: +class AssistantsToolPage(Page): + + 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,83 +241,68 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ - return "" + return "" + +class AssistantsToolList(ListResource): -class SyncMapList(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, - } - ) - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - return SyncMapInstance( - self._version, payload, service_sid=self._solution["service_sid"] + payload = self._version.create(method="POST", uri=self._uri, headers=headers) + + return AssistantsToolInstance( + self._version, payload, assistant_id=self._solution["assistant_id"] ) - async def create_async( - self, 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. @@ -385,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. @@ -410,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. @@ -436,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. @@ -464,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( { @@ -483,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( { @@ -510,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: @@ -565,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/autopilot/v1/assistant/__init__.py b/twilio/rest/autopilot/v1/assistant/__init__.py deleted file mode 100644 index a25268fc45..0000000000 --- a/twilio/rest/autopilot/v1/assistant/__init__.py +++ /dev/null @@ -1,879 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Autopilot - 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.autopilot.v1.assistant.defaults import DefaultsList -from twilio.rest.autopilot.v1.assistant.dialogue import DialogueList -from twilio.rest.autopilot.v1.assistant.field_type import FieldTypeList -from twilio.rest.autopilot.v1.assistant.model_build import ModelBuildList -from twilio.rest.autopilot.v1.assistant.query import QueryList -from twilio.rest.autopilot.v1.assistant.style_sheet import StyleSheetList -from twilio.rest.autopilot.v1.assistant.task import TaskList -from twilio.rest.autopilot.v1.assistant.webhook import WebhookList - - -class AssistantInstance(InstanceResource): - - """ - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Assistant resource. - :ivar 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. - :ivar friendly_name: The string that you assigned to describe the resource. It is not unique and can be up to 255 characters long. - :ivar latest_model_build_sid: Reserved. - :ivar links: A list of the URLs of the Assistant's related resources. - :ivar log_queries: Whether queries should be logged and kept after training. Can be: `true` or `false` and defaults to `true`. If `true`, queries are stored for 30 days, and then deleted. If `false`, no queries are stored. - :ivar development_stage: A string describing the state of the assistant. - :ivar needs_model_build: Whether model needs to be rebuilt. - :ivar sid: The unique string that we created to identify the Assistant 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. It can be up to 64 characters long. - :ivar url: The absolute URL of the Assistant resource. - :ivar callback_url: Reserved. - :ivar callback_events: Reserved. - """ - - 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.friendly_name: Optional[str] = payload.get("friendly_name") - self.latest_model_build_sid: Optional[str] = payload.get( - "latest_model_build_sid" - ) - self.links: Optional[Dict[str, object]] = payload.get("links") - self.log_queries: Optional[bool] = payload.get("log_queries") - self.development_stage: Optional[str] = payload.get("development_stage") - self.needs_model_build: Optional[bool] = payload.get("needs_model_build") - self.sid: Optional[str] = payload.get("sid") - self.unique_name: Optional[str] = payload.get("unique_name") - self.url: Optional[str] = payload.get("url") - self.callback_url: Optional[str] = payload.get("callback_url") - self.callback_events: Optional[str] = payload.get("callback_events") - - self._solution = { - "sid": sid or self.sid, - } - 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, - sid=self._solution["sid"], - ) - 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, - friendly_name: Union[str, object] = values.unset, - log_queries: Union[bool, object] = values.unset, - unique_name: Union[str, object] = values.unset, - callback_url: Union[str, object] = values.unset, - callback_events: Union[str, object] = values.unset, - style_sheet: Union[object, object] = values.unset, - defaults: Union[object, object] = values.unset, - development_stage: Union[str, object] = values.unset, - ) -> "AssistantInstance": - """ - Update the AssistantInstance - - :param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long. - :param log_queries: Whether queries should be logged and kept after training. Can be: `true` or `false` and defaults to `true`. If `true`, queries are stored for 30 days, and then deleted. If `false`, no queries are stored. - :param unique_name: An application-defined string that uniquely identifies the resource. It can be used as an alternative to the `sid` in the URL path to address the resource. The first 64 characters must be unique. - :param callback_url: Reserved. - :param callback_events: Reserved. - :param style_sheet: The JSON string that defines the Assistant's [style sheet](https://www.twilio.com/docs/autopilot/api/assistant/stylesheet) - :param defaults: A JSON object that defines the Assistant's [default tasks](https://www.twilio.com/docs/autopilot/api/assistant/defaults) for various scenarios, including initiation actions and fallback tasks. - :param development_stage: A string describing the state of the assistant. - - :returns: The updated AssistantInstance - """ - return self._proxy.update( - friendly_name=friendly_name, - log_queries=log_queries, - unique_name=unique_name, - callback_url=callback_url, - callback_events=callback_events, - style_sheet=style_sheet, - defaults=defaults, - development_stage=development_stage, - ) - - async def update_async( - self, - friendly_name: Union[str, object] = values.unset, - log_queries: Union[bool, object] = values.unset, - unique_name: Union[str, object] = values.unset, - callback_url: Union[str, object] = values.unset, - callback_events: Union[str, object] = values.unset, - style_sheet: Union[object, object] = values.unset, - defaults: Union[object, object] = values.unset, - development_stage: Union[str, object] = values.unset, - ) -> "AssistantInstance": - """ - Asynchronous coroutine to update the AssistantInstance - - :param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long. - :param log_queries: Whether queries should be logged and kept after training. Can be: `true` or `false` and defaults to `true`. If `true`, queries are stored for 30 days, and then deleted. If `false`, no queries are stored. - :param unique_name: An application-defined string that uniquely identifies the resource. It can be used as an alternative to the `sid` in the URL path to address the resource. The first 64 characters must be unique. - :param callback_url: Reserved. - :param callback_events: Reserved. - :param style_sheet: The JSON string that defines the Assistant's [style sheet](https://www.twilio.com/docs/autopilot/api/assistant/stylesheet) - :param defaults: A JSON object that defines the Assistant's [default tasks](https://www.twilio.com/docs/autopilot/api/assistant/defaults) for various scenarios, including initiation actions and fallback tasks. - :param development_stage: A string describing the state of the assistant. - - :returns: The updated AssistantInstance - """ - return await self._proxy.update_async( - friendly_name=friendly_name, - log_queries=log_queries, - unique_name=unique_name, - callback_url=callback_url, - callback_events=callback_events, - style_sheet=style_sheet, - defaults=defaults, - development_stage=development_stage, - ) - - @property - def defaults(self) -> DefaultsList: - """ - Access the defaults - """ - return self._proxy.defaults - - @property - def dialogues(self) -> DialogueList: - """ - Access the dialogues - """ - return self._proxy.dialogues - - @property - def field_types(self) -> FieldTypeList: - """ - Access the field_types - """ - return self._proxy.field_types - - @property - def model_builds(self) -> ModelBuildList: - """ - Access the model_builds - """ - return self._proxy.model_builds - - @property - def queries(self) -> QueryList: - """ - Access the queries - """ - return self._proxy.queries - - @property - def style_sheet(self) -> StyleSheetList: - """ - Access the style_sheet - """ - return self._proxy.style_sheet - - @property - def tasks(self) -> TaskList: - """ - Access the tasks - """ - return self._proxy.tasks - - @property - def webhooks(self) -> WebhookList: - """ - Access the webhooks - """ - return self._proxy.webhooks - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) - return "".format(context) - - -class AssistantContext(InstanceContext): - def __init__(self, version: Version, sid: str): - """ - Initialize the AssistantContext - - :param version: Version that contains the resource - :param sid: The Twilio-provided string that uniquely identifies the Assistant resource to update. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "sid": sid, - } - self._uri = "/Assistants/{sid}".format(**self._solution) - - self._defaults: Optional[DefaultsList] = None - self._dialogues: Optional[DialogueList] = None - self._field_types: Optional[FieldTypeList] = None - self._model_builds: Optional[ModelBuildList] = None - self._queries: Optional[QueryList] = None - self._style_sheet: Optional[StyleSheetList] = None - self._tasks: Optional[TaskList] = None - self._webhooks: Optional[WebhookList] = None - - def delete(self) -> bool: - """ - Deletes the AssistantInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the AssistantInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._version.delete_async( - method="DELETE", - uri=self._uri, - ) - - def fetch(self) -> AssistantInstance: - """ - Fetch the AssistantInstance - - - :returns: The fetched AssistantInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return AssistantInstance( - self._version, - payload, - sid=self._solution["sid"], - ) - - async def fetch_async(self) -> AssistantInstance: - """ - Asynchronous coroutine to fetch the AssistantInstance - - - :returns: The fetched AssistantInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return AssistantInstance( - self._version, - payload, - sid=self._solution["sid"], - ) - - def update( - self, - friendly_name: Union[str, object] = values.unset, - log_queries: Union[bool, object] = values.unset, - unique_name: Union[str, object] = values.unset, - callback_url: Union[str, object] = values.unset, - callback_events: Union[str, object] = values.unset, - style_sheet: Union[object, object] = values.unset, - defaults: Union[object, object] = values.unset, - development_stage: Union[str, object] = values.unset, - ) -> AssistantInstance: - """ - Update the AssistantInstance - - :param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long. - :param log_queries: Whether queries should be logged and kept after training. Can be: `true` or `false` and defaults to `true`. If `true`, queries are stored for 30 days, and then deleted. If `false`, no queries are stored. - :param unique_name: An application-defined string that uniquely identifies the resource. It can be used as an alternative to the `sid` in the URL path to address the resource. The first 64 characters must be unique. - :param callback_url: Reserved. - :param callback_events: Reserved. - :param style_sheet: The JSON string that defines the Assistant's [style sheet](https://www.twilio.com/docs/autopilot/api/assistant/stylesheet) - :param defaults: A JSON object that defines the Assistant's [default tasks](https://www.twilio.com/docs/autopilot/api/assistant/defaults) for various scenarios, including initiation actions and fallback tasks. - :param development_stage: A string describing the state of the assistant. - - :returns: The updated AssistantInstance - """ - data = values.of( - { - "FriendlyName": friendly_name, - "LogQueries": log_queries, - "UniqueName": unique_name, - "CallbackUrl": callback_url, - "CallbackEvents": callback_events, - "StyleSheet": serialize.object(style_sheet), - "Defaults": serialize.object(defaults), - "DevelopmentStage": development_stage, - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return AssistantInstance(self._version, payload, sid=self._solution["sid"]) - - async def update_async( - self, - friendly_name: Union[str, object] = values.unset, - log_queries: Union[bool, object] = values.unset, - unique_name: Union[str, object] = values.unset, - callback_url: Union[str, object] = values.unset, - callback_events: Union[str, object] = values.unset, - style_sheet: Union[object, object] = values.unset, - defaults: Union[object, object] = values.unset, - development_stage: Union[str, object] = values.unset, - ) -> AssistantInstance: - """ - Asynchronous coroutine to update the AssistantInstance - - :param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long. - :param log_queries: Whether queries should be logged and kept after training. Can be: `true` or `false` and defaults to `true`. If `true`, queries are stored for 30 days, and then deleted. If `false`, no queries are stored. - :param unique_name: An application-defined string that uniquely identifies the resource. It can be used as an alternative to the `sid` in the URL path to address the resource. The first 64 characters must be unique. - :param callback_url: Reserved. - :param callback_events: Reserved. - :param style_sheet: The JSON string that defines the Assistant's [style sheet](https://www.twilio.com/docs/autopilot/api/assistant/stylesheet) - :param defaults: A JSON object that defines the Assistant's [default tasks](https://www.twilio.com/docs/autopilot/api/assistant/defaults) for various scenarios, including initiation actions and fallback tasks. - :param development_stage: A string describing the state of the assistant. - - :returns: The updated AssistantInstance - """ - data = values.of( - { - "FriendlyName": friendly_name, - "LogQueries": log_queries, - "UniqueName": unique_name, - "CallbackUrl": callback_url, - "CallbackEvents": callback_events, - "StyleSheet": serialize.object(style_sheet), - "Defaults": serialize.object(defaults), - "DevelopmentStage": development_stage, - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return AssistantInstance(self._version, payload, sid=self._solution["sid"]) - - @property - def defaults(self) -> DefaultsList: - """ - Access the defaults - """ - if self._defaults is None: - self._defaults = DefaultsList( - self._version, - self._solution["sid"], - ) - return self._defaults - - @property - def dialogues(self) -> DialogueList: - """ - Access the dialogues - """ - if self._dialogues is None: - self._dialogues = DialogueList( - self._version, - self._solution["sid"], - ) - return self._dialogues - - @property - def field_types(self) -> FieldTypeList: - """ - Access the field_types - """ - if self._field_types is None: - self._field_types = FieldTypeList( - self._version, - self._solution["sid"], - ) - return self._field_types - - @property - def model_builds(self) -> ModelBuildList: - """ - Access the model_builds - """ - if self._model_builds is None: - self._model_builds = ModelBuildList( - self._version, - self._solution["sid"], - ) - return self._model_builds - - @property - def queries(self) -> QueryList: - """ - Access the queries - """ - if self._queries is None: - self._queries = QueryList( - self._version, - self._solution["sid"], - ) - return self._queries - - @property - def style_sheet(self) -> StyleSheetList: - """ - Access the style_sheet - """ - if self._style_sheet is None: - self._style_sheet = StyleSheetList( - self._version, - self._solution["sid"], - ) - return self._style_sheet - - @property - def tasks(self) -> TaskList: - """ - Access the tasks - """ - if self._tasks is None: - self._tasks = TaskList( - self._version, - self._solution["sid"], - ) - return self._tasks - - @property - def webhooks(self) -> WebhookList: - """ - Access the webhooks - """ - if self._webhooks is None: - self._webhooks = WebhookList( - self._version, - self._solution["sid"], - ) - return self._webhooks - - 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): - def __init__(self, version: Version): - """ - Initialize the AssistantList - - :param version: Version that contains the resource - - """ - super().__init__(version) - - self._uri = "/Assistants" - - def create( - self, - friendly_name: Union[str, object] = values.unset, - log_queries: Union[bool, object] = values.unset, - unique_name: Union[str, object] = values.unset, - callback_url: Union[str, object] = values.unset, - callback_events: Union[str, object] = values.unset, - style_sheet: Union[object, object] = values.unset, - defaults: Union[object, object] = values.unset, - ) -> AssistantInstance: - """ - Create the AssistantInstance - - :param friendly_name: A descriptive string that you create to describe the new resource. It is not unique and can be up to 255 characters long. - :param log_queries: Whether queries should be logged and kept after training. Can be: `true` or `false` and defaults to `true`. If `true`, queries are stored for 30 days, and then deleted. If `false`, no queries are stored. - :param unique_name: An application-defined string that uniquely identifies the new resource. It can be used as an alternative to the `sid` in the URL path to address the resource. The first 64 characters must be unique. - :param callback_url: Reserved. - :param callback_events: Reserved. - :param style_sheet: The JSON string that defines the Assistant's [style sheet](https://www.twilio.com/docs/autopilot/api/assistant/stylesheet) - :param defaults: A JSON object that defines the Assistant's [default tasks](https://www.twilio.com/docs/autopilot/api/assistant/defaults) for various scenarios, including initiation actions and fallback tasks. - - :returns: The created AssistantInstance - """ - data = values.of( - { - "FriendlyName": friendly_name, - "LogQueries": log_queries, - "UniqueName": unique_name, - "CallbackUrl": callback_url, - "CallbackEvents": callback_events, - "StyleSheet": serialize.object(style_sheet), - "Defaults": serialize.object(defaults), - } - ) - - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) - - return AssistantInstance(self._version, payload) - - async def create_async( - self, - friendly_name: Union[str, object] = values.unset, - log_queries: Union[bool, object] = values.unset, - unique_name: Union[str, object] = values.unset, - callback_url: Union[str, object] = values.unset, - callback_events: Union[str, object] = values.unset, - style_sheet: Union[object, object] = values.unset, - defaults: Union[object, object] = values.unset, - ) -> AssistantInstance: - """ - Asynchronously create the AssistantInstance - - :param friendly_name: A descriptive string that you create to describe the new resource. It is not unique and can be up to 255 characters long. - :param log_queries: Whether queries should be logged and kept after training. Can be: `true` or `false` and defaults to `true`. If `true`, queries are stored for 30 days, and then deleted. If `false`, no queries are stored. - :param unique_name: An application-defined string that uniquely identifies the new resource. It can be used as an alternative to the `sid` in the URL path to address the resource. The first 64 characters must be unique. - :param callback_url: Reserved. - :param callback_events: Reserved. - :param style_sheet: The JSON string that defines the Assistant's [style sheet](https://www.twilio.com/docs/autopilot/api/assistant/stylesheet) - :param defaults: A JSON object that defines the Assistant's [default tasks](https://www.twilio.com/docs/autopilot/api/assistant/defaults) for various scenarios, including initiation actions and fallback tasks. - - :returns: The created AssistantInstance - """ - data = values.of( - { - "FriendlyName": friendly_name, - "LogQueries": log_queries, - "UniqueName": unique_name, - "CallbackUrl": callback_url, - "CallbackEvents": callback_events, - "StyleSheet": serialize.object(style_sheet), - "Defaults": serialize.object(defaults), - } - ) - - payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, - ) - - return AssistantInstance(self._version, payload) - - def stream( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[AssistantInstance]: - """ - Streams AssistantInstance records from the API as a generator stream. - This operation lazily loads records as efficiently as possible until the limit - is reached. - The results are returned as a generator, so this operation is memory efficient. - - :param limit: Upper limit for the number of records to return. stream() - guarantees to never return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, stream() will attempt to read the - limit with the most efficient page size, i.e. min(limit, 1000) - - :returns: Generator that will yield up to limit results - """ - limits = self._version.read_limits(limit, page_size) - page = self.page(page_size=limits["page_size"]) - - return self._version.stream(page, limits["limit"]) - - async def stream_async( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> AsyncIterator[AssistantInstance]: - """ - Asynchronously streams AssistantInstance records from the API as a generator stream. - This operation lazily loads records as efficiently as possible until the limit - is reached. - The results are returned as a generator, so this operation is memory efficient. - - :param limit: Upper limit for the number of records to return. stream() - guarantees to never return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, stream() will attempt to read the - limit with the most efficient page size, i.e. min(limit, 1000) - - :returns: Generator that will yield up to limit results - """ - limits = self._version.read_limits(limit, page_size) - page = await self.page_async(page_size=limits["page_size"]) - - return self._version.stream_async(page, limits["limit"]) - - def list( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[AssistantInstance]: - """ - Lists AssistantInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param limit: Upper limit for the number of records to return. list() guarantees - never to return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, list() will attempt to read the limit - with the most efficient page size, i.e. min(limit, 1000) - - :returns: list that will contain up to limit results - """ - return list( - self.stream( - limit=limit, - page_size=page_size, - ) - ) - - async def list_async( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[AssistantInstance]: - """ - Asynchronously lists AssistantInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param limit: Upper limit for the number of records to return. list() guarantees - never to return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, list() will attempt to read the limit - with the most efficient page size, i.e. min(limit, 1000) - - :returns: list that will contain up to limit results - """ - return [ - record - async for record in await self.stream_async( - limit=limit, - page_size=page_size, - ) - ] - - def page( - self, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> AssistantPage: - """ - Retrieve a single page of AssistantInstance records from the API. - Request is executed immediately - - :param page_token: PageToken provided by the API - :param page_number: Page Number, this value is simply for client state - :param page_size: Number of records to return, defaults to 50 - - :returns: Page of AssistantInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = self._version.page(method="GET", uri=self._uri, params=data) - return AssistantPage(self._version, response) - - async def page_async( - self, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> AssistantPage: - """ - Asynchronously retrieve a single page of AssistantInstance records from the API. - Request is executed immediately - - :param page_token: PageToken provided by the API - :param page_number: Page Number, this value is simply for client state - :param page_size: Number of records to return, defaults to 50 - - :returns: Page of AssistantInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = await self._version.page_async( - method="GET", uri=self._uri, params=data - ) - return AssistantPage(self._version, response) - - def get_page(self, target_url: str) -> AssistantPage: - """ - Retrieve a specific page of AssistantInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of AssistantInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return AssistantPage(self._version, response) - - async def get_page_async(self, target_url: str) -> AssistantPage: - """ - Asynchronously retrieve a specific page of AssistantInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of AssistantInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return AssistantPage(self._version, response) - - def get(self, sid: str) -> AssistantContext: - """ - Constructs a AssistantContext - - :param sid: The Twilio-provided string that uniquely identifies the Assistant resource to update. - """ - return AssistantContext(self._version, sid=sid) - - def __call__(self, sid: str) -> AssistantContext: - """ - Constructs a AssistantContext - - :param sid: The Twilio-provided string that uniquely identifies the Assistant resource to update. - """ - return AssistantContext(self._version, sid=sid) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/autopilot/v1/assistant/defaults.py b/twilio/rest/autopilot/v1/assistant/defaults.py deleted file mode 100644 index 0db77b8417..0000000000 --- a/twilio/rest/autopilot/v1/assistant/defaults.py +++ /dev/null @@ -1,273 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Autopilot - 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 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 DefaultsInstance(InstanceResource): - - """ - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Defaults resource. - :ivar assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource. - :ivar url: The absolute URL of the Defaults resource. - :ivar data: The JSON string that describes the default task links for the `assistant_initiation`, `collect`, and `fallback` situations. - """ - - def __init__(self, version: Version, payload: Dict[str, Any], assistant_sid: str): - super().__init__(version) - - self.account_sid: Optional[str] = payload.get("account_sid") - self.assistant_sid: Optional[str] = payload.get("assistant_sid") - self.url: Optional[str] = payload.get("url") - self.data: Optional[Dict[str, object]] = payload.get("data") - - self._solution = { - "assistant_sid": assistant_sid, - } - self._context: Optional[DefaultsContext] = None - - @property - def _proxy(self) -> "DefaultsContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: DefaultsContext for this DefaultsInstance - """ - if self._context is None: - self._context = DefaultsContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - ) - return self._context - - def fetch(self) -> "DefaultsInstance": - """ - Fetch the DefaultsInstance - - - :returns: The fetched DefaultsInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "DefaultsInstance": - """ - Asynchronous coroutine to fetch the DefaultsInstance - - - :returns: The fetched DefaultsInstance - """ - return await self._proxy.fetch_async() - - def update( - self, defaults: Union[object, object] = values.unset - ) -> "DefaultsInstance": - """ - Update the DefaultsInstance - - :param defaults: A JSON string that describes the default task links for the `assistant_initiation`, `collect`, and `fallback` situations. - - :returns: The updated DefaultsInstance - """ - return self._proxy.update( - defaults=defaults, - ) - - async def update_async( - self, defaults: Union[object, object] = values.unset - ) -> "DefaultsInstance": - """ - Asynchronous coroutine to update the DefaultsInstance - - :param defaults: A JSON string that describes the default task links for the `assistant_initiation`, `collect`, and `fallback` situations. - - :returns: The updated DefaultsInstance - """ - return await self._proxy.update_async( - defaults=defaults, - ) - - 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 DefaultsContext(InstanceContext): - def __init__(self, version: Version, assistant_sid: str): - """ - Initialize the DefaultsContext - - :param version: Version that contains the resource - :param assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource to update. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - } - self._uri = "/Assistants/{assistant_sid}/Defaults".format(**self._solution) - - def fetch(self) -> DefaultsInstance: - """ - Fetch the DefaultsInstance - - - :returns: The fetched DefaultsInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return DefaultsInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - ) - - async def fetch_async(self) -> DefaultsInstance: - """ - Asynchronous coroutine to fetch the DefaultsInstance - - - :returns: The fetched DefaultsInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return DefaultsInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - ) - - def update( - self, defaults: Union[object, object] = values.unset - ) -> DefaultsInstance: - """ - Update the DefaultsInstance - - :param defaults: A JSON string that describes the default task links for the `assistant_initiation`, `collect`, and `fallback` situations. - - :returns: The updated DefaultsInstance - """ - data = values.of( - { - "Defaults": serialize.object(defaults), - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return DefaultsInstance( - self._version, payload, assistant_sid=self._solution["assistant_sid"] - ) - - async def update_async( - self, defaults: Union[object, object] = values.unset - ) -> DefaultsInstance: - """ - Asynchronous coroutine to update the DefaultsInstance - - :param defaults: A JSON string that describes the default task links for the `assistant_initiation`, `collect`, and `fallback` situations. - - :returns: The updated DefaultsInstance - """ - data = values.of( - { - "Defaults": serialize.object(defaults), - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return DefaultsInstance( - self._version, payload, assistant_sid=self._solution["assistant_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 DefaultsList(ListResource): - def __init__(self, version: Version, assistant_sid: str): - """ - Initialize the DefaultsList - - :param version: Version that contains the resource - :param assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource to fetch. - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - } - - def get(self) -> DefaultsContext: - """ - Constructs a DefaultsContext - - """ - return DefaultsContext( - self._version, assistant_sid=self._solution["assistant_sid"] - ) - - def __call__(self) -> DefaultsContext: - """ - Constructs a DefaultsContext - - """ - return DefaultsContext( - self._version, assistant_sid=self._solution["assistant_sid"] - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/autopilot/v1/assistant/dialogue.py b/twilio/rest/autopilot/v1/assistant/dialogue.py deleted file mode 100644 index 6e06f4ff2b..0000000000 --- a/twilio/rest/autopilot/v1/assistant/dialogue.py +++ /dev/null @@ -1,210 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Autopilot - This is the public Twilio REST API. - - NOTE: This class is auto generated by OpenAPI Generator. - https://openapi-generator.tech - Do not edit the class manually. -""" - - -from typing import Any, Dict, Optional -from twilio.base.instance_context import InstanceContext -from twilio.base.instance_resource import InstanceResource -from twilio.base.list_resource import ListResource -from twilio.base.version import Version - - -class DialogueInstance(InstanceResource): - - """ - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Dialogue resource. - :ivar assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource. - :ivar sid: The unique string that we created to identify the Dialogue resource. - :ivar data: The JSON string that describes the dialogue session object. - :ivar url: The absolute URL of the Dialogue resource. - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - assistant_sid: str, - sid: Optional[str] = None, - ): - super().__init__(version) - - self.account_sid: Optional[str] = payload.get("account_sid") - self.assistant_sid: Optional[str] = payload.get("assistant_sid") - self.sid: Optional[str] = payload.get("sid") - self.data: Optional[Dict[str, object]] = payload.get("data") - self.url: Optional[str] = payload.get("url") - - self._solution = { - "assistant_sid": assistant_sid, - "sid": sid or self.sid, - } - self._context: Optional[DialogueContext] = None - - @property - def _proxy(self) -> "DialogueContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: DialogueContext for this DialogueInstance - """ - if self._context is None: - self._context = DialogueContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - return self._context - - def fetch(self) -> "DialogueInstance": - """ - Fetch the DialogueInstance - - - :returns: The fetched DialogueInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "DialogueInstance": - """ - Asynchronous coroutine to fetch the DialogueInstance - - - :returns: The fetched DialogueInstance - """ - 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 DialogueContext(InstanceContext): - def __init__(self, version: Version, assistant_sid: str, sid: str): - """ - Initialize the DialogueContext - - :param version: Version that contains the resource - :param assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource to fetch. - :param sid: The Twilio-provided string that uniquely identifies the Dialogue resource to fetch. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - "sid": sid, - } - self._uri = "/Assistants/{assistant_sid}/Dialogues/{sid}".format( - **self._solution - ) - - def fetch(self) -> DialogueInstance: - """ - Fetch the DialogueInstance - - - :returns: The fetched DialogueInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return DialogueInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - - async def fetch_async(self) -> DialogueInstance: - """ - Asynchronous coroutine to fetch the DialogueInstance - - - :returns: The fetched DialogueInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return DialogueInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_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 DialogueList(ListResource): - def __init__(self, version: Version, assistant_sid: str): - """ - Initialize the DialogueList - - :param version: Version that contains the resource - :param assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource to fetch. - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - } - - def get(self, sid: str) -> DialogueContext: - """ - Constructs a DialogueContext - - :param sid: The Twilio-provided string that uniquely identifies the Dialogue resource to fetch. - """ - return DialogueContext( - self._version, assistant_sid=self._solution["assistant_sid"], sid=sid - ) - - def __call__(self, sid: str) -> DialogueContext: - """ - Constructs a DialogueContext - - :param sid: The Twilio-provided string that uniquely identifies the Dialogue resource to fetch. - """ - return DialogueContext( - self._version, assistant_sid=self._solution["assistant_sid"], sid=sid - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/autopilot/v1/assistant/field_type/field_value.py b/twilio/rest/autopilot/v1/assistant/field_type/field_value.py deleted file mode 100644 index 38cb71161f..0000000000 --- a/twilio/rest/autopilot/v1/assistant/field_type/field_value.py +++ /dev/null @@ -1,577 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Autopilot - 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 FieldValueInstance(InstanceResource): - - """ - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the FieldValue resource. - :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. - :ivar field_type_sid: The SID of the Field Type associated with the Field Value. - :ivar language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) tag that specifies the language of the value. Currently supported tags: `en-US` - :ivar assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the FieldType associated with the resource. - :ivar sid: The unique string that we created to identify the FieldValue resource. - :ivar value: The Field Value data. - :ivar url: The absolute URL of the FieldValue resource. - :ivar synonym_of: The word for which the field value is a synonym of. - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - assistant_sid: str, - field_type_sid: str, - 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.field_type_sid: Optional[str] = payload.get("field_type_sid") - self.language: Optional[str] = payload.get("language") - self.assistant_sid: Optional[str] = payload.get("assistant_sid") - self.sid: Optional[str] = payload.get("sid") - self.value: Optional[str] = payload.get("value") - self.url: Optional[str] = payload.get("url") - self.synonym_of: Optional[str] = payload.get("synonym_of") - - self._solution = { - "assistant_sid": assistant_sid, - "field_type_sid": field_type_sid, - "sid": sid or self.sid, - } - self._context: Optional[FieldValueContext] = None - - @property - def _proxy(self) -> "FieldValueContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: FieldValueContext for this FieldValueInstance - """ - if self._context is None: - self._context = FieldValueContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - field_type_sid=self._solution["field_type_sid"], - sid=self._solution["sid"], - ) - return self._context - - def delete(self) -> bool: - """ - Deletes the FieldValueInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the FieldValueInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def fetch(self) -> "FieldValueInstance": - """ - Fetch the FieldValueInstance - - - :returns: The fetched FieldValueInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "FieldValueInstance": - """ - Asynchronous coroutine to fetch the FieldValueInstance - - - :returns: The fetched FieldValueInstance - """ - 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 FieldValueContext(InstanceContext): - def __init__( - self, version: Version, assistant_sid: str, field_type_sid: str, sid: str - ): - """ - Initialize the FieldValueContext - - :param version: Version that contains the resource - :param assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the FieldType associated with the resource to fetch. - :param field_type_sid: The SID of the Field Type associated with the Field Value to fetch. - :param sid: The Twilio-provided string that uniquely identifies the FieldValue resource to fetch. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - "field_type_sid": field_type_sid, - "sid": sid, - } - self._uri = "/Assistants/{assistant_sid}/FieldTypes/{field_type_sid}/FieldValues/{sid}".format( - **self._solution - ) - - def delete(self) -> bool: - """ - Deletes the FieldValueInstance - - - :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 FieldValueInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._version.delete_async( - method="DELETE", - uri=self._uri, - ) - - def fetch(self) -> FieldValueInstance: - """ - Fetch the FieldValueInstance - - - :returns: The fetched FieldValueInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return FieldValueInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - field_type_sid=self._solution["field_type_sid"], - sid=self._solution["sid"], - ) - - async def fetch_async(self) -> FieldValueInstance: - """ - Asynchronous coroutine to fetch the FieldValueInstance - - - :returns: The fetched FieldValueInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return FieldValueInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - field_type_sid=self._solution["field_type_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 FieldValuePage(Page): - def get_instance(self, payload: Dict[str, Any]) -> FieldValueInstance: - """ - Build an instance of FieldValueInstance - - :param payload: Payload response from the API - """ - return FieldValueInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - field_type_sid=self._solution["field_type_sid"], - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class FieldValueList(ListResource): - def __init__(self, version: Version, assistant_sid: str, field_type_sid: str): - """ - Initialize the FieldValueList - - :param version: Version that contains the resource - :param assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the FieldType associated with the resources to read. - :param field_type_sid: The SID of the Field Type associated with the Field Value to read. - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - "field_type_sid": field_type_sid, - } - self._uri = "/Assistants/{assistant_sid}/FieldTypes/{field_type_sid}/FieldValues".format( - **self._solution - ) - - def create( - self, language: str, value: str, synonym_of: Union[str, object] = values.unset - ) -> FieldValueInstance: - """ - Create the FieldValueInstance - - :param language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) tag that specifies the language of the value. Currently supported tags: `en-US` - :param value: The Field Value data. - :param synonym_of: The string value that indicates which word the field value is a synonym of. - - :returns: The created FieldValueInstance - """ - data = values.of( - { - "Language": language, - "Value": value, - "SynonymOf": synonym_of, - } - ) - - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) - - return FieldValueInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - field_type_sid=self._solution["field_type_sid"], - ) - - async def create_async( - self, language: str, value: str, synonym_of: Union[str, object] = values.unset - ) -> FieldValueInstance: - """ - Asynchronously create the FieldValueInstance - - :param language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) tag that specifies the language of the value. Currently supported tags: `en-US` - :param value: The Field Value data. - :param synonym_of: The string value that indicates which word the field value is a synonym of. - - :returns: The created FieldValueInstance - """ - data = values.of( - { - "Language": language, - "Value": value, - "SynonymOf": synonym_of, - } - ) - - payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, - ) - - return FieldValueInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - field_type_sid=self._solution["field_type_sid"], - ) - - def stream( - self, - language: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[FieldValueInstance]: - """ - Streams FieldValueInstance 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 language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) tag that specifies the language of the value. Currently supported tags: `en-US` - :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(language=language, page_size=limits["page_size"]) - - return self._version.stream(page, limits["limit"]) - - async def stream_async( - self, - language: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> AsyncIterator[FieldValueInstance]: - """ - Asynchronously streams FieldValueInstance 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 language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) tag that specifies the language of the value. Currently supported tags: `en-US` - :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(language=language, page_size=limits["page_size"]) - - return self._version.stream_async(page, limits["limit"]) - - def list( - self, - language: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[FieldValueInstance]: - """ - Lists FieldValueInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param str language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) tag that specifies the language of the value. Currently supported tags: `en-US` - :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( - language=language, - limit=limit, - page_size=page_size, - ) - ) - - async def list_async( - self, - language: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[FieldValueInstance]: - """ - Asynchronously lists FieldValueInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param str language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) tag that specifies the language of the value. Currently supported tags: `en-US` - :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( - language=language, - limit=limit, - page_size=page_size, - ) - ] - - def page( - self, - language: 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, - ) -> FieldValuePage: - """ - Retrieve a single page of FieldValueInstance records from the API. - Request is executed immediately - - :param language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) tag that specifies the language of the value. Currently supported tags: `en-US` - :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 FieldValueInstance - """ - data = values.of( - { - "Language": language, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = self._version.page(method="GET", uri=self._uri, params=data) - return FieldValuePage(self._version, response, self._solution) - - async def page_async( - self, - language: 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, - ) -> FieldValuePage: - """ - Asynchronously retrieve a single page of FieldValueInstance records from the API. - Request is executed immediately - - :param language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) tag that specifies the language of the value. Currently supported tags: `en-US` - :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 FieldValueInstance - """ - data = values.of( - { - "Language": language, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = await self._version.page_async( - method="GET", uri=self._uri, params=data - ) - return FieldValuePage(self._version, response, self._solution) - - def get_page(self, target_url: str) -> FieldValuePage: - """ - Retrieve a specific page of FieldValueInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of FieldValueInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return FieldValuePage(self._version, response, self._solution) - - async def get_page_async(self, target_url: str) -> FieldValuePage: - """ - Asynchronously retrieve a specific page of FieldValueInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of FieldValueInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return FieldValuePage(self._version, response, self._solution) - - def get(self, sid: str) -> FieldValueContext: - """ - Constructs a FieldValueContext - - :param sid: The Twilio-provided string that uniquely identifies the FieldValue resource to fetch. - """ - return FieldValueContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - field_type_sid=self._solution["field_type_sid"], - sid=sid, - ) - - def __call__(self, sid: str) -> FieldValueContext: - """ - Constructs a FieldValueContext - - :param sid: The Twilio-provided string that uniquely identifies the FieldValue resource to fetch. - """ - return FieldValueContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - field_type_sid=self._solution["field_type_sid"], - sid=sid, - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/autopilot/v1/assistant/model_build.py b/twilio/rest/autopilot/v1/assistant/model_build.py deleted file mode 100644 index ccfb8a1c36..0000000000 --- a/twilio/rest/autopilot/v1/assistant/model_build.py +++ /dev/null @@ -1,627 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Autopilot - 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 ModelBuildInstance(InstanceResource): - class Status(object): - ENQUEUED = "enqueued" - BUILDING = "building" - COMPLETED = "completed" - FAILED = "failed" - CANCELED = "canceled" - - """ - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the ModelBuild resource. - :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. - :ivar assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource. - :ivar sid: The unique string that we created to identify the ModelBuild resource. - :ivar status: - :ivar unique_name: An application-defined string that uniquely identifies the resource. It can be used as an alternative to the `sid` in the URL path to address the resource. - :ivar url: The absolute URL of the ModelBuild resource. - :ivar build_duration: The time in seconds it took to build the model. - :ivar error_code: If the `status` for the model build is `failed`, this value is a code to more information about the failure. This value will be null for all other statuses. See [error code dictionary](https://www.twilio.com/docs/api/errors) for a description of the error. - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - assistant_sid: str, - 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.assistant_sid: Optional[str] = payload.get("assistant_sid") - self.sid: Optional[str] = payload.get("sid") - self.status: Optional["ModelBuildInstance.Status"] = payload.get("status") - self.unique_name: Optional[str] = payload.get("unique_name") - self.url: Optional[str] = payload.get("url") - self.build_duration: Optional[int] = deserialize.integer( - payload.get("build_duration") - ) - self.error_code: Optional[int] = deserialize.integer(payload.get("error_code")) - - self._solution = { - "assistant_sid": assistant_sid, - "sid": sid or self.sid, - } - self._context: Optional[ModelBuildContext] = None - - @property - def _proxy(self) -> "ModelBuildContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: ModelBuildContext for this ModelBuildInstance - """ - if self._context is None: - self._context = ModelBuildContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - return self._context - - def delete(self) -> bool: - """ - Deletes the ModelBuildInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the ModelBuildInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def fetch(self) -> "ModelBuildInstance": - """ - Fetch the ModelBuildInstance - - - :returns: The fetched ModelBuildInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "ModelBuildInstance": - """ - Asynchronous coroutine to fetch the ModelBuildInstance - - - :returns: The fetched ModelBuildInstance - """ - return await self._proxy.fetch_async() - - def update( - self, unique_name: Union[str, object] = values.unset - ) -> "ModelBuildInstance": - """ - Update the ModelBuildInstance - - :param unique_name: An application-defined string that uniquely identifies the resource. This value must be a unique string of no more than 64 characters. It can be used as an alternative to the `sid` in the URL path to address the resource. - - :returns: The updated ModelBuildInstance - """ - return self._proxy.update( - unique_name=unique_name, - ) - - async def update_async( - self, unique_name: Union[str, object] = values.unset - ) -> "ModelBuildInstance": - """ - Asynchronous coroutine to update the ModelBuildInstance - - :param unique_name: An application-defined string that uniquely identifies the resource. This value must be a unique string of no more than 64 characters. It can be used as an alternative to the `sid` in the URL path to address the resource. - - :returns: The updated ModelBuildInstance - """ - return await self._proxy.update_async( - unique_name=unique_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 ModelBuildContext(InstanceContext): - def __init__(self, version: Version, assistant_sid: str, sid: str): - """ - Initialize the ModelBuildContext - - :param version: Version that contains the resource - :param assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource to update. - :param sid: The Twilio-provided string that uniquely identifies the ModelBuild resource to update. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - "sid": sid, - } - self._uri = "/Assistants/{assistant_sid}/ModelBuilds/{sid}".format( - **self._solution - ) - - def delete(self) -> bool: - """ - Deletes the ModelBuildInstance - - - :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 ModelBuildInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._version.delete_async( - method="DELETE", - uri=self._uri, - ) - - def fetch(self) -> ModelBuildInstance: - """ - Fetch the ModelBuildInstance - - - :returns: The fetched ModelBuildInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return ModelBuildInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - - async def fetch_async(self) -> ModelBuildInstance: - """ - Asynchronous coroutine to fetch the ModelBuildInstance - - - :returns: The fetched ModelBuildInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return ModelBuildInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - - def update( - self, unique_name: Union[str, object] = values.unset - ) -> ModelBuildInstance: - """ - Update the ModelBuildInstance - - :param unique_name: An application-defined string that uniquely identifies the resource. This value must be a unique string of no more than 64 characters. It can be used as an alternative to the `sid` in the URL path to address the resource. - - :returns: The updated ModelBuildInstance - """ - data = values.of( - { - "UniqueName": unique_name, - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return ModelBuildInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - - async def update_async( - self, unique_name: Union[str, object] = values.unset - ) -> ModelBuildInstance: - """ - Asynchronous coroutine to update the ModelBuildInstance - - :param unique_name: An application-defined string that uniquely identifies the resource. This value must be a unique string of no more than 64 characters. It can be used as an alternative to the `sid` in the URL path to address the resource. - - :returns: The updated ModelBuildInstance - """ - data = values.of( - { - "UniqueName": unique_name, - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return ModelBuildInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_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 ModelBuildPage(Page): - def get_instance(self, payload: Dict[str, Any]) -> ModelBuildInstance: - """ - Build an instance of ModelBuildInstance - - :param payload: Payload response from the API - """ - return ModelBuildInstance( - self._version, payload, assistant_sid=self._solution["assistant_sid"] - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class ModelBuildList(ListResource): - def __init__(self, version: Version, assistant_sid: str): - """ - Initialize the ModelBuildList - - :param version: Version that contains the resource - :param assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resources to read. - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - } - self._uri = "/Assistants/{assistant_sid}/ModelBuilds".format(**self._solution) - - def create( - self, - status_callback: Union[str, object] = values.unset, - unique_name: Union[str, object] = values.unset, - ) -> ModelBuildInstance: - """ - Create the ModelBuildInstance - - :param status_callback: The URL we should call using a POST method to send status information to your application. - :param unique_name: An application-defined string that uniquely identifies the new resource. This value must be a unique string of no more than 64 characters. It can be used as an alternative to the `sid` in the URL path to address the resource. - - :returns: The created ModelBuildInstance - """ - data = values.of( - { - "StatusCallback": status_callback, - "UniqueName": unique_name, - } - ) - - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) - - return ModelBuildInstance( - self._version, payload, assistant_sid=self._solution["assistant_sid"] - ) - - async def create_async( - self, - status_callback: Union[str, object] = values.unset, - unique_name: Union[str, object] = values.unset, - ) -> ModelBuildInstance: - """ - Asynchronously create the ModelBuildInstance - - :param status_callback: The URL we should call using a POST method to send status information to your application. - :param unique_name: An application-defined string that uniquely identifies the new resource. This value must be a unique string of no more than 64 characters. It can be used as an alternative to the `sid` in the URL path to address the resource. - - :returns: The created ModelBuildInstance - """ - data = values.of( - { - "StatusCallback": status_callback, - "UniqueName": unique_name, - } - ) - - payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, - ) - - return ModelBuildInstance( - self._version, payload, assistant_sid=self._solution["assistant_sid"] - ) - - def stream( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[ModelBuildInstance]: - """ - Streams ModelBuildInstance 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[ModelBuildInstance]: - """ - Asynchronously streams ModelBuildInstance 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[ModelBuildInstance]: - """ - Lists ModelBuildInstance 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[ModelBuildInstance]: - """ - Asynchronously lists ModelBuildInstance 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, - ) -> ModelBuildPage: - """ - Retrieve a single page of ModelBuildInstance 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 ModelBuildInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = self._version.page(method="GET", uri=self._uri, params=data) - return ModelBuildPage(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, - ) -> ModelBuildPage: - """ - Asynchronously retrieve a single page of ModelBuildInstance 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 ModelBuildInstance - """ - 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 ModelBuildPage(self._version, response, self._solution) - - def get_page(self, target_url: str) -> ModelBuildPage: - """ - Retrieve a specific page of ModelBuildInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of ModelBuildInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return ModelBuildPage(self._version, response, self._solution) - - async def get_page_async(self, target_url: str) -> ModelBuildPage: - """ - Asynchronously retrieve a specific page of ModelBuildInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of ModelBuildInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return ModelBuildPage(self._version, response, self._solution) - - def get(self, sid: str) -> ModelBuildContext: - """ - Constructs a ModelBuildContext - - :param sid: The Twilio-provided string that uniquely identifies the ModelBuild resource to update. - """ - return ModelBuildContext( - self._version, assistant_sid=self._solution["assistant_sid"], sid=sid - ) - - def __call__(self, sid: str) -> ModelBuildContext: - """ - Constructs a ModelBuildContext - - :param sid: The Twilio-provided string that uniquely identifies the ModelBuild resource to update. - """ - return ModelBuildContext( - self._version, assistant_sid=self._solution["assistant_sid"], sid=sid - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/autopilot/v1/assistant/query.py b/twilio/rest/autopilot/v1/assistant/query.py deleted file mode 100644 index 500f6bb7f7..0000000000 --- a/twilio/rest/autopilot/v1/assistant/query.py +++ /dev/null @@ -1,729 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Autopilot - 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 QueryInstance(InstanceResource): - - """ - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Query resource. - :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. - :ivar results: The natural language analysis results that include the [Task](https://www.twilio.com/docs/autopilot/api/task) recognized and a list of identified [Fields](https://www.twilio.com/docs/autopilot/api/task-field). - :ivar language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used by the Query. For example: `en-US`. - :ivar model_build_sid: The SID of the [Model Build](https://www.twilio.com/docs/autopilot/api/model-build) queried. - :ivar query: The end-user's natural language input. - :ivar sample_sid: The SID of an optional reference to the [Sample](https://www.twilio.com/docs/autopilot/api/task-sample) created from the query. - :ivar assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource. - :ivar sid: The unique string that we created to identify the Query resource. - :ivar status: The status of the Query. Can be: `pending-review`, `reviewed`, or `discarded` - :ivar url: The absolute URL of the Query resource. - :ivar source_channel: The communication channel from where the end-user input came. - :ivar dialogue_sid: The SID of the [Dialogue](https://www.twilio.com/docs/autopilot/api/dialogue). - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - assistant_sid: str, - 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.results: Optional[Dict[str, object]] = payload.get("results") - self.language: Optional[str] = payload.get("language") - self.model_build_sid: Optional[str] = payload.get("model_build_sid") - self.query: Optional[str] = payload.get("query") - self.sample_sid: Optional[str] = payload.get("sample_sid") - self.assistant_sid: Optional[str] = payload.get("assistant_sid") - self.sid: Optional[str] = payload.get("sid") - self.status: Optional[str] = payload.get("status") - self.url: Optional[str] = payload.get("url") - self.source_channel: Optional[str] = payload.get("source_channel") - self.dialogue_sid: Optional[str] = payload.get("dialogue_sid") - - self._solution = { - "assistant_sid": assistant_sid, - "sid": sid or self.sid, - } - self._context: Optional[QueryContext] = None - - @property - def _proxy(self) -> "QueryContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: QueryContext for this QueryInstance - """ - if self._context is None: - self._context = QueryContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - return self._context - - def delete(self) -> bool: - """ - Deletes the QueryInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the QueryInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def fetch(self) -> "QueryInstance": - """ - Fetch the QueryInstance - - - :returns: The fetched QueryInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "QueryInstance": - """ - Asynchronous coroutine to fetch the QueryInstance - - - :returns: The fetched QueryInstance - """ - return await self._proxy.fetch_async() - - def update( - self, - sample_sid: Union[str, object] = values.unset, - status: Union[str, object] = values.unset, - ) -> "QueryInstance": - """ - Update the QueryInstance - - :param sample_sid: The SID of an optional reference to the [Sample](https://www.twilio.com/docs/autopilot/api/task-sample) created from the query. - :param status: The new status of the resource. Can be: `pending-review`, `reviewed`, or `discarded` - - :returns: The updated QueryInstance - """ - return self._proxy.update( - sample_sid=sample_sid, - status=status, - ) - - async def update_async( - self, - sample_sid: Union[str, object] = values.unset, - status: Union[str, object] = values.unset, - ) -> "QueryInstance": - """ - Asynchronous coroutine to update the QueryInstance - - :param sample_sid: The SID of an optional reference to the [Sample](https://www.twilio.com/docs/autopilot/api/task-sample) created from the query. - :param status: The new status of the resource. Can be: `pending-review`, `reviewed`, or `discarded` - - :returns: The updated QueryInstance - """ - return await self._proxy.update_async( - sample_sid=sample_sid, - 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 QueryContext(InstanceContext): - def __init__(self, version: Version, assistant_sid: str, sid: str): - """ - Initialize the QueryContext - - :param version: Version that contains the resource - :param assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource to update. - :param sid: The Twilio-provided string that uniquely identifies the Query resource to update. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - "sid": sid, - } - self._uri = "/Assistants/{assistant_sid}/Queries/{sid}".format(**self._solution) - - def delete(self) -> bool: - """ - Deletes the QueryInstance - - - :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 QueryInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._version.delete_async( - method="DELETE", - uri=self._uri, - ) - - def fetch(self) -> QueryInstance: - """ - Fetch the QueryInstance - - - :returns: The fetched QueryInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return QueryInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - - async def fetch_async(self) -> QueryInstance: - """ - Asynchronous coroutine to fetch the QueryInstance - - - :returns: The fetched QueryInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return QueryInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - - def update( - self, - sample_sid: Union[str, object] = values.unset, - status: Union[str, object] = values.unset, - ) -> QueryInstance: - """ - Update the QueryInstance - - :param sample_sid: The SID of an optional reference to the [Sample](https://www.twilio.com/docs/autopilot/api/task-sample) created from the query. - :param status: The new status of the resource. Can be: `pending-review`, `reviewed`, or `discarded` - - :returns: The updated QueryInstance - """ - data = values.of( - { - "SampleSid": sample_sid, - "Status": status, - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return QueryInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - - async def update_async( - self, - sample_sid: Union[str, object] = values.unset, - status: Union[str, object] = values.unset, - ) -> QueryInstance: - """ - Asynchronous coroutine to update the QueryInstance - - :param sample_sid: The SID of an optional reference to the [Sample](https://www.twilio.com/docs/autopilot/api/task-sample) created from the query. - :param status: The new status of the resource. Can be: `pending-review`, `reviewed`, or `discarded` - - :returns: The updated QueryInstance - """ - data = values.of( - { - "SampleSid": sample_sid, - "Status": status, - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return QueryInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_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 QueryPage(Page): - def get_instance(self, payload: Dict[str, Any]) -> QueryInstance: - """ - Build an instance of QueryInstance - - :param payload: Payload response from the API - """ - return QueryInstance( - self._version, payload, assistant_sid=self._solution["assistant_sid"] - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class QueryList(ListResource): - def __init__(self, version: Version, assistant_sid: str): - """ - Initialize the QueryList - - :param version: Version that contains the resource - :param assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resources to read. - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - } - self._uri = "/Assistants/{assistant_sid}/Queries".format(**self._solution) - - def create( - self, - language: str, - query: str, - tasks: Union[str, object] = values.unset, - model_build: Union[str, object] = values.unset, - ) -> QueryInstance: - """ - Create the QueryInstance - - :param language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the new query. For example: `en-US`. - :param query: The end-user's natural language input. It can be up to 2048 characters long. - :param tasks: The list of tasks to limit the new query to. Tasks are expressed as a comma-separated list of task `unique_name` values. For example, `task-unique_name-1, task-unique_name-2`. Listing specific tasks is useful to constrain the paths that a user can take. - :param model_build: The SID or unique name of the [Model Build](https://www.twilio.com/docs/autopilot/api/model-build) to be queried. - - :returns: The created QueryInstance - """ - data = values.of( - { - "Language": language, - "Query": query, - "Tasks": tasks, - "ModelBuild": model_build, - } - ) - - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) - - return QueryInstance( - self._version, payload, assistant_sid=self._solution["assistant_sid"] - ) - - async def create_async( - self, - language: str, - query: str, - tasks: Union[str, object] = values.unset, - model_build: Union[str, object] = values.unset, - ) -> QueryInstance: - """ - Asynchronously create the QueryInstance - - :param language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the new query. For example: `en-US`. - :param query: The end-user's natural language input. It can be up to 2048 characters long. - :param tasks: The list of tasks to limit the new query to. Tasks are expressed as a comma-separated list of task `unique_name` values. For example, `task-unique_name-1, task-unique_name-2`. Listing specific tasks is useful to constrain the paths that a user can take. - :param model_build: The SID or unique name of the [Model Build](https://www.twilio.com/docs/autopilot/api/model-build) to be queried. - - :returns: The created QueryInstance - """ - data = values.of( - { - "Language": language, - "Query": query, - "Tasks": tasks, - "ModelBuild": model_build, - } - ) - - payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, - ) - - return QueryInstance( - self._version, payload, assistant_sid=self._solution["assistant_sid"] - ) - - def stream( - self, - language: Union[str, object] = values.unset, - model_build: Union[str, object] = values.unset, - status: Union[str, object] = values.unset, - dialogue_sid: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[QueryInstance]: - """ - Streams QueryInstance 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 language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used by the Query resources to read. For example: `en-US`. - :param str model_build: The SID or unique name of the [Model Build](https://www.twilio.com/docs/autopilot/api/model-build) to be queried. - :param str status: The status of the resources to read. Can be: `pending-review`, `reviewed`, or `discarded` - :param str dialogue_sid: The SID of the [Dialogue](https://www.twilio.com/docs/autopilot/api/dialogue). - :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( - language=language, - model_build=model_build, - status=status, - dialogue_sid=dialogue_sid, - page_size=limits["page_size"], - ) - - return self._version.stream(page, limits["limit"]) - - async def stream_async( - self, - language: Union[str, object] = values.unset, - model_build: Union[str, object] = values.unset, - status: Union[str, object] = values.unset, - dialogue_sid: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> AsyncIterator[QueryInstance]: - """ - Asynchronously streams QueryInstance 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 language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used by the Query resources to read. For example: `en-US`. - :param str model_build: The SID or unique name of the [Model Build](https://www.twilio.com/docs/autopilot/api/model-build) to be queried. - :param str status: The status of the resources to read. Can be: `pending-review`, `reviewed`, or `discarded` - :param str dialogue_sid: The SID of the [Dialogue](https://www.twilio.com/docs/autopilot/api/dialogue). - :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( - language=language, - model_build=model_build, - status=status, - dialogue_sid=dialogue_sid, - page_size=limits["page_size"], - ) - - return self._version.stream_async(page, limits["limit"]) - - def list( - self, - language: Union[str, object] = values.unset, - model_build: Union[str, object] = values.unset, - status: Union[str, object] = values.unset, - dialogue_sid: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[QueryInstance]: - """ - Lists QueryInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param str language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used by the Query resources to read. For example: `en-US`. - :param str model_build: The SID or unique name of the [Model Build](https://www.twilio.com/docs/autopilot/api/model-build) to be queried. - :param str status: The status of the resources to read. Can be: `pending-review`, `reviewed`, or `discarded` - :param str dialogue_sid: The SID of the [Dialogue](https://www.twilio.com/docs/autopilot/api/dialogue). - :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( - language=language, - model_build=model_build, - status=status, - dialogue_sid=dialogue_sid, - limit=limit, - page_size=page_size, - ) - ) - - async def list_async( - self, - language: Union[str, object] = values.unset, - model_build: Union[str, object] = values.unset, - status: Union[str, object] = values.unset, - dialogue_sid: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[QueryInstance]: - """ - Asynchronously lists QueryInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param str language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used by the Query resources to read. For example: `en-US`. - :param str model_build: The SID or unique name of the [Model Build](https://www.twilio.com/docs/autopilot/api/model-build) to be queried. - :param str status: The status of the resources to read. Can be: `pending-review`, `reviewed`, or `discarded` - :param str dialogue_sid: The SID of the [Dialogue](https://www.twilio.com/docs/autopilot/api/dialogue). - :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( - language=language, - model_build=model_build, - status=status, - dialogue_sid=dialogue_sid, - limit=limit, - page_size=page_size, - ) - ] - - def page( - self, - language: Union[str, object] = values.unset, - model_build: Union[str, object] = values.unset, - status: Union[str, object] = values.unset, - dialogue_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, - ) -> QueryPage: - """ - Retrieve a single page of QueryInstance records from the API. - Request is executed immediately - - :param language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used by the Query resources to read. For example: `en-US`. - :param model_build: The SID or unique name of the [Model Build](https://www.twilio.com/docs/autopilot/api/model-build) to be queried. - :param status: The status of the resources to read. Can be: `pending-review`, `reviewed`, or `discarded` - :param dialogue_sid: The SID of the [Dialogue](https://www.twilio.com/docs/autopilot/api/dialogue). - :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 QueryInstance - """ - data = values.of( - { - "Language": language, - "ModelBuild": model_build, - "Status": status, - "DialogueSid": dialogue_sid, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = self._version.page(method="GET", uri=self._uri, params=data) - return QueryPage(self._version, response, self._solution) - - async def page_async( - self, - language: Union[str, object] = values.unset, - model_build: Union[str, object] = values.unset, - status: Union[str, object] = values.unset, - dialogue_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, - ) -> QueryPage: - """ - Asynchronously retrieve a single page of QueryInstance records from the API. - Request is executed immediately - - :param language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used by the Query resources to read. For example: `en-US`. - :param model_build: The SID or unique name of the [Model Build](https://www.twilio.com/docs/autopilot/api/model-build) to be queried. - :param status: The status of the resources to read. Can be: `pending-review`, `reviewed`, or `discarded` - :param dialogue_sid: The SID of the [Dialogue](https://www.twilio.com/docs/autopilot/api/dialogue). - :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 QueryInstance - """ - data = values.of( - { - "Language": language, - "ModelBuild": model_build, - "Status": status, - "DialogueSid": dialogue_sid, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = await self._version.page_async( - method="GET", uri=self._uri, params=data - ) - return QueryPage(self._version, response, self._solution) - - def get_page(self, target_url: str) -> QueryPage: - """ - Retrieve a specific page of QueryInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of QueryInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return QueryPage(self._version, response, self._solution) - - async def get_page_async(self, target_url: str) -> QueryPage: - """ - Asynchronously retrieve a specific page of QueryInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of QueryInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return QueryPage(self._version, response, self._solution) - - def get(self, sid: str) -> QueryContext: - """ - Constructs a QueryContext - - :param sid: The Twilio-provided string that uniquely identifies the Query resource to update. - """ - return QueryContext( - self._version, assistant_sid=self._solution["assistant_sid"], sid=sid - ) - - def __call__(self, sid: str) -> QueryContext: - """ - Constructs a QueryContext - - :param sid: The Twilio-provided string that uniquely identifies the Query resource to update. - """ - return QueryContext( - self._version, assistant_sid=self._solution["assistant_sid"], sid=sid - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/autopilot/v1/assistant/style_sheet.py b/twilio/rest/autopilot/v1/assistant/style_sheet.py deleted file mode 100644 index 980ab40111..0000000000 --- a/twilio/rest/autopilot/v1/assistant/style_sheet.py +++ /dev/null @@ -1,273 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Autopilot - 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 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 StyleSheetInstance(InstanceResource): - - """ - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the StyleSheet resource. - :ivar assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource. - :ivar url: The absolute URL of the StyleSheet resource. - :ivar data: The JSON string that describes the style sheet object. - """ - - def __init__(self, version: Version, payload: Dict[str, Any], assistant_sid: str): - super().__init__(version) - - self.account_sid: Optional[str] = payload.get("account_sid") - self.assistant_sid: Optional[str] = payload.get("assistant_sid") - self.url: Optional[str] = payload.get("url") - self.data: Optional[Dict[str, object]] = payload.get("data") - - self._solution = { - "assistant_sid": assistant_sid, - } - self._context: Optional[StyleSheetContext] = None - - @property - def _proxy(self) -> "StyleSheetContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: StyleSheetContext for this StyleSheetInstance - """ - if self._context is None: - self._context = StyleSheetContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - ) - return self._context - - def fetch(self) -> "StyleSheetInstance": - """ - Fetch the StyleSheetInstance - - - :returns: The fetched StyleSheetInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "StyleSheetInstance": - """ - Asynchronous coroutine to fetch the StyleSheetInstance - - - :returns: The fetched StyleSheetInstance - """ - return await self._proxy.fetch_async() - - def update( - self, style_sheet: Union[object, object] = values.unset - ) -> "StyleSheetInstance": - """ - Update the StyleSheetInstance - - :param style_sheet: The JSON string that describes the style sheet object. - - :returns: The updated StyleSheetInstance - """ - return self._proxy.update( - style_sheet=style_sheet, - ) - - async def update_async( - self, style_sheet: Union[object, object] = values.unset - ) -> "StyleSheetInstance": - """ - Asynchronous coroutine to update the StyleSheetInstance - - :param style_sheet: The JSON string that describes the style sheet object. - - :returns: The updated StyleSheetInstance - """ - return await self._proxy.update_async( - style_sheet=style_sheet, - ) - - 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 StyleSheetContext(InstanceContext): - def __init__(self, version: Version, assistant_sid: str): - """ - Initialize the StyleSheetContext - - :param version: Version that contains the resource - :param assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource to update. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - } - self._uri = "/Assistants/{assistant_sid}/StyleSheet".format(**self._solution) - - def fetch(self) -> StyleSheetInstance: - """ - Fetch the StyleSheetInstance - - - :returns: The fetched StyleSheetInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return StyleSheetInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - ) - - async def fetch_async(self) -> StyleSheetInstance: - """ - Asynchronous coroutine to fetch the StyleSheetInstance - - - :returns: The fetched StyleSheetInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return StyleSheetInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - ) - - def update( - self, style_sheet: Union[object, object] = values.unset - ) -> StyleSheetInstance: - """ - Update the StyleSheetInstance - - :param style_sheet: The JSON string that describes the style sheet object. - - :returns: The updated StyleSheetInstance - """ - data = values.of( - { - "StyleSheet": serialize.object(style_sheet), - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return StyleSheetInstance( - self._version, payload, assistant_sid=self._solution["assistant_sid"] - ) - - async def update_async( - self, style_sheet: Union[object, object] = values.unset - ) -> StyleSheetInstance: - """ - Asynchronous coroutine to update the StyleSheetInstance - - :param style_sheet: The JSON string that describes the style sheet object. - - :returns: The updated StyleSheetInstance - """ - data = values.of( - { - "StyleSheet": serialize.object(style_sheet), - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return StyleSheetInstance( - self._version, payload, assistant_sid=self._solution["assistant_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 StyleSheetList(ListResource): - def __init__(self, version: Version, assistant_sid: str): - """ - Initialize the StyleSheetList - - :param version: Version that contains the resource - :param assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource to fetch. - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - } - - def get(self) -> StyleSheetContext: - """ - Constructs a StyleSheetContext - - """ - return StyleSheetContext( - self._version, assistant_sid=self._solution["assistant_sid"] - ) - - def __call__(self) -> StyleSheetContext: - """ - Constructs a StyleSheetContext - - """ - return StyleSheetContext( - self._version, assistant_sid=self._solution["assistant_sid"] - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/autopilot/v1/assistant/task/__init__.py b/twilio/rest/autopilot/v1/assistant/task/__init__.py deleted file mode 100644 index c90b412acf..0000000000 --- a/twilio/rest/autopilot/v1/assistant/task/__init__.py +++ /dev/null @@ -1,758 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Autopilot - 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.autopilot.v1.assistant.task.field import FieldList -from twilio.rest.autopilot.v1.assistant.task.sample import SampleList -from twilio.rest.autopilot.v1.assistant.task.task_actions import TaskActionsList -from twilio.rest.autopilot.v1.assistant.task.task_statistics import TaskStatisticsList - - -class TaskInstance(InstanceResource): - - """ - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Task resource. - :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. - :ivar friendly_name: The string that you assigned to describe the resource. It is not unique and can be up to 255 characters long. - :ivar links: A list of the URLs of related resources. - :ivar assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource. - :ivar sid: The unique string that we created to identify the Task 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. - :ivar actions_url: The URL from which the Assistant can fetch actions. - :ivar url: The absolute URL of the Task resource. - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - assistant_sid: str, - 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.friendly_name: Optional[str] = payload.get("friendly_name") - self.links: Optional[Dict[str, object]] = payload.get("links") - self.assistant_sid: Optional[str] = payload.get("assistant_sid") - self.sid: Optional[str] = payload.get("sid") - self.unique_name: Optional[str] = payload.get("unique_name") - self.actions_url: Optional[str] = payload.get("actions_url") - self.url: Optional[str] = payload.get("url") - - self._solution = { - "assistant_sid": assistant_sid, - "sid": sid or self.sid, - } - self._context: Optional[TaskContext] = None - - @property - def _proxy(self) -> "TaskContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: TaskContext for this TaskInstance - """ - if self._context is None: - self._context = TaskContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - return self._context - - def delete(self) -> bool: - """ - Deletes the TaskInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the TaskInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def fetch(self) -> "TaskInstance": - """ - Fetch the TaskInstance - - - :returns: The fetched TaskInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "TaskInstance": - """ - Asynchronous coroutine to fetch the TaskInstance - - - :returns: The fetched TaskInstance - """ - return await self._proxy.fetch_async() - - def update( - self, - friendly_name: Union[str, object] = values.unset, - unique_name: Union[str, object] = values.unset, - actions: Union[object, object] = values.unset, - actions_url: Union[str, object] = values.unset, - ) -> "TaskInstance": - """ - Update the TaskInstance - - :param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long. - :param unique_name: An application-defined string that uniquely identifies the resource. This value must be 64 characters or less in length and be unique. It can be used as an alternative to the `sid` in the URL path to address the resource. - :param actions: The JSON string that specifies the [actions](https://www.twilio.com/docs/autopilot/actions) that instruct the Assistant on how to perform the task. - :param actions_url: The URL from which the Assistant can fetch actions. - - :returns: The updated TaskInstance - """ - return self._proxy.update( - friendly_name=friendly_name, - unique_name=unique_name, - actions=actions, - actions_url=actions_url, - ) - - async def update_async( - self, - friendly_name: Union[str, object] = values.unset, - unique_name: Union[str, object] = values.unset, - actions: Union[object, object] = values.unset, - actions_url: Union[str, object] = values.unset, - ) -> "TaskInstance": - """ - Asynchronous coroutine to update the TaskInstance - - :param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long. - :param unique_name: An application-defined string that uniquely identifies the resource. This value must be 64 characters or less in length and be unique. It can be used as an alternative to the `sid` in the URL path to address the resource. - :param actions: The JSON string that specifies the [actions](https://www.twilio.com/docs/autopilot/actions) that instruct the Assistant on how to perform the task. - :param actions_url: The URL from which the Assistant can fetch actions. - - :returns: The updated TaskInstance - """ - return await self._proxy.update_async( - friendly_name=friendly_name, - unique_name=unique_name, - actions=actions, - actions_url=actions_url, - ) - - @property - def fields(self) -> FieldList: - """ - Access the fields - """ - return self._proxy.fields - - @property - def samples(self) -> SampleList: - """ - Access the samples - """ - return self._proxy.samples - - @property - def task_actions(self) -> TaskActionsList: - """ - Access the task_actions - """ - return self._proxy.task_actions - - @property - def statistics(self) -> TaskStatisticsList: - """ - Access the statistics - """ - return self._proxy.statistics - - 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 TaskContext(InstanceContext): - def __init__(self, version: Version, assistant_sid: str, sid: str): - """ - Initialize the TaskContext - - :param version: Version that contains the resource - :param assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource to update. - :param sid: The Twilio-provided string that uniquely identifies the Task resource to update. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - "sid": sid, - } - self._uri = "/Assistants/{assistant_sid}/Tasks/{sid}".format(**self._solution) - - self._fields: Optional[FieldList] = None - self._samples: Optional[SampleList] = None - self._task_actions: Optional[TaskActionsList] = None - self._statistics: Optional[TaskStatisticsList] = None - - def delete(self) -> bool: - """ - Deletes the TaskInstance - - - :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 TaskInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._version.delete_async( - method="DELETE", - uri=self._uri, - ) - - def fetch(self) -> TaskInstance: - """ - Fetch the TaskInstance - - - :returns: The fetched TaskInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return TaskInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - - async def fetch_async(self) -> TaskInstance: - """ - Asynchronous coroutine to fetch the TaskInstance - - - :returns: The fetched TaskInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return TaskInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - - def update( - self, - friendly_name: Union[str, object] = values.unset, - unique_name: Union[str, object] = values.unset, - actions: Union[object, object] = values.unset, - actions_url: Union[str, object] = values.unset, - ) -> TaskInstance: - """ - Update the TaskInstance - - :param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long. - :param unique_name: An application-defined string that uniquely identifies the resource. This value must be 64 characters or less in length and be unique. It can be used as an alternative to the `sid` in the URL path to address the resource. - :param actions: The JSON string that specifies the [actions](https://www.twilio.com/docs/autopilot/actions) that instruct the Assistant on how to perform the task. - :param actions_url: The URL from which the Assistant can fetch actions. - - :returns: The updated TaskInstance - """ - data = values.of( - { - "FriendlyName": friendly_name, - "UniqueName": unique_name, - "Actions": serialize.object(actions), - "ActionsUrl": actions_url, - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return TaskInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - - async def update_async( - self, - friendly_name: Union[str, object] = values.unset, - unique_name: Union[str, object] = values.unset, - actions: Union[object, object] = values.unset, - actions_url: Union[str, object] = values.unset, - ) -> TaskInstance: - """ - Asynchronous coroutine to update the TaskInstance - - :param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long. - :param unique_name: An application-defined string that uniquely identifies the resource. This value must be 64 characters or less in length and be unique. It can be used as an alternative to the `sid` in the URL path to address the resource. - :param actions: The JSON string that specifies the [actions](https://www.twilio.com/docs/autopilot/actions) that instruct the Assistant on how to perform the task. - :param actions_url: The URL from which the Assistant can fetch actions. - - :returns: The updated TaskInstance - """ - data = values.of( - { - "FriendlyName": friendly_name, - "UniqueName": unique_name, - "Actions": serialize.object(actions), - "ActionsUrl": actions_url, - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return TaskInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - - @property - def fields(self) -> FieldList: - """ - Access the fields - """ - if self._fields is None: - self._fields = FieldList( - self._version, - self._solution["assistant_sid"], - self._solution["sid"], - ) - return self._fields - - @property - def samples(self) -> SampleList: - """ - Access the samples - """ - if self._samples is None: - self._samples = SampleList( - self._version, - self._solution["assistant_sid"], - self._solution["sid"], - ) - return self._samples - - @property - def task_actions(self) -> TaskActionsList: - """ - Access the task_actions - """ - if self._task_actions is None: - self._task_actions = TaskActionsList( - self._version, - self._solution["assistant_sid"], - self._solution["sid"], - ) - return self._task_actions - - @property - def statistics(self) -> TaskStatisticsList: - """ - Access the statistics - """ - if self._statistics is None: - self._statistics = TaskStatisticsList( - self._version, - self._solution["assistant_sid"], - self._solution["sid"], - ) - return self._statistics - - 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 TaskPage(Page): - def get_instance(self, payload: Dict[str, Any]) -> TaskInstance: - """ - Build an instance of TaskInstance - - :param payload: Payload response from the API - """ - return TaskInstance( - self._version, payload, assistant_sid=self._solution["assistant_sid"] - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class TaskList(ListResource): - def __init__(self, version: Version, assistant_sid: str): - """ - Initialize the TaskList - - :param version: Version that contains the resource - :param assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resources to read. - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - } - self._uri = "/Assistants/{assistant_sid}/Tasks".format(**self._solution) - - def create( - self, - unique_name: str, - friendly_name: Union[str, object] = values.unset, - actions: Union[object, object] = values.unset, - actions_url: Union[str, object] = values.unset, - ) -> TaskInstance: - """ - Create the TaskInstance - - :param unique_name: An application-defined string that uniquely identifies the new resource. It can be used as an alternative to the `sid` in the URL path to address the resource. This value must be unique and 64 characters or less in length. - :param friendly_name: A descriptive string that you create to describe the new resource. It is not unique and can be up to 255 characters long. - :param actions: The JSON string that specifies the [actions](https://www.twilio.com/docs/autopilot/actions) that instruct the Assistant on how to perform the task. It is optional and not unique. - :param actions_url: The URL from which the Assistant can fetch actions. - - :returns: The created TaskInstance - """ - data = values.of( - { - "UniqueName": unique_name, - "FriendlyName": friendly_name, - "Actions": serialize.object(actions), - "ActionsUrl": actions_url, - } - ) - - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) - - return TaskInstance( - self._version, payload, assistant_sid=self._solution["assistant_sid"] - ) - - async def create_async( - self, - unique_name: str, - friendly_name: Union[str, object] = values.unset, - actions: Union[object, object] = values.unset, - actions_url: Union[str, object] = values.unset, - ) -> TaskInstance: - """ - Asynchronously create the TaskInstance - - :param unique_name: An application-defined string that uniquely identifies the new resource. It can be used as an alternative to the `sid` in the URL path to address the resource. This value must be unique and 64 characters or less in length. - :param friendly_name: A descriptive string that you create to describe the new resource. It is not unique and can be up to 255 characters long. - :param actions: The JSON string that specifies the [actions](https://www.twilio.com/docs/autopilot/actions) that instruct the Assistant on how to perform the task. It is optional and not unique. - :param actions_url: The URL from which the Assistant can fetch actions. - - :returns: The created TaskInstance - """ - data = values.of( - { - "UniqueName": unique_name, - "FriendlyName": friendly_name, - "Actions": serialize.object(actions), - "ActionsUrl": actions_url, - } - ) - - payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, - ) - - return TaskInstance( - self._version, payload, assistant_sid=self._solution["assistant_sid"] - ) - - def stream( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[TaskInstance]: - """ - Streams TaskInstance 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[TaskInstance]: - """ - Asynchronously streams TaskInstance 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[TaskInstance]: - """ - Lists TaskInstance 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[TaskInstance]: - """ - Asynchronously lists TaskInstance 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, - ) -> TaskPage: - """ - Retrieve a single page of TaskInstance 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 TaskInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = self._version.page(method="GET", uri=self._uri, params=data) - return TaskPage(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, - ) -> TaskPage: - """ - Asynchronously retrieve a single page of TaskInstance 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 TaskInstance - """ - 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 TaskPage(self._version, response, self._solution) - - def get_page(self, target_url: str) -> TaskPage: - """ - Retrieve a specific page of TaskInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of TaskInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return TaskPage(self._version, response, self._solution) - - async def get_page_async(self, target_url: str) -> TaskPage: - """ - Asynchronously retrieve a specific page of TaskInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of TaskInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return TaskPage(self._version, response, self._solution) - - def get(self, sid: str) -> TaskContext: - """ - Constructs a TaskContext - - :param sid: The Twilio-provided string that uniquely identifies the Task resource to update. - """ - return TaskContext( - self._version, assistant_sid=self._solution["assistant_sid"], sid=sid - ) - - def __call__(self, sid: str) -> TaskContext: - """ - Constructs a TaskContext - - :param sid: The Twilio-provided string that uniquely identifies the Task resource to update. - """ - return TaskContext( - self._version, assistant_sid=self._solution["assistant_sid"], sid=sid - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/autopilot/v1/assistant/task/sample.py b/twilio/rest/autopilot/v1/assistant/task/sample.py deleted file mode 100644 index ce413aeaa1..0000000000 --- a/twilio/rest/autopilot/v1/assistant/task/sample.py +++ /dev/null @@ -1,697 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Autopilot - 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 SampleInstance(InstanceResource): - - """ - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Sample resource. - :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. - :ivar task_sid: The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) associated with the resource. - :ivar language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the sample. For example: `en-US`. - :ivar assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the Task associated with the resource. - :ivar sid: The unique string that we created to identify the Sample resource. - :ivar tagged_text: The text example of how end users might express the task. The sample can contain [Field tag blocks](https://www.twilio.com/docs/autopilot/api/task-sample#field-tagging). - :ivar url: The absolute URL of the Sample resource. - :ivar source_channel: The communication channel from which the sample was captured. Can be: `voice`, `sms`, `chat`, `alexa`, `google-assistant`, `slack`, or null if not included. - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - assistant_sid: str, - task_sid: str, - 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.task_sid: Optional[str] = payload.get("task_sid") - self.language: Optional[str] = payload.get("language") - self.assistant_sid: Optional[str] = payload.get("assistant_sid") - self.sid: Optional[str] = payload.get("sid") - self.tagged_text: Optional[str] = payload.get("tagged_text") - self.url: Optional[str] = payload.get("url") - self.source_channel: Optional[str] = payload.get("source_channel") - - self._solution = { - "assistant_sid": assistant_sid, - "task_sid": task_sid, - "sid": sid or self.sid, - } - self._context: Optional[SampleContext] = None - - @property - def _proxy(self) -> "SampleContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: SampleContext for this SampleInstance - """ - if self._context is None: - self._context = SampleContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - sid=self._solution["sid"], - ) - return self._context - - def delete(self) -> bool: - """ - Deletes the SampleInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the SampleInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def fetch(self) -> "SampleInstance": - """ - Fetch the SampleInstance - - - :returns: The fetched SampleInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "SampleInstance": - """ - Asynchronous coroutine to fetch the SampleInstance - - - :returns: The fetched SampleInstance - """ - return await self._proxy.fetch_async() - - def update( - self, - language: Union[str, object] = values.unset, - tagged_text: Union[str, object] = values.unset, - source_channel: Union[str, object] = values.unset, - ) -> "SampleInstance": - """ - Update the SampleInstance - - :param language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the sample. For example: `en-US`. - :param tagged_text: The text example of how end users might express the task. The sample can contain [Field tag blocks](https://www.twilio.com/docs/autopilot/api/task-sample#field-tagging). - :param source_channel: The communication channel from which the sample was captured. Can be: `voice`, `sms`, `chat`, `alexa`, `google-assistant`, `slack`, or null if not included. - - :returns: The updated SampleInstance - """ - return self._proxy.update( - language=language, - tagged_text=tagged_text, - source_channel=source_channel, - ) - - async def update_async( - self, - language: Union[str, object] = values.unset, - tagged_text: Union[str, object] = values.unset, - source_channel: Union[str, object] = values.unset, - ) -> "SampleInstance": - """ - Asynchronous coroutine to update the SampleInstance - - :param language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the sample. For example: `en-US`. - :param tagged_text: The text example of how end users might express the task. The sample can contain [Field tag blocks](https://www.twilio.com/docs/autopilot/api/task-sample#field-tagging). - :param source_channel: The communication channel from which the sample was captured. Can be: `voice`, `sms`, `chat`, `alexa`, `google-assistant`, `slack`, or null if not included. - - :returns: The updated SampleInstance - """ - return await self._proxy.update_async( - language=language, - tagged_text=tagged_text, - source_channel=source_channel, - ) - - 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 SampleContext(InstanceContext): - def __init__(self, version: Version, assistant_sid: str, task_sid: str, sid: str): - """ - Initialize the SampleContext - - :param version: Version that contains the resource - :param assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the Task associated with the resource to update. - :param task_sid: The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) associated with the Sample resource to update. - :param sid: The Twilio-provided string that uniquely identifies the Sample resource to update. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - "task_sid": task_sid, - "sid": sid, - } - self._uri = "/Assistants/{assistant_sid}/Tasks/{task_sid}/Samples/{sid}".format( - **self._solution - ) - - def delete(self) -> bool: - """ - Deletes the SampleInstance - - - :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 SampleInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._version.delete_async( - method="DELETE", - uri=self._uri, - ) - - def fetch(self) -> SampleInstance: - """ - Fetch the SampleInstance - - - :returns: The fetched SampleInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return SampleInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - sid=self._solution["sid"], - ) - - async def fetch_async(self) -> SampleInstance: - """ - Asynchronous coroutine to fetch the SampleInstance - - - :returns: The fetched SampleInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return SampleInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - sid=self._solution["sid"], - ) - - def update( - self, - language: Union[str, object] = values.unset, - tagged_text: Union[str, object] = values.unset, - source_channel: Union[str, object] = values.unset, - ) -> SampleInstance: - """ - Update the SampleInstance - - :param language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the sample. For example: `en-US`. - :param tagged_text: The text example of how end users might express the task. The sample can contain [Field tag blocks](https://www.twilio.com/docs/autopilot/api/task-sample#field-tagging). - :param source_channel: The communication channel from which the sample was captured. Can be: `voice`, `sms`, `chat`, `alexa`, `google-assistant`, `slack`, or null if not included. - - :returns: The updated SampleInstance - """ - data = values.of( - { - "Language": language, - "TaggedText": tagged_text, - "SourceChannel": source_channel, - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return SampleInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - sid=self._solution["sid"], - ) - - async def update_async( - self, - language: Union[str, object] = values.unset, - tagged_text: Union[str, object] = values.unset, - source_channel: Union[str, object] = values.unset, - ) -> SampleInstance: - """ - Asynchronous coroutine to update the SampleInstance - - :param language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the sample. For example: `en-US`. - :param tagged_text: The text example of how end users might express the task. The sample can contain [Field tag blocks](https://www.twilio.com/docs/autopilot/api/task-sample#field-tagging). - :param source_channel: The communication channel from which the sample was captured. Can be: `voice`, `sms`, `chat`, `alexa`, `google-assistant`, `slack`, or null if not included. - - :returns: The updated SampleInstance - """ - data = values.of( - { - "Language": language, - "TaggedText": tagged_text, - "SourceChannel": source_channel, - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return SampleInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_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 SamplePage(Page): - def get_instance(self, payload: Dict[str, Any]) -> SampleInstance: - """ - Build an instance of SampleInstance - - :param payload: Payload response from the API - """ - return SampleInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class SampleList(ListResource): - def __init__(self, version: Version, assistant_sid: str, task_sid: str): - """ - Initialize the SampleList - - :param version: Version that contains the resource - :param assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the Task associated with the resources to read. - :param task_sid: The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) associated with the Sample resources to read. - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - "task_sid": task_sid, - } - self._uri = "/Assistants/{assistant_sid}/Tasks/{task_sid}/Samples".format( - **self._solution - ) - - def create( - self, - language: str, - tagged_text: str, - source_channel: Union[str, object] = values.unset, - ) -> SampleInstance: - """ - Create the SampleInstance - - :param language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the new sample. For example: `en-US`. - :param tagged_text: The text example of how end users might express the task. The sample can contain [Field tag blocks](https://www.twilio.com/docs/autopilot/api/task-sample#field-tagging). - :param source_channel: The communication channel from which the new sample was captured. Can be: `voice`, `sms`, `chat`, `alexa`, `google-assistant`, `slack`, or null if not included. - - :returns: The created SampleInstance - """ - data = values.of( - { - "Language": language, - "TaggedText": tagged_text, - "SourceChannel": source_channel, - } - ) - - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) - - return SampleInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - ) - - async def create_async( - self, - language: str, - tagged_text: str, - source_channel: Union[str, object] = values.unset, - ) -> SampleInstance: - """ - Asynchronously create the SampleInstance - - :param language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the new sample. For example: `en-US`. - :param tagged_text: The text example of how end users might express the task. The sample can contain [Field tag blocks](https://www.twilio.com/docs/autopilot/api/task-sample#field-tagging). - :param source_channel: The communication channel from which the new sample was captured. Can be: `voice`, `sms`, `chat`, `alexa`, `google-assistant`, `slack`, or null if not included. - - :returns: The created SampleInstance - """ - data = values.of( - { - "Language": language, - "TaggedText": tagged_text, - "SourceChannel": source_channel, - } - ) - - payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, - ) - - return SampleInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - ) - - def stream( - self, - language: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[SampleInstance]: - """ - Streams SampleInstance 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 language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the sample. For example: `en-US`. - :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(language=language, page_size=limits["page_size"]) - - return self._version.stream(page, limits["limit"]) - - async def stream_async( - self, - language: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> AsyncIterator[SampleInstance]: - """ - Asynchronously streams SampleInstance 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 language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the sample. For example: `en-US`. - :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(language=language, page_size=limits["page_size"]) - - return self._version.stream_async(page, limits["limit"]) - - def list( - self, - language: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[SampleInstance]: - """ - Lists SampleInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param str language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the sample. For example: `en-US`. - :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( - language=language, - limit=limit, - page_size=page_size, - ) - ) - - async def list_async( - self, - language: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[SampleInstance]: - """ - Asynchronously lists SampleInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param str language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the sample. For example: `en-US`. - :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( - language=language, - limit=limit, - page_size=page_size, - ) - ] - - def page( - self, - language: 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, - ) -> SamplePage: - """ - Retrieve a single page of SampleInstance records from the API. - Request is executed immediately - - :param language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the sample. For example: `en-US`. - :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 SampleInstance - """ - data = values.of( - { - "Language": language, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = self._version.page(method="GET", uri=self._uri, params=data) - return SamplePage(self._version, response, self._solution) - - async def page_async( - self, - language: 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, - ) -> SamplePage: - """ - Asynchronously retrieve a single page of SampleInstance records from the API. - Request is executed immediately - - :param language: The [ISO language-country](https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the sample. For example: `en-US`. - :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 SampleInstance - """ - data = values.of( - { - "Language": language, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = await self._version.page_async( - method="GET", uri=self._uri, params=data - ) - return SamplePage(self._version, response, self._solution) - - def get_page(self, target_url: str) -> SamplePage: - """ - Retrieve a specific page of SampleInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of SampleInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return SamplePage(self._version, response, self._solution) - - async def get_page_async(self, target_url: str) -> SamplePage: - """ - Asynchronously retrieve a specific page of SampleInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of SampleInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return SamplePage(self._version, response, self._solution) - - def get(self, sid: str) -> SampleContext: - """ - Constructs a SampleContext - - :param sid: The Twilio-provided string that uniquely identifies the Sample resource to update. - """ - return SampleContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - sid=sid, - ) - - def __call__(self, sid: str) -> SampleContext: - """ - Constructs a SampleContext - - :param sid: The Twilio-provided string that uniquely identifies the Sample resource to update. - """ - return SampleContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - sid=sid, - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/autopilot/v1/assistant/task/task_actions.py b/twilio/rest/autopilot/v1/assistant/task/task_actions.py deleted file mode 100644 index 01d4efa2c1..0000000000 --- a/twilio/rest/autopilot/v1/assistant/task/task_actions.py +++ /dev/null @@ -1,301 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Autopilot - 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 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 TaskActionsInstance(InstanceResource): - - """ - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the TaskActions resource. - :ivar assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the Task associated with the resource. - :ivar task_sid: The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) associated with the resource. - :ivar url: The absolute URL of the TaskActions resource. - :ivar data: The JSON string that specifies the [actions](https://www.twilio.com/docs/autopilot/actions) that instruct the Assistant on how to perform the task. - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - assistant_sid: str, - task_sid: str, - ): - super().__init__(version) - - self.account_sid: Optional[str] = payload.get("account_sid") - self.assistant_sid: Optional[str] = payload.get("assistant_sid") - self.task_sid: Optional[str] = payload.get("task_sid") - self.url: Optional[str] = payload.get("url") - self.data: Optional[Dict[str, object]] = payload.get("data") - - self._solution = { - "assistant_sid": assistant_sid, - "task_sid": task_sid, - } - self._context: Optional[TaskActionsContext] = None - - @property - def _proxy(self) -> "TaskActionsContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: TaskActionsContext for this TaskActionsInstance - """ - if self._context is None: - self._context = TaskActionsContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - ) - return self._context - - def fetch(self) -> "TaskActionsInstance": - """ - Fetch the TaskActionsInstance - - - :returns: The fetched TaskActionsInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "TaskActionsInstance": - """ - Asynchronous coroutine to fetch the TaskActionsInstance - - - :returns: The fetched TaskActionsInstance - """ - return await self._proxy.fetch_async() - - def update( - self, actions: Union[object, object] = values.unset - ) -> "TaskActionsInstance": - """ - Update the TaskActionsInstance - - :param actions: The JSON string that specifies the [actions](https://www.twilio.com/docs/autopilot/actions) that instruct the Assistant on how to perform the task. - - :returns: The updated TaskActionsInstance - """ - return self._proxy.update( - actions=actions, - ) - - async def update_async( - self, actions: Union[object, object] = values.unset - ) -> "TaskActionsInstance": - """ - Asynchronous coroutine to update the TaskActionsInstance - - :param actions: The JSON string that specifies the [actions](https://www.twilio.com/docs/autopilot/actions) that instruct the Assistant on how to perform the task. - - :returns: The updated TaskActionsInstance - """ - return await self._proxy.update_async( - actions=actions, - ) - - 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 TaskActionsContext(InstanceContext): - def __init__(self, version: Version, assistant_sid: str, task_sid: str): - """ - Initialize the TaskActionsContext - - :param version: Version that contains the resource - :param assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the Task for which the task actions to update were defined. - :param task_sid: The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) for which the task actions to update were defined. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - "task_sid": task_sid, - } - self._uri = "/Assistants/{assistant_sid}/Tasks/{task_sid}/Actions".format( - **self._solution - ) - - def fetch(self) -> TaskActionsInstance: - """ - Fetch the TaskActionsInstance - - - :returns: The fetched TaskActionsInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return TaskActionsInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - ) - - async def fetch_async(self) -> TaskActionsInstance: - """ - Asynchronous coroutine to fetch the TaskActionsInstance - - - :returns: The fetched TaskActionsInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return TaskActionsInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - ) - - def update( - self, actions: Union[object, object] = values.unset - ) -> TaskActionsInstance: - """ - Update the TaskActionsInstance - - :param actions: The JSON string that specifies the [actions](https://www.twilio.com/docs/autopilot/actions) that instruct the Assistant on how to perform the task. - - :returns: The updated TaskActionsInstance - """ - data = values.of( - { - "Actions": serialize.object(actions), - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return TaskActionsInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - ) - - async def update_async( - self, actions: Union[object, object] = values.unset - ) -> TaskActionsInstance: - """ - Asynchronous coroutine to update the TaskActionsInstance - - :param actions: The JSON string that specifies the [actions](https://www.twilio.com/docs/autopilot/actions) that instruct the Assistant on how to perform the task. - - :returns: The updated TaskActionsInstance - """ - data = values.of( - { - "Actions": serialize.object(actions), - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return TaskActionsInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_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 TaskActionsList(ListResource): - def __init__(self, version: Version, assistant_sid: str, task_sid: str): - """ - Initialize the TaskActionsList - - :param version: Version that contains the resource - :param assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the Task for which the task actions to fetch were defined. - :param task_sid: The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) for which the task actions to fetch were defined. - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - "task_sid": task_sid, - } - - def get(self) -> TaskActionsContext: - """ - Constructs a TaskActionsContext - - """ - return TaskActionsContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - ) - - def __call__(self) -> TaskActionsContext: - """ - Constructs a TaskActionsContext - - """ - return TaskActionsContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/autopilot/v1/assistant/task/task_statistics.py b/twilio/rest/autopilot/v1/assistant/task/task_statistics.py deleted file mode 100644 index 3d92b05cb9..0000000000 --- a/twilio/rest/autopilot/v1/assistant/task/task_statistics.py +++ /dev/null @@ -1,221 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Autopilot - 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 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 TaskStatisticsInstance(InstanceResource): - - """ - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the TaskStatistics resource. - :ivar assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the Task associated with the resource. - :ivar task_sid: The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) for which the statistics were collected. - :ivar samples_count: The total number of [Samples](https://www.twilio.com/docs/autopilot/api/task-sample) associated with the Task. - :ivar fields_count: The total number of [Fields](https://www.twilio.com/docs/autopilot/api/task-field) associated with the Task. - :ivar url: The absolute URL of the TaskStatistics resource. - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - assistant_sid: str, - task_sid: str, - ): - super().__init__(version) - - self.account_sid: Optional[str] = payload.get("account_sid") - self.assistant_sid: Optional[str] = payload.get("assistant_sid") - self.task_sid: Optional[str] = payload.get("task_sid") - self.samples_count: Optional[int] = deserialize.integer( - payload.get("samples_count") - ) - self.fields_count: Optional[int] = deserialize.integer( - payload.get("fields_count") - ) - self.url: Optional[str] = payload.get("url") - - self._solution = { - "assistant_sid": assistant_sid, - "task_sid": task_sid, - } - self._context: Optional[TaskStatisticsContext] = None - - @property - def _proxy(self) -> "TaskStatisticsContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: TaskStatisticsContext for this TaskStatisticsInstance - """ - if self._context is None: - self._context = TaskStatisticsContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - ) - return self._context - - def fetch(self) -> "TaskStatisticsInstance": - """ - Fetch the TaskStatisticsInstance - - - :returns: The fetched TaskStatisticsInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "TaskStatisticsInstance": - """ - Asynchronous coroutine to fetch the TaskStatisticsInstance - - - :returns: The fetched TaskStatisticsInstance - """ - 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 TaskStatisticsContext(InstanceContext): - def __init__(self, version: Version, assistant_sid: str, task_sid: str): - """ - Initialize the TaskStatisticsContext - - :param version: Version that contains the resource - :param assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource to fetch. - :param task_sid: The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) that is associated with the resource to fetch. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - "task_sid": task_sid, - } - self._uri = "/Assistants/{assistant_sid}/Tasks/{task_sid}/Statistics".format( - **self._solution - ) - - def fetch(self) -> TaskStatisticsInstance: - """ - Fetch the TaskStatisticsInstance - - - :returns: The fetched TaskStatisticsInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return TaskStatisticsInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - ) - - async def fetch_async(self) -> TaskStatisticsInstance: - """ - Asynchronous coroutine to fetch the TaskStatisticsInstance - - - :returns: The fetched TaskStatisticsInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return TaskStatisticsInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_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 TaskStatisticsList(ListResource): - def __init__(self, version: Version, assistant_sid: str, task_sid: str): - """ - Initialize the TaskStatisticsList - - :param version: Version that contains the resource - :param assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource to fetch. - :param task_sid: The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) that is associated with the resource to fetch. - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - "task_sid": task_sid, - } - - def get(self) -> TaskStatisticsContext: - """ - Constructs a TaskStatisticsContext - - """ - return TaskStatisticsContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - ) - - def __call__(self) -> TaskStatisticsContext: - """ - Constructs a TaskStatisticsContext - - """ - return TaskStatisticsContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/autopilot/v1/assistant/webhook.py b/twilio/rest/autopilot/v1/assistant/webhook.py deleted file mode 100644 index 8a3e3da2f6..0000000000 --- a/twilio/rest/autopilot/v1/assistant/webhook.py +++ /dev/null @@ -1,671 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Autopilot - 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 WebhookInstance(InstanceResource): - - """ - :ivar url: The absolute URL of the Webhook resource. - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Webhook resource. - :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. - :ivar assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource. - :ivar sid: The unique string that we created to identify the Webhook 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. - :ivar events: The list of space-separated events that this Webhook is subscribed to. - :ivar webhook_url: The URL associated with this Webhook. - :ivar webhook_method: The method used when calling the webhook's URL. - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - assistant_sid: str, - sid: Optional[str] = None, - ): - super().__init__(version) - - 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.date_updated: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("date_updated") - ) - self.assistant_sid: Optional[str] = payload.get("assistant_sid") - self.sid: Optional[str] = payload.get("sid") - self.unique_name: Optional[str] = payload.get("unique_name") - self.events: Optional[str] = payload.get("events") - self.webhook_url: Optional[str] = payload.get("webhook_url") - self.webhook_method: Optional[str] = payload.get("webhook_method") - - self._solution = { - "assistant_sid": assistant_sid, - "sid": sid or self.sid, - } - self._context: Optional[WebhookContext] = None - - @property - def _proxy(self) -> "WebhookContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: WebhookContext for this WebhookInstance - """ - if self._context is None: - self._context = WebhookContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - return self._context - - def delete(self) -> bool: - """ - Deletes the WebhookInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the WebhookInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def fetch(self) -> "WebhookInstance": - """ - Fetch the WebhookInstance - - - :returns: The fetched WebhookInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "WebhookInstance": - """ - Asynchronous coroutine to fetch the WebhookInstance - - - :returns: The fetched WebhookInstance - """ - return await self._proxy.fetch_async() - - def update( - self, - unique_name: Union[str, object] = values.unset, - events: Union[str, object] = values.unset, - webhook_url: Union[str, object] = values.unset, - webhook_method: Union[str, object] = values.unset, - ) -> "WebhookInstance": - """ - Update the WebhookInstance - - :param unique_name: An application-defined string that uniquely identifies the new resource. It can be used as an alternative to the `sid` in the URL path to address the resource. This value must be unique and 64 characters or less in length. - :param events: The list of space-separated events that this Webhook will subscribe to. - :param webhook_url: The URL associated with this Webhook. - :param webhook_method: The method to be used when calling the webhook's URL. - - :returns: The updated WebhookInstance - """ - return self._proxy.update( - unique_name=unique_name, - events=events, - webhook_url=webhook_url, - webhook_method=webhook_method, - ) - - async def update_async( - self, - unique_name: Union[str, object] = values.unset, - events: Union[str, object] = values.unset, - webhook_url: Union[str, object] = values.unset, - webhook_method: Union[str, object] = values.unset, - ) -> "WebhookInstance": - """ - Asynchronous coroutine to update the WebhookInstance - - :param unique_name: An application-defined string that uniquely identifies the new resource. It can be used as an alternative to the `sid` in the URL path to address the resource. This value must be unique and 64 characters or less in length. - :param events: The list of space-separated events that this Webhook will subscribe to. - :param webhook_url: The URL associated with this Webhook. - :param webhook_method: The method to be used when calling the webhook's URL. - - :returns: The updated WebhookInstance - """ - return await self._proxy.update_async( - unique_name=unique_name, - events=events, - webhook_url=webhook_url, - webhook_method=webhook_method, - ) - - 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 WebhookContext(InstanceContext): - def __init__(self, version: Version, assistant_sid: str, sid: str): - """ - Initialize the WebhookContext - - :param version: Version that contains the resource - :param assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource to update. - :param sid: The Twilio-provided string that uniquely identifies the Webhook resource to update. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - "sid": sid, - } - self._uri = "/Assistants/{assistant_sid}/Webhooks/{sid}".format( - **self._solution - ) - - def delete(self) -> bool: - """ - Deletes the WebhookInstance - - - :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 WebhookInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._version.delete_async( - method="DELETE", - uri=self._uri, - ) - - def fetch(self) -> WebhookInstance: - """ - Fetch the WebhookInstance - - - :returns: The fetched WebhookInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return WebhookInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - - async def fetch_async(self) -> WebhookInstance: - """ - Asynchronous coroutine to fetch the WebhookInstance - - - :returns: The fetched WebhookInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return WebhookInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - - def update( - self, - unique_name: Union[str, object] = values.unset, - events: Union[str, object] = values.unset, - webhook_url: Union[str, object] = values.unset, - webhook_method: Union[str, object] = values.unset, - ) -> WebhookInstance: - """ - Update the WebhookInstance - - :param unique_name: An application-defined string that uniquely identifies the new resource. It can be used as an alternative to the `sid` in the URL path to address the resource. This value must be unique and 64 characters or less in length. - :param events: The list of space-separated events that this Webhook will subscribe to. - :param webhook_url: The URL associated with this Webhook. - :param webhook_method: The method to be used when calling the webhook's URL. - - :returns: The updated WebhookInstance - """ - data = values.of( - { - "UniqueName": unique_name, - "Events": events, - "WebhookUrl": webhook_url, - "WebhookMethod": webhook_method, - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return WebhookInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - - async def update_async( - self, - unique_name: Union[str, object] = values.unset, - events: Union[str, object] = values.unset, - webhook_url: Union[str, object] = values.unset, - webhook_method: Union[str, object] = values.unset, - ) -> WebhookInstance: - """ - Asynchronous coroutine to update the WebhookInstance - - :param unique_name: An application-defined string that uniquely identifies the new resource. It can be used as an alternative to the `sid` in the URL path to address the resource. This value must be unique and 64 characters or less in length. - :param events: The list of space-separated events that this Webhook will subscribe to. - :param webhook_url: The URL associated with this Webhook. - :param webhook_method: The method to be used when calling the webhook's URL. - - :returns: The updated WebhookInstance - """ - data = values.of( - { - "UniqueName": unique_name, - "Events": events, - "WebhookUrl": webhook_url, - "WebhookMethod": webhook_method, - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return WebhookInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_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 WebhookPage(Page): - def get_instance(self, payload: Dict[str, Any]) -> WebhookInstance: - """ - Build an instance of WebhookInstance - - :param payload: Payload response from the API - """ - return WebhookInstance( - self._version, payload, assistant_sid=self._solution["assistant_sid"] - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class WebhookList(ListResource): - def __init__(self, version: Version, assistant_sid: str): - """ - Initialize the WebhookList - - :param version: Version that contains the resource - :param assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resources to read. - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - } - self._uri = "/Assistants/{assistant_sid}/Webhooks".format(**self._solution) - - def create( - self, - unique_name: str, - events: str, - webhook_url: str, - webhook_method: Union[str, object] = values.unset, - ) -> WebhookInstance: - """ - Create the WebhookInstance - - :param unique_name: An application-defined string that uniquely identifies the new resource. It can be used as an alternative to the `sid` in the URL path to address the resource. This value must be unique and 64 characters or less in length. - :param events: The list of space-separated events that this Webhook will subscribe to. - :param webhook_url: The URL associated with this Webhook. - :param webhook_method: The method to be used when calling the webhook's URL. - - :returns: The created WebhookInstance - """ - data = values.of( - { - "UniqueName": unique_name, - "Events": events, - "WebhookUrl": webhook_url, - "WebhookMethod": webhook_method, - } - ) - - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) - - return WebhookInstance( - self._version, payload, assistant_sid=self._solution["assistant_sid"] - ) - - async def create_async( - self, - unique_name: str, - events: str, - webhook_url: str, - webhook_method: Union[str, object] = values.unset, - ) -> WebhookInstance: - """ - Asynchronously create the WebhookInstance - - :param unique_name: An application-defined string that uniquely identifies the new resource. It can be used as an alternative to the `sid` in the URL path to address the resource. This value must be unique and 64 characters or less in length. - :param events: The list of space-separated events that this Webhook will subscribe to. - :param webhook_url: The URL associated with this Webhook. - :param webhook_method: The method to be used when calling the webhook's URL. - - :returns: The created WebhookInstance - """ - data = values.of( - { - "UniqueName": unique_name, - "Events": events, - "WebhookUrl": webhook_url, - "WebhookMethod": webhook_method, - } - ) - - payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, - ) - - return WebhookInstance( - self._version, payload, assistant_sid=self._solution["assistant_sid"] - ) - - def stream( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[WebhookInstance]: - """ - Streams WebhookInstance 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[WebhookInstance]: - """ - Asynchronously streams WebhookInstance 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[WebhookInstance]: - """ - Lists WebhookInstance 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[WebhookInstance]: - """ - Asynchronously lists WebhookInstance 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, - ) -> WebhookPage: - """ - Retrieve a single page of WebhookInstance 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 WebhookInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = self._version.page(method="GET", uri=self._uri, params=data) - return WebhookPage(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, - ) -> WebhookPage: - """ - Asynchronously retrieve a single page of WebhookInstance 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 WebhookInstance - """ - 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 WebhookPage(self._version, response, self._solution) - - def get_page(self, target_url: str) -> WebhookPage: - """ - Retrieve a specific page of WebhookInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of WebhookInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return WebhookPage(self._version, response, self._solution) - - async def get_page_async(self, target_url: str) -> WebhookPage: - """ - Asynchronously retrieve a specific page of WebhookInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of WebhookInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return WebhookPage(self._version, response, self._solution) - - def get(self, sid: str) -> WebhookContext: - """ - Constructs a WebhookContext - - :param sid: The Twilio-provided string that uniquely identifies the Webhook resource to update. - """ - return WebhookContext( - self._version, assistant_sid=self._solution["assistant_sid"], sid=sid - ) - - def __call__(self, sid: str) -> WebhookContext: - """ - Constructs a WebhookContext - - :param sid: The Twilio-provided string that uniquely identifies the Webhook resource to update. - """ - return WebhookContext( - self._version, assistant_sid=self._solution["assistant_sid"], sid=sid - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/autopilot/v1/restore_assistant.py b/twilio/rest/autopilot/v1/restore_assistant.py deleted file mode 100644 index aae8dd3f8f..0000000000 --- a/twilio/rest/autopilot/v1/restore_assistant.py +++ /dev/null @@ -1,136 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Autopilot - 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_resource import InstanceResource -from twilio.base.list_resource import ListResource -from twilio.base.version import Version - - -class RestoreAssistantInstance(InstanceResource): - - """ - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Assistant resource. - :ivar sid: The unique string that we created to identify the Assistant resource. - :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. - :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. - :ivar friendly_name: The string that you assigned to describe the resource. It is not unique and can be up to 255 characters long. - :ivar needs_model_build: Whether model needs to be rebuilt. - :ivar latest_model_build_sid: Reserved. - :ivar log_queries: Whether queries should be logged and kept after training. Can be: `true` or `false` and defaults to `true`. If `true`, queries are stored for 30 days, and then deleted. If `false`, no queries are stored. - :ivar development_stage: A string describing the state of the assistant. - :ivar callback_url: Reserved. - :ivar callback_events: Reserved. - """ - - def __init__(self, version: Version, payload: Dict[str, Any]): - 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.unique_name: Optional[str] = payload.get("unique_name") - self.friendly_name: Optional[str] = payload.get("friendly_name") - self.needs_model_build: Optional[bool] = payload.get("needs_model_build") - self.latest_model_build_sid: Optional[str] = payload.get( - "latest_model_build_sid" - ) - self.log_queries: Optional[bool] = payload.get("log_queries") - self.development_stage: Optional[str] = payload.get("development_stage") - self.callback_url: Optional[str] = payload.get("callback_url") - self.callback_events: Optional[str] = payload.get("callback_events") - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - - return "" - - -class RestoreAssistantList(ListResource): - def __init__(self, version: Version): - """ - Initialize the RestoreAssistantList - - :param version: Version that contains the resource - - """ - super().__init__(version) - - self._uri = "/Assistants/Restore" - - def update(self, assistant: str) -> RestoreAssistantInstance: - """ - Update the RestoreAssistantInstance - - :param assistant: The Twilio-provided string that uniquely identifies the Assistant resource to restore. - - :returns: The created RestoreAssistantInstance - """ - data = values.of( - { - "Assistant": assistant, - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return RestoreAssistantInstance(self._version, payload) - - async def update_async(self, assistant: str) -> RestoreAssistantInstance: - """ - Asynchronously update the RestoreAssistantInstance - - :param assistant: The Twilio-provided string that uniquely identifies the Assistant resource to restore. - - :returns: The created RestoreAssistantInstance - """ - data = values.of( - { - "Assistant": assistant, - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return RestoreAssistantInstance(self._version, payload) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/bulkexports/BulkexportsBase.py b/twilio/rest/bulkexports/BulkexportsBase.py index d2efe642b4..cbca4c53e4 100644 --- a/twilio/rest/bulkexports/BulkexportsBase.py +++ b/twilio/rest/bulkexports/BulkexportsBase.py @@ -17,6 +17,7 @@ class BulkexportsBase(Domain): + def __init__(self, twilio: Client): """ Initialize the Bulkexports Domain diff --git a/twilio/rest/bulkexports/v1/__init__.py b/twilio/rest/bulkexports/v1/__init__.py index e25eb3afc3..a888fb484f 100644 --- a/twilio/rest/bulkexports/v1/__init__.py +++ b/twilio/rest/bulkexports/v1/__init__.py @@ -20,6 +20,7 @@ class V1(Version): + def __init__(self, domain: Domain): """ Initialize the V1 version of Bulkexports diff --git a/twilio/rest/bulkexports/v1/export/__init__.py b/twilio/rest/bulkexports/v1/export/__init__.py index 03d6c449ea..0ebf3a451b 100644 --- a/twilio/rest/bulkexports/v1/export/__init__.py +++ b/twilio/rest/bulkexports/v1/export/__init__.py @@ -12,8 +12,8 @@ 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 @@ -25,7 +25,6 @@ class ExportInstance(InstanceResource): - """ :ivar resource_type: The type of communication – Messages, Calls, Conferences, and Participants :ivar url: The URL of this resource. @@ -107,6 +106,7 @@ def __repr__(self) -> str: class ExportContext(InstanceContext): + def __init__(self, version: Version, resource_type: str): """ Initialize the ExportContext @@ -133,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, @@ -152,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( @@ -198,6 +202,7 @@ def __repr__(self) -> str: class ExportList(ListResource): + def __init__(self, version: Version): """ Initialize the ExportList diff --git a/twilio/rest/bulkexports/v1/export/day.py b/twilio/rest/bulkexports/v1/export/day.py index 26daf02ed1..f4b2a0650f 100644 --- a/twilio/rest/bulkexports/v1/export/day.py +++ b/twilio/rest/bulkexports/v1/export/day.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import deserialize, values from twilio.base.instance_context import InstanceContext @@ -23,7 +22,6 @@ class DayInstance(InstanceResource): - """ :ivar redirect_to: :ivar day: The ISO 8601 format date of the resources in the file, for a UTC day @@ -100,6 +98,7 @@ def __repr__(self) -> str: class DayContext(InstanceContext): + def __init__(self, version: Version, resource_type: str, day: str): """ Initialize the DayContext @@ -125,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, @@ -145,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( @@ -168,6 +171,7 @@ def __repr__(self) -> str: class DayPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> DayInstance: """ Build an instance of DayInstance @@ -188,6 +192,7 @@ def __repr__(self) -> str: class DayList(ListResource): + def __init__(self, version: Version, resource_type: str): """ Initialize the DayList @@ -331,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( @@ -358,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 2c571489d6..39f45f14b3 100644 --- a/twilio/rest/bulkexports/v1/export/export_custom_job.py +++ b/twilio/rest/bulkexports/v1/export/export_custom_job.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import values @@ -23,7 +22,6 @@ class ExportCustomJobInstance(InstanceResource): - """ :ivar friendly_name: The friendly name specified when creating the job :ivar resource_type: The type of communication – Messages, Calls, Conferences, and Participants @@ -49,7 +47,7 @@ def __init__(self, version: Version, payload: Dict[str, Any], resource_type: str self.webhook_method: Optional[str] = payload.get("webhook_method") self.email: Optional[str] = payload.get("email") self.job_sid: Optional[str] = payload.get("job_sid") - self.details: Optional[Dict[str, object]] = payload.get("details") + self.details: Optional[List[Dict[str, object]]] = payload.get("details") self.job_queue_position: Optional[str] = payload.get("job_queue_position") self.estimated_completion_time: Optional[str] = payload.get( "estimated_completion_time" @@ -70,6 +68,7 @@ def __repr__(self) -> str: class ExportCustomJobPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ExportCustomJobInstance: """ Build an instance of ExportCustomJobInstance @@ -90,6 +89,7 @@ def __repr__(self) -> str: class ExportCustomJobList(ListResource): + def __init__(self, version: Version, resource_type: str): """ Initialize the ExportCustomJobList @@ -127,6 +127,7 @@ def create( :returns: The created ExportCustomJobInstance """ + data = values.of( { "StartDay": start_day, @@ -137,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( @@ -169,6 +173,7 @@ async def create_async( :returns: The created ExportCustomJobInstance """ + data = values.of( { "StartDay": start_day, @@ -179,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( @@ -317,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( @@ -344,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 64c3c0f46f..847c14f4ef 100644 --- a/twilio/rest/bulkexports/v1/export/job.py +++ b/twilio/rest/bulkexports/v1/export/job.py @@ -12,8 +12,8 @@ Do not edit the class manually. """ - -from typing import Any, Dict, Optional +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 @@ -21,7 +21,6 @@ class JobInstance(InstanceResource): - """ :ivar resource_type: The type of communication – Messages, Calls, Conferences, and Participants :ivar friendly_name: The friendly name specified when creating the job @@ -44,7 +43,7 @@ def __init__( self.resource_type: Optional[str] = payload.get("resource_type") self.friendly_name: Optional[str] = payload.get("friendly_name") - self.details: Optional[Dict[str, object]] = payload.get("details") + self.details: Optional[List[Dict[str, object]]] = payload.get("details") self.start_day: Optional[str] = payload.get("start_day") self.end_day: Optional[str] = payload.get("end_day") self.job_sid: Optional[str] = payload.get("job_sid") @@ -124,6 +123,7 @@ def __repr__(self) -> str: class JobContext(InstanceContext): + def __init__(self, version: Version, job_sid: str): """ Initialize the JobContext @@ -146,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: """ @@ -158,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: @@ -171,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, @@ -190,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( @@ -212,6 +218,7 @@ def __repr__(self) -> str: class JobList(ListResource): + def __init__(self, version: Version): """ Initialize the JobList diff --git a/twilio/rest/bulkexports/v1/export_configuration.py b/twilio/rest/bulkexports/v1/export_configuration.py index 28e64c5cdc..207642769b 100644 --- a/twilio/rest/bulkexports/v1/export_configuration.py +++ b/twilio/rest/bulkexports/v1/export_configuration.py @@ -12,9 +12,8 @@ Do not edit the class manually. """ - from typing import Any, Dict, Optional, Union -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 @@ -22,7 +21,6 @@ class ExportConfigurationInstance(InstanceResource): - """ :ivar enabled: If true, Twilio will automatically generate every day's file when the day is over. :ivar webhook_url: Stores the URL destination for the method specified in webhook_method. @@ -136,6 +134,7 @@ def __repr__(self) -> str: class ExportConfigurationContext(InstanceContext): + def __init__(self, version: Version, resource_type: str): """ Initialize the ExportConfigurationContext @@ -159,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, @@ -178,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( @@ -204,18 +207,22 @@ def update( :returns: The updated ExportConfigurationInstance """ + data = values.of( { - "Enabled": enabled, + "Enabled": serialize.boolean_to_string(enabled), "WebhookUrl": webhook_url, "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( @@ -237,18 +244,22 @@ async def update_async( :returns: The updated ExportConfigurationInstance """ + data = values.of( { - "Enabled": enabled, + "Enabled": serialize.boolean_to_string(enabled), "WebhookUrl": webhook_url, "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( @@ -266,6 +277,7 @@ def __repr__(self) -> str: class ExportConfigurationList(ListResource): + def __init__(self, version: Version): """ Initialize the ExportConfigurationList diff --git a/twilio/rest/chat/ChatBase.py b/twilio/rest/chat/ChatBase.py index a84b4eb334..6d8656da17 100644 --- a/twilio/rest/chat/ChatBase.py +++ b/twilio/rest/chat/ChatBase.py @@ -19,6 +19,7 @@ class ChatBase(Domain): + def __init__(self, twilio: Client): """ Initialize the Chat Domain diff --git a/twilio/rest/chat/v1/__init__.py b/twilio/rest/chat/v1/__init__.py index f01101f7da..d0ade9eed5 100644 --- a/twilio/rest/chat/v1/__init__.py +++ b/twilio/rest/chat/v1/__init__.py @@ -20,6 +20,7 @@ class V1(Version): + def __init__(self, domain: Domain): """ Initialize the V1 version of Chat diff --git a/twilio/rest/chat/v1/credential.py b/twilio/rest/chat/v1/credential.py index ecdf1d58e2..3bd48b1144 100644 --- a/twilio/rest/chat/v1/credential.py +++ b/twilio/rest/chat/v1/credential.py @@ -12,10 +12,9 @@ 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 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 @@ -24,6 +23,7 @@ class CredentialInstance(InstanceResource): + class PushService(object): GCM = "gcm" APN = "apn" @@ -185,6 +185,7 @@ def __repr__(self) -> str: class CredentialContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the CredentialContext @@ -207,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: """ @@ -219,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: @@ -232,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, @@ -251,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( @@ -283,21 +290,25 @@ def update( :returns: The updated CredentialInstance """ + data = values.of( { "FriendlyName": friendly_name, "Certificate": certificate, "PrivateKey": private_key, - "Sandbox": sandbox, + "Sandbox": serialize.boolean_to_string(sandbox), "ApiKey": api_key, "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"]) @@ -323,21 +334,25 @@ async def update_async( :returns: The updated CredentialInstance """ + data = values.of( { "FriendlyName": friendly_name, "Certificate": certificate, "PrivateKey": private_key, - "Sandbox": sandbox, + "Sandbox": serialize.boolean_to_string(sandbox), "ApiKey": api_key, "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"]) @@ -353,6 +368,7 @@ def __repr__(self) -> str: class CredentialPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> CredentialInstance: """ Build an instance of CredentialInstance @@ -371,6 +387,7 @@ def __repr__(self) -> str: class CredentialList(ListResource): + def __init__(self, version: Version): """ Initialize the CredentialList @@ -405,22 +422,26 @@ def create( :returns: The created CredentialInstance """ + data = values.of( { "Type": type, "FriendlyName": friendly_name, "Certificate": certificate, "PrivateKey": private_key, - "Sandbox": sandbox, + "Sandbox": serialize.boolean_to_string(sandbox), "ApiKey": api_key, "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) @@ -448,22 +469,26 @@ async def create_async( :returns: The created CredentialInstance """ + data = values.of( { "Type": type, "FriendlyName": friendly_name, "Certificate": certificate, "PrivateKey": private_key, - "Sandbox": sandbox, + "Sandbox": serialize.boolean_to_string(sandbox), "ApiKey": api_key, "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) @@ -595,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( @@ -622,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 f8a377057c..26fde4025b 100644 --- a/twilio/rest/chat/v1/service/__init__.py +++ b/twilio/rest/chat/v1/service/__init__.py @@ -12,7 +12,6 @@ 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 @@ -27,7 +26,6 @@ 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/api/rest/account) that created the Service resource. @@ -529,6 +527,7 @@ def __repr__(self) -> str: class ServiceContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the ServiceContext @@ -555,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: """ @@ -567,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: @@ -580,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, @@ -599,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( @@ -727,23 +732,34 @@ def update( :returns: The updated ServiceInstance """ + data = values.of( { "FriendlyName": friendly_name, "DefaultServiceRoleSid": default_service_role_sid, "DefaultChannelRoleSid": default_channel_role_sid, "DefaultChannelCreatorRoleSid": default_channel_creator_role_sid, - "ReadStatusEnabled": read_status_enabled, - "ReachabilityEnabled": reachability_enabled, + "ReadStatusEnabled": serialize.boolean_to_string(read_status_enabled), + "ReachabilityEnabled": serialize.boolean_to_string( + reachability_enabled + ), "TypingIndicatorTimeout": typing_indicator_timeout, "ConsumptionReportInterval": consumption_report_interval, - "Notifications.NewMessage.Enabled": notifications_new_message_enabled, + "Notifications.NewMessage.Enabled": serialize.boolean_to_string( + notifications_new_message_enabled + ), "Notifications.NewMessage.Template": notifications_new_message_template, - "Notifications.AddedToChannel.Enabled": notifications_added_to_channel_enabled, + "Notifications.AddedToChannel.Enabled": serialize.boolean_to_string( + notifications_added_to_channel_enabled + ), "Notifications.AddedToChannel.Template": notifications_added_to_channel_template, - "Notifications.RemovedFromChannel.Enabled": notifications_removed_from_channel_enabled, + "Notifications.RemovedFromChannel.Enabled": serialize.boolean_to_string( + notifications_removed_from_channel_enabled + ), "Notifications.RemovedFromChannel.Template": notifications_removed_from_channel_template, - "Notifications.InvitedToChannel.Enabled": notifications_invited_to_channel_enabled, + "Notifications.InvitedToChannel.Enabled": serialize.boolean_to_string( + notifications_invited_to_channel_enabled + ), "Notifications.InvitedToChannel.Template": notifications_invited_to_channel_template, "PreWebhookUrl": pre_webhook_url, "PostWebhookUrl": post_webhook_url, @@ -785,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"]) @@ -911,23 +930,34 @@ async def update_async( :returns: The updated ServiceInstance """ + data = values.of( { "FriendlyName": friendly_name, "DefaultServiceRoleSid": default_service_role_sid, "DefaultChannelRoleSid": default_channel_role_sid, "DefaultChannelCreatorRoleSid": default_channel_creator_role_sid, - "ReadStatusEnabled": read_status_enabled, - "ReachabilityEnabled": reachability_enabled, + "ReadStatusEnabled": serialize.boolean_to_string(read_status_enabled), + "ReachabilityEnabled": serialize.boolean_to_string( + reachability_enabled + ), "TypingIndicatorTimeout": typing_indicator_timeout, "ConsumptionReportInterval": consumption_report_interval, - "Notifications.NewMessage.Enabled": notifications_new_message_enabled, + "Notifications.NewMessage.Enabled": serialize.boolean_to_string( + notifications_new_message_enabled + ), "Notifications.NewMessage.Template": notifications_new_message_template, - "Notifications.AddedToChannel.Enabled": notifications_added_to_channel_enabled, + "Notifications.AddedToChannel.Enabled": serialize.boolean_to_string( + notifications_added_to_channel_enabled + ), "Notifications.AddedToChannel.Template": notifications_added_to_channel_template, - "Notifications.RemovedFromChannel.Enabled": notifications_removed_from_channel_enabled, + "Notifications.RemovedFromChannel.Enabled": serialize.boolean_to_string( + notifications_removed_from_channel_enabled + ), "Notifications.RemovedFromChannel.Template": notifications_removed_from_channel_template, - "Notifications.InvitedToChannel.Enabled": notifications_invited_to_channel_enabled, + "Notifications.InvitedToChannel.Enabled": serialize.boolean_to_string( + notifications_invited_to_channel_enabled + ), "Notifications.InvitedToChannel.Template": notifications_invited_to_channel_template, "PreWebhookUrl": pre_webhook_url, "PostWebhookUrl": post_webhook_url, @@ -969,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"]) @@ -1025,6 +1058,7 @@ def __repr__(self) -> str: class ServicePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ServiceInstance: """ Build an instance of ServiceInstance @@ -1043,6 +1077,7 @@ def __repr__(self) -> str: class ServiceList(ListResource): + def __init__(self, version: Version): """ Initialize the ServiceList @@ -1062,16 +1097,20 @@ def create(self, friendly_name: str) -> ServiceInstance: :returns: The created ServiceInstance """ + data = values.of( { "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) @@ -1084,16 +1123,20 @@ async def create_async(self, friendly_name: str) -> ServiceInstance: :returns: The created ServiceInstance """ + data = values.of( { "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) @@ -1225,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( @@ -1252,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 e04d95a433..ffe42c0b5d 100644 --- a/twilio/rest/chat/v1/service/channel/__init__.py +++ b/twilio/rest/chat/v1/service/channel/__init__.py @@ -12,7 +12,6 @@ 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 @@ -27,6 +26,7 @@ class ChannelInstance(InstanceResource): + class ChannelType(object): PUBLIC = "public" PRIVATE = "private" @@ -212,6 +212,7 @@ def __repr__(self) -> str: class ChannelContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, sid: str): """ Initialize the ChannelContext @@ -240,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: """ @@ -252,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: @@ -265,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, @@ -285,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( @@ -312,6 +319,7 @@ def update( :returns: The updated ChannelInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -319,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( @@ -348,6 +359,7 @@ async def update_async( :returns: The updated ChannelInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -355,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( @@ -419,6 +434,7 @@ def __repr__(self) -> str: class ChannelPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ChannelInstance: """ Build an instance of ChannelInstance @@ -439,6 +455,7 @@ def __repr__(self) -> str: class ChannelList(ListResource): + def __init__(self, version: Version, service_sid: str): """ Initialize the ChannelList @@ -472,6 +489,7 @@ def create( :returns: The created ChannelInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -480,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( @@ -508,6 +529,7 @@ async def create_async( :returns: The created ChannelInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -516,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( @@ -667,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( @@ -697,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 e3dbbae07f..e5cd4ebe36 100644 --- a/twilio/rest/chat/v1/service/channel/invite.py +++ b/twilio/rest/chat/v1/service/channel/invite.py @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class InviteInstance(InstanceResource): - """ :ivar sid: The unique string that we created to identify the Invite resource. :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/api/rest/account) that created the Invite resource. @@ -134,6 +132,7 @@ def __repr__(self) -> str: class InviteContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, channel_sid: str, sid: str): """ Initialize the InviteContext @@ -164,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: """ @@ -176,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: @@ -189,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, @@ -210,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( @@ -234,6 +239,7 @@ def __repr__(self) -> str: class InvitePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> InviteInstance: """ Build an instance of InviteInstance @@ -257,6 +263,7 @@ def __repr__(self) -> str: class InviteList(ListResource): + def __init__(self, version: Version, service_sid: str, channel_sid: str): """ Initialize the InviteList @@ -288,17 +295,21 @@ def create( :returns: The created InviteInstance """ + data = values.of( { "Identity": identity, "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( @@ -319,17 +330,21 @@ async def create_async( :returns: The created InviteInstance """ + data = values.of( { "Identity": identity, "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( @@ -479,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( @@ -509,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 62e3912bf9..1262703ddc 100644 --- a/twilio/rest/chat/v1/service/channel/member.py +++ b/twilio/rest/chat/v1/service/channel/member.py @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class MemberInstance(InstanceResource): - """ :ivar sid: The unique string that we created to identify the Member resource. :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/api/rest/account) that created the Member resource. @@ -64,9 +62,9 @@ def __init__( self.last_consumed_message_index: Optional[int] = deserialize.integer( payload.get("last_consumed_message_index") ) - self.last_consumption_timestamp: Optional[ - datetime - ] = deserialize.iso8601_datetime(payload.get("last_consumption_timestamp")) + self.last_consumption_timestamp: Optional[datetime] = ( + deserialize.iso8601_datetime(payload.get("last_consumption_timestamp")) + ) self.url: Optional[str] = payload.get("url") self._solution = { @@ -176,6 +174,7 @@ def __repr__(self) -> str: class MemberContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, channel_sid: str, sid: str): """ Initialize the MemberContext @@ -206,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: """ @@ -218,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: @@ -231,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, @@ -252,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( @@ -278,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( @@ -312,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( @@ -344,6 +357,7 @@ def __repr__(self) -> str: class MemberPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> MemberInstance: """ Build an instance of MemberInstance @@ -367,6 +381,7 @@ def __repr__(self) -> str: class MemberList(ListResource): + def __init__(self, version: Version, service_sid: str, channel_sid: str): """ Initialize the MemberList @@ -398,17 +413,21 @@ def create( :returns: The created MemberInstance """ + data = values.of( { "Identity": identity, "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( @@ -429,17 +448,21 @@ async def create_async( :returns: The created MemberInstance """ + data = values.of( { "Identity": identity, "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( @@ -589,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( @@ -619,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 ad45b6eb59..e7cfc9217d 100644 --- a/twilio/rest/chat/v1/service/channel/message.py +++ b/twilio/rest/chat/v1/service/channel/message.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class MessageInstance(InstanceResource): + class OrderType(object): ASC = "asc" DESC = "desc" @@ -179,6 +179,7 @@ def __repr__(self) -> str: class MessageContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, channel_sid: str, sid: str): """ Initialize the MessageContext @@ -209,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: """ @@ -221,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: @@ -234,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, @@ -255,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( @@ -281,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( @@ -315,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( @@ -347,6 +362,7 @@ def __repr__(self) -> str: class MessagePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> MessageInstance: """ Build an instance of MessageInstance @@ -370,6 +386,7 @@ def __repr__(self) -> str: class MessageList(ListResource): + def __init__(self, version: Version, service_sid: str, channel_sid: str): """ Initialize the MessageList @@ -405,6 +422,7 @@ def create( :returns: The created MessageInstance """ + data = values.of( { "Body": body, @@ -412,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( @@ -441,6 +462,7 @@ async def create_async( :returns: The created MessageInstance """ + data = values.of( { "Body": body, @@ -448,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( @@ -602,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( @@ -632,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 e1a5e5cd53..d81cbd55ac 100644 --- a/twilio/rest/chat/v1/service/role.py +++ b/twilio/rest/chat/v1/service/role.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class RoleInstance(InstanceResource): + class RoleType(object): CHANNEL = "channel" DEPLOYMENT = "deployment" @@ -156,6 +156,7 @@ def __repr__(self) -> str: class RoleContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, sid: str): """ Initialize the RoleContext @@ -180,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: """ @@ -192,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: @@ -205,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, @@ -225,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( @@ -245,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( @@ -272,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( @@ -302,6 +317,7 @@ def __repr__(self) -> str: class RolePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> RoleInstance: """ Build an instance of RoleInstance @@ -322,6 +338,7 @@ def __repr__(self) -> str: class RoleList(ListResource): + def __init__(self, version: Version, service_sid: str): """ Initialize the RoleList @@ -350,6 +367,7 @@ def create( :returns: The created RoleInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -357,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( @@ -380,6 +401,7 @@ async def create_async( :returns: The created RoleInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -387,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( @@ -525,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( @@ -552,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 fd6e9d6c44..c6b900957c 100644 --- a/twilio/rest/chat/v1/service/user/__init__.py +++ b/twilio/rest/chat/v1/service/user/__init__.py @@ -12,7 +12,6 @@ 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 @@ -25,7 +24,6 @@ class UserInstance(InstanceResource): - """ :ivar sid: The unique string that we created to identify the User resource. :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/api/rest/account) that created the User resource. @@ -191,6 +189,7 @@ def __repr__(self) -> str: class UserContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, sid: str): """ Initialize the UserContext @@ -217,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: """ @@ -229,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: @@ -242,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, @@ -262,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( @@ -289,6 +294,7 @@ def update( :returns: The updated UserInstance """ + data = values.of( { "RoleSid": role_sid, @@ -296,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( @@ -325,6 +334,7 @@ async def update_async( :returns: The updated UserInstance """ + data = values.of( { "RoleSid": role_sid, @@ -332,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( @@ -370,6 +383,7 @@ def __repr__(self) -> str: class UserPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> UserInstance: """ Build an instance of UserInstance @@ -390,6 +404,7 @@ def __repr__(self) -> str: class UserList(ListResource): + def __init__(self, version: Version, service_sid: str): """ Initialize the UserList @@ -423,6 +438,7 @@ def create( :returns: The created UserInstance """ + data = values.of( { "Identity": identity, @@ -431,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( @@ -459,6 +478,7 @@ async def create_async( :returns: The created UserInstance """ + data = values.of( { "Identity": identity, @@ -467,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( @@ -605,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( @@ -632,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 353f6bf68f..b7f35aa9ef 100644 --- a/twilio/rest/chat/v1/service/user/user_channel.py +++ b/twilio/rest/chat/v1/service/user/user_channel.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import deserialize, values @@ -23,6 +22,7 @@ class UserChannelInstance(InstanceResource): + class ChannelStatus(object): JOINED = "joined" INVITED = "invited" @@ -75,6 +75,7 @@ def __repr__(self) -> str: class UserChannelPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> UserChannelInstance: """ Build an instance of UserChannelInstance @@ -98,6 +99,7 @@ def __repr__(self) -> str: class UserChannelList(ListResource): + def __init__(self, version: Version, service_sid: str, user_sid: str): """ Initialize the UserChannelList @@ -245,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( @@ -272,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/__init__.py b/twilio/rest/chat/v2/__init__.py index c433e8543f..e949532d56 100644 --- a/twilio/rest/chat/v2/__init__.py +++ b/twilio/rest/chat/v2/__init__.py @@ -20,6 +20,7 @@ class V2(Version): + def __init__(self, domain: Domain): """ Initialize the V2 version of Chat diff --git a/twilio/rest/chat/v2/credential.py b/twilio/rest/chat/v2/credential.py index 4a3df30e93..5479abeca0 100644 --- a/twilio/rest/chat/v2/credential.py +++ b/twilio/rest/chat/v2/credential.py @@ -12,10 +12,9 @@ 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 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 @@ -24,6 +23,7 @@ class CredentialInstance(InstanceResource): + class PushService(object): GCM = "gcm" APN = "apn" @@ -185,6 +185,7 @@ def __repr__(self) -> str: class CredentialContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the CredentialContext @@ -207,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: """ @@ -219,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: @@ -232,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, @@ -251,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( @@ -283,21 +290,25 @@ def update( :returns: The updated CredentialInstance """ + data = values.of( { "FriendlyName": friendly_name, "Certificate": certificate, "PrivateKey": private_key, - "Sandbox": sandbox, + "Sandbox": serialize.boolean_to_string(sandbox), "ApiKey": api_key, "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"]) @@ -323,21 +334,25 @@ async def update_async( :returns: The updated CredentialInstance """ + data = values.of( { "FriendlyName": friendly_name, "Certificate": certificate, "PrivateKey": private_key, - "Sandbox": sandbox, + "Sandbox": serialize.boolean_to_string(sandbox), "ApiKey": api_key, "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"]) @@ -353,6 +368,7 @@ def __repr__(self) -> str: class CredentialPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> CredentialInstance: """ Build an instance of CredentialInstance @@ -371,6 +387,7 @@ def __repr__(self) -> str: class CredentialList(ListResource): + def __init__(self, version: Version): """ Initialize the CredentialList @@ -405,22 +422,26 @@ def create( :returns: The created CredentialInstance """ + data = values.of( { "Type": type, "FriendlyName": friendly_name, "Certificate": certificate, "PrivateKey": private_key, - "Sandbox": sandbox, + "Sandbox": serialize.boolean_to_string(sandbox), "ApiKey": api_key, "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) @@ -448,22 +469,26 @@ async def create_async( :returns: The created CredentialInstance """ + data = values.of( { "Type": type, "FriendlyName": friendly_name, "Certificate": certificate, "PrivateKey": private_key, - "Sandbox": sandbox, + "Sandbox": serialize.boolean_to_string(sandbox), "ApiKey": api_key, "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) @@ -595,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( @@ -622,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 208805c7b7..90a6c6cdba 100644 --- a/twilio/rest/chat/v2/service/__init__.py +++ b/twilio/rest/chat/v2/service/__init__.py @@ -12,7 +12,6 @@ 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 @@ -28,7 +27,6 @@ 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. @@ -411,6 +409,7 @@ def __repr__(self) -> str: class ServiceContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the ServiceContext @@ -438,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: """ @@ -450,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: @@ -463,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, @@ -482,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( @@ -566,27 +571,40 @@ def update( :returns: The updated ServiceInstance """ + data = values.of( { "FriendlyName": friendly_name, "DefaultServiceRoleSid": default_service_role_sid, "DefaultChannelRoleSid": default_channel_role_sid, "DefaultChannelCreatorRoleSid": default_channel_creator_role_sid, - "ReadStatusEnabled": read_status_enabled, - "ReachabilityEnabled": reachability_enabled, + "ReadStatusEnabled": serialize.boolean_to_string(read_status_enabled), + "ReachabilityEnabled": serialize.boolean_to_string( + reachability_enabled + ), "TypingIndicatorTimeout": typing_indicator_timeout, "ConsumptionReportInterval": consumption_report_interval, - "Notifications.NewMessage.Enabled": notifications_new_message_enabled, + "Notifications.NewMessage.Enabled": serialize.boolean_to_string( + notifications_new_message_enabled + ), "Notifications.NewMessage.Template": notifications_new_message_template, "Notifications.NewMessage.Sound": notifications_new_message_sound, - "Notifications.NewMessage.BadgeCountEnabled": notifications_new_message_badge_count_enabled, - "Notifications.AddedToChannel.Enabled": notifications_added_to_channel_enabled, + "Notifications.NewMessage.BadgeCountEnabled": serialize.boolean_to_string( + notifications_new_message_badge_count_enabled + ), + "Notifications.AddedToChannel.Enabled": serialize.boolean_to_string( + notifications_added_to_channel_enabled + ), "Notifications.AddedToChannel.Template": notifications_added_to_channel_template, "Notifications.AddedToChannel.Sound": notifications_added_to_channel_sound, - "Notifications.RemovedFromChannel.Enabled": notifications_removed_from_channel_enabled, + "Notifications.RemovedFromChannel.Enabled": serialize.boolean_to_string( + notifications_removed_from_channel_enabled + ), "Notifications.RemovedFromChannel.Template": notifications_removed_from_channel_template, "Notifications.RemovedFromChannel.Sound": notifications_removed_from_channel_sound, - "Notifications.InvitedToChannel.Enabled": notifications_invited_to_channel_enabled, + "Notifications.InvitedToChannel.Enabled": serialize.boolean_to_string( + notifications_invited_to_channel_enabled + ), "Notifications.InvitedToChannel.Template": notifications_invited_to_channel_template, "Notifications.InvitedToChannel.Sound": notifications_invited_to_channel_sound, "PreWebhookUrl": pre_webhook_url, @@ -598,14 +616,19 @@ def update( "Media.CompatibilityMessage": media_compatibility_message, "PreWebhookRetryCount": pre_webhook_retry_count, "PostWebhookRetryCount": post_webhook_retry_count, - "Notifications.LogEnabled": notifications_log_enabled, + "Notifications.LogEnabled": serialize.boolean_to_string( + notifications_log_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"]) @@ -683,27 +706,40 @@ async def update_async( :returns: The updated ServiceInstance """ + data = values.of( { "FriendlyName": friendly_name, "DefaultServiceRoleSid": default_service_role_sid, "DefaultChannelRoleSid": default_channel_role_sid, "DefaultChannelCreatorRoleSid": default_channel_creator_role_sid, - "ReadStatusEnabled": read_status_enabled, - "ReachabilityEnabled": reachability_enabled, + "ReadStatusEnabled": serialize.boolean_to_string(read_status_enabled), + "ReachabilityEnabled": serialize.boolean_to_string( + reachability_enabled + ), "TypingIndicatorTimeout": typing_indicator_timeout, "ConsumptionReportInterval": consumption_report_interval, - "Notifications.NewMessage.Enabled": notifications_new_message_enabled, + "Notifications.NewMessage.Enabled": serialize.boolean_to_string( + notifications_new_message_enabled + ), "Notifications.NewMessage.Template": notifications_new_message_template, "Notifications.NewMessage.Sound": notifications_new_message_sound, - "Notifications.NewMessage.BadgeCountEnabled": notifications_new_message_badge_count_enabled, - "Notifications.AddedToChannel.Enabled": notifications_added_to_channel_enabled, + "Notifications.NewMessage.BadgeCountEnabled": serialize.boolean_to_string( + notifications_new_message_badge_count_enabled + ), + "Notifications.AddedToChannel.Enabled": serialize.boolean_to_string( + notifications_added_to_channel_enabled + ), "Notifications.AddedToChannel.Template": notifications_added_to_channel_template, "Notifications.AddedToChannel.Sound": notifications_added_to_channel_sound, - "Notifications.RemovedFromChannel.Enabled": notifications_removed_from_channel_enabled, + "Notifications.RemovedFromChannel.Enabled": serialize.boolean_to_string( + notifications_removed_from_channel_enabled + ), "Notifications.RemovedFromChannel.Template": notifications_removed_from_channel_template, "Notifications.RemovedFromChannel.Sound": notifications_removed_from_channel_sound, - "Notifications.InvitedToChannel.Enabled": notifications_invited_to_channel_enabled, + "Notifications.InvitedToChannel.Enabled": serialize.boolean_to_string( + notifications_invited_to_channel_enabled + ), "Notifications.InvitedToChannel.Template": notifications_invited_to_channel_template, "Notifications.InvitedToChannel.Sound": notifications_invited_to_channel_sound, "PreWebhookUrl": pre_webhook_url, @@ -715,14 +751,19 @@ async def update_async( "Media.CompatibilityMessage": media_compatibility_message, "PreWebhookRetryCount": pre_webhook_retry_count, "PostWebhookRetryCount": post_webhook_retry_count, - "Notifications.LogEnabled": notifications_log_enabled, + "Notifications.LogEnabled": serialize.boolean_to_string( + notifications_log_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"]) @@ -786,6 +827,7 @@ def __repr__(self) -> str: class ServicePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ServiceInstance: """ Build an instance of ServiceInstance @@ -804,6 +846,7 @@ def __repr__(self) -> str: class ServiceList(ListResource): + def __init__(self, version: Version): """ Initialize the ServiceList @@ -823,16 +866,20 @@ def create(self, friendly_name: str) -> ServiceInstance: :returns: The created ServiceInstance """ + data = values.of( { "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) @@ -845,16 +892,20 @@ async def create_async(self, friendly_name: str) -> ServiceInstance: :returns: The created ServiceInstance """ + data = values.of( { "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) @@ -986,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( @@ -1013,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 424ad98c0c..125f4b9368 100644 --- a/twilio/rest/chat/v2/service/binding.py +++ b/twilio/rest/chat/v2/service/binding.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class BindingInstance(InstanceResource): + class BindingType(object): GCM = "gcm" APN = "apn" @@ -141,6 +141,7 @@ def __repr__(self) -> str: class BindingContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, sid: str): """ Initialize the BindingContext @@ -165,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: """ @@ -177,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: @@ -190,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, @@ -210,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( @@ -233,6 +240,7 @@ def __repr__(self) -> str: class BindingPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> BindingInstance: """ Build an instance of BindingInstance @@ -253,6 +261,7 @@ def __repr__(self) -> str: class BindingList(ListResource): + def __init__(self, version: Version, service_sid: str): """ Initialize the BindingList @@ -426,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( @@ -459,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 82fc71f80b..36d08a3896 100644 --- a/twilio/rest/chat/v2/service/channel/__init__.py +++ b/twilio/rest/chat/v2/service/channel/__init__.py @@ -12,7 +12,6 @@ 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 @@ -28,6 +27,7 @@ class ChannelInstance(InstanceResource): + class ChannelType(object): PUBLIC = "public" PRIVATE = "private" @@ -268,6 +268,7 @@ def __repr__(self) -> str: class ChannelContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, sid: str): """ Initialize the ChannelContext @@ -309,6 +310,8 @@ def delete( } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async( @@ -330,6 +333,8 @@ async def delete_async( } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -342,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, @@ -362,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( @@ -399,6 +408,7 @@ def update( :returns: The updated ChannelInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -409,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 @@ -451,6 +470,7 @@ async def update_async( :returns: The updated ChannelInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -461,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 @@ -541,6 +570,7 @@ def __repr__(self) -> str: class ChannelPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ChannelInstance: """ Build an instance of ChannelInstance @@ -561,6 +591,7 @@ def __repr__(self) -> str: class ChannelList(ListResource): + def __init__(self, version: Version, service_sid: str): """ Initialize the ChannelList @@ -604,6 +635,7 @@ def create( :returns: The created ChannelInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -618,8 +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 ) @@ -655,6 +693,7 @@ async def create_async( :returns: The created ChannelInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -669,8 +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 ) @@ -819,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( @@ -849,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 3b89e94f85..7c7f9f6211 100644 --- a/twilio/rest/chat/v2/service/channel/invite.py +++ b/twilio/rest/chat/v2/service/channel/invite.py @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class InviteInstance(InstanceResource): - """ :ivar sid: The unique string that we created to identify the Invite resource. :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Invite resource. @@ -134,6 +132,7 @@ def __repr__(self) -> str: class InviteContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, channel_sid: str, sid: str): """ Initialize the InviteContext @@ -164,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: """ @@ -176,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: @@ -189,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, @@ -210,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( @@ -234,6 +239,7 @@ def __repr__(self) -> str: class InvitePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> InviteInstance: """ Build an instance of InviteInstance @@ -257,6 +263,7 @@ def __repr__(self) -> str: class InviteList(ListResource): + def __init__(self, version: Version, service_sid: str, channel_sid: str): """ Initialize the InviteList @@ -288,17 +295,21 @@ def create( :returns: The created InviteInstance """ + data = values.of( { "Identity": identity, "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( @@ -319,17 +330,21 @@ async def create_async( :returns: The created InviteInstance """ + data = values.of( { "Identity": identity, "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( @@ -479,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( @@ -509,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 aa03d8bac3..f07cb21891 100644 --- a/twilio/rest/chat/v2/service/channel/member.py +++ b/twilio/rest/chat/v2/service/channel/member.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class MemberInstance(InstanceResource): + class WebhookEnabledType(object): TRUE = "true" FALSE = "false" @@ -68,9 +68,9 @@ def __init__( self.last_consumed_message_index: Optional[int] = deserialize.integer( payload.get("last_consumed_message_index") ) - self.last_consumption_timestamp: Optional[ - datetime - ] = deserialize.iso8601_datetime(payload.get("last_consumption_timestamp")) + self.last_consumption_timestamp: Optional[datetime] = ( + deserialize.iso8601_datetime(payload.get("last_consumption_timestamp")) + ) self.url: Optional[str] = payload.get("url") self.attributes: Optional[str] = payload.get("attributes") @@ -231,6 +231,7 @@ def __repr__(self) -> str: class MemberContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, channel_sid: str, sid: str): """ Initialize the MemberContext @@ -273,6 +274,8 @@ def delete( } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async( @@ -294,6 +297,8 @@ async def delete_async( } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -306,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, @@ -327,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( @@ -365,6 +374,7 @@ def update( :returns: The updated MemberInstance """ + data = values.of( { "RoleSid": role_sid, @@ -377,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 @@ -420,6 +439,7 @@ async def update_async( :returns: The updated MemberInstance """ + data = values.of( { "RoleSid": role_sid, @@ -432,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 @@ -461,6 +490,7 @@ def __repr__(self) -> str: class MemberPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> MemberInstance: """ Build an instance of MemberInstance @@ -484,6 +514,7 @@ def __repr__(self) -> str: class MemberList(ListResource): + def __init__(self, version: Version, service_sid: str, channel_sid: str): """ Initialize the MemberList @@ -531,6 +562,7 @@ def create( :returns: The created MemberInstance """ + data = values.of( { "Identity": identity, @@ -547,8 +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 ) @@ -587,6 +625,7 @@ async def create_async( :returns: The created MemberInstance """ + data = values.of( { "Identity": identity, @@ -603,8 +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 ) @@ -756,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( @@ -786,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 07f6a9dc90..d0bf2e5ac7 100644 --- a/twilio/rest/chat/v2/service/channel/message.py +++ b/twilio/rest/chat/v2/service/channel/message.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class MessageInstance(InstanceResource): + class OrderType(object): ASC = "asc" DESC = "desc" @@ -239,6 +239,7 @@ def __repr__(self) -> str: class MessageContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, channel_sid: str, sid: str): """ Initialize the MessageContext @@ -281,6 +282,8 @@ def delete( } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async( @@ -302,6 +305,8 @@ async def delete_async( } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -314,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, @@ -335,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( @@ -373,6 +382,7 @@ def update( :returns: The updated MessageInstance """ + data = values.of( { "Body": body, @@ -383,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 @@ -426,6 +445,7 @@ async def update_async( :returns: The updated MessageInstance """ + data = values.of( { "Body": body, @@ -436,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 @@ -465,6 +494,7 @@ def __repr__(self) -> str: class MessagePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> MessageInstance: """ Build an instance of MessageInstance @@ -488,6 +518,7 @@ def __repr__(self) -> str: class MessageList(ListResource): + def __init__(self, version: Version, service_sid: str, channel_sid: str): """ Initialize the MessageList @@ -535,6 +566,7 @@ def create( :returns: The created MessageInstance """ + data = values.of( { "From": from_, @@ -549,8 +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 ) @@ -589,6 +627,7 @@ async def create_async( :returns: The created MessageInstance """ + data = values.of( { "From": from_, @@ -603,8 +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 ) @@ -756,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( @@ -786,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 6e05e41742..3e31df4288 100644 --- a/twilio/rest/chat/v2/service/channel/webhook.py +++ b/twilio/rest/chat/v2/service/channel/webhook.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class WebhookInstance(InstanceResource): + class Method(object): GET = "GET" POST = "POST" @@ -200,6 +200,7 @@ def __repr__(self) -> str: class WebhookContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, channel_sid: str, sid: str): """ Initialize the WebhookContext @@ -230,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: """ @@ -242,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: @@ -255,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, @@ -276,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( @@ -310,6 +317,7 @@ def update( :returns: The updated WebhookInstance """ + data = values.of( { "Configuration.Url": configuration_url, @@ -324,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( @@ -360,6 +371,7 @@ async def update_async( :returns: The updated WebhookInstance """ + data = values.of( { "Configuration.Url": configuration_url, @@ -374,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( @@ -400,6 +415,7 @@ def __repr__(self) -> str: class WebhookPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> WebhookInstance: """ Build an instance of WebhookInstance @@ -423,6 +439,7 @@ def __repr__(self) -> str: class WebhookList(ListResource): + def __init__(self, version: Version, service_sid: str, channel_sid: str): """ Initialize the WebhookList @@ -466,6 +483,7 @@ def create( :returns: The created WebhookInstance """ + data = values.of( { "Type": type, @@ -481,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( @@ -518,6 +539,7 @@ async def create_async( :returns: The created WebhookInstance """ + data = values.of( { "Type": type, @@ -533,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( @@ -674,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( @@ -701,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 7f77ee6e4b..fef06436d0 100644 --- a/twilio/rest/chat/v2/service/role.py +++ b/twilio/rest/chat/v2/service/role.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class RoleInstance(InstanceResource): + class RoleType(object): CHANNEL = "channel" DEPLOYMENT = "deployment" @@ -156,6 +156,7 @@ def __repr__(self) -> str: class RoleContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, sid: str): """ Initialize the RoleContext @@ -180,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: """ @@ -192,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: @@ -205,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, @@ -225,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( @@ -245,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( @@ -272,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( @@ -302,6 +317,7 @@ def __repr__(self) -> str: class RolePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> RoleInstance: """ Build an instance of RoleInstance @@ -322,6 +338,7 @@ def __repr__(self) -> str: class RoleList(ListResource): + def __init__(self, version: Version, service_sid: str): """ Initialize the RoleList @@ -350,6 +367,7 @@ def create( :returns: The created RoleInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -357,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( @@ -380,6 +401,7 @@ async def create_async( :returns: The created RoleInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -387,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( @@ -525,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( @@ -552,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 9977023e7f..9fbde6feda 100644 --- a/twilio/rest/chat/v2/service/user/__init__.py +++ b/twilio/rest/chat/v2/service/user/__init__.py @@ -12,7 +12,6 @@ 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 @@ -26,6 +25,7 @@ class UserInstance(InstanceResource): + class WebhookEnabledType(object): TRUE = "true" FALSE = "false" @@ -212,6 +212,7 @@ def __repr__(self) -> str: class UserContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, sid: str): """ Initialize the UserContext @@ -239,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: """ @@ -251,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: @@ -264,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, @@ -284,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( @@ -315,6 +322,7 @@ def update( :returns: The updated UserInstance """ + data = values.of( { "RoleSid": role_sid, @@ -322,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 @@ -358,6 +375,7 @@ async def update_async( :returns: The updated UserInstance """ + data = values.of( { "RoleSid": role_sid, @@ -365,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 @@ -419,6 +446,7 @@ def __repr__(self) -> str: class UserPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> UserInstance: """ Build an instance of UserInstance @@ -439,6 +467,7 @@ def __repr__(self) -> str: class UserList(ListResource): + def __init__(self, version: Version, service_sid: str): """ Initialize the UserList @@ -476,6 +505,7 @@ def create( :returns: The created UserInstance """ + data = values.of( { "Identity": identity, @@ -487,8 +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 ) @@ -518,6 +554,7 @@ async def create_async( :returns: The created UserInstance """ + data = values.of( { "Identity": identity, @@ -529,8 +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 ) @@ -666,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( @@ -693,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 5ea1628840..8d79c551af 100644 --- a/twilio/rest/chat/v2/service/user/user_binding.py +++ b/twilio/rest/chat/v2/service/user/user_binding.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class UserBindingInstance(InstanceResource): + class BindingType(object): GCM = "gcm" APN = "apn" @@ -144,6 +144,7 @@ def __repr__(self) -> str: class UserBindingContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, user_sid: str, sid: str): """ Initialize the UserBindingContext @@ -172,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: """ @@ -184,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: @@ -197,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, @@ -218,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( @@ -242,6 +249,7 @@ def __repr__(self) -> str: class UserBindingPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> UserBindingInstance: """ Build an instance of UserBindingInstance @@ -265,6 +273,7 @@ def __repr__(self) -> str: class UserBindingList(ListResource): + def __init__(self, version: Version, service_sid: str, user_sid: str): """ Initialize the UserBindingList @@ -437,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( @@ -469,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 2f72e8c59c..9fab357368 100644 --- a/twilio/rest/chat/v2/service/user/user_channel.py +++ b/twilio/rest/chat/v2/service/user/user_channel.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class UserChannelInstance(InstanceResource): + class ChannelStatus(object): JOINED = "joined" INVITED = "invited" @@ -77,9 +77,9 @@ def __init__( ) self.links: Optional[Dict[str, object]] = payload.get("links") self.url: Optional[str] = payload.get("url") - self.notification_level: Optional[ - "UserChannelInstance.NotificationLevel" - ] = payload.get("notification_level") + self.notification_level: Optional["UserChannelInstance.NotificationLevel"] = ( + payload.get("notification_level") + ) self._solution = { "service_sid": service_sid, @@ -214,6 +214,7 @@ def __repr__(self) -> str: class UserChannelContext(InstanceContext): + def __init__( self, version: Version, service_sid: str, user_sid: str, channel_sid: str ): @@ -258,6 +259,8 @@ def delete( } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async( @@ -279,6 +282,8 @@ async def delete_async( } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -291,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, @@ -312,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( @@ -342,6 +351,7 @@ def update( :returns: The updated UserChannelInstance """ + data = values.of( { "NotificationLevel": notification_level, @@ -351,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( @@ -383,6 +396,7 @@ async def update_async( :returns: The updated UserChannelInstance """ + data = values.of( { "NotificationLevel": notification_level, @@ -392,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( @@ -418,6 +435,7 @@ def __repr__(self) -> str: class UserChannelPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> UserChannelInstance: """ Build an instance of UserChannelInstance @@ -441,6 +459,7 @@ def __repr__(self) -> str: class UserChannelList(ListResource): + def __init__(self, version: Version, service_sid: str, user_sid: str): """ Initialize the UserChannelList @@ -588,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( @@ -615,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/__init__.py b/twilio/rest/chat/v3/__init__.py index 7fdfc8977f..582dc44069 100644 --- a/twilio/rest/chat/v3/__init__.py +++ b/twilio/rest/chat/v3/__init__.py @@ -19,6 +19,7 @@ class V3(Version): + def __init__(self, domain: Domain): """ Initialize the V3 version of Chat diff --git a/twilio/rest/chat/v3/channel.py b/twilio/rest/chat/v3/channel.py index 3305bb578c..4682838fba 100644 --- a/twilio/rest/chat/v3/channel.py +++ b/twilio/rest/chat/v3/channel.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import datetime from typing import Any, Dict, Optional, Union from twilio.base import deserialize, values @@ -23,6 +22,7 @@ class ChannelInstance(InstanceResource): + class ChannelType(object): PUBLIC = "public" PRIVATE = "private" @@ -44,7 +44,7 @@ class WebhookEnabledType(object): :ivar created_by: The `identity` of the User that created the channel. If the Channel was created by using the API, the value is `system`. :ivar members_count: The number of Members in the Channel. :ivar messages_count: The number of Messages that have been passed in the Channel. - :ivar messaging_service_sid: The unique ID of the [Messaging Service](https://www.twilio.com/docs/sms/services/api) this channel belongs to. + :ivar messaging_service_sid: The unique ID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) this channel belongs to. :ivar url: The absolute URL of the Channel resource. """ @@ -115,7 +115,7 @@ def update( :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header :param type: - :param messaging_service_sid: The unique ID of the [Messaging Service](https://www.twilio.com/docs/sms/services/api) this channel belongs to. + :param messaging_service_sid: The unique ID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) this channel belongs to. :returns: The updated ChannelInstance """ @@ -138,7 +138,7 @@ async def update_async( :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header :param type: - :param messaging_service_sid: The unique ID of the [Messaging Service](https://www.twilio.com/docs/sms/services/api) this channel belongs to. + :param messaging_service_sid: The unique ID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) this channel belongs to. :returns: The updated ChannelInstance """ @@ -159,6 +159,7 @@ def __repr__(self) -> str: class ChannelContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, sid: str): """ Initialize the ChannelContext @@ -189,21 +190,31 @@ def update( :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header :param type: - :param messaging_service_sid: The unique ID of the [Messaging Service](https://www.twilio.com/docs/sms/services/api) this channel belongs to. + :param messaging_service_sid: The unique ID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) this channel belongs to. :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 @@ -229,21 +240,31 @@ async def update_async( :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header :param type: - :param messaging_service_sid: The unique ID of the [Messaging Service](https://www.twilio.com/docs/sms/services/api) this channel belongs to. + :param messaging_service_sid: The unique ID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) this channel belongs to. :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 @@ -267,6 +288,7 @@ def __repr__(self) -> str: class ChannelList(ListResource): + def __init__(self, version: Version): """ Initialize the ChannelList diff --git a/twilio/rest/content/ContentBase.py b/twilio/rest/content/ContentBase.py index 72dfbad76d..8a1ccd5d94 100644 --- a/twilio/rest/content/ContentBase.py +++ b/twilio/rest/content/ContentBase.py @@ -14,9 +14,11 @@ 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): + def __init__(self, twilio: Client): """ Initialize the Content Domain @@ -25,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: @@ -35,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/__init__.py b/twilio/rest/content/v1/__init__.py index 68f3f13a69..1410fe4788 100644 --- a/twilio/rest/content/v1/__init__.py +++ b/twilio/rest/content/v1/__init__.py @@ -21,6 +21,7 @@ class V1(Version): + def __init__(self, domain: Domain): """ Initialize the V1 version of Content diff --git a/twilio/rest/content/v1/content/__init__.py b/twilio/rest/content/v1/content/__init__.py index b0eaaa0fad..44cc6a67bc 100644 --- a/twilio/rest/content/v1/content/__init__.py +++ b/twilio/rest/content/v1/content/__init__.py @@ -12,7 +12,6 @@ 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 @@ -21,11 +20,765 @@ from twilio.base.list_resource import ListResource from twilio.base.version import Version from twilio.base.page import Page +from twilio.rest.content.v1.content.approval_create import ApprovalCreateList from twilio.rest.content.v1.content.approval_fetch import ApprovalFetchList class ContentInstance(InstanceResource): + 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: + :ivar id: + """ + + 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") + self.id: Optional[str] = payload.get("id") + + def to_dict(self): + return { + "type": self.type, + "title": self.title, + "url": self.url, + "phone": self.phone, + "code": self.code, + "id": self.id, + } + + 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: + :ivar id: + :ivar address: + """ + + 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") + self.id: Optional[str] = payload.get("id") + self.address: Optional[str] = payload.get("address") + + def to_dict(self): + return { + "latitude": self.latitude, + "longitude": self.longitude, + "label": self.label, + "id": self.id, + "address": self.address, + } + + 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. @@ -108,31 +861,767 @@ def fetch(self) -> "ContentInstance": async def fetch_async(self) -> "ContentInstance": """ - Asynchronous coroutine to fetch the 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: + :ivar id: + """ + + 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") + self.id: Optional[str] = payload.get("id") + + def to_dict(self): + return { + "type": self.type, + "title": self.title, + "url": self.url, + "phone": self.phone, + "code": self.code, + "id": self.id, + } + + 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: + :ivar id: + :ivar address: + """ + + 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") + self.id: Optional[str] = payload.get("id") + self.address: Optional[str] = payload.get("address") + + def to_dict(self): + return { + "latitude": self.latitude, + "longitude": self.longitude, + "label": self.label, + "id": self.id, + "address": self.address, + } + + 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]): - :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_fetch(self) -> ApprovalFetchList: + 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): """ - Access the approval_fetch + :ivar body: + :ivar footer: + :ivar media: + :ivar header_text: + :ivar actions: """ - return self._proxy.approval_fetch - def __repr__(self) -> str: - """ - Provide a friendly representation + def __init__(self, payload: Dict[str, Any]): - :returns: Machine friendly representation - """ - context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) - return "".format(context) + 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 ContentContext(InstanceContext): def __init__(self, version: Version, sid: str): """ Initialize the ContentContext @@ -148,6 +1637,7 @@ def __init__(self, version: Version, sid: str): } self._uri = "/Content/{sid}".format(**self._solution) + self._approval_create: Optional[ApprovalCreateList] = None self._approval_fetch: Optional[ApprovalFetchList] = None def delete(self) -> bool: @@ -157,10 +1647,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 +1659,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: @@ -182,10 +1674,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, @@ -201,9 +1694,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( @@ -212,6 +1708,18 @@ async def fetch_async(self) -> ContentInstance: sid=self._solution["sid"], ) + @property + def approval_create(self) -> ApprovalCreateList: + """ + Access the approval_create + """ + if self._approval_create is None: + self._approval_create = ApprovalCreateList( + self._version, + self._solution["sid"], + ) + return self._approval_create + @property def approval_fetch(self) -> ApprovalFetchList: """ @@ -235,6 +1743,7 @@ def __repr__(self) -> str: class ContentPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ContentInstance: """ Build an instance of ContentInstance @@ -253,6 +1762,735 @@ def __repr__(self) -> str: class ContentList(ListResource): + + 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: + :ivar id: + """ + + 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") + self.id: Optional[str] = payload.get("id") + + def to_dict(self): + return { + "type": self.type, + "title": self.title, + "url": self.url, + "phone": self.phone, + "code": self.code, + "id": self.id, + } + + 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: + :ivar id: + :ivar address: + """ + + 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") + self.id: Optional[str] = payload.get("id") + self.address: Optional[str] = payload.get("address") + + def to_dict(self): + return { + "latitude": self.latitude, + "longitude": self.longitude, + "label": self.label, + "id": self.id, + "address": self.address, + } + + 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 + ), + } + def __init__(self, version: Version): """ Initialize the ContentList @@ -264,6 +2502,52 @@ def __init__(self, version: Version): self._uri = "/Content" + def create(self, content_create_request: ContentCreateRequest) -> ContentInstance: + """ + Create the ContentInstance + + :param content_create_request: + + :returns: The created ContentInstance + """ + data = content_create_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 ContentInstance(self._version, payload) + + async def create_async( + self, content_create_request: ContentCreateRequest + ) -> ContentInstance: + """ + Asynchronously create the ContentInstance + + :param content_create_request: + + :returns: The created ContentInstance + """ + data = content_create_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 ContentInstance(self._version, payload) + def stream( self, limit: Optional[int] = None, @@ -391,7 +2675,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-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( @@ -418,8 +2708,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/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 new file mode 100644 index 0000000000..9f34064e35 --- /dev/null +++ b/twilio/rest/content/v1/content/approval_create.py @@ -0,0 +1,172 @@ +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 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 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: + """ + + def __init__(self, version: Version, payload: Dict[str, Any], content_sid: str): + super().__init__(version) + + self.name: Optional[str] = payload.get("name") + self.category: Optional[str] = payload.get("category") + self.content_type: Optional[str] = payload.get("content_type") + self.status: Optional[str] = payload.get("status") + self.rejection_reason: Optional[str] = payload.get("rejection_reason") + self.allow_category_change: Optional[bool] = payload.get( + "allow_category_change" + ) + + self._solution = { + "content_sid": content_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 ApprovalCreateList(ListResource): + + 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, + } + + def __init__(self, version: Version, content_sid: str): + """ + Initialize the ApprovalCreateList + + :param version: Version that contains the resource + :param content_sid: + + """ + super().__init__(version) + + # Path Solution + self._solution = { + "content_sid": content_sid, + } + self._uri = "/Content/{content_sid}/ApprovalRequests/whatsapp".format( + **self._solution + ) + + def create( + self, content_approval_request: ContentApprovalRequest + ) -> ApprovalCreateInstance: + """ + Create the ApprovalCreateInstance + + :param content_approval_request: + + :returns: The created ApprovalCreateInstance + """ + data = content_approval_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 ApprovalCreateInstance( + self._version, payload, content_sid=self._solution["content_sid"] + ) + + async def create_async( + self, content_approval_request: ContentApprovalRequest + ) -> ApprovalCreateInstance: + """ + Asynchronously create the ApprovalCreateInstance + + :param content_approval_request: + + :returns: The created ApprovalCreateInstance + """ + data = content_approval_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 ApprovalCreateInstance( + self._version, payload, content_sid=self._solution["content_sid"] + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/content/v1/content/approval_fetch.py b/twilio/rest/content/v1/content/approval_fetch.py index ccd3b96d84..d3d00e5058 100644 --- a/twilio/rest/content/v1/content/approval_fetch.py +++ b/twilio/rest/content/v1/content/approval_fetch.py @@ -12,8 +12,8 @@ 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 @@ -21,7 +21,6 @@ class ApprovalFetchInstance(InstanceResource): - """ :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. @@ -86,6 +85,7 @@ def __repr__(self) -> str: class ApprovalFetchContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the ApprovalFetchContext @@ -109,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, @@ -128,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( @@ -150,6 +154,7 @@ def __repr__(self) -> str: class ApprovalFetchList(ListResource): + def __init__(self, version: Version, sid: str): """ Initialize the ApprovalFetchList diff --git a/twilio/rest/content/v1/content_and_approvals.py b/twilio/rest/content/v1/content_and_approvals.py index 914376ea0b..c2a210665d 100644 --- a/twilio/rest/content/v1/content_and_approvals.py +++ b/twilio/rest/content/v1/content_and_approvals.py @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ 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. @@ -67,6 +65,7 @@ def __repr__(self) -> str: class ContentAndApprovalsPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ContentAndApprovalsInstance: """ Build an instance of ContentAndApprovalsInstance @@ -85,6 +84,7 @@ def __repr__(self) -> str: class ContentAndApprovalsList(ListResource): + def __init__(self, version: Version): """ Initialize the ContentAndApprovalsList @@ -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 9a1370b98a..d32778e748 100644 --- a/twilio/rest/content/v1/legacy_content.py +++ b/twilio/rest/content/v1/legacy_content.py @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class LegacyContentInstance(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. @@ -69,6 +67,7 @@ def __repr__(self) -> str: class LegacyContentPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> LegacyContentInstance: """ Build an instance of LegacyContentInstance @@ -87,6 +86,7 @@ def __repr__(self) -> str: class LegacyContentList(ListResource): + def __init__(self, version: Version): """ Initialize the LegacyContentList @@ -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/ConversationsBase.py b/twilio/rest/conversations/ConversationsBase.py index 06d5533e3e..8904308365 100644 --- a/twilio/rest/conversations/ConversationsBase.py +++ b/twilio/rest/conversations/ConversationsBase.py @@ -17,6 +17,7 @@ class ConversationsBase(Domain): + def __init__(self, twilio: Client): """ Initialize the Conversations Domain diff --git a/twilio/rest/conversations/v1/__init__.py b/twilio/rest/conversations/v1/__init__.py index 0fbe314fa2..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, @@ -28,6 +31,7 @@ class V1(Version): + def __init__(self, domain: Domain): """ Initialize the V1 version of Conversations @@ -38,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 @@ -62,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 05bc008151..ab61a04c99 100644 --- a/twilio/rest/conversations/v1/address_configuration.py +++ b/twilio/rest/conversations/v1/address_configuration.py @@ -12,7 +12,6 @@ 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 @@ -24,20 +23,25 @@ class AddressConfigurationInstance(InstanceResource): + class AutoCreationType(object): WEBHOOK = "webhook" STUDIO = "studio" DEFAULT = "default" class Method(object): - GET = "GET" - POST = "POST" + GET = "get" + POST = "post" class Type(object): SMS = "sms" WHATSAPP = "whatsapp" MESSENGER = "messenger" GBM = "gbm" + EMAIL = "email" + RCS = "rcs" + APPLE = "apple" + CHAT = "chat" """ :ivar sid: A 34 character string that uniquely identifies this resource. @@ -49,6 +53,7 @@ class Type(object): :ivar date_created: The date that this resource was created. :ivar date_updated: The date that this resource was last updated. :ivar url: An absolute API resource URL for this address configuration. + :ivar address_country: An ISO 3166-1 alpha-2n country code which the address belongs to. This is currently only applicable to short code addresses. """ def __init__( @@ -69,6 +74,7 @@ def __init__( payload.get("date_updated") ) self.url: Optional[str] = payload.get("url") + self.address_country: Optional[str] = payload.get("address_country") self._solution = { "sid": sid or self.sid, @@ -225,6 +231,7 @@ def __repr__(self) -> str: class AddressConfigurationContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the AddressConfigurationContext @@ -247,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: """ @@ -259,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: @@ -272,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, @@ -291,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( @@ -333,10 +346,13 @@ def update( :returns: The updated AddressConfigurationInstance """ + data = values.of( { "FriendlyName": friendly_name, - "AutoCreation.Enabled": auto_creation_enabled, + "AutoCreation.Enabled": serialize.boolean_to_string( + auto_creation_enabled + ), "AutoCreation.Type": auto_creation_type, "AutoCreation.ConversationServiceSid": auto_creation_conversation_service_sid, "AutoCreation.WebhookUrl": auto_creation_webhook_url, @@ -348,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( @@ -390,10 +409,13 @@ async def update_async( :returns: The updated AddressConfigurationInstance """ + data = values.of( { "FriendlyName": friendly_name, - "AutoCreation.Enabled": auto_creation_enabled, + "AutoCreation.Enabled": serialize.boolean_to_string( + auto_creation_enabled + ), "AutoCreation.Type": auto_creation_type, "AutoCreation.ConversationServiceSid": auto_creation_conversation_service_sid, "AutoCreation.WebhookUrl": auto_creation_webhook_url, @@ -405,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( @@ -429,6 +454,7 @@ def __repr__(self) -> str: class AddressConfigurationPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> AddressConfigurationInstance: """ Build an instance of AddressConfigurationInstance @@ -447,6 +473,7 @@ def __repr__(self) -> str: class AddressConfigurationList(ListResource): + def __init__(self, version: Version): """ Initialize the AddressConfigurationList @@ -475,6 +502,7 @@ def create( auto_creation_webhook_filters: Union[List[str], object] = values.unset, auto_creation_studio_flow_sid: Union[str, object] = values.unset, auto_creation_studio_retry_count: Union[int, object] = values.unset, + address_country: Union[str, object] = values.unset, ) -> AddressConfigurationInstance: """ Create the AddressConfigurationInstance @@ -490,15 +518,19 @@ def create( :param auto_creation_webhook_filters: The list of events, firing webhook event for this Conversation. Values can be any of the following: `onMessageAdded`, `onMessageUpdated`, `onMessageRemoved`, `onConversationUpdated`, `onConversationStateUpdated`, `onConversationRemoved`, `onParticipantAdded`, `onParticipantUpdated`, `onParticipantRemoved`, `onDeliveryUpdated` :param auto_creation_studio_flow_sid: For type `studio`, the studio flow SID where the webhook should be sent to. :param auto_creation_studio_retry_count: For type `studio`, number of times to retry the webhook request + :param address_country: An ISO 3166-1 alpha-2n country code which the address belongs to. This is currently only applicable to short code addresses. :returns: The created AddressConfigurationInstance """ + data = values.of( { "Type": type, "Address": address, "FriendlyName": friendly_name, - "AutoCreation.Enabled": auto_creation_enabled, + "AutoCreation.Enabled": serialize.boolean_to_string( + auto_creation_enabled + ), "AutoCreation.Type": auto_creation_type, "AutoCreation.ConversationServiceSid": auto_creation_conversation_service_sid, "AutoCreation.WebhookUrl": auto_creation_webhook_url, @@ -508,13 +540,17 @@ def create( ), "AutoCreation.StudioFlowSid": auto_creation_studio_flow_sid, "AutoCreation.StudioRetryCount": auto_creation_studio_retry_count, + "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) @@ -536,6 +572,7 @@ async def create_async( auto_creation_webhook_filters: Union[List[str], object] = values.unset, auto_creation_studio_flow_sid: Union[str, object] = values.unset, auto_creation_studio_retry_count: Union[int, object] = values.unset, + address_country: Union[str, object] = values.unset, ) -> AddressConfigurationInstance: """ Asynchronously create the AddressConfigurationInstance @@ -551,15 +588,19 @@ async def create_async( :param auto_creation_webhook_filters: The list of events, firing webhook event for this Conversation. Values can be any of the following: `onMessageAdded`, `onMessageUpdated`, `onMessageRemoved`, `onConversationUpdated`, `onConversationStateUpdated`, `onConversationRemoved`, `onParticipantAdded`, `onParticipantUpdated`, `onParticipantRemoved`, `onDeliveryUpdated` :param auto_creation_studio_flow_sid: For type `studio`, the studio flow SID where the webhook should be sent to. :param auto_creation_studio_retry_count: For type `studio`, number of times to retry the webhook request + :param address_country: An ISO 3166-1 alpha-2n country code which the address belongs to. This is currently only applicable to short code addresses. :returns: The created AddressConfigurationInstance """ + data = values.of( { "Type": type, "Address": address, "FriendlyName": friendly_name, - "AutoCreation.Enabled": auto_creation_enabled, + "AutoCreation.Enabled": serialize.boolean_to_string( + auto_creation_enabled + ), "AutoCreation.Type": auto_creation_type, "AutoCreation.ConversationServiceSid": auto_creation_conversation_service_sid, "AutoCreation.WebhookUrl": auto_creation_webhook_url, @@ -569,13 +610,17 @@ async def create_async( ), "AutoCreation.StudioFlowSid": auto_creation_studio_flow_sid, "AutoCreation.StudioRetryCount": auto_creation_studio_retry_count, + "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) @@ -720,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( @@ -750,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 d4bd2ad394..584082353f 100644 --- a/twilio/rest/conversations/v1/configuration/__init__.py +++ b/twilio/rest/conversations/v1/configuration/__init__.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, Optional, Union from twilio.base import values from twilio.base.instance_context import InstanceContext @@ -24,11 +23,10 @@ class ConfigurationInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this configuration. :ivar default_chat_service_sid: The SID of the default [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) used when creating a conversation. - :ivar default_messaging_service_sid: The SID of the default [Messaging Service](https://www.twilio.com/docs/sms/services/api) used when creating a conversation. + :ivar default_messaging_service_sid: The SID of the default [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) used when creating a conversation. :ivar default_inactive_timer: Default ISO8601 duration when conversation will be switched to `inactive` state. Minimum value for this timer is 1 minute. :ivar default_closed_timer: Default ISO8601 duration when conversation will be switched to `closed` state. Minimum value for this timer is 10 minutes. :ivar url: An absolute API resource URL for this global configuration. @@ -97,7 +95,7 @@ def update( Update the ConfigurationInstance :param default_chat_service_sid: The SID of the default [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) to use when creating a conversation. - :param default_messaging_service_sid: The SID of the default [Messaging Service](https://www.twilio.com/docs/sms/services/api) to use when creating a conversation. + :param default_messaging_service_sid: The SID of the default [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) to use when creating a conversation. :param default_inactive_timer: Default ISO8601 duration when conversation will be switched to `inactive` state. Minimum value for this timer is 1 minute. :param default_closed_timer: Default ISO8601 duration when conversation will be switched to `closed` state. Minimum value for this timer is 10 minutes. @@ -121,7 +119,7 @@ async def update_async( Asynchronous coroutine to update the ConfigurationInstance :param default_chat_service_sid: The SID of the default [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) to use when creating a conversation. - :param default_messaging_service_sid: The SID of the default [Messaging Service](https://www.twilio.com/docs/sms/services/api) to use when creating a conversation. + :param default_messaging_service_sid: The SID of the default [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) to use when creating a conversation. :param default_inactive_timer: Default ISO8601 duration when conversation will be switched to `inactive` state. Minimum value for this timer is 1 minute. :param default_closed_timer: Default ISO8601 duration when conversation will be switched to `closed` state. Minimum value for this timer is 10 minutes. @@ -145,6 +143,7 @@ def __repr__(self) -> str: class ConfigurationContext(InstanceContext): + def __init__(self, version: Version): """ Initialize the ConfigurationContext @@ -163,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, @@ -181,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( @@ -202,12 +205,13 @@ def update( Update the ConfigurationInstance :param default_chat_service_sid: The SID of the default [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) to use when creating a conversation. - :param default_messaging_service_sid: The SID of the default [Messaging Service](https://www.twilio.com/docs/sms/services/api) to use when creating a conversation. + :param default_messaging_service_sid: The SID of the default [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) to use when creating a conversation. :param default_inactive_timer: Default ISO8601 duration when conversation will be switched to `inactive` state. Minimum value for this timer is 1 minute. :param default_closed_timer: Default ISO8601 duration when conversation will be switched to `closed` state. Minimum value for this timer is 10 minutes. :returns: The updated ConfigurationInstance """ + data = values.of( { "DefaultChatServiceSid": default_chat_service_sid, @@ -216,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) @@ -236,12 +243,13 @@ async def update_async( Asynchronous coroutine to update the ConfigurationInstance :param default_chat_service_sid: The SID of the default [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) to use when creating a conversation. - :param default_messaging_service_sid: The SID of the default [Messaging Service](https://www.twilio.com/docs/sms/services/api) to use when creating a conversation. + :param default_messaging_service_sid: The SID of the default [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) to use when creating a conversation. :param default_inactive_timer: Default ISO8601 duration when conversation will be switched to `inactive` state. Minimum value for this timer is 1 minute. :param default_closed_timer: Default ISO8601 duration when conversation will be switched to `closed` state. Minimum value for this timer is 10 minutes. :returns: The updated ConfigurationInstance """ + data = values.of( { "DefaultChatServiceSid": default_chat_service_sid, @@ -250,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) @@ -270,6 +281,7 @@ def __repr__(self) -> str: class ConfigurationList(ListResource): + def __init__(self, version: Version): """ Initialize the ConfigurationList diff --git a/twilio/rest/conversations/v1/configuration/webhook.py b/twilio/rest/conversations/v1/configuration/webhook.py index 4b2f1c1d7c..f471c879ab 100644 --- a/twilio/rest/conversations/v1/configuration/webhook.py +++ b/twilio/rest/conversations/v1/configuration/webhook.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, List, Optional, Union from twilio.base import serialize, values from twilio.base.instance_context import InstanceContext @@ -22,6 +21,7 @@ class WebhookInstance(InstanceResource): + class Method(object): GET = "GET" POST = "POST" @@ -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: @@ -150,6 +150,7 @@ def __repr__(self) -> str: class WebhookContext(InstanceContext): + def __init__(self, version: Version): """ Initialize the WebhookContext @@ -168,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, @@ -186,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( @@ -208,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, @@ -224,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) @@ -245,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, @@ -261,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) @@ -281,6 +294,7 @@ def __repr__(self) -> str: class WebhookList(ListResource): + def __init__(self, version: Version): """ Initialize the WebhookList diff --git a/twilio/rest/conversations/v1/conversation/__init__.py b/twilio/rest/conversations/v1/conversation/__init__.py index aee3bc7c6f..d1f08cc2d8 100644 --- a/twilio/rest/conversations/v1/conversation/__init__.py +++ b/twilio/rest/conversations/v1/conversation/__init__.py @@ -12,7 +12,6 @@ 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 @@ -27,6 +26,7 @@ class ConversationInstance(InstanceResource): + class State(object): INACTIVE = "inactive" ACTIVE = "active" @@ -39,7 +39,7 @@ class WebhookEnabledType(object): """ :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/sms/services/api) 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. @@ -163,6 +163,8 @@ def update( timers_inactive: Union[str, object] = values.unset, timers_closed: Union[str, object] = values.unset, unique_name: Union[str, object] = values.unset, + bindings_email_address: Union[str, object] = values.unset, + bindings_email_name: Union[str, object] = values.unset, ) -> "ConversationInstance": """ Update the ConversationInstance @@ -172,11 +174,13 @@ def update( :param date_created: The date that this resource was created. :param date_updated: The date that this resource was last updated. :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 messaging_service_sid: The unique ID of the [Messaging Service](https://www.twilio.com/docs/sms/services/api) this conversation belongs to. + :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 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 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 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. :returns: The updated ConversationInstance """ @@ -191,6 +195,8 @@ def update( timers_inactive=timers_inactive, timers_closed=timers_closed, unique_name=unique_name, + bindings_email_address=bindings_email_address, + bindings_email_name=bindings_email_name, ) async def update_async( @@ -207,6 +213,8 @@ async def update_async( timers_inactive: Union[str, object] = values.unset, timers_closed: Union[str, object] = values.unset, unique_name: Union[str, object] = values.unset, + bindings_email_address: Union[str, object] = values.unset, + bindings_email_name: Union[str, object] = values.unset, ) -> "ConversationInstance": """ Asynchronous coroutine to update the ConversationInstance @@ -216,11 +224,13 @@ async def update_async( :param date_created: The date that this resource was created. :param date_updated: The date that this resource was last updated. :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 messaging_service_sid: The unique ID of the [Messaging Service](https://www.twilio.com/docs/sms/services/api) this conversation belongs to. + :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 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 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 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. :returns: The updated ConversationInstance """ @@ -235,6 +245,8 @@ async def update_async( timers_inactive=timers_inactive, timers_closed=timers_closed, unique_name=unique_name, + bindings_email_address=bindings_email_address, + bindings_email_name=bindings_email_name, ) @property @@ -269,6 +281,7 @@ def __repr__(self) -> str: class ConversationContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the ConversationContext @@ -307,6 +320,8 @@ def delete( } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async( @@ -328,6 +343,8 @@ async def delete_async( } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -340,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, @@ -359,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( @@ -384,6 +405,8 @@ def update( timers_inactive: Union[str, object] = values.unset, timers_closed: Union[str, object] = values.unset, unique_name: Union[str, object] = values.unset, + bindings_email_address: Union[str, object] = values.unset, + bindings_email_name: Union[str, object] = values.unset, ) -> ConversationInstance: """ Update the ConversationInstance @@ -393,14 +416,17 @@ def update( :param date_created: The date that this resource was created. :param date_updated: The date that this resource was last updated. :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 messaging_service_sid: The unique ID of the [Messaging Service](https://www.twilio.com/docs/sms/services/api) this conversation belongs to. + :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 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 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 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. :returns: The updated ConversationInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -412,13 +438,24 @@ def update( "Timers.Inactive": timers_inactive, "Timers.Closed": timers_closed, "UniqueName": unique_name, + "Bindings.Email.Address": bindings_email_address, + "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 @@ -440,6 +477,8 @@ async def update_async( timers_inactive: Union[str, object] = values.unset, timers_closed: Union[str, object] = values.unset, unique_name: Union[str, object] = values.unset, + bindings_email_address: Union[str, object] = values.unset, + bindings_email_name: Union[str, object] = values.unset, ) -> ConversationInstance: """ Asynchronous coroutine to update the ConversationInstance @@ -449,14 +488,17 @@ async def update_async( :param date_created: The date that this resource was created. :param date_updated: The date that this resource was last updated. :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 messaging_service_sid: The unique ID of the [Messaging Service](https://www.twilio.com/docs/sms/services/api) this conversation belongs to. + :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 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 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 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. :returns: The updated ConversationInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -468,13 +510,24 @@ async def update_async( "Timers.Inactive": timers_inactive, "Timers.Closed": timers_closed, "UniqueName": unique_name, + "Bindings.Email.Address": bindings_email_address, + "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 @@ -529,6 +582,7 @@ def __repr__(self) -> str: class ConversationPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ConversationInstance: """ Build an instance of ConversationInstance @@ -547,6 +601,7 @@ def __repr__(self) -> str: class ConversationList(ListResource): + def __init__(self, version: Version): """ Initialize the ConversationList @@ -572,6 +627,8 @@ def create( state: Union["ConversationInstance.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, ) -> ConversationInstance: """ Create the ConversationInstance @@ -581,14 +638,17 @@ def create( :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/sms/services/api) this conversation belongs to. + :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. :returns: The created ConversationInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -600,13 +660,21 @@ def create( "State": state, "Timers.Inactive": timers_inactive, "Timers.Closed": timers_closed, + "Bindings.Email.Address": bindings_email_address, + "Bindings.Email.Name": bindings_email_name, } ) 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 ) @@ -627,6 +695,8 @@ async def create_async( state: Union["ConversationInstance.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, ) -> ConversationInstance: """ Asynchronously create the ConversationInstance @@ -636,14 +706,17 @@ async def create_async( :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/sms/services/api) this conversation belongs to. + :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. :returns: The created ConversationInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -655,13 +728,21 @@ async def create_async( "State": state, "Timers.Inactive": timers_inactive, "Timers.Closed": timers_closed, + "Bindings.Email.Address": bindings_email_address, + "Bindings.Email.Name": bindings_email_name, } ) 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 ) @@ -682,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 in ISO8601 format for sorting and filtering list of Conversations. - :param str end_date: End date in ISO8601 format for sorting and filtering list of Conversations. + :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 @@ -718,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 in ISO8601 format for sorting and filtering list of Conversations. - :param str end_date: End date in ISO8601 format for sorting and filtering list of Conversations. + :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 @@ -753,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 in ISO8601 format for sorting and filtering list of Conversations. - :param str end_date: End date in ISO8601 format for sorting and filtering list of Conversations. + :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 @@ -788,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 in ISO8601 format for sorting and filtering list of Conversations. - :param str end_date: End date in ISO8601 format for sorting and filtering list of Conversations. + :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 @@ -824,8 +905,8 @@ def page( Retrieve a single page of ConversationInstance records from the API. Request is executed immediately - :param start_date: Start date in ISO8601 format for sorting and filtering list of Conversations. - :param end_date: End date in ISO8601 format for sorting and filtering list of Conversations. + :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 @@ -844,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( @@ -860,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 in ISO8601 format for sorting and filtering list of Conversations. - :param end_date: End date in ISO8601 format for sorting and filtering list of Conversations. + :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 @@ -880,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 a4a06c093b..04e7fdf252 100644 --- a/twilio/rest/conversations/v1/conversation/message/__init__.py +++ b/twilio/rest/conversations/v1/conversation/message/__init__.py @@ -12,7 +12,6 @@ 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 @@ -27,6 +26,7 @@ class MessageInstance(InstanceResource): + class OrderType(object): ASC = "asc" DESC = "desc" @@ -50,7 +50,7 @@ class WebhookEnabledType(object): :ivar url: An absolute API resource API URL for this message. :ivar delivery: An object that contains the summary of delivery statuses for the message to non-chat participants. :ivar links: Contains an absolute API resource URL to access the delivery & read receipts of this message. - :ivar content_sid: The unique ID of the multi-channel [Rich Content](https://www.twilio.com/docs/content-api) template. + :ivar content_sid: The unique ID of the multi-channel [Rich Content](https://www.twilio.com/docs/content) template. """ def __init__( @@ -68,7 +68,7 @@ def __init__( self.index: Optional[int] = deserialize.integer(payload.get("index")) self.author: Optional[str] = payload.get("author") self.body: Optional[str] = payload.get("body") - self.media: Optional[List[object]] = payload.get("media") + self.media: Optional[List[Dict[str, object]]] = payload.get("media") self.attributes: Optional[str] = payload.get("attributes") self.participant_sid: Optional[str] = payload.get("participant_sid") self.date_created: Optional[datetime] = deserialize.iso8601_datetime( @@ -166,6 +166,7 @@ def update( date_created: Union[datetime, object] = values.unset, date_updated: Union[datetime, object] = values.unset, attributes: Union[str, object] = values.unset, + subject: Union[str, object] = values.unset, ) -> "MessageInstance": """ Update the MessageInstance @@ -176,6 +177,7 @@ def update( :param date_created: The date that this resource was created. :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. :param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. + :param subject: The subject of the message, can be up to 256 characters long. :returns: The updated MessageInstance """ @@ -186,6 +188,7 @@ def update( date_created=date_created, date_updated=date_updated, attributes=attributes, + subject=subject, ) async def update_async( @@ -198,6 +201,7 @@ async def update_async( date_created: Union[datetime, object] = values.unset, date_updated: Union[datetime, object] = values.unset, attributes: Union[str, object] = values.unset, + subject: Union[str, object] = values.unset, ) -> "MessageInstance": """ Asynchronous coroutine to update the MessageInstance @@ -208,6 +212,7 @@ async def update_async( :param date_created: The date that this resource was created. :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. :param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. + :param subject: The subject of the message, can be up to 256 characters long. :returns: The updated MessageInstance """ @@ -218,6 +223,7 @@ async def update_async( date_created=date_created, date_updated=date_updated, attributes=attributes, + subject=subject, ) @property @@ -238,6 +244,7 @@ def __repr__(self) -> str: class MessageContext(InstanceContext): + def __init__(self, version: Version, conversation_sid: str, sid: str): """ Initialize the MessageContext @@ -278,6 +285,8 @@ def delete( } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async( @@ -299,6 +308,8 @@ async def delete_async( } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -311,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, @@ -331,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( @@ -353,6 +368,7 @@ def update( date_created: Union[datetime, object] = values.unset, date_updated: Union[datetime, object] = values.unset, attributes: Union[str, object] = values.unset, + subject: Union[str, object] = values.unset, ) -> MessageInstance: """ Update the MessageInstance @@ -363,9 +379,11 @@ def update( :param date_created: The date that this resource was created. :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. :param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. + :param subject: The subject of the message, can be up to 256 characters long. :returns: The updated MessageInstance """ + data = values.of( { "Author": author, @@ -373,13 +391,23 @@ def update( "DateCreated": serialize.iso8601_datetime(date_created), "DateUpdated": serialize.iso8601_datetime(date_updated), "Attributes": attributes, + "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 @@ -402,6 +430,7 @@ async def update_async( date_created: Union[datetime, object] = values.unset, date_updated: Union[datetime, object] = values.unset, attributes: Union[str, object] = values.unset, + subject: Union[str, object] = values.unset, ) -> MessageInstance: """ Asynchronous coroutine to update the MessageInstance @@ -412,9 +441,11 @@ async def update_async( :param date_created: The date that this resource was created. :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. :param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. + :param subject: The subject of the message, can be up to 256 characters long. :returns: The updated MessageInstance """ + data = values.of( { "Author": author, @@ -422,13 +453,23 @@ async def update_async( "DateCreated": serialize.iso8601_datetime(date_created), "DateUpdated": serialize.iso8601_datetime(date_updated), "Attributes": attributes, + "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 @@ -465,6 +506,7 @@ def __repr__(self) -> str: class MessagePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> MessageInstance: """ Build an instance of MessageInstance @@ -485,6 +527,7 @@ def __repr__(self) -> str: class MessageList(ListResource): + def __init__(self, version: Version, conversation_sid: str): """ Initialize the MessageList @@ -516,6 +559,7 @@ def create( media_sid: Union[str, object] = values.unset, content_sid: Union[str, object] = values.unset, content_variables: Union[str, object] = values.unset, + subject: Union[str, object] = values.unset, ) -> MessageInstance: """ Create the MessageInstance @@ -527,11 +571,13 @@ def create( :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. :param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. :param media_sid: The Media SID to be attached to the new Message. - :param content_sid: The unique ID of the multi-channel [Rich Content](https://www.twilio.com/docs/content-api) template, required for template-generated messages. **Note** that if this field is set, `Body` and `MediaSid` parameters are ignored. + :param content_sid: The unique ID of the multi-channel [Rich Content](https://www.twilio.com/docs/content) template, required for template-generated messages. **Note** that if this field is set, `Body` and `MediaSid` parameters are ignored. :param content_variables: A structurally valid JSON string that contains values to resolve Rich Content template variables. + :param subject: The subject of the message, can be up to 256 characters long. :returns: The created MessageInstance """ + data = values.of( { "Author": author, @@ -542,13 +588,20 @@ def create( "MediaSid": media_sid, "ContentSid": content_sid, "ContentVariables": content_variables, + "Subject": subject, } ) 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 ) @@ -570,6 +623,7 @@ async def create_async( media_sid: Union[str, object] = values.unset, content_sid: Union[str, object] = values.unset, content_variables: Union[str, object] = values.unset, + subject: Union[str, object] = values.unset, ) -> MessageInstance: """ Asynchronously create the MessageInstance @@ -581,11 +635,13 @@ async def create_async( :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. :param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. :param media_sid: The Media SID to be attached to the new Message. - :param content_sid: The unique ID of the multi-channel [Rich Content](https://www.twilio.com/docs/content-api) template, required for template-generated messages. **Note** that if this field is set, `Body` and `MediaSid` parameters are ignored. + :param content_sid: The unique ID of the multi-channel [Rich Content](https://www.twilio.com/docs/content) template, required for template-generated messages. **Note** that if this field is set, `Body` and `MediaSid` parameters are ignored. :param content_variables: A structurally valid JSON string that contains values to resolve Rich Content template variables. + :param subject: The subject of the message, can be up to 256 characters long. :returns: The created MessageInstance """ + data = values.of( { "Author": author, @@ -596,13 +652,20 @@ async def create_async( "MediaSid": media_sid, "ContentSid": content_sid, "ContentVariables": content_variables, + "Subject": subject, } ) 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 ) @@ -751,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( @@ -781,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 3949c67032..2ed297e059 100644 --- a/twilio/rest/conversations/v1/conversation/message/delivery_receipt.py +++ b/twilio/rest/conversations/v1/conversation/message/delivery_receipt.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class DeliveryReceiptInstance(InstanceResource): + class DeliveryStatus(object): READ = "read" FAILED = "failed" @@ -126,6 +126,7 @@ def __repr__(self) -> str: class DeliveryReceiptContext(InstanceContext): + def __init__( self, version: Version, conversation_sid: str, message_sid: str, sid: str ): @@ -157,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, @@ -178,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( @@ -202,6 +207,7 @@ def __repr__(self) -> str: class DeliveryReceiptPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> DeliveryReceiptInstance: """ Build an instance of DeliveryReceiptInstance @@ -225,6 +231,7 @@ def __repr__(self) -> str: class DeliveryReceiptList(ListResource): + def __init__(self, version: Version, conversation_sid: str, message_sid: str): """ Initialize the DeliveryReceiptList @@ -374,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( @@ -401,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 e9cb028ff3..deb652641a 100644 --- a/twilio/rest/conversations/v1/conversation/participant.py +++ b/twilio/rest/conversations/v1/conversation/participant.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class ParticipantInstance(InstanceResource): + class WebhookEnabledType(object): TRUE = "true" FALSE = "false" @@ -246,6 +246,7 @@ def __repr__(self) -> str: class ParticipantContext(InstanceContext): + def __init__(self, version: Version, conversation_sid: str, sid: str): """ Initialize the ParticipantContext @@ -284,6 +285,8 @@ def delete( } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async( @@ -305,6 +308,8 @@ async def delete_async( } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -317,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, @@ -337,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( @@ -380,6 +389,7 @@ def update( :returns: The updated ParticipantInstance """ + data = values.of( { "DateCreated": serialize.iso8601_datetime(date_created), @@ -393,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 @@ -441,6 +460,7 @@ async def update_async( :returns: The updated ParticipantInstance """ + data = values.of( { "DateCreated": serialize.iso8601_datetime(date_created), @@ -454,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 @@ -482,6 +511,7 @@ def __repr__(self) -> str: class ParticipantPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ParticipantInstance: """ Build an instance of ParticipantInstance @@ -502,6 +532,7 @@ def __repr__(self) -> str: class ParticipantList(ListResource): + def __init__(self, version: Version, conversation_sid: str): """ Initialize the ParticipantList @@ -549,6 +580,7 @@ def create( :returns: The created ParticipantInstance """ + data = values.of( { "Identity": identity, @@ -564,8 +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 ) @@ -603,6 +641,7 @@ async def create_async( :returns: The created ParticipantInstance """ + data = values.of( { "Identity": identity, @@ -618,8 +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 ) @@ -755,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( @@ -782,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 8b7493388a..3b432caae3 100644 --- a/twilio/rest/conversations/v1/conversation/webhook.py +++ b/twilio/rest/conversations/v1/conversation/webhook.py @@ -12,7 +12,6 @@ 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 @@ -24,9 +23,10 @@ class WebhookInstance(InstanceResource): + class Method(object): - GET = "GET" - POST = "POST" + GET = "get" + POST = "post" class Target(object): WEBHOOK = "webhook" @@ -189,6 +189,7 @@ def __repr__(self) -> str: class WebhookContext(InstanceContext): + def __init__(self, version: Version, conversation_sid: str, sid: str): """ Initialize the WebhookContext @@ -215,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: """ @@ -227,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: @@ -240,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, @@ -260,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( @@ -291,6 +298,7 @@ def update( :returns: The updated WebhookInstance """ + data = values.of( { "Configuration.Url": configuration_url, @@ -304,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( @@ -337,6 +348,7 @@ async def update_async( :returns: The updated WebhookInstance """ + data = values.of( { "Configuration.Url": configuration_url, @@ -350,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( @@ -375,6 +390,7 @@ def __repr__(self) -> str: class WebhookPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> WebhookInstance: """ Build an instance of WebhookInstance @@ -395,6 +411,7 @@ def __repr__(self) -> str: class WebhookList(ListResource): + def __init__(self, version: Version, conversation_sid: str): """ Initialize the WebhookList @@ -436,6 +453,7 @@ def create( :returns: The created WebhookInstance """ + data = values.of( { "Target": target, @@ -451,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( @@ -485,6 +506,7 @@ async def create_async( :returns: The created WebhookInstance """ + data = values.of( { "Target": target, @@ -500,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( @@ -638,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( @@ -665,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 0b6dfd8289..f382458ba7 100644 --- a/twilio/rest/conversations/v1/credential.py +++ b/twilio/rest/conversations/v1/credential.py @@ -12,10 +12,9 @@ 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 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 @@ -24,6 +23,7 @@ class CredentialInstance(InstanceResource): + class PushType(object): APN = "apn" GCM = "gcm" @@ -191,6 +191,7 @@ def __repr__(self) -> str: class CredentialContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the CredentialContext @@ -213,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: """ @@ -225,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: @@ -238,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, @@ -257,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( @@ -291,22 +298,26 @@ def update( :returns: The updated CredentialInstance """ + data = values.of( { "Type": type, "FriendlyName": friendly_name, "Certificate": certificate, "PrivateKey": private_key, - "Sandbox": sandbox, + "Sandbox": serialize.boolean_to_string(sandbox), "ApiKey": api_key, "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"]) @@ -334,22 +345,26 @@ async def update_async( :returns: The updated CredentialInstance """ + data = values.of( { "Type": type, "FriendlyName": friendly_name, "Certificate": certificate, "PrivateKey": private_key, - "Sandbox": sandbox, + "Sandbox": serialize.boolean_to_string(sandbox), "ApiKey": api_key, "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"]) @@ -365,6 +380,7 @@ def __repr__(self) -> str: class CredentialPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> CredentialInstance: """ Build an instance of CredentialInstance @@ -383,6 +399,7 @@ def __repr__(self) -> str: class CredentialList(ListResource): + def __init__(self, version: Version): """ Initialize the CredentialList @@ -417,22 +434,26 @@ def create( :returns: The created CredentialInstance """ + data = values.of( { "Type": type, "FriendlyName": friendly_name, "Certificate": certificate, "PrivateKey": private_key, - "Sandbox": sandbox, + "Sandbox": serialize.boolean_to_string(sandbox), "ApiKey": api_key, "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) @@ -460,22 +481,26 @@ async def create_async( :returns: The created CredentialInstance """ + data = values.of( { "Type": type, "FriendlyName": friendly_name, "Certificate": certificate, "PrivateKey": private_key, - "Sandbox": sandbox, + "Sandbox": serialize.boolean_to_string(sandbox), "ApiKey": api_key, "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) @@ -607,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( @@ -634,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 0a7d0634b9..0938bd5421 100644 --- a/twilio/rest/conversations/v1/participant_conversation.py +++ b/twilio/rest/conversations/v1/participant_conversation.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class ParticipantConversationInstance(InstanceResource): + class State(object): INACTIVE = "inactive" ACTIVE = "active" @@ -69,18 +69,18 @@ def __init__(self, version: Version, payload: Dict[str, Any]): self.conversation_attributes: Optional[str] = payload.get( "conversation_attributes" ) - self.conversation_date_created: Optional[ - datetime - ] = deserialize.iso8601_datetime(payload.get("conversation_date_created")) - self.conversation_date_updated: Optional[ - datetime - ] = deserialize.iso8601_datetime(payload.get("conversation_date_updated")) + self.conversation_date_created: Optional[datetime] = ( + deserialize.iso8601_datetime(payload.get("conversation_date_created")) + ) + self.conversation_date_updated: Optional[datetime] = ( + deserialize.iso8601_datetime(payload.get("conversation_date_updated")) + ) self.conversation_created_by: Optional[str] = payload.get( "conversation_created_by" ) - self.conversation_state: Optional[ - "ParticipantConversationInstance.State" - ] = payload.get("conversation_state") + self.conversation_state: Optional["ParticipantConversationInstance.State"] = ( + payload.get("conversation_state") + ) self.conversation_timers: Optional[Dict[str, object]] = payload.get( "conversation_timers" ) @@ -97,6 +97,7 @@ def __repr__(self) -> str: class ParticipantConversationPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ParticipantConversationInstance: """ Build an instance of ParticipantConversationInstance @@ -115,6 +116,7 @@ def __repr__(self) -> str: class ParticipantConversationList(ListResource): + def __init__(self, version: Version): """ Initialize the ParticipantConversationList @@ -283,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( @@ -316,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 fb7626ce0c..229e9b7dd4 100644 --- a/twilio/rest/conversations/v1/role.py +++ b/twilio/rest/conversations/v1/role.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class RoleInstance(InstanceResource): + class RoleType(object): CONVERSATION = "conversation" SERVICE = "service" @@ -150,6 +150,7 @@ def __repr__(self) -> str: class RoleContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the RoleContext @@ -172,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: """ @@ -184,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: @@ -197,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, @@ -216,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( @@ -235,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"]) @@ -257,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"]) @@ -282,6 +297,7 @@ def __repr__(self) -> str: class RolePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> RoleInstance: """ Build an instance of RoleInstance @@ -300,6 +316,7 @@ def __repr__(self) -> str: class RoleList(ListResource): + def __init__(self, version: Version): """ Initialize the RoleList @@ -323,6 +340,7 @@ def create( :returns: The created RoleInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -330,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) @@ -351,6 +372,7 @@ async def create_async( :returns: The created RoleInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -358,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) @@ -494,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( @@ -521,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 ad4066710f..3b92c87934 100644 --- a/twilio/rest/conversations/v1/service/__init__.py +++ b/twilio/rest/conversations/v1/service/__init__.py @@ -12,7 +12,6 @@ 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 @@ -24,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, ) @@ -32,7 +34,6 @@ class ServiceInstance(InstanceResource): - """ :ivar account_sid: The unique ID of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this service. :ivar sid: A 34 character string that uniquely identifies this resource. @@ -137,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: """ @@ -169,6 +177,7 @@ def __repr__(self) -> str: class ServiceContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the ServiceContext @@ -187,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 @@ -198,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: """ @@ -210,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: @@ -223,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, @@ -242,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( @@ -289,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: """ @@ -336,6 +366,7 @@ def __repr__(self) -> str: class ServicePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ServiceInstance: """ Build an instance of ServiceInstance @@ -354,6 +385,7 @@ def __repr__(self) -> str: class ServiceList(ListResource): + def __init__(self, version: Version): """ Initialize the ServiceList @@ -373,16 +405,20 @@ def create(self, friendly_name: str) -> ServiceInstance: :returns: The created ServiceInstance """ + data = values.of( { "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) @@ -395,16 +431,20 @@ async def create_async(self, friendly_name: str) -> ServiceInstance: :returns: The created ServiceInstance """ + data = values.of( { "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) @@ -536,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( @@ -563,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 264ef0490c..363dab91d0 100644 --- a/twilio/rest/conversations/v1/service/binding.py +++ b/twilio/rest/conversations/v1/service/binding.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class BindingInstance(InstanceResource): + class BindingType(object): APN = "apn" GCM = "gcm" @@ -139,6 +139,7 @@ def __repr__(self) -> str: class BindingContext(InstanceContext): + def __init__(self, version: Version, chat_service_sid: str, sid: str): """ Initialize the BindingContext @@ -165,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: """ @@ -177,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: @@ -190,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, @@ -210,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( @@ -233,6 +240,7 @@ def __repr__(self) -> str: class BindingPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> BindingInstance: """ Build an instance of BindingInstance @@ -253,6 +261,7 @@ def __repr__(self) -> str: class BindingList(ListResource): + def __init__(self, version: Version, chat_service_sid: str): """ Initialize the BindingList @@ -426,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( @@ -459,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 d5a02443dc..e37c8888c8 100644 --- a/twilio/rest/conversations/v1/service/configuration/__init__.py +++ b/twilio/rest/conversations/v1/service/configuration/__init__.py @@ -12,9 +12,8 @@ Do not edit the class manually. """ - from typing import Any, Dict, Optional, Union -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 @@ -27,15 +26,14 @@ class ConfigurationInstance(InstanceResource): - """ :ivar chat_service_sid: The unique string that we created to identify the Service configuration resource. - :ivar default_conversation_creator_role_sid: The conversation-level role assigned to a conversation creator user when they join a new conversation. See the [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles. - :ivar default_conversation_role_sid: The conversation-level role assigned to users when they are added to a conversation. See the [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles. - :ivar default_chat_service_role_sid: The service-level role assigned to users when they are added to the service. See the [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles. + :ivar default_conversation_creator_role_sid: The conversation-level role assigned to a conversation creator when they join a new conversation. See [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles. + :ivar default_conversation_role_sid: The conversation-level role assigned to users when they are added to a conversation. See [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles. + :ivar default_chat_service_role_sid: The service-level role assigned to users when they are added to the service. See [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles. :ivar url: An absolute API resource URL for this service configuration. :ivar links: Contains an absolute API resource URL to access the push notifications configuration of this service. - :ivar reachability_enabled: Whether the [Reachability Indicator](https://www.twilio.com/docs/chat/reachability-indicator) is enabled for this Conversations Service. The default is `false`. + :ivar reachability_enabled: Whether the [Reachability Indicator](https://www.twilio.com/docs/conversations/reachability) is enabled for this Conversations Service. The default is `false`. """ def __init__( @@ -105,10 +103,10 @@ def update( """ Update the ConfigurationInstance - :param default_conversation_creator_role_sid: The conversation-level role assigned to a conversation creator when they join a new conversation. See the [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles. - :param default_conversation_role_sid: The conversation-level role assigned to users when they are added to a conversation. See the [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles. - :param default_chat_service_role_sid: The service-level role assigned to users when they are added to the service. See the [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles. - :param reachability_enabled: Whether the [Reachability Indicator](https://www.twilio.com/docs/chat/reachability-indicator) is enabled for this Conversations Service. The default is `false`. + :param default_conversation_creator_role_sid: The conversation-level role assigned to a conversation creator when they join a new conversation. See [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles. + :param default_conversation_role_sid: The conversation-level role assigned to users when they are added to a conversation. See [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles. + :param default_chat_service_role_sid: The service-level role assigned to users when they are added to the service. See [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles. + :param reachability_enabled: Whether the [Reachability Indicator](https://www.twilio.com/docs/conversations/reachability) is enabled for this Conversations Service. The default is `false`. :returns: The updated ConfigurationInstance """ @@ -129,10 +127,10 @@ async def update_async( """ Asynchronous coroutine to update the ConfigurationInstance - :param default_conversation_creator_role_sid: The conversation-level role assigned to a conversation creator when they join a new conversation. See the [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles. - :param default_conversation_role_sid: The conversation-level role assigned to users when they are added to a conversation. See the [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles. - :param default_chat_service_role_sid: The service-level role assigned to users when they are added to the service. See the [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles. - :param reachability_enabled: Whether the [Reachability Indicator](https://www.twilio.com/docs/chat/reachability-indicator) is enabled for this Conversations Service. The default is `false`. + :param default_conversation_creator_role_sid: The conversation-level role assigned to a conversation creator when they join a new conversation. See [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles. + :param default_conversation_role_sid: The conversation-level role assigned to users when they are added to a conversation. See [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles. + :param default_chat_service_role_sid: The service-level role assigned to users when they are added to the service. See [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles. + :param reachability_enabled: Whether the [Reachability Indicator](https://www.twilio.com/docs/conversations/reachability) is enabled for this Conversations Service. The default is `false`. :returns: The updated ConfigurationInstance """ @@ -154,6 +152,7 @@ def __repr__(self) -> str: class ConfigurationContext(InstanceContext): + def __init__(self, version: Version, chat_service_sid: str): """ Initialize the ConfigurationContext @@ -179,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, @@ -198,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( @@ -219,26 +222,32 @@ def update( """ Update the ConfigurationInstance - :param default_conversation_creator_role_sid: The conversation-level role assigned to a conversation creator when they join a new conversation. See the [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles. - :param default_conversation_role_sid: The conversation-level role assigned to users when they are added to a conversation. See the [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles. - :param default_chat_service_role_sid: The service-level role assigned to users when they are added to the service. See the [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles. - :param reachability_enabled: Whether the [Reachability Indicator](https://www.twilio.com/docs/chat/reachability-indicator) is enabled for this Conversations Service. The default is `false`. + :param default_conversation_creator_role_sid: The conversation-level role assigned to a conversation creator when they join a new conversation. See [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles. + :param default_conversation_role_sid: The conversation-level role assigned to users when they are added to a conversation. See [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles. + :param default_chat_service_role_sid: The service-level role assigned to users when they are added to the service. See [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles. + :param reachability_enabled: Whether the [Reachability Indicator](https://www.twilio.com/docs/conversations/reachability) is enabled for this Conversations Service. The default is `false`. :returns: The updated ConfigurationInstance """ + data = values.of( { "DefaultConversationCreatorRoleSid": default_conversation_creator_role_sid, "DefaultConversationRoleSid": default_conversation_role_sid, "DefaultChatServiceRoleSid": default_chat_service_role_sid, - "ReachabilityEnabled": reachability_enabled, + "ReachabilityEnabled": serialize.boolean_to_string( + reachability_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 ConfigurationInstance( @@ -255,26 +264,32 @@ async def update_async( """ Asynchronous coroutine to update the ConfigurationInstance - :param default_conversation_creator_role_sid: The conversation-level role assigned to a conversation creator when they join a new conversation. See the [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles. - :param default_conversation_role_sid: The conversation-level role assigned to users when they are added to a conversation. See the [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles. - :param default_chat_service_role_sid: The service-level role assigned to users when they are added to the service. See the [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles. - :param reachability_enabled: Whether the [Reachability Indicator](https://www.twilio.com/docs/chat/reachability-indicator) is enabled for this Conversations Service. The default is `false`. + :param default_conversation_creator_role_sid: The conversation-level role assigned to a conversation creator when they join a new conversation. See [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles. + :param default_conversation_role_sid: The conversation-level role assigned to users when they are added to a conversation. See [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles. + :param default_chat_service_role_sid: The service-level role assigned to users when they are added to the service. See [Conversation Role](https://www.twilio.com/docs/conversations/api/role-resource) for more info about roles. + :param reachability_enabled: Whether the [Reachability Indicator](https://www.twilio.com/docs/conversations/reachability) is enabled for this Conversations Service. The default is `false`. :returns: The updated ConfigurationInstance """ + data = values.of( { "DefaultConversationCreatorRoleSid": default_conversation_creator_role_sid, "DefaultConversationRoleSid": default_conversation_role_sid, "DefaultChatServiceRoleSid": default_chat_service_role_sid, - "ReachabilityEnabled": reachability_enabled, + "ReachabilityEnabled": serialize.boolean_to_string( + reachability_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 ConfigurationInstance( @@ -292,6 +307,7 @@ def __repr__(self) -> str: class ConfigurationList(ListResource): + def __init__(self, version: Version, chat_service_sid: str): """ Initialize the ConfigurationList diff --git a/twilio/rest/conversations/v1/service/configuration/notification.py b/twilio/rest/conversations/v1/service/configuration/notification.py index 388f310e9d..6aced28115 100644 --- a/twilio/rest/conversations/v1/service/configuration/notification.py +++ b/twilio/rest/conversations/v1/service/configuration/notification.py @@ -12,9 +12,8 @@ Do not edit the class manually. """ - from typing import Any, Dict, Optional, Union -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 @@ -22,7 +21,6 @@ class NotificationInstance(InstanceResource): - """ :ivar account_sid: The unique ID of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this configuration. :ivar chat_service_sid: The SID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) the Configuration applies to. @@ -201,6 +199,7 @@ def __repr__(self) -> str: class NotificationContext(InstanceContext): + def __init__(self, version: Version, chat_service_sid: str): """ Initialize the NotificationContext @@ -226,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, @@ -245,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( @@ -291,28 +294,40 @@ def update( :returns: The updated NotificationInstance """ + data = values.of( { - "LogEnabled": log_enabled, - "NewMessage.Enabled": new_message_enabled, + "LogEnabled": serialize.boolean_to_string(log_enabled), + "NewMessage.Enabled": serialize.boolean_to_string(new_message_enabled), "NewMessage.Template": new_message_template, "NewMessage.Sound": new_message_sound, - "NewMessage.BadgeCountEnabled": new_message_badge_count_enabled, - "AddedToConversation.Enabled": added_to_conversation_enabled, + "NewMessage.BadgeCountEnabled": serialize.boolean_to_string( + new_message_badge_count_enabled + ), + "AddedToConversation.Enabled": serialize.boolean_to_string( + added_to_conversation_enabled + ), "AddedToConversation.Template": added_to_conversation_template, "AddedToConversation.Sound": added_to_conversation_sound, - "RemovedFromConversation.Enabled": removed_from_conversation_enabled, + "RemovedFromConversation.Enabled": serialize.boolean_to_string( + removed_from_conversation_enabled + ), "RemovedFromConversation.Template": removed_from_conversation_template, "RemovedFromConversation.Sound": removed_from_conversation_sound, - "NewMessage.WithMedia.Enabled": new_message_with_media_enabled, + "NewMessage.WithMedia.Enabled": serialize.boolean_to_string( + new_message_with_media_enabled + ), "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( @@ -354,28 +369,40 @@ async def update_async( :returns: The updated NotificationInstance """ + data = values.of( { - "LogEnabled": log_enabled, - "NewMessage.Enabled": new_message_enabled, + "LogEnabled": serialize.boolean_to_string(log_enabled), + "NewMessage.Enabled": serialize.boolean_to_string(new_message_enabled), "NewMessage.Template": new_message_template, "NewMessage.Sound": new_message_sound, - "NewMessage.BadgeCountEnabled": new_message_badge_count_enabled, - "AddedToConversation.Enabled": added_to_conversation_enabled, + "NewMessage.BadgeCountEnabled": serialize.boolean_to_string( + new_message_badge_count_enabled + ), + "AddedToConversation.Enabled": serialize.boolean_to_string( + added_to_conversation_enabled + ), "AddedToConversation.Template": added_to_conversation_template, "AddedToConversation.Sound": added_to_conversation_sound, - "RemovedFromConversation.Enabled": removed_from_conversation_enabled, + "RemovedFromConversation.Enabled": serialize.boolean_to_string( + removed_from_conversation_enabled + ), "RemovedFromConversation.Template": removed_from_conversation_template, "RemovedFromConversation.Sound": removed_from_conversation_sound, - "NewMessage.WithMedia.Enabled": new_message_with_media_enabled, + "NewMessage.WithMedia.Enabled": serialize.boolean_to_string( + new_message_with_media_enabled + ), "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( @@ -393,6 +420,7 @@ def __repr__(self) -> str: class NotificationList(ListResource): + def __init__(self, version: Version, chat_service_sid: str): """ Initialize the NotificationList diff --git a/twilio/rest/conversations/v1/service/configuration/webhook.py b/twilio/rest/conversations/v1/service/configuration/webhook.py index 6152c44333..706f410550 100644 --- a/twilio/rest/conversations/v1/service/configuration/webhook.py +++ b/twilio/rest/conversations/v1/service/configuration/webhook.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, List, Optional, Union from twilio.base import serialize, values from twilio.base.instance_context import InstanceContext @@ -22,6 +21,7 @@ class WebhookInstance(InstanceResource): + class Method(object): GET = "GET" POST = "POST" @@ -146,6 +146,7 @@ def __repr__(self) -> str: class WebhookContext(InstanceContext): + def __init__(self, version: Version, chat_service_sid: str): """ Initialize the WebhookContext @@ -171,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, @@ -190,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( @@ -218,6 +223,7 @@ def update( :returns: The updated WebhookInstance """ + data = values.of( { "PreWebhookUrl": pre_webhook_url, @@ -226,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( @@ -254,6 +263,7 @@ async def update_async( :returns: The updated WebhookInstance """ + data = values.of( { "PreWebhookUrl": pre_webhook_url, @@ -262,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( @@ -284,6 +297,7 @@ def __repr__(self) -> str: class WebhookList(ListResource): + def __init__(self, version: Version, chat_service_sid: str): """ Initialize the WebhookList diff --git a/twilio/rest/conversations/v1/service/conversation/__init__.py b/twilio/rest/conversations/v1/service/conversation/__init__.py index e52a2bdb16..0f28c4dfe2 100644 --- a/twilio/rest/conversations/v1/service/conversation/__init__.py +++ b/twilio/rest/conversations/v1/service/conversation/__init__.py @@ -12,7 +12,6 @@ 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 @@ -29,6 +28,7 @@ class ConversationInstance(InstanceResource): + class State(object): INACTIVE = "inactive" ACTIVE = "active" @@ -41,7 +41,7 @@ class WebhookEnabledType(object): """ :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/sms/services/api) 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. @@ -171,6 +171,8 @@ def update( timers_inactive: Union[str, object] = values.unset, timers_closed: Union[str, object] = values.unset, unique_name: Union[str, object] = values.unset, + bindings_email_address: Union[str, object] = values.unset, + bindings_email_name: Union[str, object] = values.unset, ) -> "ConversationInstance": """ Update the ConversationInstance @@ -180,11 +182,13 @@ def update( :param date_created: The date that this resource was created. :param date_updated: The date that this resource was last updated. :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 messaging_service_sid: The unique ID of the [Messaging Service](https://www.twilio.com/docs/sms/services/api) this conversation belongs to. + :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 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 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 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. :returns: The updated ConversationInstance """ @@ -199,6 +203,8 @@ def update( timers_inactive=timers_inactive, timers_closed=timers_closed, unique_name=unique_name, + bindings_email_address=bindings_email_address, + bindings_email_name=bindings_email_name, ) async def update_async( @@ -215,6 +221,8 @@ async def update_async( timers_inactive: Union[str, object] = values.unset, timers_closed: Union[str, object] = values.unset, unique_name: Union[str, object] = values.unset, + bindings_email_address: Union[str, object] = values.unset, + bindings_email_name: Union[str, object] = values.unset, ) -> "ConversationInstance": """ Asynchronous coroutine to update the ConversationInstance @@ -224,11 +232,13 @@ async def update_async( :param date_created: The date that this resource was created. :param date_updated: The date that this resource was last updated. :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 messaging_service_sid: The unique ID of the [Messaging Service](https://www.twilio.com/docs/sms/services/api) this conversation belongs to. + :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 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 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 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. :returns: The updated ConversationInstance """ @@ -243,6 +253,8 @@ async def update_async( timers_inactive=timers_inactive, timers_closed=timers_closed, unique_name=unique_name, + bindings_email_address=bindings_email_address, + bindings_email_name=bindings_email_name, ) @property @@ -277,6 +289,7 @@ def __repr__(self) -> str: class ConversationContext(InstanceContext): + def __init__(self, version: Version, chat_service_sid: str, sid: str): """ Initialize the ConversationContext @@ -319,6 +332,8 @@ def delete( } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async( @@ -340,6 +355,8 @@ async def delete_async( } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -352,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, @@ -372,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( @@ -398,6 +419,8 @@ def update( timers_inactive: Union[str, object] = values.unset, timers_closed: Union[str, object] = values.unset, unique_name: Union[str, object] = values.unset, + bindings_email_address: Union[str, object] = values.unset, + bindings_email_name: Union[str, object] = values.unset, ) -> ConversationInstance: """ Update the ConversationInstance @@ -407,14 +430,17 @@ def update( :param date_created: The date that this resource was created. :param date_updated: The date that this resource was last updated. :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 messaging_service_sid: The unique ID of the [Messaging Service](https://www.twilio.com/docs/sms/services/api) this conversation belongs to. + :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 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 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 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. :returns: The updated ConversationInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -426,13 +452,24 @@ def update( "Timers.Inactive": timers_inactive, "Timers.Closed": timers_closed, "UniqueName": unique_name, + "Bindings.Email.Address": bindings_email_address, + "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 @@ -459,6 +496,8 @@ async def update_async( timers_inactive: Union[str, object] = values.unset, timers_closed: Union[str, object] = values.unset, unique_name: Union[str, object] = values.unset, + bindings_email_address: Union[str, object] = values.unset, + bindings_email_name: Union[str, object] = values.unset, ) -> ConversationInstance: """ Asynchronous coroutine to update the ConversationInstance @@ -468,14 +507,17 @@ async def update_async( :param date_created: The date that this resource was created. :param date_updated: The date that this resource was last updated. :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 messaging_service_sid: The unique ID of the [Messaging Service](https://www.twilio.com/docs/sms/services/api) this conversation belongs to. + :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 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 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 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. :returns: The updated ConversationInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -487,13 +529,24 @@ async def update_async( "Timers.Inactive": timers_inactive, "Timers.Closed": timers_closed, "UniqueName": unique_name, + "Bindings.Email.Address": bindings_email_address, + "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 @@ -556,6 +609,7 @@ def __repr__(self) -> str: class ConversationPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ConversationInstance: """ Build an instance of ConversationInstance @@ -576,6 +630,7 @@ def __repr__(self) -> str: class ConversationList(ListResource): + def __init__(self, version: Version, chat_service_sid: str): """ Initialize the ConversationList @@ -608,6 +663,8 @@ def create( state: Union["ConversationInstance.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, ) -> ConversationInstance: """ Create the ConversationInstance @@ -616,15 +673,18 @@ def create( :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 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 messaging_service_sid: The unique ID of the [Messaging Service](https://www.twilio.com/docs/sms/services/api) this conversation belongs to. + :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 date_created: The date that this resource was created. :param date_updated: The date that this resource was last updated. :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. :returns: The created ConversationInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -636,13 +696,21 @@ def create( "State": state, "Timers.Inactive": timers_inactive, "Timers.Closed": timers_closed, + "Bindings.Email.Address": bindings_email_address, + "Bindings.Email.Name": bindings_email_name, } ) 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 ) @@ -665,6 +733,8 @@ async def create_async( state: Union["ConversationInstance.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, ) -> ConversationInstance: """ Asynchronously create the ConversationInstance @@ -673,15 +743,18 @@ async def create_async( :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 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 messaging_service_sid: The unique ID of the [Messaging Service](https://www.twilio.com/docs/sms/services/api) this conversation belongs to. + :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 date_created: The date that this resource was created. :param date_updated: The date that this resource was last updated. :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. :returns: The created ConversationInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -693,13 +766,21 @@ async def create_async( "State": state, "Timers.Inactive": timers_inactive, "Timers.Closed": timers_closed, + "Bindings.Email.Address": bindings_email_address, + "Bindings.Email.Name": bindings_email_name, } ) 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 ) @@ -722,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 in ISO8601 format for sorting and filtering list of Conversations. - :param str end_date: End date in ISO8601 format for sorting and filtering list of Conversations. + :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 @@ -758,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 in ISO8601 format for sorting and filtering list of Conversations. - :param str end_date: End date in ISO8601 format for sorting and filtering list of Conversations. + :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 @@ -793,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 in ISO8601 format for sorting and filtering list of Conversations. - :param str end_date: End date in ISO8601 format for sorting and filtering list of Conversations. + :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 @@ -828,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 in ISO8601 format for sorting and filtering list of Conversations. - :param str end_date: End date in ISO8601 format for sorting and filtering list of Conversations. + :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 @@ -864,8 +945,8 @@ def page( Retrieve a single page of ConversationInstance records from the API. Request is executed immediately - :param start_date: Start date in ISO8601 format for sorting and filtering list of Conversations. - :param end_date: End date in ISO8601 format for sorting and filtering list of Conversations. + :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 @@ -884,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( @@ -900,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 in ISO8601 format for sorting and filtering list of Conversations. - :param end_date: End date in ISO8601 format for sorting and filtering list of Conversations. + :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 @@ -920,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 e8a4dd4cfb..c4123afd34 100644 --- a/twilio/rest/conversations/v1/service/conversation/message/__init__.py +++ b/twilio/rest/conversations/v1/service/conversation/message/__init__.py @@ -12,7 +12,6 @@ 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 @@ -27,6 +26,7 @@ class MessageInstance(InstanceResource): + class OrderType(object): ASC = "asc" DESC = "desc" @@ -51,7 +51,7 @@ class WebhookEnabledType(object): :ivar delivery: An object that contains the summary of delivery statuses for the message to non-chat participants. :ivar url: An absolute API resource URL for this message. :ivar links: Contains an absolute API resource URL to access the delivery & read receipts of this message. - :ivar content_sid: The unique ID of the multi-channel [Rich Content](https://www.twilio.com/docs/content-api) template. + :ivar content_sid: The unique ID of the multi-channel [Rich Content](https://www.twilio.com/docs/content) template. """ def __init__( @@ -71,7 +71,7 @@ def __init__( self.index: Optional[int] = deserialize.integer(payload.get("index")) self.author: Optional[str] = payload.get("author") self.body: Optional[str] = payload.get("body") - self.media: Optional[List[object]] = payload.get("media") + self.media: Optional[List[Dict[str, object]]] = payload.get("media") self.attributes: Optional[str] = payload.get("attributes") self.participant_sid: Optional[str] = payload.get("participant_sid") self.date_created: Optional[datetime] = deserialize.iso8601_datetime( @@ -171,6 +171,7 @@ def update( date_created: Union[datetime, object] = values.unset, date_updated: Union[datetime, object] = values.unset, attributes: Union[str, object] = values.unset, + subject: Union[str, object] = values.unset, ) -> "MessageInstance": """ Update the MessageInstance @@ -181,6 +182,7 @@ def update( :param date_created: The date that this resource was created. :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. :param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. + :param subject: The subject of the message, can be up to 256 characters long. :returns: The updated MessageInstance """ @@ -191,6 +193,7 @@ def update( date_created=date_created, date_updated=date_updated, attributes=attributes, + subject=subject, ) async def update_async( @@ -203,6 +206,7 @@ async def update_async( date_created: Union[datetime, object] = values.unset, date_updated: Union[datetime, object] = values.unset, attributes: Union[str, object] = values.unset, + subject: Union[str, object] = values.unset, ) -> "MessageInstance": """ Asynchronous coroutine to update the MessageInstance @@ -213,6 +217,7 @@ async def update_async( :param date_created: The date that this resource was created. :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. :param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. + :param subject: The subject of the message, can be up to 256 characters long. :returns: The updated MessageInstance """ @@ -223,6 +228,7 @@ async def update_async( date_created=date_created, date_updated=date_updated, attributes=attributes, + subject=subject, ) @property @@ -243,6 +249,7 @@ def __repr__(self) -> str: class MessageContext(InstanceContext): + def __init__( self, version: Version, chat_service_sid: str, conversation_sid: str, sid: str ): @@ -287,6 +294,8 @@ def delete( } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async( @@ -308,6 +317,8 @@ async def delete_async( } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -320,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, @@ -341,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( @@ -364,6 +379,7 @@ def update( date_created: Union[datetime, object] = values.unset, date_updated: Union[datetime, object] = values.unset, attributes: Union[str, object] = values.unset, + subject: Union[str, object] = values.unset, ) -> MessageInstance: """ Update the MessageInstance @@ -374,9 +390,11 @@ def update( :param date_created: The date that this resource was created. :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. :param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. + :param subject: The subject of the message, can be up to 256 characters long. :returns: The updated MessageInstance """ + data = values.of( { "Author": author, @@ -384,13 +402,23 @@ def update( "DateCreated": serialize.iso8601_datetime(date_created), "DateUpdated": serialize.iso8601_datetime(date_updated), "Attributes": attributes, + "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 @@ -414,6 +442,7 @@ async def update_async( date_created: Union[datetime, object] = values.unset, date_updated: Union[datetime, object] = values.unset, attributes: Union[str, object] = values.unset, + subject: Union[str, object] = values.unset, ) -> MessageInstance: """ Asynchronous coroutine to update the MessageInstance @@ -424,9 +453,11 @@ async def update_async( :param date_created: The date that this resource was created. :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. :param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. + :param subject: The subject of the message, can be up to 256 characters long. :returns: The updated MessageInstance """ + data = values.of( { "Author": author, @@ -434,13 +465,23 @@ async def update_async( "DateCreated": serialize.iso8601_datetime(date_created), "DateUpdated": serialize.iso8601_datetime(date_updated), "Attributes": attributes, + "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 @@ -479,6 +520,7 @@ def __repr__(self) -> str: class MessagePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> MessageInstance: """ Build an instance of MessageInstance @@ -502,6 +544,7 @@ def __repr__(self) -> str: class MessageList(ListResource): + def __init__(self, version: Version, chat_service_sid: str, conversation_sid: str): """ Initialize the MessageList @@ -535,6 +578,7 @@ def create( media_sid: Union[str, object] = values.unset, content_sid: Union[str, object] = values.unset, content_variables: Union[str, object] = values.unset, + subject: Union[str, object] = values.unset, ) -> MessageInstance: """ Create the MessageInstance @@ -546,11 +590,13 @@ def create( :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. :param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. :param media_sid: The Media SID to be attached to the new Message. - :param content_sid: The unique ID of the multi-channel [Rich Content](https://www.twilio.com/docs/content-api) template, required for template-generated messages. **Note** that if this field is set, `Body` and `MediaSid` parameters are ignored. + :param content_sid: The unique ID of the multi-channel [Rich Content](https://www.twilio.com/docs/content) template, required for template-generated messages. **Note** that if this field is set, `Body` and `MediaSid` parameters are ignored. :param content_variables: A structurally valid JSON string that contains values to resolve Rich Content template variables. + :param subject: The subject of the message, can be up to 256 characters long. :returns: The created MessageInstance """ + data = values.of( { "Author": author, @@ -561,13 +607,20 @@ def create( "MediaSid": media_sid, "ContentSid": content_sid, "ContentVariables": content_variables, + "Subject": subject, } ) 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 ) @@ -592,6 +645,7 @@ async def create_async( media_sid: Union[str, object] = values.unset, content_sid: Union[str, object] = values.unset, content_variables: Union[str, object] = values.unset, + subject: Union[str, object] = values.unset, ) -> MessageInstance: """ Asynchronously create the MessageInstance @@ -603,11 +657,13 @@ async def create_async( :param date_updated: The date that this resource was last updated. `null` if the message has not been edited. :param attributes: A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. :param media_sid: The Media SID to be attached to the new Message. - :param content_sid: The unique ID of the multi-channel [Rich Content](https://www.twilio.com/docs/content-api) template, required for template-generated messages. **Note** that if this field is set, `Body` and `MediaSid` parameters are ignored. + :param content_sid: The unique ID of the multi-channel [Rich Content](https://www.twilio.com/docs/content) template, required for template-generated messages. **Note** that if this field is set, `Body` and `MediaSid` parameters are ignored. :param content_variables: A structurally valid JSON string that contains values to resolve Rich Content template variables. + :param subject: The subject of the message, can be up to 256 characters long. :returns: The created MessageInstance """ + data = values.of( { "Author": author, @@ -618,13 +674,20 @@ async def create_async( "MediaSid": media_sid, "ContentSid": content_sid, "ContentVariables": content_variables, + "Subject": subject, } ) 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 +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( @@ -806,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 01e6f392f2..939b631271 100644 --- a/twilio/rest/conversations/v1/service/conversation/message/delivery_receipt.py +++ b/twilio/rest/conversations/v1/service/conversation/message/delivery_receipt.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class DeliveryReceiptInstance(InstanceResource): + class DeliveryStatus(object): READ = "read" FAILED = "failed" @@ -131,6 +131,7 @@ def __repr__(self) -> str: class DeliveryReceiptContext(InstanceContext): + def __init__( self, version: Version, @@ -169,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, @@ -191,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( @@ -216,6 +221,7 @@ def __repr__(self) -> str: class DeliveryReceiptPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> DeliveryReceiptInstance: """ Build an instance of DeliveryReceiptInstance @@ -240,6 +246,7 @@ def __repr__(self) -> str: class DeliveryReceiptList(ListResource): + def __init__( self, version: Version, @@ -395,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( @@ -422,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 dbec40f549..03a3cead7e 100644 --- a/twilio/rest/conversations/v1/service/conversation/participant.py +++ b/twilio/rest/conversations/v1/service/conversation/participant.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class ParticipantInstance(InstanceResource): + class WebhookEnabledType(object): TRUE = "true" FALSE = "false" @@ -33,12 +33,12 @@ class WebhookEnabledType(object): :ivar chat_service_sid: The SID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) the Participant resource is associated with. :ivar conversation_sid: The unique ID of the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this participant. :ivar sid: A 34 character string that uniquely identifies this resource. - :ivar identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversation SDK to communicate. Limited to 256 characters. - :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 identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the [Conversation SDK](https://www.twilio.com/docs/conversations/sdk-overview) to communicate. Limited to 256 characters. + :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 messaging_binding: Information about how this participant exchanges messages with the conversation. A JSON parameter consisting of type and address fields of the participant. :ivar role_sid: The SID of a conversation-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the participant. - :ivar date_created: The date that this resource was created. - :ivar date_updated: The date that this resource was last updated. + :ivar date_created: The date on which this resource was created. + :ivar date_updated: The date on which this resource was last updated. :ivar url: An absolute API resource URL for this participant. :ivar last_read_message_index: Index of last “read” message in the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for the Participant. :ivar last_read_timestamp: Timestamp of last “read” message in the [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for the Participant. @@ -171,10 +171,10 @@ def update( Update the ParticipantInstance :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header - :param date_created: The date that this resource was created. - :param date_updated: The date that this resource was last updated. - :param identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversation SDK to communicate. Limited to 256 characters. - :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 date_created: The date on which this resource was created. + :param date_updated: The date on which this resource was last updated. + :param identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the [Conversation SDK](https://www.twilio.com/docs/conversations/sdk-overview) to communicate. Limited to 256 characters. + :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 role_sid: The SID of a conversation-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the participant. :param messaging_binding_proxy_address: The address of the Twilio phone number that the participant is in contact with. 'null' value will remove it. :param messaging_binding_projected_address: The address of the Twilio phone number that is used in Group MMS. 'null' value will remove it. @@ -215,10 +215,10 @@ async def update_async( Asynchronous coroutine to update the ParticipantInstance :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header - :param date_created: The date that this resource was created. - :param date_updated: The date that this resource was last updated. - :param identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversation SDK to communicate. Limited to 256 characters. - :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 date_created: The date on which this resource was created. + :param date_updated: The date on which this resource was last updated. + :param identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the [Conversation SDK](https://www.twilio.com/docs/conversations/sdk-overview) to communicate. Limited to 256 characters. + :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 role_sid: The SID of a conversation-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the participant. :param messaging_binding_proxy_address: The address of the Twilio phone number that the participant is in contact with. 'null' value will remove it. :param messaging_binding_projected_address: The address of the Twilio phone number that is used in Group MMS. 'null' value will remove it. @@ -251,6 +251,7 @@ def __repr__(self) -> str: class ParticipantContext(InstanceContext): + def __init__( self, version: Version, chat_service_sid: str, conversation_sid: str, sid: str ): @@ -293,6 +294,8 @@ def delete( } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async( @@ -314,6 +317,8 @@ async def delete_async( } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -326,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, @@ -347,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( @@ -379,10 +388,10 @@ def update( Update the ParticipantInstance :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header - :param date_created: The date that this resource was created. - :param date_updated: The date that this resource was last updated. - :param identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversation SDK to communicate. Limited to 256 characters. - :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 date_created: The date on which this resource was created. + :param date_updated: The date on which this resource was last updated. + :param identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the [Conversation SDK](https://www.twilio.com/docs/conversations/sdk-overview) to communicate. Limited to 256 characters. + :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 role_sid: The SID of a conversation-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the participant. :param messaging_binding_proxy_address: The address of the Twilio phone number that the participant is in contact with. 'null' value will remove it. :param messaging_binding_projected_address: The address of the Twilio phone number that is used in Group MMS. 'null' value will remove it. @@ -391,6 +400,7 @@ def update( :returns: The updated ParticipantInstance """ + data = values.of( { "DateCreated": serialize.iso8601_datetime(date_created), @@ -404,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 @@ -441,10 +460,10 @@ async def update_async( Asynchronous coroutine to update the ParticipantInstance :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header - :param date_created: The date that this resource was created. - :param date_updated: The date that this resource was last updated. - :param identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversation SDK to communicate. Limited to 256 characters. - :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 date_created: The date on which this resource was created. + :param date_updated: The date on which this resource was last updated. + :param identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the [Conversation SDK](https://www.twilio.com/docs/conversations/sdk-overview) to communicate. Limited to 256 characters. + :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 role_sid: The SID of a conversation-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the participant. :param messaging_binding_proxy_address: The address of the Twilio phone number that the participant is in contact with. 'null' value will remove it. :param messaging_binding_projected_address: The address of the Twilio phone number that is used in Group MMS. 'null' value will remove it. @@ -453,6 +472,7 @@ async def update_async( :returns: The updated ParticipantInstance """ + data = values.of( { "DateCreated": serialize.iso8601_datetime(date_created), @@ -466,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 @@ -495,6 +524,7 @@ def __repr__(self) -> str: class ParticipantPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ParticipantInstance: """ Build an instance of ParticipantInstance @@ -518,6 +548,7 @@ def __repr__(self) -> str: class ParticipantList(ListResource): + def __init__(self, version: Version, chat_service_sid: str, conversation_sid: str): """ Initialize the ParticipantList @@ -556,17 +587,18 @@ def create( Create the ParticipantInstance :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header - :param identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversation SDK to communicate. Limited to 256 characters. - :param messaging_binding_address: The address of the participant's device, e.g. a phone or WhatsApp number. Together with the Proxy address, this determines a participant uniquely. This field (with proxy_address) is only null when the participant is interacting from an SDK endpoint (see the 'identity' field). - :param messaging_binding_proxy_address: The address of the Twilio phone number (or WhatsApp number) that the participant is in contact with. This field, together with participant address, is only null when the participant is interacting from an SDK endpoint (see the 'identity' field). - :param date_created: The date that this resource was created. - :param date_updated: The date that this resource was last updated. - :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 messaging_binding_projected_address: The address of the Twilio phone number that is used in Group MMS. Communication mask for the Conversation participant with Identity. + :param identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the [Conversation SDK](https://www.twilio.com/docs/conversations/sdk-overview) to communicate. Limited to 256 characters. + :param messaging_binding_address: The address of the participant's device, e.g. a phone or WhatsApp number. Together with the Proxy address, this determines a participant uniquely. This field (with `proxy_address`) is only null when the participant is interacting from an SDK endpoint (see the `identity` field). + :param messaging_binding_proxy_address: The address of the Twilio phone number (or WhatsApp number) that the participant is in contact with. This field, together with participant address, is only null when the participant is interacting from an SDK endpoint (see the `identity` field). + :param date_created: The date on which this resource was created. + :param date_updated: The date on which this resource was last updated. + :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 messaging_binding_projected_address: The address of the Twilio phone number that is used in Group MMS. :param role_sid: The SID of a conversation-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the participant. :returns: The created ParticipantInstance """ + data = values.of( { "Identity": identity, @@ -582,8 +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 ) @@ -613,17 +651,18 @@ async def create_async( Asynchronously create the ParticipantInstance :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header - :param identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversation SDK to communicate. Limited to 256 characters. - :param messaging_binding_address: The address of the participant's device, e.g. a phone or WhatsApp number. Together with the Proxy address, this determines a participant uniquely. This field (with proxy_address) is only null when the participant is interacting from an SDK endpoint (see the 'identity' field). - :param messaging_binding_proxy_address: The address of the Twilio phone number (or WhatsApp number) that the participant is in contact with. This field, together with participant address, is only null when the participant is interacting from an SDK endpoint (see the 'identity' field). - :param date_created: The date that this resource was created. - :param date_updated: The date that this resource was last updated. - :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 messaging_binding_projected_address: The address of the Twilio phone number that is used in Group MMS. Communication mask for the Conversation participant with Identity. + :param identity: A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the [Conversation SDK](https://www.twilio.com/docs/conversations/sdk-overview) to communicate. Limited to 256 characters. + :param messaging_binding_address: The address of the participant's device, e.g. a phone or WhatsApp number. Together with the Proxy address, this determines a participant uniquely. This field (with `proxy_address`) is only null when the participant is interacting from an SDK endpoint (see the `identity` field). + :param messaging_binding_proxy_address: The address of the Twilio phone number (or WhatsApp number) that the participant is in contact with. This field, together with participant address, is only null when the participant is interacting from an SDK endpoint (see the `identity` field). + :param date_created: The date on which this resource was created. + :param date_updated: The date on which this resource was last updated. + :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 messaging_binding_projected_address: The address of the Twilio phone number that is used in Group MMS. :param role_sid: The SID of a conversation-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the participant. :returns: The created ParticipantInstance """ + data = values.of( { "Identity": identity, @@ -639,8 +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 ) @@ -779,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( @@ -806,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 88e848f351..270dfaef3a 100644 --- a/twilio/rest/conversations/v1/service/conversation/webhook.py +++ b/twilio/rest/conversations/v1/service/conversation/webhook.py @@ -12,7 +12,6 @@ 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 @@ -24,9 +23,10 @@ class WebhookInstance(InstanceResource): + class Method(object): - GET = "GET" - POST = "POST" + GET = "get" + POST = "post" class Target(object): WEBHOOK = "webhook" @@ -194,6 +194,7 @@ def __repr__(self) -> str: class WebhookContext(InstanceContext): + def __init__( self, version: Version, chat_service_sid: str, conversation_sid: str, sid: str ): @@ -224,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: """ @@ -236,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: @@ -249,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, @@ -270,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( @@ -302,6 +309,7 @@ def update( :returns: The updated WebhookInstance """ + data = values.of( { "Configuration.Url": configuration_url, @@ -315,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( @@ -349,6 +360,7 @@ async def update_async( :returns: The updated WebhookInstance """ + data = values.of( { "Configuration.Url": configuration_url, @@ -362,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( @@ -388,6 +403,7 @@ def __repr__(self) -> str: class WebhookPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> WebhookInstance: """ Build an instance of WebhookInstance @@ -411,6 +427,7 @@ def __repr__(self) -> str: class WebhookList(ListResource): + def __init__(self, version: Version, chat_service_sid: str, conversation_sid: str): """ Initialize the WebhookList @@ -454,6 +471,7 @@ def create( :returns: The created WebhookInstance """ + data = values.of( { "Target": target, @@ -469,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( @@ -506,6 +527,7 @@ async def create_async( :returns: The created WebhookInstance """ + data = values.of( { "Target": target, @@ -521,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( @@ -662,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( @@ -689,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 b4de04f277..8ec561a7d9 100644 --- a/twilio/rest/conversations/v1/service/participant_conversation.py +++ b/twilio/rest/conversations/v1/service/participant_conversation.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class ParticipantConversationInstance(InstanceResource): + class State(object): INACTIVE = "inactive" ACTIVE = "active" @@ -71,18 +71,18 @@ def __init__( self.conversation_attributes: Optional[str] = payload.get( "conversation_attributes" ) - self.conversation_date_created: Optional[ - datetime - ] = deserialize.iso8601_datetime(payload.get("conversation_date_created")) - self.conversation_date_updated: Optional[ - datetime - ] = deserialize.iso8601_datetime(payload.get("conversation_date_updated")) + self.conversation_date_created: Optional[datetime] = ( + deserialize.iso8601_datetime(payload.get("conversation_date_created")) + ) + self.conversation_date_updated: Optional[datetime] = ( + deserialize.iso8601_datetime(payload.get("conversation_date_updated")) + ) self.conversation_created_by: Optional[str] = payload.get( "conversation_created_by" ) - self.conversation_state: Optional[ - "ParticipantConversationInstance.State" - ] = payload.get("conversation_state") + self.conversation_state: Optional["ParticipantConversationInstance.State"] = ( + payload.get("conversation_state") + ) self.conversation_timers: Optional[Dict[str, object]] = payload.get( "conversation_timers" ) @@ -105,6 +105,7 @@ def __repr__(self) -> str: class ParticipantConversationPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ParticipantConversationInstance: """ Build an instance of ParticipantConversationInstance @@ -125,6 +126,7 @@ def __repr__(self) -> str: class ParticipantConversationList(ListResource): + def __init__(self, version: Version, chat_service_sid: str): """ Initialize the ParticipantConversationList @@ -300,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( @@ -333,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 2ae2c16fb1..0884fb008b 100644 --- a/twilio/rest/conversations/v1/service/role.py +++ b/twilio/rest/conversations/v1/service/role.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class RoleInstance(InstanceResource): + class RoleType(object): CONVERSATION = "conversation" SERVICE = "service" @@ -156,6 +156,7 @@ def __repr__(self) -> str: class RoleContext(InstanceContext): + def __init__(self, version: Version, chat_service_sid: str, sid: str): """ Initialize the RoleContext @@ -180,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: """ @@ -192,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: @@ -205,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, @@ -225,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( @@ -245,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( @@ -272,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( @@ -302,6 +317,7 @@ def __repr__(self) -> str: class RolePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> RoleInstance: """ Build an instance of RoleInstance @@ -322,6 +338,7 @@ def __repr__(self) -> str: class RoleList(ListResource): + def __init__(self, version: Version, chat_service_sid: str): """ Initialize the RoleList @@ -350,6 +367,7 @@ def create( :returns: The created RoleInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -357,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( @@ -380,6 +401,7 @@ async def create_async( :returns: The created RoleInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -387,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( @@ -525,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( @@ -552,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 10747179bf..b8cda74c8c 100644 --- a/twilio/rest/conversations/v1/service/user/__init__.py +++ b/twilio/rest/conversations/v1/service/user/__init__.py @@ -12,7 +12,6 @@ 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 @@ -27,6 +26,7 @@ class UserInstance(InstanceResource): + class WebhookEnabledType(object): TRUE = "true" FALSE = "false" @@ -218,6 +218,7 @@ def __repr__(self) -> str: class UserContext(InstanceContext): + def __init__(self, version: Version, chat_service_sid: str, sid: str): """ Initialize the UserContext @@ -256,6 +257,8 @@ def delete( } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async( @@ -277,6 +280,8 @@ async def delete_async( } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -289,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, @@ -309,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( @@ -340,6 +349,7 @@ def update( :returns: The updated UserInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -347,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 @@ -383,6 +402,7 @@ async def update_async( :returns: The updated UserInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -390,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 @@ -431,6 +460,7 @@ def __repr__(self) -> str: class UserPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> UserInstance: """ Build an instance of UserInstance @@ -451,6 +481,7 @@ def __repr__(self) -> str: class UserList(ListResource): + def __init__(self, version: Version, chat_service_sid: str): """ Initialize the UserList @@ -488,6 +519,7 @@ def create( :returns: The created UserInstance """ + data = values.of( { "Identity": identity, @@ -499,8 +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 ) @@ -530,6 +568,7 @@ async def create_async( :returns: The created UserInstance """ + data = values.of( { "Identity": identity, @@ -541,8 +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 ) @@ -678,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( @@ -705,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 40e02f746a..4f1727f8e8 100644 --- a/twilio/rest/conversations/v1/service/user/user_conversation.py +++ b/twilio/rest/conversations/v1/service/user/user_conversation.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class UserConversationInstance(InstanceResource): + class NotificationLevel(object): DEFAULT = "default" MUTED = "muted" @@ -76,9 +76,9 @@ def __init__( self.participant_sid: Optional[str] = payload.get("participant_sid") self.user_sid: Optional[str] = payload.get("user_sid") self.friendly_name: Optional[str] = payload.get("friendly_name") - self.conversation_state: Optional[ - "UserConversationInstance.State" - ] = payload.get("conversation_state") + self.conversation_state: Optional["UserConversationInstance.State"] = ( + payload.get("conversation_state") + ) self.timers: Optional[Dict[str, object]] = payload.get("timers") self.attributes: Optional[str] = payload.get("attributes") self.date_created: Optional[datetime] = deserialize.iso8601_datetime( @@ -212,6 +212,7 @@ def __repr__(self) -> str: class UserConversationContext(InstanceContext): + def __init__( self, version: Version, @@ -246,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: """ @@ -258,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: @@ -271,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, @@ -292,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( @@ -322,6 +329,7 @@ def update( :returns: The updated UserConversationInstance """ + data = values.of( { "NotificationLevel": notification_level, @@ -329,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( @@ -361,6 +372,7 @@ async def update_async( :returns: The updated UserConversationInstance """ + data = values.of( { "NotificationLevel": notification_level, @@ -368,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( @@ -394,6 +409,7 @@ def __repr__(self) -> str: class UserConversationPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> UserConversationInstance: """ Build an instance of UserConversationInstance @@ -417,6 +433,7 @@ def __repr__(self) -> str: class UserConversationList(ListResource): + def __init__(self, version: Version, chat_service_sid: str, user_sid: str): """ Initialize the UserConversationList @@ -566,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( @@ -593,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 72a285885e..fe5d12f095 100644 --- a/twilio/rest/conversations/v1/user/__init__.py +++ b/twilio/rest/conversations/v1/user/__init__.py @@ -12,7 +12,6 @@ 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 @@ -25,6 +24,7 @@ class UserInstance(InstanceResource): + class WebhookEnabledType(object): TRUE = "true" FALSE = "false" @@ -210,6 +210,7 @@ def __repr__(self) -> str: class UserContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the UserContext @@ -246,6 +247,8 @@ def delete( } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async( @@ -267,6 +270,8 @@ async def delete_async( } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -279,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, @@ -298,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( @@ -328,6 +337,7 @@ def update( :returns: The updated UserInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -335,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 @@ -366,6 +385,7 @@ async def update_async( :returns: The updated UserInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -373,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 @@ -408,6 +437,7 @@ def __repr__(self) -> str: class UserPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> UserInstance: """ Build an instance of UserInstance @@ -426,6 +456,7 @@ def __repr__(self) -> str: class UserList(ListResource): + def __init__(self, version: Version): """ Initialize the UserList @@ -458,6 +489,7 @@ def create( :returns: The created UserInstance """ + data = values.of( { "Identity": identity, @@ -469,8 +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 ) @@ -498,6 +536,7 @@ async def create_async( :returns: The created UserInstance """ + data = values.of( { "Identity": identity, @@ -509,8 +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 ) @@ -644,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( @@ -671,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 4134066afd..16ce2c2418 100644 --- a/twilio/rest/conversations/v1/user/user_conversation.py +++ b/twilio/rest/conversations/v1/user/user_conversation.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class UserConversationInstance(InstanceResource): + class NotificationLevel(object): DEFAULT = "default" MUTED = "muted" @@ -75,9 +75,9 @@ def __init__( self.participant_sid: Optional[str] = payload.get("participant_sid") self.user_sid: Optional[str] = payload.get("user_sid") self.friendly_name: Optional[str] = payload.get("friendly_name") - self.conversation_state: Optional[ - "UserConversationInstance.State" - ] = payload.get("conversation_state") + self.conversation_state: Optional["UserConversationInstance.State"] = ( + payload.get("conversation_state") + ) self.timers: Optional[Dict[str, object]] = payload.get("timers") self.attributes: Optional[str] = payload.get("attributes") self.date_created: Optional[datetime] = deserialize.iso8601_datetime( @@ -209,6 +209,7 @@ def __repr__(self) -> str: class UserConversationContext(InstanceContext): + def __init__(self, version: Version, user_sid: str, conversation_sid: str): """ Initialize the UserConversationContext @@ -235,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: """ @@ -247,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: @@ -260,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, @@ -280,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( @@ -309,6 +316,7 @@ def update( :returns: The updated UserConversationInstance """ + data = values.of( { "NotificationLevel": notification_level, @@ -316,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( @@ -347,6 +358,7 @@ async def update_async( :returns: The updated UserConversationInstance """ + data = values.of( { "NotificationLevel": notification_level, @@ -354,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( @@ -379,6 +394,7 @@ def __repr__(self) -> str: class UserConversationPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> UserConversationInstance: """ Build an instance of UserConversationInstance @@ -399,6 +415,7 @@ def __repr__(self) -> str: class UserConversationList(ListResource): + def __init__(self, version: Version, user_sid: str): """ Initialize the UserConversationList @@ -542,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( @@ -569,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/EventsBase.py b/twilio/rest/events/EventsBase.py index 17c087a1d5..eb2251ae4e 100644 --- a/twilio/rest/events/EventsBase.py +++ b/twilio/rest/events/EventsBase.py @@ -17,6 +17,7 @@ class EventsBase(Domain): + def __init__(self, twilio: Client): """ Initialize the Events Domain diff --git a/twilio/rest/events/v1/__init__.py b/twilio/rest/events/v1/__init__.py index d62e813d50..6b91355444 100644 --- a/twilio/rest/events/v1/__init__.py +++ b/twilio/rest/events/v1/__init__.py @@ -22,6 +22,7 @@ class V1(Version): + def __init__(self, domain: Domain): """ Initialize the V1 version of Events diff --git a/twilio/rest/events/v1/event_type.py b/twilio/rest/events/v1/event_type.py index beaeed332b..7eaaeb03ba 100644 --- a/twilio/rest/events/v1/event_type.py +++ b/twilio/rest/events/v1/event_type.py @@ -12,7 +12,6 @@ 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 @@ -24,13 +23,14 @@ class EventTypeInstance(InstanceResource): - """ :ivar type: A string that uniquely identifies this Event Type. :ivar schema_id: A string that uniquely identifies the Schema this Event Type adheres to. :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: """ @@ -49,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") @@ -101,6 +103,7 @@ def __repr__(self) -> str: class EventTypeContext(InstanceContext): + def __init__(self, version: Version, type: str): """ Initialize the EventTypeContext @@ -124,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, @@ -143,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( @@ -165,6 +172,7 @@ def __repr__(self) -> str: class EventTypePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> EventTypeInstance: """ Build an instance of EventTypeInstance @@ -183,6 +191,7 @@ def __repr__(self) -> str: class EventTypeList(ListResource): + def __init__(self, version: Version): """ Initialize the EventTypeList @@ -334,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( @@ -364,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 5bd099d56b..2c7ffa6b28 100644 --- a/twilio/rest/events/v1/schema/__init__.py +++ b/twilio/rest/events/v1/schema/__init__.py @@ -12,10 +12,9 @@ Do not edit the class manually. """ - 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 @@ -25,7 +24,6 @@ class SchemaInstance(InstanceResource): - """ :ivar id: The unique identifier of the schema. Each schema can have multiple versions, that share the same id. :ivar url: The URL of this resource. @@ -42,9 +40,9 @@ def __init__( self.id: Optional[str] = payload.get("id") self.url: Optional[str] = payload.get("url") self.links: Optional[Dict[str, object]] = payload.get("links") - self.latest_version_date_created: Optional[ - datetime - ] = deserialize.iso8601_datetime(payload.get("latest_version_date_created")) + self.latest_version_date_created: Optional[datetime] = ( + deserialize.iso8601_datetime(payload.get("latest_version_date_created")) + ) self.latest_version: Optional[int] = deserialize.integer( payload.get("latest_version") ) @@ -105,6 +103,7 @@ def __repr__(self) -> str: class SchemaContext(InstanceContext): + def __init__(self, version: Version, id: str): """ Initialize the SchemaContext @@ -130,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, @@ -149,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( @@ -183,6 +186,7 @@ def __repr__(self) -> str: class SchemaList(ListResource): + def __init__(self, version: Version): """ Initialize the SchemaList diff --git a/twilio/rest/events/v1/schema/schema_version.py b/twilio/rest/events/v1/schema/schema_version.py index 823aefbf73..be000b9c0b 100644 --- a/twilio/rest/events/v1/schema/schema_version.py +++ b/twilio/rest/events/v1/schema/schema_version.py @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class SchemaVersionInstance(InstanceResource): - """ :ivar id: The unique identifier of the schema. Each schema can have multiple versions, that share the same id. :ivar schema_version: The version of this schema. @@ -103,6 +101,7 @@ def __repr__(self) -> str: class SchemaVersionContext(InstanceContext): + def __init__(self, version: Version, id: str, schema_version: int): """ Initialize the SchemaVersionContext @@ -128,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, @@ -148,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( @@ -171,6 +174,7 @@ def __repr__(self) -> str: class SchemaVersionPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> SchemaVersionInstance: """ Build an instance of SchemaVersionInstance @@ -189,6 +193,7 @@ def __repr__(self) -> str: class SchemaVersionList(ListResource): + def __init__(self, version: Version, id: str): """ Initialize the SchemaVersionList @@ -332,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( @@ -359,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 5a7626ad83..3771f83bbc 100644 --- a/twilio/rest/events/v1/sink/__init__.py +++ b/twilio/rest/events/v1/sink/__init__.py @@ -12,7 +12,6 @@ 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 @@ -26,10 +25,12 @@ class SinkInstance(InstanceResource): + class SinkType(object): KINESIS = "kinesis" WEBHOOK = "webhook" SEGMENT = "segment" + EMAIL = "email" class Status(object): INITIALIZED = "initialized" @@ -175,6 +176,7 @@ def __repr__(self) -> str: class SinkContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the SinkContext @@ -200,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: """ @@ -212,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: @@ -225,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, @@ -244,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( @@ -263,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"]) @@ -285,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"]) @@ -334,6 +350,7 @@ def __repr__(self) -> str: class SinkPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> SinkInstance: """ Build an instance of SinkInstance @@ -352,6 +369,7 @@ def __repr__(self) -> str: class SinkList(ListResource): + def __init__(self, version: Version): """ Initialize the SinkList @@ -378,6 +396,7 @@ def create( :returns: The created SinkInstance """ + data = values.of( { "Description": description, @@ -385,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) @@ -409,6 +431,7 @@ async def create_async( :returns: The created SinkInstance """ + data = values.of( { "Description": description, @@ -416,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) @@ -572,7 +598,7 @@ def page( """ data = values.of( { - "InUse": in_use, + "InUse": serialize.boolean_to_string(in_use), "Status": status, "PageToken": page_token, "Page": page_number, @@ -580,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( @@ -605,7 +637,7 @@ async def page_async( """ data = values.of( { - "InUse": in_use, + "InUse": serialize.boolean_to_string(in_use), "Status": status, "PageToken": page_token, "Page": page_number, @@ -613,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 c85c422e7b..566106efca 100644 --- a/twilio/rest/events/v1/sink/sink_test.py +++ b/twilio/rest/events/v1/sink/sink_test.py @@ -12,8 +12,8 @@ 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 @@ -21,7 +21,6 @@ class SinkTestInstance(InstanceResource): - """ :ivar result: Feedback indicating whether the test event was generated. """ @@ -46,6 +45,7 @@ def __repr__(self) -> str: class SinkTestList(ListResource): + def __init__(self, version: Version, sid: str): """ Initialize the SinkTestList @@ -70,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"]) @@ -85,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 8539a1ef41..53eef814c0 100644 --- a/twilio/rest/events/v1/sink/sink_validate.py +++ b/twilio/rest/events/v1/sink/sink_validate.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, Optional from twilio.base import values @@ -22,7 +21,6 @@ class SinkValidateInstance(InstanceResource): - """ :ivar result: Feedback indicating whether the given Sink was validated. """ @@ -47,6 +45,7 @@ def __repr__(self) -> str: class SinkValidateList(ListResource): + def __init__(self, version: Version, sid: str): """ Initialize the SinkValidateList @@ -71,16 +70,20 @@ def create(self, test_id: str) -> SinkValidateInstance: :returns: The created SinkValidateInstance """ + data = values.of( { "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"]) @@ -93,16 +96,20 @@ async def create_async(self, test_id: str) -> SinkValidateInstance: :returns: The created SinkValidateInstance """ + data = values.of( { "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 458177d487..872c9ed7d0 100644 --- a/twilio/rest/events/v1/subscription/__init__.py +++ b/twilio/rest/events/v1/subscription/__init__.py @@ -12,7 +12,6 @@ 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 @@ -25,7 +24,6 @@ class SubscriptionInstance(InstanceResource): - """ :ivar account_sid: The unique SID identifier of the Account. :ivar sid: A 34 character string that uniquely identifies this Subscription. @@ -165,6 +163,7 @@ def __repr__(self) -> str: class SubscriptionContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the SubscriptionContext @@ -189,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: """ @@ -201,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) -> SubscriptionInstance: @@ -214,10 +215,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, @@ -233,9 +235,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( @@ -257,17 +262,21 @@ def update( :returns: The updated SubscriptionInstance """ + data = values.of( { "Description": description, "SinkSid": sink_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 SubscriptionInstance(self._version, payload, sid=self._solution["sid"]) @@ -285,17 +294,21 @@ async def update_async( :returns: The updated SubscriptionInstance """ + data = values.of( { "Description": description, "SinkSid": sink_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 SubscriptionInstance(self._version, payload, sid=self._solution["sid"]) @@ -323,6 +336,7 @@ def __repr__(self) -> str: class SubscriptionPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> SubscriptionInstance: """ Build an instance of SubscriptionInstance @@ -341,6 +355,7 @@ def __repr__(self) -> str: class SubscriptionList(ListResource): + def __init__(self, version: Version): """ Initialize the SubscriptionList @@ -364,6 +379,7 @@ def create( :returns: The created SubscriptionInstance """ + data = values.of( { "Description": description, @@ -371,11 +387,14 @@ def create( "Types": serialize.map(types, 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, + method="POST", uri=self._uri, data=data, headers=headers ) return SubscriptionInstance(self._version, payload) @@ -392,6 +411,7 @@ async def create_async( :returns: The created SubscriptionInstance """ + data = values.of( { "Description": description, @@ -399,11 +419,14 @@ async def create_async( "Types": serialize.map(types, 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, + method="POST", uri=self._uri, data=data, headers=headers ) return SubscriptionInstance(self._version, payload) @@ -548,7 +571,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-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( @@ -578,8 +607,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/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 f45fe0b2e0..dae60ac206 100644 --- a/twilio/rest/events/v1/subscription/subscribed_event.py +++ b/twilio/rest/events/v1/subscription/subscribed_event.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import deserialize, values from twilio.base.instance_context import InstanceContext @@ -23,11 +22,10 @@ class SubscribedEventInstance(InstanceResource): - """ :ivar account_sid: The unique SID identifier of the Account. :ivar type: Type of event being subscribed to. - :ivar schema_version: The schema version that the subscription should use. + :ivar schema_version: The schema version that the Subscription should use. :ivar subscription_sid: The unique SID identifier of the Subscription. :ivar url: The URL of this resource. """ @@ -113,7 +111,7 @@ def update( """ Update the SubscribedEventInstance - :param schema_version: The schema version that the subscription should use. + :param schema_version: The schema version that the Subscription should use. :returns: The updated SubscribedEventInstance """ @@ -127,7 +125,7 @@ async def update_async( """ Asynchronous coroutine to update the SubscribedEventInstance - :param schema_version: The schema version that the subscription should use. + :param schema_version: The schema version that the Subscription should use. :returns: The updated SubscribedEventInstance """ @@ -146,6 +144,7 @@ def __repr__(self) -> str: class SubscribedEventContext(InstanceContext): + def __init__(self, version: Version, subscription_sid: str, type: str): """ Initialize the SubscribedEventContext @@ -172,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: """ @@ -184,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: @@ -197,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, @@ -217,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( @@ -235,20 +240,24 @@ def update( """ Update the SubscribedEventInstance - :param schema_version: The schema version that the subscription should use. + :param schema_version: The schema version that the Subscription should use. :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( @@ -264,20 +273,24 @@ async def update_async( """ Asynchronous coroutine to update the SubscribedEventInstance - :param schema_version: The schema version that the subscription should use. + :param schema_version: The schema version that the Subscription should use. :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( @@ -298,6 +311,7 @@ def __repr__(self) -> str: class SubscribedEventPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> SubscribedEventInstance: """ Build an instance of SubscribedEventInstance @@ -318,6 +332,7 @@ def __repr__(self) -> str: class SubscribedEventList(ListResource): + def __init__(self, version: Version, subscription_sid: str): """ Initialize the SubscribedEventList @@ -343,21 +358,25 @@ def create( Create the SubscribedEventInstance :param type: Type of event being subscribed to. - :param schema_version: The schema version that the subscription should use. + :param schema_version: The schema version that the Subscription should use. :returns: The created SubscribedEventInstance """ + data = values.of( { "Type": type, "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( @@ -371,21 +390,25 @@ async def create_async( Asynchronously create the SubscribedEventInstance :param type: Type of event being subscribed to. - :param schema_version: The schema version that the subscription should use. + :param schema_version: The schema version that the Subscription should use. :returns: The created SubscribedEventInstance """ + data = values.of( { "Type": type, "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( @@ -519,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( @@ -546,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/FlexApiBase.py b/twilio/rest/flex_api/FlexApiBase.py index afdad47340..3bda5b6b47 100644 --- a/twilio/rest/flex_api/FlexApiBase.py +++ b/twilio/rest/flex_api/FlexApiBase.py @@ -18,6 +18,7 @@ class FlexApiBase(Domain): + def __init__(self, twilio: Client): """ Initialize the FlexApi Domain diff --git a/twilio/rest/flex_api/v1/__init__.py b/twilio/rest/flex_api/v1/__init__.py index 64701c623f..eeb00227e9 100644 --- a/twilio/rest/flex_api/v1/__init__.py +++ b/twilio/rest/flex_api/v1/__init__.py @@ -40,10 +40,20 @@ ) from twilio.rest.flex_api.v1.insights_user_roles import InsightsUserRolesList from twilio.rest.flex_api.v1.interaction import InteractionList +from twilio.rest.flex_api.v1.plugin import PluginList +from twilio.rest.flex_api.v1.plugin_archive import PluginArchiveList +from twilio.rest.flex_api.v1.plugin_configuration import PluginConfigurationList +from twilio.rest.flex_api.v1.plugin_configuration_archive import ( + PluginConfigurationArchiveList, +) +from twilio.rest.flex_api.v1.plugin_release import PluginReleaseList +from twilio.rest.flex_api.v1.plugin_version_archive import PluginVersionArchiveList +from twilio.rest.flex_api.v1.provisioning_status import ProvisioningStatusList from twilio.rest.flex_api.v1.web_channel import WebChannelList class V1(Version): + def __init__(self, domain: Domain): """ Initialize the V1 version of FlexApi @@ -55,9 +65,9 @@ def __init__(self, domain: Domain): self._channel: Optional[ChannelList] = None self._configuration: Optional[ConfigurationList] = None self._flex_flow: Optional[FlexFlowList] = None - self._insights_assessments_comment: Optional[ - InsightsAssessmentsCommentList - ] = None + self._insights_assessments_comment: Optional[InsightsAssessmentsCommentList] = ( + None + ) self._insights_conversations: Optional[InsightsConversationsList] = None self._insights_questionnaires: Optional[InsightsQuestionnairesList] = None self._insights_questionnaires_category: Optional[ @@ -74,6 +84,15 @@ def __init__(self, domain: Domain): self._insights_settings_comment: Optional[InsightsSettingsCommentList] = None self._insights_user_roles: Optional[InsightsUserRolesList] = None self._interaction: Optional[InteractionList] = None + self._plugins: Optional[PluginList] = None + self._plugin_archive: Optional[PluginArchiveList] = None + self._plugin_configurations: Optional[PluginConfigurationList] = None + self._plugin_configuration_archive: Optional[PluginConfigurationArchiveList] = ( + None + ) + self._plugin_releases: Optional[PluginReleaseList] = None + self._plugin_version_archive: Optional[PluginVersionArchiveList] = None + self._provisioning_status: Optional[ProvisioningStatusList] = None self._web_channel: Optional[WebChannelList] = None @property @@ -170,6 +189,48 @@ def interaction(self) -> InteractionList: self._interaction = InteractionList(self) return self._interaction + @property + def plugins(self) -> PluginList: + if self._plugins is None: + self._plugins = PluginList(self) + return self._plugins + + @property + def plugin_archive(self) -> PluginArchiveList: + if self._plugin_archive is None: + self._plugin_archive = PluginArchiveList(self) + return self._plugin_archive + + @property + def plugin_configurations(self) -> PluginConfigurationList: + if self._plugin_configurations is None: + self._plugin_configurations = PluginConfigurationList(self) + return self._plugin_configurations + + @property + def plugin_configuration_archive(self) -> PluginConfigurationArchiveList: + if self._plugin_configuration_archive is None: + self._plugin_configuration_archive = PluginConfigurationArchiveList(self) + return self._plugin_configuration_archive + + @property + def plugin_releases(self) -> PluginReleaseList: + if self._plugin_releases is None: + self._plugin_releases = PluginReleaseList(self) + return self._plugin_releases + + @property + def plugin_version_archive(self) -> PluginVersionArchiveList: + if self._plugin_version_archive is None: + self._plugin_version_archive = PluginVersionArchiveList(self) + return self._plugin_version_archive + + @property + def provisioning_status(self) -> ProvisioningStatusList: + if self._provisioning_status is None: + self._provisioning_status = ProvisioningStatusList(self) + return self._provisioning_status + @property def web_channel(self) -> WebChannelList: if self._web_channel is None: diff --git a/twilio/rest/flex_api/v1/assessments.py b/twilio/rest/flex_api/v1/assessments.py index 71f0b61383..130514b295 100644 --- a/twilio/rest/flex_api/v1/assessments.py +++ b/twilio/rest/flex_api/v1/assessments.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import deserialize, values from twilio.base.instance_context import InstanceContext @@ -23,10 +22,9 @@ class AssessmentsInstance(InstanceResource): - """ :ivar account_sid: The unique SID identifier of the Account. - :ivar assessment_id: The unique id of the assessment + :ivar assessment_sid: The SID of the assessment :ivar offset: Offset of the conversation :ivar report: The flag indicating if this assessment is part of report :ivar weight: The weightage given to this comment @@ -45,12 +43,12 @@ def __init__( self, version: Version, payload: Dict[str, Any], - assessment_id: Optional[str] = None, + assessment_sid: Optional[str] = None, ): super().__init__(version) self.account_sid: Optional[str] = payload.get("account_sid") - self.assessment_id: Optional[str] = payload.get("assessment_id") + self.assessment_sid: Optional[str] = payload.get("assessment_sid") self.offset: Optional[float] = deserialize.decimal(payload.get("offset")) self.report: Optional[bool] = payload.get("report") self.weight: Optional[float] = deserialize.decimal(payload.get("weight")) @@ -65,7 +63,7 @@ def __init__( self.url: Optional[str] = payload.get("url") self._solution = { - "assessment_id": assessment_id or self.assessment_id, + "assessment_sid": assessment_sid or self.assessment_sid, } self._context: Optional[AssessmentsContext] = None @@ -80,7 +78,7 @@ def _proxy(self) -> "AssessmentsContext": if self._context is None: self._context = AssessmentsContext( self._version, - assessment_id=self._solution["assessment_id"], + assessment_sid=self._solution["assessment_sid"], ) return self._context @@ -89,7 +87,7 @@ def update( offset: float, answer_text: str, answer_id: str, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, ) -> "AssessmentsInstance": """ Update the AssessmentsInstance @@ -97,7 +95,7 @@ def update( :param offset: The offset of the conversation :param answer_text: The answer text selected by user :param answer_id: The id of the answer selected by user - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :returns: The updated AssessmentsInstance """ @@ -105,7 +103,7 @@ def update( offset=offset, answer_text=answer_text, answer_id=answer_id, - token=token, + authorization=authorization, ) async def update_async( @@ -113,7 +111,7 @@ async def update_async( offset: float, answer_text: str, answer_id: str, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, ) -> "AssessmentsInstance": """ Asynchronous coroutine to update the AssessmentsInstance @@ -121,7 +119,7 @@ async def update_async( :param offset: The offset of the conversation :param answer_text: The answer text selected by user :param answer_id: The id of the answer selected by user - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :returns: The updated AssessmentsInstance """ @@ -129,7 +127,7 @@ async def update_async( offset=offset, answer_text=answer_text, answer_id=answer_id, - token=token, + authorization=authorization, ) def __repr__(self) -> str: @@ -143,27 +141,30 @@ def __repr__(self) -> str: class AssessmentsContext(InstanceContext): - def __init__(self, version: Version, assessment_id: str): + + def __init__(self, version: Version, assessment_sid: str): """ Initialize the AssessmentsContext :param version: Version that contains the resource - :param assessment_id: The id of the assessment to be modified + :param assessment_sid: The SID of the assessment to be modified """ super().__init__(version) # Path Solution self._solution = { - "assessment_id": assessment_id, + "assessment_sid": assessment_sid, } - self._uri = "/Insights/QM/Assessments/{assessment_id}".format(**self._solution) + self._uri = "/Insights/QualityManagement/Assessments/{assessment_sid}".format( + **self._solution + ) def update( self, offset: float, answer_text: str, answer_id: str, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, ) -> AssessmentsInstance: """ Update the AssessmentsInstance @@ -171,10 +172,11 @@ def update( :param offset: The offset of the conversation :param answer_text: The answer text selected by user :param answer_id: The id of the answer selected by user - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :returns: The updated AssessmentsInstance """ + data = values.of( { "Offset": offset, @@ -182,18 +184,24 @@ def update( "AnswerId": answer_id, } ) - headers = values.of( - { - "Token": token, - } - ) + 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 ) return AssessmentsInstance( - self._version, payload, assessment_id=self._solution["assessment_id"] + self._version, payload, assessment_sid=self._solution["assessment_sid"] ) async def update_async( @@ -201,7 +209,7 @@ async def update_async( offset: float, answer_text: str, answer_id: str, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, ) -> AssessmentsInstance: """ Asynchronous coroutine to update the AssessmentsInstance @@ -209,10 +217,11 @@ async def update_async( :param offset: The offset of the conversation :param answer_text: The answer text selected by user :param answer_id: The id of the answer selected by user - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :returns: The updated AssessmentsInstance """ + data = values.of( { "Offset": offset, @@ -220,18 +229,24 @@ async def update_async( "AnswerId": answer_id, } ) - headers = values.of( - { - "Token": token, - } - ) + 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 ) return AssessmentsInstance( - self._version, payload, assessment_id=self._solution["assessment_id"] + self._version, payload, assessment_sid=self._solution["assessment_sid"] ) def __repr__(self) -> str: @@ -245,6 +260,7 @@ def __repr__(self) -> str: class AssessmentsPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> AssessmentsInstance: """ Build an instance of AssessmentsInstance @@ -263,6 +279,7 @@ def __repr__(self) -> str: class AssessmentsList(ListResource): + def __init__(self, version: Version): """ Initialize the AssessmentsList @@ -272,64 +289,65 @@ def __init__(self, version: Version): """ super().__init__(version) - self._uri = "/Insights/QM/Assessments" + self._uri = "/Insights/QualityManagement/Assessments" def create( self, - category_id: str, + category_sid: str, category_name: str, segment_id: str, - user_name: str, - user_email: str, agent_id: str, offset: float, metric_id: str, metric_name: str, answer_text: str, answer_id: str, - questionnaire_id: str, - token: Union[str, object] = values.unset, + questionnaire_sid: str, + authorization: Union[str, object] = values.unset, ) -> AssessmentsInstance: """ Create the AssessmentsInstance - :param category_id: The id of the category + :param category_sid: The SID of the category :param category_name: The name of the category :param segment_id: Segment Id of the conversation - :param user_name: Name of the user assessing conversation - :param user_email: Email of the user assessing conversation :param agent_id: The id of the Agent :param offset: The offset of the conversation. - :param metric_id: The question Id selected for assessment + :param metric_id: The question SID selected for assessment :param metric_name: The question name of the assessment :param answer_text: The answer text selected by user :param answer_id: The id of the answer selected by user - :param questionnaire_id: Questionnaire Id of the associated question - :param token: The Token HTTP request header + :param questionnaire_sid: Questionnaire SID of the associated question + :param authorization: The Authorization HTTP request header :returns: The created AssessmentsInstance """ + data = values.of( { - "CategoryId": category_id, + "CategorySid": category_sid, "CategoryName": category_name, "SegmentId": segment_id, - "UserName": user_name, - "UserEmail": user_email, "AgentId": agent_id, "Offset": offset, "MetricId": metric_id, "MetricName": metric_name, "AnswerText": answer_text, "AnswerId": answer_id, - "QuestionnaireId": questionnaire_id, + "QuestionnaireSid": questionnaire_sid, } ) headers = values.of( { - "Token": token, + "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 ) @@ -338,60 +356,61 @@ def create( async def create_async( self, - category_id: str, + category_sid: str, category_name: str, segment_id: str, - user_name: str, - user_email: str, agent_id: str, offset: float, metric_id: str, metric_name: str, answer_text: str, answer_id: str, - questionnaire_id: str, - token: Union[str, object] = values.unset, + questionnaire_sid: str, + authorization: Union[str, object] = values.unset, ) -> AssessmentsInstance: """ Asynchronously create the AssessmentsInstance - :param category_id: The id of the category + :param category_sid: The SID of the category :param category_name: The name of the category :param segment_id: Segment Id of the conversation - :param user_name: Name of the user assessing conversation - :param user_email: Email of the user assessing conversation :param agent_id: The id of the Agent :param offset: The offset of the conversation. - :param metric_id: The question Id selected for assessment + :param metric_id: The question SID selected for assessment :param metric_name: The question name of the assessment :param answer_text: The answer text selected by user :param answer_id: The id of the answer selected by user - :param questionnaire_id: Questionnaire Id of the associated question - :param token: The Token HTTP request header + :param questionnaire_sid: Questionnaire SID of the associated question + :param authorization: The Authorization HTTP request header :returns: The created AssessmentsInstance """ + data = values.of( { - "CategoryId": category_id, + "CategorySid": category_sid, "CategoryName": category_name, "SegmentId": segment_id, - "UserName": user_name, - "UserEmail": user_email, "AgentId": agent_id, "Offset": offset, "MetricId": metric_id, "MetricName": metric_name, "AnswerText": answer_text, "AnswerId": answer_id, - "QuestionnaireId": questionnaire_id, + "QuestionnaireSid": questionnaire_sid, } ) headers = values.of( { - "Token": token, + "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 ) @@ -400,7 +419,7 @@ async def create_async( def stream( self, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, segment_id: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, @@ -411,7 +430,7 @@ def stream( is reached. The results are returned as a generator, so this operation is memory efficient. - :param str token: The Token HTTP request header + :param str authorization: The Authorization HTTP request header :param str segment_id: The id of the segment. :param limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit @@ -424,14 +443,16 @@ def stream( """ limits = self._version.read_limits(limit, page_size) page = self.page( - token=token, segment_id=segment_id, page_size=limits["page_size"] + authorization=authorization, + segment_id=segment_id, + page_size=limits["page_size"], ) return self._version.stream(page, limits["limit"]) async def stream_async( self, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, segment_id: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, @@ -442,7 +463,7 @@ async def stream_async( is reached. The results are returned as a generator, so this operation is memory efficient. - :param str token: The Token HTTP request header + :param str authorization: The Authorization HTTP request header :param str segment_id: The id of the segment. :param limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit @@ -455,14 +476,16 @@ async def stream_async( """ limits = self._version.read_limits(limit, page_size) page = await self.page_async( - token=token, segment_id=segment_id, page_size=limits["page_size"] + authorization=authorization, + segment_id=segment_id, + page_size=limits["page_size"], ) return self._version.stream_async(page, limits["limit"]) def list( self, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, segment_id: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, @@ -472,7 +495,7 @@ def list( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param str token: The Token HTTP request header + :param str authorization: The Authorization HTTP request header :param str segment_id: The id of the segment. :param limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit @@ -485,7 +508,7 @@ def list( """ return list( self.stream( - token=token, + authorization=authorization, segment_id=segment_id, limit=limit, page_size=page_size, @@ -494,7 +517,7 @@ def list( async def list_async( self, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, segment_id: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, @@ -504,7 +527,7 @@ async def list_async( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param str token: The Token HTTP request header + :param str authorization: The Authorization HTTP request header :param str segment_id: The id of the segment. :param limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit @@ -518,7 +541,7 @@ async def list_async( return [ record async for record in await self.stream_async( - token=token, + authorization=authorization, segment_id=segment_id, limit=limit, page_size=page_size, @@ -527,7 +550,7 @@ async def list_async( def page( self, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, segment_id: Union[str, object] = values.unset, page_token: Union[str, object] = values.unset, page_number: Union[int, object] = values.unset, @@ -537,7 +560,7 @@ def page( Retrieve a single page of AssessmentsInstance records from the API. Request is executed immediately - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :param segment_id: The id of the segment. :param page_token: PageToken provided by the API :param page_number: Page Number, this value is simply for client state @@ -547,7 +570,7 @@ def page( """ data = values.of( { - "Token": token, + "Authorization": authorization, "SegmentId": segment_id, "PageToken": page_token, "Page": page_number, @@ -555,12 +578,23 @@ 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( self, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, segment_id: Union[str, object] = values.unset, page_token: Union[str, object] = values.unset, page_number: Union[int, object] = values.unset, @@ -570,7 +604,7 @@ async def page_async( Asynchronously retrieve a single page of AssessmentsInstance records from the API. Request is executed immediately - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :param segment_id: The id of the segment. :param page_token: PageToken provided by the API :param page_number: Page Number, this value is simply for client state @@ -580,7 +614,7 @@ async def page_async( """ data = values.of( { - "Token": token, + "Authorization": authorization, "SegmentId": segment_id, "PageToken": page_token, "Page": page_number, @@ -588,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) @@ -617,21 +660,21 @@ async def get_page_async(self, target_url: str) -> AssessmentsPage: response = await self._version.domain.twilio.request_async("GET", target_url) return AssessmentsPage(self._version, response) - def get(self, assessment_id: str) -> AssessmentsContext: + def get(self, assessment_sid: str) -> AssessmentsContext: """ Constructs a AssessmentsContext - :param assessment_id: The id of the assessment to be modified + :param assessment_sid: The SID of the assessment to be modified """ - return AssessmentsContext(self._version, assessment_id=assessment_id) + return AssessmentsContext(self._version, assessment_sid=assessment_sid) - def __call__(self, assessment_id: str) -> AssessmentsContext: + def __call__(self, assessment_sid: str) -> AssessmentsContext: """ Constructs a AssessmentsContext - :param assessment_id: The id of the assessment to be modified + :param assessment_sid: The SID of the assessment to be modified """ - return AssessmentsContext(self._version, assessment_id=assessment_id) + return AssessmentsContext(self._version, assessment_sid=assessment_sid) def __repr__(self) -> str: """ diff --git a/twilio/rest/flex_api/v1/channel.py b/twilio/rest/flex_api/v1/channel.py index cf2d765879..aa98ff8d31 100644 --- a/twilio/rest/flex_api/v1/channel.py +++ b/twilio/rest/flex_api/v1/channel.py @@ -12,10 +12,9 @@ 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 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 @@ -24,7 +23,6 @@ class ChannelInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Channel resource and owns this Workflow. :ivar flex_flow_sid: The SID of the Flex Flow. @@ -121,6 +119,7 @@ def __repr__(self) -> str: class ChannelContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the ChannelContext @@ -143,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: """ @@ -155,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: @@ -168,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, @@ -187,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( @@ -209,6 +214,7 @@ def __repr__(self) -> str: class ChannelPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ChannelInstance: """ Build an instance of ChannelInstance @@ -227,6 +233,7 @@ def __repr__(self) -> str: class ChannelList(ListResource): + def __init__(self, version: Version): """ Initialize the ChannelList @@ -267,6 +274,7 @@ def create( :returns: The created ChannelInstance """ + data = values.of( { "FlexFlowSid": flex_flow_sid, @@ -278,14 +286,17 @@ def create( "PreEngagementData": pre_engagement_data, "TaskSid": task_sid, "TaskAttributes": task_attributes, - "LongLived": long_lived, + "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) @@ -319,6 +330,7 @@ async def create_async( :returns: The created ChannelInstance """ + data = values.of( { "FlexFlowSid": flex_flow_sid, @@ -330,14 +342,17 @@ async def create_async( "PreEngagementData": pre_engagement_data, "TaskSid": task_sid, "TaskAttributes": task_attributes, - "LongLived": long_lived, + "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) @@ -469,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( @@ -496,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 741a4c40f8..28a66be036 100644 --- a/twilio/rest/flex_api/v1/configuration.py +++ b/twilio/rest/flex_api/v1/configuration.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import datetime from typing import Any, Dict, List, Optional, Union from twilio.base import deserialize, values @@ -23,6 +22,7 @@ class ConfigurationInstance(InstanceResource): + class Status(object): OK = "ok" INPROGRESS = "inprogress" @@ -46,6 +46,7 @@ class Status(object): :ivar messaging_service_instance_sid: The SID of the Messaging service instance. :ivar chat_service_instance_sid: The SID of the chat service this user belongs to. :ivar flex_service_instance_sid: The SID of the Flex service instance. + :ivar flex_instance_sid: The SID of the Flex instance. :ivar ui_language: The primary language of the Flex UI. :ivar ui_attributes: The object that describes Flex UI characteristics and settings. :ivar ui_dependencies: The object that defines the NPM packages and versions to be used in Hosted Flex. @@ -74,6 +75,9 @@ class Status(object): :ivar channel_configs: Settings for different limits for Flex Conversations channels attachments. :ivar debugger_integration: Configurable parameters for Debugger Integration. :ivar flex_ui_status_report: Configurable parameters for Flex UI Status report. + :ivar agent_conv_end_methods: Agent conversation end methods. + :ivar citrix_voice_vdi: Citrix voice vdi configuration and settings. + :ivar offline_config: Presence and presence ttl configuration """ def __init__(self, version: Version, payload: Dict[str, Any]): @@ -97,10 +101,10 @@ def __init__(self, version: Version, payload: Dict[str, Any]): self.taskrouter_target_taskqueue_sid: Optional[str] = payload.get( "taskrouter_target_taskqueue_sid" ) - self.taskrouter_taskqueues: Optional[List[object]] = payload.get( + self.taskrouter_taskqueues: Optional[List[Dict[str, object]]] = payload.get( "taskrouter_taskqueues" ) - self.taskrouter_skills: Optional[List[object]] = payload.get( + self.taskrouter_skills: Optional[List[Dict[str, object]]] = payload.get( "taskrouter_skills" ) self.taskrouter_worker_channels: Optional[Dict[str, object]] = payload.get( @@ -122,6 +126,7 @@ def __init__(self, version: Version, payload: Dict[str, Any]): self.flex_service_instance_sid: Optional[str] = payload.get( "flex_service_instance_sid" ) + self.flex_instance_sid: Optional[str] = payload.get("flex_instance_sid") self.ui_language: Optional[str] = payload.get("ui_language") self.ui_attributes: Optional[Dict[str, object]] = payload.get("ui_attributes") self.ui_dependencies: Optional[Dict[str, object]] = payload.get( @@ -149,7 +154,9 @@ def __init__(self, version: Version, payload: Dict[str, Any]): self.plugin_service_attributes: Optional[Dict[str, object]] = payload.get( "plugin_service_attributes" ) - self.integrations: Optional[List[object]] = payload.get("integrations") + self.integrations: Optional[List[Dict[str, object]]] = payload.get( + "integrations" + ) self.outbound_call_flows: Optional[Dict[str, object]] = payload.get( "outbound_call_flows" ) @@ -169,13 +176,22 @@ def __init__(self, version: Version, payload: Dict[str, Any]): "flex_insights_drilldown" ) self.flex_url: Optional[str] = payload.get("flex_url") - self.channel_configs: Optional[List[object]] = payload.get("channel_configs") + self.channel_configs: Optional[List[Dict[str, object]]] = payload.get( + "channel_configs" + ) self.debugger_integration: Optional[Dict[str, object]] = payload.get( "debugger_integration" ) self.flex_ui_status_report: Optional[Dict[str, object]] = payload.get( "flex_ui_status_report" ) + self.agent_conv_end_methods: Optional[Dict[str, object]] = payload.get( + "agent_conv_end_methods" + ) + self.citrix_voice_vdi: Optional[Dict[str, object]] = payload.get( + "citrix_voice_vdi" + ) + self.offline_config: Optional[Dict[str, object]] = payload.get("offline_config") self._context: Optional[ConfigurationContext] = None @@ -221,6 +237,34 @@ async def fetch_async( ui_version=ui_version, ) + def update( + self, body: Union[object, object] = values.unset + ) -> "ConfigurationInstance": + """ + Update the ConfigurationInstance + + :param body: + + :returns: The updated ConfigurationInstance + """ + return self._proxy.update( + body=body, + ) + + async def update_async( + self, body: Union[object, object] = values.unset + ) -> "ConfigurationInstance": + """ + Asynchronous coroutine to update the ConfigurationInstance + + :param body: + + :returns: The updated ConfigurationInstance + """ + return await self._proxy.update_async( + body=body, + ) + def __repr__(self) -> str: """ Provide a friendly representation @@ -232,6 +276,7 @@ def __repr__(self) -> str: class ConfigurationContext(InstanceContext): + def __init__(self, version: Version): """ Initialize the ConfigurationContext @@ -259,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, @@ -283,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( @@ -292,6 +347,54 @@ async def fetch_async( payload, ) + def update( + self, body: Union[object, object] = values.unset + ) -> ConfigurationInstance: + """ + Update the ConfigurationInstance + + :param body: + + :returns: The updated ConfigurationInstance + """ + 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 ConfigurationInstance(self._version, payload) + + async def update_async( + self, body: Union[object, object] = values.unset + ) -> ConfigurationInstance: + """ + Asynchronous coroutine to update the ConfigurationInstance + + :param body: + + :returns: The updated ConfigurationInstance + """ + 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 ConfigurationInstance(self._version, payload) + def __repr__(self) -> str: """ Provide a friendly representation @@ -303,6 +406,7 @@ def __repr__(self) -> str: class ConfigurationList(ListResource): + def __init__(self, version: Version): """ Initialize the ConfigurationList diff --git a/twilio/rest/flex_api/v1/flex_flow.py b/twilio/rest/flex_api/v1/flex_flow.py index 45402a43b6..0ae2634666 100644 --- a/twilio/rest/flex_api/v1/flex_flow.py +++ b/twilio/rest/flex_api/v1/flex_flow.py @@ -12,10 +12,9 @@ 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 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 @@ -24,6 +23,7 @@ class FlexFlowInstance(InstanceResource): + class ChannelType(object): WEB = "web" SMS = "sms" @@ -74,9 +74,9 @@ def __init__( ) self.contact_identity: Optional[str] = payload.get("contact_identity") self.enabled: Optional[bool] = payload.get("enabled") - self.integration_type: Optional[ - "FlexFlowInstance.IntegrationType" - ] = payload.get("integration_type") + self.integration_type: Optional["FlexFlowInstance.IntegrationType"] = ( + payload.get("integration_type") + ) self.integration: Optional[Dict[str, object]] = payload.get("integration") self.long_lived: Optional[bool] = payload.get("long_lived") self.janitor_enabled: Optional[bool] = payload.get("janitor_enabled") @@ -279,6 +279,7 @@ def __repr__(self) -> str: class FlexFlowContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the FlexFlowContext @@ -301,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: """ @@ -313,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: @@ -326,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, @@ -345,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( @@ -401,13 +408,14 @@ def update( :returns: The updated FlexFlowInstance """ + data = values.of( { "FriendlyName": friendly_name, "ChatServiceSid": chat_service_sid, "ChannelType": channel_type, "ContactIdentity": contact_identity, - "Enabled": enabled, + "Enabled": serialize.boolean_to_string(enabled), "IntegrationType": integration_type, "Integration.FlowSid": integration_flow_sid, "Integration.Url": integration_url, @@ -416,17 +424,22 @@ def update( "Integration.Channel": integration_channel, "Integration.Timeout": integration_timeout, "Integration.Priority": integration_priority, - "Integration.CreationOnMessage": integration_creation_on_message, - "LongLived": long_lived, - "JanitorEnabled": janitor_enabled, + "Integration.CreationOnMessage": serialize.boolean_to_string( + integration_creation_on_message + ), + "LongLived": serialize.boolean_to_string(long_lived), + "JanitorEnabled": serialize.boolean_to_string(janitor_enabled), "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"]) @@ -476,13 +489,14 @@ async def update_async( :returns: The updated FlexFlowInstance """ + data = values.of( { "FriendlyName": friendly_name, "ChatServiceSid": chat_service_sid, "ChannelType": channel_type, "ContactIdentity": contact_identity, - "Enabled": enabled, + "Enabled": serialize.boolean_to_string(enabled), "IntegrationType": integration_type, "Integration.FlowSid": integration_flow_sid, "Integration.Url": integration_url, @@ -491,17 +505,22 @@ async def update_async( "Integration.Channel": integration_channel, "Integration.Timeout": integration_timeout, "Integration.Priority": integration_priority, - "Integration.CreationOnMessage": integration_creation_on_message, - "LongLived": long_lived, - "JanitorEnabled": janitor_enabled, + "Integration.CreationOnMessage": serialize.boolean_to_string( + integration_creation_on_message + ), + "LongLived": serialize.boolean_to_string(long_lived), + "JanitorEnabled": serialize.boolean_to_string(janitor_enabled), "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"]) @@ -517,6 +536,7 @@ def __repr__(self) -> str: class FlexFlowPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> FlexFlowInstance: """ Build an instance of FlexFlowInstance @@ -535,6 +555,7 @@ def __repr__(self) -> str: class FlexFlowList(ListResource): + def __init__(self, version: Version): """ Initialize the FlexFlowList @@ -591,13 +612,14 @@ def create( :returns: The created FlexFlowInstance """ + data = values.of( { "FriendlyName": friendly_name, "ChatServiceSid": chat_service_sid, "ChannelType": channel_type, "ContactIdentity": contact_identity, - "Enabled": enabled, + "Enabled": serialize.boolean_to_string(enabled), "IntegrationType": integration_type, "Integration.FlowSid": integration_flow_sid, "Integration.Url": integration_url, @@ -606,17 +628,22 @@ def create( "Integration.Channel": integration_channel, "Integration.Timeout": integration_timeout, "Integration.Priority": integration_priority, - "Integration.CreationOnMessage": integration_creation_on_message, - "LongLived": long_lived, - "JanitorEnabled": janitor_enabled, + "Integration.CreationOnMessage": serialize.boolean_to_string( + integration_creation_on_message + ), + "LongLived": serialize.boolean_to_string(long_lived), + "JanitorEnabled": serialize.boolean_to_string(janitor_enabled), "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) @@ -666,13 +693,14 @@ async def create_async( :returns: The created FlexFlowInstance """ + data = values.of( { "FriendlyName": friendly_name, "ChatServiceSid": chat_service_sid, "ChannelType": channel_type, "ContactIdentity": contact_identity, - "Enabled": enabled, + "Enabled": serialize.boolean_to_string(enabled), "IntegrationType": integration_type, "Integration.FlowSid": integration_flow_sid, "Integration.Url": integration_url, @@ -681,17 +709,22 @@ async def create_async( "Integration.Channel": integration_channel, "Integration.Timeout": integration_timeout, "Integration.Priority": integration_priority, - "Integration.CreationOnMessage": integration_creation_on_message, - "LongLived": long_lived, - "JanitorEnabled": janitor_enabled, + "Integration.CreationOnMessage": serialize.boolean_to_string( + integration_creation_on_message + ), + "LongLived": serialize.boolean_to_string(long_lived), + "JanitorEnabled": serialize.boolean_to_string(janitor_enabled), "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) @@ -838,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( @@ -868,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 d8f339910c..2b6c79343b 100644 --- a/twilio/rest/flex_api/v1/insights_assessments_comment.py +++ b/twilio/rest/flex_api/v1/insights_assessments_comment.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import deserialize, values @@ -23,10 +22,9 @@ class InsightsAssessmentsCommentInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Flex Insights resource and owns this resource. - :ivar assessment_id: The unique ID of the assessment. + :ivar assessment_sid: The SID of the assessment. :ivar comment: The comment added for assessment. :ivar offset: The offset :ivar report: The flag indicating if this assessment is part of report @@ -43,7 +41,7 @@ def __init__(self, version: Version, payload: Dict[str, Any]): super().__init__(version) self.account_sid: Optional[str] = payload.get("account_sid") - self.assessment_id: Optional[str] = payload.get("assessment_id") + self.assessment_sid: Optional[str] = payload.get("assessment_sid") self.comment: Optional[Dict[str, object]] = payload.get("comment") self.offset: Optional[float] = deserialize.decimal(payload.get("offset")) self.report: Optional[bool] = payload.get("report") @@ -66,6 +64,7 @@ def __repr__(self) -> str: class InsightsAssessmentsCommentPage(Page): + def get_instance( self, payload: Dict[str, Any] ) -> InsightsAssessmentsCommentInstance: @@ -86,6 +85,7 @@ def __repr__(self) -> str: class InsightsAssessmentsCommentList(ListResource): + def __init__(self, version: Version): """ Initialize the InsightsAssessmentsCommentList @@ -95,7 +95,7 @@ def __init__(self, version: Version): """ super().__init__(version) - self._uri = "/Insights/QM/Assessments/Comments" + self._uri = "/Insights/QualityManagement/Assessments/Comments" def create( self, @@ -103,11 +103,9 @@ def create( category_name: str, comment: str, segment_id: str, - user_name: str, - user_email: str, agent_id: str, offset: float, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, ) -> InsightsAssessmentsCommentInstance: """ Create the InsightsAssessmentsCommentInstance @@ -116,31 +114,34 @@ def create( :param category_name: The name of the category :param comment: The Assessment comment. :param segment_id: The id of the segment. - :param user_name: The name of the user. - :param user_email: The email id of the user. :param agent_id: The id of the agent. :param offset: The offset - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :returns: The created InsightsAssessmentsCommentInstance """ + data = values.of( { "CategoryId": category_id, "CategoryName": category_name, "Comment": comment, "SegmentId": segment_id, - "UserName": user_name, - "UserEmail": user_email, "AgentId": agent_id, "Offset": offset, } ) headers = values.of( { - "Token": token, + "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 ) @@ -153,11 +154,9 @@ async def create_async( category_name: str, comment: str, segment_id: str, - user_name: str, - user_email: str, agent_id: str, offset: float, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, ) -> InsightsAssessmentsCommentInstance: """ Asynchronously create the InsightsAssessmentsCommentInstance @@ -166,31 +165,34 @@ async def create_async( :param category_name: The name of the category :param comment: The Assessment comment. :param segment_id: The id of the segment. - :param user_name: The name of the user. - :param user_email: The email id of the user. :param agent_id: The id of the agent. :param offset: The offset - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :returns: The created InsightsAssessmentsCommentInstance """ + data = values.of( { "CategoryId": category_id, "CategoryName": category_name, "Comment": comment, "SegmentId": segment_id, - "UserName": user_name, - "UserEmail": user_email, "AgentId": agent_id, "Offset": offset, } ) headers = values.of( { - "Token": token, + "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 ) @@ -199,7 +201,7 @@ async def create_async( def stream( self, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, segment_id: Union[str, object] = values.unset, agent_id: Union[str, object] = values.unset, limit: Optional[int] = None, @@ -211,7 +213,7 @@ def stream( is reached. The results are returned as a generator, so this operation is memory efficient. - :param str token: The Token HTTP request header + :param str authorization: The Authorization HTTP request header :param str segment_id: The id of the segment. :param str agent_id: The id of the agent. :param limit: Upper limit for the number of records to return. stream() @@ -225,7 +227,7 @@ def stream( """ limits = self._version.read_limits(limit, page_size) page = self.page( - token=token, + authorization=authorization, segment_id=segment_id, agent_id=agent_id, page_size=limits["page_size"], @@ -235,7 +237,7 @@ def stream( async def stream_async( self, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, segment_id: Union[str, object] = values.unset, agent_id: Union[str, object] = values.unset, limit: Optional[int] = None, @@ -247,7 +249,7 @@ async def stream_async( is reached. The results are returned as a generator, so this operation is memory efficient. - :param str token: The Token HTTP request header + :param str authorization: The Authorization HTTP request header :param str segment_id: The id of the segment. :param str agent_id: The id of the agent. :param limit: Upper limit for the number of records to return. stream() @@ -261,7 +263,7 @@ async def stream_async( """ limits = self._version.read_limits(limit, page_size) page = await self.page_async( - token=token, + authorization=authorization, segment_id=segment_id, agent_id=agent_id, page_size=limits["page_size"], @@ -271,7 +273,7 @@ async def stream_async( def list( self, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, segment_id: Union[str, object] = values.unset, agent_id: Union[str, object] = values.unset, limit: Optional[int] = None, @@ -282,7 +284,7 @@ def list( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param str token: The Token HTTP request header + :param str authorization: The Authorization HTTP request header :param str segment_id: The id of the segment. :param str agent_id: The id of the agent. :param limit: Upper limit for the number of records to return. list() guarantees @@ -296,7 +298,7 @@ def list( """ return list( self.stream( - token=token, + authorization=authorization, segment_id=segment_id, agent_id=agent_id, limit=limit, @@ -306,7 +308,7 @@ def list( async def list_async( self, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, segment_id: Union[str, object] = values.unset, agent_id: Union[str, object] = values.unset, limit: Optional[int] = None, @@ -317,7 +319,7 @@ async def list_async( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param str token: The Token HTTP request header + :param str authorization: The Authorization HTTP request header :param str segment_id: The id of the segment. :param str agent_id: The id of the agent. :param limit: Upper limit for the number of records to return. list() guarantees @@ -332,7 +334,7 @@ async def list_async( return [ record async for record in await self.stream_async( - token=token, + authorization=authorization, segment_id=segment_id, agent_id=agent_id, limit=limit, @@ -342,7 +344,7 @@ async def list_async( def page( self, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, segment_id: Union[str, object] = values.unset, agent_id: Union[str, object] = values.unset, page_token: Union[str, object] = values.unset, @@ -353,7 +355,7 @@ def page( Retrieve a single page of InsightsAssessmentsCommentInstance records from the API. Request is executed immediately - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :param segment_id: The id of the segment. :param agent_id: The id of the agent. :param page_token: PageToken provided by the API @@ -364,7 +366,7 @@ def page( """ data = values.of( { - "Token": token, + "Authorization": authorization, "SegmentId": segment_id, "AgentId": agent_id, "PageToken": page_token, @@ -373,12 +375,23 @@ 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( self, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, segment_id: Union[str, object] = values.unset, agent_id: Union[str, object] = values.unset, page_token: Union[str, object] = values.unset, @@ -389,7 +402,7 @@ async def page_async( Asynchronously retrieve a single page of InsightsAssessmentsCommentInstance records from the API. Request is executed immediately - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :param segment_id: The id of the segment. :param agent_id: The id of the agent. :param page_token: PageToken provided by the API @@ -400,7 +413,7 @@ async def page_async( """ data = values.of( { - "Token": token, + "Authorization": authorization, "SegmentId": segment_id, "AgentId": agent_id, "PageToken": page_token, @@ -409,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 aa1d806948..efdcea203e 100644 --- a/twilio/rest/flex_api/v1/insights_conversations.py +++ b/twilio/rest/flex_api/v1/insights_conversations.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import deserialize, values @@ -23,7 +22,6 @@ class InsightsConversationsInstance(InstanceResource): - """ :ivar account_id: The id of the account. :ivar conversation_id: The unique id of the conversation @@ -39,7 +37,7 @@ def __init__(self, version: Version, payload: Dict[str, Any]): self.segment_count: Optional[int] = deserialize.integer( payload.get("segment_count") ) - self.segments: Optional[List[object]] = payload.get("segments") + self.segments: Optional[List[Dict[str, object]]] = payload.get("segments") def __repr__(self) -> str: """ @@ -52,6 +50,7 @@ def __repr__(self) -> str: class InsightsConversationsPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> InsightsConversationsInstance: """ Build an instance of InsightsConversationsInstance @@ -70,6 +69,7 @@ def __repr__(self) -> str: class InsightsConversationsList(ListResource): + def __init__(self, version: Version): """ Initialize the InsightsConversationsList @@ -83,7 +83,7 @@ def __init__(self, version: Version): def stream( self, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, segment_id: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, @@ -94,7 +94,7 @@ def stream( is reached. The results are returned as a generator, so this operation is memory efficient. - :param str token: The Token HTTP request header + :param str authorization: The Authorization HTTP request header :param str segment_id: Unique Id of the segment for which conversation details needs to be fetched :param limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit @@ -107,14 +107,16 @@ def stream( """ limits = self._version.read_limits(limit, page_size) page = self.page( - token=token, segment_id=segment_id, page_size=limits["page_size"] + authorization=authorization, + segment_id=segment_id, + page_size=limits["page_size"], ) return self._version.stream(page, limits["limit"]) async def stream_async( self, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, segment_id: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, @@ -125,7 +127,7 @@ async def stream_async( is reached. The results are returned as a generator, so this operation is memory efficient. - :param str token: The Token HTTP request header + :param str authorization: The Authorization HTTP request header :param str segment_id: Unique Id of the segment for which conversation details needs to be fetched :param limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit @@ -138,14 +140,16 @@ async def stream_async( """ limits = self._version.read_limits(limit, page_size) page = await self.page_async( - token=token, segment_id=segment_id, page_size=limits["page_size"] + authorization=authorization, + segment_id=segment_id, + page_size=limits["page_size"], ) return self._version.stream_async(page, limits["limit"]) def list( self, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, segment_id: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, @@ -155,7 +159,7 @@ def list( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param str token: The Token HTTP request header + :param str authorization: The Authorization HTTP request header :param str segment_id: Unique Id of the segment for which conversation details needs to be fetched :param limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit @@ -168,7 +172,7 @@ def list( """ return list( self.stream( - token=token, + authorization=authorization, segment_id=segment_id, limit=limit, page_size=page_size, @@ -177,7 +181,7 @@ def list( async def list_async( self, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, segment_id: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, @@ -187,7 +191,7 @@ async def list_async( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param str token: The Token HTTP request header + :param str authorization: The Authorization HTTP request header :param str segment_id: Unique Id of the segment for which conversation details needs to be fetched :param limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit @@ -201,7 +205,7 @@ async def list_async( return [ record async for record in await self.stream_async( - token=token, + authorization=authorization, segment_id=segment_id, limit=limit, page_size=page_size, @@ -210,7 +214,7 @@ async def list_async( def page( self, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, segment_id: Union[str, object] = values.unset, page_token: Union[str, object] = values.unset, page_number: Union[int, object] = values.unset, @@ -220,7 +224,7 @@ def page( Retrieve a single page of InsightsConversationsInstance records from the API. Request is executed immediately - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :param segment_id: Unique Id of the segment for which conversation details needs to be fetched :param page_token: PageToken provided by the API :param page_number: Page Number, this value is simply for client state @@ -230,7 +234,7 @@ def page( """ data = values.of( { - "Token": token, + "Authorization": authorization, "SegmentId": segment_id, "PageToken": page_token, "Page": page_number, @@ -238,12 +242,23 @@ 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( self, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, segment_id: Union[str, object] = values.unset, page_token: Union[str, object] = values.unset, page_number: Union[int, object] = values.unset, @@ -253,7 +268,7 @@ async def page_async( Asynchronously retrieve a single page of InsightsConversationsInstance records from the API. Request is executed immediately - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :param segment_id: Unique Id of the segment for which conversation details needs to be fetched :param page_token: PageToken provided by the API :param page_number: Page Number, this value is simply for client state @@ -263,7 +278,7 @@ async def page_async( """ data = values.of( { - "Token": token, + "Authorization": authorization, "SegmentId": segment_id, "PageToken": page_token, "Page": page_number, @@ -271,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 b86378b2d1..d21aff8242 100644 --- a/twilio/rest/flex_api/v1/insights_questionnaires.py +++ b/twilio/rest/flex_api/v1/insights_questionnaires.py @@ -12,7 +12,6 @@ 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 @@ -23,10 +22,9 @@ class InsightsQuestionnairesInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Flex Insights resource and owns this resource. - :ivar id: The unique id of this questionnaire + :ivar questionnaire_sid: The sid of this questionnaire :ivar name: The name of this category. :ivar description: The description of this questionnaire :ivar active: The flag to enable or disable questionnaire @@ -35,20 +33,23 @@ class InsightsQuestionnairesInstance(InstanceResource): """ def __init__( - self, version: Version, payload: Dict[str, Any], id: Optional[str] = None + self, + version: Version, + payload: Dict[str, Any], + questionnaire_sid: Optional[str] = None, ): super().__init__(version) self.account_sid: Optional[str] = payload.get("account_sid") - self.id: Optional[str] = payload.get("id") + self.questionnaire_sid: Optional[str] = payload.get("questionnaire_sid") self.name: Optional[str] = payload.get("name") self.description: Optional[str] = payload.get("description") self.active: Optional[bool] = payload.get("active") - self.questions: Optional[List[object]] = payload.get("questions") + self.questions: Optional[List[Dict[str, object]]] = payload.get("questions") self.url: Optional[str] = payload.get("url") self._solution = { - "id": id or self.id, + "questionnaire_sid": questionnaire_sid or self.questionnaire_sid, } self._context: Optional[InsightsQuestionnairesContext] = None @@ -63,114 +64,116 @@ def _proxy(self) -> "InsightsQuestionnairesContext": if self._context is None: self._context = InsightsQuestionnairesContext( self._version, - id=self._solution["id"], + questionnaire_sid=self._solution["questionnaire_sid"], ) return self._context - def delete(self, token: Union[str, object] = values.unset) -> bool: + def delete(self, authorization: Union[str, object] = values.unset) -> bool: """ Deletes the InsightsQuestionnairesInstance - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :returns: True if delete succeeds, False otherwise """ return self._proxy.delete( - token=token, + authorization=authorization, ) - async def delete_async(self, token: Union[str, object] = values.unset) -> bool: + async def delete_async( + self, authorization: Union[str, object] = values.unset + ) -> bool: """ Asynchronous coroutine that deletes the InsightsQuestionnairesInstance - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :returns: True if delete succeeds, False otherwise """ return await self._proxy.delete_async( - token=token, + authorization=authorization, ) def fetch( - self, token: Union[str, object] = values.unset + self, authorization: Union[str, object] = values.unset ) -> "InsightsQuestionnairesInstance": """ Fetch the InsightsQuestionnairesInstance - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :returns: The fetched InsightsQuestionnairesInstance """ return self._proxy.fetch( - token=token, + authorization=authorization, ) async def fetch_async( - self, token: Union[str, object] = values.unset + self, authorization: Union[str, object] = values.unset ) -> "InsightsQuestionnairesInstance": """ Asynchronous coroutine to fetch the InsightsQuestionnairesInstance - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :returns: The fetched InsightsQuestionnairesInstance """ return await self._proxy.fetch_async( - token=token, + authorization=authorization, ) def update( self, active: bool, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, name: Union[str, object] = values.unset, description: Union[str, object] = values.unset, - question_ids: Union[List[str], object] = values.unset, + question_sids: Union[List[str], object] = values.unset, ) -> "InsightsQuestionnairesInstance": """ Update the InsightsQuestionnairesInstance :param active: The flag to enable or disable questionnaire - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :param name: The name of this questionnaire :param description: The description of this questionnaire - :param question_ids: The list of questions ids under a questionnaire + :param question_sids: The list of questions sids under a questionnaire :returns: The updated InsightsQuestionnairesInstance """ return self._proxy.update( active=active, - token=token, + authorization=authorization, name=name, description=description, - question_ids=question_ids, + question_sids=question_sids, ) async def update_async( self, active: bool, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, name: Union[str, object] = values.unset, description: Union[str, object] = values.unset, - question_ids: Union[List[str], object] = values.unset, + question_sids: Union[List[str], object] = values.unset, ) -> "InsightsQuestionnairesInstance": """ Asynchronous coroutine to update the InsightsQuestionnairesInstance :param active: The flag to enable or disable questionnaire - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :param name: The name of this questionnaire :param description: The description of this questionnaire - :param question_ids: The list of questions ids under a questionnaire + :param question_sids: The list of questions sids under a questionnaire :returns: The updated InsightsQuestionnairesInstance """ return await self._proxy.update_async( active=active, - token=token, + authorization=authorization, name=name, description=description, - question_ids=question_ids, + question_sids=question_sids, ) def __repr__(self) -> str: @@ -184,187 +187,226 @@ def __repr__(self) -> str: class InsightsQuestionnairesContext(InstanceContext): - def __init__(self, version: Version, id: str): + + def __init__(self, version: Version, questionnaire_sid: str): """ Initialize the InsightsQuestionnairesContext :param version: Version that contains the resource - :param id: The unique ID of the questionnaire + :param questionnaire_sid: The SID of the questionnaire """ super().__init__(version) # Path Solution self._solution = { - "id": id, + "questionnaire_sid": questionnaire_sid, } - self._uri = "/Insights/QM/Questionnaires/{id}".format(**self._solution) + self._uri = ( + "/Insights/QualityManagement/Questionnaires/{questionnaire_sid}".format( + **self._solution + ) + ) - def delete(self, token: Union[str, object] = values.unset) -> bool: + def delete(self, authorization: Union[str, object] = values.unset) -> bool: """ Deletes the InsightsQuestionnairesInstance - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :returns: True if delete succeeds, False otherwise """ headers = values.of( { - "Token": token, + "Authorization": authorization, } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) - async def delete_async(self, token: Union[str, object] = values.unset) -> bool: + async def delete_async( + self, authorization: Union[str, object] = values.unset + ) -> bool: """ Asynchronous coroutine that deletes the InsightsQuestionnairesInstance - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :returns: True if delete succeeds, False otherwise """ headers = values.of( { - "Token": token, + "Authorization": authorization, } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) def fetch( - self, token: Union[str, object] = values.unset + self, authorization: Union[str, object] = values.unset ) -> InsightsQuestionnairesInstance: """ Fetch the InsightsQuestionnairesInstance - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :returns: The fetched InsightsQuestionnairesInstance """ data = values.of( { - "Token": token, + "Authorization": authorization, } ) - 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, payload, - id=self._solution["id"], + questionnaire_sid=self._solution["questionnaire_sid"], ) async def fetch_async( - self, token: Union[str, object] = values.unset + self, authorization: Union[str, object] = values.unset ) -> InsightsQuestionnairesInstance: """ Asynchronous coroutine to fetch the InsightsQuestionnairesInstance - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :returns: The fetched InsightsQuestionnairesInstance """ data = values.of( { - "Token": token, + "Authorization": authorization, } ) + 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( self._version, payload, - id=self._solution["id"], + questionnaire_sid=self._solution["questionnaire_sid"], ) def update( self, active: bool, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, name: Union[str, object] = values.unset, description: Union[str, object] = values.unset, - question_ids: Union[List[str], object] = values.unset, + question_sids: Union[List[str], object] = values.unset, ) -> InsightsQuestionnairesInstance: """ Update the InsightsQuestionnairesInstance :param active: The flag to enable or disable questionnaire - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :param name: The name of this questionnaire :param description: The description of this questionnaire - :param question_ids: The list of questions ids under a questionnaire + :param question_sids: The list of questions sids under a questionnaire :returns: The updated InsightsQuestionnairesInstance """ + data = values.of( { - "Active": active, + "Active": serialize.boolean_to_string(active), "Name": name, "Description": description, - "QuestionIds": serialize.map(question_ids, lambda e: e), - } - ) - headers = values.of( - { - "Token": token, + "QuestionSids": serialize.map(question_sids, lambda e: e), } ) + 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 ) return InsightsQuestionnairesInstance( - self._version, payload, id=self._solution["id"] + self._version, + payload, + questionnaire_sid=self._solution["questionnaire_sid"], ) async def update_async( self, active: bool, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, name: Union[str, object] = values.unset, description: Union[str, object] = values.unset, - question_ids: Union[List[str], object] = values.unset, + question_sids: Union[List[str], object] = values.unset, ) -> InsightsQuestionnairesInstance: """ Asynchronous coroutine to update the InsightsQuestionnairesInstance :param active: The flag to enable or disable questionnaire - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :param name: The name of this questionnaire :param description: The description of this questionnaire - :param question_ids: The list of questions ids under a questionnaire + :param question_sids: The list of questions sids under a questionnaire :returns: The updated InsightsQuestionnairesInstance """ + data = values.of( { - "Active": active, + "Active": serialize.boolean_to_string(active), "Name": name, "Description": description, - "QuestionIds": serialize.map(question_ids, lambda e: e), - } - ) - headers = values.of( - { - "Token": token, + "QuestionSids": serialize.map(question_sids, lambda e: e), } ) + 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 ) return InsightsQuestionnairesInstance( - self._version, payload, id=self._solution["id"] + self._version, + payload, + questionnaire_sid=self._solution["questionnaire_sid"], ) def __repr__(self) -> str: @@ -378,6 +420,7 @@ def __repr__(self) -> str: class InsightsQuestionnairesPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> InsightsQuestionnairesInstance: """ Build an instance of InsightsQuestionnairesInstance @@ -396,6 +439,7 @@ def __repr__(self) -> str: class InsightsQuestionnairesList(ListResource): + def __init__(self, version: Version): """ Initialize the InsightsQuestionnairesList @@ -405,40 +449,47 @@ def __init__(self, version: Version): """ super().__init__(version) - self._uri = "/Insights/QM/Questionnaires" + self._uri = "/Insights/QualityManagement/Questionnaires" def create( self, name: str, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, description: Union[str, object] = values.unset, active: Union[bool, object] = values.unset, - question_ids: Union[List[str], object] = values.unset, + question_sids: Union[List[str], object] = values.unset, ) -> InsightsQuestionnairesInstance: """ Create the InsightsQuestionnairesInstance :param name: The name of this questionnaire - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :param description: The description of this questionnaire :param active: The flag to enable or disable questionnaire - :param question_ids: The list of questions ids under a questionnaire + :param question_sids: The list of questions sids under a questionnaire :returns: The created InsightsQuestionnairesInstance """ + data = values.of( { "Name": name, "Description": description, - "Active": active, - "QuestionIds": serialize.map(question_ids, lambda e: e), + "Active": serialize.boolean_to_string(active), + "QuestionSids": serialize.map(question_sids, lambda e: e), } ) headers = values.of( { - "Token": token, + "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 ) @@ -448,35 +499,42 @@ def create( async def create_async( self, name: str, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, description: Union[str, object] = values.unset, active: Union[bool, object] = values.unset, - question_ids: Union[List[str], object] = values.unset, + question_sids: Union[List[str], object] = values.unset, ) -> InsightsQuestionnairesInstance: """ Asynchronously create the InsightsQuestionnairesInstance :param name: The name of this questionnaire - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :param description: The description of this questionnaire :param active: The flag to enable or disable questionnaire - :param question_ids: The list of questions ids under a questionnaire + :param question_sids: The list of questions sids under a questionnaire :returns: The created InsightsQuestionnairesInstance """ + data = values.of( { "Name": name, "Description": description, - "Active": active, - "QuestionIds": serialize.map(question_ids, lambda e: e), + "Active": serialize.boolean_to_string(active), + "QuestionSids": serialize.map(question_sids, lambda e: e), } ) headers = values.of( { - "Token": token, + "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 ) @@ -485,7 +543,7 @@ async def create_async( def stream( self, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, include_inactive: Union[bool, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, @@ -496,7 +554,7 @@ def stream( is reached. The results are returned as a generator, so this operation is memory efficient. - :param str token: The Token HTTP request header + :param str authorization: The Authorization HTTP request header :param bool include_inactive: Flag indicating whether to include inactive questionnaires or not :param limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit @@ -509,7 +567,7 @@ def stream( """ limits = self._version.read_limits(limit, page_size) page = self.page( - token=token, + authorization=authorization, include_inactive=include_inactive, page_size=limits["page_size"], ) @@ -518,7 +576,7 @@ def stream( async def stream_async( self, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, include_inactive: Union[bool, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, @@ -529,7 +587,7 @@ async def stream_async( is reached. The results are returned as a generator, so this operation is memory efficient. - :param str token: The Token HTTP request header + :param str authorization: The Authorization HTTP request header :param bool include_inactive: Flag indicating whether to include inactive questionnaires or not :param limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit @@ -542,7 +600,7 @@ async def stream_async( """ limits = self._version.read_limits(limit, page_size) page = await self.page_async( - token=token, + authorization=authorization, include_inactive=include_inactive, page_size=limits["page_size"], ) @@ -551,7 +609,7 @@ async def stream_async( def list( self, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, include_inactive: Union[bool, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, @@ -561,7 +619,7 @@ def list( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param str token: The Token HTTP request header + :param str authorization: The Authorization HTTP request header :param bool include_inactive: Flag indicating whether to include inactive questionnaires or not :param limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit @@ -574,7 +632,7 @@ def list( """ return list( self.stream( - token=token, + authorization=authorization, include_inactive=include_inactive, limit=limit, page_size=page_size, @@ -583,7 +641,7 @@ def list( async def list_async( self, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, include_inactive: Union[bool, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, @@ -593,7 +651,7 @@ async def list_async( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param str token: The Token HTTP request header + :param str authorization: The Authorization HTTP request header :param bool include_inactive: Flag indicating whether to include inactive questionnaires or not :param limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit @@ -607,7 +665,7 @@ async def list_async( return [ record async for record in await self.stream_async( - token=token, + authorization=authorization, include_inactive=include_inactive, limit=limit, page_size=page_size, @@ -616,7 +674,7 @@ async def list_async( def page( self, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, include_inactive: Union[bool, object] = values.unset, page_token: Union[str, object] = values.unset, page_number: Union[int, object] = values.unset, @@ -626,7 +684,7 @@ def page( Retrieve a single page of InsightsQuestionnairesInstance records from the API. Request is executed immediately - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :param include_inactive: Flag indicating whether to include inactive questionnaires or not :param page_token: PageToken provided by the API :param page_number: Page Number, this value is simply for client state @@ -636,20 +694,31 @@ def page( """ data = values.of( { - "Token": token, - "IncludeInactive": include_inactive, + "Authorization": authorization, + "IncludeInactive": serialize.boolean_to_string(include_inactive), "PageToken": page_token, "Page": page_number, "PageSize": page_size, } ) - 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( self, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, include_inactive: Union[bool, object] = values.unset, page_token: Union[str, object] = values.unset, page_number: Union[int, object] = values.unset, @@ -659,7 +728,7 @@ async def page_async( Asynchronously retrieve a single page of InsightsQuestionnairesInstance records from the API. Request is executed immediately - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :param include_inactive: Flag indicating whether to include inactive questionnaires or not :param page_token: PageToken provided by the API :param page_number: Page Number, this value is simply for client state @@ -669,16 +738,25 @@ async def page_async( """ data = values.of( { - "Token": token, - "IncludeInactive": include_inactive, + "Authorization": authorization, + "IncludeInactive": serialize.boolean_to_string(include_inactive), "PageToken": page_token, "Page": page_number, "PageSize": page_size, } ) + 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) @@ -706,21 +784,25 @@ async def get_page_async(self, target_url: str) -> InsightsQuestionnairesPage: response = await self._version.domain.twilio.request_async("GET", target_url) return InsightsQuestionnairesPage(self._version, response) - def get(self, id: str) -> InsightsQuestionnairesContext: + def get(self, questionnaire_sid: str) -> InsightsQuestionnairesContext: """ Constructs a InsightsQuestionnairesContext - :param id: The unique ID of the questionnaire + :param questionnaire_sid: The SID of the questionnaire """ - return InsightsQuestionnairesContext(self._version, id=id) + return InsightsQuestionnairesContext( + self._version, questionnaire_sid=questionnaire_sid + ) - def __call__(self, id: str) -> InsightsQuestionnairesContext: + def __call__(self, questionnaire_sid: str) -> InsightsQuestionnairesContext: """ Constructs a InsightsQuestionnairesContext - :param id: The unique ID of the questionnaire + :param questionnaire_sid: The SID of the questionnaire """ - return InsightsQuestionnairesContext(self._version, id=id) + return InsightsQuestionnairesContext( + self._version, questionnaire_sid=questionnaire_sid + ) def __repr__(self) -> str: """ diff --git a/twilio/rest/flex_api/v1/insights_questionnaires_category.py b/twilio/rest/flex_api/v1/insights_questionnaires_category.py index 35dc3da2df..817a4753f9 100644 --- a/twilio/rest/flex_api/v1/insights_questionnaires_category.py +++ b/twilio/rest/flex_api/v1/insights_questionnaires_category.py @@ -12,7 +12,6 @@ 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 @@ -23,10 +22,9 @@ class InsightsQuestionnairesCategoryInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Flex Insights resource and owns this resource. - :ivar category_id: The unique ID for the category + :ivar category_sid: The SID of the category :ivar name: The name of this category. :ivar url: """ @@ -35,17 +33,17 @@ def __init__( self, version: Version, payload: Dict[str, Any], - category_id: Optional[str] = None, + category_sid: Optional[str] = None, ): super().__init__(version) self.account_sid: Optional[str] = payload.get("account_sid") - self.category_id: Optional[str] = payload.get("category_id") + self.category_sid: Optional[str] = payload.get("category_sid") self.name: Optional[str] = payload.get("name") self.url: Optional[str] = payload.get("url") self._solution = { - "category_id": category_id or self.category_id, + "category_sid": category_sid or self.category_sid, } self._context: Optional[InsightsQuestionnairesCategoryContext] = None @@ -60,64 +58,66 @@ def _proxy(self) -> "InsightsQuestionnairesCategoryContext": if self._context is None: self._context = InsightsQuestionnairesCategoryContext( self._version, - category_id=self._solution["category_id"], + category_sid=self._solution["category_sid"], ) return self._context - def delete(self, token: Union[str, object] = values.unset) -> bool: + def delete(self, authorization: Union[str, object] = values.unset) -> bool: """ Deletes the InsightsQuestionnairesCategoryInstance - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :returns: True if delete succeeds, False otherwise """ return self._proxy.delete( - token=token, + authorization=authorization, ) - async def delete_async(self, token: Union[str, object] = values.unset) -> bool: + async def delete_async( + self, authorization: Union[str, object] = values.unset + ) -> bool: """ Asynchronous coroutine that deletes the InsightsQuestionnairesCategoryInstance - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :returns: True if delete succeeds, False otherwise """ return await self._proxy.delete_async( - token=token, + authorization=authorization, ) def update( - self, name: str, token: Union[str, object] = values.unset + self, name: str, authorization: Union[str, object] = values.unset ) -> "InsightsQuestionnairesCategoryInstance": """ Update the InsightsQuestionnairesCategoryInstance :param name: The name of this category. - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :returns: The updated InsightsQuestionnairesCategoryInstance """ return self._proxy.update( name=name, - token=token, + authorization=authorization, ) async def update_async( - self, name: str, token: Union[str, object] = values.unset + self, name: str, authorization: Union[str, object] = values.unset ) -> "InsightsQuestionnairesCategoryInstance": """ Asynchronous coroutine to update the InsightsQuestionnairesCategoryInstance :param name: The name of this category. - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :returns: The updated InsightsQuestionnairesCategoryInstance """ return await self._proxy.update_async( name=name, - token=token, + authorization=authorization, ) def __repr__(self) -> str: @@ -133,113 +133,136 @@ def __repr__(self) -> str: class InsightsQuestionnairesCategoryContext(InstanceContext): - def __init__(self, version: Version, category_id: str): + + def __init__(self, version: Version, category_sid: str): """ Initialize the InsightsQuestionnairesCategoryContext :param version: Version that contains the resource - :param category_id: The ID of the category to be update + :param category_sid: The SID of the category to be updated """ super().__init__(version) # Path Solution self._solution = { - "category_id": category_id, + "category_sid": category_sid, } - self._uri = "/Insights/QM/Categories/{category_id}".format(**self._solution) + self._uri = "/Insights/QualityManagement/Categories/{category_sid}".format( + **self._solution + ) - def delete(self, token: Union[str, object] = values.unset) -> bool: + def delete(self, authorization: Union[str, object] = values.unset) -> bool: """ Deletes the InsightsQuestionnairesCategoryInstance - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :returns: True if delete succeeds, False otherwise """ headers = values.of( { - "Token": token, + "Authorization": authorization, } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) - async def delete_async(self, token: Union[str, object] = values.unset) -> bool: + async def delete_async( + self, authorization: Union[str, object] = values.unset + ) -> bool: """ Asynchronous coroutine that deletes the InsightsQuestionnairesCategoryInstance - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :returns: True if delete succeeds, False otherwise """ headers = values.of( { - "Token": token, + "Authorization": authorization, } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) def update( - self, name: str, token: Union[str, object] = values.unset + self, name: str, authorization: Union[str, object] = values.unset ) -> InsightsQuestionnairesCategoryInstance: """ Update the InsightsQuestionnairesCategoryInstance :param name: The name of this category. - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :returns: The updated InsightsQuestionnairesCategoryInstance """ + data = values.of( { "Name": name, } ) - headers = values.of( - { - "Token": token, - } - ) + 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 ) return InsightsQuestionnairesCategoryInstance( - self._version, payload, category_id=self._solution["category_id"] + self._version, payload, category_sid=self._solution["category_sid"] ) async def update_async( - self, name: str, token: Union[str, object] = values.unset + self, name: str, authorization: Union[str, object] = values.unset ) -> InsightsQuestionnairesCategoryInstance: """ Asynchronous coroutine to update the InsightsQuestionnairesCategoryInstance :param name: The name of this category. - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :returns: The updated InsightsQuestionnairesCategoryInstance """ + data = values.of( { "Name": name, } ) - headers = values.of( - { - "Token": token, - } - ) + 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 ) return InsightsQuestionnairesCategoryInstance( - self._version, payload, category_id=self._solution["category_id"] + self._version, payload, category_sid=self._solution["category_sid"] ) def __repr__(self) -> str: @@ -255,6 +278,7 @@ def __repr__(self) -> str: class InsightsQuestionnairesCategoryPage(Page): + def get_instance( self, payload: Dict[str, Any] ) -> InsightsQuestionnairesCategoryInstance: @@ -275,6 +299,7 @@ def __repr__(self) -> str: class InsightsQuestionnairesCategoryList(ListResource): + def __init__(self, version: Version): """ Initialize the InsightsQuestionnairesCategoryList @@ -284,19 +309,20 @@ def __init__(self, version: Version): """ super().__init__(version) - self._uri = "/Insights/QM/Categories" + self._uri = "/Insights/QualityManagement/Categories" def create( - self, name: str, token: Union[str, object] = values.unset + self, name: str, authorization: Union[str, object] = values.unset ) -> InsightsQuestionnairesCategoryInstance: """ Create the InsightsQuestionnairesCategoryInstance :param name: The name of this category. - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :returns: The created InsightsQuestionnairesCategoryInstance """ + data = values.of( { "Name": name, @@ -304,9 +330,15 @@ def create( ) headers = values.of( { - "Token": token, + "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 ) @@ -314,16 +346,17 @@ def create( return InsightsQuestionnairesCategoryInstance(self._version, payload) async def create_async( - self, name: str, token: Union[str, object] = values.unset + self, name: str, authorization: Union[str, object] = values.unset ) -> InsightsQuestionnairesCategoryInstance: """ Asynchronously create the InsightsQuestionnairesCategoryInstance :param name: The name of this category. - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :returns: The created InsightsQuestionnairesCategoryInstance """ + data = values.of( { "Name": name, @@ -331,9 +364,15 @@ async def create_async( ) headers = values.of( { - "Token": token, + "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 ) @@ -342,7 +381,7 @@ async def create_async( def stream( self, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, ) -> Iterator[InsightsQuestionnairesCategoryInstance]: @@ -352,7 +391,7 @@ def stream( is reached. The results are returned as a generator, so this operation is memory efficient. - :param str token: The Token HTTP request header + :param str authorization: The Authorization HTTP request header :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 @@ -363,13 +402,13 @@ def stream( :returns: Generator that will yield up to limit results """ limits = self._version.read_limits(limit, page_size) - page = self.page(token=token, page_size=limits["page_size"]) + page = self.page(authorization=authorization, page_size=limits["page_size"]) return self._version.stream(page, limits["limit"]) async def stream_async( self, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, ) -> AsyncIterator[InsightsQuestionnairesCategoryInstance]: @@ -379,7 +418,7 @@ async def stream_async( is reached. The results are returned as a generator, so this operation is memory efficient. - :param str token: The Token HTTP request header + :param str authorization: The Authorization HTTP request header :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 @@ -390,13 +429,15 @@ 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(token=token, page_size=limits["page_size"]) + page = await self.page_async( + authorization=authorization, page_size=limits["page_size"] + ) return self._version.stream_async(page, limits["limit"]) def list( self, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, ) -> List[InsightsQuestionnairesCategoryInstance]: @@ -405,7 +446,7 @@ def list( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param str token: The Token HTTP request header + :param str authorization: The Authorization HTTP request header :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 @@ -417,7 +458,7 @@ def list( """ return list( self.stream( - token=token, + authorization=authorization, limit=limit, page_size=page_size, ) @@ -425,7 +466,7 @@ def list( async def list_async( self, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, ) -> List[InsightsQuestionnairesCategoryInstance]: @@ -434,7 +475,7 @@ async def list_async( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param str token: The Token HTTP request header + :param str authorization: The Authorization HTTP request header :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 @@ -447,7 +488,7 @@ async def list_async( return [ record async for record in await self.stream_async( - token=token, + authorization=authorization, limit=limit, page_size=page_size, ) @@ -455,7 +496,7 @@ async def list_async( def page( self, - token: Union[str, object] = values.unset, + authorization: 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, @@ -464,7 +505,7 @@ def page( Retrieve a single page of InsightsQuestionnairesCategoryInstance records from the API. Request is executed immediately - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :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 @@ -473,19 +514,30 @@ def page( """ data = values.of( { - "Token": token, + "Authorization": authorization, "PageToken": page_token, "Page": page_number, "PageSize": page_size, } ) - 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( self, - token: Union[str, object] = values.unset, + authorization: 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, @@ -494,7 +546,7 @@ async def page_async( Asynchronously retrieve a single page of InsightsQuestionnairesCategoryInstance records from the API. Request is executed immediately - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :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 @@ -503,15 +555,24 @@ async def page_async( """ data = values.of( { - "Token": token, + "Authorization": authorization, "PageToken": page_token, "Page": page_number, "PageSize": page_size, } ) + 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) @@ -541,24 +602,24 @@ async def get_page_async( response = await self._version.domain.twilio.request_async("GET", target_url) return InsightsQuestionnairesCategoryPage(self._version, response) - def get(self, category_id: str) -> InsightsQuestionnairesCategoryContext: + def get(self, category_sid: str) -> InsightsQuestionnairesCategoryContext: """ Constructs a InsightsQuestionnairesCategoryContext - :param category_id: The ID of the category to be update + :param category_sid: The SID of the category to be updated """ return InsightsQuestionnairesCategoryContext( - self._version, category_id=category_id + self._version, category_sid=category_sid ) - def __call__(self, category_id: str) -> InsightsQuestionnairesCategoryContext: + def __call__(self, category_sid: str) -> InsightsQuestionnairesCategoryContext: """ Constructs a InsightsQuestionnairesCategoryContext - :param category_id: The ID of the category to be update + :param category_sid: The SID of the category to be updated """ return InsightsQuestionnairesCategoryContext( - self._version, category_id=category_id + self._version, category_sid=category_sid ) def __repr__(self) -> str: diff --git a/twilio/rest/flex_api/v1/insights_questionnaires_question.py b/twilio/rest/flex_api/v1/insights_questionnaires_question.py index a0cfe55262..33e2304599 100644 --- a/twilio/rest/flex_api/v1/insights_questionnaires_question.py +++ b/twilio/rest/flex_api/v1/insights_questionnaires_question.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import deserialize, serialize, values from twilio.base.instance_context import InstanceContext @@ -23,10 +22,9 @@ class InsightsQuestionnairesQuestionInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Flex Insights resource and owns this resource. - :ivar question_id: The unique ID of the question + :ivar question_sid: The SID of the question :ivar question: The question. :ivar description: The description for the question. :ivar category: The Category for the question. @@ -41,12 +39,12 @@ def __init__( self, version: Version, payload: Dict[str, Any], - question_id: Optional[str] = None, + question_sid: Optional[str] = None, ): super().__init__(version) self.account_sid: Optional[str] = payload.get("account_sid") - self.question_id: Optional[str] = payload.get("question_id") + self.question_sid: Optional[str] = payload.get("question_sid") self.question: Optional[str] = payload.get("question") self.description: Optional[str] = payload.get("description") self.category: Optional[Dict[str, object]] = payload.get("category") @@ -57,7 +55,7 @@ def __init__( self.url: Optional[str] = payload.get("url") self._solution = { - "question_id": question_id or self.question_id, + "question_sid": question_sid or self.question_sid, } self._context: Optional[InsightsQuestionnairesQuestionContext] = None @@ -72,39 +70,41 @@ def _proxy(self) -> "InsightsQuestionnairesQuestionContext": if self._context is None: self._context = InsightsQuestionnairesQuestionContext( self._version, - question_id=self._solution["question_id"], + question_sid=self._solution["question_sid"], ) return self._context - def delete(self, token: Union[str, object] = values.unset) -> bool: + def delete(self, authorization: Union[str, object] = values.unset) -> bool: """ Deletes the InsightsQuestionnairesQuestionInstance - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :returns: True if delete succeeds, False otherwise """ return self._proxy.delete( - token=token, + authorization=authorization, ) - async def delete_async(self, token: Union[str, object] = values.unset) -> bool: + async def delete_async( + self, authorization: Union[str, object] = values.unset + ) -> bool: """ Asynchronous coroutine that deletes the InsightsQuestionnairesQuestionInstance - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :returns: True if delete succeeds, False otherwise """ return await self._proxy.delete_async( - token=token, + authorization=authorization, ) def update( self, allow_na: bool, - token: Union[str, object] = values.unset, - category_id: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, + category_sid: Union[str, object] = values.unset, question: Union[str, object] = values.unset, description: Union[str, object] = values.unset, answer_set_id: Union[str, object] = values.unset, @@ -113,8 +113,8 @@ def update( Update the InsightsQuestionnairesQuestionInstance :param allow_na: The flag to enable for disable NA for answer. - :param token: The Token HTTP request header - :param category_id: The ID of the category + :param authorization: The Authorization HTTP request header + :param category_sid: The SID of the category :param question: The question. :param description: The description for the question. :param answer_set_id: The answer_set for the question. @@ -123,8 +123,8 @@ def update( """ return self._proxy.update( allow_na=allow_na, - token=token, - category_id=category_id, + authorization=authorization, + category_sid=category_sid, question=question, description=description, answer_set_id=answer_set_id, @@ -133,8 +133,8 @@ def update( async def update_async( self, allow_na: bool, - token: Union[str, object] = values.unset, - category_id: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, + category_sid: Union[str, object] = values.unset, question: Union[str, object] = values.unset, description: Union[str, object] = values.unset, answer_set_id: Union[str, object] = values.unset, @@ -143,8 +143,8 @@ async def update_async( Asynchronous coroutine to update the InsightsQuestionnairesQuestionInstance :param allow_na: The flag to enable for disable NA for answer. - :param token: The Token HTTP request header - :param category_id: The ID of the category + :param authorization: The Authorization HTTP request header + :param category_sid: The SID of the category :param question: The question. :param description: The description for the question. :param answer_set_id: The answer_set for the question. @@ -153,8 +153,8 @@ async def update_async( """ return await self._proxy.update_async( allow_na=allow_na, - token=token, - category_id=category_id, + authorization=authorization, + category_sid=category_sid, question=question, description=description, answer_set_id=answer_set_id, @@ -173,51 +173,60 @@ def __repr__(self) -> str: class InsightsQuestionnairesQuestionContext(InstanceContext): - def __init__(self, version: Version, question_id: str): + + def __init__(self, version: Version, question_sid: str): """ Initialize the InsightsQuestionnairesQuestionContext :param version: Version that contains the resource - :param question_id: The unique ID of the question + :param question_sid: The SID of the question """ super().__init__(version) # Path Solution self._solution = { - "question_id": question_id, + "question_sid": question_sid, } - self._uri = "/Insights/QM/Questions/{question_id}".format(**self._solution) + self._uri = "/Insights/QualityManagement/Questions/{question_sid}".format( + **self._solution + ) - def delete(self, token: Union[str, object] = values.unset) -> bool: + def delete(self, authorization: Union[str, object] = values.unset) -> bool: """ Deletes the InsightsQuestionnairesQuestionInstance - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :returns: True if delete succeeds, False otherwise """ headers = values.of( { - "Token": token, + "Authorization": authorization, } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) - async def delete_async(self, token: Union[str, object] = values.unset) -> bool: + async def delete_async( + self, authorization: Union[str, object] = values.unset + ) -> bool: """ Asynchronous coroutine that deletes the InsightsQuestionnairesQuestionInstance - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :returns: True if delete succeeds, False otherwise """ headers = values.of( { - "Token": token, + "Authorization": authorization, } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -225,8 +234,8 @@ async def delete_async(self, token: Union[str, object] = values.unset) -> bool: def update( self, allow_na: bool, - token: Union[str, object] = values.unset, - category_id: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, + category_sid: Union[str, object] = values.unset, question: Union[str, object] = values.unset, description: Union[str, object] = values.unset, answer_set_id: Union[str, object] = values.unset, @@ -235,42 +244,49 @@ def update( Update the InsightsQuestionnairesQuestionInstance :param allow_na: The flag to enable for disable NA for answer. - :param token: The Token HTTP request header - :param category_id: The ID of the category + :param authorization: The Authorization HTTP request header + :param category_sid: The SID of the category :param question: The question. :param description: The description for the question. :param answer_set_id: The answer_set for the question. :returns: The updated InsightsQuestionnairesQuestionInstance """ + data = values.of( { - "AllowNa": allow_na, - "CategoryId": category_id, + "AllowNa": serialize.boolean_to_string(allow_na), + "CategorySid": category_sid, "Question": question, "Description": description, "AnswerSetId": answer_set_id, } ) - headers = values.of( - { - "Token": token, - } - ) + 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 ) return InsightsQuestionnairesQuestionInstance( - self._version, payload, question_id=self._solution["question_id"] + self._version, payload, question_sid=self._solution["question_sid"] ) async def update_async( self, allow_na: bool, - token: Union[str, object] = values.unset, - category_id: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, + category_sid: Union[str, object] = values.unset, question: Union[str, object] = values.unset, description: Union[str, object] = values.unset, answer_set_id: Union[str, object] = values.unset, @@ -279,35 +295,42 @@ async def update_async( Asynchronous coroutine to update the InsightsQuestionnairesQuestionInstance :param allow_na: The flag to enable for disable NA for answer. - :param token: The Token HTTP request header - :param category_id: The ID of the category + :param authorization: The Authorization HTTP request header + :param category_sid: The SID of the category :param question: The question. :param description: The description for the question. :param answer_set_id: The answer_set for the question. :returns: The updated InsightsQuestionnairesQuestionInstance """ + data = values.of( { - "AllowNa": allow_na, - "CategoryId": category_id, + "AllowNa": serialize.boolean_to_string(allow_na), + "CategorySid": category_sid, "Question": question, "Description": description, "AnswerSetId": answer_set_id, } ) - headers = values.of( - { - "Token": token, - } - ) + 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 ) return InsightsQuestionnairesQuestionInstance( - self._version, payload, question_id=self._solution["question_id"] + self._version, payload, question_sid=self._solution["question_sid"] ) def __repr__(self) -> str: @@ -323,6 +346,7 @@ def __repr__(self) -> str: class InsightsQuestionnairesQuestionPage(Page): + def get_instance( self, payload: Dict[str, Any] ) -> InsightsQuestionnairesQuestionInstance: @@ -343,6 +367,7 @@ def __repr__(self) -> str: class InsightsQuestionnairesQuestionList(ListResource): + def __init__(self, version: Version): """ Initialize the InsightsQuestionnairesQuestionList @@ -352,43 +377,50 @@ def __init__(self, version: Version): """ super().__init__(version) - self._uri = "/Insights/QM/Questions" + self._uri = "/Insights/QualityManagement/Questions" def create( self, - category_id: str, + category_sid: str, question: str, answer_set_id: str, allow_na: bool, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, description: Union[str, object] = values.unset, ) -> InsightsQuestionnairesQuestionInstance: """ Create the InsightsQuestionnairesQuestionInstance - :param category_id: The ID of the category + :param category_sid: The SID of the category :param question: The question. :param answer_set_id: The answer_set for the question. :param allow_na: The flag to enable for disable NA for answer. - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :param description: The description for the question. :returns: The created InsightsQuestionnairesQuestionInstance """ + data = values.of( { - "CategoryId": category_id, + "CategorySid": category_sid, "Question": question, "AnswerSetId": answer_set_id, - "AllowNa": allow_na, + "AllowNa": serialize.boolean_to_string(allow_na), "Description": description, } ) headers = values.of( { - "Token": token, + "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 ) @@ -397,39 +429,46 @@ def create( async def create_async( self, - category_id: str, + category_sid: str, question: str, answer_set_id: str, allow_na: bool, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, description: Union[str, object] = values.unset, ) -> InsightsQuestionnairesQuestionInstance: """ Asynchronously create the InsightsQuestionnairesQuestionInstance - :param category_id: The ID of the category + :param category_sid: The SID of the category :param question: The question. :param answer_set_id: The answer_set for the question. :param allow_na: The flag to enable for disable NA for answer. - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header :param description: The description for the question. :returns: The created InsightsQuestionnairesQuestionInstance """ + data = values.of( { - "CategoryId": category_id, + "CategorySid": category_sid, "Question": question, "AnswerSetId": answer_set_id, - "AllowNa": allow_na, + "AllowNa": serialize.boolean_to_string(allow_na), "Description": description, } ) headers = values.of( { - "Token": token, + "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 ) @@ -438,8 +477,8 @@ async def create_async( def stream( self, - token: Union[str, object] = values.unset, - category_id: Union[List[str], object] = values.unset, + authorization: Union[str, object] = values.unset, + category_sid: Union[List[str], object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, ) -> Iterator[InsightsQuestionnairesQuestionInstance]: @@ -449,8 +488,8 @@ def stream( is reached. The results are returned as a generator, so this operation is memory efficient. - :param str token: The Token HTTP request header - :param List[str] category_id: The list of category IDs + :param str authorization: The Authorization HTTP request header + :param List[str] category_sid: The list of category SIDs :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 @@ -462,15 +501,17 @@ def stream( """ limits = self._version.read_limits(limit, page_size) page = self.page( - token=token, category_id=category_id, page_size=limits["page_size"] + authorization=authorization, + category_sid=category_sid, + page_size=limits["page_size"], ) return self._version.stream(page, limits["limit"]) async def stream_async( self, - token: Union[str, object] = values.unset, - category_id: Union[List[str], object] = values.unset, + authorization: Union[str, object] = values.unset, + category_sid: Union[List[str], object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, ) -> AsyncIterator[InsightsQuestionnairesQuestionInstance]: @@ -480,8 +521,8 @@ async def stream_async( is reached. The results are returned as a generator, so this operation is memory efficient. - :param str token: The Token HTTP request header - :param List[str] category_id: The list of category IDs + :param str authorization: The Authorization HTTP request header + :param List[str] category_sid: The list of category SIDs :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 @@ -493,15 +534,17 @@ async def stream_async( """ limits = self._version.read_limits(limit, page_size) page = await self.page_async( - token=token, category_id=category_id, page_size=limits["page_size"] + authorization=authorization, + category_sid=category_sid, + page_size=limits["page_size"], ) return self._version.stream_async(page, limits["limit"]) def list( self, - token: Union[str, object] = values.unset, - category_id: Union[List[str], object] = values.unset, + authorization: Union[str, object] = values.unset, + category_sid: Union[List[str], object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, ) -> List[InsightsQuestionnairesQuestionInstance]: @@ -510,8 +553,8 @@ def list( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param str token: The Token HTTP request header - :param List[str] category_id: The list of category IDs + :param str authorization: The Authorization HTTP request header + :param List[str] category_sid: The list of category SIDs :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 @@ -523,8 +566,8 @@ def list( """ return list( self.stream( - token=token, - category_id=category_id, + authorization=authorization, + category_sid=category_sid, limit=limit, page_size=page_size, ) @@ -532,8 +575,8 @@ def list( async def list_async( self, - token: Union[str, object] = values.unset, - category_id: Union[List[str], object] = values.unset, + authorization: Union[str, object] = values.unset, + category_sid: Union[List[str], object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, ) -> List[InsightsQuestionnairesQuestionInstance]: @@ -542,8 +585,8 @@ async def list_async( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param str token: The Token HTTP request header - :param List[str] category_id: The list of category IDs + :param str authorization: The Authorization HTTP request header + :param List[str] category_sid: The list of category SIDs :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 @@ -556,8 +599,8 @@ async def list_async( return [ record async for record in await self.stream_async( - token=token, - category_id=category_id, + authorization=authorization, + category_sid=category_sid, limit=limit, page_size=page_size, ) @@ -565,8 +608,8 @@ async def list_async( def page( self, - token: Union[str, object] = values.unset, - category_id: Union[List[str], object] = values.unset, + authorization: Union[str, object] = values.unset, + category_sid: 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, @@ -575,8 +618,8 @@ def page( Retrieve a single page of InsightsQuestionnairesQuestionInstance records from the API. Request is executed immediately - :param token: The Token HTTP request header - :param category_id: The list of category IDs + :param authorization: The Authorization HTTP request header + :param category_sid: The list of category SIDs :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 @@ -585,21 +628,32 @@ def page( """ data = values.of( { - "Token": token, - "CategoryId": serialize.map(category_id, lambda e: e), + "Authorization": authorization, + "CategorySid": serialize.map(category_sid, lambda e: e), "PageToken": page_token, "Page": page_number, "PageSize": page_size, } ) - 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( self, - token: Union[str, object] = values.unset, - category_id: Union[List[str], object] = values.unset, + authorization: Union[str, object] = values.unset, + category_sid: 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, @@ -608,8 +662,8 @@ async def page_async( Asynchronously retrieve a single page of InsightsQuestionnairesQuestionInstance records from the API. Request is executed immediately - :param token: The Token HTTP request header - :param category_id: The list of category IDs + :param authorization: The Authorization HTTP request header + :param category_sid: The list of category SIDs :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 @@ -618,16 +672,25 @@ async def page_async( """ data = values.of( { - "Token": token, - "CategoryId": serialize.map(category_id, lambda e: e), + "Authorization": authorization, + "CategorySid": serialize.map(category_sid, lambda e: e), "PageToken": page_token, "Page": page_number, "PageSize": page_size, } ) + 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) @@ -657,24 +720,24 @@ async def get_page_async( response = await self._version.domain.twilio.request_async("GET", target_url) return InsightsQuestionnairesQuestionPage(self._version, response) - def get(self, question_id: str) -> InsightsQuestionnairesQuestionContext: + def get(self, question_sid: str) -> InsightsQuestionnairesQuestionContext: """ Constructs a InsightsQuestionnairesQuestionContext - :param question_id: The unique ID of the question + :param question_sid: The SID of the question """ return InsightsQuestionnairesQuestionContext( - self._version, question_id=question_id + self._version, question_sid=question_sid ) - def __call__(self, question_id: str) -> InsightsQuestionnairesQuestionContext: + def __call__(self, question_sid: str) -> InsightsQuestionnairesQuestionContext: """ Constructs a InsightsQuestionnairesQuestionContext - :param question_id: The unique ID of the question + :param question_sid: The SID of the question """ return InsightsQuestionnairesQuestionContext( - self._version, question_id=question_id + self._version, question_sid=question_sid ) def __repr__(self) -> str: diff --git a/twilio/rest/flex_api/v1/insights_segments.py b/twilio/rest/flex_api/v1/insights_segments.py index 68eb689200..7c98e81cff 100644 --- a/twilio/rest/flex_api/v1/insights_segments.py +++ b/twilio/rest/flex_api/v1/insights_segments.py @@ -12,10 +12,9 @@ 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 @@ -23,7 +22,6 @@ class InsightsSegmentsInstance(InstanceResource): - """ :ivar segment_id: To unique id of the segment :ivar external_id: The unique id for the conversation. @@ -49,12 +47,7 @@ class InsightsSegmentsInstance(InstanceResource): :ivar url: """ - def __init__( - self, - version: Version, - payload: Dict[str, Any], - segment_id: Optional[str] = None, - ): + def __init__(self, version: Version, payload: Dict[str, Any]): super().__init__(version) self.segment_id: Optional[str] = payload.get("segment_id") @@ -90,143 +83,18 @@ def __init__( ) self.url: Optional[str] = payload.get("url") - self._solution = { - "segment_id": segment_id or self.segment_id, - } - self._context: Optional[InsightsSegmentsContext] = None - - @property - def _proxy(self) -> "InsightsSegmentsContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: InsightsSegmentsContext for this InsightsSegmentsInstance - """ - if self._context is None: - self._context = InsightsSegmentsContext( - self._version, - segment_id=self._solution["segment_id"], - ) - return self._context - - def fetch( - self, token: Union[str, object] = values.unset - ) -> "InsightsSegmentsInstance": - """ - Fetch the InsightsSegmentsInstance - - :param token: The Token HTTP request header - - :returns: The fetched InsightsSegmentsInstance - """ - return self._proxy.fetch( - token=token, - ) - - async def fetch_async( - self, token: Union[str, object] = values.unset - ) -> "InsightsSegmentsInstance": - """ - Asynchronous coroutine to fetch the InsightsSegmentsInstance - - :param token: The Token HTTP request header - - :returns: The fetched InsightsSegmentsInstance - """ - return await self._proxy.fetch_async( - token=token, - ) - 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 InsightsSegmentsContext(InstanceContext): - def __init__(self, version: Version, segment_id: str): - """ - Initialize the InsightsSegmentsContext - - :param version: Version that contains the resource - :param segment_id: To unique id of the segment - """ - super().__init__(version) - - # Path Solution - self._solution = { - "segment_id": segment_id, - } - self._uri = "/Insights/Segments/{segment_id}".format(**self._solution) - - def fetch( - self, token: Union[str, object] = values.unset - ) -> InsightsSegmentsInstance: - """ - Fetch the InsightsSegmentsInstance - - :param token: The Token HTTP request header - - :returns: The fetched InsightsSegmentsInstance - """ - - data = values.of( - { - "Token": token, - } - ) - - payload = self._version.fetch(method="GET", uri=self._uri, params=data) - - return InsightsSegmentsInstance( - self._version, - payload, - segment_id=self._solution["segment_id"], - ) - - async def fetch_async( - self, token: Union[str, object] = values.unset - ) -> InsightsSegmentsInstance: - """ - Asynchronous coroutine to fetch the InsightsSegmentsInstance - - :param token: The Token HTTP request header - - :returns: The fetched InsightsSegmentsInstance - """ - - data = values.of( - { - "Token": token, - } - ) - - payload = await self._version.fetch_async( - method="GET", uri=self._uri, params=data - ) - - return InsightsSegmentsInstance( - self._version, - payload, - segment_id=self._solution["segment_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) + return "" class InsightsSegmentsPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> InsightsSegmentsInstance: """ Build an instance of InsightsSegmentsInstance @@ -245,6 +113,7 @@ def __repr__(self) -> str: class InsightsSegmentsList(ListResource): + def __init__(self, version: Version): """ Initialize the InsightsSegmentsList @@ -258,7 +127,8 @@ def __init__(self, version: Version): def stream( self, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, + segment_id: Union[str, object] = values.unset, reservation_id: Union[List[str], object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, @@ -269,7 +139,8 @@ def stream( is reached. The results are returned as a generator, so this operation is memory efficient. - :param str token: The Token HTTP request header + :param str authorization: The Authorization HTTP request header + :param str segment_id: To unique id of the segment :param List[str] reservation_id: The list of reservation Ids :param limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit @@ -282,14 +153,18 @@ def stream( """ limits = self._version.read_limits(limit, page_size) page = self.page( - token=token, reservation_id=reservation_id, page_size=limits["page_size"] + authorization=authorization, + segment_id=segment_id, + reservation_id=reservation_id, + page_size=limits["page_size"], ) return self._version.stream(page, limits["limit"]) async def stream_async( self, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, + segment_id: Union[str, object] = values.unset, reservation_id: Union[List[str], object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, @@ -300,7 +175,8 @@ async def stream_async( is reached. The results are returned as a generator, so this operation is memory efficient. - :param str token: The Token HTTP request header + :param str authorization: The Authorization HTTP request header + :param str segment_id: To unique id of the segment :param List[str] reservation_id: The list of reservation Ids :param limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit @@ -313,14 +189,18 @@ async def stream_async( """ limits = self._version.read_limits(limit, page_size) page = await self.page_async( - token=token, reservation_id=reservation_id, page_size=limits["page_size"] + authorization=authorization, + segment_id=segment_id, + reservation_id=reservation_id, + page_size=limits["page_size"], ) return self._version.stream_async(page, limits["limit"]) def list( self, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, + segment_id: Union[str, object] = values.unset, reservation_id: Union[List[str], object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, @@ -330,7 +210,8 @@ def list( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param str token: The Token HTTP request header + :param str authorization: The Authorization HTTP request header + :param str segment_id: To unique id of the segment :param List[str] reservation_id: The list of reservation Ids :param limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit @@ -343,7 +224,8 @@ def list( """ return list( self.stream( - token=token, + authorization=authorization, + segment_id=segment_id, reservation_id=reservation_id, limit=limit, page_size=page_size, @@ -352,7 +234,8 @@ def list( async def list_async( self, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, + segment_id: Union[str, object] = values.unset, reservation_id: Union[List[str], object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, @@ -362,7 +245,8 @@ async def list_async( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param str token: The Token HTTP request header + :param str authorization: The Authorization HTTP request header + :param str segment_id: To unique id of the segment :param List[str] reservation_id: The list of reservation Ids :param limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit @@ -376,7 +260,8 @@ async def list_async( return [ record async for record in await self.stream_async( - token=token, + authorization=authorization, + segment_id=segment_id, reservation_id=reservation_id, limit=limit, page_size=page_size, @@ -385,7 +270,8 @@ async def list_async( def page( self, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, + segment_id: Union[str, object] = values.unset, reservation_id: Union[List[str], object] = values.unset, page_token: Union[str, object] = values.unset, page_number: Union[int, object] = values.unset, @@ -395,7 +281,8 @@ def page( Retrieve a single page of InsightsSegmentsInstance records from the API. Request is executed immediately - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header + :param segment_id: To unique id of the segment :param reservation_id: The list of reservation Ids :param page_token: PageToken provided by the API :param page_number: Page Number, this value is simply for client state @@ -405,7 +292,8 @@ def page( """ data = values.of( { - "Token": token, + "Authorization": authorization, + "SegmentId": segment_id, "ReservationId": serialize.map(reservation_id, lambda e: e), "PageToken": page_token, "Page": page_number, @@ -413,12 +301,24 @@ 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( self, - token: Union[str, object] = values.unset, + authorization: Union[str, object] = values.unset, + segment_id: Union[str, object] = values.unset, reservation_id: Union[List[str], object] = values.unset, page_token: Union[str, object] = values.unset, page_number: Union[int, object] = values.unset, @@ -428,7 +328,8 @@ async def page_async( Asynchronously retrieve a single page of InsightsSegmentsInstance records from the API. Request is executed immediately - :param token: The Token HTTP request header + :param authorization: The Authorization HTTP request header + :param segment_id: To unique id of the segment :param reservation_id: The list of reservation Ids :param page_token: PageToken provided by the API :param page_number: Page Number, this value is simply for client state @@ -438,7 +339,8 @@ async def page_async( """ data = values.of( { - "Token": token, + "Authorization": authorization, + "SegmentId": segment_id, "ReservationId": serialize.map(reservation_id, lambda e: e), "PageToken": page_token, "Page": page_number, @@ -446,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) @@ -475,22 +386,6 @@ async def get_page_async(self, target_url: str) -> InsightsSegmentsPage: response = await self._version.domain.twilio.request_async("GET", target_url) return InsightsSegmentsPage(self._version, response) - def get(self, segment_id: str) -> InsightsSegmentsContext: - """ - Constructs a InsightsSegmentsContext - - :param segment_id: To unique id of the segment - """ - return InsightsSegmentsContext(self._version, segment_id=segment_id) - - def __call__(self, segment_id: str) -> InsightsSegmentsContext: - """ - Constructs a InsightsSegmentsContext - - :param segment_id: To unique id of the segment - """ - return InsightsSegmentsContext(self._version, segment_id=segment_id) - def __repr__(self) -> str: """ Provide a friendly representation diff --git a/twilio/rest/flex_api/v1/insights_session.py b/twilio/rest/flex_api/v1/insights_session.py index d0b889822e..b4174aa949 100644 --- a/twilio/rest/flex_api/v1/insights_session.py +++ b/twilio/rest/flex_api/v1/insights_session.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, Optional, Union from twilio.base import values from twilio.base.instance_context import InstanceContext @@ -22,7 +21,6 @@ class InsightsSessionInstance(InstanceResource): - """ :ivar workspace_id: Unique ID to identify the user's workspace :ivar session_expiry: The session expiry date and time, given in ISO 8601 format. @@ -95,6 +93,7 @@ def __repr__(self) -> str: class InsightsSessionContext(InstanceContext): + def __init__(self, version: Version): """ Initialize the InsightsSessionContext @@ -158,6 +157,7 @@ def __repr__(self) -> str: class InsightsSessionList(ListResource): + def __init__(self, version: Version): """ Initialize the InsightsSessionList 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 f93fc0db62..9b0e89e938 100644 --- a/twilio/rest/flex_api/v1/insights_settings_answer_sets.py +++ b/twilio/rest/flex_api/v1/insights_settings_answer_sets.py @@ -12,8 +12,8 @@ Do not edit the class manually. """ - -from typing import Any, Dict, Optional +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 @@ -21,7 +21,6 @@ class InsightsSettingsAnswerSetsInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Flex Insights resource and owns this resource. :ivar answer_sets: The lis of answer sets @@ -52,6 +51,7 @@ def __repr__(self) -> str: class InsightsSettingsAnswerSetsList(ListResource): + def __init__(self, version: Version): """ Initialize the InsightsSettingsAnswerSetsList @@ -61,25 +61,51 @@ def __init__(self, version: Version): """ super().__init__(version) - self._uri = "/Insights/QM/Settings/AnswerSets" + self._uri = "/Insights/QualityManagement/Settings/AnswerSets" - def fetch(self) -> InsightsSettingsAnswerSetsInstance: + def fetch( + self, authorization: Union[str, object] = values.unset + ) -> InsightsSettingsAnswerSetsInstance: """ Asynchronously fetch the InsightsSettingsAnswerSetsInstance + :param authorization: The Authorization HTTP request header :returns: The fetched InsightsSettingsAnswerSetsInstance """ - payload = self._version.fetch(method="GET", uri=self._uri) + 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) - async def fetch_async(self) -> InsightsSettingsAnswerSetsInstance: + async def fetch_async( + self, authorization: Union[str, object] = values.unset + ) -> InsightsSettingsAnswerSetsInstance: """ Asynchronously fetch the InsightsSettingsAnswerSetsInstance + :param authorization: The Authorization HTTP request header :returns: The fetched InsightsSettingsAnswerSetsInstance """ - payload = await self._version.fetch_async(method="GET", uri=self._uri) + 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 + ) return InsightsSettingsAnswerSetsInstance(self._version, payload) diff --git a/twilio/rest/flex_api/v1/insights_settings_comment.py b/twilio/rest/flex_api/v1/insights_settings_comment.py index 4d848ce980..18733a4957 100644 --- a/twilio/rest/flex_api/v1/insights_settings_comment.py +++ b/twilio/rest/flex_api/v1/insights_settings_comment.py @@ -12,8 +12,8 @@ Do not edit the class manually. """ - -from typing import Any, Dict, Optional +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 @@ -21,7 +21,6 @@ class InsightsSettingsCommentInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Flex Insights resource and owns this resource. :ivar comments: @@ -46,6 +45,7 @@ def __repr__(self) -> str: class InsightsSettingsCommentList(ListResource): + def __init__(self, version: Version): """ Initialize the InsightsSettingsCommentList @@ -55,25 +55,51 @@ def __init__(self, version: Version): """ super().__init__(version) - self._uri = "/Insights/QM/Settings/CommentTags" + self._uri = "/Insights/QualityManagement/Settings/CommentTags" - def fetch(self) -> InsightsSettingsCommentInstance: + def fetch( + self, authorization: Union[str, object] = values.unset + ) -> InsightsSettingsCommentInstance: """ Asynchronously fetch the InsightsSettingsCommentInstance + :param authorization: The Authorization HTTP request header :returns: The fetched InsightsSettingsCommentInstance """ - payload = self._version.fetch(method="GET", uri=self._uri) + 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) - async def fetch_async(self) -> InsightsSettingsCommentInstance: + async def fetch_async( + self, authorization: Union[str, object] = values.unset + ) -> InsightsSettingsCommentInstance: """ Asynchronously fetch the InsightsSettingsCommentInstance + :param authorization: The Authorization HTTP request header :returns: The fetched InsightsSettingsCommentInstance """ - payload = await self._version.fetch_async(method="GET", uri=self._uri) + 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 + ) return InsightsSettingsCommentInstance(self._version, payload) diff --git a/twilio/rest/flex_api/v1/insights_user_roles.py b/twilio/rest/flex_api/v1/insights_user_roles.py index 25d406bcb2..19cb10b8e4 100644 --- a/twilio/rest/flex_api/v1/insights_user_roles.py +++ b/twilio/rest/flex_api/v1/insights_user_roles.py @@ -12,7 +12,6 @@ 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 @@ -22,7 +21,6 @@ class InsightsUserRolesInstance(InstanceResource): - """ :ivar roles: Flex Insights roles for the user :ivar url: @@ -89,6 +87,7 @@ def __repr__(self) -> str: class InsightsUserRolesContext(InstanceContext): + def __init__(self, version: Version): """ Initialize the InsightsUserRolesContext @@ -116,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, @@ -140,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( @@ -160,6 +169,7 @@ def __repr__(self) -> str: class InsightsUserRolesList(ListResource): + def __init__(self, version: Version): """ Initialize the InsightsUserRolesList diff --git a/twilio/rest/flex_api/v1/interaction/__init__.py b/twilio/rest/flex_api/v1/interaction/__init__.py index 852b29c5e5..653938f28d 100644 --- a/twilio/rest/flex_api/v1/interaction/__init__.py +++ b/twilio/rest/flex_api/v1/interaction/__init__.py @@ -12,8 +12,7 @@ Do not edit the class manually. """ - -from typing import Any, Dict, Optional +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 @@ -26,13 +25,14 @@ class InteractionInstance(InstanceResource): - """ :ivar sid: The unique string created by Twilio to identify an Interaction resource, prefixed with KD. :ivar channel: A JSON object that defines the Interaction’s communication channel and includes details about the channel. See the [Outbound SMS](https://www.twilio.com/docs/flex/developer/conversations/interactions-api/interactions#agent-initiated-outbound-interactions) and [inbound (API-initiated)](https://www.twilio.com/docs/flex/developer/conversations/interactions-api/interactions#api-initiated-contact) Channel object examples. :ivar routing: A JSON Object representing the routing rules for the Interaction Channel. See [Outbound SMS Example](https://www.twilio.com/docs/flex/developer/conversations/interactions-api/interactions#agent-initiated-outbound-interactions) for an example Routing object. The Interactions resource uses TaskRouter for all routing functionality. All attributes in the Routing object on your Interaction request body are added “as is” to the task. For a list of known attributes consumed by the Flex UI and/or Flex Insights, see [Known Task Attributes](https://www.twilio.com/docs/flex/developer/conversations/interactions-api#task-attributes). :ivar url: :ivar links: + :ivar interaction_context_sid: + :ivar webhook_ttid: """ def __init__( @@ -45,6 +45,10 @@ def __init__( self.routing: Optional[Dict[str, object]] = payload.get("routing") self.url: Optional[str] = payload.get("url") self.links: Optional[Dict[str, object]] = payload.get("links") + 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, @@ -84,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: """ @@ -102,6 +134,7 @@ def __repr__(self) -> str: class InteractionContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the InteractionContext @@ -127,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, @@ -146,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( @@ -157,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: """ @@ -180,6 +273,7 @@ def __repr__(self) -> str: class InteractionList(ListResource): + def __init__(self, version: Version): """ Initialize the InteractionList @@ -191,52 +285,78 @@ def __init__(self, version: Version): self._uri = "/Interactions" - def create(self, channel: object, routing: object) -> InteractionInstance: + def create( + self, + channel: 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 :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 """ + data = values.of( { "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) async def create_async( - self, channel: object, routing: object + self, + channel: 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 :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 """ + data = values.of( { "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 939e587cf7..b029104c8d 100644 --- a/twilio/rest/flex_api/v1/interaction/interaction_channel/__init__.py +++ b/twilio/rest/flex_api/v1/interaction/interaction_channel/__init__.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import deserialize, serialize, values from twilio.base.instance_context import InstanceContext @@ -26,18 +25,19 @@ 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): + class ChannelStatus(object): SETUP = "setup" ACTIVE = "active" FAILED = "failed" CLOSED = "closed" - - class Status(object): - CLOSED = "closed" - WRAPUP = "wrapup" + INACTIVE = "inactive" class Type(object): VOICE = "voice" @@ -49,6 +49,10 @@ class Type(object): MESSENGER = "messenger" GBM = "gbm" + class UpdateChannelStatus(object): + CLOSED = "closed" + INACTIVE = "inactive" + """ :ivar sid: The unique string created by Twilio to identify an Interaction Channel resource, prefixed with UO. :ivar interaction_sid: The unique string created by Twilio to identify an Interaction resource, prefixed with KD. @@ -122,14 +126,14 @@ async def fetch_async(self) -> "InteractionChannelInstance": def update( self, - status: "InteractionChannelInstance.Status", + status: "InteractionChannelInstance.UpdateChannelStatus", routing: Union[object, object] = values.unset, ) -> "InteractionChannelInstance": """ Update the InteractionChannelInstance :param status: - :param routing: Optional. The state of associated tasks. If not specified, all tasks will be set to `wrapping`. + :param routing: It changes the state of associated tasks. Routing status is required, When the channel status is set to `inactive`. Allowed Value for routing status is `closed`. Otherwise Optional, if not specified, all tasks will be set to `wrapping`. :returns: The updated InteractionChannelInstance """ @@ -140,14 +144,14 @@ def update( async def update_async( self, - status: "InteractionChannelInstance.Status", + status: "InteractionChannelInstance.UpdateChannelStatus", routing: Union[object, object] = values.unset, ) -> "InteractionChannelInstance": """ Asynchronous coroutine to update the InteractionChannelInstance :param status: - :param routing: Optional. The state of associated tasks. If not specified, all tasks will be set to `wrapping`. + :param routing: It changes the state of associated tasks. Routing status is required, When the channel status is set to `inactive`. Allowed Value for routing status is `closed`. Otherwise Optional, if not specified, all tasks will be set to `wrapping`. :returns: The updated InteractionChannelInstance """ @@ -170,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 @@ -181,6 +192,7 @@ def __repr__(self) -> str: class InteractionChannelContext(InstanceContext): + def __init__(self, version: Version, interaction_sid: str, sid: str): """ Initialize the InteractionChannelContext @@ -202,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: """ @@ -211,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, @@ -231,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( @@ -245,28 +262,32 @@ async def fetch_async(self) -> InteractionChannelInstance: def update( self, - status: "InteractionChannelInstance.Status", + status: "InteractionChannelInstance.UpdateChannelStatus", routing: Union[object, object] = values.unset, ) -> InteractionChannelInstance: """ Update the InteractionChannelInstance :param status: - :param routing: Optional. The state of associated tasks. If not specified, all tasks will be set to `wrapping`. + :param routing: It changes the state of associated tasks. Routing status is required, When the channel status is set to `inactive`. Allowed Value for routing status is `closed`. Otherwise Optional, if not specified, all tasks will be set to `wrapping`. :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( @@ -278,28 +299,32 @@ def update( async def update_async( self, - status: "InteractionChannelInstance.Status", + status: "InteractionChannelInstance.UpdateChannelStatus", routing: Union[object, object] = values.unset, ) -> InteractionChannelInstance: """ Asynchronous coroutine to update the InteractionChannelInstance :param status: - :param routing: Optional. The state of associated tasks. If not specified, all tasks will be set to `wrapping`. + :param routing: It changes the state of associated tasks. Routing status is required, When the channel status is set to `inactive`. Allowed Value for routing status is `closed`. Otherwise Optional, if not specified, all tasks will be set to `wrapping`. :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( @@ -335,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 @@ -346,6 +384,7 @@ def __repr__(self) -> str: class InteractionChannelPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> InteractionChannelInstance: """ Build an instance of InteractionChannelInstance @@ -366,6 +405,7 @@ def __repr__(self) -> str: class InteractionChannelList(ListResource): + def __init__(self, version: Version, interaction_sid: str): """ Initialize the InteractionChannelList @@ -509,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( @@ -536,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 b585176ec9..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 @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import serialize, values @@ -23,7 +22,6 @@ class InteractionChannelInviteInstance(InstanceResource): - """ :ivar sid: The unique string created by Twilio to identify an Interaction Channel Invite resource. :ivar interaction_sid: The Interaction SID for this Channel. @@ -63,6 +61,7 @@ def __repr__(self) -> str: class InteractionChannelInvitePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> InteractionChannelInviteInstance: """ Build an instance of InteractionChannelInviteInstance @@ -86,6 +85,7 @@ def __repr__(self) -> str: class InteractionChannelInviteList(ListResource): + def __init__(self, version: Version, interaction_sid: str, channel_sid: str): """ Initialize the InteractionChannelInviteList @@ -116,16 +116,20 @@ def create(self, routing: object) -> InteractionChannelInviteInstance: :returns: The created InteractionChannelInviteInstance """ + data = values.of( { "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( @@ -143,16 +147,20 @@ async def create_async(self, routing: object) -> InteractionChannelInviteInstanc :returns: The created InteractionChannelInviteInstance """ + data = values.of( { "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( @@ -289,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( @@ -316,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 761516f9fa..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 @@ -12,7 +12,6 @@ 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 @@ -23,6 +22,7 @@ class InteractionChannelParticipantInstance(InstanceResource): + class Status(object): CLOSED = "closed" WRAPUP = "wrapup" @@ -40,6 +40,7 @@ class Type(object): :ivar interaction_sid: The Interaction Sid for this channel. :ivar channel_sid: The Channel Sid for this Participant. :ivar url: + :ivar routing_properties: The Participant's routing properties. """ def __init__( @@ -59,6 +60,9 @@ def __init__( self.interaction_sid: Optional[str] = payload.get("interaction_sid") self.channel_sid: Optional[str] = payload.get("channel_sid") self.url: Optional[str] = payload.get("url") + self.routing_properties: Optional[Dict[str, object]] = payload.get( + "routing_properties" + ) self._solution = { "interaction_sid": interaction_sid, @@ -125,6 +129,7 @@ def __repr__(self) -> str: class InteractionChannelParticipantContext(InstanceContext): + def __init__( self, version: Version, interaction_sid: str, channel_sid: str, sid: str ): @@ -158,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( @@ -188,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( @@ -221,6 +234,7 @@ def __repr__(self) -> str: class InteractionChannelParticipantPage(Page): + def get_instance( self, payload: Dict[str, Any] ) -> InteractionChannelParticipantInstance: @@ -246,6 +260,7 @@ def __repr__(self) -> str: class InteractionChannelParticipantList(ListResource): + def __init__(self, version: Version, interaction_sid: str, channel_sid: str): """ Initialize the InteractionChannelParticipantList @@ -270,26 +285,33 @@ def create( self, type: "InteractionChannelParticipantInstance.Type", media_properties: object, + routing_properties: Union[object, object] = values.unset, ) -> InteractionChannelParticipantInstance: """ Create the InteractionChannelParticipantInstance :param type: :param media_properties: JSON representing the Media Properties for the new Participant. + :param routing_properties: Object representing the Routing Properties for the new Participant. :returns: The created InteractionChannelParticipantInstance """ + data = values.of( { "Type": type, "MediaProperties": serialize.object(media_properties), + "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( @@ -303,26 +325,33 @@ async def create_async( self, type: "InteractionChannelParticipantInstance.Type", media_properties: object, + routing_properties: Union[object, object] = values.unset, ) -> InteractionChannelParticipantInstance: """ Asynchronously create the InteractionChannelParticipantInstance :param type: :param media_properties: JSON representing the Media Properties for the new Participant. + :param routing_properties: Object representing the Routing Properties for the new Participant. :returns: The created InteractionChannelParticipantInstance """ + data = values.of( { "Type": type, "MediaProperties": serialize.object(media_properties), + "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( @@ -459,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 ) @@ -488,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 new file mode 100644 index 0000000000..2415c42710 --- /dev/null +++ b/twilio/rest/flex_api/v1/plugin/__init__.py @@ -0,0 +1,707 @@ +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, 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.flex_api.v1.plugin.plugin_versions import PluginVersionsList + + +class PluginInstance(InstanceResource): + """ + :ivar sid: The unique string that we created to identify the Flex Plugin resource. + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Flex Plugin resource and owns this resource. + :ivar unique_name: The name that uniquely identifies this Flex Plugin resource. + :ivar friendly_name: The friendly name this Flex Plugin resource. + :ivar description: A descriptive string that you create to describe the plugin resource. It can be up to 500 characters long + :ivar archived: Whether the Flex Plugin is archived. The default value is false. + :ivar date_created: The date and time in GMT-7 when the Flex Plugin was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + :ivar date_updated: The date and time in GMT-7 when the Flex Plugin was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + :ivar url: The absolute URL of the Flex Plugin resource. + :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.unique_name: Optional[str] = payload.get("unique_name") + self.friendly_name: Optional[str] = payload.get("friendly_name") + self.description: Optional[str] = payload.get("description") + self.archived: Optional[bool] = payload.get("archived") + 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[PluginContext] = None + + @property + def _proxy(self) -> "PluginContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: PluginContext for this PluginInstance + """ + if self._context is None: + self._context = PluginContext( + self._version, + sid=self._solution["sid"], + ) + return self._context + + def fetch( + self, flex_metadata: Union[str, object] = values.unset + ) -> "PluginInstance": + """ + Fetch the PluginInstance + + :param flex_metadata: The Flex-Metadata HTTP request header + + :returns: The fetched PluginInstance + """ + return self._proxy.fetch( + flex_metadata=flex_metadata, + ) + + async def fetch_async( + self, flex_metadata: Union[str, object] = values.unset + ) -> "PluginInstance": + """ + Asynchronous coroutine to fetch the PluginInstance + + :param flex_metadata: The Flex-Metadata HTTP request header + + :returns: The fetched PluginInstance + """ + return await self._proxy.fetch_async( + flex_metadata=flex_metadata, + ) + + def update( + self, + flex_metadata: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + description: Union[str, object] = values.unset, + ) -> "PluginInstance": + """ + Update the PluginInstance + + :param flex_metadata: The Flex-Metadata HTTP request header + :param friendly_name: The Flex Plugin's friendly name. + :param description: A descriptive string that you update to describe the plugin resource. It can be up to 500 characters long + + :returns: The updated PluginInstance + """ + return self._proxy.update( + flex_metadata=flex_metadata, + friendly_name=friendly_name, + description=description, + ) + + async def update_async( + self, + flex_metadata: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + description: Union[str, object] = values.unset, + ) -> "PluginInstance": + """ + Asynchronous coroutine to update the PluginInstance + + :param flex_metadata: The Flex-Metadata HTTP request header + :param friendly_name: The Flex Plugin's friendly name. + :param description: A descriptive string that you update to describe the plugin resource. It can be up to 500 characters long + + :returns: The updated PluginInstance + """ + return await self._proxy.update_async( + flex_metadata=flex_metadata, + friendly_name=friendly_name, + description=description, + ) + + @property + def plugin_versions(self) -> PluginVersionsList: + """ + Access the plugin_versions + """ + return self._proxy.plugin_versions + + 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 PluginContext(InstanceContext): + + def __init__(self, version: Version, sid: str): + """ + Initialize the PluginContext + + :param version: Version that contains the resource + :param sid: The SID of the Flex Plugin resource to update. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "sid": sid, + } + self._uri = "/PluginService/Plugins/{sid}".format(**self._solution) + + self._plugin_versions: Optional[PluginVersionsList] = None + + def fetch(self, flex_metadata: Union[str, object] = values.unset) -> PluginInstance: + """ + Fetch the PluginInstance + + :param flex_metadata: The Flex-Metadata HTTP request header + + :returns: The fetched PluginInstance + """ + + data = values.of( + { + "Flex-Metadata": flex_metadata, + } + ) + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) + + return PluginInstance( + self._version, + payload, + sid=self._solution["sid"], + ) + + async def fetch_async( + self, flex_metadata: Union[str, object] = values.unset + ) -> PluginInstance: + """ + Asynchronous coroutine to fetch the PluginInstance + + :param flex_metadata: The Flex-Metadata HTTP request header + + :returns: The fetched PluginInstance + """ + + data = values.of( + { + "Flex-Metadata": flex_metadata, + } + ) + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + + return PluginInstance( + self._version, + payload, + sid=self._solution["sid"], + ) + + def update( + self, + flex_metadata: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + description: Union[str, object] = values.unset, + ) -> PluginInstance: + """ + Update the PluginInstance + + :param flex_metadata: The Flex-Metadata HTTP request header + :param friendly_name: The Flex Plugin's friendly name. + :param description: A descriptive string that you update to describe the plugin resource. It can be up to 500 characters long + + :returns: The updated PluginInstance + """ + + data = values.of( + { + "FriendlyName": friendly_name, + "Description": description, + } + ) + 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 + ) + + return PluginInstance(self._version, payload, sid=self._solution["sid"]) + + async def update_async( + self, + flex_metadata: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + description: Union[str, object] = values.unset, + ) -> PluginInstance: + """ + Asynchronous coroutine to update the PluginInstance + + :param flex_metadata: The Flex-Metadata HTTP request header + :param friendly_name: The Flex Plugin's friendly name. + :param description: A descriptive string that you update to describe the plugin resource. It can be up to 500 characters long + + :returns: The updated PluginInstance + """ + + data = values.of( + { + "FriendlyName": friendly_name, + "Description": description, + } + ) + 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 + ) + + return PluginInstance(self._version, payload, sid=self._solution["sid"]) + + @property + def plugin_versions(self) -> PluginVersionsList: + """ + Access the plugin_versions + """ + if self._plugin_versions is None: + self._plugin_versions = PluginVersionsList( + self._version, + self._solution["sid"], + ) + return self._plugin_versions + + 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 PluginPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> PluginInstance: + """ + Build an instance of PluginInstance + + :param payload: Payload response from the API + """ + return PluginInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class PluginList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the PluginList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/PluginService/Plugins" + + def create( + self, + unique_name: str, + flex_metadata: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + description: Union[str, object] = values.unset, + ) -> PluginInstance: + """ + Create the PluginInstance + + :param unique_name: The Flex Plugin's unique name. + :param flex_metadata: The Flex-Metadata HTTP request header + :param friendly_name: The Flex Plugin's friendly name. + :param description: A descriptive string that you create to describe the plugin resource. It can be up to 500 characters long + + :returns: The created PluginInstance + """ + + data = values.of( + { + "UniqueName": unique_name, + "FriendlyName": friendly_name, + "Description": description, + } + ) + 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 + ) + + return PluginInstance(self._version, payload) + + async def create_async( + self, + unique_name: str, + flex_metadata: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + description: Union[str, object] = values.unset, + ) -> PluginInstance: + """ + Asynchronously create the PluginInstance + + :param unique_name: The Flex Plugin's unique name. + :param flex_metadata: The Flex-Metadata HTTP request header + :param friendly_name: The Flex Plugin's friendly name. + :param description: A descriptive string that you create to describe the plugin resource. It can be up to 500 characters long + + :returns: The created PluginInstance + """ + + data = values.of( + { + "UniqueName": unique_name, + "FriendlyName": friendly_name, + "Description": description, + } + ) + 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 + ) + + return PluginInstance(self._version, payload) + + def stream( + self, + flex_metadata: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[PluginInstance]: + """ + Streams PluginInstance 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 flex_metadata: The Flex-Metadata HTTP request header + :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(flex_metadata=flex_metadata, page_size=limits["page_size"]) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + flex_metadata: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[PluginInstance]: + """ + Asynchronously streams PluginInstance 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 flex_metadata: The Flex-Metadata HTTP request header + :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( + flex_metadata=flex_metadata, page_size=limits["page_size"] + ) + + return self._version.stream_async(page, limits["limit"]) + + def list( + self, + flex_metadata: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[PluginInstance]: + """ + Lists PluginInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str flex_metadata: The Flex-Metadata HTTP request header + :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( + flex_metadata=flex_metadata, + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + flex_metadata: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[PluginInstance]: + """ + Asynchronously lists PluginInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str flex_metadata: The Flex-Metadata HTTP request header + :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( + flex_metadata=flex_metadata, + limit=limit, + page_size=page_size, + ) + ] + + def page( + self, + flex_metadata: 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, + ) -> PluginPage: + """ + Retrieve a single page of PluginInstance records from the API. + Request is executed immediately + + :param flex_metadata: The Flex-Metadata HTTP request header + :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 PluginInstance + """ + data = values.of( + { + "Flex-Metadata": flex_metadata, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + 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( + self, + flex_metadata: 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, + ) -> PluginPage: + """ + Asynchronously retrieve a single page of PluginInstance records from the API. + Request is executed immediately + + :param flex_metadata: The Flex-Metadata HTTP request header + :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 PluginInstance + """ + data = values.of( + { + "Flex-Metadata": flex_metadata, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + 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, headers=headers + ) + return PluginPage(self._version, response) + + def get_page(self, target_url: str) -> PluginPage: + """ + Retrieve a specific page of PluginInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of PluginInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return PluginPage(self._version, response) + + async def get_page_async(self, target_url: str) -> PluginPage: + """ + Asynchronously retrieve a specific page of PluginInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of PluginInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return PluginPage(self._version, response) + + def get(self, sid: str) -> PluginContext: + """ + Constructs a PluginContext + + :param sid: The SID of the Flex Plugin resource to update. + """ + return PluginContext(self._version, sid=sid) + + def __call__(self, sid: str) -> PluginContext: + """ + Constructs a PluginContext + + :param sid: The SID of the Flex Plugin resource to update. + """ + return PluginContext(self._version, sid=sid) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/flex_api/v1/plugin/plugin_versions.py b/twilio/rest/flex_api/v1/plugin/plugin_versions.py new file mode 100644 index 0000000000..4d66ef572b --- /dev/null +++ b/twilio/rest/flex_api/v1/plugin/plugin_versions.py @@ -0,0 +1,612 @@ +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, 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 PluginVersionsInstance(InstanceResource): + """ + :ivar sid: The unique string that we created to identify the Flex Plugin Version resource. + :ivar plugin_sid: The SID of the Flex Plugin resource this Flex Plugin Version belongs to. + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Flex Plugin Version resource and owns this resource. + :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 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. + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + plugin_sid: str, + sid: Optional[str] = None, + ): + super().__init__(version) + + self.sid: Optional[str] = payload.get("sid") + self.plugin_sid: Optional[str] = payload.get("plugin_sid") + self.account_sid: Optional[str] = payload.get("account_sid") + self.version: Optional[str] = payload.get("version") + self.plugin_url: Optional[str] = payload.get("plugin_url") + 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") + ) + self.url: Optional[str] = payload.get("url") + + self._solution = { + "plugin_sid": plugin_sid, + "sid": sid or self.sid, + } + self._context: Optional[PluginVersionsContext] = None + + @property + def _proxy(self) -> "PluginVersionsContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: PluginVersionsContext for this PluginVersionsInstance + """ + if self._context is None: + self._context = PluginVersionsContext( + self._version, + plugin_sid=self._solution["plugin_sid"], + sid=self._solution["sid"], + ) + return self._context + + def fetch( + self, flex_metadata: Union[str, object] = values.unset + ) -> "PluginVersionsInstance": + """ + Fetch the PluginVersionsInstance + + :param flex_metadata: The Flex-Metadata HTTP request header + + :returns: The fetched PluginVersionsInstance + """ + return self._proxy.fetch( + flex_metadata=flex_metadata, + ) + + async def fetch_async( + self, flex_metadata: Union[str, object] = values.unset + ) -> "PluginVersionsInstance": + """ + Asynchronous coroutine to fetch the PluginVersionsInstance + + :param flex_metadata: The Flex-Metadata HTTP request header + + :returns: The fetched PluginVersionsInstance + """ + return await self._proxy.fetch_async( + flex_metadata=flex_metadata, + ) + + 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 PluginVersionsContext(InstanceContext): + + def __init__(self, version: Version, plugin_sid: str, sid: str): + """ + Initialize the PluginVersionsContext + + :param version: Version that contains the resource + :param plugin_sid: The SID of the Flex Plugin the resource to belongs to. + :param sid: The SID of the Flex Plugin Version resource to fetch. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "plugin_sid": plugin_sid, + "sid": sid, + } + self._uri = "/PluginService/Plugins/{plugin_sid}/Versions/{sid}".format( + **self._solution + ) + + def fetch( + self, flex_metadata: Union[str, object] = values.unset + ) -> PluginVersionsInstance: + """ + Fetch the PluginVersionsInstance + + :param flex_metadata: The Flex-Metadata HTTP request header + + :returns: The fetched PluginVersionsInstance + """ + + data = values.of( + { + "Flex-Metadata": flex_metadata, + } + ) + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) + + return PluginVersionsInstance( + self._version, + payload, + plugin_sid=self._solution["plugin_sid"], + sid=self._solution["sid"], + ) + + async def fetch_async( + self, flex_metadata: Union[str, object] = values.unset + ) -> PluginVersionsInstance: + """ + Asynchronous coroutine to fetch the PluginVersionsInstance + + :param flex_metadata: The Flex-Metadata HTTP request header + + :returns: The fetched PluginVersionsInstance + """ + + data = values.of( + { + "Flex-Metadata": flex_metadata, + } + ) + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + + return PluginVersionsInstance( + self._version, + payload, + plugin_sid=self._solution["plugin_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 PluginVersionsPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> PluginVersionsInstance: + """ + Build an instance of PluginVersionsInstance + + :param payload: Payload response from the API + """ + return PluginVersionsInstance( + self._version, payload, plugin_sid=self._solution["plugin_sid"] + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class PluginVersionsList(ListResource): + + def __init__(self, version: Version, plugin_sid: str): + """ + Initialize the PluginVersionsList + + :param version: Version that contains the resource + :param plugin_sid: The SID of the Flex Plugin the resource to belongs to. + + """ + super().__init__(version) + + # Path Solution + self._solution = { + "plugin_sid": plugin_sid, + } + self._uri = "/PluginService/Plugins/{plugin_sid}/Versions".format( + **self._solution + ) + + def create( + self, + version: str, + plugin_url: str, + 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 + + :param version: The Flex Plugin Version's version. + :param plugin_url: The URL of the Flex Plugin Version bundle + :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 + """ + + data = values.of( + { + "Version": version, + "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 + ) + + return PluginVersionsInstance( + self._version, payload, plugin_sid=self._solution["plugin_sid"] + ) + + async def create_async( + self, + version: str, + plugin_url: str, + 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 + + :param version: The Flex Plugin Version's version. + :param plugin_url: The URL of the Flex Plugin Version bundle + :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 + """ + + data = values.of( + { + "Version": version, + "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 + ) + + return PluginVersionsInstance( + self._version, payload, plugin_sid=self._solution["plugin_sid"] + ) + + def stream( + self, + flex_metadata: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[PluginVersionsInstance]: + """ + Streams PluginVersionsInstance 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 flex_metadata: The Flex-Metadata HTTP request header + :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(flex_metadata=flex_metadata, page_size=limits["page_size"]) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + flex_metadata: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[PluginVersionsInstance]: + """ + Asynchronously streams PluginVersionsInstance 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 flex_metadata: The Flex-Metadata HTTP request header + :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( + flex_metadata=flex_metadata, page_size=limits["page_size"] + ) + + return self._version.stream_async(page, limits["limit"]) + + def list( + self, + flex_metadata: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[PluginVersionsInstance]: + """ + Lists PluginVersionsInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str flex_metadata: The Flex-Metadata HTTP request header + :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( + flex_metadata=flex_metadata, + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + flex_metadata: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[PluginVersionsInstance]: + """ + Asynchronously lists PluginVersionsInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str flex_metadata: The Flex-Metadata HTTP request header + :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( + flex_metadata=flex_metadata, + limit=limit, + page_size=page_size, + ) + ] + + def page( + self, + flex_metadata: 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, + ) -> PluginVersionsPage: + """ + Retrieve a single page of PluginVersionsInstance records from the API. + Request is executed immediately + + :param flex_metadata: The Flex-Metadata HTTP request header + :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 PluginVersionsInstance + """ + data = values.of( + { + "Flex-Metadata": flex_metadata, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + 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( + self, + flex_metadata: 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, + ) -> PluginVersionsPage: + """ + Asynchronously retrieve a single page of PluginVersionsInstance records from the API. + Request is executed immediately + + :param flex_metadata: The Flex-Metadata HTTP request header + :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 PluginVersionsInstance + """ + data = values.of( + { + "Flex-Metadata": flex_metadata, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + 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, headers=headers + ) + return PluginVersionsPage(self._version, response, self._solution) + + def get_page(self, target_url: str) -> PluginVersionsPage: + """ + Retrieve a specific page of PluginVersionsInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of PluginVersionsInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return PluginVersionsPage(self._version, response, self._solution) + + async def get_page_async(self, target_url: str) -> PluginVersionsPage: + """ + Asynchronously retrieve a specific page of PluginVersionsInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of PluginVersionsInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return PluginVersionsPage(self._version, response, self._solution) + + def get(self, sid: str) -> PluginVersionsContext: + """ + Constructs a PluginVersionsContext + + :param sid: The SID of the Flex Plugin Version resource to fetch. + """ + return PluginVersionsContext( + self._version, plugin_sid=self._solution["plugin_sid"], sid=sid + ) + + def __call__(self, sid: str) -> PluginVersionsContext: + """ + Constructs a PluginVersionsContext + + :param sid: The SID of the Flex Plugin Version resource to fetch. + """ + return PluginVersionsContext( + self._version, plugin_sid=self._solution["plugin_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_archive.py b/twilio/rest/flex_api/v1/plugin_archive.py new file mode 100644 index 0000000000..e7f526a919 --- /dev/null +++ b/twilio/rest/flex_api/v1/plugin_archive.py @@ -0,0 +1,230 @@ +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 PluginArchiveInstance(InstanceResource): + """ + :ivar sid: The unique string that we created to identify the Flex Plugin resource. + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Flex Plugin resource and owns this resource. + :ivar unique_name: The name that uniquely identifies this Flex Plugin resource. + :ivar friendly_name: The friendly name this Flex Plugin resource. + :ivar description: A descriptive string that you create to describe the plugin resource. It can be up to 500 characters long + :ivar archived: Whether the Flex Plugin is archived. The default value is false. + :ivar date_created: The date and time in GMT when the Flex Plugin 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 Flex Plugin was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + :ivar url: The absolute URL of the Flex Plugin 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.account_sid: Optional[str] = payload.get("account_sid") + self.unique_name: Optional[str] = payload.get("unique_name") + self.friendly_name: Optional[str] = payload.get("friendly_name") + self.description: Optional[str] = payload.get("description") + self.archived: Optional[bool] = payload.get("archived") + 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[PluginArchiveContext] = None + + @property + def _proxy(self) -> "PluginArchiveContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: PluginArchiveContext for this PluginArchiveInstance + """ + if self._context is None: + self._context = PluginArchiveContext( + self._version, + sid=self._solution["sid"], + ) + return self._context + + def update( + self, flex_metadata: Union[str, object] = values.unset + ) -> "PluginArchiveInstance": + """ + Update the PluginArchiveInstance + + :param flex_metadata: The Flex-Metadata HTTP request header + + :returns: The updated PluginArchiveInstance + """ + return self._proxy.update( + flex_metadata=flex_metadata, + ) + + async def update_async( + self, flex_metadata: Union[str, object] = values.unset + ) -> "PluginArchiveInstance": + """ + Asynchronous coroutine to update the PluginArchiveInstance + + :param flex_metadata: The Flex-Metadata HTTP request header + + :returns: The updated PluginArchiveInstance + """ + return await self._proxy.update_async( + flex_metadata=flex_metadata, + ) + + 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 PluginArchiveContext(InstanceContext): + + def __init__(self, version: Version, sid: str): + """ + Initialize the PluginArchiveContext + + :param version: Version that contains the resource + :param sid: The SID of the Flex Plugin resource to archive. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "sid": sid, + } + self._uri = "/PluginService/Plugins/{sid}/Archive".format(**self._solution) + + def update( + self, flex_metadata: Union[str, object] = values.unset + ) -> PluginArchiveInstance: + """ + Update the PluginArchiveInstance + + :param flex_metadata: The Flex-Metadata HTTP request header + + :returns: The updated PluginArchiveInstance + """ + + data = values.of({}) + 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 + ) + + return PluginArchiveInstance(self._version, payload, sid=self._solution["sid"]) + + async def update_async( + self, flex_metadata: Union[str, object] = values.unset + ) -> PluginArchiveInstance: + """ + Asynchronous coroutine to update the PluginArchiveInstance + + :param flex_metadata: The Flex-Metadata HTTP request header + + :returns: The updated PluginArchiveInstance + """ + + data = values.of({}) + 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 + ) + + return PluginArchiveInstance(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 PluginArchiveList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the PluginArchiveList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + def get(self, sid: str) -> PluginArchiveContext: + """ + Constructs a PluginArchiveContext + + :param sid: The SID of the Flex Plugin resource to archive. + """ + return PluginArchiveContext(self._version, sid=sid) + + def __call__(self, sid: str) -> PluginArchiveContext: + """ + Constructs a PluginArchiveContext + + :param sid: The SID of the Flex Plugin resource to archive. + """ + return PluginArchiveContext(self._version, sid=sid) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/flex_api/v1/plugin_configuration/__init__.py b/twilio/rest/flex_api/v1/plugin_configuration/__init__.py new file mode 100644 index 0000000000..b17d697e3b --- /dev/null +++ b/twilio/rest/flex_api/v1/plugin_configuration/__init__.py @@ -0,0 +1,583 @@ +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, 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.flex_api.v1.plugin_configuration.configured_plugin import ( + ConfiguredPluginList, +) + + +class PluginConfigurationInstance(InstanceResource): + """ + :ivar sid: The unique string that we created to identify the Flex Plugin Configuration resource. + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Flex Plugin Configuration resource and owns this resource. + :ivar name: The name of this Flex Plugin Configuration. + :ivar description: The description of the Flex Plugin Configuration resource. + :ivar archived: Whether the Flex Plugin Configuration is archived. The default value is false. + :ivar date_created: The date and time in GMT when the Flex Plugin Configuration was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + :ivar url: The absolute URL of the Flex Plugin Configuration resource. + :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.name: Optional[str] = payload.get("name") + self.description: Optional[str] = payload.get("description") + self.archived: Optional[bool] = payload.get("archived") + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_created") + ) + 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[PluginConfigurationContext] = None + + @property + def _proxy(self) -> "PluginConfigurationContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: PluginConfigurationContext for this PluginConfigurationInstance + """ + if self._context is None: + self._context = PluginConfigurationContext( + self._version, + sid=self._solution["sid"], + ) + return self._context + + def fetch( + self, flex_metadata: Union[str, object] = values.unset + ) -> "PluginConfigurationInstance": + """ + Fetch the PluginConfigurationInstance + + :param flex_metadata: The Flex-Metadata HTTP request header + + :returns: The fetched PluginConfigurationInstance + """ + return self._proxy.fetch( + flex_metadata=flex_metadata, + ) + + async def fetch_async( + self, flex_metadata: Union[str, object] = values.unset + ) -> "PluginConfigurationInstance": + """ + Asynchronous coroutine to fetch the PluginConfigurationInstance + + :param flex_metadata: The Flex-Metadata HTTP request header + + :returns: The fetched PluginConfigurationInstance + """ + return await self._proxy.fetch_async( + flex_metadata=flex_metadata, + ) + + @property + def plugins(self) -> ConfiguredPluginList: + """ + Access the plugins + """ + return self._proxy.plugins + + 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 PluginConfigurationContext(InstanceContext): + + def __init__(self, version: Version, sid: str): + """ + Initialize the PluginConfigurationContext + + :param version: Version that contains the resource + :param sid: The SID of the Flex Plugin Configuration resource to fetch. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "sid": sid, + } + self._uri = "/PluginService/Configurations/{sid}".format(**self._solution) + + self._plugins: Optional[ConfiguredPluginList] = None + + def fetch( + self, flex_metadata: Union[str, object] = values.unset + ) -> PluginConfigurationInstance: + """ + Fetch the PluginConfigurationInstance + + :param flex_metadata: The Flex-Metadata HTTP request header + + :returns: The fetched PluginConfigurationInstance + """ + + data = values.of( + { + "Flex-Metadata": flex_metadata, + } + ) + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) + + return PluginConfigurationInstance( + self._version, + payload, + sid=self._solution["sid"], + ) + + async def fetch_async( + self, flex_metadata: Union[str, object] = values.unset + ) -> PluginConfigurationInstance: + """ + Asynchronous coroutine to fetch the PluginConfigurationInstance + + :param flex_metadata: The Flex-Metadata HTTP request header + + :returns: The fetched PluginConfigurationInstance + """ + + data = values.of( + { + "Flex-Metadata": flex_metadata, + } + ) + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + + return PluginConfigurationInstance( + self._version, + payload, + sid=self._solution["sid"], + ) + + @property + def plugins(self) -> ConfiguredPluginList: + """ + Access the plugins + """ + if self._plugins is None: + self._plugins = ConfiguredPluginList( + self._version, + self._solution["sid"], + ) + return self._plugins + + 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 PluginConfigurationPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> PluginConfigurationInstance: + """ + Build an instance of PluginConfigurationInstance + + :param payload: Payload response from the API + """ + return PluginConfigurationInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class PluginConfigurationList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the PluginConfigurationList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/PluginService/Configurations" + + def create( + self, + name: str, + flex_metadata: Union[str, object] = values.unset, + plugins: Union[List[object], object] = values.unset, + description: Union[str, object] = values.unset, + ) -> PluginConfigurationInstance: + """ + Create the PluginConfigurationInstance + + :param name: The Flex Plugin Configuration's name. + :param flex_metadata: The Flex-Metadata HTTP request header + :param plugins: A list of objects that describe the plugin versions included in the configuration. Each object contains the sid of the plugin version. + :param description: The Flex Plugin Configuration's description. + + :returns: The created PluginConfigurationInstance + """ + + data = values.of( + { + "Name": name, + "Plugins": serialize.map(plugins, lambda e: serialize.object(e)), + "Description": description, + } + ) + 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 + ) + + return PluginConfigurationInstance(self._version, payload) + + async def create_async( + self, + name: str, + flex_metadata: Union[str, object] = values.unset, + plugins: Union[List[object], object] = values.unset, + description: Union[str, object] = values.unset, + ) -> PluginConfigurationInstance: + """ + Asynchronously create the PluginConfigurationInstance + + :param name: The Flex Plugin Configuration's name. + :param flex_metadata: The Flex-Metadata HTTP request header + :param plugins: A list of objects that describe the plugin versions included in the configuration. Each object contains the sid of the plugin version. + :param description: The Flex Plugin Configuration's description. + + :returns: The created PluginConfigurationInstance + """ + + data = values.of( + { + "Name": name, + "Plugins": serialize.map(plugins, lambda e: serialize.object(e)), + "Description": description, + } + ) + 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 + ) + + return PluginConfigurationInstance(self._version, payload) + + def stream( + self, + flex_metadata: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[PluginConfigurationInstance]: + """ + Streams PluginConfigurationInstance 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 flex_metadata: The Flex-Metadata HTTP request header + :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(flex_metadata=flex_metadata, page_size=limits["page_size"]) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + flex_metadata: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[PluginConfigurationInstance]: + """ + Asynchronously streams PluginConfigurationInstance 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 flex_metadata: The Flex-Metadata HTTP request header + :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( + flex_metadata=flex_metadata, page_size=limits["page_size"] + ) + + return self._version.stream_async(page, limits["limit"]) + + def list( + self, + flex_metadata: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[PluginConfigurationInstance]: + """ + Lists PluginConfigurationInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str flex_metadata: The Flex-Metadata HTTP request header + :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( + flex_metadata=flex_metadata, + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + flex_metadata: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[PluginConfigurationInstance]: + """ + Asynchronously lists PluginConfigurationInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str flex_metadata: The Flex-Metadata HTTP request header + :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( + flex_metadata=flex_metadata, + limit=limit, + page_size=page_size, + ) + ] + + def page( + self, + flex_metadata: 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, + ) -> PluginConfigurationPage: + """ + Retrieve a single page of PluginConfigurationInstance records from the API. + Request is executed immediately + + :param flex_metadata: The Flex-Metadata HTTP request header + :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 PluginConfigurationInstance + """ + data = values.of( + { + "Flex-Metadata": flex_metadata, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + 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( + self, + flex_metadata: 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, + ) -> PluginConfigurationPage: + """ + Asynchronously retrieve a single page of PluginConfigurationInstance records from the API. + Request is executed immediately + + :param flex_metadata: The Flex-Metadata HTTP request header + :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 PluginConfigurationInstance + """ + data = values.of( + { + "Flex-Metadata": flex_metadata, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + 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, headers=headers + ) + return PluginConfigurationPage(self._version, response) + + def get_page(self, target_url: str) -> PluginConfigurationPage: + """ + Retrieve a specific page of PluginConfigurationInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of PluginConfigurationInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return PluginConfigurationPage(self._version, response) + + async def get_page_async(self, target_url: str) -> PluginConfigurationPage: + """ + Asynchronously retrieve a specific page of PluginConfigurationInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of PluginConfigurationInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return PluginConfigurationPage(self._version, response) + + def get(self, sid: str) -> PluginConfigurationContext: + """ + Constructs a PluginConfigurationContext + + :param sid: The SID of the Flex Plugin Configuration resource to fetch. + """ + return PluginConfigurationContext(self._version, sid=sid) + + def __call__(self, sid: str) -> PluginConfigurationContext: + """ + Constructs a PluginConfigurationContext + + :param sid: The SID of the Flex Plugin Configuration resource to fetch. + """ + return PluginConfigurationContext(self._version, sid=sid) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/flex_api/v1/plugin_configuration/configured_plugin.py b/twilio/rest/flex_api/v1/plugin_configuration/configured_plugin.py new file mode 100644 index 0000000000..062a7db7b4 --- /dev/null +++ b/twilio/rest/flex_api/v1/plugin_configuration/configured_plugin.py @@ -0,0 +1,524 @@ +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, 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 ConfiguredPluginInstance(InstanceResource): + """ + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that the Flex Plugin resource is installed for. + :ivar configuration_sid: The SID of the Flex Plugin Configuration that this Flex Plugin belongs to. + :ivar plugin_sid: The SID of the Flex Plugin. + :ivar plugin_version_sid: The SID of the Flex Plugin Version. + :ivar phase: The phase this Flex Plugin would initialize at runtime. + :ivar plugin_url: The URL of where the Flex Plugin Version JavaScript bundle is hosted on. + :ivar unique_name: The name that uniquely identifies this Flex Plugin resource. + :ivar friendly_name: The friendly name of this Flex Plugin resource. + :ivar description: A descriptive string that you create to describe the plugin resource. It can be up to 500 characters long + :ivar plugin_archived: Whether the Flex Plugin is archived. The default value is false. + :ivar version: The latest version of this Flex Plugin Version. + :ivar changelog: A changelog that describes the changes this Flex Plugin Version brings. + :ivar plugin_version_archived: Whether the Flex Plugin Version is archived. The default value is false. + :ivar private: Whether to validate the request is authorized to access the Flex Plugin Version. + :ivar date_created: The date and time in GMT when the Flex Plugin was installed specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + :ivar url: The absolute URL of the Flex Plugin resource. + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + configuration_sid: str, + plugin_sid: Optional[str] = None, + ): + super().__init__(version) + + self.account_sid: Optional[str] = payload.get("account_sid") + self.configuration_sid: Optional[str] = payload.get("configuration_sid") + self.plugin_sid: Optional[str] = payload.get("plugin_sid") + self.plugin_version_sid: Optional[str] = payload.get("plugin_version_sid") + self.phase: Optional[int] = deserialize.integer(payload.get("phase")) + self.plugin_url: Optional[str] = payload.get("plugin_url") + self.unique_name: Optional[str] = payload.get("unique_name") + self.friendly_name: Optional[str] = payload.get("friendly_name") + self.description: Optional[str] = payload.get("description") + self.plugin_archived: Optional[bool] = payload.get("plugin_archived") + self.version: Optional[str] = payload.get("version") + self.changelog: Optional[str] = payload.get("changelog") + self.plugin_version_archived: Optional[bool] = payload.get( + "plugin_version_archived" + ) + self.private: Optional[bool] = payload.get("private") + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_created") + ) + self.url: Optional[str] = payload.get("url") + + self._solution = { + "configuration_sid": configuration_sid, + "plugin_sid": plugin_sid or self.plugin_sid, + } + self._context: Optional[ConfiguredPluginContext] = None + + @property + def _proxy(self) -> "ConfiguredPluginContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: ConfiguredPluginContext for this ConfiguredPluginInstance + """ + if self._context is None: + self._context = ConfiguredPluginContext( + self._version, + configuration_sid=self._solution["configuration_sid"], + plugin_sid=self._solution["plugin_sid"], + ) + return self._context + + def fetch( + self, flex_metadata: Union[str, object] = values.unset + ) -> "ConfiguredPluginInstance": + """ + Fetch the ConfiguredPluginInstance + + :param flex_metadata: The Flex-Metadata HTTP request header + + :returns: The fetched ConfiguredPluginInstance + """ + return self._proxy.fetch( + flex_metadata=flex_metadata, + ) + + async def fetch_async( + self, flex_metadata: Union[str, object] = values.unset + ) -> "ConfiguredPluginInstance": + """ + Asynchronous coroutine to fetch the ConfiguredPluginInstance + + :param flex_metadata: The Flex-Metadata HTTP request header + + :returns: The fetched ConfiguredPluginInstance + """ + return await self._proxy.fetch_async( + flex_metadata=flex_metadata, + ) + + 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 ConfiguredPluginContext(InstanceContext): + + def __init__(self, version: Version, configuration_sid: str, plugin_sid: str): + """ + Initialize the ConfiguredPluginContext + + :param version: Version that contains the resource + :param configuration_sid: The SID of the Flex Plugin Configuration the resource to belongs to. + :param plugin_sid: The unique string that we created to identify the Flex Plugin resource. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "configuration_sid": configuration_sid, + "plugin_sid": plugin_sid, + } + self._uri = "/PluginService/Configurations/{configuration_sid}/Plugins/{plugin_sid}".format( + **self._solution + ) + + def fetch( + self, flex_metadata: Union[str, object] = values.unset + ) -> ConfiguredPluginInstance: + """ + Fetch the ConfiguredPluginInstance + + :param flex_metadata: The Flex-Metadata HTTP request header + + :returns: The fetched ConfiguredPluginInstance + """ + + data = values.of( + { + "Flex-Metadata": flex_metadata, + } + ) + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) + + return ConfiguredPluginInstance( + self._version, + payload, + configuration_sid=self._solution["configuration_sid"], + plugin_sid=self._solution["plugin_sid"], + ) + + async def fetch_async( + self, flex_metadata: Union[str, object] = values.unset + ) -> ConfiguredPluginInstance: + """ + Asynchronous coroutine to fetch the ConfiguredPluginInstance + + :param flex_metadata: The Flex-Metadata HTTP request header + + :returns: The fetched ConfiguredPluginInstance + """ + + data = values.of( + { + "Flex-Metadata": flex_metadata, + } + ) + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + + return ConfiguredPluginInstance( + self._version, + payload, + configuration_sid=self._solution["configuration_sid"], + plugin_sid=self._solution["plugin_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 ConfiguredPluginPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> ConfiguredPluginInstance: + """ + Build an instance of ConfiguredPluginInstance + + :param payload: Payload response from the API + """ + return ConfiguredPluginInstance( + self._version, + payload, + configuration_sid=self._solution["configuration_sid"], + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class ConfiguredPluginList(ListResource): + + def __init__(self, version: Version, configuration_sid: str): + """ + Initialize the ConfiguredPluginList + + :param version: Version that contains the resource + :param configuration_sid: The SID of the Flex Plugin Configuration the resource to belongs to. + + """ + super().__init__(version) + + # Path Solution + self._solution = { + "configuration_sid": configuration_sid, + } + self._uri = "/PluginService/Configurations/{configuration_sid}/Plugins".format( + **self._solution + ) + + def stream( + self, + flex_metadata: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[ConfiguredPluginInstance]: + """ + Streams ConfiguredPluginInstance 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 flex_metadata: The Flex-Metadata HTTP request header + :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(flex_metadata=flex_metadata, page_size=limits["page_size"]) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + flex_metadata: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[ConfiguredPluginInstance]: + """ + Asynchronously streams ConfiguredPluginInstance 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 flex_metadata: The Flex-Metadata HTTP request header + :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( + flex_metadata=flex_metadata, page_size=limits["page_size"] + ) + + return self._version.stream_async(page, limits["limit"]) + + def list( + self, + flex_metadata: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[ConfiguredPluginInstance]: + """ + Lists ConfiguredPluginInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str flex_metadata: The Flex-Metadata HTTP request header + :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( + flex_metadata=flex_metadata, + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + flex_metadata: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[ConfiguredPluginInstance]: + """ + Asynchronously lists ConfiguredPluginInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str flex_metadata: The Flex-Metadata HTTP request header + :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( + flex_metadata=flex_metadata, + limit=limit, + page_size=page_size, + ) + ] + + def page( + self, + flex_metadata: 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, + ) -> ConfiguredPluginPage: + """ + Retrieve a single page of ConfiguredPluginInstance records from the API. + Request is executed immediately + + :param flex_metadata: The Flex-Metadata HTTP request header + :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 ConfiguredPluginInstance + """ + data = values.of( + { + "Flex-Metadata": flex_metadata, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + 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( + self, + flex_metadata: 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, + ) -> ConfiguredPluginPage: + """ + Asynchronously retrieve a single page of ConfiguredPluginInstance records from the API. + Request is executed immediately + + :param flex_metadata: The Flex-Metadata HTTP request header + :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 ConfiguredPluginInstance + """ + data = values.of( + { + "Flex-Metadata": flex_metadata, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + 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, headers=headers + ) + return ConfiguredPluginPage(self._version, response, self._solution) + + def get_page(self, target_url: str) -> ConfiguredPluginPage: + """ + Retrieve a specific page of ConfiguredPluginInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of ConfiguredPluginInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return ConfiguredPluginPage(self._version, response, self._solution) + + async def get_page_async(self, target_url: str) -> ConfiguredPluginPage: + """ + Asynchronously retrieve a specific page of ConfiguredPluginInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of ConfiguredPluginInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return ConfiguredPluginPage(self._version, response, self._solution) + + def get(self, plugin_sid: str) -> ConfiguredPluginContext: + """ + Constructs a ConfiguredPluginContext + + :param plugin_sid: The unique string that we created to identify the Flex Plugin resource. + """ + return ConfiguredPluginContext( + self._version, + configuration_sid=self._solution["configuration_sid"], + plugin_sid=plugin_sid, + ) + + def __call__(self, plugin_sid: str) -> ConfiguredPluginContext: + """ + Constructs a ConfiguredPluginContext + + :param plugin_sid: The unique string that we created to identify the Flex Plugin resource. + """ + return ConfiguredPluginContext( + self._version, + configuration_sid=self._solution["configuration_sid"], + plugin_sid=plugin_sid, + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/flex_api/v1/plugin_configuration_archive.py b/twilio/rest/flex_api/v1/plugin_configuration_archive.py new file mode 100644 index 0000000000..3fec073333 --- /dev/null +++ b/twilio/rest/flex_api/v1/plugin_configuration_archive.py @@ -0,0 +1,234 @@ +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 PluginConfigurationArchiveInstance(InstanceResource): + """ + :ivar sid: The unique string that we created to identify the Flex Plugin Configuration resource. + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Flex Plugin Configuration resource and owns this resource. + :ivar name: The name of this Flex Plugin Configuration. + :ivar description: The description of the Flex Plugin Configuration resource. + :ivar archived: Whether the Flex Plugin Configuration is archived. The default value is false. + :ivar date_created: The date and time in GMT when the Flex Plugin Configuration was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + :ivar url: The absolute URL of the Flex Plugin Configuration 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.account_sid: Optional[str] = payload.get("account_sid") + self.name: Optional[str] = payload.get("name") + self.description: Optional[str] = payload.get("description") + self.archived: Optional[bool] = payload.get("archived") + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_created") + ) + self.url: Optional[str] = payload.get("url") + + self._solution = { + "sid": sid or self.sid, + } + self._context: Optional[PluginConfigurationArchiveContext] = None + + @property + def _proxy(self) -> "PluginConfigurationArchiveContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: PluginConfigurationArchiveContext for this PluginConfigurationArchiveInstance + """ + if self._context is None: + self._context = PluginConfigurationArchiveContext( + self._version, + sid=self._solution["sid"], + ) + return self._context + + def update( + self, flex_metadata: Union[str, object] = values.unset + ) -> "PluginConfigurationArchiveInstance": + """ + Update the PluginConfigurationArchiveInstance + + :param flex_metadata: The Flex-Metadata HTTP request header + + :returns: The updated PluginConfigurationArchiveInstance + """ + return self._proxy.update( + flex_metadata=flex_metadata, + ) + + async def update_async( + self, flex_metadata: Union[str, object] = values.unset + ) -> "PluginConfigurationArchiveInstance": + """ + Asynchronous coroutine to update the PluginConfigurationArchiveInstance + + :param flex_metadata: The Flex-Metadata HTTP request header + + :returns: The updated PluginConfigurationArchiveInstance + """ + return await self._proxy.update_async( + flex_metadata=flex_metadata, + ) + + 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 PluginConfigurationArchiveContext(InstanceContext): + + def __init__(self, version: Version, sid: str): + """ + Initialize the PluginConfigurationArchiveContext + + :param version: Version that contains the resource + :param sid: The SID of the Flex Plugin Configuration resource to archive. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "sid": sid, + } + self._uri = "/PluginService/Configurations/{sid}/Archive".format( + **self._solution + ) + + def update( + self, flex_metadata: Union[str, object] = values.unset + ) -> PluginConfigurationArchiveInstance: + """ + Update the PluginConfigurationArchiveInstance + + :param flex_metadata: The Flex-Metadata HTTP request header + + :returns: The updated PluginConfigurationArchiveInstance + """ + + data = values.of({}) + 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 + ) + + return PluginConfigurationArchiveInstance( + self._version, payload, sid=self._solution["sid"] + ) + + async def update_async( + self, flex_metadata: Union[str, object] = values.unset + ) -> PluginConfigurationArchiveInstance: + """ + Asynchronous coroutine to update the PluginConfigurationArchiveInstance + + :param flex_metadata: The Flex-Metadata HTTP request header + + :returns: The updated PluginConfigurationArchiveInstance + """ + + data = values.of({}) + 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 + ) + + return PluginConfigurationArchiveInstance( + 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 PluginConfigurationArchiveList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the PluginConfigurationArchiveList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + def get(self, sid: str) -> PluginConfigurationArchiveContext: + """ + Constructs a PluginConfigurationArchiveContext + + :param sid: The SID of the Flex Plugin Configuration resource to archive. + """ + return PluginConfigurationArchiveContext(self._version, sid=sid) + + def __call__(self, sid: str) -> PluginConfigurationArchiveContext: + """ + Constructs a PluginConfigurationArchiveContext + + :param sid: The SID of the Flex Plugin Configuration resource to archive. + """ + return PluginConfigurationArchiveContext(self._version, sid=sid) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/flex_api/v1/plugin_release.py b/twilio/rest/flex_api/v1/plugin_release.py new file mode 100644 index 0000000000..0694b05f8b --- /dev/null +++ b/twilio/rest/flex_api/v1/plugin_release.py @@ -0,0 +1,537 @@ +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, 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 PluginReleaseInstance(InstanceResource): + """ + :ivar sid: The unique string that we created to identify the Plugin Release resource. + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Plugin Release resource and owns this resource. + :ivar configuration_sid: The SID of the Plugin Configuration resource to release. + :ivar date_created: The date and time in GMT when the Flex Plugin Release was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + :ivar url: The absolute URL of the Plugin Release 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.account_sid: Optional[str] = payload.get("account_sid") + self.configuration_sid: Optional[str] = payload.get("configuration_sid") + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_created") + ) + self.url: Optional[str] = payload.get("url") + + self._solution = { + "sid": sid or self.sid, + } + self._context: Optional[PluginReleaseContext] = None + + @property + def _proxy(self) -> "PluginReleaseContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: PluginReleaseContext for this PluginReleaseInstance + """ + if self._context is None: + self._context = PluginReleaseContext( + self._version, + sid=self._solution["sid"], + ) + return self._context + + def fetch( + self, flex_metadata: Union[str, object] = values.unset + ) -> "PluginReleaseInstance": + """ + Fetch the PluginReleaseInstance + + :param flex_metadata: The Flex-Metadata HTTP request header + + :returns: The fetched PluginReleaseInstance + """ + return self._proxy.fetch( + flex_metadata=flex_metadata, + ) + + async def fetch_async( + self, flex_metadata: Union[str, object] = values.unset + ) -> "PluginReleaseInstance": + """ + Asynchronous coroutine to fetch the PluginReleaseInstance + + :param flex_metadata: The Flex-Metadata HTTP request header + + :returns: The fetched PluginReleaseInstance + """ + return await self._proxy.fetch_async( + flex_metadata=flex_metadata, + ) + + 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 PluginReleaseContext(InstanceContext): + + def __init__(self, version: Version, sid: str): + """ + Initialize the PluginReleaseContext + + :param version: Version that contains the resource + :param sid: The SID of the Flex Plugin Release resource to fetch. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "sid": sid, + } + self._uri = "/PluginService/Releases/{sid}".format(**self._solution) + + def fetch( + self, flex_metadata: Union[str, object] = values.unset + ) -> PluginReleaseInstance: + """ + Fetch the PluginReleaseInstance + + :param flex_metadata: The Flex-Metadata HTTP request header + + :returns: The fetched PluginReleaseInstance + """ + + data = values.of( + { + "Flex-Metadata": flex_metadata, + } + ) + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) + + return PluginReleaseInstance( + self._version, + payload, + sid=self._solution["sid"], + ) + + async def fetch_async( + self, flex_metadata: Union[str, object] = values.unset + ) -> PluginReleaseInstance: + """ + Asynchronous coroutine to fetch the PluginReleaseInstance + + :param flex_metadata: The Flex-Metadata HTTP request header + + :returns: The fetched PluginReleaseInstance + """ + + data = values.of( + { + "Flex-Metadata": flex_metadata, + } + ) + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + + return PluginReleaseInstance( + 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 PluginReleasePage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> PluginReleaseInstance: + """ + Build an instance of PluginReleaseInstance + + :param payload: Payload response from the API + """ + return PluginReleaseInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class PluginReleaseList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the PluginReleaseList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/PluginService/Releases" + + def create( + self, configuration_id: str, flex_metadata: Union[str, object] = values.unset + ) -> PluginReleaseInstance: + """ + Create the PluginReleaseInstance + + :param configuration_id: The SID or the Version of the Flex Plugin Configuration to release. + :param flex_metadata: The Flex-Metadata HTTP request header + + :returns: The created PluginReleaseInstance + """ + + data = values.of( + { + "ConfigurationId": configuration_id, + } + ) + 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 + ) + + return PluginReleaseInstance(self._version, payload) + + async def create_async( + self, configuration_id: str, flex_metadata: Union[str, object] = values.unset + ) -> PluginReleaseInstance: + """ + Asynchronously create the PluginReleaseInstance + + :param configuration_id: The SID or the Version of the Flex Plugin Configuration to release. + :param flex_metadata: The Flex-Metadata HTTP request header + + :returns: The created PluginReleaseInstance + """ + + data = values.of( + { + "ConfigurationId": configuration_id, + } + ) + 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 + ) + + return PluginReleaseInstance(self._version, payload) + + def stream( + self, + flex_metadata: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[PluginReleaseInstance]: + """ + Streams PluginReleaseInstance 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 flex_metadata: The Flex-Metadata HTTP request header + :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(flex_metadata=flex_metadata, page_size=limits["page_size"]) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + flex_metadata: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[PluginReleaseInstance]: + """ + Asynchronously streams PluginReleaseInstance 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 flex_metadata: The Flex-Metadata HTTP request header + :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( + flex_metadata=flex_metadata, page_size=limits["page_size"] + ) + + return self._version.stream_async(page, limits["limit"]) + + def list( + self, + flex_metadata: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[PluginReleaseInstance]: + """ + Lists PluginReleaseInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str flex_metadata: The Flex-Metadata HTTP request header + :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( + flex_metadata=flex_metadata, + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + flex_metadata: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[PluginReleaseInstance]: + """ + Asynchronously lists PluginReleaseInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str flex_metadata: The Flex-Metadata HTTP request header + :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( + flex_metadata=flex_metadata, + limit=limit, + page_size=page_size, + ) + ] + + def page( + self, + flex_metadata: 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, + ) -> PluginReleasePage: + """ + Retrieve a single page of PluginReleaseInstance records from the API. + Request is executed immediately + + :param flex_metadata: The Flex-Metadata HTTP request header + :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 PluginReleaseInstance + """ + data = values.of( + { + "Flex-Metadata": flex_metadata, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + 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( + self, + flex_metadata: 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, + ) -> PluginReleasePage: + """ + Asynchronously retrieve a single page of PluginReleaseInstance records from the API. + Request is executed immediately + + :param flex_metadata: The Flex-Metadata HTTP request header + :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 PluginReleaseInstance + """ + data = values.of( + { + "Flex-Metadata": flex_metadata, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + 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, headers=headers + ) + return PluginReleasePage(self._version, response) + + def get_page(self, target_url: str) -> PluginReleasePage: + """ + Retrieve a specific page of PluginReleaseInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of PluginReleaseInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return PluginReleasePage(self._version, response) + + async def get_page_async(self, target_url: str) -> PluginReleasePage: + """ + Asynchronously retrieve a specific page of PluginReleaseInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of PluginReleaseInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return PluginReleasePage(self._version, response) + + def get(self, sid: str) -> PluginReleaseContext: + """ + Constructs a PluginReleaseContext + + :param sid: The SID of the Flex Plugin Release resource to fetch. + """ + return PluginReleaseContext(self._version, sid=sid) + + def __call__(self, sid: str) -> PluginReleaseContext: + """ + Constructs a PluginReleaseContext + + :param sid: The SID of the Flex Plugin Release resource to fetch. + """ + return PluginReleaseContext(self._version, sid=sid) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/flex_api/v1/plugin_version_archive.py b/twilio/rest/flex_api/v1/plugin_version_archive.py new file mode 100644 index 0000000000..be169d4d64 --- /dev/null +++ b/twilio/rest/flex_api/v1/plugin_version_archive.py @@ -0,0 +1,256 @@ +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 PluginVersionArchiveInstance(InstanceResource): + """ + :ivar sid: The unique string that we created to identify the Flex Plugin Version resource. + :ivar plugin_sid: The SID of the Flex Plugin resource this Flex Plugin Version belongs to. + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Flex Plugin Version resource and owns this resource. + :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 archived: Whether the Flex Plugin Version is archived. The default value is false. + :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. + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + plugin_sid: Optional[str] = None, + sid: Optional[str] = None, + ): + super().__init__(version) + + self.sid: Optional[str] = payload.get("sid") + self.plugin_sid: Optional[str] = payload.get("plugin_sid") + self.account_sid: Optional[str] = payload.get("account_sid") + self.version: Optional[str] = payload.get("version") + self.plugin_url: Optional[str] = payload.get("plugin_url") + self.changelog: Optional[str] = payload.get("changelog") + self.private: Optional[bool] = payload.get("private") + self.archived: Optional[bool] = payload.get("archived") + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_created") + ) + self.url: Optional[str] = payload.get("url") + + self._solution = { + "plugin_sid": plugin_sid or self.plugin_sid, + "sid": sid or self.sid, + } + self._context: Optional[PluginVersionArchiveContext] = None + + @property + def _proxy(self) -> "PluginVersionArchiveContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: PluginVersionArchiveContext for this PluginVersionArchiveInstance + """ + if self._context is None: + self._context = PluginVersionArchiveContext( + self._version, + plugin_sid=self._solution["plugin_sid"], + sid=self._solution["sid"], + ) + return self._context + + def update( + self, flex_metadata: Union[str, object] = values.unset + ) -> "PluginVersionArchiveInstance": + """ + Update the PluginVersionArchiveInstance + + :param flex_metadata: The Flex-Metadata HTTP request header + + :returns: The updated PluginVersionArchiveInstance + """ + return self._proxy.update( + flex_metadata=flex_metadata, + ) + + async def update_async( + self, flex_metadata: Union[str, object] = values.unset + ) -> "PluginVersionArchiveInstance": + """ + Asynchronous coroutine to update the PluginVersionArchiveInstance + + :param flex_metadata: The Flex-Metadata HTTP request header + + :returns: The updated PluginVersionArchiveInstance + """ + return await self._proxy.update_async( + flex_metadata=flex_metadata, + ) + + 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 PluginVersionArchiveContext(InstanceContext): + + def __init__(self, version: Version, plugin_sid: str, sid: str): + """ + Initialize the PluginVersionArchiveContext + + :param version: Version that contains the resource + :param plugin_sid: The SID of the Flex Plugin the resource to belongs to. + :param sid: The SID of the Flex Plugin Version resource to archive. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "plugin_sid": plugin_sid, + "sid": sid, + } + self._uri = "/PluginService/Plugins/{plugin_sid}/Versions/{sid}/Archive".format( + **self._solution + ) + + def update( + self, flex_metadata: Union[str, object] = values.unset + ) -> PluginVersionArchiveInstance: + """ + Update the PluginVersionArchiveInstance + + :param flex_metadata: The Flex-Metadata HTTP request header + + :returns: The updated PluginVersionArchiveInstance + """ + + data = values.of({}) + 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 + ) + + return PluginVersionArchiveInstance( + self._version, + payload, + plugin_sid=self._solution["plugin_sid"], + sid=self._solution["sid"], + ) + + async def update_async( + self, flex_metadata: Union[str, object] = values.unset + ) -> PluginVersionArchiveInstance: + """ + Asynchronous coroutine to update the PluginVersionArchiveInstance + + :param flex_metadata: The Flex-Metadata HTTP request header + + :returns: The updated PluginVersionArchiveInstance + """ + + data = values.of({}) + 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 + ) + + return PluginVersionArchiveInstance( + self._version, + payload, + plugin_sid=self._solution["plugin_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 PluginVersionArchiveList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the PluginVersionArchiveList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + def get(self, plugin_sid: str, sid: str) -> PluginVersionArchiveContext: + """ + Constructs a PluginVersionArchiveContext + + :param plugin_sid: The SID of the Flex Plugin the resource to belongs to. + :param sid: The SID of the Flex Plugin Version resource to archive. + """ + return PluginVersionArchiveContext( + self._version, plugin_sid=plugin_sid, sid=sid + ) + + def __call__(self, plugin_sid: str, sid: str) -> PluginVersionArchiveContext: + """ + Constructs a PluginVersionArchiveContext + + :param plugin_sid: The SID of the Flex Plugin the resource to belongs to. + :param sid: The SID of the Flex Plugin Version resource to archive. + """ + return PluginVersionArchiveContext( + self._version, plugin_sid=plugin_sid, sid=sid + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/flex_api/v1/provisioning_status.py b/twilio/rest/flex_api/v1/provisioning_status.py new file mode 100644 index 0000000000..2a7bc5b465 --- /dev/null +++ b/twilio/rest/flex_api/v1/provisioning_status.py @@ -0,0 +1,181 @@ +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 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 ProvisioningStatusInstance(InstanceResource): + + class Status(object): + ACTIVE = "active" + IN_PROGRESS = "in-progress" + NOT_CONFIGURED = "not-configured" + FAILED = "failed" + + """ + :ivar status: + :ivar url: The absolute URL of the resource. + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.status: Optional["ProvisioningStatusInstance.Status"] = payload.get( + "status" + ) + self.url: Optional[str] = payload.get("url") + + self._context: Optional[ProvisioningStatusContext] = None + + @property + def _proxy(self) -> "ProvisioningStatusContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: ProvisioningStatusContext for this ProvisioningStatusInstance + """ + if self._context is None: + self._context = ProvisioningStatusContext( + self._version, + ) + return self._context + + def fetch(self) -> "ProvisioningStatusInstance": + """ + Fetch the ProvisioningStatusInstance + + + :returns: The fetched ProvisioningStatusInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "ProvisioningStatusInstance": + """ + Asynchronous coroutine to fetch the ProvisioningStatusInstance + + + :returns: The fetched ProvisioningStatusInstance + """ + return await self._proxy.fetch_async() + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class ProvisioningStatusContext(InstanceContext): + + def __init__(self, version: Version): + """ + Initialize the ProvisioningStatusContext + + :param version: Version that contains the resource + """ + super().__init__(version) + + self._uri = "/account/provision/status" + + def fetch(self) -> ProvisioningStatusInstance: + """ + Fetch the ProvisioningStatusInstance + + + :returns: The fetched ProvisioningStatusInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return ProvisioningStatusInstance( + self._version, + payload, + ) + + async def fetch_async(self) -> ProvisioningStatusInstance: + """ + Asynchronous coroutine to fetch the ProvisioningStatusInstance + + + :returns: The fetched ProvisioningStatusInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + return ProvisioningStatusInstance( + self._version, + payload, + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class ProvisioningStatusList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the ProvisioningStatusList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + def get(self) -> ProvisioningStatusContext: + """ + Constructs a ProvisioningStatusContext + + """ + return ProvisioningStatusContext(self._version) + + def __call__(self) -> ProvisioningStatusContext: + """ + Constructs a ProvisioningStatusContext + + """ + return ProvisioningStatusContext(self._version) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/flex_api/v1/web_channel.py b/twilio/rest/flex_api/v1/web_channel.py index 436c0be8b2..46e44fcecd 100644 --- a/twilio/rest/flex_api/v1/web_channel.py +++ b/twilio/rest/flex_api/v1/web_channel.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class WebChannelInstance(InstanceResource): + class ChatStatus(object): INACTIVE = "inactive" @@ -155,6 +155,7 @@ def __repr__(self) -> str: class WebChannelContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the WebChannelContext @@ -177,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: """ @@ -189,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: @@ -202,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, @@ -221,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( @@ -245,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"]) @@ -273,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"]) @@ -299,6 +314,7 @@ def __repr__(self) -> str: class WebChannelPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> WebChannelInstance: """ Build an instance of WebChannelInstance @@ -317,6 +333,7 @@ def __repr__(self) -> str: class WebChannelList(ListResource): + def __init__(self, version: Version): """ Initialize the WebChannelList @@ -349,6 +366,7 @@ def create( :returns: The created WebChannelInstance """ + data = values.of( { "FlexFlowSid": flex_flow_sid, @@ -359,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) @@ -389,6 +410,7 @@ async def create_async( :returns: The created WebChannelInstance """ + data = values.of( { "FlexFlowSid": flex_flow_sid, @@ -399,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) @@ -535,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( @@ -562,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 e48012241d..e05ffcdfb5 100644 --- a/twilio/rest/flex_api/v2/__init__.py +++ b/twilio/rest/flex_api/v2/__init__.py @@ -15,10 +15,12 @@ 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 class V2(Version): + def __init__(self, domain: Domain): """ Initialize the V2 version of FlexApi @@ -26,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 b8953bd651..8e5aff8226 100644 --- a/twilio/rest/flex_api/v2/web_channels.py +++ b/twilio/rest/flex_api/v2/web_channels.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, Optional, Union from twilio.base import values @@ -22,7 +21,6 @@ class WebChannelsInstance(InstanceResource): - """ :ivar conversation_sid: The unique string representing the [Conversation resource](https://www.twilio.com/docs/conversations/api/conversation-resource) created. :ivar identity: The unique string representing the User created and should be authorized to participate in the Conversation. For more details, see [User Identity & Access Tokens](https://www.twilio.com/docs/conversations/identity). @@ -45,6 +43,7 @@ def __repr__(self) -> str: class WebChannelsList(ListResource): + def __init__(self, version: Version): """ Initialize the WebChannelsList @@ -59,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, @@ -67,12 +67,14 @@ 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. :returns: The created WebChannelsInstance """ + data = values.of( { "AddressSid": address_sid, @@ -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,12 +112,14 @@ 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. :returns: The created WebChannelsInstance """ + data = values.of( { "AddressSid": address_sid, @@ -115,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/FrontlineApiBase.py b/twilio/rest/frontline_api/FrontlineApiBase.py index 302854dc0c..d9dadc16e9 100644 --- a/twilio/rest/frontline_api/FrontlineApiBase.py +++ b/twilio/rest/frontline_api/FrontlineApiBase.py @@ -17,6 +17,7 @@ class FrontlineApiBase(Domain): + def __init__(self, twilio: Client): """ Initialize the FrontlineApi Domain diff --git a/twilio/rest/frontline_api/v1/__init__.py b/twilio/rest/frontline_api/v1/__init__.py index d2629dd5a0..610ed37194 100644 --- a/twilio/rest/frontline_api/v1/__init__.py +++ b/twilio/rest/frontline_api/v1/__init__.py @@ -19,6 +19,7 @@ class V1(Version): + def __init__(self, domain: Domain): """ Initialize the V1 version of FrontlineApi diff --git a/twilio/rest/frontline_api/v1/user.py b/twilio/rest/frontline_api/v1/user.py index aa279937e8..a45ed2ffee 100644 --- a/twilio/rest/frontline_api/v1/user.py +++ b/twilio/rest/frontline_api/v1/user.py @@ -12,9 +12,8 @@ Do not edit the class manually. """ - from typing import Any, Dict, Optional, Union -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 @@ -22,6 +21,7 @@ class UserInstance(InstanceResource): + class StateType(object): ACTIVE = "active" DEACTIVATED = "deactivated" @@ -146,6 +146,7 @@ def __repr__(self) -> str: class UserContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the UserContext @@ -169,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, @@ -188,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( @@ -216,19 +221,23 @@ def update( :returns: The updated UserInstance """ + data = values.of( { "FriendlyName": friendly_name, "Avatar": avatar, "State": state, - "IsAvailable": is_available, + "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"]) @@ -250,19 +259,23 @@ async def update_async( :returns: The updated UserInstance """ + data = values.of( { "FriendlyName": friendly_name, "Avatar": avatar, "State": state, - "IsAvailable": is_available, + "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"]) @@ -278,6 +291,7 @@ def __repr__(self) -> str: class UserList(ListResource): + def __init__(self, version: Version): """ Initialize the UserList 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 28c5e37a00..2882ec145b 100644 --- a/twilio/rest/media/MediaBase.py +++ b/twilio/rest/iam/IamBase.py @@ -13,23 +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) @@ -40,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/InsightsBase.py b/twilio/rest/insights/InsightsBase.py index efe713ba03..458122cec7 100644 --- a/twilio/rest/insights/InsightsBase.py +++ b/twilio/rest/insights/InsightsBase.py @@ -17,6 +17,7 @@ class InsightsBase(Domain): + def __init__(self, twilio: Client): """ Initialize the Insights Domain diff --git a/twilio/rest/insights/v1/__init__.py b/twilio/rest/insights/v1/__init__.py index b5b6c44863..8f7d1946f0 100644 --- a/twilio/rest/insights/v1/__init__.py +++ b/twilio/rest/insights/v1/__init__.py @@ -23,6 +23,7 @@ class V1(Version): + def __init__(self, domain: Domain): """ Initialize the V1 version of Insights diff --git a/twilio/rest/insights/v1/call/__init__.py b/twilio/rest/insights/v1/call/__init__.py index 32672015ba..cb08aa58aa 100644 --- a/twilio/rest/insights/v1/call/__init__.py +++ b/twilio/rest/insights/v1/call/__init__.py @@ -12,8 +12,8 @@ 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 @@ -26,7 +26,6 @@ class CallInstance(InstanceResource): - """ :ivar sid: :ivar url: @@ -119,6 +118,7 @@ def __repr__(self) -> str: class CallContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the CallContext @@ -147,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, @@ -166,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( @@ -236,6 +240,7 @@ def __repr__(self) -> str: class CallList(ListResource): + def __init__(self, version: Version): """ Initialize the CallList diff --git a/twilio/rest/insights/v1/call/annotation.py b/twilio/rest/insights/v1/call/annotation.py index e9ca222180..6e705d3916 100644 --- a/twilio/rest/insights/v1/call/annotation.py +++ b/twilio/rest/insights/v1/call/annotation.py @@ -12,9 +12,8 @@ Do not edit the class manually. """ - from typing import Any, Dict, List, Optional, Union -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 @@ -22,6 +21,7 @@ class AnnotationInstance(InstanceResource): + class AnsweredBy(object): UNKNOWN_ANSWERED_BY = "unknown_answered_by" HUMAN = "human" @@ -40,12 +40,12 @@ class ConnectivityIssue(object): :ivar account_sid: The unique SID identifier of the Account. :ivar answered_by: :ivar connectivity_issue: - :ivar quality_issues: Specify if the call had any subjective quality issues. Possible values, one or more of: no_quality_issue, low_volume, choppy_robotic, echo, dtmf, latency, owa, static_noise. Use comma separated values to indicate multiple quality issues for the same call - :ivar spam: Specify if the call was a spam call. Use this to provide feedback on whether calls placed from your account were marked as spam, or if inbound calls received by your account were unwanted spam. Is of type Boolean: true, false. Use true if the call was a spam call. - :ivar call_score: Specify the call score. This is of type integer. Use a range of 1-5 to indicate the call experience score, with the following mapping as a reference for rating the call [5: Excellent, 4: Good, 3 : Fair, 2 : Poor, 1: Bad]. - :ivar comment: Specify any comments pertaining to the call. This of type string with a max limit of 100 characters. Twilio does not treat this field as PII, so don’t put any PII in here. - :ivar incident: Associate this call with an incident or support ticket. This is of type string with a max limit of 100 characters. Twilio does not treat this field as PII, so don’t put any PII in here. - :ivar url: The URL of this resource. + :ivar quality_issues: Specifies if the call had any subjective quality issues. Possible values are one or more of `no_quality_issue`, `low_volume`, `choppy_robotic`, `echo`, `dtmf`, `latency`, `owa`, or `static_noise`. + :ivar spam: Specifies if the call was a spam call. Use this to provide feedback on whether calls placed from your account were marked as spam, or if inbound calls received by your account were unwanted spam. Is of type Boolean: true, false. Use true if the call was a spam call. + :ivar call_score: Specifies the Call Score, if available. This is of type integer. Use a range of 1-5 to indicate the call experience score, with the following mapping as a reference for rating the call [5: Excellent, 4: Good, 3 : Fair, 2 : Poor, 1: Bad]. + :ivar comment: Specifies any comments pertaining to the call. Twilio does not treat this field as PII, so no PII should be included in comments. + :ivar incident: Incident or support ticket associated with this call. The `incident` property is of type string with a maximum character limit of 100. Twilio does not treat this field as PII, so no PII should be included in `incident`. + :ivar url: """ def __init__(self, version: Version, payload: Dict[str, Any], call_sid: str): @@ -56,9 +56,9 @@ def __init__(self, version: Version, payload: Dict[str, Any], call_sid: str): self.answered_by: Optional["AnnotationInstance.AnsweredBy"] = payload.get( "answered_by" ) - self.connectivity_issue: Optional[ - "AnnotationInstance.ConnectivityIssue" - ] = payload.get("connectivity_issue") + self.connectivity_issue: Optional["AnnotationInstance.ConnectivityIssue"] = ( + payload.get("connectivity_issue") + ) self.quality_issues: Optional[List[str]] = payload.get("quality_issues") self.spam: Optional[bool] = payload.get("spam") self.call_score: Optional[int] = deserialize.integer(payload.get("call_score")) @@ -121,11 +121,11 @@ def update( :param answered_by: :param connectivity_issue: - :param quality_issues: Specify if the call had any subjective quality issues. Possible values, one or more of: no_quality_issue, low_volume, choppy_robotic, echo, dtmf, latency, owa, static_noise. Use comma separated values to indicate multiple quality issues for the same call - :param spam: Specify if the call was a spam call. Use this to provide feedback on whether calls placed from your account were marked as spam, or if inbound calls received by your account were unwanted spam. Is of type Boolean: true, false. Use true if the call was a spam call. + :param quality_issues: Specify if the call had any subjective quality issues. Possible values, one or more of `no_quality_issue`, `low_volume`, `choppy_robotic`, `echo`, `dtmf`, `latency`, `owa`, `static_noise`. Use comma separated values to indicate multiple quality issues for the same call. + :param spam: A boolean flag to indicate if the call was a spam call. Use this to provide feedback on whether calls placed from your account were marked as spam, or if inbound calls received by your account were unwanted spam. Use `true` if the call was a spam call. :param call_score: Specify the call score. This is of type integer. Use a range of 1-5 to indicate the call experience score, with the following mapping as a reference for rating the call [5: Excellent, 4: Good, 3 : Fair, 2 : Poor, 1: Bad]. - :param comment: Specify any comments pertaining to the call. This of type string with a max limit of 100 characters. Twilio does not treat this field as PII, so don’t put any PII in here. - :param incident: Associate this call with an incident or support ticket. This is of type string with a max limit of 100 characters. Twilio does not treat this field as PII, so don’t put any PII in here. + :param comment: Specify any comments pertaining to the call. `comment` has a maximum character limit of 100. Twilio does not treat this field as PII, so no PII should be included in the `comment`. + :param incident: Associate this call with an incident or support ticket. The `incident` parameter is of type string with a maximum character limit of 100. Twilio does not treat this field as PII, so no PII should be included in `incident`. :returns: The updated AnnotationInstance """ @@ -156,11 +156,11 @@ async def update_async( :param answered_by: :param connectivity_issue: - :param quality_issues: Specify if the call had any subjective quality issues. Possible values, one or more of: no_quality_issue, low_volume, choppy_robotic, echo, dtmf, latency, owa, static_noise. Use comma separated values to indicate multiple quality issues for the same call - :param spam: Specify if the call was a spam call. Use this to provide feedback on whether calls placed from your account were marked as spam, or if inbound calls received by your account were unwanted spam. Is of type Boolean: true, false. Use true if the call was a spam call. + :param quality_issues: Specify if the call had any subjective quality issues. Possible values, one or more of `no_quality_issue`, `low_volume`, `choppy_robotic`, `echo`, `dtmf`, `latency`, `owa`, `static_noise`. Use comma separated values to indicate multiple quality issues for the same call. + :param spam: A boolean flag to indicate if the call was a spam call. Use this to provide feedback on whether calls placed from your account were marked as spam, or if inbound calls received by your account were unwanted spam. Use `true` if the call was a spam call. :param call_score: Specify the call score. This is of type integer. Use a range of 1-5 to indicate the call experience score, with the following mapping as a reference for rating the call [5: Excellent, 4: Good, 3 : Fair, 2 : Poor, 1: Bad]. - :param comment: Specify any comments pertaining to the call. This of type string with a max limit of 100 characters. Twilio does not treat this field as PII, so don’t put any PII in here. - :param incident: Associate this call with an incident or support ticket. This is of type string with a max limit of 100 characters. Twilio does not treat this field as PII, so don’t put any PII in here. + :param comment: Specify any comments pertaining to the call. `comment` has a maximum character limit of 100. Twilio does not treat this field as PII, so no PII should be included in the `comment`. + :param incident: Associate this call with an incident or support ticket. The `incident` parameter is of type string with a maximum character limit of 100. Twilio does not treat this field as PII, so no PII should be included in `incident`. :returns: The updated AnnotationInstance """ @@ -185,6 +185,7 @@ def __repr__(self) -> str: class AnnotationContext(InstanceContext): + def __init__(self, version: Version, call_sid: str): """ Initialize the AnnotationContext @@ -208,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, @@ -227,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( @@ -255,30 +260,34 @@ def update( :param answered_by: :param connectivity_issue: - :param quality_issues: Specify if the call had any subjective quality issues. Possible values, one or more of: no_quality_issue, low_volume, choppy_robotic, echo, dtmf, latency, owa, static_noise. Use comma separated values to indicate multiple quality issues for the same call - :param spam: Specify if the call was a spam call. Use this to provide feedback on whether calls placed from your account were marked as spam, or if inbound calls received by your account were unwanted spam. Is of type Boolean: true, false. Use true if the call was a spam call. + :param quality_issues: Specify if the call had any subjective quality issues. Possible values, one or more of `no_quality_issue`, `low_volume`, `choppy_robotic`, `echo`, `dtmf`, `latency`, `owa`, `static_noise`. Use comma separated values to indicate multiple quality issues for the same call. + :param spam: A boolean flag to indicate if the call was a spam call. Use this to provide feedback on whether calls placed from your account were marked as spam, or if inbound calls received by your account were unwanted spam. Use `true` if the call was a spam call. :param call_score: Specify the call score. This is of type integer. Use a range of 1-5 to indicate the call experience score, with the following mapping as a reference for rating the call [5: Excellent, 4: Good, 3 : Fair, 2 : Poor, 1: Bad]. - :param comment: Specify any comments pertaining to the call. This of type string with a max limit of 100 characters. Twilio does not treat this field as PII, so don’t put any PII in here. - :param incident: Associate this call with an incident or support ticket. This is of type string with a max limit of 100 characters. Twilio does not treat this field as PII, so don’t put any PII in here. + :param comment: Specify any comments pertaining to the call. `comment` has a maximum character limit of 100. Twilio does not treat this field as PII, so no PII should be included in the `comment`. + :param incident: Associate this call with an incident or support ticket. The `incident` parameter is of type string with a maximum character limit of 100. Twilio does not treat this field as PII, so no PII should be included in `incident`. :returns: The updated AnnotationInstance """ + data = values.of( { "AnsweredBy": answered_by, "ConnectivityIssue": connectivity_issue, "QualityIssues": quality_issues, - "Spam": spam, + "Spam": serialize.boolean_to_string(spam), "CallScore": call_score, "Comment": comment, "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( @@ -302,30 +311,34 @@ async def update_async( :param answered_by: :param connectivity_issue: - :param quality_issues: Specify if the call had any subjective quality issues. Possible values, one or more of: no_quality_issue, low_volume, choppy_robotic, echo, dtmf, latency, owa, static_noise. Use comma separated values to indicate multiple quality issues for the same call - :param spam: Specify if the call was a spam call. Use this to provide feedback on whether calls placed from your account were marked as spam, or if inbound calls received by your account were unwanted spam. Is of type Boolean: true, false. Use true if the call was a spam call. + :param quality_issues: Specify if the call had any subjective quality issues. Possible values, one or more of `no_quality_issue`, `low_volume`, `choppy_robotic`, `echo`, `dtmf`, `latency`, `owa`, `static_noise`. Use comma separated values to indicate multiple quality issues for the same call. + :param spam: A boolean flag to indicate if the call was a spam call. Use this to provide feedback on whether calls placed from your account were marked as spam, or if inbound calls received by your account were unwanted spam. Use `true` if the call was a spam call. :param call_score: Specify the call score. This is of type integer. Use a range of 1-5 to indicate the call experience score, with the following mapping as a reference for rating the call [5: Excellent, 4: Good, 3 : Fair, 2 : Poor, 1: Bad]. - :param comment: Specify any comments pertaining to the call. This of type string with a max limit of 100 characters. Twilio does not treat this field as PII, so don’t put any PII in here. - :param incident: Associate this call with an incident or support ticket. This is of type string with a max limit of 100 characters. Twilio does not treat this field as PII, so don’t put any PII in here. + :param comment: Specify any comments pertaining to the call. `comment` has a maximum character limit of 100. Twilio does not treat this field as PII, so no PII should be included in the `comment`. + :param incident: Associate this call with an incident or support ticket. The `incident` parameter is of type string with a maximum character limit of 100. Twilio does not treat this field as PII, so no PII should be included in `incident`. :returns: The updated AnnotationInstance """ + data = values.of( { "AnsweredBy": answered_by, "ConnectivityIssue": connectivity_issue, "QualityIssues": quality_issues, - "Spam": spam, + "Spam": serialize.boolean_to_string(spam), "CallScore": call_score, "Comment": comment, "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( @@ -343,6 +356,7 @@ def __repr__(self) -> str: class AnnotationList(ListResource): + def __init__(self, version: Version, call_sid: str): """ Initialize the AnnotationList diff --git a/twilio/rest/insights/v1/call/call_summary.py b/twilio/rest/insights/v1/call/call_summary.py index dc871eb8b7..e21af100a1 100644 --- a/twilio/rest/insights/v1/call/call_summary.py +++ b/twilio/rest/insights/v1/call/call_summary.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import datetime from typing import Any, Dict, List, Optional, Union from twilio.base import deserialize, values @@ -23,6 +22,7 @@ class CallSummaryInstance(InstanceResource): + class AnsweredBy(object): UNKNOWN = "unknown" MACHINE_START = "machine_start" @@ -47,35 +47,36 @@ class CallType(object): SIP = "sip" TRUNKING = "trunking" CLIENT = "client" + WHATSAPP = "whatsapp" class ProcessingState(object): COMPLETE = "complete" PARTIAL = "partial" """ - :ivar account_sid: - :ivar call_sid: + :ivar account_sid: The unique SID identifier of the Account. + :ivar call_sid: The unique SID identifier of the Call. :ivar call_type: :ivar call_state: :ivar answered_by: :ivar processing_state: - :ivar created_time: - :ivar start_time: - :ivar end_time: - :ivar duration: - :ivar connect_duration: - :ivar _from: - :ivar to: - :ivar carrier_edge: - :ivar client_edge: - :ivar sdk_edge: - :ivar sip_edge: - :ivar tags: - :ivar url: - :ivar attributes: - :ivar properties: - :ivar trust: - :ivar annotation: + :ivar created_time: The time at which the Call was created, given in ISO 8601 format. Can be different from `start_time` in the event of queueing due to CPS + :ivar start_time: The time at which the Call was started, given in ISO 8601 format. + :ivar end_time: The time at which the Call was ended, given in ISO 8601 format. + :ivar duration: Duration between when the call was initiated and the call was ended + :ivar connect_duration: Duration between when the call was answered and when it ended + :ivar _from: The calling party. + :ivar to: The called party. + :ivar carrier_edge: Contains metrics and properties for the Twilio media gateway of a PSTN call. + :ivar client_edge: Contains metrics and properties for the Twilio media gateway of a Client call. + :ivar sdk_edge: Contains metrics and properties for the SDK sensor library for Client calls. + :ivar sip_edge: Contains metrics and properties for the Twilio media gateway of a SIP Interface or Trunking call. + :ivar tags: Tags applied to calls by Voice Insights analysis indicating a condition that could result in subjective degradation of the call quality. + :ivar url: The URL of this resource. + :ivar attributes: Attributes capturing call-flow-specific details. + :ivar properties: Contains edge-agnostic call-level details. + :ivar trust: Contains trusted communications details including Branded Call and verified caller ID. + :ivar annotation: Programmatically labeled annotations for the Call. Developers can update the Call Summary records with Annotation during or after a Call. Annotations can be updated as long as the Call Summary record is addressable via the API. """ def __init__(self, version: Version, payload: Dict[str, Any], call_sid: str): @@ -92,9 +93,9 @@ def __init__(self, version: Version, payload: Dict[str, Any], call_sid: str): self.answered_by: Optional["CallSummaryInstance.AnsweredBy"] = payload.get( "answered_by" ) - self.processing_state: Optional[ - "CallSummaryInstance.ProcessingState" - ] = payload.get("processing_state") + self.processing_state: Optional["CallSummaryInstance.ProcessingState"] = ( + payload.get("processing_state") + ) self.created_time: Optional[datetime] = deserialize.iso8601_datetime( payload.get("created_time") ) @@ -150,7 +151,7 @@ def fetch( """ Fetch the CallSummaryInstance - :param processing_state: + :param processing_state: The Processing State of this Call Summary. One of `complete`, `partial` or `all`. :returns: The fetched CallSummaryInstance """ @@ -167,7 +168,7 @@ async def fetch_async( """ Asynchronous coroutine to fetch the CallSummaryInstance - :param processing_state: + :param processing_state: The Processing State of this Call Summary. One of `complete`, `partial` or `all`. :returns: The fetched CallSummaryInstance """ @@ -186,12 +187,13 @@ def __repr__(self) -> str: class CallSummaryContext(InstanceContext): + def __init__(self, version: Version, call_sid: str): """ Initialize the CallSummaryContext :param version: Version that contains the resource - :param call_sid: + :param call_sid: The unique SID identifier of the Call. """ super().__init__(version) @@ -210,7 +212,7 @@ def fetch( """ Fetch the CallSummaryInstance - :param processing_state: + :param processing_state: The Processing State of this Call Summary. One of `complete`, `partial` or `all`. :returns: The fetched CallSummaryInstance """ @@ -221,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, @@ -238,7 +246,7 @@ async def fetch_async( """ Asynchronous coroutine to fetch the CallSummaryInstance - :param processing_state: + :param processing_state: The Processing State of this Call Summary. One of `complete`, `partial` or `all`. :returns: The fetched CallSummaryInstance """ @@ -249,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( @@ -270,12 +282,13 @@ def __repr__(self) -> str: class CallSummaryList(ListResource): + def __init__(self, version: Version, call_sid: str): """ Initialize the CallSummaryList :param version: Version that contains the resource - :param call_sid: + :param call_sid: The unique SID identifier of the Call. """ super().__init__(version) diff --git a/twilio/rest/insights/v1/call/event.py b/twilio/rest/insights/v1/call/event.py index 22f6c52515..98dce5eb71 100644 --- a/twilio/rest/insights/v1/call/event.py +++ b/twilio/rest/insights/v1/call/event.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import values @@ -23,6 +22,7 @@ class EventInstance(InstanceResource): + class Level(object): UNKNOWN = "UNKNOWN" DEBUG = "DEBUG" @@ -38,17 +38,17 @@ class TwilioEdge(object): CLIENT_EDGE = "client_edge" """ - :ivar timestamp: - :ivar call_sid: - :ivar account_sid: + :ivar timestamp: Event time. + :ivar call_sid: The unique SID identifier of the Call. + :ivar account_sid: The unique SID identifier of the Account. :ivar edge: - :ivar group: + :ivar group: Event group. :ivar level: - :ivar name: - :ivar carrier_edge: - :ivar sip_edge: - :ivar sdk_edge: - :ivar client_edge: + :ivar name: Event name. + :ivar carrier_edge: Represents the connection between Twilio and our immediate carrier partners. The events here describe the call lifecycle as reported by Twilio's carrier media gateways. + :ivar sip_edge: Represents the Twilio media gateway for SIP interface and SIP trunking calls. The events here describe the call lifecycle as reported by Twilio's public media gateways. + :ivar sdk_edge: Represents the Voice SDK running locally in the browser or in the Android/iOS application. The events here are emitted by the Voice SDK in response to certain call progress events, network changes, or call quality conditions. + :ivar client_edge: Represents the Twilio media gateway for Client calls. The events here describe the call lifecycle as reported by Twilio's Voice SDK media gateways. """ def __init__(self, version: Version, payload: Dict[str, Any], call_sid: str): @@ -81,6 +81,7 @@ def __repr__(self) -> str: class EventPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> EventInstance: """ Build an instance of EventInstance @@ -101,12 +102,13 @@ def __repr__(self) -> str: class EventList(ListResource): + def __init__(self, version: Version, call_sid: str): """ Initialize the EventList :param version: Version that contains the resource - :param call_sid: + :param call_sid: The unique SID identifier of the Call. """ super().__init__(version) @@ -129,7 +131,7 @@ def stream( is reached. The results are returned as a generator, so this operation is memory efficient. - :param "EventInstance.TwilioEdge" edge: + :param "EventInstance.TwilioEdge" edge: The Edge of this Event. One of `unknown_edge`, `carrier_edge`, `sip_edge`, `sdk_edge` or `client_edge`. :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 @@ -156,7 +158,7 @@ async def stream_async( is reached. The results are returned as a generator, so this operation is memory efficient. - :param "EventInstance.TwilioEdge" edge: + :param "EventInstance.TwilioEdge" edge: The Edge of this Event. One of `unknown_edge`, `carrier_edge`, `sip_edge`, `sdk_edge` or `client_edge`. :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 @@ -182,7 +184,7 @@ def list( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param "EventInstance.TwilioEdge" edge: + :param "EventInstance.TwilioEdge" edge: The Edge of this Event. One of `unknown_edge`, `carrier_edge`, `sip_edge`, `sdk_edge` or `client_edge`. :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 @@ -211,7 +213,7 @@ async def list_async( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param "EventInstance.TwilioEdge" edge: + :param "EventInstance.TwilioEdge" edge: The Edge of this Event. One of `unknown_edge`, `carrier_edge`, `sip_edge`, `sdk_edge` or `client_edge`. :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 @@ -241,7 +243,7 @@ def page( Retrieve a single page of EventInstance records from the API. Request is executed immediately - :param edge: + :param edge: The Edge of this Event. One of `unknown_edge`, `carrier_edge`, `sip_edge`, `sdk_edge` or `client_edge`. :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 @@ -257,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( @@ -271,7 +279,7 @@ async def page_async( Asynchronously retrieve a single page of EventInstance records from the API. Request is executed immediately - :param edge: + :param edge: The Edge of this Event. One of `unknown_edge`, `carrier_edge`, `sip_edge`, `sdk_edge` or `client_edge`. :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 @@ -287,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 06bb972620..77f770ae7c 100644 --- a/twilio/rest/insights/v1/call/metric.py +++ b/twilio/rest/insights/v1/call/metric.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import values @@ -23,6 +22,7 @@ class MetricInstance(InstanceResource): + class StreamDirection(object): UNKNOWN = "unknown" INBOUND = "inbound" @@ -37,15 +37,15 @@ class TwilioEdge(object): CLIENT_EDGE = "client_edge" """ - :ivar timestamp: - :ivar call_sid: - :ivar account_sid: + :ivar timestamp: Timestamp of metric sample. Samples are taken every 10 seconds and contain the metrics for the previous 10 seconds. + :ivar call_sid: The unique SID identifier of the Call. + :ivar account_sid: The unique SID identifier of the Account. :ivar edge: :ivar direction: - :ivar carrier_edge: - :ivar sip_edge: - :ivar sdk_edge: - :ivar client_edge: + :ivar carrier_edge: Contains metrics and properties for the Twilio media gateway of a PSTN call. + :ivar sip_edge: Contains metrics and properties for the Twilio media gateway of a SIP Interface or Trunking call. + :ivar sdk_edge: Contains metrics and properties for the SDK sensor library for Client calls. + :ivar client_edge: Contains metrics and properties for the Twilio media gateway of a Client call. """ def __init__(self, version: Version, payload: Dict[str, Any], call_sid: str): @@ -78,6 +78,7 @@ def __repr__(self) -> str: class MetricPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> MetricInstance: """ Build an instance of MetricInstance @@ -98,12 +99,13 @@ def __repr__(self) -> str: class MetricList(ListResource): + def __init__(self, version: Version, call_sid: str): """ Initialize the MetricList :param version: Version that contains the resource - :param call_sid: + :param call_sid: The unique SID identifier of the Call. """ super().__init__(version) @@ -127,8 +129,8 @@ def stream( is reached. The results are returned as a generator, so this operation is memory efficient. - :param "MetricInstance.TwilioEdge" edge: - :param "MetricInstance.StreamDirection" direction: + :param "MetricInstance.TwilioEdge" edge: The Edge of this Metric. One of `unknown_edge`, `carrier_edge`, `sip_edge`, `sdk_edge` or `client_edge`. + :param "MetricInstance.StreamDirection" direction: The Direction of this Metric. One of `unknown`, `inbound`, `outbound` or `both`. :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 @@ -156,8 +158,8 @@ async def stream_async( is reached. The results are returned as a generator, so this operation is memory efficient. - :param "MetricInstance.TwilioEdge" edge: - :param "MetricInstance.StreamDirection" direction: + :param "MetricInstance.TwilioEdge" edge: The Edge of this Metric. One of `unknown_edge`, `carrier_edge`, `sip_edge`, `sdk_edge` or `client_edge`. + :param "MetricInstance.StreamDirection" direction: The Direction of this Metric. One of `unknown`, `inbound`, `outbound` or `both`. :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 @@ -186,8 +188,8 @@ def list( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param "MetricInstance.TwilioEdge" edge: - :param "MetricInstance.StreamDirection" direction: + :param "MetricInstance.TwilioEdge" edge: The Edge of this Metric. One of `unknown_edge`, `carrier_edge`, `sip_edge`, `sdk_edge` or `client_edge`. + :param "MetricInstance.StreamDirection" direction: The Direction of this Metric. One of `unknown`, `inbound`, `outbound` or `both`. :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 @@ -218,8 +220,8 @@ async def list_async( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param "MetricInstance.TwilioEdge" edge: - :param "MetricInstance.StreamDirection" direction: + :param "MetricInstance.TwilioEdge" edge: The Edge of this Metric. One of `unknown_edge`, `carrier_edge`, `sip_edge`, `sdk_edge` or `client_edge`. + :param "MetricInstance.StreamDirection" direction: The Direction of this Metric. One of `unknown`, `inbound`, `outbound` or `both`. :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 @@ -251,8 +253,8 @@ def page( Retrieve a single page of MetricInstance records from the API. Request is executed immediately - :param edge: - :param direction: + :param edge: The Edge of this Metric. One of `unknown_edge`, `carrier_edge`, `sip_edge`, `sdk_edge` or `client_edge`. + :param direction: The Direction of this Metric. One of `unknown`, `inbound`, `outbound` or `both`. :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 @@ -269,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( @@ -284,8 +292,8 @@ async def page_async( Asynchronously retrieve a single page of MetricInstance records from the API. Request is executed immediately - :param edge: - :param direction: + :param edge: The Edge of this Metric. One of `unknown_edge`, `carrier_edge`, `sip_edge`, `sdk_edge` or `client_edge`. + :param direction: The Direction of this Metric. One of `unknown`, `inbound`, `outbound` or `both`. :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 @@ -302,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 4e428c0a0d..0a75e38454 100644 --- a/twilio/rest/insights/v1/call_summaries.py +++ b/twilio/rest/insights/v1/call_summaries.py @@ -12,10 +12,9 @@ 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 import deserialize, serialize, values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource @@ -24,6 +23,7 @@ class CallSummariesInstance(InstanceResource): + class AnsweredBy(object): UNKNOWN = "unknown" MACHINE_START = "machine_start" @@ -48,6 +48,7 @@ class CallType(object): SIP = "sip" TRUNKING = "trunking" CLIENT = "client" + WHATSAPP = "whatsapp" class ProcessingState(object): COMPLETE = "complete" @@ -64,28 +65,29 @@ class SortBy(object): END_TIME = "end_time" """ - :ivar account_sid: - :ivar call_sid: + :ivar account_sid: The unique SID identifier of the Account. + :ivar call_sid: The unique SID identifier of the Call. :ivar answered_by: :ivar call_type: :ivar call_state: :ivar processing_state: - :ivar created_time: - :ivar start_time: - :ivar end_time: - :ivar duration: - :ivar connect_duration: - :ivar _from: - :ivar to: - :ivar carrier_edge: - :ivar client_edge: - :ivar sdk_edge: - :ivar sip_edge: - :ivar tags: - :ivar url: - :ivar attributes: - :ivar properties: - :ivar trust: + :ivar created_time: The time at which the Call was created, given in ISO 8601 format. Can be different from `start_time` in the event of queueing due to CPS + :ivar start_time: The time at which the Call was started, given in ISO 8601 format. + :ivar end_time: The time at which the Call was ended, given in ISO 8601 format. + :ivar duration: Duration between when the call was initiated and the call was ended + :ivar connect_duration: Duration between when the call was answered and when it ended + :ivar _from: The calling party. + :ivar to: The called party. + :ivar carrier_edge: Contains metrics and properties for the Twilio media gateway of a PSTN call. + :ivar client_edge: Contains metrics and properties for the Twilio media gateway of a Client call. + :ivar sdk_edge: Contains metrics and properties for the SDK sensor library for Client calls. + :ivar sip_edge: Contains metrics and properties for the Twilio media gateway of a SIP Interface or Trunking call. + :ivar tags: Tags applied to calls by Voice Insights analysis indicating a condition that could result in subjective degradation of the call quality. + :ivar url: The URL of this resource. + :ivar attributes: Attributes capturing call-flow-specific details. + :ivar properties: Contains edge-agnostic call-level details. + :ivar trust: Contains trusted communications details including Branded Call and verified caller ID. + :ivar annotation: """ def __init__(self, version: Version, payload: Dict[str, Any]): @@ -102,9 +104,9 @@ def __init__(self, version: Version, payload: Dict[str, Any]): self.call_state: Optional["CallSummariesInstance.CallState"] = payload.get( "call_state" ) - self.processing_state: Optional[ - "CallSummariesInstance.ProcessingState" - ] = payload.get("processing_state") + self.processing_state: Optional["CallSummariesInstance.ProcessingState"] = ( + payload.get("processing_state") + ) self.created_time: Optional[datetime] = deserialize.iso8601_datetime( payload.get("created_time") ) @@ -129,6 +131,7 @@ def __init__(self, version: Version, payload: Dict[str, Any]): self.attributes: Optional[Dict[str, object]] = payload.get("attributes") self.properties: Optional[Dict[str, object]] = payload.get("properties") self.trust: Optional[Dict[str, object]] = payload.get("trust") + self.annotation: Optional[Dict[str, object]] = payload.get("annotation") def __repr__(self) -> str: """ @@ -141,6 +144,7 @@ def __repr__(self) -> str: class CallSummariesPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> CallSummariesInstance: """ Build an instance of CallSummariesInstance @@ -159,6 +163,7 @@ def __repr__(self) -> str: class CallSummariesList(ListResource): + def __init__(self, version: Version): """ Initialize the CallSummariesList @@ -178,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, @@ -193,6 +197,20 @@ def stream( subaccount: Union[str, object] = values.unset, abnormal_session: Union[bool, object] = values.unset, answered_by: Union["CallSummariesInstance.AnsweredBy", object] = values.unset, + answered_by_annotation: Union[str, object] = values.unset, + connectivity_issue_annotation: Union[str, object] = values.unset, + 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]: @@ -202,25 +220,38 @@ def stream( is reached. The results are returned as a generator, so this operation is memory efficient. - :param str from_: - :param str to: - :param str from_carrier: - :param str to_carrier: - :param str from_country_code: - :param str to_country_code: - :param bool branded: - :param bool verified_caller: - :param bool has_tag: - :param str start_time: - :param str end_time: - :param str call_type: - :param str call_state: - :param str direction: - :param "CallSummariesInstance.ProcessingStateRequest" processing_state: - :param "CallSummariesInstance.SortBy" sort_by: - :param str subaccount: - :param bool abnormal_session: - :param "CallSummariesInstance.AnsweredBy" answered_by: + :param str from_: A calling party. Could be an E.164 number, a SIP URI, or a Twilio Client registered name. + :param str to: A called party. Could be an E.164 number, a SIP URI, or a Twilio Client registered name. + :param str from_carrier: An origination carrier. + :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 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. + :param str call_type: A Call Type of the calls. One of `carrier`, `sip`, `trunking` or `client`. + :param str call_state: A Call State of the calls. One of `ringing`, `completed`, `busy`, `fail`, `noanswer`, `canceled`, `answered`, `undialed`. + :param str direction: A Direction of the calls. One of `outbound_api`, `outbound_dial`, `inbound`, `trunking_originating`, `trunking_terminating`. + :param "CallSummariesInstance.ProcessingStateRequest" processing_state: A Processing State of the Call Summaries. One of `completed`, `partial` or `all`. + :param "CallSummariesInstance.SortBy" sort_by: A Sort By criterion for the returned list of Call Summaries. One of `start_time` or `end_time`. + :param str subaccount: A unique SID identifier of a Subaccount. + :param bool abnormal_session: A boolean flag indicating an abnormal session where the last SIP response was not 200 OK. + :param "CallSummariesInstance.AnsweredBy" answered_by: An Answered By value for the calls based on `Answering Machine Detection (AMD)`. One of `unknown`, `machine_start`, `machine_end_beep`, `machine_end_silence`, `machine_end_other`, `human` or `fax`. + :param str answered_by_annotation: Either machine or human. + :param str connectivity_issue_annotation: A Connectivity Issue with the calls. One of `no_connectivity_issue`, `invalid_number`, `caller_id`, `dropped_call`, or `number_reachability`. + :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 @@ -238,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, @@ -251,6 +281,20 @@ def stream( subaccount=subaccount, abnormal_session=abnormal_session, answered_by=answered_by, + answered_by_annotation=answered_by_annotation, + connectivity_issue_annotation=connectivity_issue_annotation, + 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"], ) @@ -264,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, @@ -279,6 +322,20 @@ async def stream_async( subaccount: Union[str, object] = values.unset, abnormal_session: Union[bool, object] = values.unset, answered_by: Union["CallSummariesInstance.AnsweredBy", object] = values.unset, + answered_by_annotation: Union[str, object] = values.unset, + connectivity_issue_annotation: Union[str, object] = values.unset, + 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]: @@ -288,25 +345,38 @@ async def stream_async( is reached. The results are returned as a generator, so this operation is memory efficient. - :param str from_: - :param str to: - :param str from_carrier: - :param str to_carrier: - :param str from_country_code: - :param str to_country_code: - :param bool branded: - :param bool verified_caller: - :param bool has_tag: - :param str start_time: - :param str end_time: - :param str call_type: - :param str call_state: - :param str direction: - :param "CallSummariesInstance.ProcessingStateRequest" processing_state: - :param "CallSummariesInstance.SortBy" sort_by: - :param str subaccount: - :param bool abnormal_session: - :param "CallSummariesInstance.AnsweredBy" answered_by: + :param str from_: A calling party. Could be an E.164 number, a SIP URI, or a Twilio Client registered name. + :param str to: A called party. Could be an E.164 number, a SIP URI, or a Twilio Client registered name. + :param str from_carrier: An origination carrier. + :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 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. + :param str call_type: A Call Type of the calls. One of `carrier`, `sip`, `trunking` or `client`. + :param str call_state: A Call State of the calls. One of `ringing`, `completed`, `busy`, `fail`, `noanswer`, `canceled`, `answered`, `undialed`. + :param str direction: A Direction of the calls. One of `outbound_api`, `outbound_dial`, `inbound`, `trunking_originating`, `trunking_terminating`. + :param "CallSummariesInstance.ProcessingStateRequest" processing_state: A Processing State of the Call Summaries. One of `completed`, `partial` or `all`. + :param "CallSummariesInstance.SortBy" sort_by: A Sort By criterion for the returned list of Call Summaries. One of `start_time` or `end_time`. + :param str subaccount: A unique SID identifier of a Subaccount. + :param bool abnormal_session: A boolean flag indicating an abnormal session where the last SIP response was not 200 OK. + :param "CallSummariesInstance.AnsweredBy" answered_by: An Answered By value for the calls based on `Answering Machine Detection (AMD)`. One of `unknown`, `machine_start`, `machine_end_beep`, `machine_end_silence`, `machine_end_other`, `human` or `fax`. + :param str answered_by_annotation: Either machine or human. + :param str connectivity_issue_annotation: A Connectivity Issue with the calls. One of `no_connectivity_issue`, `invalid_number`, `caller_id`, `dropped_call`, or `number_reachability`. + :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 @@ -324,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, @@ -337,6 +406,20 @@ async def stream_async( subaccount=subaccount, abnormal_session=abnormal_session, answered_by=answered_by, + answered_by_annotation=answered_by_annotation, + connectivity_issue_annotation=connectivity_issue_annotation, + 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"], ) @@ -350,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, @@ -365,6 +447,20 @@ def list( subaccount: Union[str, object] = values.unset, abnormal_session: Union[bool, object] = values.unset, answered_by: Union["CallSummariesInstance.AnsweredBy", object] = values.unset, + answered_by_annotation: Union[str, object] = values.unset, + connectivity_issue_annotation: Union[str, object] = values.unset, + 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]: @@ -373,25 +469,38 @@ def list( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param str from_: - :param str to: - :param str from_carrier: - :param str to_carrier: - :param str from_country_code: - :param str to_country_code: - :param bool branded: - :param bool verified_caller: - :param bool has_tag: - :param str start_time: - :param str end_time: - :param str call_type: - :param str call_state: - :param str direction: - :param "CallSummariesInstance.ProcessingStateRequest" processing_state: - :param "CallSummariesInstance.SortBy" sort_by: - :param str subaccount: - :param bool abnormal_session: - :param "CallSummariesInstance.AnsweredBy" answered_by: + :param str from_: A calling party. Could be an E.164 number, a SIP URI, or a Twilio Client registered name. + :param str to: A called party. Could be an E.164 number, a SIP URI, or a Twilio Client registered name. + :param str from_carrier: An origination carrier. + :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 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. + :param str call_type: A Call Type of the calls. One of `carrier`, `sip`, `trunking` or `client`. + :param str call_state: A Call State of the calls. One of `ringing`, `completed`, `busy`, `fail`, `noanswer`, `canceled`, `answered`, `undialed`. + :param str direction: A Direction of the calls. One of `outbound_api`, `outbound_dial`, `inbound`, `trunking_originating`, `trunking_terminating`. + :param "CallSummariesInstance.ProcessingStateRequest" processing_state: A Processing State of the Call Summaries. One of `completed`, `partial` or `all`. + :param "CallSummariesInstance.SortBy" sort_by: A Sort By criterion for the returned list of Call Summaries. One of `start_time` or `end_time`. + :param str subaccount: A unique SID identifier of a Subaccount. + :param bool abnormal_session: A boolean flag indicating an abnormal session where the last SIP response was not 200 OK. + :param "CallSummariesInstance.AnsweredBy" answered_by: An Answered By value for the calls based on `Answering Machine Detection (AMD)`. One of `unknown`, `machine_start`, `machine_end_beep`, `machine_end_silence`, `machine_end_other`, `human` or `fax`. + :param str answered_by_annotation: Either machine or human. + :param str connectivity_issue_annotation: A Connectivity Issue with the calls. One of `no_connectivity_issue`, `invalid_number`, `caller_id`, `dropped_call`, or `number_reachability`. + :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 @@ -409,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, @@ -422,6 +530,20 @@ def list( subaccount=subaccount, abnormal_session=abnormal_session, answered_by=answered_by, + answered_by_annotation=answered_by_annotation, + connectivity_issue_annotation=connectivity_issue_annotation, + 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, ) @@ -435,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, @@ -450,6 +571,20 @@ async def list_async( subaccount: Union[str, object] = values.unset, abnormal_session: Union[bool, object] = values.unset, answered_by: Union["CallSummariesInstance.AnsweredBy", object] = values.unset, + answered_by_annotation: Union[str, object] = values.unset, + connectivity_issue_annotation: Union[str, object] = values.unset, + 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]: @@ -458,25 +593,38 @@ async def list_async( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param str from_: - :param str to: - :param str from_carrier: - :param str to_carrier: - :param str from_country_code: - :param str to_country_code: - :param bool branded: - :param bool verified_caller: - :param bool has_tag: - :param str start_time: - :param str end_time: - :param str call_type: - :param str call_state: - :param str direction: - :param "CallSummariesInstance.ProcessingStateRequest" processing_state: - :param "CallSummariesInstance.SortBy" sort_by: - :param str subaccount: - :param bool abnormal_session: - :param "CallSummariesInstance.AnsweredBy" answered_by: + :param str from_: A calling party. Could be an E.164 number, a SIP URI, or a Twilio Client registered name. + :param str to: A called party. Could be an E.164 number, a SIP URI, or a Twilio Client registered name. + :param str from_carrier: An origination carrier. + :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 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. + :param str call_type: A Call Type of the calls. One of `carrier`, `sip`, `trunking` or `client`. + :param str call_state: A Call State of the calls. One of `ringing`, `completed`, `busy`, `fail`, `noanswer`, `canceled`, `answered`, `undialed`. + :param str direction: A Direction of the calls. One of `outbound_api`, `outbound_dial`, `inbound`, `trunking_originating`, `trunking_terminating`. + :param "CallSummariesInstance.ProcessingStateRequest" processing_state: A Processing State of the Call Summaries. One of `completed`, `partial` or `all`. + :param "CallSummariesInstance.SortBy" sort_by: A Sort By criterion for the returned list of Call Summaries. One of `start_time` or `end_time`. + :param str subaccount: A unique SID identifier of a Subaccount. + :param bool abnormal_session: A boolean flag indicating an abnormal session where the last SIP response was not 200 OK. + :param "CallSummariesInstance.AnsweredBy" answered_by: An Answered By value for the calls based on `Answering Machine Detection (AMD)`. One of `unknown`, `machine_start`, `machine_end_beep`, `machine_end_silence`, `machine_end_other`, `human` or `fax`. + :param str answered_by_annotation: Either machine or human. + :param str connectivity_issue_annotation: A Connectivity Issue with the calls. One of `no_connectivity_issue`, `invalid_number`, `caller_id`, `dropped_call`, or `number_reachability`. + :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 @@ -495,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, @@ -508,6 +655,20 @@ async def list_async( subaccount=subaccount, abnormal_session=abnormal_session, answered_by=answered_by, + answered_by_annotation=answered_by_annotation, + connectivity_issue_annotation=connectivity_issue_annotation, + 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, ) @@ -521,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, @@ -536,6 +696,20 @@ def page( subaccount: Union[str, object] = values.unset, abnormal_session: Union[bool, object] = values.unset, answered_by: Union["CallSummariesInstance.AnsweredBy", object] = values.unset, + answered_by_annotation: Union[str, object] = values.unset, + connectivity_issue_annotation: Union[str, object] = values.unset, + 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, @@ -544,25 +718,38 @@ def page( Retrieve a single page of CallSummariesInstance records from the API. Request is executed immediately - :param from_: - :param to: - :param from_carrier: - :param to_carrier: - :param from_country_code: - :param to_country_code: - :param branded: - :param verified_caller: - :param has_tag: - :param start_time: - :param end_time: - :param call_type: - :param call_state: - :param direction: - :param processing_state: - :param sort_by: - :param subaccount: - :param abnormal_session: - :param answered_by: + :param from_: A calling party. Could be an E.164 number, a SIP URI, or a Twilio Client registered name. + :param to: A called party. Could be an E.164 number, a SIP URI, or a Twilio Client registered name. + :param from_carrier: An origination carrier. + :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 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. + :param call_type: A Call Type of the calls. One of `carrier`, `sip`, `trunking` or `client`. + :param call_state: A Call State of the calls. One of `ringing`, `completed`, `busy`, `fail`, `noanswer`, `canceled`, `answered`, `undialed`. + :param direction: A Direction of the calls. One of `outbound_api`, `outbound_dial`, `inbound`, `trunking_originating`, `trunking_terminating`. + :param processing_state: A Processing State of the Call Summaries. One of `completed`, `partial` or `all`. + :param sort_by: A Sort By criterion for the returned list of Call Summaries. One of `start_time` or `end_time`. + :param subaccount: A unique SID identifier of a Subaccount. + :param abnormal_session: A boolean flag indicating an abnormal session where the last SIP response was not 200 OK. + :param answered_by: An Answered By value for the calls based on `Answering Machine Detection (AMD)`. One of `unknown`, `machine_start`, `machine_end_beep`, `machine_end_silence`, `machine_end_other`, `human` or `fax`. + :param answered_by_annotation: Either machine or human. + :param connectivity_issue_annotation: A Connectivity Issue with the calls. One of `no_connectivity_issue`, `invalid_number`, `caller_id`, `dropped_call`, or `number_reachability`. + :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 @@ -577,9 +764,8 @@ def page( "ToCarrier": to_carrier, "FromCountryCode": from_country_code, "ToCountryCode": to_country_code, - "Branded": branded, - "VerifiedCaller": verified_caller, - "HasTag": has_tag, + "VerifiedCaller": serialize.boolean_to_string(verified_caller), + "HasTag": serialize.boolean_to_string(has_tag), "StartTime": start_time, "EndTime": end_time, "CallType": call_type, @@ -588,15 +774,37 @@ def page( "ProcessingState": processing_state, "SortBy": sort_by, "Subaccount": subaccount, - "AbnormalSession": abnormal_session, + "AbnormalSession": serialize.boolean_to_string(abnormal_session), "AnsweredBy": answered_by, + "AnsweredByAnnotation": answered_by_annotation, + "ConnectivityIssueAnnotation": connectivity_issue_annotation, + "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( @@ -607,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, @@ -622,6 +829,20 @@ async def page_async( subaccount: Union[str, object] = values.unset, abnormal_session: Union[bool, object] = values.unset, answered_by: Union["CallSummariesInstance.AnsweredBy", object] = values.unset, + answered_by_annotation: Union[str, object] = values.unset, + connectivity_issue_annotation: Union[str, object] = values.unset, + 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, @@ -630,25 +851,38 @@ async def page_async( Asynchronously retrieve a single page of CallSummariesInstance records from the API. Request is executed immediately - :param from_: - :param to: - :param from_carrier: - :param to_carrier: - :param from_country_code: - :param to_country_code: - :param branded: - :param verified_caller: - :param has_tag: - :param start_time: - :param end_time: - :param call_type: - :param call_state: - :param direction: - :param processing_state: - :param sort_by: - :param subaccount: - :param abnormal_session: - :param answered_by: + :param from_: A calling party. Could be an E.164 number, a SIP URI, or a Twilio Client registered name. + :param to: A called party. Could be an E.164 number, a SIP URI, or a Twilio Client registered name. + :param from_carrier: An origination carrier. + :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 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. + :param call_type: A Call Type of the calls. One of `carrier`, `sip`, `trunking` or `client`. + :param call_state: A Call State of the calls. One of `ringing`, `completed`, `busy`, `fail`, `noanswer`, `canceled`, `answered`, `undialed`. + :param direction: A Direction of the calls. One of `outbound_api`, `outbound_dial`, `inbound`, `trunking_originating`, `trunking_terminating`. + :param processing_state: A Processing State of the Call Summaries. One of `completed`, `partial` or `all`. + :param sort_by: A Sort By criterion for the returned list of Call Summaries. One of `start_time` or `end_time`. + :param subaccount: A unique SID identifier of a Subaccount. + :param abnormal_session: A boolean flag indicating an abnormal session where the last SIP response was not 200 OK. + :param answered_by: An Answered By value for the calls based on `Answering Machine Detection (AMD)`. One of `unknown`, `machine_start`, `machine_end_beep`, `machine_end_silence`, `machine_end_other`, `human` or `fax`. + :param answered_by_annotation: Either machine or human. + :param connectivity_issue_annotation: A Connectivity Issue with the calls. One of `no_connectivity_issue`, `invalid_number`, `caller_id`, `dropped_call`, or `number_reachability`. + :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 @@ -663,9 +897,8 @@ async def page_async( "ToCarrier": to_carrier, "FromCountryCode": from_country_code, "ToCountryCode": to_country_code, - "Branded": branded, - "VerifiedCaller": verified_caller, - "HasTag": has_tag, + "VerifiedCaller": serialize.boolean_to_string(verified_caller), + "HasTag": serialize.boolean_to_string(has_tag), "StartTime": start_time, "EndTime": end_time, "CallType": call_type, @@ -674,16 +907,36 @@ async def page_async( "ProcessingState": processing_state, "SortBy": sort_by, "Subaccount": subaccount, - "AbnormalSession": abnormal_session, + "AbnormalSession": serialize.boolean_to_string(abnormal_session), "AnsweredBy": answered_by, + "AnsweredByAnnotation": answered_by_annotation, + "ConnectivityIssueAnnotation": connectivity_issue_annotation, + "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 ca0a316eee..ef3c51dac3 100644 --- a/twilio/rest/insights/v1/conference/__init__.py +++ b/twilio/rest/insights/v1/conference/__init__.py @@ -12,7 +12,6 @@ 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 @@ -27,6 +26,7 @@ class ConferenceInstance(InstanceResource): + class ConferenceEndReason(object): LAST_PARTICIPANT_LEFT = "last_participant_left" CONFERENCE_ENDED_VIA_API = "conference_ended_via_api" @@ -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. @@ -135,25 +138,25 @@ def __init__( self.unique_participants: Optional[int] = deserialize.integer( payload.get("unique_participants") ) - self.end_reason: Optional[ - "ConferenceInstance.ConferenceEndReason" - ] = payload.get("end_reason") + self.end_reason: Optional["ConferenceInstance.ConferenceEndReason"] = ( + payload.get("end_reason") + ) self.ended_by: Optional[str] = payload.get("ended_by") self.mixer_region: Optional["ConferenceInstance.Region"] = payload.get( "mixer_region" ) - self.mixer_region_requested: Optional[ - "ConferenceInstance.Region" - ] = payload.get("mixer_region_requested") + self.mixer_region_requested: Optional["ConferenceInstance.Region"] = ( + payload.get("mixer_region_requested") + ) self.recording_enabled: Optional[bool] = payload.get("recording_enabled") self.detected_issues: Optional[Dict[str, object]] = payload.get( "detected_issues" ) self.tags: Optional[List["ConferenceInstance.Tag"]] = payload.get("tags") self.tag_info: Optional[Dict[str, object]] = payload.get("tag_info") - self.processing_state: Optional[ - "ConferenceInstance.ProcessingState" - ] = payload.get("processing_state") + self.processing_state: Optional["ConferenceInstance.ProcessingState"] = ( + payload.get("processing_state") + ) self.url: Optional[str] = payload.get("url") self.links: Optional[Dict[str, object]] = payload.get("links") @@ -213,6 +216,7 @@ def __repr__(self) -> str: class ConferenceContext(InstanceContext): + def __init__(self, version: Version, conference_sid: str): """ Initialize the ConferenceContext @@ -238,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, @@ -257,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( @@ -291,6 +299,7 @@ def __repr__(self) -> str: class ConferencePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ConferenceInstance: """ Build an instance of ConferenceInstance @@ -309,6 +318,7 @@ def __repr__(self) -> str: class ConferenceList(ListResource): + def __init__(self, version: Version): """ Initialize the ConferenceList @@ -601,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( @@ -658,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 e6c5489b41..171f4f1f87 100644 --- a/twilio/rest/insights/v1/conference/conference_participant.py +++ b/twilio/rest/insights/v1/conference/conference_participant.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class ConferenceParticipantInstance(InstanceResource): + class CallDirection(object): INBOUND = "inbound" OUTBOUND = "outbound" @@ -62,6 +62,7 @@ class Region(object): JP1 = "jp1" SG1 = "sg1" DE1 = "de1" + IN1 = "in1" """ :ivar participant_sid: SID for this participant. @@ -107,14 +108,14 @@ def __init__( self.conference_sid: Optional[str] = payload.get("conference_sid") self.call_sid: Optional[str] = payload.get("call_sid") self.account_sid: Optional[str] = payload.get("account_sid") - self.call_direction: Optional[ - "ConferenceParticipantInstance.CallDirection" - ] = payload.get("call_direction") + self.call_direction: Optional["ConferenceParticipantInstance.CallDirection"] = ( + payload.get("call_direction") + ) self._from: Optional[str] = payload.get("from") self.to: Optional[str] = payload.get("to") - self.call_status: Optional[ - "ConferenceParticipantInstance.CallStatus" - ] = payload.get("call_status") + self.call_status: Optional["ConferenceParticipantInstance.CallStatus"] = ( + payload.get("call_status") + ) self.country_code: Optional[str] = payload.get("country_code") self.is_moderator: Optional[bool] = payload.get("is_moderator") self.join_time: Optional[datetime] = deserialize.iso8601_datetime( @@ -139,15 +140,15 @@ def __init__( self.coached_participants: Optional[List[str]] = payload.get( "coached_participants" ) - self.participant_region: Optional[ - "ConferenceParticipantInstance.Region" - ] = payload.get("participant_region") - self.conference_region: Optional[ - "ConferenceParticipantInstance.Region" - ] = payload.get("conference_region") - self.call_type: Optional[ - "ConferenceParticipantInstance.CallType" - ] = payload.get("call_type") + self.participant_region: Optional["ConferenceParticipantInstance.Region"] = ( + payload.get("participant_region") + ) + self.conference_region: Optional["ConferenceParticipantInstance.Region"] = ( + payload.get("conference_region") + ) + self.call_type: Optional["ConferenceParticipantInstance.CallType"] = ( + payload.get("call_type") + ) self.processing_state: Optional[ "ConferenceParticipantInstance.ProcessingState" ] = payload.get("processing_state") @@ -225,6 +226,7 @@ def __repr__(self) -> str: class ConferenceParticipantContext(InstanceContext): + def __init__(self, version: Version, conference_sid: str, participant_sid: str): """ Initialize the ConferenceParticipantContext @@ -267,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, @@ -297,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( @@ -319,6 +331,7 @@ def __repr__(self) -> str: class ConferenceParticipantPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ConferenceParticipantInstance: """ Build an instance of ConferenceParticipantInstance @@ -339,6 +352,7 @@ def __repr__(self) -> str: class ConferenceParticipantList(ListResource): + def __init__(self, version: Version, conference_sid: str): """ Initialize the ConferenceParticipantList @@ -533,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( @@ -569,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 c17dd25648..6fe0c476b5 100644 --- a/twilio/rest/insights/v1/room/__init__.py +++ b/twilio/rest/insights/v1/room/__init__.py @@ -12,7 +12,6 @@ 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 @@ -25,10 +24,12 @@ class RoomInstance(InstanceResource): + 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. @@ -223,6 +238,7 @@ def __repr__(self) -> str: class RoomContext(InstanceContext): + def __init__(self, version: Version, room_sid: str): """ Initialize the RoomContext @@ -248,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, @@ -267,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( @@ -301,6 +321,7 @@ def __repr__(self) -> str: class RoomPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> RoomInstance: """ Build an instance of RoomInstance @@ -319,6 +340,7 @@ def __repr__(self) -> str: class RoomList(ListResource): + def __init__(self, version: Version): """ Initialize the RoomList @@ -536,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( @@ -578,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 b1548c1334..d0d3e592e0 100644 --- a/twilio/rest/insights/v1/room/participant.py +++ b/twilio/rest/insights/v1/room/participant.py @@ -12,7 +12,6 @@ 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 @@ -24,10 +23,12 @@ class ParticipantInstance(InstanceResource): + 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. @@ -66,13 +81,13 @@ class TwilioRealm(object): :ivar room_sid: Unique identifier for the room. :ivar status: :ivar codecs: Codecs detected from the participant. Can be `VP8`, `H264`, or `VP9`. - :ivar end_reason: Reason the participant left the room. See [the list of possible values here](https://www.twilio.com/docs/video/video-log-analyzer/video-log-analyzer-api#end_reason). + :ivar end_reason: Reason the participant left the room. See [the list of possible values here](https://www.twilio.com/docs/video/troubleshooting/video-log-analyzer-api#end_reason). :ivar error_code: Errors encountered by the participant. :ivar error_code_url: Twilio error code dictionary link. :ivar media_region: - :ivar properties: Object containing information about the participant's data from the room. See [below](https://www.twilio.com/docs/video/video-log-analyzer/video-log-analyzer-api#properties) for more information. + :ivar properties: Object containing information about the participant's data from the room. See [below](https://www.twilio.com/docs/video/troubleshooting/video-log-analyzer-api#properties) for more information. :ivar edge_location: - :ivar publisher_info: Object containing information about the SDK name and version. See [below](https://www.twilio.com/docs/video/video-log-analyzer/video-log-analyzer-api#publisher_info) for more information. + :ivar publisher_info: Object containing information about the SDK name and version. See [below](https://www.twilio.com/docs/video/troubleshooting/video-log-analyzer-api#publisher_info) for more information. :ivar url: URL of the participant resource. """ @@ -162,6 +177,7 @@ def __repr__(self) -> str: class ParticipantContext(InstanceContext): + def __init__(self, version: Version, room_sid: str, participant_sid: str): """ Initialize the ParticipantContext @@ -189,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, @@ -209,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( @@ -232,6 +252,7 @@ def __repr__(self) -> str: class ParticipantPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ParticipantInstance: """ Build an instance of ParticipantInstance @@ -252,6 +273,7 @@ def __repr__(self) -> str: class ParticipantList(ListResource): + def __init__(self, version: Version, room_sid: str): """ Initialize the ParticipantList @@ -395,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( @@ -422,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 c58f502522..3c6b746f07 100644 --- a/twilio/rest/insights/v1/setting.py +++ b/twilio/rest/insights/v1/setting.py @@ -12,9 +12,8 @@ Do not edit the class manually. """ - from typing import Any, Dict, Optional, Union -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 @@ -22,12 +21,11 @@ class SettingInstance(InstanceResource): - """ - :ivar account_sid: - :ivar advanced_features: - :ivar voice_trace: - :ivar url: + :ivar account_sid: The unique SID identifier of the Account. + :ivar advanced_features: A boolean flag indicating whether Advanced Features for Voice Insights are enabled. + :ivar voice_trace: A boolean flag indicating whether Voice Trace is enabled. + :ivar url: The URL of this resource. """ def __init__(self, version: Version, payload: Dict[str, Any]): @@ -60,7 +58,7 @@ def fetch( """ Fetch the SettingInstance - :param subaccount_sid: + :param subaccount_sid: The unique SID identifier of the Subaccount. :returns: The fetched SettingInstance """ @@ -74,7 +72,7 @@ async def fetch_async( """ Asynchronous coroutine to fetch the SettingInstance - :param subaccount_sid: + :param subaccount_sid: The unique SID identifier of the Subaccount. :returns: The fetched SettingInstance """ @@ -91,9 +89,9 @@ def update( """ Update the SettingInstance - :param advanced_features: - :param voice_trace: - :param subaccount_sid: + :param advanced_features: A boolean flag to enable Advanced Features for Voice Insights. + :param voice_trace: A boolean flag to enable Voice Trace. + :param subaccount_sid: The unique SID identifier of the Subaccount. :returns: The updated SettingInstance """ @@ -112,9 +110,9 @@ async def update_async( """ Asynchronous coroutine to update the SettingInstance - :param advanced_features: - :param voice_trace: - :param subaccount_sid: + :param advanced_features: A boolean flag to enable Advanced Features for Voice Insights. + :param voice_trace: A boolean flag to enable Voice Trace. + :param subaccount_sid: The unique SID identifier of the Subaccount. :returns: The updated SettingInstance """ @@ -135,6 +133,7 @@ def __repr__(self) -> str: class SettingContext(InstanceContext): + def __init__(self, version: Version): """ Initialize the SettingContext @@ -151,7 +150,7 @@ def fetch( """ Fetch the SettingInstance - :param subaccount_sid: + :param subaccount_sid: The unique SID identifier of the Subaccount. :returns: The fetched SettingInstance """ @@ -162,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, @@ -175,7 +180,7 @@ async def fetch_async( """ Asynchronous coroutine to fetch the SettingInstance - :param subaccount_sid: + :param subaccount_sid: The unique SID identifier of the Subaccount. :returns: The fetched SettingInstance """ @@ -186,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( @@ -204,24 +213,28 @@ def update( """ Update the SettingInstance - :param advanced_features: - :param voice_trace: - :param subaccount_sid: + :param advanced_features: A boolean flag to enable Advanced Features for Voice Insights. + :param voice_trace: A boolean flag to enable Voice Trace. + :param subaccount_sid: The unique SID identifier of the Subaccount. :returns: The updated SettingInstance """ + data = values.of( { - "AdvancedFeatures": advanced_features, - "VoiceTrace": voice_trace, + "AdvancedFeatures": serialize.boolean_to_string(advanced_features), + "VoiceTrace": serialize.boolean_to_string(voice_trace), "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) @@ -235,24 +248,28 @@ async def update_async( """ Asynchronous coroutine to update the SettingInstance - :param advanced_features: - :param voice_trace: - :param subaccount_sid: + :param advanced_features: A boolean flag to enable Advanced Features for Voice Insights. + :param voice_trace: A boolean flag to enable Voice Trace. + :param subaccount_sid: The unique SID identifier of the Subaccount. :returns: The updated SettingInstance """ + data = values.of( { - "AdvancedFeatures": advanced_features, - "VoiceTrace": voice_trace, + "AdvancedFeatures": serialize.boolean_to_string(advanced_features), + "VoiceTrace": serialize.boolean_to_string(voice_trace), "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) @@ -268,6 +285,7 @@ def __repr__(self) -> str: class SettingList(ListResource): + def __init__(self, version: Version): """ Initialize the SettingList diff --git a/twilio/rest/intelligence/IntelligenceBase.py b/twilio/rest/intelligence/IntelligenceBase.py new file mode 100644 index 0000000000..0546bc15ae --- /dev/null +++ b/twilio/rest/intelligence/IntelligenceBase.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.intelligence.v2 import V2 + + +class IntelligenceBase(Domain): + + def __init__(self, twilio: Client): + """ + Initialize the Intelligence Domain + + :returns: Domain for Intelligence + """ + super().__init__(twilio, "https://intelligence.twilio.com") + self._v2: Optional[V2] = None + + @property + def v2(self) -> V2: + """ + :returns: Versions v2 of Intelligence + """ + if self._v2 is None: + self._v2 = V2(self) + return self._v2 + + def __repr__(self) -> str: + """ + Provide a friendly representation + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/intelligence/__init__.py b/twilio/rest/intelligence/__init__.py new file mode 100644 index 0000000000..6d565b433c --- /dev/null +++ b/twilio/rest/intelligence/__init__.py @@ -0,0 +1,13 @@ +from twilio.rest.intelligence.IntelligenceBase import IntelligenceBase +from twilio.rest.intelligence.v2.service import ServiceList +from twilio.rest.intelligence.v2.transcript import TranscriptList + + +class Intelligence(IntelligenceBase): + @property + def transcripts(self) -> TranscriptList: + return self.v2.transcripts + + @property + def services(self) -> ServiceList: + return self.v2.services diff --git a/twilio/rest/intelligence/v2/__init__.py b/twilio/rest/intelligence/v2/__init__.py new file mode 100644 index 0000000000..4999146f93 --- /dev/null +++ b/twilio/rest/intelligence/v2/__init__.py @@ -0,0 +1,99 @@ +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 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 + + +class V2(Version): + + def __init__(self, domain: Domain): + """ + Initialize the V2 version of Intelligence + + :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: + self._services = ServiceList(self) + return self._services + + @property + def transcripts(self) -> TranscriptList: + if self._transcripts is None: + self._transcripts = TranscriptList(self) + return self._transcripts + + def __repr__(self) -> str: + """ + Provide a friendly representation + :returns: Machine friendly representation + """ + return "" 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/microvisor/v1/account_config.py b/twilio/rest/intelligence/v2/operator_type.py similarity index 51% rename from twilio/rest/microvisor/v1/account_config.py rename to twilio/rest/intelligence/v2/operator_type.py index 7d8119a3de..b14e677ad2 100644 --- a/twilio/rest/microvisor/v1/account_config.py +++ b/twilio/rest/intelligence/v2/operator_type.py @@ -4,7 +4,7 @@ | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - Twilio - Microvisor + Twilio - Intelligence This is the public Twilio REST API. NOTE: This class is auto generated by OpenAPI Generator. @@ -12,7 +12,6 @@ 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 @@ -23,107 +22,113 @@ from twilio.base.page import Page -class AccountConfigInstance(InstanceResource): +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 key: The config key; up to 100 characters. - :ivar date_updated: - :ivar value: The config value; up to 4096 characters. - :ivar url: The absolute URL of the Config. + :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], key: Optional[str] = None + self, version: Version, payload: Dict[str, Any], sid: Optional[str] = None ): super().__init__(version) - self.key: Optional[str] = payload.get("key") + 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.value: Optional[str] = payload.get("value") self.url: Optional[str] = payload.get("url") self._solution = { - "key": key or self.key, + "sid": sid or self.sid, } - self._context: Optional[AccountConfigContext] = None + self._context: Optional[OperatorTypeContext] = None @property - def _proxy(self) -> "AccountConfigContext": + 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: AccountConfigContext for this AccountConfigInstance + :returns: OperatorTypeContext for this OperatorTypeInstance """ if self._context is None: - self._context = AccountConfigContext( + self._context = OperatorTypeContext( self._version, - key=self._solution["key"], + sid=self._solution["sid"], ) return self._context - def delete(self) -> bool: + def fetch(self) -> "OperatorTypeInstance": """ - Deletes the AccountConfigInstance - + Fetch the OperatorTypeInstance - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the AccountConfigInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def fetch(self) -> "AccountConfigInstance": - """ - Fetch the AccountConfigInstance - - - :returns: The fetched AccountConfigInstance + :returns: The fetched OperatorTypeInstance """ return self._proxy.fetch() - async def fetch_async(self) -> "AccountConfigInstance": + async def fetch_async(self) -> "OperatorTypeInstance": """ - Asynchronous coroutine to fetch the AccountConfigInstance + Asynchronous coroutine to fetch the OperatorTypeInstance - :returns: The fetched AccountConfigInstance + :returns: The fetched OperatorTypeInstance """ return await self._proxy.fetch_async() - def update(self, value: str) -> "AccountConfigInstance": - """ - Update the AccountConfigInstance - - :param value: The config value; up to 4096 characters. - - :returns: The updated AccountConfigInstance - """ - return self._proxy.update( - value=value, - ) - - async def update_async(self, value: str) -> "AccountConfigInstance": - """ - Asynchronous coroutine to update the AccountConfigInstance - - :param value: The config value; up to 4096 characters. - - :returns: The updated AccountConfigInstance - """ - return await self._proxy.update_async( - value=value, - ) - def __repr__(self) -> str: """ Provide a friendly representation @@ -131,131 +136,68 @@ 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 OperatorTypeContext(InstanceContext): -class AccountConfigContext(InstanceContext): - def __init__(self, version: Version, key: str): + def __init__(self, version: Version, sid: str): """ - Initialize the AccountConfigContext + Initialize the OperatorTypeContext :param version: Version that contains the resource - :param key: The config key; up to 100 characters. + :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 = { - "key": key, + "sid": sid, } - self._uri = "/Configs/{key}".format(**self._solution) + self._uri = "/OperatorTypes/{sid}".format(**self._solution) - def delete(self) -> bool: + def fetch(self) -> OperatorTypeInstance: """ - Deletes the AccountConfigInstance + Fetch the OperatorTypeInstance - :returns: True if delete succeeds, False otherwise + :returns: The fetched OperatorTypeInstance """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the AccountConfigInstance + headers = values.of({}) - :returns: True if delete succeeds, False otherwise - """ - return await self._version.delete_async( - method="DELETE", - uri=self._uri, - ) + headers["Accept"] = "application/json" - def fetch(self) -> AccountConfigInstance: - """ - Fetch the AccountConfigInstance + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) - - :returns: The fetched AccountConfigInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return AccountConfigInstance( + return OperatorTypeInstance( self._version, payload, - key=self._solution["key"], + sid=self._solution["sid"], ) - async def fetch_async(self) -> AccountConfigInstance: + async def fetch_async(self) -> OperatorTypeInstance: """ - Asynchronous coroutine to fetch the AccountConfigInstance + Asynchronous coroutine to fetch the OperatorTypeInstance - :returns: The fetched AccountConfigInstance + :returns: The fetched OperatorTypeInstance """ + headers = values.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( + return OperatorTypeInstance( self._version, payload, - key=self._solution["key"], - ) - - def update(self, value: str) -> AccountConfigInstance: - """ - Update the AccountConfigInstance - - :param value: The config value; up to 4096 characters. - - :returns: The updated AccountConfigInstance - """ - data = values.of( - { - "Value": value, - } + sid=self._solution["sid"], ) - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return AccountConfigInstance(self._version, payload, key=self._solution["key"]) - - async def update_async(self, value: str) -> AccountConfigInstance: - """ - Asynchronous coroutine to update the AccountConfigInstance - - :param value: The config value; up to 4096 characters. - - :returns: The updated AccountConfigInstance - """ - data = values.of( - { - "Value": value, - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return AccountConfigInstance(self._version, payload, key=self._solution["key"]) - def __repr__(self) -> str: """ Provide a friendly representation @@ -263,17 +205,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 AccountConfigPage(Page): - def get_instance(self, payload: Dict[str, Any]) -> AccountConfigInstance: +class OperatorTypePage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> OperatorTypeInstance: """ - Build an instance of AccountConfigInstance + Build an instance of OperatorTypeInstance :param payload: Payload response from the API """ - return AccountConfigInstance(self._version, payload) + return OperatorTypeInstance(self._version, payload) def __repr__(self) -> str: """ @@ -281,76 +224,29 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ - return "" + return "" + +class OperatorTypeList(ListResource): -class AccountConfigList(ListResource): def __init__(self, version: Version): """ - Initialize the AccountConfigList + Initialize the OperatorTypeList :param version: Version that contains the resource """ super().__init__(version) - self._uri = "/Configs" - - def create(self, key: str, value: str) -> AccountConfigInstance: - """ - Create the AccountConfigInstance - - :param key: The config key; up to 100 characters. - :param value: The config value; up to 4096 characters. - - :returns: The created AccountConfigInstance - """ - data = values.of( - { - "Key": key, - "Value": value, - } - ) - - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) - - return AccountConfigInstance(self._version, payload) - - async def create_async(self, key: str, value: str) -> AccountConfigInstance: - """ - Asynchronously create the AccountConfigInstance - - :param key: The config key; up to 100 characters. - :param value: The config value; up to 4096 characters. - - :returns: The created AccountConfigInstance - """ - data = values.of( - { - "Key": key, - "Value": value, - } - ) - - payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, - ) - - return AccountConfigInstance(self._version, payload) + self._uri = "/OperatorTypes" def stream( self, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> Iterator[AccountConfigInstance]: + ) -> Iterator[OperatorTypeInstance]: """ - Streams AccountConfigInstance records from the API as a generator stream. + 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. @@ -373,9 +269,9 @@ async def stream_async( self, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> AsyncIterator[AccountConfigInstance]: + ) -> AsyncIterator[OperatorTypeInstance]: """ - Asynchronously streams AccountConfigInstance records from the API as a generator stream. + 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. @@ -398,9 +294,9 @@ def list( self, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> List[AccountConfigInstance]: + ) -> List[OperatorTypeInstance]: """ - Lists AccountConfigInstance records from the API as a list. + Lists OperatorTypeInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @@ -424,9 +320,9 @@ async def list_async( self, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> List[AccountConfigInstance]: + ) -> List[OperatorTypeInstance]: """ - Asynchronously lists AccountConfigInstance records from the API as a list. + 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. @@ -452,16 +348,16 @@ def page( page_token: Union[str, object] = values.unset, page_number: Union[int, object] = values.unset, page_size: Union[int, object] = values.unset, - ) -> AccountConfigPage: + ) -> OperatorTypePage: """ - Retrieve a single page of AccountConfigInstance records from the API. + 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 AccountConfigInstance + :returns: Page of OperatorTypeInstance """ data = values.of( { @@ -471,24 +367,30 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) - return AccountConfigPage(self._version, response) + headers = values.of({"Content-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, - ) -> AccountConfigPage: + ) -> OperatorTypePage: """ - Asynchronously retrieve a single page of AccountConfigInstance records from the API. + 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 AccountConfigInstance + :returns: Page of OperatorTypeInstance """ data = values.of( { @@ -498,50 +400,54 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/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) + return OperatorTypePage(self._version, response) - def get_page(self, target_url: str) -> AccountConfigPage: + def get_page(self, target_url: str) -> OperatorTypePage: """ - Retrieve a specific page of AccountConfigInstance records from the API. + 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 AccountConfigInstance + :returns: Page of OperatorTypeInstance """ response = self._version.domain.twilio.request("GET", target_url) - return AccountConfigPage(self._version, response) + return OperatorTypePage(self._version, response) - async def get_page_async(self, target_url: str) -> AccountConfigPage: + async def get_page_async(self, target_url: str) -> OperatorTypePage: """ - Asynchronously retrieve a specific page of AccountConfigInstance records from the API. + 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 AccountConfigInstance + :returns: Page of OperatorTypeInstance """ response = await self._version.domain.twilio.request_async("GET", target_url) - return AccountConfigPage(self._version, response) + return OperatorTypePage(self._version, response) - def get(self, key: str) -> AccountConfigContext: + def get(self, sid: str) -> OperatorTypeContext: """ - Constructs a AccountConfigContext + Constructs a OperatorTypeContext - :param key: The config key; up to 100 characters. + :param sid: Either a 34 character string that uniquely identifies this Operator Type or the unique name that references an Operator Type. """ - return AccountConfigContext(self._version, key=key) + return OperatorTypeContext(self._version, sid=sid) - def __call__(self, key: str) -> AccountConfigContext: + def __call__(self, sid: str) -> OperatorTypeContext: """ - Constructs a AccountConfigContext + Constructs a OperatorTypeContext - :param key: The config key; up to 100 characters. + :param sid: Either a 34 character string that uniquely identifies this Operator Type or the unique name that references an Operator Type. """ - return AccountConfigContext(self._version, key=key) + return OperatorTypeContext(self._version, sid=sid) def __repr__(self) -> str: """ @@ -549,4 +455,4 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ - return "" + 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 new file mode 100644 index 0000000000..fac3eb8473 --- /dev/null +++ b/twilio/rest/intelligence/v2/service.py @@ -0,0 +1,787 @@ +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 ServiceInstance(InstanceResource): + + class HttpMethod(object): + GET = "GET" + POST = "POST" + NULL = "NULL" + + """ + :ivar account_sid: The unique SID identifier of the Account the Service belongs to. + :ivar auto_redaction: Instructs the Speech Recognition service to automatically redact PII from all transcripts made on this service. + :ivar 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. + :ivar auto_transcribe: Instructs the Speech Recognition service to automatically transcribe all recordings made on the account. + :ivar 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. + :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 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. + """ + + 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.auto_redaction: Optional[bool] = payload.get("auto_redaction") + self.media_redaction: Optional[bool] = payload.get("media_redaction") + self.auto_transcribe: Optional[bool] = payload.get("auto_transcribe") + self.data_logging: Optional[bool] = payload.get("data_logging") + 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.friendly_name: Optional[str] = payload.get("friendly_name") + self.language_code: Optional[str] = payload.get("language_code") + self.sid: Optional[str] = payload.get("sid") + self.unique_name: Optional[str] = payload.get("unique_name") + self.url: Optional[str] = payload.get("url") + self.webhook_url: Optional[str] = payload.get("webhook_url") + 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 = { + "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, + if_match: Union[str, object] = values.unset, + auto_transcribe: Union[bool, object] = values.unset, + data_logging: Union[bool, object] = values.unset, + friendly_name: 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, + webhook_url: Union[str, object] = values.unset, + webhook_http_method: Union["ServiceInstance.HttpMethod", object] = values.unset, + ) -> "ServiceInstance": + """ + Update the ServiceInstance + + :param if_match: The If-Match HTTP request header + :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 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. + :param webhook_url: The URL Twilio will request when executing the Webhook. + :param webhook_http_method: + + :returns: The updated ServiceInstance + """ + return self._proxy.update( + if_match=if_match, + auto_transcribe=auto_transcribe, + data_logging=data_logging, + friendly_name=friendly_name, + unique_name=unique_name, + auto_redaction=auto_redaction, + media_redaction=media_redaction, + webhook_url=webhook_url, + webhook_http_method=webhook_http_method, + ) + + async def update_async( + self, + if_match: Union[str, object] = values.unset, + auto_transcribe: Union[bool, object] = values.unset, + data_logging: Union[bool, object] = values.unset, + friendly_name: 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, + webhook_url: Union[str, object] = values.unset, + webhook_http_method: Union["ServiceInstance.HttpMethod", object] = values.unset, + ) -> "ServiceInstance": + """ + Asynchronous coroutine to update the ServiceInstance + + :param if_match: The If-Match HTTP request header + :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 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. + :param webhook_url: The URL Twilio will request when executing the Webhook. + :param webhook_http_method: + + :returns: The updated ServiceInstance + """ + return await self._proxy.update_async( + if_match=if_match, + auto_transcribe=auto_transcribe, + data_logging=data_logging, + friendly_name=friendly_name, + unique_name=unique_name, + auto_redaction=auto_redaction, + media_redaction=media_redaction, + webhook_url=webhook_url, + webhook_http_method=webhook_http_method, + ) + + 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: A 34 character string that uniquely identifies this Service. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "sid": sid, + } + self._uri = "/Services/{sid}".format(**self._solution) + + def delete(self) -> bool: + """ + Deletes the ServiceInstance + + + :returns: True if delete succeeds, False otherwise + """ + + headers = values.of({}) + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the ServiceInstance + + + :returns: True if delete succeeds, False otherwise + """ + + headers = values.of({}) + + return await self._version.delete_async( + method="DELETE", uri=self._uri, headers=headers + ) + + def fetch(self) -> ServiceInstance: + """ + Fetch the ServiceInstance + + + :returns: The fetched ServiceInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return ServiceInstance( + self._version, + payload, + sid=self._solution["sid"], + ) + + async def fetch_async(self) -> ServiceInstance: + """ + Asynchronous coroutine to fetch the ServiceInstance + + + :returns: The fetched ServiceInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + return ServiceInstance( + self._version, + payload, + sid=self._solution["sid"], + ) + + def update( + self, + if_match: Union[str, object] = values.unset, + auto_transcribe: Union[bool, object] = values.unset, + data_logging: Union[bool, object] = values.unset, + friendly_name: 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, + webhook_url: Union[str, object] = values.unset, + webhook_http_method: Union["ServiceInstance.HttpMethod", object] = values.unset, + ) -> ServiceInstance: + """ + Update the ServiceInstance + + :param if_match: The If-Match HTTP request header + :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 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. + :param webhook_url: The URL Twilio will request when executing the Webhook. + :param webhook_http_method: + + :returns: The updated ServiceInstance + """ + + data = values.of( + { + "AutoTranscribe": serialize.boolean_to_string(auto_transcribe), + "DataLogging": serialize.boolean_to_string(data_logging), + "FriendlyName": friendly_name, + "UniqueName": unique_name, + "AutoRedaction": serialize.boolean_to_string(auto_redaction), + "MediaRedaction": serialize.boolean_to_string(media_redaction), + "WebhookUrl": webhook_url, + "WebhookHttpMethod": webhook_http_method, + } + ) + 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 ServiceInstance(self._version, payload, sid=self._solution["sid"]) + + async def update_async( + self, + if_match: Union[str, object] = values.unset, + auto_transcribe: Union[bool, object] = values.unset, + data_logging: Union[bool, object] = values.unset, + friendly_name: 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, + webhook_url: Union[str, object] = values.unset, + webhook_http_method: Union["ServiceInstance.HttpMethod", object] = values.unset, + ) -> ServiceInstance: + """ + Asynchronous coroutine to update the ServiceInstance + + :param if_match: The If-Match HTTP request header + :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 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. + :param webhook_url: The URL Twilio will request when executing the Webhook. + :param webhook_http_method: + + :returns: The updated ServiceInstance + """ + + data = values.of( + { + "AutoTranscribe": serialize.boolean_to_string(auto_transcribe), + "DataLogging": serialize.boolean_to_string(data_logging), + "FriendlyName": friendly_name, + "UniqueName": unique_name, + "AutoRedaction": serialize.boolean_to_string(auto_redaction), + "MediaRedaction": serialize.boolean_to_string(media_redaction), + "WebhookUrl": webhook_url, + "WebhookHttpMethod": webhook_http_method, + } + ) + 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 ServiceInstance(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 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, + unique_name: str, + 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, + auto_redaction: Union[bool, object] = values.unset, + media_redaction: Union[bool, object] = values.unset, + webhook_url: Union[str, object] = values.unset, + webhook_http_method: Union["ServiceInstance.HttpMethod", object] = values.unset, + ) -> ServiceInstance: + """ + Create the ServiceInstance + + :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_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 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. + :param webhook_http_method: + + :returns: The created ServiceInstance + """ + + data = values.of( + { + "UniqueName": unique_name, + "AutoTranscribe": serialize.boolean_to_string(auto_transcribe), + "DataLogging": serialize.boolean_to_string(data_logging), + "FriendlyName": friendly_name, + "LanguageCode": language_code, + "AutoRedaction": serialize.boolean_to_string(auto_redaction), + "MediaRedaction": serialize.boolean_to_string(media_redaction), + "WebhookUrl": webhook_url, + "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, headers=headers + ) + + return ServiceInstance(self._version, payload) + + async def create_async( + self, + unique_name: str, + 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, + auto_redaction: Union[bool, object] = values.unset, + media_redaction: Union[bool, object] = values.unset, + webhook_url: Union[str, object] = values.unset, + webhook_http_method: Union["ServiceInstance.HttpMethod", object] = values.unset, + ) -> ServiceInstance: + """ + Asynchronously create the ServiceInstance + + :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_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 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. + :param webhook_http_method: + + :returns: The created ServiceInstance + """ + + data = values.of( + { + "UniqueName": unique_name, + "AutoTranscribe": serialize.boolean_to_string(auto_transcribe), + "DataLogging": serialize.boolean_to_string(data_logging), + "FriendlyName": friendly_name, + "LanguageCode": language_code, + "AutoRedaction": serialize.boolean_to_string(auto_redaction), + "MediaRedaction": serialize.boolean_to_string(media_redaction), + "WebhookUrl": webhook_url, + "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, headers=headers + ) + + return ServiceInstance(self._version, payload) + + def stream( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[ServiceInstance]: + """ + Streams ServiceInstance records from the API as a generator stream. + This operation lazily loads records as efficiently as possible until the limit + is reached. + The results are returned as a generator, so this operation is memory efficient. + + :param limit: Upper limit for the number of records to return. stream() + guarantees to never return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, stream() will attempt to read the + limit with the most efficient page size, i.e. min(limit, 1000) + + :returns: Generator that will yield up to limit results + """ + limits = self._version.read_limits(limit, page_size) + page = self.page(page_size=limits["page_size"]) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[ServiceInstance]: + """ + Asynchronously streams ServiceInstance records from the API as a generator stream. + This operation lazily loads records as efficiently as possible until the limit + is reached. + The results are returned as a generator, so this operation is memory efficient. + + :param limit: Upper limit for the number of records to return. stream() + guarantees to never return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, stream() will attempt to read the + limit with the most efficient page size, i.e. min(limit, 1000) + + :returns: Generator that will yield up to limit results + """ + limits = self._version.read_limits(limit, page_size) + page = await self.page_async(page_size=limits["page_size"]) + + return self._version.stream_async(page, limits["limit"]) + + def list( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[ServiceInstance]: + """ + Lists ServiceInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param limit: Upper limit for the number of records to return. list() guarantees + never to return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, list() will attempt to read the limit + with the most efficient page size, i.e. min(limit, 1000) + + :returns: list that will contain up to limit results + """ + return list( + self.stream( + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[ServiceInstance]: + """ + Asynchronously lists ServiceInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param limit: Upper limit for the number of records to return. list() guarantees + never to return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, list() will attempt to read the limit + with the most efficient page size, i.e. min(limit, 1000) + + :returns: list that will contain up to limit results + """ + return [ + record + async for record in await self.stream_async( + limit=limit, + page_size=page_size, + ) + ] + + def page( + self, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> ServicePage: + """ + Retrieve a single page of ServiceInstance records from the API. + Request is executed immediately + + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: Page of ServiceInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return ServicePage(self._version, response) + + async def page_async( + self, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> ServicePage: + """ + Asynchronously retrieve a single page of ServiceInstance records from the API. + Request is executed immediately + + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: Page of ServiceInstance + """ + data = values.of( + { + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + return ServicePage(self._version, response) + + def get_page(self, target_url: str) -> ServicePage: + """ + Retrieve a specific page of ServiceInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of ServiceInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return ServicePage(self._version, response) + + async def get_page_async(self, target_url: str) -> ServicePage: + """ + Asynchronously retrieve a specific page of ServiceInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of ServiceInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return ServicePage(self._version, response) + + def get(self, sid: str) -> ServiceContext: + """ + Constructs a ServiceContext + + :param sid: A 34 character string that uniquely identifies this Service. + """ + return ServiceContext(self._version, sid=sid) + + def __call__(self, sid: str) -> ServiceContext: + """ + Constructs a ServiceContext + + :param sid: A 34 character string that uniquely identifies this Service. + """ + return ServiceContext(self._version, sid=sid) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/intelligence/v2/transcript/__init__.py b/twilio/rest/intelligence/v2/transcript/__init__.py new file mode 100644 index 0000000000..c2141bb5da --- /dev/null +++ b/twilio/rest/intelligence/v2/transcript/__init__.py @@ -0,0 +1,775 @@ +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 +from twilio.rest.intelligence.v2.transcript.media import MediaList +from twilio.rest.intelligence.v2.transcript.operator_result import OperatorResultList +from twilio.rest.intelligence.v2.transcript.sentence import SentenceList + + +class TranscriptInstance(InstanceResource): + + class Status(object): + QUEUED = "queued" + IN_PROGRESS = "in-progress" + COMPLETED = "completed" + FAILED = "failed" + CANCELED = "canceled" + + """ + :ivar account_sid: The unique SID identifier of the Account. + :ivar service_sid: The unique SID identifier of the Service. + :ivar sid: A 34 character string that uniquely identifies this Transcript. + :ivar date_created: The date that this Transcript was created, given in ISO 8601 format. + :ivar date_updated: The date that this Transcript was updated, given in ISO 8601 format. + :ivar status: + :ivar channel: Media Channel describing Transcript Source and Participant Mapping + :ivar 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. + :ivar language_code: The default language code of the audio. + :ivar customer_key: + :ivar media_start_time: The date that this Transcript's media was started, given in ISO 8601 format. + :ivar duration: The duration of this Transcript's source + :ivar url: The URL of this resource. + :ivar redaction: If the transcript has been redacted, a redacted alternative of the transcript will be available. + :ivar links: + """ + + 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.service_sid: Optional[str] = payload.get("service_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.status: Optional["TranscriptInstance.Status"] = payload.get("status") + self.channel: Optional[Dict[str, object]] = payload.get("channel") + self.data_logging: Optional[bool] = payload.get("data_logging") + self.language_code: Optional[str] = payload.get("language_code") + self.customer_key: Optional[str] = payload.get("customer_key") + self.media_start_time: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("media_start_time") + ) + self.duration: Optional[int] = deserialize.integer(payload.get("duration")) + self.url: Optional[str] = payload.get("url") + self.redaction: Optional[bool] = payload.get("redaction") + self.links: Optional[Dict[str, object]] = payload.get("links") + + self._solution = { + "sid": sid or self.sid, + } + self._context: Optional[TranscriptContext] = None + + @property + def _proxy(self) -> "TranscriptContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: TranscriptContext for this TranscriptInstance + """ + if self._context is None: + self._context = TranscriptContext( + self._version, + sid=self._solution["sid"], + ) + return self._context + + def delete(self) -> bool: + """ + Deletes the TranscriptInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._proxy.delete() + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the TranscriptInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._proxy.delete_async() + + def fetch(self) -> "TranscriptInstance": + """ + Fetch the TranscriptInstance + + + :returns: The fetched TranscriptInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "TranscriptInstance": + """ + Asynchronous coroutine to fetch the TranscriptInstance + + + :returns: The fetched TranscriptInstance + """ + return await self._proxy.fetch_async() + + @property + def media(self) -> MediaList: + """ + Access the media + """ + return self._proxy.media + + @property + def operator_results(self) -> OperatorResultList: + """ + Access the operator_results + """ + return self._proxy.operator_results + + @property + def sentences(self) -> SentenceList: + """ + Access the sentences + """ + return self._proxy.sentences + + 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 TranscriptContext(InstanceContext): + + def __init__(self, version: Version, sid: str): + """ + Initialize the TranscriptContext + + :param version: Version that contains the resource + :param sid: A 34 character string that uniquely identifies this Transcript. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "sid": sid, + } + self._uri = "/Transcripts/{sid}".format(**self._solution) + + self._media: Optional[MediaList] = None + self._operator_results: Optional[OperatorResultList] = None + self._sentences: Optional[SentenceList] = None + + def delete(self) -> bool: + """ + Deletes the TranscriptInstance + + + :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 TranscriptInstance + + + :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) -> TranscriptInstance: + """ + Fetch the TranscriptInstance + + + :returns: The fetched TranscriptInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return TranscriptInstance( + self._version, + payload, + sid=self._solution["sid"], + ) + + async def fetch_async(self) -> TranscriptInstance: + """ + Asynchronous coroutine to fetch the TranscriptInstance + + + :returns: The fetched TranscriptInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + return TranscriptInstance( + self._version, + payload, + sid=self._solution["sid"], + ) + + @property + def media(self) -> MediaList: + """ + Access the media + """ + if self._media is None: + self._media = MediaList( + self._version, + self._solution["sid"], + ) + return self._media + + @property + def operator_results(self) -> OperatorResultList: + """ + Access the operator_results + """ + if self._operator_results is None: + self._operator_results = OperatorResultList( + self._version, + self._solution["sid"], + ) + return self._operator_results + + @property + def sentences(self) -> SentenceList: + """ + Access the sentences + """ + if self._sentences is None: + self._sentences = SentenceList( + self._version, + self._solution["sid"], + ) + return self._sentences + + 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 TranscriptPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> TranscriptInstance: + """ + Build an instance of TranscriptInstance + + :param payload: Payload response from the API + """ + return TranscriptInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class TranscriptList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the TranscriptList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/Transcripts" + + def create( + self, + service_sid: str, + channel: object, + customer_key: Union[str, object] = values.unset, + media_start_time: Union[datetime, object] = values.unset, + ) -> TranscriptInstance: + """ + Create the TranscriptInstance + + :param service_sid: The unique SID identifier of the Service. + :param channel: JSON object describing Media Channel including Source and Participants + :param customer_key: Used to store client provided metadata. Maximum of 64 double-byte UTF8 characters. + :param media_start_time: The date that this Transcript's media was started, given in ISO 8601 format. + + :returns: The created TranscriptInstance + """ + + data = values.of( + { + "ServiceSid": service_sid, + "Channel": serialize.object(channel), + "CustomerKey": customer_key, + "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, headers=headers + ) + + return TranscriptInstance(self._version, payload) + + async def create_async( + self, + service_sid: str, + channel: object, + customer_key: Union[str, object] = values.unset, + media_start_time: Union[datetime, object] = values.unset, + ) -> TranscriptInstance: + """ + Asynchronously create the TranscriptInstance + + :param service_sid: The unique SID identifier of the Service. + :param channel: JSON object describing Media Channel including Source and Participants + :param customer_key: Used to store client provided metadata. Maximum of 64 double-byte UTF8 characters. + :param media_start_time: The date that this Transcript's media was started, given in ISO 8601 format. + + :returns: The created TranscriptInstance + """ + + data = values.of( + { + "ServiceSid": service_sid, + "Channel": serialize.object(channel), + "CustomerKey": customer_key, + "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, headers=headers + ) + + return TranscriptInstance(self._version, payload) + + def stream( + self, + service_sid: Union[str, object] = values.unset, + before_start_time: Union[str, object] = values.unset, + after_start_time: Union[str, object] = values.unset, + before_date_created: Union[str, object] = values.unset, + after_date_created: Union[str, object] = values.unset, + status: Union[str, object] = values.unset, + language_code: Union[str, object] = values.unset, + source_sid: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[TranscriptInstance]: + """ + Streams TranscriptInstance 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 service_sid: The unique SID identifier of the Service. + :param str before_start_time: Filter by before StartTime. + :param str after_start_time: Filter by after StartTime. + :param str before_date_created: Filter by before DateCreated. + :param str after_date_created: Filter by after DateCreated. + :param str status: Filter by status. + :param str language_code: Filter by Language Code. + :param str source_sid: Filter by SourceSid. + :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( + service_sid=service_sid, + before_start_time=before_start_time, + after_start_time=after_start_time, + before_date_created=before_date_created, + after_date_created=after_date_created, + status=status, + language_code=language_code, + source_sid=source_sid, + page_size=limits["page_size"], + ) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + service_sid: Union[str, object] = values.unset, + before_start_time: Union[str, object] = values.unset, + after_start_time: Union[str, object] = values.unset, + before_date_created: Union[str, object] = values.unset, + after_date_created: Union[str, object] = values.unset, + status: Union[str, object] = values.unset, + language_code: Union[str, object] = values.unset, + source_sid: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[TranscriptInstance]: + """ + Asynchronously streams TranscriptInstance 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 service_sid: The unique SID identifier of the Service. + :param str before_start_time: Filter by before StartTime. + :param str after_start_time: Filter by after StartTime. + :param str before_date_created: Filter by before DateCreated. + :param str after_date_created: Filter by after DateCreated. + :param str status: Filter by status. + :param str language_code: Filter by Language Code. + :param str source_sid: Filter by SourceSid. + :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( + service_sid=service_sid, + before_start_time=before_start_time, + after_start_time=after_start_time, + before_date_created=before_date_created, + after_date_created=after_date_created, + status=status, + language_code=language_code, + source_sid=source_sid, + page_size=limits["page_size"], + ) + + return self._version.stream_async(page, limits["limit"]) + + def list( + self, + service_sid: Union[str, object] = values.unset, + before_start_time: Union[str, object] = values.unset, + after_start_time: Union[str, object] = values.unset, + before_date_created: Union[str, object] = values.unset, + after_date_created: Union[str, object] = values.unset, + status: Union[str, object] = values.unset, + language_code: Union[str, object] = values.unset, + source_sid: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[TranscriptInstance]: + """ + Lists TranscriptInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str service_sid: The unique SID identifier of the Service. + :param str before_start_time: Filter by before StartTime. + :param str after_start_time: Filter by after StartTime. + :param str before_date_created: Filter by before DateCreated. + :param str after_date_created: Filter by after DateCreated. + :param str status: Filter by status. + :param str language_code: Filter by Language Code. + :param str source_sid: Filter by SourceSid. + :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( + service_sid=service_sid, + before_start_time=before_start_time, + after_start_time=after_start_time, + before_date_created=before_date_created, + after_date_created=after_date_created, + status=status, + language_code=language_code, + source_sid=source_sid, + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + service_sid: Union[str, object] = values.unset, + before_start_time: Union[str, object] = values.unset, + after_start_time: Union[str, object] = values.unset, + before_date_created: Union[str, object] = values.unset, + after_date_created: Union[str, object] = values.unset, + status: Union[str, object] = values.unset, + language_code: Union[str, object] = values.unset, + source_sid: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[TranscriptInstance]: + """ + Asynchronously lists TranscriptInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str service_sid: The unique SID identifier of the Service. + :param str before_start_time: Filter by before StartTime. + :param str after_start_time: Filter by after StartTime. + :param str before_date_created: Filter by before DateCreated. + :param str after_date_created: Filter by after DateCreated. + :param str status: Filter by status. + :param str language_code: Filter by Language Code. + :param str source_sid: Filter by SourceSid. + :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( + service_sid=service_sid, + before_start_time=before_start_time, + after_start_time=after_start_time, + before_date_created=before_date_created, + after_date_created=after_date_created, + status=status, + language_code=language_code, + source_sid=source_sid, + limit=limit, + page_size=page_size, + ) + ] + + def page( + self, + service_sid: Union[str, object] = values.unset, + before_start_time: Union[str, object] = values.unset, + after_start_time: Union[str, object] = values.unset, + before_date_created: Union[str, object] = values.unset, + after_date_created: Union[str, object] = values.unset, + status: Union[str, object] = values.unset, + language_code: 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, + ) -> TranscriptPage: + """ + Retrieve a single page of TranscriptInstance records from the API. + Request is executed immediately + + :param service_sid: The unique SID identifier of the Service. + :param before_start_time: Filter by before StartTime. + :param after_start_time: Filter by after StartTime. + :param before_date_created: Filter by before DateCreated. + :param after_date_created: Filter by after DateCreated. + :param status: Filter by status. + :param language_code: Filter by Language Code. + :param source_sid: Filter by SourceSid. + :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 TranscriptInstance + """ + data = values.of( + { + "ServiceSid": service_sid, + "BeforeStartTime": before_start_time, + "AfterStartTime": after_start_time, + "BeforeDateCreated": before_date_created, + "AfterDateCreated": after_date_created, + "Status": status, + "LanguageCode": language_code, + "SourceSid": source_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 TranscriptPage(self._version, response) + + async def page_async( + self, + service_sid: Union[str, object] = values.unset, + before_start_time: Union[str, object] = values.unset, + after_start_time: Union[str, object] = values.unset, + before_date_created: Union[str, object] = values.unset, + after_date_created: Union[str, object] = values.unset, + status: Union[str, object] = values.unset, + language_code: 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, + ) -> TranscriptPage: + """ + Asynchronously retrieve a single page of TranscriptInstance records from the API. + Request is executed immediately + + :param service_sid: The unique SID identifier of the Service. + :param before_start_time: Filter by before StartTime. + :param after_start_time: Filter by after StartTime. + :param before_date_created: Filter by before DateCreated. + :param after_date_created: Filter by after DateCreated. + :param status: Filter by status. + :param language_code: Filter by Language Code. + :param source_sid: Filter by SourceSid. + :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 TranscriptInstance + """ + data = values.of( + { + "ServiceSid": service_sid, + "BeforeStartTime": before_start_time, + "AfterStartTime": after_start_time, + "BeforeDateCreated": before_date_created, + "AfterDateCreated": after_date_created, + "Status": status, + "LanguageCode": language_code, + "SourceSid": source_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 TranscriptPage(self._version, response) + + def get_page(self, target_url: str) -> TranscriptPage: + """ + Retrieve a specific page of TranscriptInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of TranscriptInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return TranscriptPage(self._version, response) + + async def get_page_async(self, target_url: str) -> TranscriptPage: + """ + Asynchronously retrieve a specific page of TranscriptInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of TranscriptInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return TranscriptPage(self._version, response) + + def get(self, sid: str) -> TranscriptContext: + """ + Constructs a TranscriptContext + + :param sid: A 34 character string that uniquely identifies this Transcript. + """ + return TranscriptContext(self._version, sid=sid) + + def __call__(self, sid: str) -> TranscriptContext: + """ + Constructs a TranscriptContext + + :param sid: A 34 character string that uniquely identifies this Transcript. + """ + return TranscriptContext(self._version, sid=sid) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/intelligence/v2/transcript/media.py b/twilio/rest/intelligence/v2/transcript/media.py new file mode 100644 index 0000000000..76bc448e9b --- /dev/null +++ b/twilio/rest/intelligence/v2/transcript/media.py @@ -0,0 +1,221 @@ +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, 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 + + +class MediaInstance(InstanceResource): + """ + :ivar account_sid: The unique SID identifier of the Account. + :ivar media_url: Downloadable URL for media, if stored in Twilio AI. + :ivar service_sid: The unique SID identifier of the Service. + :ivar sid: The unique SID identifier of the Transcript. + :ivar url: The URL of this resource. + """ + + def __init__(self, version: Version, payload: Dict[str, Any], sid: str): + super().__init__(version) + + self.account_sid: Optional[str] = payload.get("account_sid") + self.media_url: Optional[str] = payload.get("media_url") + self.service_sid: Optional[str] = payload.get("service_sid") + self.sid: Optional[str] = payload.get("sid") + self.url: Optional[str] = payload.get("url") + + self._solution = { + "sid": sid, + } + self._context: Optional[MediaContext] = None + + @property + def _proxy(self) -> "MediaContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: MediaContext for this MediaInstance + """ + if self._context is None: + self._context = MediaContext( + self._version, + sid=self._solution["sid"], + ) + return self._context + + def fetch(self, redacted: Union[bool, object] = values.unset) -> "MediaInstance": + """ + Fetch the MediaInstance + + :param redacted: Grant access to PII Redacted/Unredacted Media. If redaction is enabled, the default is `true` to access redacted media. + + :returns: The fetched MediaInstance + """ + return self._proxy.fetch( + redacted=redacted, + ) + + async def fetch_async( + self, redacted: Union[bool, object] = values.unset + ) -> "MediaInstance": + """ + Asynchronous coroutine to fetch the MediaInstance + + :param redacted: Grant access to PII Redacted/Unredacted Media. If redaction is enabled, the default is `true` to access redacted media. + + :returns: The fetched MediaInstance + """ + return await self._proxy.fetch_async( + redacted=redacted, + ) + + 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 MediaContext(InstanceContext): + + def __init__(self, version: Version, sid: str): + """ + Initialize the MediaContext + + :param version: Version that contains the resource + :param sid: The unique SID identifier of the Transcript. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "sid": sid, + } + self._uri = "/Transcripts/{sid}/Media".format(**self._solution) + + def fetch(self, redacted: Union[bool, object] = values.unset) -> MediaInstance: + """ + Fetch the MediaInstance + + :param redacted: Grant access to PII Redacted/Unredacted Media. If redaction is enabled, the default is `true` to access redacted media. + + :returns: The fetched MediaInstance + """ + + data = values.of( + { + "Redacted": serialize.boolean_to_string(redacted), + } + ) + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) + + return MediaInstance( + self._version, + payload, + sid=self._solution["sid"], + ) + + async def fetch_async( + self, redacted: Union[bool, object] = values.unset + ) -> MediaInstance: + """ + Asynchronous coroutine to fetch the MediaInstance + + :param redacted: Grant access to PII Redacted/Unredacted Media. If redaction is enabled, the default is `true` to access redacted media. + + :returns: The fetched MediaInstance + """ + + data = values.of( + { + "Redacted": serialize.boolean_to_string(redacted), + } + ) + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + + return MediaInstance( + 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 MediaList(ListResource): + + def __init__(self, version: Version, sid: str): + """ + Initialize the MediaList + + :param version: Version that contains the resource + :param sid: The unique SID identifier of the Transcript. + + """ + super().__init__(version) + + # Path Solution + self._solution = { + "sid": sid, + } + + def get(self) -> MediaContext: + """ + Constructs a MediaContext + + """ + return MediaContext(self._version, sid=self._solution["sid"]) + + def __call__(self) -> MediaContext: + """ + Constructs a MediaContext + + """ + return MediaContext(self._version, sid=self._solution["sid"]) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/intelligence/v2/transcript/operator_result.py b/twilio/rest/intelligence/v2/transcript/operator_result.py new file mode 100644 index 0000000000..9ba2c57f62 --- /dev/null +++ b/twilio/rest/intelligence/v2/transcript/operator_result.py @@ -0,0 +1,531 @@ +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, 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 OperatorResultInstance(InstanceResource): + + class OperatorType(object): + CONVERSATION_CLASSIFY = "conversation_classify" + UTTERANCE_CLASSIFY = "utterance_classify" + EXTRACT = "extract" + EXTRACT_NORMALIZE = "extract_normalize" + PII_EXTRACT = "pii_extract" + TEXT_GENERATION = "text_generation" + JSON = "json" + + """ + :ivar operator_type: + :ivar name: The name of the applied Language Understanding. + :ivar operator_sid: A 34 character string that identifies this Language Understanding operator sid. + :ivar extract_match: Boolean to tell if extract Language Understanding Processing model matches results. + :ivar match_probability: Percentage of 'matching' class needed to consider a sentence matches + :ivar normalized_result: Normalized output of extraction stage which matches Label. + :ivar utterance_results: List of mapped utterance object which matches sentences. + :ivar utterance_match: Boolean to tell if Utterance matches results. + :ivar predicted_label: The 'matching' class. This might be available on conversation classify model outputs. + :ivar predicted_probability: Percentage of 'matching' class needed to consider a sentence matches. + :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. + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + transcript_sid: str, + operator_sid: Optional[str] = None, + ): + super().__init__(version) + + self.operator_type: Optional["OperatorResultInstance.OperatorType"] = ( + payload.get("operator_type") + ) + self.name: Optional[str] = payload.get("name") + self.operator_sid: Optional[str] = payload.get("operator_sid") + self.extract_match: Optional[bool] = payload.get("extract_match") + self.match_probability: Optional[float] = deserialize.decimal( + payload.get("match_probability") + ) + self.normalized_result: Optional[str] = payload.get("normalized_result") + self.utterance_results: Optional[List[Dict[str, object]]] = payload.get( + "utterance_results" + ) + self.utterance_match: Optional[bool] = payload.get("utterance_match") + self.predicted_label: Optional[str] = payload.get("predicted_label") + self.predicted_probability: Optional[float] = deserialize.decimal( + payload.get("predicted_probability") + ) + self.label_probabilities: Optional[Dict[str, object]] = payload.get( + "label_probabilities" + ) + self.extract_results: Optional[Dict[str, object]] = payload.get( + "extract_results" + ) + 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") + + self._solution = { + "transcript_sid": transcript_sid, + "operator_sid": operator_sid or self.operator_sid, + } + self._context: Optional[OperatorResultContext] = None + + @property + def _proxy(self) -> "OperatorResultContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: OperatorResultContext for this OperatorResultInstance + """ + if self._context is None: + self._context = OperatorResultContext( + self._version, + transcript_sid=self._solution["transcript_sid"], + operator_sid=self._solution["operator_sid"], + ) + return self._context + + def fetch( + self, redacted: Union[bool, object] = values.unset + ) -> "OperatorResultInstance": + """ + Fetch the OperatorResultInstance + + :param redacted: Grant access to PII redacted/unredacted Language Understanding operator. If redaction is enabled, the default is True. + + :returns: The fetched OperatorResultInstance + """ + return self._proxy.fetch( + redacted=redacted, + ) + + async def fetch_async( + self, redacted: Union[bool, object] = values.unset + ) -> "OperatorResultInstance": + """ + Asynchronous coroutine to fetch the OperatorResultInstance + + :param redacted: Grant access to PII redacted/unredacted Language Understanding operator. If redaction is enabled, the default is True. + + :returns: The fetched OperatorResultInstance + """ + return await self._proxy.fetch_async( + redacted=redacted, + ) + + 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 OperatorResultContext(InstanceContext): + + def __init__(self, version: Version, transcript_sid: str, operator_sid: str): + """ + Initialize the OperatorResultContext + + :param version: Version that contains the resource + :param transcript_sid: A 34 character string that uniquely identifies this Transcript. + :param operator_sid: A 34 character string that identifies this Language Understanding operator sid. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "transcript_sid": transcript_sid, + "operator_sid": operator_sid, + } + self._uri = ( + "/Transcripts/{transcript_sid}/OperatorResults/{operator_sid}".format( + **self._solution + ) + ) + + def fetch( + self, redacted: Union[bool, object] = values.unset + ) -> OperatorResultInstance: + """ + Fetch the OperatorResultInstance + + :param redacted: Grant access to PII redacted/unredacted Language Understanding operator. If redaction is enabled, the default is True. + + :returns: The fetched OperatorResultInstance + """ + + data = values.of( + { + "Redacted": serialize.boolean_to_string(redacted), + } + ) + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) + + return OperatorResultInstance( + self._version, + payload, + transcript_sid=self._solution["transcript_sid"], + operator_sid=self._solution["operator_sid"], + ) + + async def fetch_async( + self, redacted: Union[bool, object] = values.unset + ) -> OperatorResultInstance: + """ + Asynchronous coroutine to fetch the OperatorResultInstance + + :param redacted: Grant access to PII redacted/unredacted Language Understanding operator. If redaction is enabled, the default is True. + + :returns: The fetched OperatorResultInstance + """ + + data = values.of( + { + "Redacted": serialize.boolean_to_string(redacted), + } + ) + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + + return OperatorResultInstance( + self._version, + payload, + transcript_sid=self._solution["transcript_sid"], + operator_sid=self._solution["operator_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 OperatorResultPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> OperatorResultInstance: + """ + Build an instance of OperatorResultInstance + + :param payload: Payload response from the API + """ + return OperatorResultInstance( + self._version, payload, transcript_sid=self._solution["transcript_sid"] + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class OperatorResultList(ListResource): + + def __init__(self, version: Version, transcript_sid: str): + """ + Initialize the OperatorResultList + + :param version: Version that contains the resource + :param transcript_sid: A 34 character string that uniquely identifies this Transcript. + + """ + super().__init__(version) + + # Path Solution + self._solution = { + "transcript_sid": transcript_sid, + } + self._uri = "/Transcripts/{transcript_sid}/OperatorResults".format( + **self._solution + ) + + def stream( + self, + redacted: Union[bool, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[OperatorResultInstance]: + """ + Streams OperatorResultInstance 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 bool redacted: Grant access to PII redacted/unredacted Language Understanding operator. If redaction is enabled, the default is True. + :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(redacted=redacted, page_size=limits["page_size"]) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + redacted: Union[bool, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[OperatorResultInstance]: + """ + Asynchronously streams OperatorResultInstance 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 bool redacted: Grant access to PII redacted/unredacted Language Understanding operator. If redaction is enabled, the default is True. + :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(redacted=redacted, page_size=limits["page_size"]) + + return self._version.stream_async(page, limits["limit"]) + + def list( + self, + redacted: Union[bool, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[OperatorResultInstance]: + """ + Lists OperatorResultInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param bool redacted: Grant access to PII redacted/unredacted Language Understanding operator. If redaction is enabled, the default is True. + :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( + redacted=redacted, + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + redacted: Union[bool, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[OperatorResultInstance]: + """ + Asynchronously lists OperatorResultInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param bool redacted: Grant access to PII redacted/unredacted Language Understanding operator. If redaction is enabled, the default is True. + :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( + redacted=redacted, + limit=limit, + page_size=page_size, + ) + ] + + def page( + self, + redacted: 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, + ) -> OperatorResultPage: + """ + Retrieve a single page of OperatorResultInstance records from the API. + Request is executed immediately + + :param redacted: Grant access to PII redacted/unredacted Language Understanding operator. If redaction is enabled, the default is True. + :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 OperatorResultInstance + """ + data = values.of( + { + "Redacted": serialize.boolean_to_string(redacted), + "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 OperatorResultPage(self._version, response, self._solution) + + async def page_async( + self, + redacted: 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, + ) -> OperatorResultPage: + """ + Asynchronously retrieve a single page of OperatorResultInstance records from the API. + Request is executed immediately + + :param redacted: Grant access to PII redacted/unredacted Language Understanding operator. If redaction is enabled, the default is True. + :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 OperatorResultInstance + """ + data = values.of( + { + "Redacted": serialize.boolean_to_string(redacted), + "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 OperatorResultPage(self._version, response, self._solution) + + def get_page(self, target_url: str) -> OperatorResultPage: + """ + Retrieve a specific page of OperatorResultInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of OperatorResultInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return OperatorResultPage(self._version, response, self._solution) + + async def get_page_async(self, target_url: str) -> OperatorResultPage: + """ + Asynchronously retrieve a specific page of OperatorResultInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of OperatorResultInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return OperatorResultPage(self._version, response, self._solution) + + def get(self, operator_sid: str) -> OperatorResultContext: + """ + Constructs a OperatorResultContext + + :param operator_sid: A 34 character string that identifies this Language Understanding operator sid. + """ + return OperatorResultContext( + self._version, + transcript_sid=self._solution["transcript_sid"], + operator_sid=operator_sid, + ) + + def __call__(self, operator_sid: str) -> OperatorResultContext: + """ + Constructs a OperatorResultContext + + :param operator_sid: A 34 character string that identifies this Language Understanding operator sid. + """ + return OperatorResultContext( + self._version, + transcript_sid=self._solution["transcript_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/transcript/sentence.py b/twilio/rest/intelligence/v2/transcript/sentence.py new file mode 100644 index 0000000000..f4fb0b3b92 --- /dev/null +++ b/twilio/rest/intelligence/v2/transcript/sentence.py @@ -0,0 +1,348 @@ +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, 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 SentenceInstance(InstanceResource): + """ + :ivar media_channel: The channel number. + :ivar sentence_index: The index of the sentence in the transcript. + :ivar start_time: Offset from the beginning of the transcript when this sentence starts. + :ivar end_time: Offset from the beginning of the transcript when this sentence ends. + :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): + super().__init__(version) + + self.media_channel: Optional[int] = deserialize.integer( + payload.get("media_channel") + ) + self.sentence_index: Optional[int] = deserialize.integer( + payload.get("sentence_index") + ) + self.start_time: Optional[float] = deserialize.decimal( + payload.get("start_time") + ) + self.end_time: Optional[float] = deserialize.decimal(payload.get("end_time")) + self.transcript: Optional[str] = payload.get("transcript") + self.sid: Optional[str] = payload.get("sid") + 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, + } + + 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 SentencePage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> SentenceInstance: + """ + Build an instance of SentenceInstance + + :param payload: Payload response from the API + """ + return SentenceInstance( + self._version, payload, transcript_sid=self._solution["transcript_sid"] + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class SentenceList(ListResource): + + def __init__(self, version: Version, transcript_sid: str): + """ + Initialize the SentenceList + + :param version: Version that contains the resource + :param transcript_sid: The unique SID identifier of the Transcript. + + """ + super().__init__(version) + + # Path Solution + self._solution = { + "transcript_sid": transcript_sid, + } + self._uri = "/Transcripts/{transcript_sid}/Sentences".format(**self._solution) + + 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]: + """ + Streams SentenceInstance 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 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 + 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( + 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]: + """ + Asynchronously streams SentenceInstance 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 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 + 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( + 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]: + """ + Lists SentenceInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + 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 + 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( + redacted=redacted, + word_timestamps=word_timestamps, + limit=limit, + page_size=page_size, + ) + ) + + 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]: + """ + Asynchronously lists SentenceInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + 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 + 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( + redacted=redacted, + word_timestamps=word_timestamps, + limit=limit, + page_size=page_size, + ) + ] + + 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, + ) -> SentencePage: + """ + Retrieve a single page of SentenceInstance records from the API. + 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 + + :returns: Page of SentenceInstance + """ + 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 = 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, + ) -> SentencePage: + """ + Asynchronously retrieve a single page of SentenceInstance records from the API. + 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 + + :returns: Page of SentenceInstance + """ + 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, headers=headers + ) + return SentencePage(self._version, response, self._solution) + + def get_page(self, target_url: str) -> SentencePage: + """ + Retrieve a specific page of SentenceInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of SentenceInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return SentencePage(self._version, response, self._solution) + + async def get_page_async(self, target_url: str) -> SentencePage: + """ + Asynchronously retrieve a specific page of SentenceInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of SentenceInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return SentencePage(self._version, response, self._solution) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/ip_messaging/IpMessagingBase.py b/twilio/rest/ip_messaging/IpMessagingBase.py index d9e063c308..752d41adce 100644 --- a/twilio/rest/ip_messaging/IpMessagingBase.py +++ b/twilio/rest/ip_messaging/IpMessagingBase.py @@ -18,6 +18,7 @@ class IpMessagingBase(Domain): + def __init__(self, twilio: Client): """ Initialize the IpMessaging Domain diff --git a/twilio/rest/ip_messaging/v1/__init__.py b/twilio/rest/ip_messaging/v1/__init__.py index 1fd53b76b1..d1f40c791f 100644 --- a/twilio/rest/ip_messaging/v1/__init__.py +++ b/twilio/rest/ip_messaging/v1/__init__.py @@ -20,6 +20,7 @@ class V1(Version): + def __init__(self, domain: Domain): """ Initialize the V1 version of IpMessaging diff --git a/twilio/rest/ip_messaging/v1/credential.py b/twilio/rest/ip_messaging/v1/credential.py index 6a193aa1f4..4aa6d3fc63 100644 --- a/twilio/rest/ip_messaging/v1/credential.py +++ b/twilio/rest/ip_messaging/v1/credential.py @@ -12,10 +12,9 @@ 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 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 @@ -24,6 +23,7 @@ class CredentialInstance(InstanceResource): + class PushService(object): GCM = "gcm" APN = "apn" @@ -185,6 +185,7 @@ def __repr__(self) -> str: class CredentialContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the CredentialContext @@ -207,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: """ @@ -219,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: @@ -232,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, @@ -251,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( @@ -283,21 +290,25 @@ def update( :returns: The updated CredentialInstance """ + data = values.of( { "FriendlyName": friendly_name, "Certificate": certificate, "PrivateKey": private_key, - "Sandbox": sandbox, + "Sandbox": serialize.boolean_to_string(sandbox), "ApiKey": api_key, "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"]) @@ -323,21 +334,25 @@ async def update_async( :returns: The updated CredentialInstance """ + data = values.of( { "FriendlyName": friendly_name, "Certificate": certificate, "PrivateKey": private_key, - "Sandbox": sandbox, + "Sandbox": serialize.boolean_to_string(sandbox), "ApiKey": api_key, "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"]) @@ -353,6 +368,7 @@ def __repr__(self) -> str: class CredentialPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> CredentialInstance: """ Build an instance of CredentialInstance @@ -371,6 +387,7 @@ def __repr__(self) -> str: class CredentialList(ListResource): + def __init__(self, version: Version): """ Initialize the CredentialList @@ -405,22 +422,26 @@ def create( :returns: The created CredentialInstance """ + data = values.of( { "Type": type, "FriendlyName": friendly_name, "Certificate": certificate, "PrivateKey": private_key, - "Sandbox": sandbox, + "Sandbox": serialize.boolean_to_string(sandbox), "ApiKey": api_key, "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) @@ -448,22 +469,26 @@ async def create_async( :returns: The created CredentialInstance """ + data = values.of( { "Type": type, "FriendlyName": friendly_name, "Certificate": certificate, "PrivateKey": private_key, - "Sandbox": sandbox, + "Sandbox": serialize.boolean_to_string(sandbox), "ApiKey": api_key, "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) @@ -595,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( @@ -622,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 c07b4cc252..3a77cf765e 100644 --- a/twilio/rest/ip_messaging/v1/service/__init__.py +++ b/twilio/rest/ip_messaging/v1/service/__init__.py @@ -12,7 +12,6 @@ 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 @@ -27,7 +26,6 @@ class ServiceInstance(InstanceResource): - """ :ivar sid: :ivar account_sid: @@ -529,6 +527,7 @@ def __repr__(self) -> str: class ServiceContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the ServiceContext @@ -555,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: """ @@ -567,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: @@ -580,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, @@ -599,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( @@ -727,23 +732,34 @@ def update( :returns: The updated ServiceInstance """ + data = values.of( { "FriendlyName": friendly_name, "DefaultServiceRoleSid": default_service_role_sid, "DefaultChannelRoleSid": default_channel_role_sid, "DefaultChannelCreatorRoleSid": default_channel_creator_role_sid, - "ReadStatusEnabled": read_status_enabled, - "ReachabilityEnabled": reachability_enabled, + "ReadStatusEnabled": serialize.boolean_to_string(read_status_enabled), + "ReachabilityEnabled": serialize.boolean_to_string( + reachability_enabled + ), "TypingIndicatorTimeout": typing_indicator_timeout, "ConsumptionReportInterval": consumption_report_interval, - "Notifications.NewMessage.Enabled": notifications_new_message_enabled, + "Notifications.NewMessage.Enabled": serialize.boolean_to_string( + notifications_new_message_enabled + ), "Notifications.NewMessage.Template": notifications_new_message_template, - "Notifications.AddedToChannel.Enabled": notifications_added_to_channel_enabled, + "Notifications.AddedToChannel.Enabled": serialize.boolean_to_string( + notifications_added_to_channel_enabled + ), "Notifications.AddedToChannel.Template": notifications_added_to_channel_template, - "Notifications.RemovedFromChannel.Enabled": notifications_removed_from_channel_enabled, + "Notifications.RemovedFromChannel.Enabled": serialize.boolean_to_string( + notifications_removed_from_channel_enabled + ), "Notifications.RemovedFromChannel.Template": notifications_removed_from_channel_template, - "Notifications.InvitedToChannel.Enabled": notifications_invited_to_channel_enabled, + "Notifications.InvitedToChannel.Enabled": serialize.boolean_to_string( + notifications_invited_to_channel_enabled + ), "Notifications.InvitedToChannel.Template": notifications_invited_to_channel_template, "PreWebhookUrl": pre_webhook_url, "PostWebhookUrl": post_webhook_url, @@ -785,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"]) @@ -911,23 +930,34 @@ async def update_async( :returns: The updated ServiceInstance """ + data = values.of( { "FriendlyName": friendly_name, "DefaultServiceRoleSid": default_service_role_sid, "DefaultChannelRoleSid": default_channel_role_sid, "DefaultChannelCreatorRoleSid": default_channel_creator_role_sid, - "ReadStatusEnabled": read_status_enabled, - "ReachabilityEnabled": reachability_enabled, + "ReadStatusEnabled": serialize.boolean_to_string(read_status_enabled), + "ReachabilityEnabled": serialize.boolean_to_string( + reachability_enabled + ), "TypingIndicatorTimeout": typing_indicator_timeout, "ConsumptionReportInterval": consumption_report_interval, - "Notifications.NewMessage.Enabled": notifications_new_message_enabled, + "Notifications.NewMessage.Enabled": serialize.boolean_to_string( + notifications_new_message_enabled + ), "Notifications.NewMessage.Template": notifications_new_message_template, - "Notifications.AddedToChannel.Enabled": notifications_added_to_channel_enabled, + "Notifications.AddedToChannel.Enabled": serialize.boolean_to_string( + notifications_added_to_channel_enabled + ), "Notifications.AddedToChannel.Template": notifications_added_to_channel_template, - "Notifications.RemovedFromChannel.Enabled": notifications_removed_from_channel_enabled, + "Notifications.RemovedFromChannel.Enabled": serialize.boolean_to_string( + notifications_removed_from_channel_enabled + ), "Notifications.RemovedFromChannel.Template": notifications_removed_from_channel_template, - "Notifications.InvitedToChannel.Enabled": notifications_invited_to_channel_enabled, + "Notifications.InvitedToChannel.Enabled": serialize.boolean_to_string( + notifications_invited_to_channel_enabled + ), "Notifications.InvitedToChannel.Template": notifications_invited_to_channel_template, "PreWebhookUrl": pre_webhook_url, "PostWebhookUrl": post_webhook_url, @@ -969,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"]) @@ -1025,6 +1058,7 @@ def __repr__(self) -> str: class ServicePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ServiceInstance: """ Build an instance of ServiceInstance @@ -1043,6 +1077,7 @@ def __repr__(self) -> str: class ServiceList(ListResource): + def __init__(self, version: Version): """ Initialize the ServiceList @@ -1062,16 +1097,20 @@ def create(self, friendly_name: str) -> ServiceInstance: :returns: The created ServiceInstance """ + data = values.of( { "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) @@ -1084,16 +1123,20 @@ async def create_async(self, friendly_name: str) -> ServiceInstance: :returns: The created ServiceInstance """ + data = values.of( { "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) @@ -1225,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( @@ -1252,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 32961bcff0..14423c9e38 100644 --- a/twilio/rest/ip_messaging/v1/service/channel/__init__.py +++ b/twilio/rest/ip_messaging/v1/service/channel/__init__.py @@ -12,7 +12,6 @@ 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 @@ -27,6 +26,7 @@ class ChannelInstance(InstanceResource): + class ChannelType(object): PUBLIC = "public" PRIVATE = "private" @@ -212,6 +212,7 @@ def __repr__(self) -> str: class ChannelContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, sid: str): """ Initialize the ChannelContext @@ -240,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: """ @@ -252,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: @@ -265,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, @@ -285,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( @@ -312,6 +319,7 @@ def update( :returns: The updated ChannelInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -319,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( @@ -348,6 +359,7 @@ async def update_async( :returns: The updated ChannelInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -355,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( @@ -419,6 +434,7 @@ def __repr__(self) -> str: class ChannelPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ChannelInstance: """ Build an instance of ChannelInstance @@ -439,6 +455,7 @@ def __repr__(self) -> str: class ChannelList(ListResource): + def __init__(self, version: Version, service_sid: str): """ Initialize the ChannelList @@ -472,6 +489,7 @@ def create( :returns: The created ChannelInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -480,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( @@ -508,6 +529,7 @@ async def create_async( :returns: The created ChannelInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -516,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( @@ -667,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( @@ -697,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 476e89f4c2..d348540346 100644 --- a/twilio/rest/ip_messaging/v1/service/channel/invite.py +++ b/twilio/rest/ip_messaging/v1/service/channel/invite.py @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class InviteInstance(InstanceResource): - """ :ivar sid: :ivar account_sid: @@ -134,6 +132,7 @@ def __repr__(self) -> str: class InviteContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, channel_sid: str, sid: str): """ Initialize the InviteContext @@ -164,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: """ @@ -176,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: @@ -189,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, @@ -210,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( @@ -234,6 +239,7 @@ def __repr__(self) -> str: class InvitePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> InviteInstance: """ Build an instance of InviteInstance @@ -257,6 +263,7 @@ def __repr__(self) -> str: class InviteList(ListResource): + def __init__(self, version: Version, service_sid: str, channel_sid: str): """ Initialize the InviteList @@ -288,17 +295,21 @@ def create( :returns: The created InviteInstance """ + data = values.of( { "Identity": identity, "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( @@ -319,17 +330,21 @@ async def create_async( :returns: The created InviteInstance """ + data = values.of( { "Identity": identity, "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( @@ -479,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( @@ -509,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 2414e72c93..26a68650ef 100644 --- a/twilio/rest/ip_messaging/v1/service/channel/member.py +++ b/twilio/rest/ip_messaging/v1/service/channel/member.py @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class MemberInstance(InstanceResource): - """ :ivar sid: :ivar account_sid: @@ -64,9 +62,9 @@ def __init__( self.last_consumed_message_index: Optional[int] = deserialize.integer( payload.get("last_consumed_message_index") ) - self.last_consumption_timestamp: Optional[ - datetime - ] = deserialize.iso8601_datetime(payload.get("last_consumption_timestamp")) + self.last_consumption_timestamp: Optional[datetime] = ( + deserialize.iso8601_datetime(payload.get("last_consumption_timestamp")) + ) self.url: Optional[str] = payload.get("url") self._solution = { @@ -176,6 +174,7 @@ def __repr__(self) -> str: class MemberContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, channel_sid: str, sid: str): """ Initialize the MemberContext @@ -206,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: """ @@ -218,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: @@ -231,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, @@ -252,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( @@ -278,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( @@ -312,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( @@ -344,6 +357,7 @@ def __repr__(self) -> str: class MemberPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> MemberInstance: """ Build an instance of MemberInstance @@ -367,6 +381,7 @@ def __repr__(self) -> str: class MemberList(ListResource): + def __init__(self, version: Version, service_sid: str, channel_sid: str): """ Initialize the MemberList @@ -398,17 +413,21 @@ def create( :returns: The created MemberInstance """ + data = values.of( { "Identity": identity, "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( @@ -429,17 +448,21 @@ async def create_async( :returns: The created MemberInstance """ + data = values.of( { "Identity": identity, "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( @@ -589,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( @@ -619,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 e562faafb6..ad7c05d8a1 100644 --- a/twilio/rest/ip_messaging/v1/service/channel/message.py +++ b/twilio/rest/ip_messaging/v1/service/channel/message.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class MessageInstance(InstanceResource): + class OrderType(object): ASC = "asc" DESC = "desc" @@ -179,6 +179,7 @@ def __repr__(self) -> str: class MessageContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, channel_sid: str, sid: str): """ Initialize the MessageContext @@ -209,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: """ @@ -221,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: @@ -234,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, @@ -255,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( @@ -281,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( @@ -315,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( @@ -347,6 +362,7 @@ def __repr__(self) -> str: class MessagePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> MessageInstance: """ Build an instance of MessageInstance @@ -370,6 +386,7 @@ def __repr__(self) -> str: class MessageList(ListResource): + def __init__(self, version: Version, service_sid: str, channel_sid: str): """ Initialize the MessageList @@ -405,6 +422,7 @@ def create( :returns: The created MessageInstance """ + data = values.of( { "Body": body, @@ -412,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( @@ -441,6 +462,7 @@ async def create_async( :returns: The created MessageInstance """ + data = values.of( { "Body": body, @@ -448,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( @@ -602,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( @@ -632,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 e637e2c900..d5d0628032 100644 --- a/twilio/rest/ip_messaging/v1/service/role.py +++ b/twilio/rest/ip_messaging/v1/service/role.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class RoleInstance(InstanceResource): + class RoleType(object): CHANNEL = "channel" DEPLOYMENT = "deployment" @@ -156,6 +156,7 @@ def __repr__(self) -> str: class RoleContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, sid: str): """ Initialize the RoleContext @@ -180,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: """ @@ -192,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: @@ -205,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, @@ -225,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( @@ -245,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( @@ -272,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( @@ -302,6 +317,7 @@ def __repr__(self) -> str: class RolePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> RoleInstance: """ Build an instance of RoleInstance @@ -322,6 +338,7 @@ def __repr__(self) -> str: class RoleList(ListResource): + def __init__(self, version: Version, service_sid: str): """ Initialize the RoleList @@ -350,6 +367,7 @@ def create( :returns: The created RoleInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -357,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( @@ -380,6 +401,7 @@ async def create_async( :returns: The created RoleInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -387,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( @@ -525,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( @@ -552,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 e19eb82be6..5f37f2d3aa 100644 --- a/twilio/rest/ip_messaging/v1/service/user/__init__.py +++ b/twilio/rest/ip_messaging/v1/service/user/__init__.py @@ -12,7 +12,6 @@ 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 @@ -25,7 +24,6 @@ class UserInstance(InstanceResource): - """ :ivar sid: :ivar account_sid: @@ -191,6 +189,7 @@ def __repr__(self) -> str: class UserContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, sid: str): """ Initialize the UserContext @@ -217,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: """ @@ -229,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: @@ -242,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, @@ -262,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( @@ -289,6 +294,7 @@ def update( :returns: The updated UserInstance """ + data = values.of( { "RoleSid": role_sid, @@ -296,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( @@ -325,6 +334,7 @@ async def update_async( :returns: The updated UserInstance """ + data = values.of( { "RoleSid": role_sid, @@ -332,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( @@ -370,6 +383,7 @@ def __repr__(self) -> str: class UserPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> UserInstance: """ Build an instance of UserInstance @@ -390,6 +404,7 @@ def __repr__(self) -> str: class UserList(ListResource): + def __init__(self, version: Version, service_sid: str): """ Initialize the UserList @@ -423,6 +438,7 @@ def create( :returns: The created UserInstance """ + data = values.of( { "Identity": identity, @@ -431,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( @@ -459,6 +478,7 @@ async def create_async( :returns: The created UserInstance """ + data = values.of( { "Identity": identity, @@ -467,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( @@ -605,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( @@ -632,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 4d00fa50c0..4245449869 100644 --- a/twilio/rest/ip_messaging/v1/service/user/user_channel.py +++ b/twilio/rest/ip_messaging/v1/service/user/user_channel.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import deserialize, values @@ -23,6 +22,7 @@ class UserChannelInstance(InstanceResource): + class ChannelStatus(object): JOINED = "joined" INVITED = "invited" @@ -75,6 +75,7 @@ def __repr__(self) -> str: class UserChannelPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> UserChannelInstance: """ Build an instance of UserChannelInstance @@ -98,6 +99,7 @@ def __repr__(self) -> str: class UserChannelList(ListResource): + def __init__(self, version: Version, service_sid: str, user_sid: str): """ Initialize the UserChannelList @@ -245,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( @@ -272,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/__init__.py b/twilio/rest/ip_messaging/v2/__init__.py index 966a35a441..6003c86b12 100644 --- a/twilio/rest/ip_messaging/v2/__init__.py +++ b/twilio/rest/ip_messaging/v2/__init__.py @@ -20,6 +20,7 @@ class V2(Version): + def __init__(self, domain: Domain): """ Initialize the V2 version of IpMessaging diff --git a/twilio/rest/ip_messaging/v2/credential.py b/twilio/rest/ip_messaging/v2/credential.py index 3d72b3a0d6..065c5048e9 100644 --- a/twilio/rest/ip_messaging/v2/credential.py +++ b/twilio/rest/ip_messaging/v2/credential.py @@ -12,10 +12,9 @@ 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 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 @@ -24,6 +23,7 @@ class CredentialInstance(InstanceResource): + class PushService(object): GCM = "gcm" APN = "apn" @@ -185,6 +185,7 @@ def __repr__(self) -> str: class CredentialContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the CredentialContext @@ -207,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: """ @@ -219,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: @@ -232,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, @@ -251,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( @@ -283,21 +290,25 @@ def update( :returns: The updated CredentialInstance """ + data = values.of( { "FriendlyName": friendly_name, "Certificate": certificate, "PrivateKey": private_key, - "Sandbox": sandbox, + "Sandbox": serialize.boolean_to_string(sandbox), "ApiKey": api_key, "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"]) @@ -323,21 +334,25 @@ async def update_async( :returns: The updated CredentialInstance """ + data = values.of( { "FriendlyName": friendly_name, "Certificate": certificate, "PrivateKey": private_key, - "Sandbox": sandbox, + "Sandbox": serialize.boolean_to_string(sandbox), "ApiKey": api_key, "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"]) @@ -353,6 +368,7 @@ def __repr__(self) -> str: class CredentialPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> CredentialInstance: """ Build an instance of CredentialInstance @@ -371,6 +387,7 @@ def __repr__(self) -> str: class CredentialList(ListResource): + def __init__(self, version: Version): """ Initialize the CredentialList @@ -405,22 +422,26 @@ def create( :returns: The created CredentialInstance """ + data = values.of( { "Type": type, "FriendlyName": friendly_name, "Certificate": certificate, "PrivateKey": private_key, - "Sandbox": sandbox, + "Sandbox": serialize.boolean_to_string(sandbox), "ApiKey": api_key, "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) @@ -448,22 +469,26 @@ async def create_async( :returns: The created CredentialInstance """ + data = values.of( { "Type": type, "FriendlyName": friendly_name, "Certificate": certificate, "PrivateKey": private_key, - "Sandbox": sandbox, + "Sandbox": serialize.boolean_to_string(sandbox), "ApiKey": api_key, "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) @@ -595,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( @@ -622,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 b94def1fa6..a303f10f33 100644 --- a/twilio/rest/ip_messaging/v2/service/__init__.py +++ b/twilio/rest/ip_messaging/v2/service/__init__.py @@ -12,7 +12,6 @@ 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 @@ -28,7 +27,6 @@ class ServiceInstance(InstanceResource): - """ :ivar sid: :ivar account_sid: @@ -411,6 +409,7 @@ def __repr__(self) -> str: class ServiceContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the ServiceContext @@ -438,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: """ @@ -450,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: @@ -463,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, @@ -482,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( @@ -566,27 +571,40 @@ def update( :returns: The updated ServiceInstance """ + data = values.of( { "FriendlyName": friendly_name, "DefaultServiceRoleSid": default_service_role_sid, "DefaultChannelRoleSid": default_channel_role_sid, "DefaultChannelCreatorRoleSid": default_channel_creator_role_sid, - "ReadStatusEnabled": read_status_enabled, - "ReachabilityEnabled": reachability_enabled, + "ReadStatusEnabled": serialize.boolean_to_string(read_status_enabled), + "ReachabilityEnabled": serialize.boolean_to_string( + reachability_enabled + ), "TypingIndicatorTimeout": typing_indicator_timeout, "ConsumptionReportInterval": consumption_report_interval, - "Notifications.NewMessage.Enabled": notifications_new_message_enabled, + "Notifications.NewMessage.Enabled": serialize.boolean_to_string( + notifications_new_message_enabled + ), "Notifications.NewMessage.Template": notifications_new_message_template, "Notifications.NewMessage.Sound": notifications_new_message_sound, - "Notifications.NewMessage.BadgeCountEnabled": notifications_new_message_badge_count_enabled, - "Notifications.AddedToChannel.Enabled": notifications_added_to_channel_enabled, + "Notifications.NewMessage.BadgeCountEnabled": serialize.boolean_to_string( + notifications_new_message_badge_count_enabled + ), + "Notifications.AddedToChannel.Enabled": serialize.boolean_to_string( + notifications_added_to_channel_enabled + ), "Notifications.AddedToChannel.Template": notifications_added_to_channel_template, "Notifications.AddedToChannel.Sound": notifications_added_to_channel_sound, - "Notifications.RemovedFromChannel.Enabled": notifications_removed_from_channel_enabled, + "Notifications.RemovedFromChannel.Enabled": serialize.boolean_to_string( + notifications_removed_from_channel_enabled + ), "Notifications.RemovedFromChannel.Template": notifications_removed_from_channel_template, "Notifications.RemovedFromChannel.Sound": notifications_removed_from_channel_sound, - "Notifications.InvitedToChannel.Enabled": notifications_invited_to_channel_enabled, + "Notifications.InvitedToChannel.Enabled": serialize.boolean_to_string( + notifications_invited_to_channel_enabled + ), "Notifications.InvitedToChannel.Template": notifications_invited_to_channel_template, "Notifications.InvitedToChannel.Sound": notifications_invited_to_channel_sound, "PreWebhookUrl": pre_webhook_url, @@ -598,14 +616,19 @@ def update( "Media.CompatibilityMessage": media_compatibility_message, "PreWebhookRetryCount": pre_webhook_retry_count, "PostWebhookRetryCount": post_webhook_retry_count, - "Notifications.LogEnabled": notifications_log_enabled, + "Notifications.LogEnabled": serialize.boolean_to_string( + notifications_log_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"]) @@ -683,27 +706,40 @@ async def update_async( :returns: The updated ServiceInstance """ + data = values.of( { "FriendlyName": friendly_name, "DefaultServiceRoleSid": default_service_role_sid, "DefaultChannelRoleSid": default_channel_role_sid, "DefaultChannelCreatorRoleSid": default_channel_creator_role_sid, - "ReadStatusEnabled": read_status_enabled, - "ReachabilityEnabled": reachability_enabled, + "ReadStatusEnabled": serialize.boolean_to_string(read_status_enabled), + "ReachabilityEnabled": serialize.boolean_to_string( + reachability_enabled + ), "TypingIndicatorTimeout": typing_indicator_timeout, "ConsumptionReportInterval": consumption_report_interval, - "Notifications.NewMessage.Enabled": notifications_new_message_enabled, + "Notifications.NewMessage.Enabled": serialize.boolean_to_string( + notifications_new_message_enabled + ), "Notifications.NewMessage.Template": notifications_new_message_template, "Notifications.NewMessage.Sound": notifications_new_message_sound, - "Notifications.NewMessage.BadgeCountEnabled": notifications_new_message_badge_count_enabled, - "Notifications.AddedToChannel.Enabled": notifications_added_to_channel_enabled, + "Notifications.NewMessage.BadgeCountEnabled": serialize.boolean_to_string( + notifications_new_message_badge_count_enabled + ), + "Notifications.AddedToChannel.Enabled": serialize.boolean_to_string( + notifications_added_to_channel_enabled + ), "Notifications.AddedToChannel.Template": notifications_added_to_channel_template, "Notifications.AddedToChannel.Sound": notifications_added_to_channel_sound, - "Notifications.RemovedFromChannel.Enabled": notifications_removed_from_channel_enabled, + "Notifications.RemovedFromChannel.Enabled": serialize.boolean_to_string( + notifications_removed_from_channel_enabled + ), "Notifications.RemovedFromChannel.Template": notifications_removed_from_channel_template, "Notifications.RemovedFromChannel.Sound": notifications_removed_from_channel_sound, - "Notifications.InvitedToChannel.Enabled": notifications_invited_to_channel_enabled, + "Notifications.InvitedToChannel.Enabled": serialize.boolean_to_string( + notifications_invited_to_channel_enabled + ), "Notifications.InvitedToChannel.Template": notifications_invited_to_channel_template, "Notifications.InvitedToChannel.Sound": notifications_invited_to_channel_sound, "PreWebhookUrl": pre_webhook_url, @@ -715,14 +751,19 @@ async def update_async( "Media.CompatibilityMessage": media_compatibility_message, "PreWebhookRetryCount": pre_webhook_retry_count, "PostWebhookRetryCount": post_webhook_retry_count, - "Notifications.LogEnabled": notifications_log_enabled, + "Notifications.LogEnabled": serialize.boolean_to_string( + notifications_log_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"]) @@ -786,6 +827,7 @@ def __repr__(self) -> str: class ServicePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ServiceInstance: """ Build an instance of ServiceInstance @@ -804,6 +846,7 @@ def __repr__(self) -> str: class ServiceList(ListResource): + def __init__(self, version: Version): """ Initialize the ServiceList @@ -823,16 +866,20 @@ def create(self, friendly_name: str) -> ServiceInstance: :returns: The created ServiceInstance """ + data = values.of( { "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) @@ -845,16 +892,20 @@ async def create_async(self, friendly_name: str) -> ServiceInstance: :returns: The created ServiceInstance """ + data = values.of( { "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) @@ -986,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( @@ -1013,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 70dbc78fb7..af9018af9f 100644 --- a/twilio/rest/ip_messaging/v2/service/binding.py +++ b/twilio/rest/ip_messaging/v2/service/binding.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class BindingInstance(InstanceResource): + class BindingType(object): GCM = "gcm" APN = "apn" @@ -141,6 +141,7 @@ def __repr__(self) -> str: class BindingContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, sid: str): """ Initialize the BindingContext @@ -165,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: """ @@ -177,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: @@ -190,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, @@ -210,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( @@ -233,6 +240,7 @@ def __repr__(self) -> str: class BindingPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> BindingInstance: """ Build an instance of BindingInstance @@ -253,6 +261,7 @@ def __repr__(self) -> str: class BindingList(ListResource): + def __init__(self, version: Version, service_sid: str): """ Initialize the BindingList @@ -426,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( @@ -459,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 6e62c31093..8220a4be9c 100644 --- a/twilio/rest/ip_messaging/v2/service/channel/__init__.py +++ b/twilio/rest/ip_messaging/v2/service/channel/__init__.py @@ -12,7 +12,6 @@ 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 @@ -28,6 +27,7 @@ class ChannelInstance(InstanceResource): + class ChannelType(object): PUBLIC = "public" PRIVATE = "private" @@ -268,6 +268,7 @@ def __repr__(self) -> str: class ChannelContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, sid: str): """ Initialize the ChannelContext @@ -309,6 +310,8 @@ def delete( } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async( @@ -330,6 +333,8 @@ async def delete_async( } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -342,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, @@ -362,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( @@ -399,6 +408,7 @@ def update( :returns: The updated ChannelInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -409,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 @@ -451,6 +470,7 @@ async def update_async( :returns: The updated ChannelInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -461,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 @@ -541,6 +570,7 @@ def __repr__(self) -> str: class ChannelPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ChannelInstance: """ Build an instance of ChannelInstance @@ -561,6 +591,7 @@ def __repr__(self) -> str: class ChannelList(ListResource): + def __init__(self, version: Version, service_sid: str): """ Initialize the ChannelList @@ -604,6 +635,7 @@ def create( :returns: The created ChannelInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -618,8 +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 ) @@ -655,6 +693,7 @@ async def create_async( :returns: The created ChannelInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -669,8 +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 ) @@ -819,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( @@ -849,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 aeb07b7b92..4fa3c187fc 100644 --- a/twilio/rest/ip_messaging/v2/service/channel/invite.py +++ b/twilio/rest/ip_messaging/v2/service/channel/invite.py @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class InviteInstance(InstanceResource): - """ :ivar sid: :ivar account_sid: @@ -134,6 +132,7 @@ def __repr__(self) -> str: class InviteContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, channel_sid: str, sid: str): """ Initialize the InviteContext @@ -164,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: """ @@ -176,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: @@ -189,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, @@ -210,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( @@ -234,6 +239,7 @@ def __repr__(self) -> str: class InvitePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> InviteInstance: """ Build an instance of InviteInstance @@ -257,6 +263,7 @@ def __repr__(self) -> str: class InviteList(ListResource): + def __init__(self, version: Version, service_sid: str, channel_sid: str): """ Initialize the InviteList @@ -288,17 +295,21 @@ def create( :returns: The created InviteInstance """ + data = values.of( { "Identity": identity, "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( @@ -319,17 +330,21 @@ async def create_async( :returns: The created InviteInstance """ + data = values.of( { "Identity": identity, "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( @@ -479,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( @@ -509,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 823c37b6df..6456d3be20 100644 --- a/twilio/rest/ip_messaging/v2/service/channel/member.py +++ b/twilio/rest/ip_messaging/v2/service/channel/member.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class MemberInstance(InstanceResource): + class WebhookEnabledType(object): TRUE = "true" FALSE = "false" @@ -68,9 +68,9 @@ def __init__( self.last_consumed_message_index: Optional[int] = deserialize.integer( payload.get("last_consumed_message_index") ) - self.last_consumption_timestamp: Optional[ - datetime - ] = deserialize.iso8601_datetime(payload.get("last_consumption_timestamp")) + self.last_consumption_timestamp: Optional[datetime] = ( + deserialize.iso8601_datetime(payload.get("last_consumption_timestamp")) + ) self.url: Optional[str] = payload.get("url") self.attributes: Optional[str] = payload.get("attributes") @@ -231,6 +231,7 @@ def __repr__(self) -> str: class MemberContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, channel_sid: str, sid: str): """ Initialize the MemberContext @@ -273,6 +274,8 @@ def delete( } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async( @@ -294,6 +297,8 @@ async def delete_async( } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -306,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, @@ -327,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( @@ -365,6 +374,7 @@ def update( :returns: The updated MemberInstance """ + data = values.of( { "RoleSid": role_sid, @@ -377,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 @@ -420,6 +439,7 @@ async def update_async( :returns: The updated MemberInstance """ + data = values.of( { "RoleSid": role_sid, @@ -432,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 @@ -461,6 +490,7 @@ def __repr__(self) -> str: class MemberPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> MemberInstance: """ Build an instance of MemberInstance @@ -484,6 +514,7 @@ def __repr__(self) -> str: class MemberList(ListResource): + def __init__(self, version: Version, service_sid: str, channel_sid: str): """ Initialize the MemberList @@ -531,6 +562,7 @@ def create( :returns: The created MemberInstance """ + data = values.of( { "Identity": identity, @@ -547,8 +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 ) @@ -587,6 +625,7 @@ async def create_async( :returns: The created MemberInstance """ + data = values.of( { "Identity": identity, @@ -603,8 +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 ) @@ -756,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( @@ -786,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 c2401c53f9..838b3c7271 100644 --- a/twilio/rest/ip_messaging/v2/service/channel/message.py +++ b/twilio/rest/ip_messaging/v2/service/channel/message.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class MessageInstance(InstanceResource): + class OrderType(object): ASC = "asc" DESC = "desc" @@ -239,6 +239,7 @@ def __repr__(self) -> str: class MessageContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, channel_sid: str, sid: str): """ Initialize the MessageContext @@ -281,6 +282,8 @@ def delete( } ) + headers = values.of({}) + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) async def delete_async( @@ -302,6 +305,8 @@ async def delete_async( } ) + headers = values.of({}) + return await self._version.delete_async( method="DELETE", uri=self._uri, headers=headers ) @@ -314,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, @@ -335,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( @@ -373,6 +382,7 @@ def update( :returns: The updated MessageInstance """ + data = values.of( { "Body": body, @@ -383,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 @@ -426,6 +445,7 @@ async def update_async( :returns: The updated MessageInstance """ + data = values.of( { "Body": body, @@ -436,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 @@ -465,6 +494,7 @@ def __repr__(self) -> str: class MessagePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> MessageInstance: """ Build an instance of MessageInstance @@ -488,6 +518,7 @@ def __repr__(self) -> str: class MessageList(ListResource): + def __init__(self, version: Version, service_sid: str, channel_sid: str): """ Initialize the MessageList @@ -535,6 +566,7 @@ def create( :returns: The created MessageInstance """ + data = values.of( { "From": from_, @@ -549,8 +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 ) @@ -589,6 +627,7 @@ async def create_async( :returns: The created MessageInstance """ + data = values.of( { "From": from_, @@ -603,8 +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 ) @@ -756,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( @@ -786,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 077bbfa8e4..3c7570fd0e 100644 --- a/twilio/rest/ip_messaging/v2/service/channel/webhook.py +++ b/twilio/rest/ip_messaging/v2/service/channel/webhook.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class WebhookInstance(InstanceResource): + class Method(object): GET = "GET" POST = "POST" @@ -200,6 +200,7 @@ def __repr__(self) -> str: class WebhookContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, channel_sid: str, sid: str): """ Initialize the WebhookContext @@ -230,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: """ @@ -242,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: @@ -255,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, @@ -276,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( @@ -310,6 +317,7 @@ def update( :returns: The updated WebhookInstance """ + data = values.of( { "Configuration.Url": configuration_url, @@ -324,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( @@ -360,6 +371,7 @@ async def update_async( :returns: The updated WebhookInstance """ + data = values.of( { "Configuration.Url": configuration_url, @@ -374,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( @@ -400,6 +415,7 @@ def __repr__(self) -> str: class WebhookPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> WebhookInstance: """ Build an instance of WebhookInstance @@ -423,6 +439,7 @@ def __repr__(self) -> str: class WebhookList(ListResource): + def __init__(self, version: Version, service_sid: str, channel_sid: str): """ Initialize the WebhookList @@ -466,6 +483,7 @@ def create( :returns: The created WebhookInstance """ + data = values.of( { "Type": type, @@ -481,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( @@ -518,6 +539,7 @@ async def create_async( :returns: The created WebhookInstance """ + data = values.of( { "Type": type, @@ -533,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( @@ -674,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( @@ -701,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 c8e3b95611..32f70c2272 100644 --- a/twilio/rest/ip_messaging/v2/service/role.py +++ b/twilio/rest/ip_messaging/v2/service/role.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class RoleInstance(InstanceResource): + class RoleType(object): CHANNEL = "channel" DEPLOYMENT = "deployment" @@ -156,6 +156,7 @@ def __repr__(self) -> str: class RoleContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, sid: str): """ Initialize the RoleContext @@ -180,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: """ @@ -192,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: @@ -205,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, @@ -225,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( @@ -245,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( @@ -272,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( @@ -302,6 +317,7 @@ def __repr__(self) -> str: class RolePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> RoleInstance: """ Build an instance of RoleInstance @@ -322,6 +338,7 @@ def __repr__(self) -> str: class RoleList(ListResource): + def __init__(self, version: Version, service_sid: str): """ Initialize the RoleList @@ -350,6 +367,7 @@ def create( :returns: The created RoleInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -357,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( @@ -380,6 +401,7 @@ async def create_async( :returns: The created RoleInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -387,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( @@ -525,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( @@ -552,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 1f11793877..f5f1454c72 100644 --- a/twilio/rest/ip_messaging/v2/service/user/__init__.py +++ b/twilio/rest/ip_messaging/v2/service/user/__init__.py @@ -12,7 +12,6 @@ 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 @@ -26,6 +25,7 @@ class UserInstance(InstanceResource): + class WebhookEnabledType(object): TRUE = "true" FALSE = "false" @@ -212,6 +212,7 @@ def __repr__(self) -> str: class UserContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, sid: str): """ Initialize the UserContext @@ -239,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: """ @@ -251,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: @@ -264,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, @@ -284,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( @@ -315,6 +322,7 @@ def update( :returns: The updated UserInstance """ + data = values.of( { "RoleSid": role_sid, @@ -322,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 @@ -358,6 +375,7 @@ async def update_async( :returns: The updated UserInstance """ + data = values.of( { "RoleSid": role_sid, @@ -365,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 @@ -419,6 +446,7 @@ def __repr__(self) -> str: class UserPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> UserInstance: """ Build an instance of UserInstance @@ -439,6 +467,7 @@ def __repr__(self) -> str: class UserList(ListResource): + def __init__(self, version: Version, service_sid: str): """ Initialize the UserList @@ -476,6 +505,7 @@ def create( :returns: The created UserInstance """ + data = values.of( { "Identity": identity, @@ -487,8 +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 ) @@ -518,6 +554,7 @@ async def create_async( :returns: The created UserInstance """ + data = values.of( { "Identity": identity, @@ -529,8 +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 ) @@ -666,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( @@ -693,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 c2e389fc92..4f1d9f10a7 100644 --- a/twilio/rest/ip_messaging/v2/service/user/user_binding.py +++ b/twilio/rest/ip_messaging/v2/service/user/user_binding.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class UserBindingInstance(InstanceResource): + class BindingType(object): GCM = "gcm" APN = "apn" @@ -144,6 +144,7 @@ def __repr__(self) -> str: class UserBindingContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, user_sid: str, sid: str): """ Initialize the UserBindingContext @@ -172,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: """ @@ -184,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: @@ -197,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, @@ -218,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( @@ -242,6 +249,7 @@ def __repr__(self) -> str: class UserBindingPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> UserBindingInstance: """ Build an instance of UserBindingInstance @@ -265,6 +273,7 @@ def __repr__(self) -> str: class UserBindingList(ListResource): + def __init__(self, version: Version, service_sid: str, user_sid: str): """ Initialize the UserBindingList @@ -437,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( @@ -469,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 51239956f0..5cb544fc3f 100644 --- a/twilio/rest/ip_messaging/v2/service/user/user_channel.py +++ b/twilio/rest/ip_messaging/v2/service/user/user_channel.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class UserChannelInstance(InstanceResource): + class ChannelStatus(object): JOINED = "joined" INVITED = "invited" @@ -73,9 +73,9 @@ def __init__( ) self.links: Optional[Dict[str, object]] = payload.get("links") self.url: Optional[str] = payload.get("url") - self.notification_level: Optional[ - "UserChannelInstance.NotificationLevel" - ] = payload.get("notification_level") + self.notification_level: Optional["UserChannelInstance.NotificationLevel"] = ( + payload.get("notification_level") + ) self._solution = { "service_sid": service_sid, @@ -194,6 +194,7 @@ def __repr__(self) -> str: class UserChannelContext(InstanceContext): + def __init__( self, version: Version, service_sid: str, user_sid: str, channel_sid: str ): @@ -226,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: """ @@ -238,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: @@ -251,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, @@ -272,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( @@ -302,6 +309,7 @@ def update( :returns: The updated UserChannelInstance """ + data = values.of( { "NotificationLevel": notification_level, @@ -311,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( @@ -343,6 +354,7 @@ async def update_async( :returns: The updated UserChannelInstance """ + data = values.of( { "NotificationLevel": notification_level, @@ -352,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( @@ -378,6 +393,7 @@ def __repr__(self) -> str: class UserChannelPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> UserChannelInstance: """ Build an instance of UserChannelInstance @@ -401,6 +417,7 @@ def __repr__(self) -> str: class UserChannelList(ListResource): + def __init__(self, version: Version, service_sid: str, user_sid: str): """ Initialize the UserChannelList @@ -548,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( @@ -575,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/lookups/LookupsBase.py b/twilio/rest/lookups/LookupsBase.py index fe3aa2aa6d..e24f8dc611 100644 --- a/twilio/rest/lookups/LookupsBase.py +++ b/twilio/rest/lookups/LookupsBase.py @@ -18,6 +18,7 @@ class LookupsBase(Domain): + def __init__(self, twilio: Client): """ Initialize the Lookups Domain diff --git a/twilio/rest/lookups/v1/__init__.py b/twilio/rest/lookups/v1/__init__.py index 82f17cc04f..72204da366 100644 --- a/twilio/rest/lookups/v1/__init__.py +++ b/twilio/rest/lookups/v1/__init__.py @@ -19,6 +19,7 @@ class V1(Version): + def __init__(self, domain: Domain): """ Initialize the V1 version of Lookups diff --git a/twilio/rest/lookups/v1/phone_number.py b/twilio/rest/lookups/v1/phone_number.py index f38a5c9f0b..304b89ab15 100644 --- a/twilio/rest/lookups/v1/phone_number.py +++ b/twilio/rest/lookups/v1/phone_number.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, List, Optional, Union from twilio.base import serialize, values from twilio.base.instance_context import InstanceContext @@ -22,7 +21,6 @@ class PhoneNumberInstance(InstanceResource): - """ :ivar caller_name: The name of the phone number's owner. If `null`, that information was not available. :ivar country_code: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) for the phone number. @@ -80,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. @@ -104,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. @@ -128,6 +126,7 @@ def __repr__(self) -> str: class PhoneNumberContext(InstanceContext): + def __init__(self, version: Version, phone_number: str): """ Initialize the PhoneNumberContext @@ -154,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. @@ -168,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, @@ -189,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. @@ -203,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( @@ -226,6 +237,7 @@ def __repr__(self) -> str: class PhoneNumberList(ListResource): + def __init__(self, version: Version): """ Initialize the PhoneNumberList diff --git a/twilio/rest/lookups/v2/__init__.py b/twilio/rest/lookups/v2/__init__.py index 1cea8ab0b2..852f552540 100644 --- a/twilio/rest/lookups/v2/__init__.py +++ b/twilio/rest/lookups/v2/__init__.py @@ -15,10 +15,15 @@ from typing import Optional from twilio.base.version import Version from twilio.base.domain import Domain +from twilio.rest.lookups.v2.bucket import BucketList +from twilio.rest.lookups.v2.lookup_override import LookupOverrideList from twilio.rest.lookups.v2.phone_number import PhoneNumberList +from twilio.rest.lookups.v2.query import QueryList +from twilio.rest.lookups.v2.rate_limit import RateLimitList class V2(Version): + def __init__(self, domain: Domain): """ Initialize the V2 version of Lookups @@ -26,7 +31,23 @@ def __init__(self, domain: Domain): :param domain: The Twilio.lookups domain """ super().__init__(domain, "v2") + self._bucket: Optional[BucketList] = None + self._lookup_overrides: Optional[LookupOverrideList] = None self._phone_numbers: Optional[PhoneNumberList] = None + self._query: Optional[QueryList] = None + self._rate_limits: Optional[RateLimitList] = None + + @property + def bucket(self) -> BucketList: + if self._bucket is None: + self._bucket = BucketList(self) + return self._bucket + + @property + def lookup_overrides(self) -> LookupOverrideList: + if self._lookup_overrides is None: + self._lookup_overrides = LookupOverrideList(self) + return self._lookup_overrides @property def phone_numbers(self) -> PhoneNumberList: @@ -34,6 +55,18 @@ def phone_numbers(self) -> PhoneNumberList: self._phone_numbers = PhoneNumberList(self) return self._phone_numbers + @property + def query(self) -> QueryList: + if self._query is None: + self._query = QueryList(self) + return self._query + + @property + def rate_limits(self) -> RateLimitList: + if self._rate_limits is None: + self._rate_limits = RateLimitList(self) + return self._rate_limits + def __repr__(self) -> str: """ Provide a friendly representation diff --git a/twilio/rest/lookups/v2/bucket.py b/twilio/rest/lookups/v2/bucket.py new file mode 100644 index 0000000000..c8f9bdad6b --- /dev/null +++ b/twilio/rest/lookups/v2/bucket.py @@ -0,0 +1,401 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Lookups + 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_context import InstanceContext +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + + +class BucketInstance(InstanceResource): + + class RateLimitRequest(object): + """ + :ivar limit: Limit of requests for the bucket + :ivar ttl: Time to live of the rule + """ + + def __init__(self, payload: Dict[str, Any]): + + self.limit: Optional[int] = payload.get("limit") + self.ttl: Optional[int] = payload.get("ttl") + + def to_dict(self): + return { + "limit": self.limit, + "ttl": self.ttl, + } + + """ + :ivar code: Twilio-specific error code + :ivar message: Error message + :ivar more_info: Link to Error Code References + :ivar status: HTTP response status code + :ivar field: Limit of requests for the bucket + :ivar limit: Limit of requests for the bucket + :ivar bucket: Name of the bucket + :ivar owner: Owner of the rule + :ivar ttl: Time to live of the rule + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + field: Optional[str] = None, + bucket: Optional[str] = None, + ): + super().__init__(version) + + self.code: Optional[int] = payload.get("code") + self.message: Optional[str] = payload.get("message") + self.more_info: Optional[str] = payload.get("more_info") + self.status: Optional[int] = payload.get("status") + self.field: Optional[str] = payload.get("field") + self.limit: Optional[int] = payload.get("limit") + self.bucket: Optional[str] = payload.get("bucket") + self.owner: Optional[str] = payload.get("owner") + self.ttl: Optional[int] = payload.get("ttl") + + self._solution = { + "field": field or self.field, + "bucket": bucket or self.bucket, + } + self._context: Optional[BucketContext] = None + + @property + def _proxy(self) -> "BucketContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: BucketContext for this BucketInstance + """ + if self._context is None: + self._context = BucketContext( + self._version, + field=self._solution["field"], + bucket=self._solution["bucket"], + ) + return self._context + + def delete(self) -> bool: + """ + Deletes the BucketInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._proxy.delete() + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the BucketInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._proxy.delete_async() + + def fetch(self) -> "BucketInstance": + """ + Fetch the BucketInstance + + + :returns: The fetched BucketInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "BucketInstance": + """ + Asynchronous coroutine to fetch the BucketInstance + + + :returns: The fetched BucketInstance + """ + return await self._proxy.fetch_async() + + def update( + self, rate_limit_request: Union[RateLimitRequest, object] = values.unset + ) -> "BucketInstance": + """ + Update the BucketInstance + + :param rate_limit_request: + + :returns: The updated BucketInstance + """ + return self._proxy.update( + rate_limit_request=rate_limit_request, + ) + + async def update_async( + self, rate_limit_request: Union[RateLimitRequest, object] = values.unset + ) -> "BucketInstance": + """ + Asynchronous coroutine to update the BucketInstance + + :param rate_limit_request: + + :returns: The updated BucketInstance + """ + return await self._proxy.update_async( + rate_limit_request=rate_limit_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 BucketContext(InstanceContext): + + class RateLimitRequest(object): + """ + :ivar limit: Limit of requests for the bucket + :ivar ttl: Time to live of the rule + """ + + def __init__(self, payload: Dict[str, Any]): + + self.limit: Optional[int] = payload.get("limit") + self.ttl: Optional[int] = payload.get("ttl") + + def to_dict(self): + return { + "limit": self.limit, + "ttl": self.ttl, + } + + def __init__(self, version: Version, field: str, bucket: str): + """ + Initialize the BucketContext + + :param version: Version that contains the resource + :param field: field name + :param bucket: bucket name + """ + super().__init__(version) + + # Path Solution + self._solution = { + "field": field, + "bucket": bucket, + } + self._uri = "/RateLimits/Fields/{field}/Bucket/{bucket}".format( + **self._solution + ) + + def delete(self) -> bool: + """ + Deletes the BucketInstance + + + :returns: True if delete succeeds, False otherwise + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the BucketInstance + + + :returns: True if delete succeeds, False otherwise + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + return await self._version.delete_async( + method="DELETE", uri=self._uri, headers=headers + ) + + def fetch(self) -> BucketInstance: + """ + Fetch the BucketInstance + + + :returns: The fetched BucketInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return BucketInstance( + self._version, + payload, + field=self._solution["field"], + bucket=self._solution["bucket"], + ) + + async def fetch_async(self) -> BucketInstance: + """ + Asynchronous coroutine to fetch the BucketInstance + + + :returns: The fetched BucketInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + return BucketInstance( + self._version, + payload, + field=self._solution["field"], + bucket=self._solution["bucket"], + ) + + def update( + self, rate_limit_request: Union[RateLimitRequest, object] = values.unset + ) -> BucketInstance: + """ + Update the BucketInstance + + :param rate_limit_request: + + :returns: The updated BucketInstance + """ + data = rate_limit_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 BucketInstance( + self._version, + payload, + field=self._solution["field"], + bucket=self._solution["bucket"], + ) + + async def update_async( + self, rate_limit_request: Union[RateLimitRequest, object] = values.unset + ) -> BucketInstance: + """ + Asynchronous coroutine to update the BucketInstance + + :param rate_limit_request: + + :returns: The updated BucketInstance + """ + data = rate_limit_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 BucketInstance( + self._version, + payload, + field=self._solution["field"], + bucket=self._solution["bucket"], + ) + + 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 BucketList(ListResource): + + class RateLimitRequest(object): + """ + :ivar limit: Limit of requests for the bucket + :ivar ttl: Time to live of the rule + """ + + def __init__(self, payload: Dict[str, Any]): + + self.limit: Optional[int] = payload.get("limit") + self.ttl: Optional[int] = payload.get("ttl") + + def to_dict(self): + return { + "limit": self.limit, + "ttl": self.ttl, + } + + def __init__(self, version: Version): + """ + Initialize the BucketList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + def get(self, field: str, bucket: str) -> BucketContext: + """ + Constructs a BucketContext + + :param field: field name + :param bucket: bucket name + """ + return BucketContext(self._version, field=field, bucket=bucket) + + def __call__(self, field: str, bucket: str) -> BucketContext: + """ + Constructs a BucketContext + + :param field: field name + :param bucket: bucket name + """ + return BucketContext(self._version, field=field, bucket=bucket) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/lookups/v2/lookup_override.py b/twilio/rest/lookups/v2/lookup_override.py new file mode 100644 index 0000000000..ebd566b125 --- /dev/null +++ b/twilio/rest/lookups/v2/lookup_override.py @@ -0,0 +1,508 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Lookups + 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 LookupOverrideInstance(InstanceResource): + + class OverridesRequest(object): + """ + :ivar line_type: The new line type to override the original line type + :ivar reason: The reason for the override + """ + + def __init__(self, payload: Dict[str, Any]): + + self.line_type: Optional["LookupOverrideInstance.str"] = payload.get( + "line_type" + ) + self.reason: Optional[str] = payload.get("reason") + + def to_dict(self): + return { + "line_type": self.line_type, + "reason": self.reason, + } + + """ + :ivar phone_number: The phone number for which the override was created + :ivar original_line_type: The original line type + :ivar overridden_line_type: The new line type after the override + :ivar override_reason: The reason for the override + :ivar override_timestamp: + :ivar overridden_by_account_sid: The Account SID for the user who made the override + :ivar code: Twilio-specific error code + :ivar message: Error message + :ivar more_info: Link to Error Code References + :ivar status: HTTP response status code + :ivar field: Limit of requests for the bucket + :ivar limit: Limit of requests for the bucket + :ivar bucket: Name of the bucket + :ivar owner: Owner of the rule + :ivar ttl: Time to live of the rule + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + field: Optional[str] = None, + phone_number: Optional[str] = None, + ): + super().__init__(version) + + self.phone_number: Optional[str] = payload.get("phone_number") + self.original_line_type: Optional[str] = payload.get("original_line_type") + self.overridden_line_type: Optional[str] = payload.get("overridden_line_type") + self.override_reason: Optional[str] = payload.get("override_reason") + self.override_timestamp: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("override_timestamp") + ) + self.overridden_by_account_sid: Optional[str] = payload.get( + "overridden_by_account_sid" + ) + self.code: Optional[int] = payload.get("code") + self.message: Optional[str] = payload.get("message") + self.more_info: Optional[str] = payload.get("more_info") + self.status: Optional[int] = payload.get("status") + self.field: Optional[str] = payload.get("field") + self.limit: Optional[int] = payload.get("limit") + self.bucket: Optional[str] = payload.get("bucket") + self.owner: Optional[str] = payload.get("owner") + self.ttl: Optional[int] = payload.get("ttl") + + self._solution = { + "field": field or self.field, + "phone_number": phone_number or self.phone_number, + } + self._context: Optional[LookupOverrideContext] = None + + @property + def _proxy(self) -> "LookupOverrideContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: LookupOverrideContext for this LookupOverrideInstance + """ + if self._context is None: + self._context = LookupOverrideContext( + self._version, + field=self._solution["field"], + phone_number=self._solution["phone_number"], + ) + return self._context + + def create( + self, overrides_request: Union[OverridesRequest, object] = values.unset + ) -> "LookupOverrideInstance": + """ + Create the LookupOverrideInstance + + :param overrides_request: + + :returns: The created LookupOverrideInstance + """ + return self._proxy.create( + overrides_request=overrides_request, + ) + + async def create_async( + self, overrides_request: Union[OverridesRequest, object] = values.unset + ) -> "LookupOverrideInstance": + """ + Asynchronous coroutine to create the LookupOverrideInstance + + :param overrides_request: + + :returns: The created LookupOverrideInstance + """ + return await self._proxy.create_async( + overrides_request=overrides_request, + ) + + def delete(self) -> bool: + """ + Deletes the LookupOverrideInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._proxy.delete() + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the LookupOverrideInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._proxy.delete_async() + + def fetch(self) -> "LookupOverrideInstance": + """ + Fetch the LookupOverrideInstance + + + :returns: The fetched LookupOverrideInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "LookupOverrideInstance": + """ + Asynchronous coroutine to fetch the LookupOverrideInstance + + + :returns: The fetched LookupOverrideInstance + """ + return await self._proxy.fetch_async() + + def update( + self, overrides_request: Union[OverridesRequest, object] = values.unset + ) -> "LookupOverrideInstance": + """ + Update the LookupOverrideInstance + + :param overrides_request: + + :returns: The updated LookupOverrideInstance + """ + return self._proxy.update( + overrides_request=overrides_request, + ) + + async def update_async( + self, overrides_request: Union[OverridesRequest, object] = values.unset + ) -> "LookupOverrideInstance": + """ + Asynchronous coroutine to update the LookupOverrideInstance + + :param overrides_request: + + :returns: The updated LookupOverrideInstance + """ + return await self._proxy.update_async( + overrides_request=overrides_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 LookupOverrideContext(InstanceContext): + + class OverridesRequest(object): + """ + :ivar line_type: The new line type to override the original line type + :ivar reason: The reason for the override + """ + + def __init__(self, payload: Dict[str, Any]): + + self.line_type: Optional["LookupOverrideInstance.str"] = payload.get( + "line_type" + ) + self.reason: Optional[str] = payload.get("reason") + + def to_dict(self): + return { + "line_type": self.line_type, + "reason": self.reason, + } + + def __init__(self, version: Version, field: str, phone_number: str): + """ + Initialize the LookupOverrideContext + + :param version: Version that contains the resource + :param field: + :param phone_number: + """ + super().__init__(version) + + # Path Solution + self._solution = { + "field": field, + "phone_number": phone_number, + } + self._uri = "/PhoneNumbers/{phone_number}/Overrides/{field}".format( + **self._solution + ) + + def create( + self, overrides_request: Union[OverridesRequest, object] = values.unset + ) -> LookupOverrideInstance: + """ + Create the LookupOverrideInstance + + :param overrides_request: + + :returns: The created LookupOverrideInstance + """ + data = values.of( + { + "OverridesRequest": overrides_request, + } + ) + + payload = self._version.create(method="POST", uri=self._uri, data=data) + + return LookupOverrideInstance( + self._version, + payload, + field=self._solution["field"], + phone_number=self._solution["phone_number"], + ) + + async def create_async( + self, overrides_request: Union[OverridesRequest, object] = values.unset + ) -> LookupOverrideInstance: + """ + Asynchronous coroutine to create the LookupOverrideInstance + + :param overrides_request: + + :returns: The created LookupOverrideInstance + """ + data = values.of( + { + "OverridesRequest": overrides_request, + } + ) + + payload = await self._version.create_async( + method="POST", uri=self._uri, data=data + ) + + return LookupOverrideInstance( + self._version, + payload, + field=self._solution["field"], + phone_number=self._solution["phone_number"], + ) + + def delete(self) -> bool: + """ + Deletes the LookupOverrideInstance + + + :returns: True if delete succeeds, False otherwise + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + return self._version.delete(method="DELETE", uri=self._uri, headers=headers) + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the LookupOverrideInstance + + + :returns: True if delete succeeds, False otherwise + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + return await self._version.delete_async( + method="DELETE", uri=self._uri, headers=headers + ) + + def fetch(self) -> LookupOverrideInstance: + """ + Fetch the LookupOverrideInstance + + + :returns: The fetched LookupOverrideInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return LookupOverrideInstance( + self._version, + payload, + field=self._solution["field"], + phone_number=self._solution["phone_number"], + ) + + async def fetch_async(self) -> LookupOverrideInstance: + """ + Asynchronous coroutine to fetch the LookupOverrideInstance + + + :returns: The fetched LookupOverrideInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + return LookupOverrideInstance( + self._version, + payload, + field=self._solution["field"], + phone_number=self._solution["phone_number"], + ) + + def update( + self, overrides_request: Union[OverridesRequest, object] = values.unset + ) -> LookupOverrideInstance: + """ + Update the LookupOverrideInstance + + :param overrides_request: + + :returns: The updated LookupOverrideInstance + """ + data = overrides_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 LookupOverrideInstance( + self._version, + payload, + field=self._solution["field"], + phone_number=self._solution["phone_number"], + ) + + async def update_async( + self, overrides_request: Union[OverridesRequest, object] = values.unset + ) -> LookupOverrideInstance: + """ + Asynchronous coroutine to update the LookupOverrideInstance + + :param overrides_request: + + :returns: The updated LookupOverrideInstance + """ + data = overrides_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 LookupOverrideInstance( + self._version, + payload, + field=self._solution["field"], + phone_number=self._solution["phone_number"], + ) + + 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 LookupOverrideList(ListResource): + + class OverridesRequest(object): + """ + :ivar line_type: The new line type to override the original line type + :ivar reason: The reason for the override + """ + + def __init__(self, payload: Dict[str, Any]): + + self.line_type: Optional["LookupOverrideInstance.str"] = payload.get( + "line_type" + ) + self.reason: Optional[str] = payload.get("reason") + + def to_dict(self): + return { + "line_type": self.line_type, + "reason": self.reason, + } + + def __init__(self, version: Version): + """ + Initialize the LookupOverrideList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + def get(self, field: str, phone_number: str) -> LookupOverrideContext: + """ + Constructs a LookupOverrideContext + + :param field: + :param phone_number: + """ + return LookupOverrideContext( + self._version, field=field, phone_number=phone_number + ) + + def __call__(self, field: str, phone_number: str) -> LookupOverrideContext: + """ + Constructs a LookupOverrideContext + + :param field: + :param phone_number: + """ + return LookupOverrideContext( + self._version, field=field, phone_number=phone_number + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/lookups/v2/phone_number.py b/twilio/rest/lookups/v2/phone_number.py index 676a3fdfb7..fc60eed6d3 100644 --- a/twilio/rest/lookups/v2/phone_number.py +++ b/twilio/rest/lookups/v2/phone_number.py @@ -12,7 +12,6 @@ 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 @@ -22,6 +21,7 @@ class PhoneNumberInstance(InstanceResource): + class ValidationError(object): TOO_SHORT = "TOO_SHORT" TOO_LONG = "TOO_LONG" @@ -40,10 +40,13 @@ class ValidationError(object): :ivar caller_name: An object that contains caller name information based on [CNAM](https://support.twilio.com/hc/en-us/articles/360051670533-Getting-Started-with-CNAM-Caller-ID). :ivar sim_swap: An object that contains information on the last date the subscriber identity module (SIM) was changed for a mobile phone number. :ivar call_forwarding: An object that contains information on the unconditional call forwarding status of mobile phone number. - :ivar live_activity: An object that contains live activity information for a mobile phone number. + :ivar line_status: An object that contains line status information for a mobile phone number. :ivar line_type_intelligence: An object that contains line type information including the carrier name, mobile country code, and mobile network code. :ivar identity_match: An object that contains identity match information. The result of comparing user-provided information including name, address, date of birth, national ID, against authoritative phone-based data sources + :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. """ @@ -68,14 +71,21 @@ def __init__( self.call_forwarding: Optional[Dict[str, object]] = payload.get( "call_forwarding" ) - self.live_activity: Optional[Dict[str, object]] = payload.get("live_activity") + self.line_status: Optional[Dict[str, object]] = payload.get("line_status") self.line_type_intelligence: Optional[Dict[str, object]] = payload.get( "line_type_intelligence" ) self.identity_match: Optional[Dict[str, object]] = payload.get("identity_match") + self.reassigned_number: Optional[Dict[str, object]] = payload.get( + "reassigned_number" + ) self.sms_pumping_risk: Optional[Dict[str, object]] = payload.get( "sms_pumping_risk" ) + 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 = { @@ -112,11 +122,14 @@ def fetch( address_country_code: Union[str, object] = values.unset, 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 caller_name, sim_swap, call_forwarding, live_activity, line_type_intelligence, identity_match. + :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. @@ -128,6 +141,9 @@ def fetch( :param address_country_code: User’s country, up to two characters. This query parameter is only used (optionally) for identity_match package requests. :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 """ @@ -144,6 +160,9 @@ def fetch( address_country_code=address_country_code, 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( @@ -160,11 +179,14 @@ async def fetch_async( address_country_code: Union[str, object] = values.unset, 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 caller_name, sim_swap, call_forwarding, live_activity, line_type_intelligence, identity_match. + :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. @@ -176,6 +198,9 @@ async def fetch_async( :param address_country_code: User’s country, up to two characters. This query parameter is only used (optionally) for identity_match package requests. :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 """ @@ -192,6 +217,9 @@ async def fetch_async( address_country_code=address_country_code, 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: @@ -205,6 +233,7 @@ def __repr__(self) -> str: class PhoneNumberContext(InstanceContext): + def __init__(self, version: Version, phone_number: str): """ Initialize the PhoneNumberContext @@ -234,11 +263,14 @@ def fetch( address_country_code: Union[str, object] = values.unset, 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 caller_name, sim_swap, call_forwarding, live_activity, line_type_intelligence, identity_match. + :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. @@ -250,6 +282,9 @@ def fetch( :param address_country_code: User’s country, up to two characters. This query parameter is only used (optionally) for identity_match package requests. :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 """ @@ -268,10 +303,19 @@ def fetch( "AddressCountryCode": address_country_code, "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, @@ -293,11 +337,14 @@ async def fetch_async( address_country_code: Union[str, object] = values.unset, 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 caller_name, sim_swap, call_forwarding, live_activity, line_type_intelligence, identity_match. + :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. @@ -309,6 +356,9 @@ async def fetch_async( :param address_country_code: User’s country, up to two characters. This query parameter is only used (optionally) for identity_match package requests. :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 """ @@ -327,11 +377,18 @@ async def fetch_async( "AddressCountryCode": address_country_code, "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( @@ -351,6 +408,7 @@ def __repr__(self) -> str: class PhoneNumberList(ListResource): + def __init__(self, version: Version): """ Initialize the PhoneNumberList diff --git a/twilio/rest/lookups/v2/query.py b/twilio/rest/lookups/v2/query.py new file mode 100644 index 0000000000..4a8047859a --- /dev/null +++ b/twilio/rest/lookups/v2/query.py @@ -0,0 +1,874 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Lookups + 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 values + +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + + +class QueryInstance(InstanceResource): + + class CallForwarding(object): + """ + :ivar call_forwarding_enabled: + :ivar error_code: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.call_forwarding_enabled: Optional[bool] = payload.get( + "call_forwarding_enabled" + ) + self.error_code: Optional[int] = payload.get("error_code") + + def to_dict(self): + return { + "": self.call_forwarding_enabled, + "": self.error_code, + } + + class CallerName(object): + """ + :ivar caller_name: + :ivar caller_type: + :ivar error_code: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.caller_name: Optional[str] = payload.get("caller_name") + self.caller_type: Optional[str] = payload.get("caller_type") + self.error_code: Optional[int] = payload.get("error_code") + + def to_dict(self): + return { + "": self.caller_name, + "": self.caller_type, + "": self.error_code, + } + + class IdentityMatch(object): + """ + :ivar first_name_match: + :ivar last_name_match: + :ivar address_line_match: + :ivar city_match: + :ivar state_match: + :ivar postal_code_match: + :ivar country_code_match: + :ivar national_id_match: + :ivar date_of_birth_match: + :ivar summary_score: + :ivar error_code: + :ivar error_message: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.first_name_match: Optional[str] = payload.get("first_name_match") + self.last_name_match: Optional[str] = payload.get("last_name_match") + self.address_line_match: Optional[str] = payload.get("address_line_match") + self.city_match: Optional[str] = payload.get("city_match") + self.state_match: Optional[str] = payload.get("state_match") + self.postal_code_match: Optional[str] = payload.get("postal_code_match") + self.country_code_match: Optional[str] = payload.get("country_code_match") + self.national_id_match: Optional[str] = payload.get("national_id_match") + self.date_of_birth_match: Optional[str] = payload.get("date_of_birth_match") + self.summary_score: Optional[int] = payload.get("summary_score") + self.error_code: Optional[int] = payload.get("error_code") + self.error_message: Optional[str] = payload.get("error_message") + + def to_dict(self): + return { + "": self.first_name_match, + "": self.last_name_match, + "": self.address_line_match, + "": self.city_match, + "": self.state_match, + "": self.postal_code_match, + "": self.country_code_match, + "": self.national_id_match, + "": self.date_of_birth_match, + "": self.summary_score, + "": self.error_code, + "": self.error_message, + } + + class IdentityMatchParameters(object): + """ + :ivar first_name: + :ivar last_name: + :ivar address_line1: + :ivar address_line2: + :ivar city: + :ivar state: + :ivar postal_code: + :ivar address_country_code: + :ivar national_id: + :ivar date_of_birth: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.first_name: Optional[str] = payload.get("first_name") + self.last_name: Optional[str] = payload.get("last_name") + self.address_line1: Optional[str] = payload.get("address_line1") + self.address_line2: Optional[str] = payload.get("address_line2") + self.city: Optional[str] = payload.get("city") + self.state: Optional[str] = payload.get("state") + self.postal_code: Optional[str] = payload.get("postal_code") + self.address_country_code: Optional[str] = payload.get( + "address_country_code" + ) + self.national_id: Optional[str] = payload.get("national_id") + self.date_of_birth: Optional[str] = payload.get("date_of_birth") + + def to_dict(self): + return { + "first_name": self.first_name, + "last_name": self.last_name, + "address_line1": self.address_line1, + "address_line2": self.address_line2, + "city": self.city, + "state": self.state, + "postal_code": self.postal_code, + "address_country_code": self.address_country_code, + "national_id": self.national_id, + "date_of_birth": self.date_of_birth, + } + + class LastSimSwap(object): + """ + :ivar last_sim_swap_date: + :ivar swapped_period: + :ivar swapped_in_period: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.last_sim_swap_date: Optional[datetime] = payload.get( + "last_sim_swap_date" + ) + self.swapped_period: Optional[str] = payload.get("swapped_period") + self.swapped_in_period: Optional[bool] = payload.get("swapped_in_period") + + def to_dict(self): + return { + "": self.last_sim_swap_date, + "": self.swapped_period, + "": self.swapped_in_period, + } + + class LineStatus(object): + """ + :ivar status: + :ivar error_code: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.status: Optional[str] = payload.get("status") + self.error_code: Optional[int] = payload.get("error_code") + + def to_dict(self): + return { + "": self.status, + "": self.error_code, + } + + class LineTypeIntelligence(object): + """ + :ivar type: + :ivar carrier_name: + :ivar mobile_country_code: + :ivar mobile_network_code: + :ivar error_code: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.type: Optional[str] = payload.get("type") + self.carrier_name: Optional[str] = payload.get("carrier_name") + self.mobile_country_code: Optional[str] = payload.get("mobile_country_code") + self.mobile_network_code: Optional[str] = payload.get("mobile_network_code") + self.error_code: Optional[int] = payload.get("error_code") + + def to_dict(self): + return { + "": self.type, + "": self.carrier_name, + "": self.mobile_country_code, + "": self.mobile_network_code, + "": self.error_code, + } + + class LookupRequest1(object): + """ + :ivar phone_numbers: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.phone_numbers: Optional[List[QueryList.LookupRequestWithCorId]] = ( + payload.get("phone_numbers") + ) + + def to_dict(self): + return { + "phone_numbers": ( + [phone_numbers.to_dict() for phone_numbers in self.phone_numbers] + if self.phone_numbers is not None + else None + ), + } + + class LookupRequestWithCorId(object): + """ + :ivar correlation_id: Unique identifier used to match request with response + :ivar phone_number: + :ivar fields: + :ivar country_code: + :ivar identity_match: + :ivar reassigned_number: + :ivar sms_pumping_risk: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.correlation_id: Optional[str] = payload.get("correlation_id") + self.phone_number: Optional[str] = payload.get("phone_number") + self.fields: Optional[List[Enumstr]] = payload.get("fields") + self.country_code: Optional[str] = payload.get("country_code") + self.identity_match: Optional[QueryList.IdentityMatchParameters] = ( + payload.get("identity_match") + ) + self.reassigned_number: Optional[QueryList.ReassignedNumberRequest] = ( + payload.get("reassigned_number") + ) + self.sms_pumping_risk: Optional[QueryList.SmsPumpingRiskParameters] = ( + payload.get("sms_pumping_risk") + ) + + def to_dict(self): + return { + "correlation_id": self.correlation_id, + "phone_number": self.phone_number, + "fields": self.fields, + "country_code": self.country_code, + "identity_match": ( + self.identity_match.to_dict() + if self.identity_match is not None + else None + ), + "reassigned_number": ( + self.reassigned_number.to_dict() + if self.reassigned_number is not None + else None + ), + "sms_pumping_risk": ( + self.sms_pumping_risk.to_dict() + if self.sms_pumping_risk is not None + else None + ), + } + + class ReassignedNumberRequest(object): + """ + :ivar last_verified_date: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.last_verified_date: Optional[str] = payload.get("last_verified_date") + + def to_dict(self): + return { + "last_verified_date": self.last_verified_date, + } + + class ReassignedNumberResponse(object): + """ + :ivar last_verified_date: + :ivar is_number_reassigned: + :ivar error_code: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.last_verified_date: Optional[str] = payload.get("last_verified_date") + self.is_number_reassigned: Optional[str] = payload.get( + "is_number_reassigned" + ) + self.error_code: Optional[str] = payload.get("error_code") + + def to_dict(self): + return { + "": self.last_verified_date, + "": self.is_number_reassigned, + "": self.error_code, + } + + class SimSwap(object): + """ + :ivar last_sim_swap: + :ivar carrier_name: + :ivar mobile_country_code: + :ivar mobile_network_code: + :ivar error_code: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.last_sim_swap: Optional[LastSimSwap] = payload.get("last_sim_swap") + self.carrier_name: Optional[str] = payload.get("carrier_name") + self.mobile_country_code: Optional[str] = payload.get("mobile_country_code") + self.mobile_network_code: Optional[str] = payload.get("mobile_network_code") + self.error_code: Optional[int] = payload.get("error_code") + + def to_dict(self): + return { + "": ( + self.last_sim_swap.to_dict() + if self.last_sim_swap is not None + else None + ), + "": self.carrier_name, + "": self.mobile_country_code, + "": self.mobile_network_code, + "": self.error_code, + } + + class SmsPumpingRisk(object): + """ + :ivar carrier_risk_category: + :ivar number_blocked: + :ivar number_blocked_date: + :ivar number_blocked_last_3_months: + :ivar sms_pumping_risk_score: + :ivar error_code: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.carrier_risk_category: Optional[str] = payload.get( + "carrier_risk_category" + ) + self.number_blocked: Optional[bool] = payload.get("number_blocked") + self.number_blocked_date: Optional[datetime] = payload.get( + "number_blocked_date" + ) + self.number_blocked_last_3_months: Optional[bool] = payload.get( + "number_blocked_last_3_months" + ) + self.sms_pumping_risk_score: Optional[int] = payload.get( + "sms_pumping_risk_score" + ) + self.error_code: Optional[int] = payload.get("error_code") + + def to_dict(self): + return { + "": self.carrier_risk_category, + "": self.number_blocked, + "": self.number_blocked_date, + "": self.number_blocked_last_3_months, + "": self.sms_pumping_risk_score, + "": self.error_code, + } + + class SmsPumpingRiskParameters(object): + """ + :ivar partner_sub_id: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.partner_sub_id: Optional[str] = payload.get("partner_sub_id") + + def to_dict(self): + return { + "partner_sub_id": self.partner_sub_id, + } + + """ + :ivar phone_numbers: + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.phone_numbers: Optional[List[str]] = payload.get("phone_numbers") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class QueryList(ListResource): + + class CallForwarding(object): + """ + :ivar call_forwarding_enabled: + :ivar error_code: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.call_forwarding_enabled: Optional[bool] = payload.get( + "call_forwarding_enabled" + ) + self.error_code: Optional[int] = payload.get("error_code") + + def to_dict(self): + return { + "": self.call_forwarding_enabled, + "": self.error_code, + } + + class CallerName(object): + """ + :ivar caller_name: + :ivar caller_type: + :ivar error_code: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.caller_name: Optional[str] = payload.get("caller_name") + self.caller_type: Optional[str] = payload.get("caller_type") + self.error_code: Optional[int] = payload.get("error_code") + + def to_dict(self): + return { + "": self.caller_name, + "": self.caller_type, + "": self.error_code, + } + + class IdentityMatch(object): + """ + :ivar first_name_match: + :ivar last_name_match: + :ivar address_line_match: + :ivar city_match: + :ivar state_match: + :ivar postal_code_match: + :ivar country_code_match: + :ivar national_id_match: + :ivar date_of_birth_match: + :ivar summary_score: + :ivar error_code: + :ivar error_message: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.first_name_match: Optional[str] = payload.get("first_name_match") + self.last_name_match: Optional[str] = payload.get("last_name_match") + self.address_line_match: Optional[str] = payload.get("address_line_match") + self.city_match: Optional[str] = payload.get("city_match") + self.state_match: Optional[str] = payload.get("state_match") + self.postal_code_match: Optional[str] = payload.get("postal_code_match") + self.country_code_match: Optional[str] = payload.get("country_code_match") + self.national_id_match: Optional[str] = payload.get("national_id_match") + self.date_of_birth_match: Optional[str] = payload.get("date_of_birth_match") + self.summary_score: Optional[int] = payload.get("summary_score") + self.error_code: Optional[int] = payload.get("error_code") + self.error_message: Optional[str] = payload.get("error_message") + + def to_dict(self): + return { + "": self.first_name_match, + "": self.last_name_match, + "": self.address_line_match, + "": self.city_match, + "": self.state_match, + "": self.postal_code_match, + "": self.country_code_match, + "": self.national_id_match, + "": self.date_of_birth_match, + "": self.summary_score, + "": self.error_code, + "": self.error_message, + } + + class IdentityMatchParameters(object): + """ + :ivar first_name: + :ivar last_name: + :ivar address_line1: + :ivar address_line2: + :ivar city: + :ivar state: + :ivar postal_code: + :ivar address_country_code: + :ivar national_id: + :ivar date_of_birth: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.first_name: Optional[str] = payload.get("first_name") + self.last_name: Optional[str] = payload.get("last_name") + self.address_line1: Optional[str] = payload.get("address_line1") + self.address_line2: Optional[str] = payload.get("address_line2") + self.city: Optional[str] = payload.get("city") + self.state: Optional[str] = payload.get("state") + self.postal_code: Optional[str] = payload.get("postal_code") + self.address_country_code: Optional[str] = payload.get( + "address_country_code" + ) + self.national_id: Optional[str] = payload.get("national_id") + self.date_of_birth: Optional[str] = payload.get("date_of_birth") + + def to_dict(self): + return { + "first_name": self.first_name, + "last_name": self.last_name, + "address_line1": self.address_line1, + "address_line2": self.address_line2, + "city": self.city, + "state": self.state, + "postal_code": self.postal_code, + "address_country_code": self.address_country_code, + "national_id": self.national_id, + "date_of_birth": self.date_of_birth, + } + + class LastSimSwap(object): + """ + :ivar last_sim_swap_date: + :ivar swapped_period: + :ivar swapped_in_period: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.last_sim_swap_date: Optional[datetime] = payload.get( + "last_sim_swap_date" + ) + self.swapped_period: Optional[str] = payload.get("swapped_period") + self.swapped_in_period: Optional[bool] = payload.get("swapped_in_period") + + def to_dict(self): + return { + "": self.last_sim_swap_date, + "": self.swapped_period, + "": self.swapped_in_period, + } + + class LineStatus(object): + """ + :ivar status: + :ivar error_code: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.status: Optional[str] = payload.get("status") + self.error_code: Optional[int] = payload.get("error_code") + + def to_dict(self): + return { + "": self.status, + "": self.error_code, + } + + class LineTypeIntelligence(object): + """ + :ivar type: + :ivar carrier_name: + :ivar mobile_country_code: + :ivar mobile_network_code: + :ivar error_code: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.type: Optional[str] = payload.get("type") + self.carrier_name: Optional[str] = payload.get("carrier_name") + self.mobile_country_code: Optional[str] = payload.get("mobile_country_code") + self.mobile_network_code: Optional[str] = payload.get("mobile_network_code") + self.error_code: Optional[int] = payload.get("error_code") + + def to_dict(self): + return { + "": self.type, + "": self.carrier_name, + "": self.mobile_country_code, + "": self.mobile_network_code, + "": self.error_code, + } + + class LookupRequest1(object): + """ + :ivar phone_numbers: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.phone_numbers: Optional[List[QueryList.LookupRequestWithCorId]] = ( + payload.get("phone_numbers") + ) + + def to_dict(self): + return { + "phone_numbers": ( + [phone_numbers.to_dict() for phone_numbers in self.phone_numbers] + if self.phone_numbers is not None + else None + ), + } + + class LookupRequestWithCorId(object): + """ + :ivar correlation_id: Unique identifier used to match request with response + :ivar phone_number: + :ivar fields: + :ivar country_code: + :ivar identity_match: + :ivar reassigned_number: + :ivar sms_pumping_risk: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.correlation_id: Optional[str] = payload.get("correlation_id") + self.phone_number: Optional[str] = payload.get("phone_number") + self.fields: Optional[List[Enumstr]] = payload.get("fields") + self.country_code: Optional[str] = payload.get("country_code") + self.identity_match: Optional[QueryList.IdentityMatchParameters] = ( + payload.get("identity_match") + ) + self.reassigned_number: Optional[QueryList.ReassignedNumberRequest] = ( + payload.get("reassigned_number") + ) + self.sms_pumping_risk: Optional[QueryList.SmsPumpingRiskParameters] = ( + payload.get("sms_pumping_risk") + ) + + def to_dict(self): + return { + "correlation_id": self.correlation_id, + "phone_number": self.phone_number, + "fields": self.fields, + "country_code": self.country_code, + "identity_match": ( + self.identity_match.to_dict() + if self.identity_match is not None + else None + ), + "reassigned_number": ( + self.reassigned_number.to_dict() + if self.reassigned_number is not None + else None + ), + "sms_pumping_risk": ( + self.sms_pumping_risk.to_dict() + if self.sms_pumping_risk is not None + else None + ), + } + + class ReassignedNumberRequest(object): + """ + :ivar last_verified_date: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.last_verified_date: Optional[str] = payload.get("last_verified_date") + + def to_dict(self): + return { + "last_verified_date": self.last_verified_date, + } + + class ReassignedNumberResponse(object): + """ + :ivar last_verified_date: + :ivar is_number_reassigned: + :ivar error_code: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.last_verified_date: Optional[str] = payload.get("last_verified_date") + self.is_number_reassigned: Optional[str] = payload.get( + "is_number_reassigned" + ) + self.error_code: Optional[str] = payload.get("error_code") + + def to_dict(self): + return { + "": self.last_verified_date, + "": self.is_number_reassigned, + "": self.error_code, + } + + class SimSwap(object): + """ + :ivar last_sim_swap: + :ivar carrier_name: + :ivar mobile_country_code: + :ivar mobile_network_code: + :ivar error_code: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.last_sim_swap: Optional[LastSimSwap] = payload.get("last_sim_swap") + self.carrier_name: Optional[str] = payload.get("carrier_name") + self.mobile_country_code: Optional[str] = payload.get("mobile_country_code") + self.mobile_network_code: Optional[str] = payload.get("mobile_network_code") + self.error_code: Optional[int] = payload.get("error_code") + + def to_dict(self): + return { + "": ( + self.last_sim_swap.to_dict() + if self.last_sim_swap is not None + else None + ), + "": self.carrier_name, + "": self.mobile_country_code, + "": self.mobile_network_code, + "": self.error_code, + } + + class SmsPumpingRisk(object): + """ + :ivar carrier_risk_category: + :ivar number_blocked: + :ivar number_blocked_date: + :ivar number_blocked_last_3_months: + :ivar sms_pumping_risk_score: + :ivar error_code: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.carrier_risk_category: Optional[str] = payload.get( + "carrier_risk_category" + ) + self.number_blocked: Optional[bool] = payload.get("number_blocked") + self.number_blocked_date: Optional[datetime] = payload.get( + "number_blocked_date" + ) + self.number_blocked_last_3_months: Optional[bool] = payload.get( + "number_blocked_last_3_months" + ) + self.sms_pumping_risk_score: Optional[int] = payload.get( + "sms_pumping_risk_score" + ) + self.error_code: Optional[int] = payload.get("error_code") + + def to_dict(self): + return { + "": self.carrier_risk_category, + "": self.number_blocked, + "": self.number_blocked_date, + "": self.number_blocked_last_3_months, + "": self.sms_pumping_risk_score, + "": self.error_code, + } + + class SmsPumpingRiskParameters(object): + """ + :ivar partner_sub_id: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.partner_sub_id: Optional[str] = payload.get("partner_sub_id") + + def to_dict(self): + return { + "partner_sub_id": self.partner_sub_id, + } + + def __init__(self, version: Version): + """ + Initialize the QueryList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/batch/query" + + def create( + self, lookup_request1: Union[LookupRequest1, object] = values.unset + ) -> QueryInstance: + """ + Create the QueryInstance + + :param lookup_request1: + + :returns: The created QueryInstance + """ + data = lookup_request1.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 QueryInstance(self._version, payload) + + async def create_async( + self, lookup_request1: Union[LookupRequest1, object] = values.unset + ) -> QueryInstance: + """ + Asynchronously create the QueryInstance + + :param lookup_request1: + + :returns: The created QueryInstance + """ + data = lookup_request1.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 QueryInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/lookups/v2/rate_limit.py b/twilio/rest/lookups/v2/rate_limit.py new file mode 100644 index 0000000000..6870ce7495 --- /dev/null +++ b/twilio/rest/lookups/v2/rate_limit.py @@ -0,0 +1,112 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Lookups + 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 RateLimitInstance(InstanceResource): + """ + :ivar rate_limits: + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.rate_limits: Optional[List[str]] = payload.get("rate_limits") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class RateLimitList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the RateLimitList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/RateLimits" + + def fetch( + self, fields: Union[List[str], object] = values.unset + ) -> RateLimitInstance: + """ + Asynchronously fetch the RateLimitInstance + + :param fields: + :returns: The fetched RateLimitInstance + """ + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + params = values.of( + { + "Fields": fields, + } + ) + + payload = self._version.fetch( + method="GET", uri=self._uri, headers=headers, params=params + ) + + return RateLimitInstance(self._version, payload) + + async def fetch_async( + self, fields: Union[List[str], object] = values.unset + ) -> RateLimitInstance: + """ + Asynchronously fetch the RateLimitInstance + + :param fields: + :returns: The fetched RateLimitInstance + """ + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + params = values.of( + { + "Fields": fields, + } + ) + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers, params=params + ) + + return RateLimitInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" 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/microvisor/v1/app/__init__.py b/twilio/rest/marketplace/v1/available_add_on/__init__.py similarity index 60% rename from twilio/rest/microvisor/v1/app/__init__.py rename to twilio/rest/marketplace/v1/available_add_on/__init__.py index e9f547af76..297d5dd6f3 100644 --- a/twilio/rest/microvisor/v1/app/__init__.py +++ b/twilio/rest/marketplace/v1/available_add_on/__init__.py @@ -4,7 +4,7 @@ | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - Twilio - Microvisor + Twilio - Marketplace This is the public Twilio REST API. NOTE: This class is auto generated by OpenAPI Generator. @@ -12,29 +12,27 @@ 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 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.microvisor.v1.app.app_manifest import AppManifestList - +from twilio.rest.marketplace.v1.available_add_on.available_add_on_extension import ( + AvailableAddOnExtensionList, +) -class AppInstance(InstanceResource): +class AvailableAddOnInstance(InstanceResource): """ - :ivar sid: A 34-character string that uniquely identifies this App. - :ivar account_sid: The unique SID identifier of the Account. - :ivar hash: App manifest hash represented as `hash_algorithm:hash_value`. - :ivar unique_name: A developer-defined string that uniquely identifies the App. This value must be unique for all Apps on this Account. The `unique_name` value may be used as an alternative to the `sid` in the URL path to address the resource. - :ivar date_created: The date that this App was created, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. - :ivar date_updated: The date that this App was last updated, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. - :ivar url: The URL of this resource. - :ivar links: + :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__( @@ -43,14 +41,11 @@ def __init__( super().__init__(version) self.sid: Optional[str] = payload.get("sid") - self.account_sid: Optional[str] = payload.get("account_sid") - self.hash: Optional[str] = payload.get("hash") - 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.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") @@ -58,65 +53,47 @@ def __init__( self._solution = { "sid": sid or self.sid, } - self._context: Optional[AppContext] = None + self._context: Optional[AvailableAddOnContext] = None @property - def _proxy(self) -> "AppContext": + 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: AppContext for this AppInstance + :returns: AvailableAddOnContext for this AvailableAddOnInstance """ if self._context is None: - self._context = AppContext( + self._context = AvailableAddOnContext( self._version, sid=self._solution["sid"], ) return self._context - def delete(self) -> bool: + def fetch(self) -> "AvailableAddOnInstance": """ - Deletes the AppInstance + Fetch the AvailableAddOnInstance - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the AppInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def fetch(self) -> "AppInstance": - """ - Fetch the AppInstance - - - :returns: The fetched AppInstance + :returns: The fetched AvailableAddOnInstance """ return self._proxy.fetch() - async def fetch_async(self) -> "AppInstance": + async def fetch_async(self) -> "AvailableAddOnInstance": """ - Asynchronous coroutine to fetch the AppInstance + Asynchronous coroutine to fetch the AvailableAddOnInstance - :returns: The fetched AppInstance + :returns: The fetched AvailableAddOnInstance """ return await self._proxy.fetch_async() @property - def app_manifests(self) -> AppManifestList: + def extensions(self) -> AvailableAddOnExtensionList: """ - Access the app_manifests + Access the extensions """ - return self._proxy.app_manifests + return self._proxy.extensions def __repr__(self) -> str: """ @@ -125,16 +102,17 @@ 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 AppContext(InstanceContext): +class AvailableAddOnContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ - Initialize the AppContext + Initialize the AvailableAddOnContext :param version: Version that contains the resource - :param sid: A 34-character string that uniquely identifies this App. + :param sid: The SID of the AvailableAddOn resource to fetch. """ super().__init__(version) @@ -142,83 +120,63 @@ def __init__(self, version: Version, sid: str): self._solution = { "sid": sid, } - self._uri = "/Apps/{sid}".format(**self._solution) - - self._app_manifests: Optional[AppManifestList] = None - - def delete(self) -> bool: - """ - Deletes the AppInstance + self._uri = "/AvailableAddOns/{sid}".format(**self._solution) + self._extensions: Optional[AvailableAddOnExtensionList] = None - :returns: True if delete succeeds, False otherwise + def fetch(self) -> AvailableAddOnInstance: """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the AppInstance + Fetch the AvailableAddOnInstance - :returns: True if delete succeeds, False otherwise + :returns: The fetched AvailableAddOnInstance """ - return await self._version.delete_async( - method="DELETE", - uri=self._uri, - ) - def fetch(self) -> AppInstance: - """ - Fetch the AppInstance + headers = values.of({}) + headers["Accept"] = "application/json" - :returns: The fetched AppInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) - return AppInstance( + return AvailableAddOnInstance( self._version, payload, sid=self._solution["sid"], ) - async def fetch_async(self) -> AppInstance: + async def fetch_async(self) -> AvailableAddOnInstance: """ - Asynchronous coroutine to fetch the AppInstance + Asynchronous coroutine to fetch the AvailableAddOnInstance - :returns: The fetched AppInstance + :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 AppInstance( + return AvailableAddOnInstance( self._version, payload, sid=self._solution["sid"], ) @property - def app_manifests(self) -> AppManifestList: + def extensions(self) -> AvailableAddOnExtensionList: """ - Access the app_manifests + Access the extensions """ - if self._app_manifests is None: - self._app_manifests = AppManifestList( + if self._extensions is None: + self._extensions = AvailableAddOnExtensionList( self._version, self._solution["sid"], ) - return self._app_manifests + return self._extensions def __repr__(self) -> str: """ @@ -227,17 +185,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 AvailableAddOnPage(Page): -class AppPage(Page): - def get_instance(self, payload: Dict[str, Any]) -> AppInstance: + def get_instance(self, payload: Dict[str, Any]) -> AvailableAddOnInstance: """ - Build an instance of AppInstance + Build an instance of AvailableAddOnInstance :param payload: Payload response from the API """ - return AppInstance(self._version, payload) + return AvailableAddOnInstance(self._version, payload) def __repr__(self) -> str: """ @@ -245,28 +204,29 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ - return "" + return "" -class AppList(ListResource): +class AvailableAddOnList(ListResource): + def __init__(self, version: Version): """ - Initialize the AppList + Initialize the AvailableAddOnList :param version: Version that contains the resource """ super().__init__(version) - self._uri = "/Apps" + self._uri = "/AvailableAddOns" def stream( self, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> Iterator[AppInstance]: + ) -> Iterator[AvailableAddOnInstance]: """ - Streams AppInstance records from the API as a generator stream. + 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. @@ -289,9 +249,9 @@ async def stream_async( self, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> AsyncIterator[AppInstance]: + ) -> AsyncIterator[AvailableAddOnInstance]: """ - Asynchronously streams AppInstance records from the API as a generator stream. + 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. @@ -314,9 +274,9 @@ def list( self, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> List[AppInstance]: + ) -> List[AvailableAddOnInstance]: """ - Lists AppInstance records from the API as a list. + Lists AvailableAddOnInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @@ -340,9 +300,9 @@ async def list_async( self, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> List[AppInstance]: + ) -> List[AvailableAddOnInstance]: """ - Asynchronously lists AppInstance records from the API as a list. + 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. @@ -368,16 +328,16 @@ def page( page_token: Union[str, object] = values.unset, page_number: Union[int, object] = values.unset, page_size: Union[int, object] = values.unset, - ) -> AppPage: + ) -> AvailableAddOnPage: """ - Retrieve a single page of AppInstance records from the API. + 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 AppInstance + :returns: Page of AvailableAddOnInstance """ data = values.of( { @@ -387,24 +347,30 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) - return AppPage(self._version, response) + headers = values.of({"Content-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, - ) -> AppPage: + ) -> AvailableAddOnPage: """ - Asynchronously retrieve a single page of AppInstance records from the API. + 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 AppInstance + :returns: Page of AvailableAddOnInstance """ data = values.of( { @@ -414,50 +380,54 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/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) + return AvailableAddOnPage(self._version, response) - def get_page(self, target_url: str) -> AppPage: + def get_page(self, target_url: str) -> AvailableAddOnPage: """ - Retrieve a specific page of AppInstance records from the API. + 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 AppInstance + :returns: Page of AvailableAddOnInstance """ response = self._version.domain.twilio.request("GET", target_url) - return AppPage(self._version, response) + return AvailableAddOnPage(self._version, response) - async def get_page_async(self, target_url: str) -> AppPage: + async def get_page_async(self, target_url: str) -> AvailableAddOnPage: """ - Asynchronously retrieve a specific page of AppInstance records from the API. + 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 AppInstance + :returns: Page of AvailableAddOnInstance """ response = await self._version.domain.twilio.request_async("GET", target_url) - return AppPage(self._version, response) + return AvailableAddOnPage(self._version, response) - def get(self, sid: str) -> AppContext: + def get(self, sid: str) -> AvailableAddOnContext: """ - Constructs a AppContext + Constructs a AvailableAddOnContext - :param sid: A 34-character string that uniquely identifies this App. + :param sid: The SID of the AvailableAddOn resource to fetch. """ - return AppContext(self._version, sid=sid) + return AvailableAddOnContext(self._version, sid=sid) - def __call__(self, sid: str) -> AppContext: + def __call__(self, sid: str) -> AvailableAddOnContext: """ - Constructs a AppContext + Constructs a AvailableAddOnContext - :param sid: A 34-character string that uniquely identifies this App. + :param sid: The SID of the AvailableAddOn resource to fetch. """ - return AppContext(self._version, sid=sid) + return AvailableAddOnContext(self._version, sid=sid) def __repr__(self) -> str: """ @@ -465,4 +435,4 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ - return "" + return "" diff --git a/twilio/rest/microvisor/v1/account_secret.py b/twilio/rest/marketplace/v1/available_add_on/available_add_on_extension.py similarity index 50% rename from twilio/rest/microvisor/v1/account_secret.py rename to twilio/rest/marketplace/v1/available_add_on/available_add_on_extension.py index a7fc4f8969..a8973a08b0 100644 --- a/twilio/rest/microvisor/v1/account_secret.py +++ b/twilio/rest/marketplace/v1/available_add_on/available_add_on_extension.py @@ -4,7 +4,7 @@ | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - Twilio - Microvisor + Twilio - Marketplace This is the public Twilio REST API. NOTE: This class is auto generated by OpenAPI Generator. @@ -12,10 +12,8 @@ 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 import values from twilio.base.instance_context import InstanceContext from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource @@ -23,105 +21,72 @@ from twilio.base.page import Page -class AccountSecretInstance(InstanceResource): - +class AvailableAddOnExtensionInstance(InstanceResource): """ - :ivar key: The secret key; up to 100 characters. - :ivar date_rotated: - :ivar url: The absolute URL of the Secret. + :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], key: Optional[str] = None + self, + version: Version, + payload: Dict[str, Any], + available_add_on_sid: str, + sid: Optional[str] = None, ): super().__init__(version) - self.key: Optional[str] = payload.get("key") - self.date_rotated: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("date_rotated") - ) + 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 = { - "key": key or self.key, + "available_add_on_sid": available_add_on_sid, + "sid": sid or self.sid, } - self._context: Optional[AccountSecretContext] = None + self._context: Optional[AvailableAddOnExtensionContext] = None @property - def _proxy(self) -> "AccountSecretContext": + 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: AccountSecretContext for this AccountSecretInstance + :returns: AvailableAddOnExtensionContext for this AvailableAddOnExtensionInstance """ if self._context is None: - self._context = AccountSecretContext( + self._context = AvailableAddOnExtensionContext( self._version, - key=self._solution["key"], + available_add_on_sid=self._solution["available_add_on_sid"], + sid=self._solution["sid"], ) return self._context - def delete(self) -> bool: - """ - Deletes the AccountSecretInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the AccountSecretInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def fetch(self) -> "AccountSecretInstance": + def fetch(self) -> "AvailableAddOnExtensionInstance": """ - Fetch the AccountSecretInstance + Fetch the AvailableAddOnExtensionInstance - :returns: The fetched AccountSecretInstance + :returns: The fetched AvailableAddOnExtensionInstance """ return self._proxy.fetch() - async def fetch_async(self) -> "AccountSecretInstance": + async def fetch_async(self) -> "AvailableAddOnExtensionInstance": """ - Asynchronous coroutine to fetch the AccountSecretInstance + Asynchronous coroutine to fetch the AvailableAddOnExtensionInstance - :returns: The fetched AccountSecretInstance + :returns: The fetched AvailableAddOnExtensionInstance """ return await self._proxy.fetch_async() - def update(self, value: str) -> "AccountSecretInstance": - """ - Update the AccountSecretInstance - - :param value: The secret value; up to 4096 characters. - - :returns: The updated AccountSecretInstance - """ - return self._proxy.update( - value=value, - ) - - async def update_async(self, value: str) -> "AccountSecretInstance": - """ - Asynchronous coroutine to update the AccountSecretInstance - - :param value: The secret value; up to 4096 characters. - - :returns: The updated AccountSecretInstance - """ - return await self._proxy.update_async( - value=value, - ) - def __repr__(self) -> str: """ Provide a friendly representation @@ -129,131 +94,76 @@ 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 AccountSecretContext(InstanceContext): - def __init__(self, version: Version, key: str): +class AvailableAddOnExtensionContext(InstanceContext): + + def __init__(self, version: Version, available_add_on_sid: str, sid: str): """ - Initialize the AccountSecretContext + Initialize the AvailableAddOnExtensionContext :param version: Version that contains the resource - :param key: The secret key; up to 100 characters. + :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 = { - "key": key, + "available_add_on_sid": available_add_on_sid, + "sid": sid, } - self._uri = "/Secrets/{key}".format(**self._solution) - - def delete(self) -> bool: - """ - Deletes the AccountSecretInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._version.delete( - method="DELETE", - uri=self._uri, + self._uri = "/AvailableAddOns/{available_add_on_sid}/Extensions/{sid}".format( + **self._solution ) - async def delete_async(self) -> bool: + def fetch(self) -> AvailableAddOnExtensionInstance: """ - Asynchronous coroutine that deletes the AccountSecretInstance + Fetch the AvailableAddOnExtensionInstance - :returns: True if delete succeeds, False otherwise + :returns: The fetched AvailableAddOnExtensionInstance """ - return await self._version.delete_async( - method="DELETE", - uri=self._uri, - ) - - def fetch(self) -> AccountSecretInstance: - """ - Fetch the AccountSecretInstance + headers = values.of({}) - :returns: The fetched AccountSecretInstance - """ + headers["Accept"] = "application/json" - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) - return AccountSecretInstance( + return AvailableAddOnExtensionInstance( self._version, payload, - key=self._solution["key"], + available_add_on_sid=self._solution["available_add_on_sid"], + sid=self._solution["sid"], ) - async def fetch_async(self) -> AccountSecretInstance: + async def fetch_async(self) -> AvailableAddOnExtensionInstance: """ - Asynchronous coroutine to fetch the AccountSecretInstance + Asynchronous coroutine to fetch the AvailableAddOnExtensionInstance - :returns: The fetched AccountSecretInstance + :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 AccountSecretInstance( + return AvailableAddOnExtensionInstance( self._version, payload, - key=self._solution["key"], + available_add_on_sid=self._solution["available_add_on_sid"], + sid=self._solution["sid"], ) - def update(self, value: str) -> AccountSecretInstance: - """ - Update the AccountSecretInstance - - :param value: The secret value; up to 4096 characters. - - :returns: The updated AccountSecretInstance - """ - data = values.of( - { - "Value": value, - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return AccountSecretInstance(self._version, payload, key=self._solution["key"]) - - async def update_async(self, value: str) -> AccountSecretInstance: - """ - Asynchronous coroutine to update the AccountSecretInstance - - :param value: The secret value; up to 4096 characters. - - :returns: The updated AccountSecretInstance - """ - data = values.of( - { - "Value": value, - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return AccountSecretInstance(self._version, payload, key=self._solution["key"]) - def __repr__(self) -> str: """ Provide a friendly representation @@ -261,17 +171,24 @@ 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 AvailableAddOnExtensionPage(Page): -class AccountSecretPage(Page): - def get_instance(self, payload: Dict[str, Any]) -> AccountSecretInstance: + def get_instance(self, payload: Dict[str, Any]) -> AvailableAddOnExtensionInstance: """ - Build an instance of AccountSecretInstance + Build an instance of AvailableAddOnExtensionInstance :param payload: Payload response from the API """ - return AccountSecretInstance(self._version, payload) + return AvailableAddOnExtensionInstance( + self._version, + payload, + available_add_on_sid=self._solution["available_add_on_sid"], + ) def __repr__(self) -> str: """ @@ -279,76 +196,36 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ - return "" + return "" + +class AvailableAddOnExtensionList(ListResource): -class AccountSecretList(ListResource): - def __init__(self, version: Version): + def __init__(self, version: Version, available_add_on_sid: str): """ - Initialize the AccountSecretList + 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) - self._uri = "/Secrets" - - def create(self, key: str, value: str) -> AccountSecretInstance: - """ - Create the AccountSecretInstance - - :param key: The secret key; up to 100 characters. - :param value: The secret value; up to 4096 characters. - - :returns: The created AccountSecretInstance - """ - data = values.of( - { - "Key": key, - "Value": value, - } - ) - - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) - - return AccountSecretInstance(self._version, payload) - - async def create_async(self, key: str, value: str) -> AccountSecretInstance: - """ - Asynchronously create the AccountSecretInstance - - :param key: The secret key; up to 100 characters. - :param value: The secret value; up to 4096 characters. - - :returns: The created AccountSecretInstance - """ - data = values.of( - { - "Key": key, - "Value": value, - } - ) - - payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + # Path Solution + self._solution = { + "available_add_on_sid": available_add_on_sid, + } + self._uri = "/AvailableAddOns/{available_add_on_sid}/Extensions".format( + **self._solution ) - return AccountSecretInstance(self._version, payload) - def stream( self, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> Iterator[AccountSecretInstance]: + ) -> Iterator[AvailableAddOnExtensionInstance]: """ - Streams AccountSecretInstance records from the API as a generator stream. + 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. @@ -371,9 +248,9 @@ async def stream_async( self, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> AsyncIterator[AccountSecretInstance]: + ) -> AsyncIterator[AvailableAddOnExtensionInstance]: """ - Asynchronously streams AccountSecretInstance records from the API as a generator stream. + 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. @@ -396,9 +273,9 @@ def list( self, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> List[AccountSecretInstance]: + ) -> List[AvailableAddOnExtensionInstance]: """ - Lists AccountSecretInstance records from the API as a list. + Lists AvailableAddOnExtensionInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @@ -422,9 +299,9 @@ async def list_async( self, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> List[AccountSecretInstance]: + ) -> List[AvailableAddOnExtensionInstance]: """ - Asynchronously lists AccountSecretInstance records from the API as a list. + 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. @@ -450,16 +327,16 @@ def page( page_token: Union[str, object] = values.unset, page_number: Union[int, object] = values.unset, page_size: Union[int, object] = values.unset, - ) -> AccountSecretPage: + ) -> AvailableAddOnExtensionPage: """ - Retrieve a single page of AccountSecretInstance records from the API. + 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 AccountSecretInstance + :returns: Page of AvailableAddOnExtensionInstance """ data = values.of( { @@ -469,24 +346,30 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) - return AccountSecretPage(self._version, response) + headers = values.of({"Content-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, - ) -> AccountSecretPage: + ) -> AvailableAddOnExtensionPage: """ - Asynchronously retrieve a single page of AccountSecretInstance records from the API. + 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 AccountSecretInstance + :returns: Page of AvailableAddOnExtensionInstance """ data = values.of( { @@ -496,50 +379,62 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/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) + return AvailableAddOnExtensionPage(self._version, response, self._solution) - def get_page(self, target_url: str) -> AccountSecretPage: + def get_page(self, target_url: str) -> AvailableAddOnExtensionPage: """ - Retrieve a specific page of AccountSecretInstance records from the API. + 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 AccountSecretInstance + :returns: Page of AvailableAddOnExtensionInstance """ response = self._version.domain.twilio.request("GET", target_url) - return AccountSecretPage(self._version, response) + return AvailableAddOnExtensionPage(self._version, response, self._solution) - async def get_page_async(self, target_url: str) -> AccountSecretPage: + async def get_page_async(self, target_url: str) -> AvailableAddOnExtensionPage: """ - Asynchronously retrieve a specific page of AccountSecretInstance records from the API. + 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 AccountSecretInstance + :returns: Page of AvailableAddOnExtensionInstance """ response = await self._version.domain.twilio.request_async("GET", target_url) - return AccountSecretPage(self._version, response) + return AvailableAddOnExtensionPage(self._version, response, self._solution) - def get(self, key: str) -> AccountSecretContext: + def get(self, sid: str) -> AvailableAddOnExtensionContext: """ - Constructs a AccountSecretContext + Constructs a AvailableAddOnExtensionContext - :param key: The secret key; up to 100 characters. + :param sid: The SID of the AvailableAddOn Extension resource to fetch. """ - return AccountSecretContext(self._version, key=key) + return AvailableAddOnExtensionContext( + self._version, + available_add_on_sid=self._solution["available_add_on_sid"], + sid=sid, + ) - def __call__(self, key: str) -> AccountSecretContext: + def __call__(self, sid: str) -> AvailableAddOnExtensionContext: """ - Constructs a AccountSecretContext + Constructs a AvailableAddOnExtensionContext - :param key: The secret key; up to 100 characters. + :param sid: The SID of the AvailableAddOn Extension resource to fetch. """ - return AccountSecretContext(self._version, key=key) + return AvailableAddOnExtensionContext( + self._version, + available_add_on_sid=self._solution["available_add_on_sid"], + sid=sid, + ) def __repr__(self) -> str: """ @@ -547,4 +442,4 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ - return "" + return "" diff --git a/twilio/rest/autopilot/v1/assistant/field_type/__init__.py b/twilio/rest/marketplace/v1/installed_add_on/__init__.py similarity index 50% rename from twilio/rest/autopilot/v1/assistant/field_type/__init__.py rename to twilio/rest/marketplace/v1/installed_add_on/__init__.py index 4639a6e962..8fedfb9b41 100644 --- a/twilio/rest/autopilot/v1/assistant/field_type/__init__.py +++ b/twilio/rest/marketplace/v1/installed_add_on/__init__.py @@ -4,7 +4,7 @@ | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - Twilio - Autopilot + Twilio - Marketplace This is the public Twilio REST API. NOTE: This class is auto generated by OpenAPI Generator. @@ -12,80 +12,79 @@ 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 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.autopilot.v1.assistant.field_type.field_value import FieldValueList - +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 FieldTypeInstance(InstanceResource): +class InstalledAddOnInstance(InstanceResource): """ - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the FieldType resource. - :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. - :ivar friendly_name: The string that you assigned to describe the resource. It is not unique and can be up to 255 characters long. - :ivar links: A list of the URLs of related resources. - :ivar assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource. - :ivar sid: The unique string that we created to identify the FieldType 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. - :ivar url: The absolute URL of the FieldType resource. + :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], - assistant_sid: str, - sid: Optional[str] = None, + 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.friendly_name: Optional[str] = payload.get("friendly_name") - self.links: Optional[Dict[str, object]] = payload.get("links") - self.assistant_sid: Optional[str] = payload.get("assistant_sid") - self.sid: Optional[str] = payload.get("sid") - self.unique_name: Optional[str] = payload.get("unique_name") self.url: Optional[str] = payload.get("url") + self.links: Optional[Dict[str, object]] = payload.get("links") self._solution = { - "assistant_sid": assistant_sid, "sid": sid or self.sid, } - self._context: Optional[FieldTypeContext] = None + self._context: Optional[InstalledAddOnContext] = None @property - def _proxy(self) -> "FieldTypeContext": + 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: FieldTypeContext for this FieldTypeInstance + :returns: InstalledAddOnContext for this InstalledAddOnInstance """ if self._context is None: - self._context = FieldTypeContext( + self._context = InstalledAddOnContext( self._version, - assistant_sid=self._solution["assistant_sid"], sid=self._solution["sid"], ) return self._context def delete(self) -> bool: """ - Deletes the FieldTypeInstance + Deletes the InstalledAddOnInstance :returns: True if delete succeeds, False otherwise @@ -94,73 +93,80 @@ def delete(self) -> bool: async def delete_async(self) -> bool: """ - Asynchronous coroutine that deletes the FieldTypeInstance + Asynchronous coroutine that deletes the InstalledAddOnInstance :returns: True if delete succeeds, False otherwise """ return await self._proxy.delete_async() - def fetch(self) -> "FieldTypeInstance": + def fetch(self) -> "InstalledAddOnInstance": """ - Fetch the FieldTypeInstance + Fetch the InstalledAddOnInstance - :returns: The fetched FieldTypeInstance + :returns: The fetched InstalledAddOnInstance """ return self._proxy.fetch() - async def fetch_async(self) -> "FieldTypeInstance": + async def fetch_async(self) -> "InstalledAddOnInstance": """ - Asynchronous coroutine to fetch the FieldTypeInstance + Asynchronous coroutine to fetch the InstalledAddOnInstance - :returns: The fetched FieldTypeInstance + :returns: The fetched InstalledAddOnInstance """ return await self._proxy.fetch_async() def update( self, - friendly_name: Union[str, object] = values.unset, + configuration: Union[object, object] = values.unset, unique_name: Union[str, object] = values.unset, - ) -> "FieldTypeInstance": + ) -> "InstalledAddOnInstance": """ - Update the FieldTypeInstance + Update the InstalledAddOnInstance - :param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long. - :param unique_name: An application-defined string that uniquely identifies the resource. It can be used as an alternative to the `sid` in the URL path to address the resource. The first 64 characters must be unique. + :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 FieldTypeInstance + :returns: The updated InstalledAddOnInstance """ return self._proxy.update( - friendly_name=friendly_name, + configuration=configuration, unique_name=unique_name, ) async def update_async( self, - friendly_name: Union[str, object] = values.unset, + configuration: Union[object, object] = values.unset, unique_name: Union[str, object] = values.unset, - ) -> "FieldTypeInstance": + ) -> "InstalledAddOnInstance": """ - Asynchronous coroutine to update the FieldTypeInstance + Asynchronous coroutine to update the InstalledAddOnInstance - :param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long. - :param unique_name: An application-defined string that uniquely identifies the resource. It can be used as an alternative to the `sid` in the URL path to address the resource. The first 64 characters must be unique. + :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 FieldTypeInstance + :returns: The updated InstalledAddOnInstance """ return await self._proxy.update_async( - friendly_name=friendly_name, + configuration=configuration, unique_name=unique_name, ) @property - def field_values(self) -> FieldValueList: + def extensions(self) -> InstalledAddOnExtensionList: + """ + Access the extensions + """ + return self._proxy.extensions + + @property + def usage(self) -> InstalledAddOnUsageList: """ - Access the field_values + Access the usage """ - return self._proxy.field_values + return self._proxy.usage def __repr__(self) -> str: """ @@ -169,173 +175,184 @@ 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 FieldTypeContext(InstanceContext): - def __init__(self, version: Version, assistant_sid: str, sid: str): +class InstalledAddOnContext(InstanceContext): + + def __init__(self, version: Version, sid: str): """ - Initialize the FieldTypeContext + Initialize the InstalledAddOnContext :param version: Version that contains the resource - :param assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the to update. - :param sid: The Twilio-provided string that uniquely identifies the FieldType resource to update. + :param sid: The SID of the InstalledAddOn resource to update. """ super().__init__(version) # Path Solution self._solution = { - "assistant_sid": assistant_sid, "sid": sid, } - self._uri = "/Assistants/{assistant_sid}/FieldTypes/{sid}".format( - **self._solution - ) + self._uri = "/InstalledAddOns/{sid}".format(**self._solution) - self._field_values: Optional[FieldValueList] = None + self._extensions: Optional[InstalledAddOnExtensionList] = None + self._usage: Optional[InstalledAddOnUsageList] = None def delete(self) -> bool: """ - Deletes the FieldTypeInstance + Deletes the InstalledAddOnInstance :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 FieldTypeInstance + 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, + method="DELETE", uri=self._uri, headers=headers ) - def fetch(self) -> FieldTypeInstance: + def fetch(self) -> InstalledAddOnInstance: """ - Fetch the FieldTypeInstance + Fetch the InstalledAddOnInstance - :returns: The fetched FieldTypeInstance + :returns: The fetched InstalledAddOnInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) + + headers["Accept"] = "application/json" - return FieldTypeInstance( + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return InstalledAddOnInstance( self._version, payload, - assistant_sid=self._solution["assistant_sid"], sid=self._solution["sid"], ) - async def fetch_async(self) -> FieldTypeInstance: + async def fetch_async(self) -> InstalledAddOnInstance: """ - Asynchronous coroutine to fetch the FieldTypeInstance + Asynchronous coroutine to fetch the InstalledAddOnInstance - :returns: The fetched FieldTypeInstance + :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 FieldTypeInstance( + return InstalledAddOnInstance( self._version, payload, - assistant_sid=self._solution["assistant_sid"], sid=self._solution["sid"], ) def update( self, - friendly_name: Union[str, object] = values.unset, + configuration: Union[object, object] = values.unset, unique_name: Union[str, object] = values.unset, - ) -> FieldTypeInstance: + ) -> InstalledAddOnInstance: """ - Update the FieldTypeInstance + Update the InstalledAddOnInstance - :param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long. - :param unique_name: An application-defined string that uniquely identifies the resource. It can be used as an alternative to the `sid` in the URL path to address the resource. The first 64 characters must be unique. + :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 FieldTypeInstance + :returns: The updated InstalledAddOnInstance """ + data = values.of( { - "FriendlyName": friendly_name, + "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 FieldTypeInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) + return InstalledAddOnInstance(self._version, payload, sid=self._solution["sid"]) async def update_async( self, - friendly_name: Union[str, object] = values.unset, + configuration: Union[object, object] = values.unset, unique_name: Union[str, object] = values.unset, - ) -> FieldTypeInstance: + ) -> InstalledAddOnInstance: """ - Asynchronous coroutine to update the FieldTypeInstance + Asynchronous coroutine to update the InstalledAddOnInstance - :param friendly_name: A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long. - :param unique_name: An application-defined string that uniquely identifies the resource. It can be used as an alternative to the `sid` in the URL path to address the resource. The first 64 characters must be unique. + :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 FieldTypeInstance + :returns: The updated InstalledAddOnInstance """ + data = values.of( { - "FriendlyName": friendly_name, + "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 FieldTypeInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) + 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 field_values(self) -> FieldValueList: + def usage(self) -> InstalledAddOnUsageList: """ - Access the field_values + Access the usage """ - if self._field_values is None: - self._field_values = FieldValueList( + if self._usage is None: + self._usage = InstalledAddOnUsageList( self._version, - self._solution["assistant_sid"], self._solution["sid"], ) - return self._field_values + return self._usage def __repr__(self) -> str: """ @@ -344,19 +361,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 InstalledAddOnPage(Page): -class FieldTypePage(Page): - def get_instance(self, payload: Dict[str, Any]) -> FieldTypeInstance: + def get_instance(self, payload: Dict[str, Any]) -> InstalledAddOnInstance: """ - Build an instance of FieldTypeInstance + Build an instance of InstalledAddOnInstance :param payload: Payload response from the API """ - return FieldTypeInstance( - self._version, payload, assistant_sid=self._solution["assistant_sid"] - ) + return InstalledAddOnInstance(self._version, payload) def __repr__(self) -> str: """ @@ -364,89 +380,109 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ - return "" + return "" + +class InstalledAddOnList(ListResource): -class FieldTypeList(ListResource): - def __init__(self, version: Version, assistant_sid: str): + def __init__(self, version: Version): """ - Initialize the FieldTypeList + Initialize the InstalledAddOnList :param version: Version that contains the resource - :param assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resources to read. """ super().__init__(version) - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - } - self._uri = "/Assistants/{assistant_sid}/FieldTypes".format(**self._solution) + self._uri = "/InstalledAddOns" def create( - self, unique_name: str, friendly_name: Union[str, object] = values.unset - ) -> FieldTypeInstance: + 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 FieldTypeInstance + Create the InstalledAddOnInstance - :param unique_name: An application-defined string that uniquely identifies the new resource. It can be used as an alternative to the `sid` in the URL path to address the resource. The first 64 characters must be unique. - :param friendly_name: A descriptive string that you create to describe the new resource. It is not unique and can be up to 255 characters long. + :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 FieldTypeInstance + :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, - "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 FieldTypeInstance( - self._version, payload, assistant_sid=self._solution["assistant_sid"] - ) + return InstalledAddOnInstance(self._version, payload) async def create_async( - self, unique_name: str, friendly_name: Union[str, object] = values.unset - ) -> FieldTypeInstance: + 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 FieldTypeInstance + Asynchronously create the InstalledAddOnInstance - :param unique_name: An application-defined string that uniquely identifies the new resource. It can be used as an alternative to the `sid` in the URL path to address the resource. The first 64 characters must be unique. - :param friendly_name: A descriptive string that you create to describe the new resource. It is not unique and can be up to 255 characters long. + :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 FieldTypeInstance + :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, - "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 FieldTypeInstance( - self._version, payload, assistant_sid=self._solution["assistant_sid"] - ) + return InstalledAddOnInstance(self._version, payload) def stream( self, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> Iterator[FieldTypeInstance]: + ) -> Iterator[InstalledAddOnInstance]: """ - Streams FieldTypeInstance records from the API as a generator stream. + 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. @@ -469,9 +505,9 @@ async def stream_async( self, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> AsyncIterator[FieldTypeInstance]: + ) -> AsyncIterator[InstalledAddOnInstance]: """ - Asynchronously streams FieldTypeInstance records from the API as a generator stream. + 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. @@ -494,9 +530,9 @@ def list( self, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> List[FieldTypeInstance]: + ) -> List[InstalledAddOnInstance]: """ - Lists FieldTypeInstance records from the API as a list. + Lists InstalledAddOnInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @@ -520,9 +556,9 @@ async def list_async( self, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> List[FieldTypeInstance]: + ) -> List[InstalledAddOnInstance]: """ - Asynchronously lists FieldTypeInstance records from the API as a list. + 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. @@ -548,16 +584,16 @@ def page( page_token: Union[str, object] = values.unset, page_number: Union[int, object] = values.unset, page_size: Union[int, object] = values.unset, - ) -> FieldTypePage: + ) -> InstalledAddOnPage: """ - Retrieve a single page of FieldTypeInstance records from the API. + 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 FieldTypeInstance + :returns: Page of InstalledAddOnInstance """ data = values.of( { @@ -567,24 +603,30 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) - return FieldTypePage(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 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, - ) -> FieldTypePage: + ) -> InstalledAddOnPage: """ - Asynchronously retrieve a single page of FieldTypeInstance records from the API. + 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 FieldTypeInstance + :returns: Page of InstalledAddOnInstance """ data = values.of( { @@ -594,54 +636,54 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) - return FieldTypePage(self._version, response, self._solution) + return InstalledAddOnPage(self._version, response) - def get_page(self, target_url: str) -> FieldTypePage: + def get_page(self, target_url: str) -> InstalledAddOnPage: """ - Retrieve a specific page of FieldTypeInstance records from the API. + 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 FieldTypeInstance + :returns: Page of InstalledAddOnInstance """ response = self._version.domain.twilio.request("GET", target_url) - return FieldTypePage(self._version, response, self._solution) + return InstalledAddOnPage(self._version, response) - async def get_page_async(self, target_url: str) -> FieldTypePage: + async def get_page_async(self, target_url: str) -> InstalledAddOnPage: """ - Asynchronously retrieve a specific page of FieldTypeInstance records from the API. + 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 FieldTypeInstance + :returns: Page of InstalledAddOnInstance """ response = await self._version.domain.twilio.request_async("GET", target_url) - return FieldTypePage(self._version, response, self._solution) + return InstalledAddOnPage(self._version, response) - def get(self, sid: str) -> FieldTypeContext: + def get(self, sid: str) -> InstalledAddOnContext: """ - Constructs a FieldTypeContext + Constructs a InstalledAddOnContext - :param sid: The Twilio-provided string that uniquely identifies the FieldType resource to update. + :param sid: The SID of the InstalledAddOn resource to update. """ - return FieldTypeContext( - self._version, assistant_sid=self._solution["assistant_sid"], sid=sid - ) + return InstalledAddOnContext(self._version, sid=sid) - def __call__(self, sid: str) -> FieldTypeContext: + def __call__(self, sid: str) -> InstalledAddOnContext: """ - Constructs a FieldTypeContext + Constructs a InstalledAddOnContext - :param sid: The Twilio-provided string that uniquely identifies the FieldType resource to update. + :param sid: The SID of the InstalledAddOn resource to update. """ - return FieldTypeContext( - self._version, assistant_sid=self._solution["assistant_sid"], sid=sid - ) + return InstalledAddOnContext(self._version, sid=sid) def __repr__(self) -> str: """ @@ -649,4 +691,4 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ - return "" + return "" diff --git a/twilio/rest/preview/understand/assistant/task/field.py b/twilio/rest/marketplace/v1/installed_add_on/installed_add_on_extension.py similarity index 51% rename from twilio/rest/preview/understand/assistant/task/field.py rename to twilio/rest/marketplace/v1/installed_add_on/installed_add_on_extension.py index e8f4aa3a8c..88f160ed29 100644 --- a/twilio/rest/preview/understand/assistant/task/field.py +++ b/twilio/rest/marketplace/v1/installed_add_on/installed_add_on_extension.py @@ -4,7 +4,7 @@ | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - Twilio - Preview + Twilio - Marketplace This is the public Twilio REST API. NOTE: This class is auto generated by OpenAPI Generator. @@ -12,10 +12,8 @@ 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 import serialize, values from twilio.base.instance_context import InstanceContext from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource @@ -23,103 +21,97 @@ from twilio.base.page import Page -class FieldInstance(InstanceResource): - +class InstalledAddOnExtensionInstance(InstanceResource): """ - :ivar account_sid: The unique ID of the Account that created this Field. - :ivar date_created: The date that this resource was created - :ivar date_updated: The date that this resource was last updated - :ivar field_type: The Field Type of this field. It can be any [Built-in Field Type](https://www.twilio.com/docs/assistant/api/built-in-field-types) or the unique_name or sid of a custom Field Type. - :ivar task_sid: The unique ID of the Task associated with this Field. - :ivar assistant_sid: The unique ID of the parent Assistant. - :ivar sid: A 34 character string that uniquely identifies this resource. - :ivar unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - :ivar url: + :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], - assistant_sid: str, - task_sid: str, + installed_add_on_sid: str, 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.field_type: Optional[str] = payload.get("field_type") - self.task_sid: Optional[str] = payload.get("task_sid") - self.assistant_sid: Optional[str] = payload.get("assistant_sid") 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 = { - "assistant_sid": assistant_sid, - "task_sid": task_sid, + "installed_add_on_sid": installed_add_on_sid, "sid": sid or self.sid, } - self._context: Optional[FieldContext] = None + self._context: Optional[InstalledAddOnExtensionContext] = None @property - def _proxy(self) -> "FieldContext": + 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: FieldContext for this FieldInstance + :returns: InstalledAddOnExtensionContext for this InstalledAddOnExtensionInstance """ if self._context is None: - self._context = FieldContext( + self._context = InstalledAddOnExtensionContext( self._version, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], + installed_add_on_sid=self._solution["installed_add_on_sid"], sid=self._solution["sid"], ) return self._context - def delete(self) -> bool: + def fetch(self) -> "InstalledAddOnExtensionInstance": """ - Deletes the FieldInstance + Fetch the InstalledAddOnExtensionInstance - :returns: True if delete succeeds, False otherwise + :returns: The fetched InstalledAddOnExtensionInstance """ - return self._proxy.delete() + return self._proxy.fetch() - async def delete_async(self) -> bool: + async def fetch_async(self) -> "InstalledAddOnExtensionInstance": """ - Asynchronous coroutine that deletes the FieldInstance + Asynchronous coroutine to fetch the InstalledAddOnExtensionInstance - :returns: True if delete succeeds, False otherwise + :returns: The fetched InstalledAddOnExtensionInstance """ - return await self._proxy.delete_async() + return await self._proxy.fetch_async() - def fetch(self) -> "FieldInstance": + def update(self, enabled: bool) -> "InstalledAddOnExtensionInstance": """ - Fetch the FieldInstance + Update the InstalledAddOnExtensionInstance + :param enabled: Whether the Extension should be invoked. - :returns: The fetched FieldInstance + :returns: The updated InstalledAddOnExtensionInstance """ - return self._proxy.fetch() + return self._proxy.update( + enabled=enabled, + ) - async def fetch_async(self) -> "FieldInstance": + async def update_async(self, enabled: bool) -> "InstalledAddOnExtensionInstance": """ - Asynchronous coroutine to fetch the FieldInstance + Asynchronous coroutine to update the InstalledAddOnExtensionInstance + :param enabled: Whether the Extension should be invoked. - :returns: The fetched FieldInstance + :returns: The updated InstalledAddOnExtensionInstance """ - return await self._proxy.fetch_async() + return await self._proxy.update_async( + enabled=enabled, + ) def __repr__(self) -> str: """ @@ -128,94 +120,135 @@ 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 FieldContext(InstanceContext): - def __init__(self, version: Version, assistant_sid: str, task_sid: str, sid: str): +class InstalledAddOnExtensionContext(InstanceContext): + + def __init__(self, version: Version, installed_add_on_sid: str, sid: str): """ - Initialize the FieldContext + Initialize the InstalledAddOnExtensionContext :param version: Version that contains the resource - :param assistant_sid: The unique ID of the Assistant. - :param task_sid: The unique ID of the Task associated with this Field. - :param sid: A 34 character string that uniquely identifies this 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 = { - "assistant_sid": assistant_sid, - "task_sid": task_sid, + "installed_add_on_sid": installed_add_on_sid, "sid": sid, } - self._uri = "/Assistants/{assistant_sid}/Tasks/{task_sid}/Fields/{sid}".format( + self._uri = "/InstalledAddOns/{installed_add_on_sid}/Extensions/{sid}".format( **self._solution ) - def delete(self) -> bool: + def fetch(self) -> InstalledAddOnExtensionInstance: """ - Deletes the FieldInstance + Fetch the InstalledAddOnExtensionInstance - :returns: True if delete succeeds, False otherwise + :returns: The fetched InstalledAddOnExtensionInstance """ - return self._version.delete( - method="DELETE", - 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, + payload, + installed_add_on_sid=self._solution["installed_add_on_sid"], + sid=self._solution["sid"], ) - async def delete_async(self) -> bool: + async def fetch_async(self) -> InstalledAddOnExtensionInstance: """ - Asynchronous coroutine that deletes the FieldInstance + Asynchronous coroutine to fetch the InstalledAddOnExtensionInstance - :returns: True if delete succeeds, False otherwise + :returns: The fetched InstalledAddOnExtensionInstance """ - return await self._version.delete_async( - method="DELETE", - uri=self._uri, + + 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 fetch(self) -> FieldInstance: + def update(self, enabled: bool) -> InstalledAddOnExtensionInstance: """ - Fetch the FieldInstance + Update the InstalledAddOnExtensionInstance + :param enabled: Whether the Extension should be invoked. - :returns: The fetched FieldInstance + :returns: The updated InstalledAddOnExtensionInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, + 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 FieldInstance( + return InstalledAddOnExtensionInstance( self._version, payload, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], + installed_add_on_sid=self._solution["installed_add_on_sid"], sid=self._solution["sid"], ) - async def fetch_async(self) -> FieldInstance: + async def update_async(self, enabled: bool) -> InstalledAddOnExtensionInstance: """ - Asynchronous coroutine to fetch the FieldInstance + Asynchronous coroutine to update the InstalledAddOnExtensionInstance + :param enabled: Whether the Extension should be invoked. - :returns: The fetched FieldInstance + :returns: The updated InstalledAddOnExtensionInstance """ - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, + data = values.of( + { + "Enabled": serialize.boolean_to_string(enabled), + } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" - return FieldInstance( + payload = await self._version.update_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + return InstalledAddOnExtensionInstance( self._version, payload, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], + installed_add_on_sid=self._solution["installed_add_on_sid"], sid=self._solution["sid"], ) @@ -226,21 +259,23 @@ 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 FieldPage(Page): - def get_instance(self, payload: Dict[str, Any]) -> FieldInstance: +class InstalledAddOnExtensionPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> InstalledAddOnExtensionInstance: """ - Build an instance of FieldInstance + Build an instance of InstalledAddOnExtensionInstance :param payload: Payload response from the API """ - return FieldInstance( + return InstalledAddOnExtensionInstance( self._version, payload, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], + installed_add_on_sid=self._solution["installed_add_on_sid"], ) def __repr__(self) -> str: @@ -249,95 +284,36 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ - return "" + return "" + +class InstalledAddOnExtensionList(ListResource): -class FieldList(ListResource): - def __init__(self, version: Version, assistant_sid: str, task_sid: str): + def __init__(self, version: Version, installed_add_on_sid: str): """ - Initialize the FieldList + Initialize the InstalledAddOnExtensionList :param version: Version that contains the resource - :param assistant_sid: The unique ID of the Assistant. - :param task_sid: The unique ID of the Task associated with this Field. + :param installed_add_on_sid: The SID of the InstalledAddOn resource with the extensions to read. """ super().__init__(version) # Path Solution self._solution = { - "assistant_sid": assistant_sid, - "task_sid": task_sid, + "installed_add_on_sid": installed_add_on_sid, } - self._uri = "/Assistants/{assistant_sid}/Tasks/{task_sid}/Fields".format( + self._uri = "/InstalledAddOns/{installed_add_on_sid}/Extensions".format( **self._solution ) - def create(self, field_type: str, unique_name: str) -> FieldInstance: - """ - Create the FieldInstance - - :param field_type: The unique name or sid of the FieldType. It can be any [Built-in Field Type](https://www.twilio.com/docs/assistant/api/built-in-field-types) or the unique_name or the Field Type sid of a custom Field Type. - :param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - - :returns: The created FieldInstance - """ - data = values.of( - { - "FieldType": field_type, - "UniqueName": unique_name, - } - ) - - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) - - return FieldInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - ) - - async def create_async(self, field_type: str, unique_name: str) -> FieldInstance: - """ - Asynchronously create the FieldInstance - - :param field_type: The unique name or sid of the FieldType. It can be any [Built-in Field Type](https://www.twilio.com/docs/assistant/api/built-in-field-types) or the unique_name or the Field Type sid of a custom Field Type. - :param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - - :returns: The created FieldInstance - """ - data = values.of( - { - "FieldType": field_type, - "UniqueName": unique_name, - } - ) - - payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, - ) - - return FieldInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - ) - def stream( self, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> Iterator[FieldInstance]: + ) -> Iterator[InstalledAddOnExtensionInstance]: """ - Streams FieldInstance records from the API as a generator stream. + 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. @@ -360,9 +336,9 @@ async def stream_async( self, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> AsyncIterator[FieldInstance]: + ) -> AsyncIterator[InstalledAddOnExtensionInstance]: """ - Asynchronously streams FieldInstance records from the API as a generator stream. + 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. @@ -385,9 +361,9 @@ def list( self, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> List[FieldInstance]: + ) -> List[InstalledAddOnExtensionInstance]: """ - Lists FieldInstance records from the API as a list. + Lists InstalledAddOnExtensionInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @@ -411,9 +387,9 @@ async def list_async( self, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> List[FieldInstance]: + ) -> List[InstalledAddOnExtensionInstance]: """ - Asynchronously lists FieldInstance records from the API as a list. + 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. @@ -439,16 +415,16 @@ def page( page_token: Union[str, object] = values.unset, page_number: Union[int, object] = values.unset, page_size: Union[int, object] = values.unset, - ) -> FieldPage: + ) -> InstalledAddOnExtensionPage: """ - Retrieve a single page of FieldInstance records from the API. + 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 FieldInstance + :returns: Page of InstalledAddOnExtensionInstance """ data = values.of( { @@ -458,24 +434,30 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) - return FieldPage(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 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, - ) -> FieldPage: + ) -> InstalledAddOnExtensionPage: """ - Asynchronously retrieve a single page of FieldInstance records from the API. + 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 FieldInstance + :returns: Page of InstalledAddOnExtensionInstance """ data = values.of( { @@ -485,58 +467,60 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) - return FieldPage(self._version, response, self._solution) + return InstalledAddOnExtensionPage(self._version, response, self._solution) - def get_page(self, target_url: str) -> FieldPage: + def get_page(self, target_url: str) -> InstalledAddOnExtensionPage: """ - Retrieve a specific page of FieldInstance records from the API. + 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 FieldInstance + :returns: Page of InstalledAddOnExtensionInstance """ response = self._version.domain.twilio.request("GET", target_url) - return FieldPage(self._version, response, self._solution) + return InstalledAddOnExtensionPage(self._version, response, self._solution) - async def get_page_async(self, target_url: str) -> FieldPage: + async def get_page_async(self, target_url: str) -> InstalledAddOnExtensionPage: """ - Asynchronously retrieve a specific page of FieldInstance records from the API. + 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 FieldInstance + :returns: Page of InstalledAddOnExtensionInstance """ response = await self._version.domain.twilio.request_async("GET", target_url) - return FieldPage(self._version, response, self._solution) + return InstalledAddOnExtensionPage(self._version, response, self._solution) - def get(self, sid: str) -> FieldContext: + def get(self, sid: str) -> InstalledAddOnExtensionContext: """ - Constructs a FieldContext + Constructs a InstalledAddOnExtensionContext - :param sid: A 34 character string that uniquely identifies this resource. + :param sid: The SID of the InstalledAddOn Extension resource to update. """ - return FieldContext( + return InstalledAddOnExtensionContext( self._version, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], + installed_add_on_sid=self._solution["installed_add_on_sid"], sid=sid, ) - def __call__(self, sid: str) -> FieldContext: + def __call__(self, sid: str) -> InstalledAddOnExtensionContext: """ - Constructs a FieldContext + Constructs a InstalledAddOnExtensionContext - :param sid: A 34 character string that uniquely identifies this resource. + :param sid: The SID of the InstalledAddOn Extension resource to update. """ - return FieldContext( + return InstalledAddOnExtensionContext( self._version, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], + installed_add_on_sid=self._solution["installed_add_on_sid"], sid=sid, ) @@ -546,4 +530,4 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ - return "" + 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 cca96fc012..0000000000 --- a/twilio/rest/media/v1/__init__.py +++ /dev/null @@ -1,58 +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 f136619d6c..0000000000 --- a/twilio/rest/media/v1/media_processor.py +++ /dev/null @@ -1,617 +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/api/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/api/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/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/api/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/api/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/api/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/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/api/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/api/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/api/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/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 da0ea616dc..0000000000 --- a/twilio/rest/media/v1/media_recording.py +++ /dev/null @@ -1,551 +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/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 80946e466e..0000000000 --- a/twilio/rest/media/v1/player_streamer/__init__.py +++ /dev/null @@ -1,636 +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 -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/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/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": 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/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": 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 4ea581b474..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 ea6b0dd0a5..e45ed56fcd 100644 --- a/twilio/rest/messaging/MessagingBase.py +++ b/twilio/rest/messaging/MessagingBase.py @@ -14,9 +14,11 @@ 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): + def __init__(self, twilio: Client): """ Initialize the Messaging Domain @@ -25,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: @@ -35,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 159a4422a0..6bd630fbd8 100644 --- a/twilio/rest/messaging/v1/__init__.py +++ b/twilio/rest/messaging/v1/__init__.py @@ -26,12 +26,17 @@ from twilio.rest.messaging.v1.linkshortening_messaging_service import ( LinkshorteningMessagingServiceList, ) +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 class V1(Version): + def __init__(self, domain: Domain): """ Initialize the V1 version of Messaging @@ -50,6 +55,10 @@ def __init__(self, domain: Domain): self._linkshortening_messaging_service: Optional[ LinkshorteningMessagingServiceList ] = None + 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 @@ -100,6 +109,22 @@ def linkshortening_messaging_service(self) -> LinkshorteningMessagingServiceList ) return self._linkshortening_messaging_service + @property + def linkshortening_messaging_service_domain_association( + self, + ) -> LinkshorteningMessagingServiceDomainAssociationList: + if self._linkshortening_messaging_service_domain_association is None: + self._linkshortening_messaging_service_domain_association = ( + LinkshorteningMessagingServiceDomainAssociationList(self) + ) + 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 68a669e3ce..939cba604c 100644 --- a/twilio/rest/messaging/v1/brand_registration/__init__.py +++ b/twilio/rest/messaging/v1/brand_registration/__init__.py @@ -12,10 +12,9 @@ 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 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 @@ -28,6 +27,7 @@ class BrandRegistrationInstance(InstanceResource): + class BrandFeedback(object): TAX_ID = "TAX_ID" STOCK_SYMBOL = "STOCK_SYMBOL" @@ -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. @@ -58,10 +60,11 @@ class Status(object): :ivar brand_type: Type of brand. One of: \"STANDARD\", \"SOLE_PROPRIETOR\". SOLE_PROPRIETOR is for the low volume, SOLE_PROPRIETOR campaign use case. There can only be one SOLE_PROPRIETOR campaign created per SOLE_PROPRIETOR brand. STANDARD is for all other campaign use cases. Multiple campaign use cases can be created per STANDARD brand. :ivar status: :ivar tcr_id: Campaign Registry (TCR) Brand ID. Assigned only after successful brand registration. - :ivar failure_reason: A reason why brand registration has failed. Only applicable when status is FAILED. + :ivar failure_reason: DEPRECATED. A reason why brand registration has failed. Only applicable when status is FAILED. + :ivar errors: A list of errors that occurred during the brand registration process. :ivar url: The absolute URL of the Brand Registration resource. :ivar brand_score: The secondary vetting score if it was done. Otherwise, it will be the brand score if it's returned from TCR. It may be null if no score is available. - :ivar brand_feedback: Feedback on how to improve brand score + :ivar brand_feedback: DEPRECATED. Feedback on how to improve brand score :ivar identity_status: :ivar russell_3000: Publicly traded company identified in the Russell 3000 Index :ivar government_entity: Identified as a government entity @@ -96,6 +99,7 @@ def __init__( ) self.tcr_id: Optional[str] = payload.get("tcr_id") self.failure_reason: Optional[str] = payload.get("failure_reason") + self.errors: Optional[List[Dict[str, object]]] = payload.get("errors") self.url: Optional[str] = payload.get("url") self.brand_score: Optional[int] = deserialize.integer( payload.get("brand_score") @@ -103,9 +107,9 @@ def __init__( self.brand_feedback: Optional[ List["BrandRegistrationInstance.BrandFeedback"] ] = payload.get("brand_feedback") - self.identity_status: Optional[ - "BrandRegistrationInstance.IdentityStatus" - ] = payload.get("identity_status") + self.identity_status: Optional["BrandRegistrationInstance.IdentityStatus"] = ( + payload.get("identity_status") + ) self.russell_3000: Optional[bool] = payload.get("russell_3000") self.government_entity: Optional[bool] = payload.get("government_entity") self.tax_exempt_status: Optional[str] = payload.get("tax_exempt_status") @@ -196,6 +200,7 @@ def __repr__(self) -> str: class BrandRegistrationContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the BrandRegistrationContext @@ -222,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, @@ -241,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( @@ -259,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( @@ -278,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( @@ -325,6 +338,7 @@ def __repr__(self) -> str: class BrandRegistrationPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> BrandRegistrationInstance: """ Build an instance of BrandRegistrationInstance @@ -343,6 +357,7 @@ def __repr__(self) -> str: class BrandRegistrationList(ListResource): + def __init__(self, version: Version): """ Initialize the BrandRegistrationList @@ -373,20 +388,26 @@ def create( :returns: The created BrandRegistrationInstance """ + data = values.of( { "CustomerProfileBundleSid": customer_profile_bundle_sid, "A2PProfileBundleSid": a2p_profile_bundle_sid, "BrandType": brand_type, - "Mock": mock, - "SkipAutomaticSecVet": skip_automatic_sec_vet, + "Mock": serialize.boolean_to_string(mock), + "SkipAutomaticSecVet": serialize.boolean_to_string( + skip_automatic_sec_vet + ), } ) + 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) @@ -410,20 +431,26 @@ async def create_async( :returns: The created BrandRegistrationInstance """ + data = values.of( { "CustomerProfileBundleSid": customer_profile_bundle_sid, "A2PProfileBundleSid": a2p_profile_bundle_sid, "BrandType": brand_type, - "Mock": mock, - "SkipAutomaticSecVet": skip_automatic_sec_vet, + "Mock": serialize.boolean_to_string(mock), + "SkipAutomaticSecVet": serialize.boolean_to_string( + skip_automatic_sec_vet + ), } ) + 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) @@ -555,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( @@ -582,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 3cc7d364bb..415dec9589 100644 --- a/twilio/rest/messaging/v1/brand_registration/brand_registration_otp.py +++ b/twilio/rest/messaging/v1/brand_registration/brand_registration_otp.py @@ -12,8 +12,8 @@ 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 @@ -21,7 +21,6 @@ class BrandRegistrationOtpInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Brand Registration resource. :ivar brand_registration_sid: The unique string to identify Brand Registration of Sole Proprietor Brand @@ -52,6 +51,7 @@ def __repr__(self) -> str: class BrandRegistrationOtpList(ListResource): + def __init__(self, version: Version, brand_registration_sid: str): """ Initialize the BrandRegistrationOtpList @@ -78,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, @@ -97,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 2fff9ebbed..b633144a71 100644 --- a/twilio/rest/messaging/v1/brand_registration/brand_vetting.py +++ b/twilio/rest/messaging/v1/brand_registration/brand_vetting.py @@ -12,7 +12,6 @@ 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 @@ -24,8 +23,10 @@ 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. @@ -61,9 +62,9 @@ def __init__( self.vetting_id: Optional[str] = payload.get("vetting_id") self.vetting_class: Optional[str] = payload.get("vetting_class") self.vetting_status: Optional[str] = payload.get("vetting_status") - self.vetting_provider: Optional[ - "BrandVettingInstance.VettingProvider" - ] = payload.get("vetting_provider") + self.vetting_provider: Optional["BrandVettingInstance.VettingProvider"] = ( + payload.get("vetting_provider") + ) self.url: Optional[str] = payload.get("url") self._solution = { @@ -117,6 +118,7 @@ def __repr__(self) -> str: class BrandVettingContext(InstanceContext): + def __init__(self, version: Version, brand_sid: str, brand_vetting_sid: str): """ Initialize the BrandVettingContext @@ -146,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, @@ -166,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( @@ -189,6 +195,7 @@ def __repr__(self) -> str: class BrandVettingPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> BrandVettingInstance: """ Build an instance of BrandVettingInstance @@ -209,6 +216,7 @@ def __repr__(self) -> str: class BrandVettingList(ListResource): + def __init__(self, version: Version, brand_sid: str): """ Initialize the BrandVettingList @@ -240,17 +248,21 @@ def create( :returns: The created BrandVettingInstance """ + data = values.of( { "VettingProvider": vetting_provider, "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( @@ -270,17 +282,21 @@ async def create_async( :returns: The created BrandVettingInstance """ + data = values.of( { "VettingProvider": vetting_provider, "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( @@ -441,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( @@ -473,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 972ee62e30..e2cbf17a94 100644 --- a/twilio/rest/messaging/v1/deactivations.py +++ b/twilio/rest/messaging/v1/deactivations.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import date from typing import Any, Dict, Optional, Union from twilio.base import serialize, values @@ -23,7 +22,6 @@ class DeactivationsInstance(InstanceResource): - """ :ivar redirect_to: Returns an authenticated url that redirects to a file containing the deactivated numbers for the requested day. This url is valid for up to two minutes. """ @@ -88,6 +86,7 @@ def __repr__(self) -> str: class DeactivationsContext(InstanceContext): + def __init__(self, version: Version): """ Initialize the DeactivationsContext @@ -113,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, @@ -137,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( @@ -157,6 +166,7 @@ def __repr__(self) -> str: class DeactivationsList(ListResource): + def __init__(self, version: Version): """ Initialize the DeactivationsList diff --git a/twilio/rest/messaging/v1/domain_certs.py b/twilio/rest/messaging/v1/domain_certs.py index 71ef3105bc..6da256cdb0 100644 --- a/twilio/rest/messaging/v1/domain_certs.py +++ b/twilio/rest/messaging/v1/domain_certs.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import datetime from typing import Any, Dict, Optional from twilio.base import deserialize, values @@ -23,7 +22,6 @@ class DomainCertsInstance(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. @@ -151,6 +149,7 @@ def __repr__(self) -> str: class DomainCertsContext(InstanceContext): + def __init__(self, version: Version, domain_sid: str): """ Initialize the DomainCertsContext @@ -175,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: """ @@ -187,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: @@ -200,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, @@ -219,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( @@ -238,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( @@ -262,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( @@ -289,6 +302,7 @@ def __repr__(self) -> str: class DomainCertsList(ListResource): + def __init__(self, version: Version): """ Initialize the DomainCertsList diff --git a/twilio/rest/messaging/v1/domain_config.py b/twilio/rest/messaging/v1/domain_config.py index af4d28771e..ed70351077 100644 --- a/twilio/rest/messaging/v1/domain_config.py +++ b/twilio/rest/messaging/v1/domain_config.py @@ -12,9 +12,8 @@ Do not edit the class manually. """ - from datetime import datetime -from typing import Any, Dict, List, Optional, Union +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 @@ -23,16 +22,16 @@ class DomainConfigInstance(InstanceResource): - """ :ivar domain_sid: The unique string that we created to identify the Domain resource. :ivar config_sid: The unique string that we created to identify the Domain config (prefix ZK). - :ivar messaging_service_sids: A list of messagingServiceSids (with prefix MG). :ivar fallback_url: Any requests we receive to this domain that do not match an existing shortened message will be redirected to the fallback url. These will likely be either expired messages, random misdirected traffic, or intentional scraping. :ivar callback_url: URL to receive click events to your webhook whenever the recipients click on the shortened links. + :ivar continue_on_failure: Boolean field to set customer delivery preference when there is a failure in linkShortening service :ivar date_created: Date this Domain Config was created. :ivar date_updated: Date that this Domain Config was last updated. :ivar url: + :ivar disable_https: Customer's choice to send links with/without \"https://\" attached to shortened url. If true, messages will not be sent with https:// at the beginning of the url. If false, messages will be sent with https:// at the beginning of the url. False is the default behavior if it is not specified. """ def __init__( @@ -45,11 +44,9 @@ def __init__( self.domain_sid: Optional[str] = payload.get("domain_sid") self.config_sid: Optional[str] = payload.get("config_sid") - self.messaging_service_sids: Optional[List[str]] = payload.get( - "messaging_service_sids" - ) self.fallback_url: Optional[str] = payload.get("fallback_url") self.callback_url: Optional[str] = payload.get("callback_url") + self.continue_on_failure: Optional[bool] = payload.get("continue_on_failure") self.date_created: Optional[datetime] = deserialize.iso8601_datetime( payload.get("date_created") ) @@ -57,6 +54,7 @@ def __init__( payload.get("date_updated") ) self.url: Optional[str] = payload.get("url") + self.disable_https: Optional[bool] = payload.get("disable_https") self._solution = { "domain_sid": domain_sid or self.domain_sid, @@ -98,50 +96,50 @@ async def fetch_async(self) -> "DomainConfigInstance": def update( self, - messaging_service_sids: List[str], fallback_url: Union[str, object] = values.unset, callback_url: Union[str, object] = values.unset, - messaging_service_sids_action: Union[str, object] = values.unset, + continue_on_failure: Union[bool, object] = values.unset, + disable_https: Union[bool, object] = values.unset, ) -> "DomainConfigInstance": """ Update the DomainConfigInstance - :param messaging_service_sids: A list of messagingServiceSids (with prefix MG) :param fallback_url: Any requests we receive to this domain that do not match an existing shortened message will be redirected to the fallback url. These will likely be either expired messages, random misdirected traffic, or intentional scraping. :param callback_url: URL to receive click events to your webhook whenever the recipients click on the shortened links - :param messaging_service_sids_action: An action type for messaging_service_sids operation (ADD, DELETE, REPLACE) + :param continue_on_failure: Boolean field to set customer delivery preference when there is a failure in linkShortening service + :param disable_https: Customer's choice to send links with/without \\\"https://\\\" attached to shortened url. If true, messages will not be sent with https:// at the beginning of the url. If false, messages will be sent with https:// at the beginning of the url. False is the default behavior if it is not specified. :returns: The updated DomainConfigInstance """ return self._proxy.update( - messaging_service_sids=messaging_service_sids, fallback_url=fallback_url, callback_url=callback_url, - messaging_service_sids_action=messaging_service_sids_action, + continue_on_failure=continue_on_failure, + disable_https=disable_https, ) async def update_async( self, - messaging_service_sids: List[str], fallback_url: Union[str, object] = values.unset, callback_url: Union[str, object] = values.unset, - messaging_service_sids_action: Union[str, object] = values.unset, + continue_on_failure: Union[bool, object] = values.unset, + disable_https: Union[bool, object] = values.unset, ) -> "DomainConfigInstance": """ Asynchronous coroutine to update the DomainConfigInstance - :param messaging_service_sids: A list of messagingServiceSids (with prefix MG) :param fallback_url: Any requests we receive to this domain that do not match an existing shortened message will be redirected to the fallback url. These will likely be either expired messages, random misdirected traffic, or intentional scraping. :param callback_url: URL to receive click events to your webhook whenever the recipients click on the shortened links - :param messaging_service_sids_action: An action type for messaging_service_sids operation (ADD, DELETE, REPLACE) + :param continue_on_failure: Boolean field to set customer delivery preference when there is a failure in linkShortening service + :param disable_https: Customer's choice to send links with/without \\\"https://\\\" attached to shortened url. If true, messages will not be sent with https:// at the beginning of the url. If false, messages will be sent with https:// at the beginning of the url. False is the default behavior if it is not specified. :returns: The updated DomainConfigInstance """ return await self._proxy.update_async( - messaging_service_sids=messaging_service_sids, fallback_url=fallback_url, callback_url=callback_url, - messaging_service_sids_action=messaging_service_sids_action, + continue_on_failure=continue_on_failure, + disable_https=disable_https, ) def __repr__(self) -> str: @@ -155,6 +153,7 @@ def __repr__(self) -> str: class DomainConfigContext(InstanceContext): + def __init__(self, version: Version, domain_sid: str): """ Initialize the DomainConfigContext @@ -180,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, @@ -199,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( @@ -212,36 +215,38 @@ async def fetch_async(self) -> DomainConfigInstance: def update( self, - messaging_service_sids: List[str], fallback_url: Union[str, object] = values.unset, callback_url: Union[str, object] = values.unset, - messaging_service_sids_action: Union[str, object] = values.unset, + continue_on_failure: Union[bool, object] = values.unset, + disable_https: Union[bool, object] = values.unset, ) -> DomainConfigInstance: """ Update the DomainConfigInstance - :param messaging_service_sids: A list of messagingServiceSids (with prefix MG) :param fallback_url: Any requests we receive to this domain that do not match an existing shortened message will be redirected to the fallback url. These will likely be either expired messages, random misdirected traffic, or intentional scraping. :param callback_url: URL to receive click events to your webhook whenever the recipients click on the shortened links - :param messaging_service_sids_action: An action type for messaging_service_sids operation (ADD, DELETE, REPLACE) + :param continue_on_failure: Boolean field to set customer delivery preference when there is a failure in linkShortening service + :param disable_https: Customer's choice to send links with/without \\\"https://\\\" attached to shortened url. If true, messages will not be sent with https:// at the beginning of the url. If false, messages will be sent with https:// at the beginning of the url. False is the default behavior if it is not specified. :returns: The updated DomainConfigInstance """ + data = values.of( { - "MessagingServiceSids": serialize.map( - messaging_service_sids, lambda e: e - ), "FallbackUrl": fallback_url, "CallbackUrl": callback_url, - "MessagingServiceSidsAction": messaging_service_sids_action, + "ContinueOnFailure": serialize.boolean_to_string(continue_on_failure), + "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( @@ -250,36 +255,38 @@ def update( async def update_async( self, - messaging_service_sids: List[str], fallback_url: Union[str, object] = values.unset, callback_url: Union[str, object] = values.unset, - messaging_service_sids_action: Union[str, object] = values.unset, + continue_on_failure: Union[bool, object] = values.unset, + disable_https: Union[bool, object] = values.unset, ) -> DomainConfigInstance: """ Asynchronous coroutine to update the DomainConfigInstance - :param messaging_service_sids: A list of messagingServiceSids (with prefix MG) :param fallback_url: Any requests we receive to this domain that do not match an existing shortened message will be redirected to the fallback url. These will likely be either expired messages, random misdirected traffic, or intentional scraping. :param callback_url: URL to receive click events to your webhook whenever the recipients click on the shortened links - :param messaging_service_sids_action: An action type for messaging_service_sids operation (ADD, DELETE, REPLACE) + :param continue_on_failure: Boolean field to set customer delivery preference when there is a failure in linkShortening service + :param disable_https: Customer's choice to send links with/without \\\"https://\\\" attached to shortened url. If true, messages will not be sent with https:// at the beginning of the url. If false, messages will be sent with https:// at the beginning of the url. False is the default behavior if it is not specified. :returns: The updated DomainConfigInstance """ + data = values.of( { - "MessagingServiceSids": serialize.map( - messaging_service_sids, lambda e: e - ), "FallbackUrl": fallback_url, "CallbackUrl": callback_url, - "MessagingServiceSidsAction": messaging_service_sids_action, + "ContinueOnFailure": serialize.boolean_to_string(continue_on_failure), + "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( @@ -297,6 +304,7 @@ def __repr__(self) -> str: class DomainConfigList(ListResource): + def __init__(self, version: Version): """ Initialize the DomainConfigList diff --git a/twilio/rest/messaging/v1/domain_config_messaging_service.py b/twilio/rest/messaging/v1/domain_config_messaging_service.py index 6e5866900b..2bcd4aa88c 100644 --- a/twilio/rest/messaging/v1/domain_config_messaging_service.py +++ b/twilio/rest/messaging/v1/domain_config_messaging_service.py @@ -12,10 +12,9 @@ Do not edit the class manually. """ - 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 @@ -23,13 +22,13 @@ class DomainConfigMessagingServiceInstance(InstanceResource): - """ :ivar domain_sid: The unique string that we created to identify the Domain resource. :ivar config_sid: The unique string that we created to identify the Domain config (prefix ZK). :ivar messaging_service_sid: The unique string that identifies the messaging service :ivar fallback_url: Any requests we receive to this domain that do not match an existing shortened message will be redirected to the fallback url. These will likely be either expired messages, random misdirected traffic, or intentional scraping. :ivar callback_url: URL to receive click events to your webhook whenever the recipients click on the shortened links. + :ivar continue_on_failure: Boolean field to set customer delivery preference when there is a failure in linkShortening service :ivar date_created: Date this Domain Config was created. :ivar date_updated: Date that this Domain Config was last updated. :ivar url: @@ -48,6 +47,7 @@ def __init__( self.messaging_service_sid: Optional[str] = payload.get("messaging_service_sid") self.fallback_url: Optional[str] = payload.get("fallback_url") self.callback_url: Optional[str] = payload.get("callback_url") + self.continue_on_failure: Optional[bool] = payload.get("continue_on_failure") self.date_created: Optional[datetime] = deserialize.iso8601_datetime( payload.get("date_created") ) @@ -108,6 +108,7 @@ def __repr__(self) -> str: class DomainConfigMessagingServiceContext(InstanceContext): + def __init__(self, version: Version, messaging_service_sid: str): """ Initialize the DomainConfigMessagingServiceContext @@ -133,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, @@ -152,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( @@ -176,6 +181,7 @@ def __repr__(self) -> str: class DomainConfigMessagingServiceList(ListResource): + def __init__(self, version: Version): """ Initialize the DomainConfigMessagingServiceList diff --git a/twilio/rest/messaging/v1/external_campaign.py b/twilio/rest/messaging/v1/external_campaign.py index dd1890644b..eed039a6cc 100644 --- a/twilio/rest/messaging/v1/external_campaign.py +++ b/twilio/rest/messaging/v1/external_campaign.py @@ -12,10 +12,9 @@ Do not edit the class manually. """ - 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 @@ -23,12 +22,11 @@ class ExternalCampaignInstance(InstanceResource): - """ :ivar sid: The unique string that identifies a US A2P Compliance resource `QE2c6890da8086d771620e9b13fadeba0b`. :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that the Campaign belongs to. :ivar campaign_id: ID of the preregistered campaign. - :ivar messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/services/api) that the resource is associated with. + :ivar messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) that 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. """ @@ -54,6 +52,7 @@ def __repr__(self) -> str: class ExternalCampaignList(ListResource): + def __init__(self, version: Version): """ Initialize the ExternalCampaignList @@ -66,53 +65,71 @@ 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/services/api) that the resource is associated with. + :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 """ + data = values.of( { "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/services/api) that the resource is associated with. + :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 """ + data = values.of( { "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 c5b20e28a5..ac69842a0c 100644 --- a/twilio/rest/messaging/v1/linkshortening_messaging_service.py +++ b/twilio/rest/messaging/v1/linkshortening_messaging_service.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, Optional from twilio.base import values from twilio.base.instance_context import InstanceContext @@ -22,7 +21,6 @@ class LinkshorteningMessagingServiceInstance(InstanceResource): - """ :ivar domain_sid: The unique string identifies the domain resource :ivar messaging_service_sid: The unique string that identifies the messaging service @@ -114,6 +112,7 @@ def __repr__(self) -> str: class LinkshorteningMessagingServiceContext(InstanceContext): + def __init__(self, version: Version, domain_sid: str, messaging_service_sid: str): """ Initialize the LinkshorteningMessagingServiceContext @@ -178,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: """ @@ -190,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: @@ -208,6 +209,7 @@ def __repr__(self) -> str: class LinkshorteningMessagingServiceList(ListResource): + def __init__(self, version: Version): """ Initialize the LinkshorteningMessagingServiceList diff --git a/twilio/rest/messaging/v1/linkshortening_messaging_service_domain_association.py b/twilio/rest/messaging/v1/linkshortening_messaging_service_domain_association.py new file mode 100644 index 0000000000..4c0b52bddf --- /dev/null +++ b/twilio/rest/messaging/v1/linkshortening_messaging_service_domain_association.py @@ -0,0 +1,217 @@ +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, 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 LinkshorteningMessagingServiceDomainAssociationInstance(InstanceResource): + """ + :ivar domain_sid: The unique string that we created to identify the Domain resource. + :ivar messaging_service_sid: The unique string that identifies the messaging service + :ivar url: + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + messaging_service_sid: Optional[str] = None, + ): + super().__init__(version) + + self.domain_sid: Optional[str] = payload.get("domain_sid") + self.messaging_service_sid: Optional[str] = payload.get("messaging_service_sid") + self.url: Optional[str] = payload.get("url") + + self._solution = { + "messaging_service_sid": messaging_service_sid + or self.messaging_service_sid, + } + self._context: Optional[ + LinkshorteningMessagingServiceDomainAssociationContext + ] = None + + @property + def _proxy(self) -> "LinkshorteningMessagingServiceDomainAssociationContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: LinkshorteningMessagingServiceDomainAssociationContext for this LinkshorteningMessagingServiceDomainAssociationInstance + """ + if self._context is None: + self._context = LinkshorteningMessagingServiceDomainAssociationContext( + self._version, + messaging_service_sid=self._solution["messaging_service_sid"], + ) + return self._context + + def fetch(self) -> "LinkshorteningMessagingServiceDomainAssociationInstance": + """ + Fetch the LinkshorteningMessagingServiceDomainAssociationInstance + + + :returns: The fetched LinkshorteningMessagingServiceDomainAssociationInstance + """ + return self._proxy.fetch() + + async def fetch_async( + self, + ) -> "LinkshorteningMessagingServiceDomainAssociationInstance": + """ + Asynchronous coroutine to fetch the LinkshorteningMessagingServiceDomainAssociationInstance + + + :returns: The fetched LinkshorteningMessagingServiceDomainAssociationInstance + """ + 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 LinkshorteningMessagingServiceDomainAssociationContext(InstanceContext): + + def __init__(self, version: Version, messaging_service_sid: str): + """ + Initialize the LinkshorteningMessagingServiceDomainAssociationContext + + :param version: Version that contains the resource + :param messaging_service_sid: Unique string used to identify the Messaging service that this domain should be associated with. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "messaging_service_sid": messaging_service_sid, + } + self._uri = ( + "/LinkShortening/MessagingServices/{messaging_service_sid}/Domain".format( + **self._solution + ) + ) + + def fetch(self) -> LinkshorteningMessagingServiceDomainAssociationInstance: + """ + Fetch the LinkshorteningMessagingServiceDomainAssociationInstance + + + :returns: The fetched LinkshorteningMessagingServiceDomainAssociationInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return LinkshorteningMessagingServiceDomainAssociationInstance( + self._version, + payload, + messaging_service_sid=self._solution["messaging_service_sid"], + ) + + async def fetch_async( + self, + ) -> LinkshorteningMessagingServiceDomainAssociationInstance: + """ + Asynchronous coroutine to fetch the LinkshorteningMessagingServiceDomainAssociationInstance + + + :returns: The fetched LinkshorteningMessagingServiceDomainAssociationInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + return LinkshorteningMessagingServiceDomainAssociationInstance( + self._version, + payload, + messaging_service_sid=self._solution["messaging_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 LinkshorteningMessagingServiceDomainAssociationList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the LinkshorteningMessagingServiceDomainAssociationList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + def get( + self, messaging_service_sid: str + ) -> LinkshorteningMessagingServiceDomainAssociationContext: + """ + Constructs a LinkshorteningMessagingServiceDomainAssociationContext + + :param messaging_service_sid: Unique string used to identify the Messaging service that this domain should be associated with. + """ + return LinkshorteningMessagingServiceDomainAssociationContext( + self._version, messaging_service_sid=messaging_service_sid + ) + + def __call__( + self, messaging_service_sid: str + ) -> LinkshorteningMessagingServiceDomainAssociationContext: + """ + Constructs a LinkshorteningMessagingServiceDomainAssociationContext + + :param messaging_service_sid: Unique string used to identify the Messaging service that this domain should be associated with. + """ + return LinkshorteningMessagingServiceDomainAssociationContext( + self._version, messaging_service_sid=messaging_service_sid + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return ( + "" + ) 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 73ee02bb33..78a2b83015 100644 --- a/twilio/rest/messaging/v1/service/__init__.py +++ b/twilio/rest/messaging/v1/service/__init__.py @@ -12,16 +12,19 @@ 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 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.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 @@ -31,6 +34,7 @@ class ServiceInstance(InstanceResource): + class ScanMessageContent(object): INHERIT = "inherit" ENABLE = "enable" @@ -47,17 +51,17 @@ class ScanMessageContent(object): :ivar fallback_url: The URL that we call using `fallback_method` if an error occurs while retrieving or executing the TwiML from the Inbound Request URL. If the `use_inbound_webhook_on_number` field is enabled then the webhook url defined on the phone number will override the `fallback_url` defined for the Messaging Service. :ivar fallback_method: The HTTP method we use to call `fallback_url`. Can be: `GET` or `POST`. :ivar status_callback: The URL we call to [pass status updates](https://www.twilio.com/docs/sms/api/message-resource#message-status-values) about message delivery. - :ivar sticky_sender: Whether to enable [Sticky Sender](https://www.twilio.com/docs/sms/services#sticky-sender) on the Service instance. - :ivar mms_converter: Whether to enable the [MMS Converter](https://www.twilio.com/docs/sms/services#mms-converter) for messages sent through the Service instance. - :ivar smart_encoding: Whether to enable [Smart Encoding](https://www.twilio.com/docs/sms/services#smart-encoding) for messages sent through the Service instance. + :ivar sticky_sender: Whether to enable [Sticky Sender](https://www.twilio.com/docs/messaging/services#sticky-sender) on the Service instance. + :ivar mms_converter: Whether to enable the [MMS Converter](https://www.twilio.com/docs/messaging/services#mms-converter) for messages sent through the Service instance. + :ivar smart_encoding: Whether to enable [Smart Encoding](https://www.twilio.com/docs/messaging/services#smart-encoding) for messages sent through the Service instance. :ivar scan_message_content: - :ivar fallback_to_long_code: Whether to enable [Fallback to Long Code](https://www.twilio.com/docs/sms/services#fallback-to-long-code) for messages sent through the Service instance. - :ivar area_code_geomatch: Whether to enable [Area Code Geomatch](https://www.twilio.com/docs/sms/services#area-code-geomatch) on the Service Instance. + :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 `36,000`. Default value is `36,000`. :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. Examples: [notification, marketing, verification, poll ..] + :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`. :ivar us_app_to_person_registered: Whether US A2P campaign is registered for this Service. :ivar 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. """ @@ -84,9 +88,9 @@ def __init__( self.sticky_sender: Optional[bool] = payload.get("sticky_sender") self.mms_converter: Optional[bool] = payload.get("mms_converter") self.smart_encoding: Optional[bool] = payload.get("smart_encoding") - self.scan_message_content: Optional[ - "ServiceInstance.ScanMessageContent" - ] = payload.get("scan_message_content") + self.scan_message_content: Optional["ServiceInstance.ScanMessageContent"] = ( + payload.get("scan_message_content") + ) self.fallback_to_long_code: Optional[bool] = payload.get( "fallback_to_long_code" ) @@ -193,15 +197,15 @@ def update( :param fallback_url: The URL that we call using `fallback_method` if an error occurs while retrieving or executing the TwiML from the Inbound Request URL. If the `use_inbound_webhook_on_number` field is enabled then the webhook url defined on the phone number will override the `fallback_url` defined for the Messaging Service. :param fallback_method: The HTTP method we should use to call `fallback_url`. Can be: `GET` or `POST`. :param status_callback: The URL we should call to [pass status updates](https://www.twilio.com/docs/sms/api/message-resource#message-status-values) about message delivery. - :param sticky_sender: Whether to enable [Sticky Sender](https://www.twilio.com/docs/sms/services#sticky-sender) on the Service instance. - :param mms_converter: Whether to enable the [MMS Converter](https://www.twilio.com/docs/sms/services#mms-converter) for messages sent through the Service instance. - :param smart_encoding: Whether to enable [Smart Encoding](https://www.twilio.com/docs/sms/services#smart-encoding) for messages sent through the Service instance. + :param sticky_sender: Whether to enable [Sticky Sender](https://www.twilio.com/docs/messaging/services#sticky-sender) on the Service instance. + :param mms_converter: Whether to enable the [MMS Converter](https://www.twilio.com/docs/messaging/services#mms-converter) for messages sent through the Service instance. + :param smart_encoding: Whether to enable [Smart Encoding](https://www.twilio.com/docs/messaging/services#smart-encoding) for messages sent through the Service instance. :param scan_message_content: - :param fallback_to_long_code: Whether to enable [Fallback to Long Code](https://www.twilio.com/docs/sms/services#fallback-to-long-code) for messages sent through the Service instance. - :param area_code_geomatch: Whether to enable [Area Code Geomatch](https://www.twilio.com/docs/sms/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 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 `36,000`. Default value is `36,000`. :param synchronous_validation: Reserved. - :param usecase: A string that describes the scenario in which the Messaging Service will be used. Examples: [notification, marketing, verification, poll ..] + :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 @@ -255,15 +259,15 @@ async def update_async( :param fallback_url: The URL that we call using `fallback_method` if an error occurs while retrieving or executing the TwiML from the Inbound Request URL. If the `use_inbound_webhook_on_number` field is enabled then the webhook url defined on the phone number will override the `fallback_url` defined for the Messaging Service. :param fallback_method: The HTTP method we should use to call `fallback_url`. Can be: `GET` or `POST`. :param status_callback: The URL we should call to [pass status updates](https://www.twilio.com/docs/sms/api/message-resource#message-status-values) about message delivery. - :param sticky_sender: Whether to enable [Sticky Sender](https://www.twilio.com/docs/sms/services#sticky-sender) on the Service instance. - :param mms_converter: Whether to enable the [MMS Converter](https://www.twilio.com/docs/sms/services#mms-converter) for messages sent through the Service instance. - :param smart_encoding: Whether to enable [Smart Encoding](https://www.twilio.com/docs/sms/services#smart-encoding) for messages sent through the Service instance. + :param sticky_sender: Whether to enable [Sticky Sender](https://www.twilio.com/docs/messaging/services#sticky-sender) on the Service instance. + :param mms_converter: Whether to enable the [MMS Converter](https://www.twilio.com/docs/messaging/services#mms-converter) for messages sent through the Service instance. + :param smart_encoding: Whether to enable [Smart Encoding](https://www.twilio.com/docs/messaging/services#smart-encoding) for messages sent through the Service instance. :param scan_message_content: - :param fallback_to_long_code: Whether to enable [Fallback to Long Code](https://www.twilio.com/docs/sms/services#fallback-to-long-code) for messages sent through the Service instance. - :param area_code_geomatch: Whether to enable [Area Code Geomatch](https://www.twilio.com/docs/sms/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 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 `36,000`. Default value is `36,000`. :param synchronous_validation: Reserved. - :param usecase: A string that describes the scenario in which the Messaging Service will be used. Examples: [notification, marketing, verification, poll ..] + :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 @@ -294,6 +298,20 @@ def alpha_senders(self) -> AlphaSenderList: """ return self._proxy.alpha_senders + @property + def channel_senders(self) -> ChannelSenderList: + """ + Access the channel_senders + """ + 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: """ @@ -333,6 +351,7 @@ def __repr__(self) -> str: class ServiceContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the ServiceContext @@ -349,6 +368,8 @@ def __init__(self, version: Version, sid: str): self._uri = "/Services/{sid}".format(**self._solution) 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 @@ -361,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: """ @@ -373,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: @@ -386,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, @@ -405,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( @@ -446,19 +473,20 @@ def update( :param fallback_url: The URL that we call using `fallback_method` if an error occurs while retrieving or executing the TwiML from the Inbound Request URL. If the `use_inbound_webhook_on_number` field is enabled then the webhook url defined on the phone number will override the `fallback_url` defined for the Messaging Service. :param fallback_method: The HTTP method we should use to call `fallback_url`. Can be: `GET` or `POST`. :param status_callback: The URL we should call to [pass status updates](https://www.twilio.com/docs/sms/api/message-resource#message-status-values) about message delivery. - :param sticky_sender: Whether to enable [Sticky Sender](https://www.twilio.com/docs/sms/services#sticky-sender) on the Service instance. - :param mms_converter: Whether to enable the [MMS Converter](https://www.twilio.com/docs/sms/services#mms-converter) for messages sent through the Service instance. - :param smart_encoding: Whether to enable [Smart Encoding](https://www.twilio.com/docs/sms/services#smart-encoding) for messages sent through the Service instance. + :param sticky_sender: Whether to enable [Sticky Sender](https://www.twilio.com/docs/messaging/services#sticky-sender) on the Service instance. + :param mms_converter: Whether to enable the [MMS Converter](https://www.twilio.com/docs/messaging/services#mms-converter) for messages sent through the Service instance. + :param smart_encoding: Whether to enable [Smart Encoding](https://www.twilio.com/docs/messaging/services#smart-encoding) for messages sent through the Service instance. :param scan_message_content: - :param fallback_to_long_code: Whether to enable [Fallback to Long Code](https://www.twilio.com/docs/sms/services#fallback-to-long-code) for messages sent through the Service instance. - :param area_code_geomatch: Whether to enable [Area Code Geomatch](https://www.twilio.com/docs/sms/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 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 `36,000`. Default value is `36,000`. :param synchronous_validation: Reserved. - :param usecase: A string that describes the scenario in which the Messaging Service will be used. Examples: [notification, marketing, verification, poll ..] + :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, @@ -467,23 +495,32 @@ def update( "FallbackUrl": fallback_url, "FallbackMethod": fallback_method, "StatusCallback": status_callback, - "StickySender": sticky_sender, - "MmsConverter": mms_converter, - "SmartEncoding": smart_encoding, + "StickySender": serialize.boolean_to_string(sticky_sender), + "MmsConverter": serialize.boolean_to_string(mms_converter), + "SmartEncoding": serialize.boolean_to_string(smart_encoding), "ScanMessageContent": scan_message_content, - "FallbackToLongCode": fallback_to_long_code, - "AreaCodeGeomatch": area_code_geomatch, + "FallbackToLongCode": serialize.boolean_to_string( + fallback_to_long_code + ), + "AreaCodeGeomatch": serialize.boolean_to_string(area_code_geomatch), "ValidityPeriod": validity_period, - "SynchronousValidation": synchronous_validation, + "SynchronousValidation": serialize.boolean_to_string( + synchronous_validation + ), "Usecase": usecase, - "UseInboundWebhookOnNumber": use_inbound_webhook_on_number, + "UseInboundWebhookOnNumber": serialize.boolean_to_string( + use_inbound_webhook_on_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 ServiceInstance(self._version, payload, sid=self._solution["sid"]) @@ -518,19 +555,20 @@ async def update_async( :param fallback_url: The URL that we call using `fallback_method` if an error occurs while retrieving or executing the TwiML from the Inbound Request URL. If the `use_inbound_webhook_on_number` field is enabled then the webhook url defined on the phone number will override the `fallback_url` defined for the Messaging Service. :param fallback_method: The HTTP method we should use to call `fallback_url`. Can be: `GET` or `POST`. :param status_callback: The URL we should call to [pass status updates](https://www.twilio.com/docs/sms/api/message-resource#message-status-values) about message delivery. - :param sticky_sender: Whether to enable [Sticky Sender](https://www.twilio.com/docs/sms/services#sticky-sender) on the Service instance. - :param mms_converter: Whether to enable the [MMS Converter](https://www.twilio.com/docs/sms/services#mms-converter) for messages sent through the Service instance. - :param smart_encoding: Whether to enable [Smart Encoding](https://www.twilio.com/docs/sms/services#smart-encoding) for messages sent through the Service instance. + :param sticky_sender: Whether to enable [Sticky Sender](https://www.twilio.com/docs/messaging/services#sticky-sender) on the Service instance. + :param mms_converter: Whether to enable the [MMS Converter](https://www.twilio.com/docs/messaging/services#mms-converter) for messages sent through the Service instance. + :param smart_encoding: Whether to enable [Smart Encoding](https://www.twilio.com/docs/messaging/services#smart-encoding) for messages sent through the Service instance. :param scan_message_content: - :param fallback_to_long_code: Whether to enable [Fallback to Long Code](https://www.twilio.com/docs/sms/services#fallback-to-long-code) for messages sent through the Service instance. - :param area_code_geomatch: Whether to enable [Area Code Geomatch](https://www.twilio.com/docs/sms/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 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 `36,000`. Default value is `36,000`. :param synchronous_validation: Reserved. - :param usecase: A string that describes the scenario in which the Messaging Service will be used. Examples: [notification, marketing, verification, poll ..] + :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, @@ -539,23 +577,32 @@ async def update_async( "FallbackUrl": fallback_url, "FallbackMethod": fallback_method, "StatusCallback": status_callback, - "StickySender": sticky_sender, - "MmsConverter": mms_converter, - "SmartEncoding": smart_encoding, + "StickySender": serialize.boolean_to_string(sticky_sender), + "MmsConverter": serialize.boolean_to_string(mms_converter), + "SmartEncoding": serialize.boolean_to_string(smart_encoding), "ScanMessageContent": scan_message_content, - "FallbackToLongCode": fallback_to_long_code, - "AreaCodeGeomatch": area_code_geomatch, + "FallbackToLongCode": serialize.boolean_to_string( + fallback_to_long_code + ), + "AreaCodeGeomatch": serialize.boolean_to_string(area_code_geomatch), "ValidityPeriod": validity_period, - "SynchronousValidation": synchronous_validation, + "SynchronousValidation": serialize.boolean_to_string( + synchronous_validation + ), "Usecase": usecase, - "UseInboundWebhookOnNumber": use_inbound_webhook_on_number, + "UseInboundWebhookOnNumber": serialize.boolean_to_string( + use_inbound_webhook_on_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 ServiceInstance(self._version, payload, sid=self._solution["sid"]) @@ -572,6 +619,30 @@ def alpha_senders(self) -> AlphaSenderList: ) return self._alpha_senders + @property + def channel_senders(self) -> ChannelSenderList: + """ + Access the channel_senders + """ + if self._channel_senders is None: + self._channel_senders = ChannelSenderList( + self._version, + self._solution["sid"], + ) + 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: """ @@ -631,6 +702,7 @@ def __repr__(self) -> str: class ServicePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ServiceInstance: """ Build an instance of ServiceInstance @@ -649,6 +721,7 @@ def __repr__(self) -> str: class ServiceList(ListResource): + def __init__(self, version: Version): """ Initialize the ServiceList @@ -690,19 +763,20 @@ def create( :param fallback_url: The URL that we call using `fallback_method` if an error occurs while retrieving or executing the TwiML from the Inbound Request URL. If the `use_inbound_webhook_on_number` field is enabled then the webhook url defined on the phone number will override the `fallback_url` defined for the Messaging Service. :param fallback_method: The HTTP method we should use to call `fallback_url`. Can be: `GET` or `POST`. :param status_callback: The URL we should call to [pass status updates](https://www.twilio.com/docs/sms/api/message-resource#message-status-values) about message delivery. - :param sticky_sender: Whether to enable [Sticky Sender](https://www.twilio.com/docs/sms/services#sticky-sender) on the Service instance. - :param mms_converter: Whether to enable the [MMS Converter](https://www.twilio.com/docs/sms/services#mms-converter) for messages sent through the Service instance. - :param smart_encoding: Whether to enable [Smart Encoding](https://www.twilio.com/docs/sms/services#smart-encoding) for messages sent through the Service instance. + :param sticky_sender: Whether to enable [Sticky Sender](https://www.twilio.com/docs/messaging/services#sticky-sender) on the Service instance. + :param mms_converter: Whether to enable the [MMS Converter](https://www.twilio.com/docs/messaging/services#mms-converter) for messages sent through the Service instance. + :param smart_encoding: Whether to enable [Smart Encoding](https://www.twilio.com/docs/messaging/services#smart-encoding) for messages sent through the Service instance. :param scan_message_content: - :param fallback_to_long_code: Whether to enable [Fallback to Long Code](https://www.twilio.com/docs/sms/services#fallback-to-long-code) for messages sent through the Service instance. - :param area_code_geomatch: Whether to enable [Area Code Geomatch](https://www.twilio.com/docs/sms/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 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 `36,000`. Default value is `36,000`. :param synchronous_validation: Reserved. - :param usecase: A string that describes the scenario in which the Messaging Service will be used. Examples: [notification, marketing, verification, poll ..]. + :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 created ServiceInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -711,23 +785,32 @@ def create( "FallbackUrl": fallback_url, "FallbackMethod": fallback_method, "StatusCallback": status_callback, - "StickySender": sticky_sender, - "MmsConverter": mms_converter, - "SmartEncoding": smart_encoding, + "StickySender": serialize.boolean_to_string(sticky_sender), + "MmsConverter": serialize.boolean_to_string(mms_converter), + "SmartEncoding": serialize.boolean_to_string(smart_encoding), "ScanMessageContent": scan_message_content, - "FallbackToLongCode": fallback_to_long_code, - "AreaCodeGeomatch": area_code_geomatch, + "FallbackToLongCode": serialize.boolean_to_string( + fallback_to_long_code + ), + "AreaCodeGeomatch": serialize.boolean_to_string(area_code_geomatch), "ValidityPeriod": validity_period, - "SynchronousValidation": synchronous_validation, + "SynchronousValidation": serialize.boolean_to_string( + synchronous_validation + ), "Usecase": usecase, - "UseInboundWebhookOnNumber": use_inbound_webhook_on_number, + "UseInboundWebhookOnNumber": serialize.boolean_to_string( + use_inbound_webhook_on_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 ServiceInstance(self._version, payload) @@ -762,19 +845,20 @@ async def create_async( :param fallback_url: The URL that we call using `fallback_method` if an error occurs while retrieving or executing the TwiML from the Inbound Request URL. If the `use_inbound_webhook_on_number` field is enabled then the webhook url defined on the phone number will override the `fallback_url` defined for the Messaging Service. :param fallback_method: The HTTP method we should use to call `fallback_url`. Can be: `GET` or `POST`. :param status_callback: The URL we should call to [pass status updates](https://www.twilio.com/docs/sms/api/message-resource#message-status-values) about message delivery. - :param sticky_sender: Whether to enable [Sticky Sender](https://www.twilio.com/docs/sms/services#sticky-sender) on the Service instance. - :param mms_converter: Whether to enable the [MMS Converter](https://www.twilio.com/docs/sms/services#mms-converter) for messages sent through the Service instance. - :param smart_encoding: Whether to enable [Smart Encoding](https://www.twilio.com/docs/sms/services#smart-encoding) for messages sent through the Service instance. + :param sticky_sender: Whether to enable [Sticky Sender](https://www.twilio.com/docs/messaging/services#sticky-sender) on the Service instance. + :param mms_converter: Whether to enable the [MMS Converter](https://www.twilio.com/docs/messaging/services#mms-converter) for messages sent through the Service instance. + :param smart_encoding: Whether to enable [Smart Encoding](https://www.twilio.com/docs/messaging/services#smart-encoding) for messages sent through the Service instance. :param scan_message_content: - :param fallback_to_long_code: Whether to enable [Fallback to Long Code](https://www.twilio.com/docs/sms/services#fallback-to-long-code) for messages sent through the Service instance. - :param area_code_geomatch: Whether to enable [Area Code Geomatch](https://www.twilio.com/docs/sms/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 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 `36,000`. Default value is `36,000`. :param synchronous_validation: Reserved. - :param usecase: A string that describes the scenario in which the Messaging Service will be used. Examples: [notification, marketing, verification, poll ..]. + :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 created ServiceInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -783,23 +867,32 @@ async def create_async( "FallbackUrl": fallback_url, "FallbackMethod": fallback_method, "StatusCallback": status_callback, - "StickySender": sticky_sender, - "MmsConverter": mms_converter, - "SmartEncoding": smart_encoding, + "StickySender": serialize.boolean_to_string(sticky_sender), + "MmsConverter": serialize.boolean_to_string(mms_converter), + "SmartEncoding": serialize.boolean_to_string(smart_encoding), "ScanMessageContent": scan_message_content, - "FallbackToLongCode": fallback_to_long_code, - "AreaCodeGeomatch": area_code_geomatch, + "FallbackToLongCode": serialize.boolean_to_string( + fallback_to_long_code + ), + "AreaCodeGeomatch": serialize.boolean_to_string(area_code_geomatch), "ValidityPeriod": validity_period, - "SynchronousValidation": synchronous_validation, + "SynchronousValidation": serialize.boolean_to_string( + synchronous_validation + ), "Usecase": usecase, - "UseInboundWebhookOnNumber": use_inbound_webhook_on_number, + "UseInboundWebhookOnNumber": serialize.boolean_to_string( + use_inbound_webhook_on_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 ServiceInstance(self._version, payload) @@ -931,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( @@ -958,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 92d81e9fc4..2ba4c2a45c 100644 --- a/twilio/rest/messaging/v1/service/alpha_sender.py +++ b/twilio/rest/messaging/v1/service/alpha_sender.py @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class AlphaSenderInstance(InstanceResource): - """ :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. @@ -127,6 +125,7 @@ def __repr__(self) -> str: class AlphaSenderContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, sid: str): """ Initialize the AlphaSenderContext @@ -153,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: """ @@ -165,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: @@ -178,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, @@ -198,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( @@ -221,6 +226,7 @@ def __repr__(self) -> str: class AlphaSenderPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> AlphaSenderInstance: """ Build an instance of AlphaSenderInstance @@ -241,6 +247,7 @@ def __repr__(self) -> str: class AlphaSenderList(ListResource): + def __init__(self, version: Version, service_sid: str): """ Initialize the AlphaSenderList @@ -265,16 +272,20 @@ def create(self, alpha_sender: str) -> AlphaSenderInstance: :returns: The created AlphaSenderInstance """ + data = values.of( { "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( @@ -289,16 +300,20 @@ async def create_async(self, alpha_sender: str) -> AlphaSenderInstance: :returns: The created AlphaSenderInstance """ + data = values.of( { "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( @@ -432,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( @@ -459,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/autopilot/v1/assistant/task/field.py b/twilio/rest/messaging/v1/service/channel_sender.py similarity index 55% rename from twilio/rest/autopilot/v1/assistant/task/field.py rename to twilio/rest/messaging/v1/service/channel_sender.py index dc48c44659..9d708a2fba 100644 --- a/twilio/rest/autopilot/v1/assistant/task/field.py +++ b/twilio/rest/messaging/v1/service/channel_sender.py @@ -4,7 +4,7 @@ | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - Twilio - Autopilot + Twilio - Messaging This is the public Twilio REST API. NOTE: This class is auto generated by OpenAPI Generator. @@ -12,7 +12,6 @@ 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 @@ -23,71 +22,67 @@ from twilio.base.page import Page -class FieldInstance(InstanceResource): - +class ChannelSenderInstance(InstanceResource): """ - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Field resource. - :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. - :ivar field_type: The Field Type of the field. Can be: a [Built-in Field Type](https://www.twilio.com/docs/autopilot/built-in-field-types), the unique_name, or the SID of a custom Field Type. - :ivar task_sid: The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource associated with this Field. - :ivar assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the Task associated with the resource. - :ivar sid: The unique string that we created to identify the Field 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. - :ivar url: The absolute URL of the Field resource. + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the ChannelSender resource. + :ivar messaging_service_sid: The SID of the [Service](https://www.twilio.com/docs/messaging/services) the resource is associated with. + :ivar sid: The unique string that we created to identify the ChannelSender resource. + :ivar sender: The unique string that identifies the sender e.g whatsapp:+123456XXXX. + :ivar sender_type: A string value that identifies the sender type e.g WhatsApp, Messenger. + :ivar country_code: The 2-character [ISO Country Code](https://www.iso.org/iso-3166-country-codes.html) of the number. + :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 ChannelSender resource. """ def __init__( self, version: Version, payload: Dict[str, Any], - assistant_sid: str, - task_sid: str, + messaging_service_sid: str, sid: Optional[str] = None, ): super().__init__(version) self.account_sid: Optional[str] = payload.get("account_sid") + self.messaging_service_sid: Optional[str] = payload.get("messaging_service_sid") + self.sid: Optional[str] = payload.get("sid") + self.sender: Optional[str] = payload.get("sender") + self.sender_type: Optional[str] = payload.get("sender_type") + self.country_code: Optional[str] = payload.get("country_code") 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.field_type: Optional[str] = payload.get("field_type") - self.task_sid: Optional[str] = payload.get("task_sid") - self.assistant_sid: Optional[str] = payload.get("assistant_sid") - self.sid: Optional[str] = payload.get("sid") - self.unique_name: Optional[str] = payload.get("unique_name") self.url: Optional[str] = payload.get("url") self._solution = { - "assistant_sid": assistant_sid, - "task_sid": task_sid, + "messaging_service_sid": messaging_service_sid, "sid": sid or self.sid, } - self._context: Optional[FieldContext] = None + self._context: Optional[ChannelSenderContext] = None @property - def _proxy(self) -> "FieldContext": + def _proxy(self) -> "ChannelSenderContext": """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context - :returns: FieldContext for this FieldInstance + :returns: ChannelSenderContext for this ChannelSenderInstance """ if self._context is None: - self._context = FieldContext( + self._context = ChannelSenderContext( self._version, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], + messaging_service_sid=self._solution["messaging_service_sid"], sid=self._solution["sid"], ) return self._context def delete(self) -> bool: """ - Deletes the FieldInstance + Deletes the ChannelSenderInstance :returns: True if delete succeeds, False otherwise @@ -96,28 +91,28 @@ def delete(self) -> bool: async def delete_async(self) -> bool: """ - Asynchronous coroutine that deletes the FieldInstance + Asynchronous coroutine that deletes the ChannelSenderInstance :returns: True if delete succeeds, False otherwise """ return await self._proxy.delete_async() - def fetch(self) -> "FieldInstance": + def fetch(self) -> "ChannelSenderInstance": """ - Fetch the FieldInstance + Fetch the ChannelSenderInstance - :returns: The fetched FieldInstance + :returns: The fetched ChannelSenderInstance """ return self._proxy.fetch() - async def fetch_async(self) -> "FieldInstance": + async def fetch_async(self) -> "ChannelSenderInstance": """ - Asynchronous coroutine to fetch the FieldInstance + Asynchronous coroutine to fetch the ChannelSenderInstance - :returns: The fetched FieldInstance + :returns: The fetched ChannelSenderInstance """ return await self._proxy.fetch_async() @@ -128,94 +123,97 @@ 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 FieldContext(InstanceContext): - def __init__(self, version: Version, assistant_sid: str, task_sid: str, sid: str): +class ChannelSenderContext(InstanceContext): + + def __init__(self, version: Version, messaging_service_sid: str, sid: str): """ - Initialize the FieldContext + Initialize the ChannelSenderContext :param version: Version that contains the resource - :param assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the Task associated with the resource to fetch. - :param task_sid: The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource associated with the Field resource to fetch. - :param sid: The Twilio-provided string that uniquely identifies the Field resource to fetch. + :param messaging_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 ChannelSender resource to fetch. """ super().__init__(version) # Path Solution self._solution = { - "assistant_sid": assistant_sid, - "task_sid": task_sid, + "messaging_service_sid": messaging_service_sid, "sid": sid, } - self._uri = "/Assistants/{assistant_sid}/Tasks/{task_sid}/Fields/{sid}".format( + self._uri = "/Services/{messaging_service_sid}/ChannelSenders/{sid}".format( **self._solution ) def delete(self) -> bool: """ - Deletes the FieldInstance + Deletes the ChannelSenderInstance :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 FieldInstance + 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, + method="DELETE", uri=self._uri, headers=headers ) - def fetch(self) -> FieldInstance: + def fetch(self) -> ChannelSenderInstance: """ - Fetch the FieldInstance + Fetch the ChannelSenderInstance - :returns: The fetched FieldInstance + :returns: The fetched ChannelSenderInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) - return FieldInstance( + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return ChannelSenderInstance( self._version, payload, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], + messaging_service_sid=self._solution["messaging_service_sid"], sid=self._solution["sid"], ) - async def fetch_async(self) -> FieldInstance: + async def fetch_async(self) -> ChannelSenderInstance: """ - Asynchronous coroutine to fetch the FieldInstance + Asynchronous coroutine to fetch the ChannelSenderInstance - :returns: The fetched FieldInstance + :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 FieldInstance( + return ChannelSenderInstance( self._version, payload, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], + messaging_service_sid=self._solution["messaging_service_sid"], sid=self._solution["sid"], ) @@ -226,21 +224,21 @@ 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 ChannelSenderPage(Page): -class FieldPage(Page): - def get_instance(self, payload: Dict[str, Any]) -> FieldInstance: + def get_instance(self, payload: Dict[str, Any]) -> ChannelSenderInstance: """ - Build an instance of FieldInstance + Build an instance of ChannelSenderInstance :param payload: Payload response from the API """ - return FieldInstance( + return ChannelSenderInstance( self._version, payload, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], + messaging_service_sid=self._solution["messaging_service_sid"], ) def __repr__(self) -> str: @@ -249,95 +247,96 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ - return "" + return "" -class FieldList(ListResource): - def __init__(self, version: Version, assistant_sid: str, task_sid: str): +class ChannelSenderList(ListResource): + + def __init__(self, version: Version, messaging_service_sid: str): """ - Initialize the FieldList + Initialize the ChannelSenderList :param version: Version that contains the resource - :param assistant_sid: The SID of the [Assistant](https://www.twilio.com/docs/autopilot/api/assistant) that is the parent of the Task associated with the resources to read. - :param task_sid: The SID of the [Task](https://www.twilio.com/docs/autopilot/api/task) resource associated with the Field resources to read. + :param messaging_service_sid: The SID of the [Service](https://www.twilio.com/docs/chat/rest/service-resource) to read the resources from. """ super().__init__(version) # Path Solution self._solution = { - "assistant_sid": assistant_sid, - "task_sid": task_sid, + "messaging_service_sid": messaging_service_sid, } - self._uri = "/Assistants/{assistant_sid}/Tasks/{task_sid}/Fields".format( + self._uri = "/Services/{messaging_service_sid}/ChannelSenders".format( **self._solution ) - def create(self, field_type: str, unique_name: str) -> FieldInstance: + def create(self, sid: str) -> ChannelSenderInstance: """ - Create the FieldInstance + Create the ChannelSenderInstance - :param field_type: The Field Type of the new field. Can be: a [Built-in Field Type](https://www.twilio.com/docs/autopilot/built-in-field-types), the `unique_name`, or the `sid` of a custom Field Type. - :param unique_name: An application-defined string that uniquely identifies the new resource. This value must be a unique string of no more than 64 characters. It can be used as an alternative to the `sid` in the URL path to address the resource. + :param sid: The SID of the Channel Sender being added to the Service. - :returns: The created FieldInstance + :returns: The created ChannelSenderInstance """ + data = values.of( { - "FieldType": field_type, - "UniqueName": unique_name, + "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 FieldInstance( + return ChannelSenderInstance( self._version, payload, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], + messaging_service_sid=self._solution["messaging_service_sid"], ) - async def create_async(self, field_type: str, unique_name: str) -> FieldInstance: + async def create_async(self, sid: str) -> ChannelSenderInstance: """ - Asynchronously create the FieldInstance + Asynchronously create the ChannelSenderInstance - :param field_type: The Field Type of the new field. Can be: a [Built-in Field Type](https://www.twilio.com/docs/autopilot/built-in-field-types), the `unique_name`, or the `sid` of a custom Field Type. - :param unique_name: An application-defined string that uniquely identifies the new resource. This value must be a unique string of no more than 64 characters. It can be used as an alternative to the `sid` in the URL path to address the resource. + :param sid: The SID of the Channel Sender being added to the Service. - :returns: The created FieldInstance + :returns: The created ChannelSenderInstance """ + data = values.of( { - "FieldType": field_type, - "UniqueName": unique_name, + "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 FieldInstance( + return ChannelSenderInstance( self._version, payload, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], + messaging_service_sid=self._solution["messaging_service_sid"], ) def stream( self, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> Iterator[FieldInstance]: + ) -> Iterator[ChannelSenderInstance]: """ - Streams FieldInstance records from the API as a generator stream. + Streams ChannelSenderInstance 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. @@ -360,9 +359,9 @@ async def stream_async( self, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> AsyncIterator[FieldInstance]: + ) -> AsyncIterator[ChannelSenderInstance]: """ - Asynchronously streams FieldInstance records from the API as a generator stream. + Asynchronously streams ChannelSenderInstance 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. @@ -385,9 +384,9 @@ def list( self, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> List[FieldInstance]: + ) -> List[ChannelSenderInstance]: """ - Lists FieldInstance records from the API as a list. + Lists ChannelSenderInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @@ -411,9 +410,9 @@ async def list_async( self, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> List[FieldInstance]: + ) -> List[ChannelSenderInstance]: """ - Asynchronously lists FieldInstance records from the API as a list. + Asynchronously lists ChannelSenderInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @@ -439,16 +438,16 @@ def page( page_token: Union[str, object] = values.unset, page_number: Union[int, object] = values.unset, page_size: Union[int, object] = values.unset, - ) -> FieldPage: + ) -> ChannelSenderPage: """ - Retrieve a single page of FieldInstance records from the API. + Retrieve a single page of ChannelSenderInstance 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 FieldInstance + :returns: Page of ChannelSenderInstance """ data = values.of( { @@ -458,24 +457,30 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) - return FieldPage(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 ChannelSenderPage(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, - ) -> FieldPage: + ) -> ChannelSenderPage: """ - Asynchronously retrieve a single page of FieldInstance records from the API. + Asynchronously retrieve a single page of ChannelSenderInstance 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 FieldInstance + :returns: Page of ChannelSenderInstance """ data = values.of( { @@ -485,58 +490,60 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + response = await self._version.page_async( - method="GET", uri=self._uri, params=data + method="GET", uri=self._uri, params=data, headers=headers ) - return FieldPage(self._version, response, self._solution) + return ChannelSenderPage(self._version, response, self._solution) - def get_page(self, target_url: str) -> FieldPage: + def get_page(self, target_url: str) -> ChannelSenderPage: """ - Retrieve a specific page of FieldInstance records from the API. + Retrieve a specific page of ChannelSenderInstance records from the API. Request is executed immediately :param target_url: API-generated URL for the requested results page - :returns: Page of FieldInstance + :returns: Page of ChannelSenderInstance """ response = self._version.domain.twilio.request("GET", target_url) - return FieldPage(self._version, response, self._solution) + return ChannelSenderPage(self._version, response, self._solution) - async def get_page_async(self, target_url: str) -> FieldPage: + async def get_page_async(self, target_url: str) -> ChannelSenderPage: """ - Asynchronously retrieve a specific page of FieldInstance records from the API. + Asynchronously retrieve a specific page of ChannelSenderInstance records from the API. Request is executed immediately :param target_url: API-generated URL for the requested results page - :returns: Page of FieldInstance + :returns: Page of ChannelSenderInstance """ response = await self._version.domain.twilio.request_async("GET", target_url) - return FieldPage(self._version, response, self._solution) + return ChannelSenderPage(self._version, response, self._solution) - def get(self, sid: str) -> FieldContext: + def get(self, sid: str) -> ChannelSenderContext: """ - Constructs a FieldContext + Constructs a ChannelSenderContext - :param sid: The Twilio-provided string that uniquely identifies the Field resource to fetch. + :param sid: The SID of the ChannelSender resource to fetch. """ - return FieldContext( + return ChannelSenderContext( self._version, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], + messaging_service_sid=self._solution["messaging_service_sid"], sid=sid, ) - def __call__(self, sid: str) -> FieldContext: + def __call__(self, sid: str) -> ChannelSenderContext: """ - Constructs a FieldContext + Constructs a ChannelSenderContext - :param sid: The Twilio-provided string that uniquely identifies the Field resource to fetch. + :param sid: The SID of the ChannelSender resource to fetch. """ - return FieldContext( + return ChannelSenderContext( self._version, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], + messaging_service_sid=self._solution["messaging_service_sid"], sid=sid, ) @@ -546,4 +553,4 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ - return "" + return "" diff --git a/twilio/rest/proxy/v1/service/short_code.py b/twilio/rest/messaging/v1/service/destination_alpha_sender.py similarity index 51% rename from twilio/rest/proxy/v1/service/short_code.py rename to twilio/rest/messaging/v1/service/destination_alpha_sender.py index 27dc8467f1..244d906cae 100644 --- a/twilio/rest/proxy/v1/service/short_code.py +++ b/twilio/rest/messaging/v1/service/destination_alpha_sender.py @@ -4,7 +4,7 @@ | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - Twilio - Proxy + Twilio - Messaging This is the public Twilio REST API. NOTE: This class is auto generated by OpenAPI Generator. @@ -12,7 +12,6 @@ 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 @@ -23,19 +22,17 @@ from twilio.base.page import Page -class ShortCodeInstance(InstanceResource): - +class DestinationAlphaSenderInstance(InstanceResource): """ - :ivar sid: The unique string that we created to identify the ShortCode resource. - :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the ShortCode resource. - :ivar service_sid: The SID of the ShortCode resource's parent [Service](https://www.twilio.com/docs/proxy/api/service) resource. - :ivar date_created: The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time in GMT when the resource was created. - :ivar date_updated: The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time in GMT when the resource was last updated. - :ivar short_code: The short code's number. - :ivar iso_country: The ISO Country Code for the short code. - :ivar capabilities: - :ivar url: The absolute URL of the ShortCode resource. - :ivar is_reserved: Whether the short code should be reserved and not be assigned to a participant using proxy pool logic. See [Reserved Phone Numbers](https://www.twilio.com/docs/proxy/reserved-phone-numbers) for more information. + :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__( @@ -56,28 +53,27 @@ def __init__( self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( payload.get("date_updated") ) - self.short_code: Optional[str] = payload.get("short_code") - self.iso_country: Optional[str] = payload.get("iso_country") - self.capabilities: Optional[str] = payload.get("capabilities") + 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.is_reserved: Optional[bool] = payload.get("is_reserved") + 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[ShortCodeContext] = None + self._context: Optional[DestinationAlphaSenderContext] = None @property - def _proxy(self) -> "ShortCodeContext": + 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: ShortCodeContext for this ShortCodeInstance + :returns: DestinationAlphaSenderContext for this DestinationAlphaSenderInstance """ if self._context is None: - self._context = ShortCodeContext( + self._context = DestinationAlphaSenderContext( self._version, service_sid=self._solution["service_sid"], sid=self._solution["sid"], @@ -86,7 +82,7 @@ def _proxy(self) -> "ShortCodeContext": def delete(self) -> bool: """ - Deletes the ShortCodeInstance + Deletes the DestinationAlphaSenderInstance :returns: True if delete succeeds, False otherwise @@ -95,59 +91,31 @@ def delete(self) -> bool: async def delete_async(self) -> bool: """ - Asynchronous coroutine that deletes the ShortCodeInstance + Asynchronous coroutine that deletes the DestinationAlphaSenderInstance :returns: True if delete succeeds, False otherwise """ return await self._proxy.delete_async() - def fetch(self) -> "ShortCodeInstance": + def fetch(self) -> "DestinationAlphaSenderInstance": """ - Fetch the ShortCodeInstance + Fetch the DestinationAlphaSenderInstance - :returns: The fetched ShortCodeInstance + :returns: The fetched DestinationAlphaSenderInstance """ return self._proxy.fetch() - async def fetch_async(self) -> "ShortCodeInstance": + async def fetch_async(self) -> "DestinationAlphaSenderInstance": """ - Asynchronous coroutine to fetch the ShortCodeInstance + Asynchronous coroutine to fetch the DestinationAlphaSenderInstance - :returns: The fetched ShortCodeInstance + :returns: The fetched DestinationAlphaSenderInstance """ return await self._proxy.fetch_async() - def update( - self, is_reserved: Union[bool, object] = values.unset - ) -> "ShortCodeInstance": - """ - Update the ShortCodeInstance - - :param is_reserved: Whether the short code should be reserved and not be assigned to a participant using proxy pool logic. See [Reserved Phone Numbers](https://www.twilio.com/docs/proxy/reserved-phone-numbers) for more information. - - :returns: The updated ShortCodeInstance - """ - return self._proxy.update( - is_reserved=is_reserved, - ) - - async def update_async( - self, is_reserved: Union[bool, object] = values.unset - ) -> "ShortCodeInstance": - """ - Asynchronous coroutine to update the ShortCodeInstance - - :param is_reserved: Whether the short code should be reserved and not be assigned to a participant using proxy pool logic. See [Reserved Phone Numbers](https://www.twilio.com/docs/proxy/reserved-phone-numbers) for more information. - - :returns: The updated ShortCodeInstance - """ - return await self._proxy.update_async( - is_reserved=is_reserved, - ) - def __repr__(self) -> str: """ Provide a friendly representation @@ -155,17 +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 ShortCodeContext(InstanceContext): +class DestinationAlphaSenderContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, sid: str): """ - Initialize the ShortCodeContext + Initialize the DestinationAlphaSenderContext :param version: Version that contains the resource - :param service_sid: The SID of the parent [Service](https://www.twilio.com/docs/proxy/api/service) of the resource to update. - :param sid: The Twilio-provided string that uniquely identifies the ShortCode resource to update. + :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) @@ -174,124 +143,74 @@ def __init__(self, version: Version, service_sid: str, sid: str): "service_sid": service_sid, "sid": sid, } - self._uri = "/Services/{service_sid}/ShortCodes/{sid}".format(**self._solution) + self._uri = "/Services/{service_sid}/DestinationAlphaSenders/{sid}".format( + **self._solution + ) def delete(self) -> bool: """ - Deletes the ShortCodeInstance + 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 ShortCodeInstance + 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) -> ShortCodeInstance: + def fetch(self) -> DestinationAlphaSenderInstance: """ - Fetch the ShortCodeInstance + Fetch the DestinationAlphaSenderInstance - :returns: The fetched ShortCodeInstance + :returns: The fetched DestinationAlphaSenderInstance """ - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) + headers = values.of({}) - return ShortCodeInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - sid=self._solution["sid"], - ) + headers["Accept"] = "application/json" - async def fetch_async(self) -> ShortCodeInstance: - """ - Asynchronous coroutine to fetch the ShortCodeInstance - - - :returns: The fetched ShortCodeInstance - """ + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return ShortCodeInstance( + return DestinationAlphaSenderInstance( self._version, payload, service_sid=self._solution["service_sid"], sid=self._solution["sid"], ) - def update( - self, is_reserved: Union[bool, object] = values.unset - ) -> ShortCodeInstance: - """ - Update the ShortCodeInstance - - :param is_reserved: Whether the short code should be reserved and not be assigned to a participant using proxy pool logic. See [Reserved Phone Numbers](https://www.twilio.com/docs/proxy/reserved-phone-numbers) for more information. - - :returns: The updated ShortCodeInstance + async def fetch_async(self) -> DestinationAlphaSenderInstance: """ - data = values.of( - { - "IsReserved": is_reserved, - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) + Asynchronous coroutine to fetch the DestinationAlphaSenderInstance - return ShortCodeInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - sid=self._solution["sid"], - ) - async def update_async( - self, is_reserved: Union[bool, object] = values.unset - ) -> ShortCodeInstance: + :returns: The fetched DestinationAlphaSenderInstance """ - Asynchronous coroutine to update the ShortCodeInstance - :param is_reserved: Whether the short code should be reserved and not be assigned to a participant using proxy pool logic. See [Reserved Phone Numbers](https://www.twilio.com/docs/proxy/reserved-phone-numbers) for more information. + headers = values.of({}) - :returns: The updated ShortCodeInstance - """ - data = values.of( - { - "IsReserved": is_reserved, - } - ) + headers["Accept"] = "application/json" - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers ) - return ShortCodeInstance( + return DestinationAlphaSenderInstance( self._version, payload, service_sid=self._solution["service_sid"], @@ -305,17 +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 DestinationAlphaSenderPage(Page): -class ShortCodePage(Page): - def get_instance(self, payload: Dict[str, Any]) -> ShortCodeInstance: + def get_instance(self, payload: Dict[str, Any]) -> DestinationAlphaSenderInstance: """ - Build an instance of ShortCodeInstance + Build an instance of DestinationAlphaSenderInstance :param payload: Payload response from the API """ - return ShortCodeInstance( + return DestinationAlphaSenderInstance( self._version, payload, service_sid=self._solution["service_sid"] ) @@ -325,16 +245,17 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ - return "" + return "" + +class DestinationAlphaSenderList(ListResource): -class ShortCodeList(ListResource): def __init__(self, version: Version, service_sid: str): """ - Initialize the ShortCodeList + Initialize the DestinationAlphaSenderList :param version: Version that contains the resource - :param service_sid: The SID of the parent [Service](https://www.twilio.com/docs/proxy/api/service) to read the resources from. + :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) @@ -343,67 +264,87 @@ def __init__(self, version: Version, service_sid: str): self._solution = { "service_sid": service_sid, } - self._uri = "/Services/{service_sid}/ShortCodes".format(**self._solution) + self._uri = "/Services/{service_sid}/DestinationAlphaSenders".format( + **self._solution + ) - def create(self, sid: str) -> ShortCodeInstance: + def create( + self, alpha_sender: str, iso_country_code: Union[str, object] = values.unset + ) -> DestinationAlphaSenderInstance: """ - Create the ShortCodeInstance + Create the DestinationAlphaSenderInstance - :param sid: The SID of a Twilio [ShortCode](https://www.twilio.com/docs/sms/api/short-code) resource that represents the short code you would like to assign to your Proxy Service. + :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 ShortCodeInstance + :returns: The created DestinationAlphaSenderInstance """ + data = values.of( { - "Sid": sid, + "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 ShortCodeInstance( + return DestinationAlphaSenderInstance( self._version, payload, service_sid=self._solution["service_sid"] ) - async def create_async(self, sid: str) -> ShortCodeInstance: + async def create_async( + self, alpha_sender: str, iso_country_code: Union[str, object] = values.unset + ) -> DestinationAlphaSenderInstance: """ - Asynchronously create the ShortCodeInstance + Asynchronously create the DestinationAlphaSenderInstance - :param sid: The SID of a Twilio [ShortCode](https://www.twilio.com/docs/sms/api/short-code) resource that represents the short code you would like to assign to your Proxy Service. + :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 ShortCodeInstance + :returns: The created DestinationAlphaSenderInstance """ + data = values.of( { - "Sid": sid, + "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 ShortCodeInstance( + return DestinationAlphaSenderInstance( self._version, payload, service_sid=self._solution["service_sid"] ) def stream( self, + iso_country_code: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> Iterator[ShortCodeInstance]: + ) -> Iterator[DestinationAlphaSenderInstance]: """ - Streams ShortCodeInstance 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. + :param str iso_country_code: Optional filter to return only alphanumeric sender IDs associated with the specified two-character ISO country 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 @@ -414,21 +355,25 @@ def stream( :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"]) + page = self.page( + iso_country_code=iso_country_code, page_size=limits["page_size"] + ) return self._version.stream(page, limits["limit"]) async def stream_async( self, + iso_country_code: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> AsyncIterator[ShortCodeInstance]: + ) -> AsyncIterator[DestinationAlphaSenderInstance]: """ - Asynchronously streams ShortCodeInstance 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. + :param str iso_country_code: Optional filter to return only alphanumeric sender IDs associated with the specified two-character ISO country 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 @@ -439,20 +384,24 @@ 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(page_size=limits["page_size"]) + page = await self.page_async( + iso_country_code=iso_country_code, page_size=limits["page_size"] + ) return self._version.stream_async(page, limits["limit"]) def list( self, + iso_country_code: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> List[ShortCodeInstance]: + ) -> List[DestinationAlphaSenderInstance]: """ - Lists ShortCodeInstance 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. + :param str iso_country_code: Optional filter to return only alphanumeric sender IDs associated with the specified two-character ISO country 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 @@ -464,6 +413,7 @@ def list( """ return list( self.stream( + iso_country_code=iso_country_code, limit=limit, page_size=page_size, ) @@ -471,14 +421,16 @@ def list( async def list_async( self, + iso_country_code: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, - ) -> List[ShortCodeInstance]: + ) -> List[DestinationAlphaSenderInstance]: """ - Asynchronously lists ShortCodeInstance 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. + :param str iso_country_code: Optional filter to return only alphanumeric sender IDs associated with the specified two-character ISO country 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 @@ -491,6 +443,7 @@ async def list_async( return [ record async for record in await self.stream_async( + iso_country_code=iso_country_code, limit=limit, page_size=page_size, ) @@ -498,101 +451,117 @@ async def list_async( def page( self, + iso_country_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, - ) -> ShortCodePage: + ) -> DestinationAlphaSenderPage: """ - Retrieve a single page of ShortCodeInstance records from the API. + Retrieve a single page of DestinationAlphaSenderInstance records from the API. Request is executed immediately + :param iso_country_code: Optional filter to return only alphanumeric sender IDs associated with the specified two-character ISO country 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 ShortCodeInstance + :returns: Page of DestinationAlphaSenderInstance """ data = values.of( { + "IsoCountryCode": iso_country_code, "PageToken": page_token, "Page": page_number, "PageSize": page_size, } ) - response = self._version.page(method="GET", uri=self._uri, params=data) - return ShortCodePage(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, + iso_country_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, - ) -> ShortCodePage: + ) -> DestinationAlphaSenderPage: """ - Asynchronously retrieve a single page of ShortCodeInstance records from the API. + Asynchronously retrieve a single page of DestinationAlphaSenderInstance records from the API. Request is executed immediately + :param iso_country_code: Optional filter to return only alphanumeric sender IDs associated with the specified two-character ISO country 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 ShortCodeInstance + :returns: Page of DestinationAlphaSenderInstance """ data = values.of( { + "IsoCountryCode": iso_country_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 + method="GET", uri=self._uri, params=data, headers=headers ) - return ShortCodePage(self._version, response, self._solution) + return DestinationAlphaSenderPage(self._version, response, self._solution) - def get_page(self, target_url: str) -> ShortCodePage: + def get_page(self, target_url: str) -> DestinationAlphaSenderPage: """ - Retrieve a specific page of ShortCodeInstance 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 ShortCodeInstance + :returns: Page of DestinationAlphaSenderInstance """ response = self._version.domain.twilio.request("GET", target_url) - return ShortCodePage(self._version, response, self._solution) + return DestinationAlphaSenderPage(self._version, response, self._solution) - async def get_page_async(self, target_url: str) -> ShortCodePage: + async def get_page_async(self, target_url: str) -> DestinationAlphaSenderPage: """ - Asynchronously retrieve a specific page of ShortCodeInstance 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 ShortCodeInstance + :returns: Page of DestinationAlphaSenderInstance """ response = await self._version.domain.twilio.request_async("GET", target_url) - return ShortCodePage(self._version, response, self._solution) + return DestinationAlphaSenderPage(self._version, response, self._solution) - def get(self, sid: str) -> ShortCodeContext: + def get(self, sid: str) -> DestinationAlphaSenderContext: """ - Constructs a ShortCodeContext + Constructs a DestinationAlphaSenderContext - :param sid: The Twilio-provided string that uniquely identifies the ShortCode resource to update. + :param sid: The SID of the AlphaSender resource to fetch. """ - return ShortCodeContext( + return DestinationAlphaSenderContext( self._version, service_sid=self._solution["service_sid"], sid=sid ) - def __call__(self, sid: str) -> ShortCodeContext: + def __call__(self, sid: str) -> DestinationAlphaSenderContext: """ - Constructs a ShortCodeContext + Constructs a DestinationAlphaSenderContext - :param sid: The Twilio-provided string that uniquely identifies the ShortCode resource to update. + :param sid: The SID of the AlphaSender resource to fetch. """ - return ShortCodeContext( + return DestinationAlphaSenderContext( self._version, service_sid=self._solution["service_sid"], sid=sid ) @@ -602,4 +571,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 c01c76a3b7..11b806583e 100644 --- a/twilio/rest/messaging/v1/service/phone_number.py +++ b/twilio/rest/messaging/v1/service/phone_number.py @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class PhoneNumberInstance(InstanceResource): - """ :ivar sid: The unique string that we created to identify the PhoneNumber resource. :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the PhoneNumber resource. @@ -129,6 +127,7 @@ def __repr__(self) -> str: class PhoneNumberContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, sid: str): """ Initialize the PhoneNumberContext @@ -155,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: """ @@ -167,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: @@ -180,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, @@ -200,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( @@ -223,6 +228,7 @@ def __repr__(self) -> str: class PhoneNumberPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> PhoneNumberInstance: """ Build an instance of PhoneNumberInstance @@ -243,6 +249,7 @@ def __repr__(self) -> str: class PhoneNumberList(ListResource): + def __init__(self, version: Version, service_sid: str): """ Initialize the PhoneNumberList @@ -267,16 +274,20 @@ def create(self, phone_number_sid: str) -> PhoneNumberInstance: :returns: The created PhoneNumberInstance """ + data = values.of( { "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( @@ -291,16 +302,20 @@ async def create_async(self, phone_number_sid: str) -> PhoneNumberInstance: :returns: The created PhoneNumberInstance """ + data = values.of( { "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( @@ -434,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( @@ -461,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 104f03f6ec..172c78dbb9 100644 --- a/twilio/rest/messaging/v1/service/short_code.py +++ b/twilio/rest/messaging/v1/service/short_code.py @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class ShortCodeInstance(InstanceResource): - """ :ivar sid: The unique string that we created to identify the ShortCode resource. :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the ShortCode resource. @@ -129,6 +127,7 @@ def __repr__(self) -> str: class ShortCodeContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, sid: str): """ Initialize the ShortCodeContext @@ -153,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: """ @@ -165,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: @@ -178,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, @@ -198,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( @@ -221,6 +226,7 @@ def __repr__(self) -> str: class ShortCodePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ShortCodeInstance: """ Build an instance of ShortCodeInstance @@ -241,6 +247,7 @@ def __repr__(self) -> str: class ShortCodeList(ListResource): + def __init__(self, version: Version, service_sid: str): """ Initialize the ShortCodeList @@ -265,16 +272,20 @@ def create(self, short_code_sid: str) -> ShortCodeInstance: :returns: The created ShortCodeInstance """ + data = values.of( { "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( @@ -289,16 +300,20 @@ async def create_async(self, short_code_sid: str) -> ShortCodeInstance: :returns: The created ShortCodeInstance """ + data = values.of( { "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( @@ -432,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( @@ -459,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 5aa45fc162..dd451f5c59 100644 --- a/twilio/rest/messaging/v1/service/us_app_to_person.py +++ b/twilio/rest/messaging/v1/service/us_app_to_person.py @@ -12,7 +12,6 @@ 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 @@ -24,17 +23,19 @@ class UsAppToPersonInstance(InstanceResource): - """ :ivar sid: The unique string that identifies a US A2P Compliance resource `QE2c6890da8086d771620e9b13fadeba0b`. :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that the Campaign belongs to. :ivar brand_registration_sid: The unique string to identify the A2P brand. - :ivar messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/services/api) that the resource is associated with. + :ivar messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) that the resource is associated with. :ivar description: A short description of what this SMS campaign does. Min length: 40 characters. Max length: 4096 characters. - :ivar message_samples: Message samples, at least 1 and up to 5 sample messages (at least 2 for starter/sole proprietor), >=20 chars, <=1024 chars each. + :ivar message_samples: An array of sample message strings, min two and max five. Min length for each sample: 20 chars. Max length for each sample: 1024 chars. :ivar us_app_to_person_usecase: A2P Campaign Use Case. Examples: [ 2FA, EMERGENCY, MARKETING, SOLE_PROPRIETOR...]. SOLE_PROPRIETOR campaign use cases can only be created by SOLE_PROPRIETOR Brands, and there can only be one SOLE_PROPRIETOR campaign created per SOLE_PROPRIETOR Brand. :ivar has_embedded_links: Indicate that this SMS campaign will send messages that contain links. :ivar has_embedded_phone: Indicates that this SMS campaign will send messages that contain phone numbers. + :ivar subscriber_opt_in: A boolean that specifies whether campaign has Subscriber Optin or not. + :ivar age_gated: A boolean that specifies whether campaign is age gated or not. + :ivar direct_lending: A boolean that specifies whether campaign allows direct lending or not. :ivar campaign_status: Campaign status. Examples: IN_PROGRESS, VERIFIED, FAILED. :ivar campaign_id: The Campaign Registry (TCR) Campaign ID. :ivar is_externally_registered: Indicates whether the campaign was registered externally or not. @@ -50,6 +51,7 @@ class UsAppToPersonInstance(InstanceResource): :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 US App to Person resource. :ivar mock: A boolean that specifies whether campaign is a mock or not. Mock campaigns will be automatically created if using a mock brand. Mock campaigns should only be used for testing purposes. + :ivar errors: Details indicating why a campaign registration failed. These errors can indicate one or more fields that were incorrect or did not meet review requirements. """ def __init__( @@ -74,6 +76,9 @@ def __init__( ) self.has_embedded_links: Optional[bool] = payload.get("has_embedded_links") self.has_embedded_phone: Optional[bool] = payload.get("has_embedded_phone") + self.subscriber_opt_in: Optional[bool] = payload.get("subscriber_opt_in") + self.age_gated: Optional[bool] = payload.get("age_gated") + self.direct_lending: Optional[bool] = payload.get("direct_lending") self.campaign_status: Optional[str] = payload.get("campaign_status") self.campaign_id: Optional[str] = payload.get("campaign_id") self.is_externally_registered: Optional[bool] = payload.get( @@ -95,6 +100,7 @@ def __init__( ) self.url: Optional[str] = payload.get("url") self.mock: Optional[bool] = payload.get("mock") + self.errors: Optional[List[Dict[str, object]]] = payload.get("errors") self._solution = { "messaging_service_sid": messaging_service_sid, @@ -154,6 +160,72 @@ async def fetch_async(self) -> "UsAppToPersonInstance": """ return await self._proxy.fetch_async() + def update( + self, + has_embedded_links: bool, + has_embedded_phone: bool, + message_samples: List[str], + message_flow: str, + description: str, + age_gated: bool, + direct_lending: bool, + ) -> "UsAppToPersonInstance": + """ + Update the UsAppToPersonInstance + + :param has_embedded_links: Indicates that this SMS campaign will send messages that contain links. + :param has_embedded_phone: Indicates that this SMS campaign will send messages that contain phone numbers. + :param message_samples: An array of sample message strings, min two and max five. Min length for each sample: 20 chars. Max length for each sample: 1024 chars. + :param message_flow: Required for all Campaigns. Details around how a consumer opts-in to their campaign, therefore giving consent to receive their messages. If multiple opt-in methods can be used for the same campaign, they must all be listed. 40 character minimum. 2048 character maximum. + :param description: A short description of what this SMS campaign does. Min length: 40 characters. Max length: 4096 characters. + :param age_gated: A boolean that specifies whether campaign requires age gate for federally legal content. + :param direct_lending: A boolean that specifies whether campaign allows direct lending or not. + + :returns: The updated UsAppToPersonInstance + """ + return self._proxy.update( + has_embedded_links=has_embedded_links, + has_embedded_phone=has_embedded_phone, + message_samples=message_samples, + message_flow=message_flow, + description=description, + age_gated=age_gated, + direct_lending=direct_lending, + ) + + async def update_async( + self, + has_embedded_links: bool, + has_embedded_phone: bool, + message_samples: List[str], + message_flow: str, + description: str, + age_gated: bool, + direct_lending: bool, + ) -> "UsAppToPersonInstance": + """ + Asynchronous coroutine to update the UsAppToPersonInstance + + :param has_embedded_links: Indicates that this SMS campaign will send messages that contain links. + :param has_embedded_phone: Indicates that this SMS campaign will send messages that contain phone numbers. + :param message_samples: An array of sample message strings, min two and max five. Min length for each sample: 20 chars. Max length for each sample: 1024 chars. + :param message_flow: Required for all Campaigns. Details around how a consumer opts-in to their campaign, therefore giving consent to receive their messages. If multiple opt-in methods can be used for the same campaign, they must all be listed. 40 character minimum. 2048 character maximum. + :param description: A short description of what this SMS campaign does. Min length: 40 characters. Max length: 4096 characters. + :param age_gated: A boolean that specifies whether campaign requires age gate for federally legal content. + :param direct_lending: A boolean that specifies whether campaign allows direct lending or not. + + :returns: The updated UsAppToPersonInstance + """ + return await self._proxy.update_async( + has_embedded_links=has_embedded_links, + has_embedded_phone=has_embedded_phone, + message_samples=message_samples, + message_flow=message_flow, + description=description, + age_gated=age_gated, + direct_lending=direct_lending, + ) + def __repr__(self) -> str: """ Provide a friendly representation @@ -165,13 +237,14 @@ def __repr__(self) -> str: class UsAppToPersonContext(InstanceContext): + def __init__(self, version: Version, messaging_service_sid: str, sid: str): """ Initialize the UsAppToPersonContext :param version: Version that contains the resource - :param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/services/api) to fetch the resource from. - :param sid: The SID of the US A2P Compliance resource to fetch `QE2c6890da8086d771620e9b13fadeba0b`. + :param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/services/api) to update the resource from. + :param sid: The SID of the US A2P Compliance resource to update `QE2c6890da8086d771620e9b13fadeba0b`. """ super().__init__(version) @@ -191,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: """ @@ -203,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: @@ -216,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, @@ -236,9 +312,116 @@ 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( + self._version, + payload, + messaging_service_sid=self._solution["messaging_service_sid"], + sid=self._solution["sid"], + ) + + def update( + self, + has_embedded_links: bool, + has_embedded_phone: bool, + message_samples: List[str], + message_flow: str, + description: str, + age_gated: bool, + direct_lending: bool, + ) -> UsAppToPersonInstance: + """ + Update the UsAppToPersonInstance + + :param has_embedded_links: Indicates that this SMS campaign will send messages that contain links. + :param has_embedded_phone: Indicates that this SMS campaign will send messages that contain phone numbers. + :param message_samples: An array of sample message strings, min two and max five. Min length for each sample: 20 chars. Max length for each sample: 1024 chars. + :param message_flow: Required for all Campaigns. Details around how a consumer opts-in to their campaign, therefore giving consent to receive their messages. If multiple opt-in methods can be used for the same campaign, they must all be listed. 40 character minimum. 2048 character maximum. + :param description: A short description of what this SMS campaign does. Min length: 40 characters. Max length: 4096 characters. + :param age_gated: A boolean that specifies whether campaign requires age gate for federally legal content. + :param direct_lending: A boolean that specifies whether campaign allows direct lending or not. + + :returns: The updated UsAppToPersonInstance + """ + + data = values.of( + { + "HasEmbeddedLinks": serialize.boolean_to_string(has_embedded_links), + "HasEmbeddedPhone": serialize.boolean_to_string(has_embedded_phone), + "MessageSamples": serialize.map(message_samples, lambda e: e), + "MessageFlow": message_flow, + "Description": description, + "AgeGated": serialize.boolean_to_string(age_gated), + "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, headers=headers + ) + + return UsAppToPersonInstance( + self._version, + payload, + messaging_service_sid=self._solution["messaging_service_sid"], + sid=self._solution["sid"], + ) + + async def update_async( + self, + has_embedded_links: bool, + has_embedded_phone: bool, + message_samples: List[str], + message_flow: str, + description: str, + age_gated: bool, + direct_lending: bool, + ) -> UsAppToPersonInstance: + """ + Asynchronous coroutine to update the UsAppToPersonInstance + + :param has_embedded_links: Indicates that this SMS campaign will send messages that contain links. + :param has_embedded_phone: Indicates that this SMS campaign will send messages that contain phone numbers. + :param message_samples: An array of sample message strings, min two and max five. Min length for each sample: 20 chars. Max length for each sample: 1024 chars. + :param message_flow: Required for all Campaigns. Details around how a consumer opts-in to their campaign, therefore giving consent to receive their messages. If multiple opt-in methods can be used for the same campaign, they must all be listed. 40 character minimum. 2048 character maximum. + :param description: A short description of what this SMS campaign does. Min length: 40 characters. Max length: 4096 characters. + :param age_gated: A boolean that specifies whether campaign requires age gate for federally legal content. + :param direct_lending: A boolean that specifies whether campaign allows direct lending or not. + + :returns: The updated UsAppToPersonInstance + """ + + data = values.of( + { + "HasEmbeddedLinks": serialize.boolean_to_string(has_embedded_links), + "HasEmbeddedPhone": serialize.boolean_to_string(has_embedded_phone), + "MessageSamples": serialize.map(message_samples, lambda e: e), + "MessageFlow": message_flow, + "Description": description, + "AgeGated": serialize.boolean_to_string(age_gated), + "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, headers=headers ) return UsAppToPersonInstance( @@ -259,6 +442,7 @@ def __repr__(self) -> str: class UsAppToPersonPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> UsAppToPersonInstance: """ Build an instance of UsAppToPersonInstance @@ -281,12 +465,13 @@ def __repr__(self) -> str: class UsAppToPersonList(ListResource): + def __init__(self, version: Version, messaging_service_sid: str): """ Initialize the UsAppToPersonList :param version: Version that contains the resource - :param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/services/api) to fetch the resource from. + :param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) to fetch the resource from. """ super().__init__(version) @@ -314,6 +499,9 @@ def create( opt_in_keywords: Union[List[str], object] = values.unset, opt_out_keywords: Union[List[str], object] = values.unset, help_keywords: Union[List[str], object] = values.unset, + subscriber_opt_in: Union[bool, object] = values.unset, + age_gated: Union[bool, object] = values.unset, + direct_lending: Union[bool, object] = values.unset, ) -> UsAppToPersonInstance: """ Create the UsAppToPersonInstance @@ -321,7 +509,7 @@ def create( :param brand_registration_sid: A2P Brand Registration SID :param description: A short description of what this SMS campaign does. Min length: 40 characters. Max length: 4096 characters. :param message_flow: Required for all Campaigns. Details around how a consumer opts-in to their campaign, therefore giving consent to receive their messages. If multiple opt-in methods can be used for the same campaign, they must all be listed. 40 character minimum. 2048 character maximum. - :param message_samples: Message samples, at least 1 and up to 5 sample messages (at least 2 for sole proprietor), >=20 chars, <=1024 chars each. + :param message_samples: An array of sample message strings, min two and max five. Min length for each sample: 20 chars. Max length for each sample: 1024 chars. :param us_app_to_person_usecase: A2P Campaign Use Case. Examples: [ 2FA, EMERGENCY, MARKETING..] :param has_embedded_links: Indicates that this SMS campaign will send messages that contain links. :param has_embedded_phone: Indicates that this SMS campaign will send messages that contain phone numbers. @@ -331,9 +519,13 @@ def create( :param opt_in_keywords: If end users can text in a keyword to start receiving messages from this campaign, those keywords must be provided. This field is required if end users can text in a keyword to start receiving messages from this campaign. Values must be alphanumeric. 255 character maximum. :param opt_out_keywords: End users should be able to text in a keyword to stop receiving messages from this campaign. Those keywords must be provided. This field is required if managing opt out keywords yourself (i.e. not using Twilio's Default or Advanced Opt Out features). Values must be alphanumeric. 255 character maximum. :param help_keywords: End users should be able to text in a keyword to receive help. Those keywords must be provided as part of the campaign registration request. This field is required if managing help keywords yourself (i.e. not using Twilio's Default or Advanced Opt Out features). Values must be alphanumeric. 255 character maximum. + :param subscriber_opt_in: A boolean that specifies whether campaign has Subscriber Optin or not. + :param age_gated: A boolean that specifies whether campaign is age gated or not. + :param direct_lending: A boolean that specifies whether campaign allows direct lending or not. :returns: The created UsAppToPersonInstance """ + data = values.of( { "BrandRegistrationSid": brand_registration_sid, @@ -341,21 +533,27 @@ def create( "MessageFlow": message_flow, "MessageSamples": serialize.map(message_samples, lambda e: e), "UsAppToPersonUsecase": us_app_to_person_usecase, - "HasEmbeddedLinks": has_embedded_links, - "HasEmbeddedPhone": has_embedded_phone, + "HasEmbeddedLinks": serialize.boolean_to_string(has_embedded_links), + "HasEmbeddedPhone": serialize.boolean_to_string(has_embedded_phone), "OptInMessage": opt_in_message, "OptOutMessage": opt_out_message, "HelpMessage": help_message, "OptInKeywords": serialize.map(opt_in_keywords, lambda e: e), "OptOutKeywords": serialize.map(opt_out_keywords, lambda e: e), "HelpKeywords": serialize.map(help_keywords, lambda e: e), + "SubscriberOptIn": serialize.boolean_to_string(subscriber_opt_in), + "AgeGated": serialize.boolean_to_string(age_gated), + "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( @@ -379,6 +577,9 @@ async def create_async( opt_in_keywords: Union[List[str], object] = values.unset, opt_out_keywords: Union[List[str], object] = values.unset, help_keywords: Union[List[str], object] = values.unset, + subscriber_opt_in: Union[bool, object] = values.unset, + age_gated: Union[bool, object] = values.unset, + direct_lending: Union[bool, object] = values.unset, ) -> UsAppToPersonInstance: """ Asynchronously create the UsAppToPersonInstance @@ -386,7 +587,7 @@ async def create_async( :param brand_registration_sid: A2P Brand Registration SID :param description: A short description of what this SMS campaign does. Min length: 40 characters. Max length: 4096 characters. :param message_flow: Required for all Campaigns. Details around how a consumer opts-in to their campaign, therefore giving consent to receive their messages. If multiple opt-in methods can be used for the same campaign, they must all be listed. 40 character minimum. 2048 character maximum. - :param message_samples: Message samples, at least 1 and up to 5 sample messages (at least 2 for sole proprietor), >=20 chars, <=1024 chars each. + :param message_samples: An array of sample message strings, min two and max five. Min length for each sample: 20 chars. Max length for each sample: 1024 chars. :param us_app_to_person_usecase: A2P Campaign Use Case. Examples: [ 2FA, EMERGENCY, MARKETING..] :param has_embedded_links: Indicates that this SMS campaign will send messages that contain links. :param has_embedded_phone: Indicates that this SMS campaign will send messages that contain phone numbers. @@ -396,9 +597,13 @@ async def create_async( :param opt_in_keywords: If end users can text in a keyword to start receiving messages from this campaign, those keywords must be provided. This field is required if end users can text in a keyword to start receiving messages from this campaign. Values must be alphanumeric. 255 character maximum. :param opt_out_keywords: End users should be able to text in a keyword to stop receiving messages from this campaign. Those keywords must be provided. This field is required if managing opt out keywords yourself (i.e. not using Twilio's Default or Advanced Opt Out features). Values must be alphanumeric. 255 character maximum. :param help_keywords: End users should be able to text in a keyword to receive help. Those keywords must be provided as part of the campaign registration request. This field is required if managing help keywords yourself (i.e. not using Twilio's Default or Advanced Opt Out features). Values must be alphanumeric. 255 character maximum. + :param subscriber_opt_in: A boolean that specifies whether campaign has Subscriber Optin or not. + :param age_gated: A boolean that specifies whether campaign is age gated or not. + :param direct_lending: A boolean that specifies whether campaign allows direct lending or not. :returns: The created UsAppToPersonInstance """ + data = values.of( { "BrandRegistrationSid": brand_registration_sid, @@ -406,21 +611,27 @@ async def create_async( "MessageFlow": message_flow, "MessageSamples": serialize.map(message_samples, lambda e: e), "UsAppToPersonUsecase": us_app_to_person_usecase, - "HasEmbeddedLinks": has_embedded_links, - "HasEmbeddedPhone": has_embedded_phone, + "HasEmbeddedLinks": serialize.boolean_to_string(has_embedded_links), + "HasEmbeddedPhone": serialize.boolean_to_string(has_embedded_phone), "OptInMessage": opt_in_message, "OptOutMessage": opt_out_message, "HelpMessage": help_message, "OptInKeywords": serialize.map(opt_in_keywords, lambda e: e), "OptOutKeywords": serialize.map(opt_out_keywords, lambda e: e), "HelpKeywords": serialize.map(help_keywords, lambda e: e), + "SubscriberOptIn": serialize.boolean_to_string(subscriber_opt_in), + "AgeGated": serialize.boolean_to_string(age_gated), + "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( @@ -556,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( @@ -583,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) @@ -616,7 +837,7 @@ def get(self, sid: str) -> UsAppToPersonContext: """ Constructs a UsAppToPersonContext - :param sid: The SID of the US A2P Compliance resource to fetch `QE2c6890da8086d771620e9b13fadeba0b`. + :param sid: The SID of the US A2P Compliance resource to update `QE2c6890da8086d771620e9b13fadeba0b`. """ return UsAppToPersonContext( self._version, @@ -628,7 +849,7 @@ def __call__(self, sid: str) -> UsAppToPersonContext: """ Constructs a UsAppToPersonContext - :param sid: The SID of the US A2P Compliance resource to fetch `QE2c6890da8086d771620e9b13fadeba0b`. + :param sid: The SID of the US A2P Compliance resource to update `QE2c6890da8086d771620e9b13fadeba0b`. """ return UsAppToPersonContext( self._version, 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 572434a3d9..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 @@ -12,8 +12,8 @@ Do not edit the class manually. """ - -from typing import Any, Dict, List, Optional +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 @@ -21,7 +21,6 @@ class UsAppToPersonUsecaseInstance(InstanceResource): - """ :ivar us_app_to_person_usecases: Human readable name, code, description and post_approval_required (indicates whether or not post approval is required for this Use Case) of A2P Campaign Use Cases. """ @@ -31,7 +30,7 @@ def __init__( ): super().__init__(version) - self.us_app_to_person_usecases: Optional[List[object]] = payload.get( + self.us_app_to_person_usecases: Optional[List[Dict[str, object]]] = payload.get( "us_app_to_person_usecases" ) @@ -50,12 +49,13 @@ def __repr__(self) -> str: class UsAppToPersonUsecaseList(ListResource): + def __init__(self, version: Version, messaging_service_sid: str): """ Initialize the UsAppToPersonUsecaseList :param version: Version that contains the resource - :param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/services/api) to fetch the resource from. + :param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) to fetch the resource from. """ super().__init__(version) @@ -70,13 +70,28 @@ def __init__(self, version: Version, messaging_service_sid: str): ) ) - def fetch(self) -> UsAppToPersonUsecaseInstance: + def fetch( + self, brand_registration_sid: Union[str, object] = values.unset + ) -> UsAppToPersonUsecaseInstance: """ Asynchronously fetch the UsAppToPersonUsecaseInstance + :param brand_registration_sid: The unique string to identify the A2P brand. :returns: The fetched UsAppToPersonUsecaseInstance """ - payload = self._version.fetch(method="GET", uri=self._uri) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + params = values.of( + { + "BrandRegistrationSid": brand_registration_sid, + } + ) + + payload = self._version.fetch( + method="GET", uri=self._uri, headers=headers, params=params + ) return UsAppToPersonUsecaseInstance( self._version, @@ -84,13 +99,28 @@ def fetch(self) -> UsAppToPersonUsecaseInstance: messaging_service_sid=self._solution["messaging_service_sid"], ) - async def fetch_async(self) -> UsAppToPersonUsecaseInstance: + async def fetch_async( + self, brand_registration_sid: Union[str, object] = values.unset + ) -> UsAppToPersonUsecaseInstance: """ Asynchronously fetch the UsAppToPersonUsecaseInstance + :param brand_registration_sid: The unique string to identify the A2P brand. :returns: The fetched UsAppToPersonUsecaseInstance """ - payload = await self._version.fetch_async(method="GET", uri=self._uri) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + params = values.of( + { + "BrandRegistrationSid": brand_registration_sid, + } + ) + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers, params=params + ) return UsAppToPersonUsecaseInstance( self._version, diff --git a/twilio/rest/messaging/v1/tollfree_verification.py b/twilio/rest/messaging/v1/tollfree_verification.py index 249aa6874e..00cf9c96e3 100644 --- a/twilio/rest/messaging/v1/tollfree_verification.py +++ b/twilio/rest/messaging/v1/tollfree_verification.py @@ -12,7 +12,6 @@ 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 @@ -24,12 +23,15 @@ class TollfreeVerificationInstance(InstanceResource): + class OptInType(object): VERBAL = "VERBAL" WEB_FORM = "WEB_FORM" 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" @@ -56,7 +58,7 @@ class Status(object): :ivar business_contact_first_name: The first name of the contact for the business or organization using the Tollfree number. :ivar business_contact_last_name: The last name of the contact for the business or organization using the Tollfree number. :ivar business_contact_email: The email address of the contact for the business or organization using the Tollfree number. - :ivar business_contact_phone: The phone number of the contact for the business or organization using the Tollfree number. + :ivar business_contact_phone: The E.164 formatted phone number of the contact for the business or organization using the Tollfree number. :ivar notification_email: The email address to receive the notification about the verification result. . :ivar use_case_categories: The category of the use case for the Tollfree Number. List as many are applicable.. :ivar use_case_summary: Use this to further explain how messaging is used by the business or organization. @@ -68,6 +70,11 @@ class Status(object): :ivar tollfree_phone_number_sid: The SID of the Phone Number associated with the Tollfree Verification. :ivar status: :ivar url: The absolute URL of the Tollfree Verification resource. + :ivar rejection_reason: The rejection reason given when a Tollfree Verification has been rejected. + :ivar error_code: The error code given when a Tollfree Verification has been rejected. + :ivar edit_expiration: The date and time when the ability to edit a rejected verification expires. + :ivar edit_allowed: If a rejected verification is allowed to be edited/resubmitted. Some rejection reasons allow editing and some do not. + :ivar rejection_reasons: A list of rejection reasons and codes describing why a Tollfree Verification has been rejected. :ivar resource_links: The URLs of the documents associated with the Tollfree Verification resource. :ivar external_reference_id: An optional external reference ID supplied by customer and echoed back on status retrieval. """ @@ -123,9 +130,9 @@ def __init__( "production_message_sample" ) self.opt_in_image_urls: Optional[List[str]] = payload.get("opt_in_image_urls") - self.opt_in_type: Optional[ - "TollfreeVerificationInstance.OptInType" - ] = payload.get("opt_in_type") + self.opt_in_type: Optional["TollfreeVerificationInstance.OptInType"] = ( + payload.get("opt_in_type") + ) self.message_volume: Optional[str] = payload.get("message_volume") self.additional_information: Optional[str] = payload.get( "additional_information" @@ -137,6 +144,15 @@ def __init__( "status" ) self.url: Optional[str] = payload.get("url") + self.rejection_reason: Optional[str] = payload.get("rejection_reason") + self.error_code: Optional[int] = deserialize.integer(payload.get("error_code")) + self.edit_expiration: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("edit_expiration") + ) + self.edit_allowed: Optional[bool] = payload.get("edit_allowed") + self.rejection_reasons: Optional[List[Dict[str, object]]] = payload.get( + "rejection_reasons" + ) self.resource_links: Optional[Dict[str, object]] = payload.get("resource_links") self.external_reference_id: Optional[str] = payload.get("external_reference_id") @@ -160,6 +176,24 @@ def _proxy(self) -> "TollfreeVerificationContext": ) return self._context + def delete(self) -> bool: + """ + Deletes the TollfreeVerificationInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._proxy.delete() + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the TollfreeVerificationInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._proxy.delete_async() + def fetch(self) -> "TollfreeVerificationInstance": """ Fetch the TollfreeVerificationInstance @@ -202,6 +236,7 @@ def update( 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, + edit_reason: Union[str, object] = values.unset, ) -> "TollfreeVerificationInstance": """ Update the TollfreeVerificationInstance @@ -225,7 +260,8 @@ def update( :param business_contact_first_name: The first name of the contact for the business or organization using the Tollfree number. :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 business_contact_phone: The E.164 formatted phone number of the contact for the business or organization using the Tollfree number. + :param edit_reason: Describe why the verification is being edited. If the verification was rejected because of a technical issue, such as the website being down, and the issue has been resolved this parameter should be set to something similar to 'Website fixed'. :returns: The updated TollfreeVerificationInstance """ @@ -250,6 +286,7 @@ def update( business_contact_last_name=business_contact_last_name, business_contact_email=business_contact_email, business_contact_phone=business_contact_phone, + edit_reason=edit_reason, ) async def update_async( @@ -276,6 +313,7 @@ async def update_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, + edit_reason: Union[str, object] = values.unset, ) -> "TollfreeVerificationInstance": """ Asynchronous coroutine to update the TollfreeVerificationInstance @@ -299,7 +337,8 @@ async def update_async( :param business_contact_first_name: The first name of the contact for the business or organization using the Tollfree number. :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 business_contact_phone: The E.164 formatted phone number of the contact for the business or organization using the Tollfree number. + :param edit_reason: Describe why the verification is being edited. If the verification was rejected because of a technical issue, such as the website being down, and the issue has been resolved this parameter should be set to something similar to 'Website fixed'. :returns: The updated TollfreeVerificationInstance """ @@ -324,6 +363,7 @@ async def update_async( business_contact_last_name=business_contact_last_name, business_contact_email=business_contact_email, business_contact_phone=business_contact_phone, + edit_reason=edit_reason, ) def __repr__(self) -> str: @@ -337,6 +377,7 @@ def __repr__(self) -> str: class TollfreeVerificationContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the TollfreeVerificationContext @@ -352,6 +393,32 @@ def __init__(self, version: Version, sid: str): } self._uri = "/Tollfree/Verifications/{sid}".format(**self._solution) + def delete(self) -> bool: + """ + Deletes the TollfreeVerificationInstance + + + :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 TollfreeVerificationInstance + + + :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) -> TollfreeVerificationInstance: """ Fetch the TollfreeVerificationInstance @@ -360,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, @@ -379,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( @@ -414,6 +485,7 @@ def update( 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, + edit_reason: Union[str, object] = values.unset, ) -> TollfreeVerificationInstance: """ Update the TollfreeVerificationInstance @@ -437,10 +509,12 @@ def update( :param business_contact_first_name: The first name of the contact for the business or organization using the Tollfree number. :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 business_contact_phone: The E.164 formatted phone number of the contact for the business or organization using the Tollfree number. + :param edit_reason: Describe why the verification is being edited. If the verification was rejected because of a technical issue, such as the website being down, and the issue has been resolved this parameter should be set to something similar to 'Website fixed'. :returns: The updated TollfreeVerificationInstance """ + data = values.of( { "BusinessName": business_name, @@ -463,13 +537,17 @@ def update( "BusinessContactLastName": business_contact_last_name, "BusinessContactEmail": business_contact_email, "BusinessContactPhone": business_contact_phone, + "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( @@ -500,6 +578,7 @@ async def update_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, + edit_reason: Union[str, object] = values.unset, ) -> TollfreeVerificationInstance: """ Asynchronous coroutine to update the TollfreeVerificationInstance @@ -523,10 +602,12 @@ async def update_async( :param business_contact_first_name: The first name of the contact for the business or organization using the Tollfree number. :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 business_contact_phone: The E.164 formatted phone number of the contact for the business or organization using the Tollfree number. + :param edit_reason: Describe why the verification is being edited. If the verification was rejected because of a technical issue, such as the website being down, and the issue has been resolved this parameter should be set to something similar to 'Website fixed'. :returns: The updated TollfreeVerificationInstance """ + data = values.of( { "BusinessName": business_name, @@ -549,13 +630,17 @@ async def update_async( "BusinessContactLastName": business_contact_last_name, "BusinessContactEmail": business_contact_email, "BusinessContactPhone": business_contact_phone, + "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( @@ -573,6 +658,7 @@ def __repr__(self) -> str: class TollfreeVerificationPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> TollfreeVerificationInstance: """ Build an instance of TollfreeVerificationInstance @@ -591,6 +677,7 @@ def __repr__(self) -> str: class TollfreeVerificationList(ListResource): + def __init__(self, version: Version): """ Initialize the TollfreeVerificationList @@ -652,11 +739,12 @@ def create( :param business_contact_first_name: The first name of the contact for the business or organization using the Tollfree number. :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 business_contact_phone: The E.164 formatted phone number of the contact for the business or organization using the Tollfree number. :param external_reference_id: An optional external reference ID supplied by customer and echoed back on status retrieval. :returns: The created TollfreeVerificationInstance """ + data = values.of( { "BusinessName": business_name, @@ -684,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) @@ -743,11 +834,12 @@ async def create_async( :param business_contact_first_name: The first name of the contact for the business or organization using the Tollfree number. :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 business_contact_phone: The E.164 formatted phone number of the contact for the business or organization using the Tollfree number. :param external_reference_id: An optional external reference ID supplied by customer and echoed back on status retrieval. :returns: The created TollfreeVerificationInstance """ + data = values.of( { "BusinessName": business_name, @@ -775,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) @@ -788,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]: @@ -799,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 @@ -812,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"], ) @@ -821,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]: @@ -832,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 @@ -845,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"], ) @@ -854,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]: @@ -864,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 @@ -877,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, ) @@ -886,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]: @@ -896,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 @@ -910,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, ) @@ -919,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, @@ -929,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 @@ -939,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, @@ -962,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 @@ -972,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 ba65e8b106..fe811e0c84 100644 --- a/twilio/rest/messaging/v1/usecase.py +++ b/twilio/rest/messaging/v1/usecase.py @@ -12,8 +12,8 @@ Do not edit the class manually. """ - 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 @@ -21,7 +21,6 @@ class UsecaseInstance(InstanceResource): - """ :ivar usecases: Human readable use case details (usecase, description and purpose) of Messaging Service Use Cases. """ @@ -29,7 +28,7 @@ class UsecaseInstance(InstanceResource): def __init__(self, version: Version, payload: Dict[str, Any]): super().__init__(version) - self.usecases: Optional[List[object]] = payload.get("usecases") + self.usecases: Optional[List[Dict[str, object]]] = payload.get("usecases") def __repr__(self) -> str: """ @@ -42,6 +41,7 @@ def __repr__(self) -> str: class UsecaseList(ListResource): + def __init__(self, version: Version): """ Initialize the UsecaseList @@ -57,9 +57,14 @@ def fetch(self) -> UsecaseInstance: """ Asynchronously fetch the UsecaseInstance + :returns: The fetched UsecaseInstance """ - payload = self._version.fetch(method="GET", uri=self._uri) + 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 UsecaseInstance(self._version, payload) @@ -67,9 +72,16 @@ async def fetch_async(self) -> UsecaseInstance: """ Asynchronously fetch the UsecaseInstance + :returns: The fetched UsecaseInstance """ - payload = await self._version.fetch_async(method="GET", uri=self._uri) + 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 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 30d6288565..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,28 +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..16bfaefe4e --- /dev/null +++ b/twilio/rest/messaging/v2/channels_sender.py @@ -0,0 +1,1206 @@ +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[Dict[str, object]] = payload.get("emails") + self.logo_url: Optional[str] = payload.get("logo_url") + self.vertical: Optional[str] = payload.get("vertical") + self.websites: Optional[Dict[str, object]] = payload.get("websites") + + def to_dict(self): + return { + "name": self.name, + "about": self.about, + "address": self.address, + "description": self.description, + "emails": self.emails, + "logo_url": self.logo_url, + "vertical": self.vertical, + "websites": self.websites, + } + + class MessagingV2ChannelsSenderProfileResponseEmails(object): + """ + :ivar email: + :ivar label: + """ + + 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 { + "": self.email, + "": self.label, + } + + class MessagingV2ChannelsSenderProfileResponseWebsites(object): + """ + :ivar website: + :ivar label: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.website: Optional[str] = payload.get("website") + self.label: Optional[str] = payload.get("label") + + def to_dict(self): + return { + "": self.website, + "": self.label, + } + + 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[Dict[str, object]] = payload.get("emails") + self.logo_url: Optional[str] = payload.get("logo_url") + self.vertical: Optional[str] = payload.get("vertical") + self.websites: Optional[Dict[str, object]] = payload.get("websites") + + def to_dict(self): + return { + "name": self.name, + "about": self.about, + "address": self.address, + "description": self.description, + "emails": self.emails, + "logo_url": self.logo_url, + "vertical": self.vertical, + "websites": self.websites, + } + + class MessagingV2ChannelsSenderProfileResponseEmails(object): + """ + :ivar email: + :ivar label: + """ + + 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 { + "": self.email, + "": self.label, + } + + class MessagingV2ChannelsSenderProfileResponseWebsites(object): + """ + :ivar website: + :ivar label: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.website: Optional[str] = payload.get("website") + self.label: Optional[str] = payload.get("label") + + def to_dict(self): + return { + "": self.website, + "": self.label, + } + + 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[Dict[str, object]] = payload.get("emails") + self.logo_url: Optional[str] = payload.get("logo_url") + self.vertical: Optional[str] = payload.get("vertical") + self.websites: Optional[Dict[str, object]] = payload.get("websites") + + def to_dict(self): + return { + "name": self.name, + "about": self.about, + "address": self.address, + "description": self.description, + "emails": self.emails, + "logo_url": self.logo_url, + "vertical": self.vertical, + "websites": self.websites, + } + + class MessagingV2ChannelsSenderProfileResponseEmails(object): + """ + :ivar email: + :ivar label: + """ + + 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 { + "": self.email, + "": self.label, + } + + class MessagingV2ChannelsSenderProfileResponseWebsites(object): + """ + :ivar website: + :ivar label: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.website: Optional[str] = payload.get("website") + self.label: Optional[str] = payload.get("label") + + def to_dict(self): + return { + "": self.website, + "": self.label, + } + + 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/__init__.py b/twilio/rest/microvisor/__init__.py deleted file mode 100644 index 6bf448b29c..0000000000 --- a/twilio/rest/microvisor/__init__.py +++ /dev/null @@ -1,43 +0,0 @@ -from warnings import warn - -from twilio.rest.microvisor.MicrovisorBase import MicrovisorBase -from twilio.rest.microvisor.v1.account_config import AccountConfigList -from twilio.rest.microvisor.v1.account_secret import AccountSecretList -from twilio.rest.microvisor.v1.app import AppList -from twilio.rest.microvisor.v1.device import DeviceList - - -class Microvisor(MicrovisorBase): - @property - def account_configs(self) -> AccountConfigList: - warn( - "account_configs is deprecated. Use v1.account_configs instead.", - DeprecationWarning, - stacklevel=2, - ) - return self.v1.account_configs - - @property - def account_secrets(self) -> AccountSecretList: - warn( - "account_secrets is deprecated. Use v1.account_secrets instead.", - DeprecationWarning, - stacklevel=2, - ) - return self.v1.account_secrets - - @property - def apps(self) -> AppList: - warn( - "apps is deprecated. Use v1.apps instead.", DeprecationWarning, stacklevel=2 - ) - return self.v1.apps - - @property - def devices(self) -> DeviceList: - warn( - "devices is deprecated. Use v1.devices instead.", - DeprecationWarning, - stacklevel=2, - ) - return self.v1.devices diff --git a/twilio/rest/microvisor/v1/__init__.py b/twilio/rest/microvisor/v1/__init__.py deleted file mode 100644 index d47ed845bd..0000000000 --- a/twilio/rest/microvisor/v1/__init__.py +++ /dev/null @@ -1,66 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Microvisor - 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.microvisor.v1.account_config import AccountConfigList -from twilio.rest.microvisor.v1.account_secret import AccountSecretList -from twilio.rest.microvisor.v1.app import AppList -from twilio.rest.microvisor.v1.device import DeviceList - - -class V1(Version): - def __init__(self, domain: Domain): - """ - Initialize the V1 version of Microvisor - - :param domain: The Twilio.microvisor domain - """ - super().__init__(domain, "v1") - self._account_configs: Optional[AccountConfigList] = None - self._account_secrets: Optional[AccountSecretList] = None - self._apps: Optional[AppList] = None - self._devices: Optional[DeviceList] = None - - @property - def account_configs(self) -> AccountConfigList: - if self._account_configs is None: - self._account_configs = AccountConfigList(self) - return self._account_configs - - @property - def account_secrets(self) -> AccountSecretList: - if self._account_secrets is None: - self._account_secrets = AccountSecretList(self) - return self._account_secrets - - @property - def apps(self) -> AppList: - if self._apps is None: - self._apps = AppList(self) - return self._apps - - @property - def devices(self) -> DeviceList: - if self._devices is None: - self._devices = DeviceList(self) - return self._devices - - def __repr__(self) -> str: - """ - Provide a friendly representation - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/microvisor/v1/app/app_manifest.py b/twilio/rest/microvisor/v1/app/app_manifest.py deleted file mode 100644 index dba0240e91..0000000000 --- a/twilio/rest/microvisor/v1/app/app_manifest.py +++ /dev/null @@ -1,188 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Microvisor - This is the public Twilio REST API. - - NOTE: This class is auto generated by OpenAPI Generator. - https://openapi-generator.tech - Do not edit the class manually. -""" - - -from typing import Any, Dict, Optional -from twilio.base.instance_context import InstanceContext -from twilio.base.instance_resource import InstanceResource -from twilio.base.list_resource import ListResource -from twilio.base.version import Version - - -class AppManifestInstance(InstanceResource): - - """ - :ivar app_sid: A 34-character string that uniquely identifies this App. - :ivar hash: App manifest hash represented as `hash_algorithm:hash_value`. - :ivar encoded_bytes: The base-64 encoded manifest - :ivar url: The absolute URL of this Manifest. - """ - - def __init__(self, version: Version, payload: Dict[str, Any], app_sid: str): - super().__init__(version) - - self.app_sid: Optional[str] = payload.get("app_sid") - self.hash: Optional[str] = payload.get("hash") - self.encoded_bytes: Optional[str] = payload.get("encoded_bytes") - self.url: Optional[str] = payload.get("url") - - self._solution = { - "app_sid": app_sid, - } - self._context: Optional[AppManifestContext] = None - - @property - def _proxy(self) -> "AppManifestContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: AppManifestContext for this AppManifestInstance - """ - if self._context is None: - self._context = AppManifestContext( - self._version, - app_sid=self._solution["app_sid"], - ) - return self._context - - def fetch(self) -> "AppManifestInstance": - """ - Fetch the AppManifestInstance - - - :returns: The fetched AppManifestInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "AppManifestInstance": - """ - Asynchronous coroutine to fetch the AppManifestInstance - - - :returns: The fetched AppManifestInstance - """ - 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 AppManifestContext(InstanceContext): - def __init__(self, version: Version, app_sid: str): - """ - Initialize the AppManifestContext - - :param version: Version that contains the resource - :param app_sid: A 34-character string that uniquely identifies this App. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "app_sid": app_sid, - } - self._uri = "/Apps/{app_sid}/Manifest".format(**self._solution) - - def fetch(self) -> AppManifestInstance: - """ - Fetch the AppManifestInstance - - - :returns: The fetched AppManifestInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return AppManifestInstance( - self._version, - payload, - app_sid=self._solution["app_sid"], - ) - - async def fetch_async(self) -> AppManifestInstance: - """ - Asynchronous coroutine to fetch the AppManifestInstance - - - :returns: The fetched AppManifestInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return AppManifestInstance( - self._version, - payload, - app_sid=self._solution["app_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 AppManifestList(ListResource): - def __init__(self, version: Version, app_sid: str): - """ - Initialize the AppManifestList - - :param version: Version that contains the resource - :param app_sid: A 34-character string that uniquely identifies this App. - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "app_sid": app_sid, - } - - def get(self) -> AppManifestContext: - """ - Constructs a AppManifestContext - - """ - return AppManifestContext(self._version, app_sid=self._solution["app_sid"]) - - def __call__(self) -> AppManifestContext: - """ - Constructs a AppManifestContext - - """ - return AppManifestContext(self._version, app_sid=self._solution["app_sid"]) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/microvisor/v1/device/__init__.py b/twilio/rest/microvisor/v1/device/__init__.py deleted file mode 100644 index 89e4e9f4c2..0000000000 --- a/twilio/rest/microvisor/v1/device/__init__.py +++ /dev/null @@ -1,553 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Microvisor - 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.microvisor.v1.device.device_config import DeviceConfigList -from twilio.rest.microvisor.v1.device.device_secret import DeviceSecretList - - -class DeviceInstance(InstanceResource): - - """ - :ivar sid: A 34-character string that uniquely identifies this Device. - :ivar unique_name: A developer-defined string that uniquely identifies the Device. This value must be unique for all Devices on this Account. The `unique_name` value may be used as an alternative to the `sid` in the URL path to address the resource. - :ivar account_sid: The unique SID identifier of the Account. - :ivar app: Information about the target App and the App reported by this Device. Contains the properties `target_sid`, `date_targeted`, `update_status` (one of `up-to-date`, `pending` and `error`), `update_error_code`, `reported_sid` and `date_reported`. - :ivar logging: Object specifying whether application logging is enabled for this Device. Contains the properties `enabled` and `date_expires`. - :ivar date_created: The date that this Device was created, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. - :ivar date_updated: The date that this Device was last updated, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. - :ivar url: The URL of this resource. - :ivar links: The absolute 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.unique_name: Optional[str] = payload.get("unique_name") - self.account_sid: Optional[str] = payload.get("account_sid") - self.app: Optional[Dict[str, object]] = payload.get("app") - self.logging: Optional[Dict[str, object]] = payload.get("logging") - 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[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, - sid=self._solution["sid"], - ) - return self._context - - 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, - unique_name: Union[str, object] = values.unset, - target_app: Union[str, object] = values.unset, - logging_enabled: Union[bool, object] = values.unset, - ) -> "DeviceInstance": - """ - Update the DeviceInstance - - :param unique_name: A unique and addressable name to be assigned to this Device by the developer. It may be used in place of the Device SID. - :param target_app: The SID or unique name of the App to be targeted to the Device. - :param logging_enabled: A Boolean flag specifying whether to enable application logging. Logs will be enabled or extended for 24 hours. - - :returns: The updated DeviceInstance - """ - return self._proxy.update( - unique_name=unique_name, - target_app=target_app, - logging_enabled=logging_enabled, - ) - - async def update_async( - self, - unique_name: Union[str, object] = values.unset, - target_app: Union[str, object] = values.unset, - logging_enabled: Union[bool, object] = values.unset, - ) -> "DeviceInstance": - """ - Asynchronous coroutine to update the DeviceInstance - - :param unique_name: A unique and addressable name to be assigned to this Device by the developer. It may be used in place of the Device SID. - :param target_app: The SID or unique name of the App to be targeted to the Device. - :param logging_enabled: A Boolean flag specifying whether to enable application logging. Logs will be enabled or extended for 24 hours. - - :returns: The updated DeviceInstance - """ - return await self._proxy.update_async( - unique_name=unique_name, - target_app=target_app, - logging_enabled=logging_enabled, - ) - - @property - def device_configs(self) -> DeviceConfigList: - """ - Access the device_configs - """ - return self._proxy.device_configs - - @property - def device_secrets(self) -> DeviceSecretList: - """ - Access the device_secrets - """ - return self._proxy.device_secrets - - 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, sid: str): - """ - Initialize the DeviceContext - - :param version: Version that contains the resource - :param sid: A 34-character string that uniquely identifies this Device. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "sid": sid, - } - self._uri = "/Devices/{sid}".format(**self._solution) - - self._device_configs: Optional[DeviceConfigList] = None - self._device_secrets: Optional[DeviceSecretList] = None - - 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, - 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, - sid=self._solution["sid"], - ) - - def update( - self, - unique_name: Union[str, object] = values.unset, - target_app: Union[str, object] = values.unset, - logging_enabled: Union[bool, object] = values.unset, - ) -> DeviceInstance: - """ - Update the DeviceInstance - - :param unique_name: A unique and addressable name to be assigned to this Device by the developer. It may be used in place of the Device SID. - :param target_app: The SID or unique name of the App to be targeted to the Device. - :param logging_enabled: A Boolean flag specifying whether to enable application logging. Logs will be enabled or extended for 24 hours. - - :returns: The updated DeviceInstance - """ - data = values.of( - { - "UniqueName": unique_name, - "TargetApp": target_app, - "LoggingEnabled": logging_enabled, - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return DeviceInstance(self._version, payload, sid=self._solution["sid"]) - - async def update_async( - self, - unique_name: Union[str, object] = values.unset, - target_app: Union[str, object] = values.unset, - logging_enabled: Union[bool, object] = values.unset, - ) -> DeviceInstance: - """ - Asynchronous coroutine to update the DeviceInstance - - :param unique_name: A unique and addressable name to be assigned to this Device by the developer. It may be used in place of the Device SID. - :param target_app: The SID or unique name of the App to be targeted to the Device. - :param logging_enabled: A Boolean flag specifying whether to enable application logging. Logs will be enabled or extended for 24 hours. - - :returns: The updated DeviceInstance - """ - data = values.of( - { - "UniqueName": unique_name, - "TargetApp": target_app, - "LoggingEnabled": logging_enabled, - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return DeviceInstance(self._version, payload, sid=self._solution["sid"]) - - @property - def device_configs(self) -> DeviceConfigList: - """ - Access the device_configs - """ - if self._device_configs is None: - self._device_configs = DeviceConfigList( - self._version, - self._solution["sid"], - ) - return self._device_configs - - @property - def device_secrets(self) -> DeviceSecretList: - """ - Access the device_secrets - """ - if self._device_secrets is None: - self._device_secrets = DeviceSecretList( - self._version, - self._solution["sid"], - ) - return self._device_secrets - - 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) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class DeviceList(ListResource): - def __init__(self, version: Version): - """ - Initialize the DeviceList - - :param version: Version that contains the resource - - """ - super().__init__(version) - - self._uri = "/Devices" - - def stream( - self, - 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 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[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 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[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 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[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 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, - ) -> DevicePage: - """ - Retrieve a single page of DeviceInstance 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 DeviceInstance - """ - data = values.of( - { - "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) - - 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, - ) -> DevicePage: - """ - Asynchronously retrieve a single page of DeviceInstance 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 DeviceInstance - """ - 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 DevicePage(self._version, response) - - 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) - - 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) - - def get(self, sid: str) -> DeviceContext: - """ - Constructs a DeviceContext - - :param sid: A 34-character string that uniquely identifies this Device. - """ - return DeviceContext(self._version, sid=sid) - - def __call__(self, sid: str) -> DeviceContext: - """ - Constructs a DeviceContext - - :param sid: A 34-character string that uniquely identifies this Device. - """ - return DeviceContext(self._version, sid=sid) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/microvisor/v1/device/device_config.py b/twilio/rest/microvisor/v1/device/device_config.py deleted file mode 100644 index a954727bf0..0000000000 --- a/twilio/rest/microvisor/v1/device/device_config.py +++ /dev/null @@ -1,589 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Microvisor - 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 DeviceConfigInstance(InstanceResource): - - """ - :ivar device_sid: A 34-character string that uniquely identifies the parent Device. - :ivar key: The config key; up to 100 characters. - :ivar value: The config value; up to 4096 characters. - :ivar date_updated: - :ivar url: The absolute URL of the Config. - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - device_sid: str, - key: Optional[str] = None, - ): - super().__init__(version) - - self.device_sid: Optional[str] = payload.get("device_sid") - self.key: Optional[str] = payload.get("key") - self.value: Optional[str] = payload.get("value") - self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("date_updated") - ) - self.url: Optional[str] = payload.get("url") - - self._solution = { - "device_sid": device_sid, - "key": key or self.key, - } - self._context: Optional[DeviceConfigContext] = None - - @property - def _proxy(self) -> "DeviceConfigContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: DeviceConfigContext for this DeviceConfigInstance - """ - if self._context is None: - self._context = DeviceConfigContext( - self._version, - device_sid=self._solution["device_sid"], - key=self._solution["key"], - ) - return self._context - - def delete(self) -> bool: - """ - Deletes the DeviceConfigInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the DeviceConfigInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def fetch(self) -> "DeviceConfigInstance": - """ - Fetch the DeviceConfigInstance - - - :returns: The fetched DeviceConfigInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "DeviceConfigInstance": - """ - Asynchronous coroutine to fetch the DeviceConfigInstance - - - :returns: The fetched DeviceConfigInstance - """ - return await self._proxy.fetch_async() - - def update(self, value: str) -> "DeviceConfigInstance": - """ - Update the DeviceConfigInstance - - :param value: The config value; up to 4096 characters. - - :returns: The updated DeviceConfigInstance - """ - return self._proxy.update( - value=value, - ) - - async def update_async(self, value: str) -> "DeviceConfigInstance": - """ - Asynchronous coroutine to update the DeviceConfigInstance - - :param value: The config value; up to 4096 characters. - - :returns: The updated DeviceConfigInstance - """ - return await self._proxy.update_async( - value=value, - ) - - 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 DeviceConfigContext(InstanceContext): - def __init__(self, version: Version, device_sid: str, key: str): - """ - Initialize the DeviceConfigContext - - :param version: Version that contains the resource - :param device_sid: A 34-character string that uniquely identifies the Device. - :param key: The config key; up to 100 characters. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "device_sid": device_sid, - "key": key, - } - self._uri = "/Devices/{device_sid}/Configs/{key}".format(**self._solution) - - def delete(self) -> bool: - """ - Deletes the DeviceConfigInstance - - - :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 DeviceConfigInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._version.delete_async( - method="DELETE", - uri=self._uri, - ) - - def fetch(self) -> DeviceConfigInstance: - """ - Fetch the DeviceConfigInstance - - - :returns: The fetched DeviceConfigInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return DeviceConfigInstance( - self._version, - payload, - device_sid=self._solution["device_sid"], - key=self._solution["key"], - ) - - async def fetch_async(self) -> DeviceConfigInstance: - """ - Asynchronous coroutine to fetch the DeviceConfigInstance - - - :returns: The fetched DeviceConfigInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return DeviceConfigInstance( - self._version, - payload, - device_sid=self._solution["device_sid"], - key=self._solution["key"], - ) - - def update(self, value: str) -> DeviceConfigInstance: - """ - Update the DeviceConfigInstance - - :param value: The config value; up to 4096 characters. - - :returns: The updated DeviceConfigInstance - """ - data = values.of( - { - "Value": value, - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return DeviceConfigInstance( - self._version, - payload, - device_sid=self._solution["device_sid"], - key=self._solution["key"], - ) - - async def update_async(self, value: str) -> DeviceConfigInstance: - """ - Asynchronous coroutine to update the DeviceConfigInstance - - :param value: The config value; up to 4096 characters. - - :returns: The updated DeviceConfigInstance - """ - data = values.of( - { - "Value": value, - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return DeviceConfigInstance( - self._version, - payload, - device_sid=self._solution["device_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 DeviceConfigPage(Page): - def get_instance(self, payload: Dict[str, Any]) -> DeviceConfigInstance: - """ - Build an instance of DeviceConfigInstance - - :param payload: Payload response from the API - """ - return DeviceConfigInstance( - self._version, payload, device_sid=self._solution["device_sid"] - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class DeviceConfigList(ListResource): - def __init__(self, version: Version, device_sid: str): - """ - Initialize the DeviceConfigList - - :param version: Version that contains the resource - :param device_sid: A 34-character string that uniquely identifies the Device. - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "device_sid": device_sid, - } - self._uri = "/Devices/{device_sid}/Configs".format(**self._solution) - - def create(self, key: str, value: str) -> DeviceConfigInstance: - """ - Create the DeviceConfigInstance - - :param key: The config key; up to 100 characters. - :param value: The config value; up to 4096 characters. - - :returns: The created DeviceConfigInstance - """ - data = values.of( - { - "Key": key, - "Value": value, - } - ) - - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) - - return DeviceConfigInstance( - self._version, payload, device_sid=self._solution["device_sid"] - ) - - async def create_async(self, key: str, value: str) -> DeviceConfigInstance: - """ - Asynchronously create the DeviceConfigInstance - - :param key: The config key; up to 100 characters. - :param value: The config value; up to 4096 characters. - - :returns: The created DeviceConfigInstance - """ - data = values.of( - { - "Key": key, - "Value": value, - } - ) - - payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, - ) - - return DeviceConfigInstance( - self._version, payload, device_sid=self._solution["device_sid"] - ) - - def stream( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[DeviceConfigInstance]: - """ - Streams DeviceConfigInstance 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[DeviceConfigInstance]: - """ - Asynchronously streams DeviceConfigInstance 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[DeviceConfigInstance]: - """ - Lists DeviceConfigInstance 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[DeviceConfigInstance]: - """ - Asynchronously lists DeviceConfigInstance 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, - ) -> DeviceConfigPage: - """ - Retrieve a single page of DeviceConfigInstance 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 DeviceConfigInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = self._version.page(method="GET", uri=self._uri, params=data) - return DeviceConfigPage(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, - ) -> DeviceConfigPage: - """ - Asynchronously retrieve a single page of DeviceConfigInstance 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 DeviceConfigInstance - """ - 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 DeviceConfigPage(self._version, response, self._solution) - - def get_page(self, target_url: str) -> DeviceConfigPage: - """ - Retrieve a specific page of DeviceConfigInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of DeviceConfigInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return DeviceConfigPage(self._version, response, self._solution) - - async def get_page_async(self, target_url: str) -> DeviceConfigPage: - """ - Asynchronously retrieve a specific page of DeviceConfigInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of DeviceConfigInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return DeviceConfigPage(self._version, response, self._solution) - - def get(self, key: str) -> DeviceConfigContext: - """ - Constructs a DeviceConfigContext - - :param key: The config key; up to 100 characters. - """ - return DeviceConfigContext( - self._version, device_sid=self._solution["device_sid"], key=key - ) - - def __call__(self, key: str) -> DeviceConfigContext: - """ - Constructs a DeviceConfigContext - - :param key: The config key; up to 100 characters. - """ - return DeviceConfigContext( - self._version, device_sid=self._solution["device_sid"], key=key - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/microvisor/v1/device/device_secret.py b/twilio/rest/microvisor/v1/device/device_secret.py deleted file mode 100644 index 7f2ee0eeb0..0000000000 --- a/twilio/rest/microvisor/v1/device/device_secret.py +++ /dev/null @@ -1,587 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Microvisor - 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 DeviceSecretInstance(InstanceResource): - - """ - :ivar device_sid: A 34-character string that uniquely identifies the parent Device. - :ivar key: The secret key; up to 100 characters. - :ivar date_rotated: - :ivar url: The absolute URL of the Secret. - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - device_sid: str, - key: Optional[str] = None, - ): - super().__init__(version) - - self.device_sid: Optional[str] = payload.get("device_sid") - self.key: Optional[str] = payload.get("key") - self.date_rotated: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("date_rotated") - ) - self.url: Optional[str] = payload.get("url") - - self._solution = { - "device_sid": device_sid, - "key": key or self.key, - } - self._context: Optional[DeviceSecretContext] = None - - @property - def _proxy(self) -> "DeviceSecretContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: DeviceSecretContext for this DeviceSecretInstance - """ - if self._context is None: - self._context = DeviceSecretContext( - self._version, - device_sid=self._solution["device_sid"], - key=self._solution["key"], - ) - return self._context - - def delete(self) -> bool: - """ - Deletes the DeviceSecretInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the DeviceSecretInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def fetch(self) -> "DeviceSecretInstance": - """ - Fetch the DeviceSecretInstance - - - :returns: The fetched DeviceSecretInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "DeviceSecretInstance": - """ - Asynchronous coroutine to fetch the DeviceSecretInstance - - - :returns: The fetched DeviceSecretInstance - """ - return await self._proxy.fetch_async() - - def update(self, value: str) -> "DeviceSecretInstance": - """ - Update the DeviceSecretInstance - - :param value: The secret value; up to 4096 characters. - - :returns: The updated DeviceSecretInstance - """ - return self._proxy.update( - value=value, - ) - - async def update_async(self, value: str) -> "DeviceSecretInstance": - """ - Asynchronous coroutine to update the DeviceSecretInstance - - :param value: The secret value; up to 4096 characters. - - :returns: The updated DeviceSecretInstance - """ - return await self._proxy.update_async( - value=value, - ) - - 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 DeviceSecretContext(InstanceContext): - def __init__(self, version: Version, device_sid: str, key: str): - """ - Initialize the DeviceSecretContext - - :param version: Version that contains the resource - :param device_sid: A 34-character string that uniquely identifies the Device. - :param key: The secret key; up to 100 characters. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "device_sid": device_sid, - "key": key, - } - self._uri = "/Devices/{device_sid}/Secrets/{key}".format(**self._solution) - - def delete(self) -> bool: - """ - Deletes the DeviceSecretInstance - - - :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 DeviceSecretInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._version.delete_async( - method="DELETE", - uri=self._uri, - ) - - def fetch(self) -> DeviceSecretInstance: - """ - Fetch the DeviceSecretInstance - - - :returns: The fetched DeviceSecretInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return DeviceSecretInstance( - self._version, - payload, - device_sid=self._solution["device_sid"], - key=self._solution["key"], - ) - - async def fetch_async(self) -> DeviceSecretInstance: - """ - Asynchronous coroutine to fetch the DeviceSecretInstance - - - :returns: The fetched DeviceSecretInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return DeviceSecretInstance( - self._version, - payload, - device_sid=self._solution["device_sid"], - key=self._solution["key"], - ) - - def update(self, value: str) -> DeviceSecretInstance: - """ - Update the DeviceSecretInstance - - :param value: The secret value; up to 4096 characters. - - :returns: The updated DeviceSecretInstance - """ - data = values.of( - { - "Value": value, - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return DeviceSecretInstance( - self._version, - payload, - device_sid=self._solution["device_sid"], - key=self._solution["key"], - ) - - async def update_async(self, value: str) -> DeviceSecretInstance: - """ - Asynchronous coroutine to update the DeviceSecretInstance - - :param value: The secret value; up to 4096 characters. - - :returns: The updated DeviceSecretInstance - """ - data = values.of( - { - "Value": value, - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return DeviceSecretInstance( - self._version, - payload, - device_sid=self._solution["device_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 DeviceSecretPage(Page): - def get_instance(self, payload: Dict[str, Any]) -> DeviceSecretInstance: - """ - Build an instance of DeviceSecretInstance - - :param payload: Payload response from the API - """ - return DeviceSecretInstance( - self._version, payload, device_sid=self._solution["device_sid"] - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class DeviceSecretList(ListResource): - def __init__(self, version: Version, device_sid: str): - """ - Initialize the DeviceSecretList - - :param version: Version that contains the resource - :param device_sid: A 34-character string that uniquely identifies the Device. - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "device_sid": device_sid, - } - self._uri = "/Devices/{device_sid}/Secrets".format(**self._solution) - - def create(self, key: str, value: str) -> DeviceSecretInstance: - """ - Create the DeviceSecretInstance - - :param key: The secret key; up to 100 characters. - :param value: The secret value; up to 4096 characters. - - :returns: The created DeviceSecretInstance - """ - data = values.of( - { - "Key": key, - "Value": value, - } - ) - - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) - - return DeviceSecretInstance( - self._version, payload, device_sid=self._solution["device_sid"] - ) - - async def create_async(self, key: str, value: str) -> DeviceSecretInstance: - """ - Asynchronously create the DeviceSecretInstance - - :param key: The secret key; up to 100 characters. - :param value: The secret value; up to 4096 characters. - - :returns: The created DeviceSecretInstance - """ - data = values.of( - { - "Key": key, - "Value": value, - } - ) - - payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, - ) - - return DeviceSecretInstance( - self._version, payload, device_sid=self._solution["device_sid"] - ) - - def stream( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[DeviceSecretInstance]: - """ - Streams DeviceSecretInstance 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[DeviceSecretInstance]: - """ - Asynchronously streams DeviceSecretInstance 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[DeviceSecretInstance]: - """ - Lists DeviceSecretInstance 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[DeviceSecretInstance]: - """ - Asynchronously lists DeviceSecretInstance 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, - ) -> DeviceSecretPage: - """ - Retrieve a single page of DeviceSecretInstance 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 DeviceSecretInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = self._version.page(method="GET", uri=self._uri, params=data) - return DeviceSecretPage(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, - ) -> DeviceSecretPage: - """ - Asynchronously retrieve a single page of DeviceSecretInstance 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 DeviceSecretInstance - """ - 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 DeviceSecretPage(self._version, response, self._solution) - - def get_page(self, target_url: str) -> DeviceSecretPage: - """ - Retrieve a specific page of DeviceSecretInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of DeviceSecretInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return DeviceSecretPage(self._version, response, self._solution) - - async def get_page_async(self, target_url: str) -> DeviceSecretPage: - """ - Asynchronously retrieve a specific page of DeviceSecretInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of DeviceSecretInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return DeviceSecretPage(self._version, response, self._solution) - - def get(self, key: str) -> DeviceSecretContext: - """ - Constructs a DeviceSecretContext - - :param key: The secret key; up to 100 characters. - """ - return DeviceSecretContext( - self._version, device_sid=self._solution["device_sid"], key=key - ) - - def __call__(self, key: str) -> DeviceSecretContext: - """ - Constructs a DeviceSecretContext - - :param key: The secret key; up to 100 characters. - """ - return DeviceSecretContext( - self._version, device_sid=self._solution["device_sid"], key=key - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/monitor/MonitorBase.py b/twilio/rest/monitor/MonitorBase.py index d63580761f..4c5c6ebcd6 100644 --- a/twilio/rest/monitor/MonitorBase.py +++ b/twilio/rest/monitor/MonitorBase.py @@ -17,6 +17,7 @@ class MonitorBase(Domain): + def __init__(self, twilio: Client): """ Initialize the Monitor Domain diff --git a/twilio/rest/monitor/v1/__init__.py b/twilio/rest/monitor/v1/__init__.py index fcf06738fa..e892612b3b 100644 --- a/twilio/rest/monitor/v1/__init__.py +++ b/twilio/rest/monitor/v1/__init__.py @@ -20,6 +20,7 @@ class V1(Version): + def __init__(self, domain: Domain): """ Initialize the V1 version of Monitor diff --git a/twilio/rest/monitor/v1/alert.py b/twilio/rest/monitor/v1/alert.py index b3c44374e5..829e633643 100644 --- a/twilio/rest/monitor/v1/alert.py +++ b/twilio/rest/monitor/v1/alert.py @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class AlertInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Alert resource. :ivar alert_text: The text of the alert. @@ -127,6 +125,7 @@ def __repr__(self) -> str: class AlertContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the AlertContext @@ -150,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, @@ -169,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( @@ -191,6 +194,7 @@ def __repr__(self) -> str: class AlertPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> AlertInstance: """ Build an instance of AlertInstance @@ -209,6 +213,7 @@ def __repr__(self) -> str: class AlertList(ListResource): + def __init__(self, version: Version): """ Initialize the AlertList @@ -396,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( @@ -432,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 63829c43e0..61450c872c 100644 --- a/twilio/rest/monitor/v1/event.py +++ b/twilio/rest/monitor/v1/event.py @@ -12,7 +12,6 @@ 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 @@ -24,10 +23,9 @@ 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. @@ -113,6 +111,7 @@ def __repr__(self) -> str: class EventContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the EventContext @@ -136,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, @@ -155,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( @@ -177,6 +180,7 @@ def __repr__(self) -> str: class EventPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> EventInstance: """ Build an instance of EventInstance @@ -195,6 +199,7 @@ def __repr__(self) -> str: class EventList(ListResource): + def __init__(self, version: Version): """ Initialize the EventList @@ -427,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( @@ -472,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/NotifyBase.py b/twilio/rest/notify/NotifyBase.py index d8a79bed63..2772ed0959 100644 --- a/twilio/rest/notify/NotifyBase.py +++ b/twilio/rest/notify/NotifyBase.py @@ -17,6 +17,7 @@ class NotifyBase(Domain): + def __init__(self, twilio: Client): """ Initialize the Notify Domain diff --git a/twilio/rest/notify/v1/__init__.py b/twilio/rest/notify/v1/__init__.py index 91942a4f73..90cab95028 100644 --- a/twilio/rest/notify/v1/__init__.py +++ b/twilio/rest/notify/v1/__init__.py @@ -20,6 +20,7 @@ class V1(Version): + def __init__(self, domain: Domain): """ Initialize the V1 version of Notify diff --git a/twilio/rest/notify/v1/credential.py b/twilio/rest/notify/v1/credential.py index 2b1efcf82a..9ca59927cb 100644 --- a/twilio/rest/notify/v1/credential.py +++ b/twilio/rest/notify/v1/credential.py @@ -12,10 +12,9 @@ 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 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 @@ -24,6 +23,7 @@ class CredentialInstance(InstanceResource): + class PushService(object): GCM = "gcm" APN = "apn" @@ -185,6 +185,7 @@ def __repr__(self) -> str: class CredentialContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the CredentialContext @@ -207,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: """ @@ -219,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: @@ -232,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, @@ -251,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( @@ -283,21 +290,25 @@ def update( :returns: The updated CredentialInstance """ + data = values.of( { "FriendlyName": friendly_name, "Certificate": certificate, "PrivateKey": private_key, - "Sandbox": sandbox, + "Sandbox": serialize.boolean_to_string(sandbox), "ApiKey": api_key, "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"]) @@ -323,21 +334,25 @@ async def update_async( :returns: The updated CredentialInstance """ + data = values.of( { "FriendlyName": friendly_name, "Certificate": certificate, "PrivateKey": private_key, - "Sandbox": sandbox, + "Sandbox": serialize.boolean_to_string(sandbox), "ApiKey": api_key, "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"]) @@ -353,6 +368,7 @@ def __repr__(self) -> str: class CredentialPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> CredentialInstance: """ Build an instance of CredentialInstance @@ -371,6 +387,7 @@ def __repr__(self) -> str: class CredentialList(ListResource): + def __init__(self, version: Version): """ Initialize the CredentialList @@ -405,22 +422,26 @@ def create( :returns: The created CredentialInstance """ + data = values.of( { "Type": type, "FriendlyName": friendly_name, "Certificate": certificate, "PrivateKey": private_key, - "Sandbox": sandbox, + "Sandbox": serialize.boolean_to_string(sandbox), "ApiKey": api_key, "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) @@ -448,22 +469,26 @@ async def create_async( :returns: The created CredentialInstance """ + data = values.of( { "Type": type, "FriendlyName": friendly_name, "Certificate": certificate, "PrivateKey": private_key, - "Sandbox": sandbox, + "Sandbox": serialize.boolean_to_string(sandbox), "ApiKey": api_key, "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) @@ -595,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( @@ -622,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 fa07045470..e097e69a67 100644 --- a/twilio/rest/notify/v1/service/__init__.py +++ b/twilio/rest/notify/v1/service/__init__.py @@ -12,10 +12,9 @@ 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 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 @@ -26,7 +25,6 @@ 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. @@ -36,7 +34,7 @@ class ServiceInstance(InstanceResource): :ivar apn_credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for APN Bindings. :ivar gcm_credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for GCM Bindings. :ivar fcm_credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for FCM Bindings. - :ivar messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/sms/send-messages#messaging-services) to use for SMS Bindings. In order to send SMS notifications this parameter has to be set. + :ivar messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/sms/quickstart#messaging-services) to use for SMS Bindings. In order to send SMS notifications this parameter has to be set. :ivar facebook_messenger_page_id: Deprecated. :ivar default_apn_notification_protocol_version: The protocol version to use for sending APNS notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource. :ivar default_gcm_notification_protocol_version: The protocol version to use for sending GCM notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource. @@ -171,7 +169,7 @@ def update( :param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long. :param apn_credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for APN Bindings. :param gcm_credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for GCM Bindings. - :param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/sms/send-messages#messaging-services) to use for SMS Bindings. This parameter must be set in order to send SMS notifications. + :param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/sms/quickstart#messaging-services) to use for SMS Bindings. This parameter must be set in order to send SMS notifications. :param facebook_messenger_page_id: Deprecated. :param default_apn_notification_protocol_version: The protocol version to use for sending APNS notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource. :param default_gcm_notification_protocol_version: The protocol version to use for sending GCM notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource. @@ -225,7 +223,7 @@ async def update_async( :param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long. :param apn_credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for APN Bindings. :param gcm_credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for GCM Bindings. - :param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/sms/send-messages#messaging-services) to use for SMS Bindings. This parameter must be set in order to send SMS notifications. + :param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/sms/quickstart#messaging-services) to use for SMS Bindings. This parameter must be set in order to send SMS notifications. :param facebook_messenger_page_id: Deprecated. :param default_apn_notification_protocol_version: The protocol version to use for sending APNS notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource. :param default_gcm_notification_protocol_version: The protocol version to use for sending GCM notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource. @@ -281,6 +279,7 @@ def __repr__(self) -> str: class ServiceContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the ServiceContext @@ -306,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: """ @@ -318,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: @@ -331,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, @@ -350,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( @@ -384,7 +389,7 @@ def update( :param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long. :param apn_credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for APN Bindings. :param gcm_credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for GCM Bindings. - :param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/sms/send-messages#messaging-services) to use for SMS Bindings. This parameter must be set in order to send SMS notifications. + :param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/sms/quickstart#messaging-services) to use for SMS Bindings. This parameter must be set in order to send SMS notifications. :param facebook_messenger_page_id: Deprecated. :param default_apn_notification_protocol_version: The protocol version to use for sending APNS notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource. :param default_gcm_notification_protocol_version: The protocol version to use for sending GCM notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource. @@ -398,6 +403,7 @@ def update( :returns: The updated ServiceInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -409,18 +415,23 @@ def update( "DefaultGcmNotificationProtocolVersion": default_gcm_notification_protocol_version, "FcmCredentialSid": fcm_credential_sid, "DefaultFcmNotificationProtocolVersion": default_fcm_notification_protocol_version, - "LogEnabled": log_enabled, + "LogEnabled": serialize.boolean_to_string(log_enabled), "AlexaSkillId": alexa_skill_id, "DefaultAlexaNotificationProtocolVersion": default_alexa_notification_protocol_version, "DeliveryCallbackUrl": delivery_callback_url, - "DeliveryCallbackEnabled": delivery_callback_enabled, + "DeliveryCallbackEnabled": serialize.boolean_to_string( + delivery_callback_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"]) @@ -448,7 +459,7 @@ async def update_async( :param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long. :param apn_credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for APN Bindings. :param gcm_credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for GCM Bindings. - :param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/sms/send-messages#messaging-services) to use for SMS Bindings. This parameter must be set in order to send SMS notifications. + :param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/sms/quickstart#messaging-services) to use for SMS Bindings. This parameter must be set in order to send SMS notifications. :param facebook_messenger_page_id: Deprecated. :param default_apn_notification_protocol_version: The protocol version to use for sending APNS notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource. :param default_gcm_notification_protocol_version: The protocol version to use for sending GCM notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource. @@ -462,6 +473,7 @@ async def update_async( :returns: The updated ServiceInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -473,18 +485,23 @@ async def update_async( "DefaultGcmNotificationProtocolVersion": default_gcm_notification_protocol_version, "FcmCredentialSid": fcm_credential_sid, "DefaultFcmNotificationProtocolVersion": default_fcm_notification_protocol_version, - "LogEnabled": log_enabled, + "LogEnabled": serialize.boolean_to_string(log_enabled), "AlexaSkillId": alexa_skill_id, "DefaultAlexaNotificationProtocolVersion": default_alexa_notification_protocol_version, "DeliveryCallbackUrl": delivery_callback_url, - "DeliveryCallbackEnabled": delivery_callback_enabled, + "DeliveryCallbackEnabled": serialize.boolean_to_string( + delivery_callback_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"]) @@ -524,6 +541,7 @@ def __repr__(self) -> str: class ServicePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ServiceInstance: """ Build an instance of ServiceInstance @@ -542,6 +560,7 @@ def __repr__(self) -> str: class ServiceList(ListResource): + def __init__(self, version: Version): """ Initialize the ServiceList @@ -576,7 +595,7 @@ def create( :param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long. :param apn_credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for APN Bindings. :param gcm_credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for GCM Bindings. - :param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/sms/send-messages#messaging-services) to use for SMS Bindings. This parameter must be set in order to send SMS notifications. + :param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/sms/quickstart#messaging-services) to use for SMS Bindings. This parameter must be set in order to send SMS notifications. :param facebook_messenger_page_id: Deprecated. :param default_apn_notification_protocol_version: The protocol version to use for sending APNS notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource. :param default_gcm_notification_protocol_version: The protocol version to use for sending GCM notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource. @@ -590,6 +609,7 @@ def create( :returns: The created ServiceInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -601,18 +621,23 @@ def create( "DefaultGcmNotificationProtocolVersion": default_gcm_notification_protocol_version, "FcmCredentialSid": fcm_credential_sid, "DefaultFcmNotificationProtocolVersion": default_fcm_notification_protocol_version, - "LogEnabled": log_enabled, + "LogEnabled": serialize.boolean_to_string(log_enabled), "AlexaSkillId": alexa_skill_id, "DefaultAlexaNotificationProtocolVersion": default_alexa_notification_protocol_version, "DeliveryCallbackUrl": delivery_callback_url, - "DeliveryCallbackEnabled": delivery_callback_enabled, + "DeliveryCallbackEnabled": serialize.boolean_to_string( + delivery_callback_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) @@ -640,7 +665,7 @@ async def create_async( :param friendly_name: A descriptive string that you create to describe the resource. It can be up to 64 characters long. :param apn_credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for APN Bindings. :param gcm_credential_sid: The SID of the [Credential](https://www.twilio.com/docs/notify/api/credential-resource) to use for GCM Bindings. - :param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/sms/send-messages#messaging-services) to use for SMS Bindings. This parameter must be set in order to send SMS notifications. + :param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/sms/quickstart#messaging-services) to use for SMS Bindings. This parameter must be set in order to send SMS notifications. :param facebook_messenger_page_id: Deprecated. :param default_apn_notification_protocol_version: The protocol version to use for sending APNS notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource. :param default_gcm_notification_protocol_version: The protocol version to use for sending GCM notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](https://www.twilio.com/docs/notify/api/binding-resource) resource. @@ -654,6 +679,7 @@ async def create_async( :returns: The created ServiceInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -665,18 +691,23 @@ async def create_async( "DefaultGcmNotificationProtocolVersion": default_gcm_notification_protocol_version, "FcmCredentialSid": fcm_credential_sid, "DefaultFcmNotificationProtocolVersion": default_fcm_notification_protocol_version, - "LogEnabled": log_enabled, + "LogEnabled": serialize.boolean_to_string(log_enabled), "AlexaSkillId": alexa_skill_id, "DefaultAlexaNotificationProtocolVersion": default_alexa_notification_protocol_version, "DeliveryCallbackUrl": delivery_callback_url, - "DeliveryCallbackEnabled": delivery_callback_enabled, + "DeliveryCallbackEnabled": serialize.boolean_to_string( + delivery_callback_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) @@ -823,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( @@ -853,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 dba36be720..33b1a4aac0 100644 --- a/twilio/rest/notify/v1/service/binding.py +++ b/twilio/rest/notify/v1/service/binding.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import date, datetime from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import deserialize, serialize, values @@ -24,6 +23,7 @@ class BindingInstance(InstanceResource): + class BindingType(object): APN = "apn" GCM = "gcm" @@ -148,6 +148,7 @@ def __repr__(self) -> str: class BindingContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, sid: str): """ Initialize the BindingContext @@ -172,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: """ @@ -184,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: @@ -197,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, @@ -217,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( @@ -240,6 +247,7 @@ def __repr__(self) -> str: class BindingPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> BindingInstance: """ Build an instance of BindingInstance @@ -260,6 +268,7 @@ def __repr__(self) -> str: class BindingList(ListResource): + def __init__(self, version: Version, service_sid: str): """ Initialize the BindingList @@ -299,6 +308,7 @@ def create( :returns: The created BindingInstance """ + data = values.of( { "Identity": identity, @@ -310,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( @@ -344,6 +357,7 @@ async def create_async( :returns: The created BindingInstance """ + data = values.of( { "Identity": identity, @@ -355,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( @@ -557,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( @@ -596,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 980dbe633c..4d228e864f 100644 --- a/twilio/rest/notify/v1/service/notification.py +++ b/twilio/rest/notify/v1/service/notification.py @@ -12,7 +12,6 @@ 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 @@ -23,6 +22,7 @@ class NotificationInstance(InstanceResource): + class Priority(object): HIGH = "high" LOW = "low" @@ -95,6 +95,7 @@ def __repr__(self) -> str: class NotificationList(ListResource): + def __init__(self, version: Version, service_sid: str): """ Initialize the NotificationList @@ -144,7 +145,7 @@ def create( :param data: The custom key-value pairs of the notification's payload. For FCM and GCM, this value translates to `data` in the FCM and GCM payloads. FCM and GCM [reserve certain keys](https://firebase.google.com/docs/cloud-messaging/http-server-ref) that cannot be used in those channels. For APNS, attributes of `data` are inserted into the APNS payload as custom properties outside of the `aps` dictionary. In all channels, we reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed and are rejected as 400 Bad request with no delivery attempted. For SMS, this parameter is not supported and is omitted from deliveries to those channels. :param apn: The APNS-specific payload that overrides corresponding attributes in the generic payload for APNS Bindings. This property maps to the APNS `Payload` item, therefore the `aps` key must be used to change standard attributes. Adds custom key-value pairs to the root of the dictionary. See the [APNS documentation](https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html) for more details. We reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed. :param gcm: The GCM-specific payload that overrides corresponding attributes in the generic payload for GCM Bindings. This property maps to the root JSON dictionary. See the [GCM documentation](https://firebase.google.com/docs/cloud-messaging/http-server-ref) for more details. Target parameters `to`, `registration_ids`, and `notification_key` are not allowed. We reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed. GCM also [reserves certain keys](https://firebase.google.com/docs/cloud-messaging/http-server-ref). - :param sms: The SMS-specific payload that overrides corresponding attributes in the generic payload for SMS Bindings. Each attribute in this value maps to the corresponding `form` parameter of the Twilio [Message](https://www.twilio.com/docs/sms/send-messages) resource. These parameters of the Message resource are supported in snake case format: `body`, `media_urls`, `status_callback`, and `max_price`. The `status_callback` parameter overrides the corresponding parameter in the messaging service, if configured. The `media_urls` property expects a JSON array. + :param sms: The SMS-specific payload that overrides corresponding attributes in the generic payload for SMS Bindings. Each attribute in this value maps to the corresponding `form` parameter of the Twilio [Message](https://www.twilio.com/docs/sms/quickstart) resource. These parameters of the Message resource are supported in snake case format: `body`, `media_urls`, `status_callback`, and `max_price`. The `status_callback` parameter overrides the corresponding parameter in the messaging service, if configured. The `media_urls` property expects a JSON array. :param facebook_messenger: Deprecated. :param fcm: The FCM-specific payload that overrides corresponding attributes in the generic payload for FCM Bindings. This property maps to the root JSON dictionary. See the [FCM documentation](https://firebase.google.com/docs/cloud-messaging/http-server-ref#downstream) for more details. Target parameters `to`, `registration_ids`, `condition`, and `notification_key` are not allowed in this parameter. We reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed. FCM also [reserves certain keys](https://firebase.google.com/docs/cloud-messaging/http-server-ref), which cannot be used in that channel. :param segment: The Segment resource is deprecated. Use the `tag` parameter, instead. @@ -156,6 +157,7 @@ def create( :returns: The created NotificationInstance """ + data = values.of( { "Body": body, @@ -178,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( @@ -222,7 +227,7 @@ async def create_async( :param data: The custom key-value pairs of the notification's payload. For FCM and GCM, this value translates to `data` in the FCM and GCM payloads. FCM and GCM [reserve certain keys](https://firebase.google.com/docs/cloud-messaging/http-server-ref) that cannot be used in those channels. For APNS, attributes of `data` are inserted into the APNS payload as custom properties outside of the `aps` dictionary. In all channels, we reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed and are rejected as 400 Bad request with no delivery attempted. For SMS, this parameter is not supported and is omitted from deliveries to those channels. :param apn: The APNS-specific payload that overrides corresponding attributes in the generic payload for APNS Bindings. This property maps to the APNS `Payload` item, therefore the `aps` key must be used to change standard attributes. Adds custom key-value pairs to the root of the dictionary. See the [APNS documentation](https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html) for more details. We reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed. :param gcm: The GCM-specific payload that overrides corresponding attributes in the generic payload for GCM Bindings. This property maps to the root JSON dictionary. See the [GCM documentation](https://firebase.google.com/docs/cloud-messaging/http-server-ref) for more details. Target parameters `to`, `registration_ids`, and `notification_key` are not allowed. We reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed. GCM also [reserves certain keys](https://firebase.google.com/docs/cloud-messaging/http-server-ref). - :param sms: The SMS-specific payload that overrides corresponding attributes in the generic payload for SMS Bindings. Each attribute in this value maps to the corresponding `form` parameter of the Twilio [Message](https://www.twilio.com/docs/sms/send-messages) resource. These parameters of the Message resource are supported in snake case format: `body`, `media_urls`, `status_callback`, and `max_price`. The `status_callback` parameter overrides the corresponding parameter in the messaging service, if configured. The `media_urls` property expects a JSON array. + :param sms: The SMS-specific payload that overrides corresponding attributes in the generic payload for SMS Bindings. Each attribute in this value maps to the corresponding `form` parameter of the Twilio [Message](https://www.twilio.com/docs/sms/quickstart) resource. These parameters of the Message resource are supported in snake case format: `body`, `media_urls`, `status_callback`, and `max_price`. The `status_callback` parameter overrides the corresponding parameter in the messaging service, if configured. The `media_urls` property expects a JSON array. :param facebook_messenger: Deprecated. :param fcm: The FCM-specific payload that overrides corresponding attributes in the generic payload for FCM Bindings. This property maps to the root JSON dictionary. See the [FCM documentation](https://firebase.google.com/docs/cloud-messaging/http-server-ref#downstream) for more details. Target parameters `to`, `registration_ids`, `condition`, and `notification_key` are not allowed in this parameter. We reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed. FCM also [reserves certain keys](https://firebase.google.com/docs/cloud-messaging/http-server-ref), which cannot be used in that channel. :param segment: The Segment resource is deprecated. Use the `tag` parameter, instead. @@ -234,6 +239,7 @@ async def create_async( :returns: The created NotificationInstance """ + data = values.of( { "Body": body, @@ -256,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/NumbersBase.py b/twilio/rest/numbers/NumbersBase.py index db8cb4b5d6..7b9e08638f 100644 --- a/twilio/rest/numbers/NumbersBase.py +++ b/twilio/rest/numbers/NumbersBase.py @@ -13,10 +13,12 @@ from twilio.base.domain import Domain from twilio.rest import Client +from twilio.rest.numbers.v1 import V1 from twilio.rest.numbers.v2 import V2 class NumbersBase(Domain): + def __init__(self, twilio: Client): """ Initialize the Numbers Domain @@ -24,8 +26,18 @@ def __init__(self, twilio: Client): :returns: Domain for Numbers """ super().__init__(twilio, "https://numbers.twilio.com") + self._v1: Optional[V1] = None self._v2: Optional[V2] = None + @property + def v1(self) -> V1: + """ + :returns: Versions v1 of Numbers + """ + if self._v1 is None: + self._v1 = V1(self) + return self._v1 + @property def v2(self) -> V2: """ diff --git a/twilio/rest/numbers/v1/__init__.py b/twilio/rest/numbers/v1/__init__.py new file mode 100644 index 0000000000..043364c3d5 --- /dev/null +++ b/twilio/rest/numbers/v1/__init__.py @@ -0,0 +1,135 @@ +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 Optional +from twilio.base.version import Version +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_port_in import PortingPortInList +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): + + def __init__(self, domain: Domain): + """ + Initialize the V1 version of Numbers + + :param domain: The Twilio.numbers domain + """ + super().__init__(domain, "v1") + self._bulk_eligibilities: Optional[BulkEligibilityList] = None + self._eligibilities: Optional[EligibilityList] = None + self._porting_port_ins: Optional[PortingPortInList] = 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: + if self._bulk_eligibilities is None: + self._bulk_eligibilities = BulkEligibilityList(self) + return self._bulk_eligibilities + + @property + def eligibilities(self) -> EligibilityList: + if self._eligibilities is None: + self._eligibilities = EligibilityList(self) + return self._eligibilities + + @property + def porting_port_ins(self) -> PortingPortInList: + if self._porting_port_ins is None: + self._porting_port_ins = PortingPortInList(self) + return self._porting_port_ins + + @property + 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: + if self._porting_portabilities is None: + 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 + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/numbers/v1/bulk_eligibility.py b/twilio/rest/numbers/v1/bulk_eligibility.py new file mode 100644 index 0000000000..766032f7c4 --- /dev/null +++ b/twilio/rest/numbers/v1/bulk_eligibility.py @@ -0,0 +1,257 @@ +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, 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 BulkEligibilityInstance(InstanceResource): + """ + :ivar request_id: The SID of the bulk eligibility check that you want to know about. + :ivar url: This is the url of the request that you're trying to reach out to locate the resource. + :ivar results: The result set that contains the eligibility check response for each requested number, each result has at least the following attributes: phone_number: The requested phone number ,hosting_account_sid: The account sid where the phone number will be hosted, country: Phone number’s country, eligibility_status: Indicates the eligibility status of the PN (Eligible/Ineligible), eligibility_sub_status: Indicates the sub status of the eligibility , ineligibility_reason: Reason for number's ineligibility (if applicable), next_step: Suggested next step in the hosting process based on the eligibility status. + :ivar friendly_name: This is the string that you assigned as a friendly name for describing the eligibility check request. + :ivar status: This is the status of the bulk eligibility check request. (Example: COMPLETE, IN_PROGRESS) + :ivar date_created: + :ivar date_completed: + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + request_id: Optional[str] = None, + ): + super().__init__(version) + + self.request_id: Optional[str] = payload.get("request_id") + self.url: Optional[str] = payload.get("url") + self.results: Optional[List[Dict[str, object]]] = payload.get("results") + self.friendly_name: Optional[str] = payload.get("friendly_name") + self.status: Optional[str] = payload.get("status") + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_created") + ) + self.date_completed: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_completed") + ) + + self._solution = { + "request_id": request_id or self.request_id, + } + self._context: Optional[BulkEligibilityContext] = None + + @property + def _proxy(self) -> "BulkEligibilityContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: BulkEligibilityContext for this BulkEligibilityInstance + """ + if self._context is None: + self._context = BulkEligibilityContext( + self._version, + request_id=self._solution["request_id"], + ) + return self._context + + def fetch(self) -> "BulkEligibilityInstance": + """ + Fetch the BulkEligibilityInstance + + + :returns: The fetched BulkEligibilityInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "BulkEligibilityInstance": + """ + Asynchronous coroutine to fetch the BulkEligibilityInstance + + + :returns: The fetched BulkEligibilityInstance + """ + 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 BulkEligibilityContext(InstanceContext): + + def __init__(self, version: Version, request_id: str): + """ + Initialize the BulkEligibilityContext + + :param version: Version that contains the resource + :param request_id: The SID of the bulk eligibility check that you want to know about. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "request_id": request_id, + } + self._uri = "/HostedNumber/Eligibility/Bulk/{request_id}".format( + **self._solution + ) + + def fetch(self) -> BulkEligibilityInstance: + """ + Fetch the BulkEligibilityInstance + + + :returns: The fetched BulkEligibilityInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return BulkEligibilityInstance( + self._version, + payload, + request_id=self._solution["request_id"], + ) + + async def fetch_async(self) -> BulkEligibilityInstance: + """ + Asynchronous coroutine to fetch the BulkEligibilityInstance + + + :returns: The fetched BulkEligibilityInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + return BulkEligibilityInstance( + self._version, + payload, + request_id=self._solution["request_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 BulkEligibilityList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the BulkEligibilityList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/HostedNumber/Eligibility/Bulk" + + def create( + self, body: Union[object, object] = values.unset + ) -> BulkEligibilityInstance: + """ + Create the BulkEligibilityInstance + + :param body: + + :returns: The created BulkEligibilityInstance + """ + 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 BulkEligibilityInstance(self._version, payload) + + async def create_async( + self, body: Union[object, object] = values.unset + ) -> BulkEligibilityInstance: + """ + Asynchronously create the BulkEligibilityInstance + + :param body: + + :returns: The created BulkEligibilityInstance + """ + 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 BulkEligibilityInstance(self._version, payload) + + def get(self, request_id: str) -> BulkEligibilityContext: + """ + Constructs a BulkEligibilityContext + + :param request_id: The SID of the bulk eligibility check that you want to know about. + """ + return BulkEligibilityContext(self._version, request_id=request_id) + + def __call__(self, request_id: str) -> BulkEligibilityContext: + """ + Constructs a BulkEligibilityContext + + :param request_id: The SID of the bulk eligibility check that you want to know about. + """ + return BulkEligibilityContext(self._version, request_id=request_id) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/numbers/v1/eligibility.py b/twilio/rest/numbers/v1/eligibility.py new file mode 100644 index 0000000000..8c5af0ac64 --- /dev/null +++ b/twilio/rest/numbers/v1/eligibility.py @@ -0,0 +1,108 @@ +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 EligibilityInstance(InstanceResource): + """ + :ivar results: The result set that contains the eligibility check response for the requested number, each result has at least the following attributes: phone_number: The requested phone number ,hosting_account_sid: The account sid where the phone number will be hosted, date_last_checked: Datetime (ISO 8601) when the PN was last checked for eligibility, country: Phone number’s country, eligibility_status: Indicates the eligibility status of the PN (Eligible/Ineligible), eligibility_sub_status: Indicates the sub status of the eligibility , ineligibility_reason: Reason for number's ineligibility (if applicable), next_step: Suggested next step in the hosting process based on the eligibility status. + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.results: Optional[List[Dict[str, object]]] = payload.get("results") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class EligibilityList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the EligibilityList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/HostedNumber/Eligibility" + + def create(self, body: Union[object, object] = values.unset) -> EligibilityInstance: + """ + Create the EligibilityInstance + + :param body: + + :returns: The created EligibilityInstance + """ + 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 EligibilityInstance(self._version, payload) + + async def create_async( + self, body: Union[object, object] = values.unset + ) -> EligibilityInstance: + """ + Asynchronously create the EligibilityInstance + + :param body: + + :returns: The created EligibilityInstance + """ + 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 EligibilityInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/numbers/v1/porting_port_in.py b/twilio/rest/numbers/v1/porting_port_in.py new file mode 100644 index 0000000000..3df2c15462 --- /dev/null +++ b/twilio/rest/numbers/v1/porting_port_in.py @@ -0,0 +1,325 @@ +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, 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 PortingPortInInstance(InstanceResource): + """ + :ivar port_in_request_sid: The SID of the Port In request. This is a unique identifier of the port in request. + :ivar url: The URL of this Port In request + :ivar account_sid: 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. We can't guarantee the exact date and time, as this depends on the losing carrier + :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'. We can't guarantee the exact date and time, as this depends on the losing carrier + :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'. We can't guarantee the exact date and time, as this depends on the losing carrier + :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], + 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: + """ + Provide a friendly representation + + :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 + + + :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): + + def __init__(self, version: Version): + """ + Initialize the PortingPortInList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/Porting/PortIn" + + def create( + self, body: Union[object, object] = values.unset + ) -> PortingPortInInstance: + """ + Create the PortingPortInInstance + + :param body: + + :returns: The created PortingPortInInstance + """ + 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 PortingPortInInstance(self._version, payload) + + async def create_async( + self, body: Union[object, object] = values.unset + ) -> PortingPortInInstance: + """ + Asynchronously create the PortingPortInInstance + + :param body: + + :returns: The created PortingPortInInstance + """ + 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 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 + + :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 new file mode 100644 index 0000000000..351cd541af --- /dev/null +++ b/twilio/rest/numbers/v1/porting_portability.py @@ -0,0 +1,265 @@ +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, 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 PortingPortabilityInstance(InstanceResource): + + class NumberType(object): + LOCAL = "LOCAL" + UNKNOWN = "UNKNOWN" + MOBILE = "MOBILE" + TOLL_FREE = "TOLL-FREE" + + """ + :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: 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. + :ivar number_type: + :ivar country: Country the phone number belongs to. + :ivar url: This is the url of the request that you're trying to reach out to locate the resource. + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + phone_number: Optional[str] = None, + ): + super().__init__(version) + + self.phone_number: Optional[str] = payload.get("phone_number") + self.account_sid: Optional[str] = payload.get("account_sid") + self.portable: Optional[bool] = payload.get("portable") + self.pin_and_account_number_required: Optional[bool] = payload.get( + "pin_and_account_number_required" + ) + self.not_portable_reason: Optional[str] = payload.get("not_portable_reason") + self.not_portable_reason_code: Optional[int] = deserialize.integer( + payload.get("not_portable_reason_code") + ) + self.number_type: Optional["PortingPortabilityInstance.NumberType"] = ( + payload.get("number_type") + ) + self.country: Optional[str] = payload.get("country") + self.url: Optional[str] = payload.get("url") + + self._solution = { + "phone_number": phone_number or self.phone_number, + } + self._context: Optional[PortingPortabilityContext] = None + + @property + def _proxy(self) -> "PortingPortabilityContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: PortingPortabilityContext for this PortingPortabilityInstance + """ + if self._context is None: + self._context = PortingPortabilityContext( + self._version, + phone_number=self._solution["phone_number"], + ) + return self._context + + def fetch( + self, + target_account_sid: Union[str, object] = values.unset, + address_sid: Union[str, object] = values.unset, + ) -> "PortingPortabilityInstance": + """ + Fetch the PortingPortabilityInstance + + :param target_account_sid: Account Sid to which the number will be ported. This can be used to determine if a sub account already has the number in its inventory or a different sub account. If this is not provided, the authenticated account will be assumed to be the target account. + :param address_sid: Address Sid of customer to which the number will be ported. + + :returns: The fetched PortingPortabilityInstance + """ + return self._proxy.fetch( + target_account_sid=target_account_sid, + address_sid=address_sid, + ) + + async def fetch_async( + self, + target_account_sid: Union[str, object] = values.unset, + address_sid: Union[str, object] = values.unset, + ) -> "PortingPortabilityInstance": + """ + Asynchronous coroutine to fetch the PortingPortabilityInstance + + :param target_account_sid: Account Sid to which the number will be ported. This can be used to determine if a sub account already has the number in its inventory or a different sub account. If this is not provided, the authenticated account will be assumed to be the target account. + :param address_sid: Address Sid of customer to which the number will be ported. + + :returns: The fetched PortingPortabilityInstance + """ + return await self._proxy.fetch_async( + target_account_sid=target_account_sid, + address_sid=address_sid, + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class PortingPortabilityContext(InstanceContext): + + def __init__(self, version: Version, phone_number: str): + """ + Initialize the PortingPortabilityContext + + :param version: Version that contains the resource + :param phone_number: Phone number to check portability in e164 format. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "phone_number": phone_number, + } + self._uri = "/Porting/Portability/PhoneNumber/{phone_number}".format( + **self._solution + ) + + def fetch( + self, + target_account_sid: Union[str, object] = values.unset, + address_sid: Union[str, object] = values.unset, + ) -> PortingPortabilityInstance: + """ + Fetch the PortingPortabilityInstance + + :param target_account_sid: Account Sid to which the number will be ported. This can be used to determine if a sub account already has the number in its inventory or a different sub account. If this is not provided, the authenticated account will be assumed to be the target account. + :param address_sid: Address Sid of customer to which the number will be ported. + + :returns: The fetched PortingPortabilityInstance + """ + + data = values.of( + { + "TargetAccountSid": target_account_sid, + "AddressSid": address_sid, + } + ) + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) + + return PortingPortabilityInstance( + self._version, + payload, + phone_number=self._solution["phone_number"], + ) + + async def fetch_async( + self, + target_account_sid: Union[str, object] = values.unset, + address_sid: Union[str, object] = values.unset, + ) -> PortingPortabilityInstance: + """ + Asynchronous coroutine to fetch the PortingPortabilityInstance + + :param target_account_sid: Account Sid to which the number will be ported. This can be used to determine if a sub account already has the number in its inventory or a different sub account. If this is not provided, the authenticated account will be assumed to be the target account. + :param address_sid: Address Sid of customer to which the number will be ported. + + :returns: The fetched PortingPortabilityInstance + """ + + 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, headers=headers + ) + + return PortingPortabilityInstance( + self._version, + payload, + phone_number=self._solution["phone_number"], + ) + + 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 PortingPortabilityList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the PortingPortabilityList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + def get(self, phone_number: str) -> PortingPortabilityContext: + """ + Constructs a PortingPortabilityContext + + :param phone_number: Phone number to check portability in e164 format. + """ + return PortingPortabilityContext(self._version, phone_number=phone_number) + + def __call__(self, phone_number: str) -> PortingPortabilityContext: + """ + Constructs a PortingPortabilityContext + + :param phone_number: Phone number to check portability in e164 format. + """ + return PortingPortabilityContext(self._version, phone_number=phone_number) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" 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 bf3dc53ba2..04b303486e 100644 --- a/twilio/rest/numbers/v2/__init__.py +++ b/twilio/rest/numbers/v2/__init__.py @@ -15,10 +15,15 @@ from typing import Optional from twilio.base.version import Version 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 class V2(Version): + def __init__(self, domain: Domain): """ Initialize the V2 version of Numbers @@ -26,8 +31,36 @@ def __init__(self, domain: Domain): :param domain: The Twilio.numbers 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 + @property + def authorization_documents(self) -> AuthorizationDocumentList: + if self._authorization_documents is None: + self._authorization_documents = AuthorizationDocumentList(self) + return self._authorization_documents + + @property + def bulk_hosted_number_orders(self) -> BulkHostedNumberOrderList: + if self._bulk_hosted_number_orders is None: + 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: + self._hosted_number_orders = HostedNumberOrderList(self) + return self._hosted_number_orders + @property def regulatory_compliance(self) -> RegulatoryComplianceList: if self._regulatory_compliance is None: diff --git a/twilio/rest/numbers/v2/authorization_document/__init__.py b/twilio/rest/numbers/v2/authorization_document/__init__.py new file mode 100644 index 0000000000..033a32cfd7 --- /dev/null +++ b/twilio/rest/numbers/v2/authorization_document/__init__.py @@ -0,0 +1,629 @@ +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, 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.numbers.v2.authorization_document.dependent_hosted_number_order import ( + DependentHostedNumberOrderList, +) + + +class AuthorizationDocumentInstance(InstanceResource): + + class Status(object): + OPENED = "opened" + SIGNING = "signing" + SIGNED = "signed" + CANCELED = "canceled" + FAILED = "failed" + + """ + :ivar sid: A 34 character string that uniquely identifies this AuthorizationDocument. + :ivar address_sid: A 34 character string that uniquely identifies the Address resource that is associated with this AuthorizationDocument. + :ivar status: + :ivar email: Email that this AuthorizationDocument will be sent to for signing. + :ivar cc_emails: Email recipients who will be informed when an Authorization Document has been sent and signed. + :ivar date_created: The date this resource was created, given as [GMT RFC 2822](http://www.ietf.org/rfc/rfc2822.txt) format. + :ivar date_updated: The date that this resource was updated, given as [GMT RFC 2822](http://www.ietf.org/rfc/rfc2822.txt) format. + :ivar url: + :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.address_sid: Optional[str] = payload.get("address_sid") + self.status: Optional["AuthorizationDocumentInstance.Status"] = payload.get( + "status" + ) + self.email: Optional[str] = payload.get("email") + self.cc_emails: Optional[List[str]] = payload.get("cc_emails") + 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[AuthorizationDocumentContext] = None + + @property + def _proxy(self) -> "AuthorizationDocumentContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: AuthorizationDocumentContext for this AuthorizationDocumentInstance + """ + if self._context is None: + self._context = AuthorizationDocumentContext( + self._version, + sid=self._solution["sid"], + ) + return self._context + + def delete(self) -> bool: + """ + Deletes the AuthorizationDocumentInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._proxy.delete() + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the AuthorizationDocumentInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._proxy.delete_async() + + def fetch(self) -> "AuthorizationDocumentInstance": + """ + Fetch the AuthorizationDocumentInstance + + + :returns: The fetched AuthorizationDocumentInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "AuthorizationDocumentInstance": + """ + Asynchronous coroutine to fetch the AuthorizationDocumentInstance + + + :returns: The fetched AuthorizationDocumentInstance + """ + return await self._proxy.fetch_async() + + @property + def dependent_hosted_number_orders(self) -> DependentHostedNumberOrderList: + """ + Access the dependent_hosted_number_orders + """ + return self._proxy.dependent_hosted_number_orders + + 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 AuthorizationDocumentContext(InstanceContext): + + def __init__(self, version: Version, sid: str): + """ + Initialize the AuthorizationDocumentContext + + :param version: Version that contains the resource + :param sid: A 34 character string that uniquely identifies this AuthorizationDocument. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "sid": sid, + } + self._uri = "/HostedNumber/AuthorizationDocuments/{sid}".format( + **self._solution + ) + + self._dependent_hosted_number_orders: Optional[ + DependentHostedNumberOrderList + ] = None + + def delete(self) -> bool: + """ + Deletes the AuthorizationDocumentInstance + + + :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 AuthorizationDocumentInstance + + + :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) -> AuthorizationDocumentInstance: + """ + Fetch the AuthorizationDocumentInstance + + + :returns: The fetched AuthorizationDocumentInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return AuthorizationDocumentInstance( + self._version, + payload, + sid=self._solution["sid"], + ) + + async def fetch_async(self) -> AuthorizationDocumentInstance: + """ + Asynchronous coroutine to fetch the AuthorizationDocumentInstance + + + :returns: The fetched AuthorizationDocumentInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + return AuthorizationDocumentInstance( + self._version, + payload, + sid=self._solution["sid"], + ) + + @property + def dependent_hosted_number_orders(self) -> DependentHostedNumberOrderList: + """ + Access the dependent_hosted_number_orders + """ + if self._dependent_hosted_number_orders is None: + self._dependent_hosted_number_orders = DependentHostedNumberOrderList( + self._version, + self._solution["sid"], + ) + return self._dependent_hosted_number_orders + + 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 AuthorizationDocumentPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> AuthorizationDocumentInstance: + """ + Build an instance of AuthorizationDocumentInstance + + :param payload: Payload response from the API + """ + return AuthorizationDocumentInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class AuthorizationDocumentList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the AuthorizationDocumentList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/HostedNumber/AuthorizationDocuments" + + def create( + self, + address_sid: str, + email: str, + contact_phone_number: str, + hosted_number_order_sids: List[str], + contact_title: Union[str, object] = values.unset, + cc_emails: Union[List[str], object] = values.unset, + ) -> AuthorizationDocumentInstance: + """ + Create the AuthorizationDocumentInstance + + :param address_sid: A 34 character string that uniquely identifies the Address resource that is associated with this AuthorizationDocument. + :param email: Email that this AuthorizationDocument will be sent to for signing. + :param contact_phone_number: The contact phone number of the person authorized to sign the Authorization Document. + :param hosted_number_order_sids: A list of HostedNumberOrder sids that this AuthorizationDocument will authorize for hosting phone number capabilities on Twilio's platform. + :param contact_title: The title of the person authorized to sign the Authorization Document for this phone number. + :param cc_emails: Email recipients who will be informed when an Authorization Document has been sent and signed. + + :returns: The created AuthorizationDocumentInstance + """ + + data = values.of( + { + "AddressSid": address_sid, + "Email": email, + "ContactPhoneNumber": contact_phone_number, + "HostedNumberOrderSids": serialize.map( + hosted_number_order_sids, lambda e: e + ), + "ContactTitle": contact_title, + "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, headers=headers + ) + + return AuthorizationDocumentInstance(self._version, payload) + + async def create_async( + self, + address_sid: str, + email: str, + contact_phone_number: str, + hosted_number_order_sids: List[str], + contact_title: Union[str, object] = values.unset, + cc_emails: Union[List[str], object] = values.unset, + ) -> AuthorizationDocumentInstance: + """ + Asynchronously create the AuthorizationDocumentInstance + + :param address_sid: A 34 character string that uniquely identifies the Address resource that is associated with this AuthorizationDocument. + :param email: Email that this AuthorizationDocument will be sent to for signing. + :param contact_phone_number: The contact phone number of the person authorized to sign the Authorization Document. + :param hosted_number_order_sids: A list of HostedNumberOrder sids that this AuthorizationDocument will authorize for hosting phone number capabilities on Twilio's platform. + :param contact_title: The title of the person authorized to sign the Authorization Document for this phone number. + :param cc_emails: Email recipients who will be informed when an Authorization Document has been sent and signed. + + :returns: The created AuthorizationDocumentInstance + """ + + data = values.of( + { + "AddressSid": address_sid, + "Email": email, + "ContactPhoneNumber": contact_phone_number, + "HostedNumberOrderSids": serialize.map( + hosted_number_order_sids, lambda e: e + ), + "ContactTitle": contact_title, + "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, headers=headers + ) + + return AuthorizationDocumentInstance(self._version, payload) + + def stream( + self, + email: Union[str, object] = values.unset, + status: Union["AuthorizationDocumentInstance.Status", object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[AuthorizationDocumentInstance]: + """ + Streams AuthorizationDocumentInstance 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 email: Email that this AuthorizationDocument will be sent to for signing. + :param "AuthorizationDocumentInstance.Status" status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses. + :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(email=email, status=status, page_size=limits["page_size"]) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + email: Union[str, object] = values.unset, + status: Union["AuthorizationDocumentInstance.Status", object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[AuthorizationDocumentInstance]: + """ + Asynchronously streams AuthorizationDocumentInstance 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 email: Email that this AuthorizationDocument will be sent to for signing. + :param "AuthorizationDocumentInstance.Status" status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses. + :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( + email=email, status=status, page_size=limits["page_size"] + ) + + return self._version.stream_async(page, limits["limit"]) + + def list( + self, + email: Union[str, object] = values.unset, + status: Union["AuthorizationDocumentInstance.Status", object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[AuthorizationDocumentInstance]: + """ + Lists AuthorizationDocumentInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str email: Email that this AuthorizationDocument will be sent to for signing. + :param "AuthorizationDocumentInstance.Status" status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses. + :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( + email=email, + status=status, + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + email: Union[str, object] = values.unset, + status: Union["AuthorizationDocumentInstance.Status", object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[AuthorizationDocumentInstance]: + """ + Asynchronously lists AuthorizationDocumentInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str email: Email that this AuthorizationDocument will be sent to for signing. + :param "AuthorizationDocumentInstance.Status" status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses. + :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( + email=email, + status=status, + limit=limit, + page_size=page_size, + ) + ] + + def page( + self, + email: Union[str, object] = values.unset, + status: Union["AuthorizationDocumentInstance.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, + ) -> AuthorizationDocumentPage: + """ + Retrieve a single page of AuthorizationDocumentInstance records from the API. + Request is executed immediately + + :param email: Email that this AuthorizationDocument will be sent to for signing. + :param status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses. + :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 AuthorizationDocumentInstance + """ + data = values.of( + { + "Email": email, + "Status": status, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return AuthorizationDocumentPage(self._version, response) + + async def page_async( + self, + email: Union[str, object] = values.unset, + status: Union["AuthorizationDocumentInstance.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, + ) -> AuthorizationDocumentPage: + """ + Asynchronously retrieve a single page of AuthorizationDocumentInstance records from the API. + Request is executed immediately + + :param email: Email that this AuthorizationDocument will be sent to for signing. + :param status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses. + :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 AuthorizationDocumentInstance + """ + data = values.of( + { + "Email": email, + "Status": status, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + return AuthorizationDocumentPage(self._version, response) + + def get_page(self, target_url: str) -> AuthorizationDocumentPage: + """ + Retrieve a specific page of AuthorizationDocumentInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of AuthorizationDocumentInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return AuthorizationDocumentPage(self._version, response) + + async def get_page_async(self, target_url: str) -> AuthorizationDocumentPage: + """ + Asynchronously retrieve a specific page of AuthorizationDocumentInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of AuthorizationDocumentInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return AuthorizationDocumentPage(self._version, response) + + def get(self, sid: str) -> AuthorizationDocumentContext: + """ + Constructs a AuthorizationDocumentContext + + :param sid: A 34 character string that uniquely identifies this AuthorizationDocument. + """ + return AuthorizationDocumentContext(self._version, sid=sid) + + def __call__(self, sid: str) -> AuthorizationDocumentContext: + """ + Constructs a AuthorizationDocumentContext + + :param sid: A 34 character string that uniquely identifies this AuthorizationDocument. + """ + return AuthorizationDocumentContext(self._version, sid=sid) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" 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 new file mode 100644 index 0000000000..36f961f5ef --- /dev/null +++ b/twilio/rest/numbers/v2/authorization_document/dependent_hosted_number_order.py @@ -0,0 +1,439 @@ +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, 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 DependentHostedNumberOrderInstance(InstanceResource): + + class Status(object): + RECEIVED = "received" + VERIFIED = "verified" + PENDING_LOA = "pending-loa" + CARRIER_PROCESSING = "carrier-processing" + COMPLETED = "completed" + FAILED = "failed" + ACTION_REQUIRED = "action-required" + + """ + :ivar sid: A 34 character string that uniquely identifies this 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 account_sid: The unique SID identifier of the Account. + :ivar incoming_phone_number_sid: A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder. + :ivar address_sid: A 34 character string that uniquely identifies the Address resource that represents the address of the owner of this phone number. + :ivar signing_document_sid: A 34 character string that uniquely identifies the LOA document associated with this HostedNumberOrder. + :ivar phone_number: An E164 formatted phone number hosted by this HostedNumberOrder. + :ivar capabilities: + :ivar friendly_name: A human readable description of this resource, up to 128 characters. + :ivar status: + :ivar failure_reason: A message that explains why a hosted_number_order went to status \"action-required\" + :ivar date_created: The date this resource was created, given as [GMT RFC 2822](http://www.ietf.org/rfc/rfc2822.txt) format. + :ivar date_updated: The date that this resource was updated, given as [GMT RFC 2822](http://www.ietf.org/rfc/rfc2822.txt) format. + :ivar email: Email of the owner of this phone number that is being hosted. + :ivar cc_emails: Email recipients who will be informed when an Authorization Document has been sent and signed + :ivar contact_title: The title of the person authorized to sign the Authorization Document for this phone number. + :ivar contact_phone_number: The contact phone number of the person authorized to sign the Authorization Document. + """ + + def __init__( + self, version: Version, payload: Dict[str, Any], signing_document_sid: str + ): + super().__init__(version) + + self.sid: Optional[str] = payload.get("sid") + self.bulk_hosting_request_sid: Optional[str] = payload.get( + "bulk_hosting_request_sid" + ) + self.next_step: Optional[str] = payload.get("next_step") + self.account_sid: Optional[str] = payload.get("account_sid") + self.incoming_phone_number_sid: Optional[str] = payload.get( + "incoming_phone_number_sid" + ) + self.address_sid: Optional[str] = payload.get("address_sid") + self.signing_document_sid: Optional[str] = payload.get("signing_document_sid") + self.phone_number: Optional[str] = payload.get("phone_number") + self.capabilities: Optional[str] = payload.get("capabilities") + self.friendly_name: Optional[str] = payload.get("friendly_name") + self.status: Optional["DependentHostedNumberOrderInstance.Status"] = ( + payload.get("status") + ) + self.failure_reason: Optional[str] = payload.get("failure_reason") + 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.email: Optional[str] = payload.get("email") + self.cc_emails: Optional[List[str]] = payload.get("cc_emails") + self.contact_title: Optional[str] = payload.get("contact_title") + self.contact_phone_number: Optional[str] = payload.get("contact_phone_number") + + self._solution = { + "signing_document_sid": signing_document_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 DependentHostedNumberOrderPage(Page): + + def get_instance( + self, payload: Dict[str, Any] + ) -> DependentHostedNumberOrderInstance: + """ + Build an instance of DependentHostedNumberOrderInstance + + :param payload: Payload response from the API + """ + return DependentHostedNumberOrderInstance( + self._version, + payload, + signing_document_sid=self._solution["signing_document_sid"], + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class DependentHostedNumberOrderList(ListResource): + + def __init__(self, version: Version, signing_document_sid: str): + """ + Initialize the DependentHostedNumberOrderList + + :param version: Version that contains the resource + :param signing_document_sid: A 34 character string that uniquely identifies the LOA document associated with this HostedNumberOrder. + + """ + super().__init__(version) + + # Path Solution + self._solution = { + "signing_document_sid": signing_document_sid, + } + self._uri = "/HostedNumber/AuthorizationDocuments/{signing_document_sid}/DependentHostedNumberOrders".format( + **self._solution + ) + + def stream( + self, + status: Union[ + "DependentHostedNumberOrderInstance.Status", object + ] = values.unset, + phone_number: Union[str, object] = values.unset, + incoming_phone_number_sid: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[DependentHostedNumberOrderInstance]: + """ + Streams DependentHostedNumberOrderInstance 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 "DependentHostedNumberOrderInstance.Status" status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses. + :param str phone_number: An E164 formatted phone number hosted by this HostedNumberOrder. + :param str incoming_phone_number_sid: A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder. + :param str friendly_name: A human readable description of this resource, up to 128 characters. + :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( + status=status, + phone_number=phone_number, + incoming_phone_number_sid=incoming_phone_number_sid, + friendly_name=friendly_name, + page_size=limits["page_size"], + ) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + status: Union[ + "DependentHostedNumberOrderInstance.Status", object + ] = values.unset, + phone_number: Union[str, object] = values.unset, + incoming_phone_number_sid: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[DependentHostedNumberOrderInstance]: + """ + Asynchronously streams DependentHostedNumberOrderInstance 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 "DependentHostedNumberOrderInstance.Status" status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses. + :param str phone_number: An E164 formatted phone number hosted by this HostedNumberOrder. + :param str incoming_phone_number_sid: A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder. + :param str friendly_name: A human readable description of this resource, up to 128 characters. + :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( + status=status, + phone_number=phone_number, + incoming_phone_number_sid=incoming_phone_number_sid, + friendly_name=friendly_name, + page_size=limits["page_size"], + ) + + return self._version.stream_async(page, limits["limit"]) + + def list( + self, + status: Union[ + "DependentHostedNumberOrderInstance.Status", object + ] = values.unset, + phone_number: Union[str, object] = values.unset, + incoming_phone_number_sid: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[DependentHostedNumberOrderInstance]: + """ + Lists DependentHostedNumberOrderInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param "DependentHostedNumberOrderInstance.Status" status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses. + :param str phone_number: An E164 formatted phone number hosted by this HostedNumberOrder. + :param str incoming_phone_number_sid: A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder. + :param str friendly_name: A human readable description of this resource, up to 128 characters. + :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( + status=status, + phone_number=phone_number, + incoming_phone_number_sid=incoming_phone_number_sid, + friendly_name=friendly_name, + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + status: Union[ + "DependentHostedNumberOrderInstance.Status", object + ] = values.unset, + phone_number: Union[str, object] = values.unset, + incoming_phone_number_sid: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[DependentHostedNumberOrderInstance]: + """ + Asynchronously lists DependentHostedNumberOrderInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param "DependentHostedNumberOrderInstance.Status" status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses. + :param str phone_number: An E164 formatted phone number hosted by this HostedNumberOrder. + :param str incoming_phone_number_sid: A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder. + :param str friendly_name: A human readable description of this resource, up to 128 characters. + :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( + status=status, + phone_number=phone_number, + incoming_phone_number_sid=incoming_phone_number_sid, + friendly_name=friendly_name, + limit=limit, + page_size=page_size, + ) + ] + + def page( + self, + status: Union[ + "DependentHostedNumberOrderInstance.Status", object + ] = values.unset, + phone_number: Union[str, object] = values.unset, + incoming_phone_number_sid: Union[str, object] = values.unset, + friendly_name: 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, + ) -> DependentHostedNumberOrderPage: + """ + Retrieve a single page of DependentHostedNumberOrderInstance records from the API. + Request is executed immediately + + :param status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses. + :param phone_number: An E164 formatted phone number hosted by this HostedNumberOrder. + :param incoming_phone_number_sid: A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder. + :param friendly_name: A human readable description of this resource, up to 128 characters. + :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 DependentHostedNumberOrderInstance + """ + data = values.of( + { + "Status": status, + "PhoneNumber": phone_number, + "IncomingPhoneNumberSid": incoming_phone_number_sid, + "FriendlyName": friendly_name, + "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 DependentHostedNumberOrderPage(self._version, response, self._solution) + + async def page_async( + self, + status: Union[ + "DependentHostedNumberOrderInstance.Status", object + ] = values.unset, + phone_number: Union[str, object] = values.unset, + incoming_phone_number_sid: Union[str, object] = values.unset, + friendly_name: 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, + ) -> DependentHostedNumberOrderPage: + """ + Asynchronously retrieve a single page of DependentHostedNumberOrderInstance records from the API. + Request is executed immediately + + :param status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses. + :param phone_number: An E164 formatted phone number hosted by this HostedNumberOrder. + :param incoming_phone_number_sid: A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder. + :param friendly_name: A human readable description of this resource, up to 128 characters. + :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 DependentHostedNumberOrderInstance + """ + data = values.of( + { + "Status": status, + "PhoneNumber": phone_number, + "IncomingPhoneNumberSid": incoming_phone_number_sid, + "FriendlyName": friendly_name, + "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 DependentHostedNumberOrderPage(self._version, response, self._solution) + + def get_page(self, target_url: str) -> DependentHostedNumberOrderPage: + """ + Retrieve a specific page of DependentHostedNumberOrderInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of DependentHostedNumberOrderInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return DependentHostedNumberOrderPage(self._version, response, self._solution) + + async def get_page_async(self, target_url: str) -> DependentHostedNumberOrderPage: + """ + Asynchronously retrieve a specific page of DependentHostedNumberOrderInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of DependentHostedNumberOrderInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return DependentHostedNumberOrderPage(self._version, response, self._solution) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/numbers/v2/bulk_hosted_number_order.py b/twilio/rest/numbers/v2/bulk_hosted_number_order.py new file mode 100644 index 0000000000..7259c801d2 --- /dev/null +++ b/twilio/rest/numbers/v2/bulk_hosted_number_order.py @@ -0,0 +1,305 @@ +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, 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 BulkHostedNumberOrderInstance(InstanceResource): + + class RequestStatus(object): + QUEUED = "QUEUED" + IN_PROGRESS = "IN_PROGRESS" + PROCESSED = "PROCESSED" + + """ + :ivar bulk_hosting_sid: A 34 character string that uniquely identifies this BulkHostedNumberOrder. + :ivar request_status: + :ivar friendly_name: A 128 character string that is a human-readable text that describes this resource. + :ivar notification_email: Email address used for send notifications about this Bulk hosted number request. + :ivar date_created: The date this resource was created, given as [GMT RFC 2822](http://www.ietf.org/rfc/rfc2822.txt) format. + :ivar date_completed: The date that this resource was completed, given as [GMT RFC 2822](http://www.ietf.org/rfc/rfc2822.txt) format. + :ivar url: The URL of this BulkHostedNumberOrder resource. + :ivar total_count: The total count of phone numbers in this Bulk hosting request. + :ivar results: Contains a list of all the individual hosting orders and their information, for this Bulk request. Each result object is grouped by its order status. To see a complete list of order status, please check 'https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/hosted-number-order-resource#status-values'. + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + bulk_hosting_sid: Optional[str] = None, + ): + super().__init__(version) + + self.bulk_hosting_sid: Optional[str] = payload.get("bulk_hosting_sid") + self.request_status: Optional["BulkHostedNumberOrderInstance.RequestStatus"] = ( + payload.get("request_status") + ) + self.friendly_name: Optional[str] = payload.get("friendly_name") + self.notification_email: Optional[str] = payload.get("notification_email") + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_created") + ) + self.date_completed: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("date_completed") + ) + self.url: Optional[str] = payload.get("url") + self.total_count: Optional[int] = deserialize.integer( + payload.get("total_count") + ) + self.results: Optional[List[Dict[str, object]]] = payload.get("results") + + self._solution = { + "bulk_hosting_sid": bulk_hosting_sid or self.bulk_hosting_sid, + } + self._context: Optional[BulkHostedNumberOrderContext] = None + + @property + def _proxy(self) -> "BulkHostedNumberOrderContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: BulkHostedNumberOrderContext for this BulkHostedNumberOrderInstance + """ + if self._context is None: + self._context = BulkHostedNumberOrderContext( + self._version, + bulk_hosting_sid=self._solution["bulk_hosting_sid"], + ) + return self._context + + def fetch( + self, order_status: Union[str, object] = values.unset + ) -> "BulkHostedNumberOrderInstance": + """ + Fetch the BulkHostedNumberOrderInstance + + :param order_status: Order status can be used for filtering on Hosted Number Order status values. To see a complete list of order statuses, please check 'https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/hosted-number-order-resource#status-values'. + + :returns: The fetched BulkHostedNumberOrderInstance + """ + return self._proxy.fetch( + order_status=order_status, + ) + + async def fetch_async( + self, order_status: Union[str, object] = values.unset + ) -> "BulkHostedNumberOrderInstance": + """ + Asynchronous coroutine to fetch the BulkHostedNumberOrderInstance + + :param order_status: Order status can be used for filtering on Hosted Number Order status values. To see a complete list of order statuses, please check 'https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/hosted-number-order-resource#status-values'. + + :returns: The fetched BulkHostedNumberOrderInstance + """ + return await self._proxy.fetch_async( + order_status=order_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 BulkHostedNumberOrderContext(InstanceContext): + + def __init__(self, version: Version, bulk_hosting_sid: str): + """ + Initialize the BulkHostedNumberOrderContext + + :param version: Version that contains the resource + :param bulk_hosting_sid: A 34 character string that uniquely identifies this BulkHostedNumberOrder. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "bulk_hosting_sid": bulk_hosting_sid, + } + self._uri = "/HostedNumber/Orders/Bulk/{bulk_hosting_sid}".format( + **self._solution + ) + + def fetch( + self, order_status: Union[str, object] = values.unset + ) -> BulkHostedNumberOrderInstance: + """ + Fetch the BulkHostedNumberOrderInstance + + :param order_status: Order status can be used for filtering on Hosted Number Order status values. To see a complete list of order statuses, please check 'https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/hosted-number-order-resource#status-values'. + + :returns: The fetched BulkHostedNumberOrderInstance + """ + + data = values.of( + { + "OrderStatus": order_status, + } + ) + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch( + method="GET", uri=self._uri, params=data, headers=headers + ) + + return BulkHostedNumberOrderInstance( + self._version, + payload, + bulk_hosting_sid=self._solution["bulk_hosting_sid"], + ) + + async def fetch_async( + self, order_status: Union[str, object] = values.unset + ) -> BulkHostedNumberOrderInstance: + """ + Asynchronous coroutine to fetch the BulkHostedNumberOrderInstance + + :param order_status: Order status can be used for filtering on Hosted Number Order status values. To see a complete list of order statuses, please check 'https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/hosted-number-order-resource#status-values'. + + :returns: The fetched BulkHostedNumberOrderInstance + """ + + data = values.of( + { + "OrderStatus": order_status, + } + ) + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + + return BulkHostedNumberOrderInstance( + self._version, + payload, + bulk_hosting_sid=self._solution["bulk_hosting_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 BulkHostedNumberOrderList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the BulkHostedNumberOrderList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/HostedNumber/Orders/Bulk" + + def create( + self, body: Union[object, object] = values.unset + ) -> BulkHostedNumberOrderInstance: + """ + Create the BulkHostedNumberOrderInstance + + :param body: + + :returns: The created BulkHostedNumberOrderInstance + """ + 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 BulkHostedNumberOrderInstance(self._version, payload) + + async def create_async( + self, body: Union[object, object] = values.unset + ) -> BulkHostedNumberOrderInstance: + """ + Asynchronously create the BulkHostedNumberOrderInstance + + :param body: + + :returns: The created BulkHostedNumberOrderInstance + """ + 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 BulkHostedNumberOrderInstance(self._version, payload) + + def get(self, bulk_hosting_sid: str) -> BulkHostedNumberOrderContext: + """ + Constructs a BulkHostedNumberOrderContext + + :param bulk_hosting_sid: A 34 character string that uniquely identifies this BulkHostedNumberOrder. + """ + return BulkHostedNumberOrderContext( + self._version, bulk_hosting_sid=bulk_hosting_sid + ) + + def __call__(self, bulk_hosting_sid: str) -> BulkHostedNumberOrderContext: + """ + Constructs a BulkHostedNumberOrderContext + + :param bulk_hosting_sid: A 34 character string that uniquely identifies this BulkHostedNumberOrder. + """ + return BulkHostedNumberOrderContext( + self._version, bulk_hosting_sid=bulk_hosting_sid + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" 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 new file mode 100644 index 0000000000..6afa755bd3 --- /dev/null +++ b/twilio/rest/numbers/v2/hosted_number_order.py @@ -0,0 +1,887 @@ +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, 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 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. + :ivar incoming_phone_number_sid: A 34 character string that uniquely identifies the [IncomingPhoneNumber](https://www.twilio.com/docs/phone-numbers/api/incomingphonenumber-resource) resource that represents the phone number being hosted. + :ivar address_sid: A 34 character string that uniquely identifies the Address resource that represents the address of the owner of this phone number. + :ivar signing_document_sid: A 34 character string that uniquely identifies the [Authorization Document](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource) the user needs to sign. + :ivar phone_number: Phone number to be hosted. This must be in [E.164](https://en.wikipedia.org/wiki/E.164) format, e.g., +16175551212 + :ivar capabilities: + :ivar friendly_name: A 128 character string that is a human-readable text that describes this resource. + :ivar status: + :ivar failure_reason: A message that explains why a hosted_number_order went to status \"action-required\" + :ivar date_created: The date this resource was created, given as [GMT RFC 2822](http://www.ietf.org/rfc/rfc2822.txt) format. + :ivar date_updated: The date that this resource was updated, given as [GMT RFC 2822](http://www.ietf.org/rfc/rfc2822.txt) format. + :ivar email: Email of the owner of this phone number that is being hosted. + :ivar cc_emails: A list of emails that LOA document for this HostedNumberOrder will be carbon copied to. + :ivar url: The URL of this HostedNumberOrder. + :ivar contact_title: The title of the person authorized to sign the Authorization Document for this phone number. + :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__( + 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.incoming_phone_number_sid: Optional[str] = payload.get( + "incoming_phone_number_sid" + ) + self.address_sid: Optional[str] = payload.get("address_sid") + self.signing_document_sid: Optional[str] = payload.get("signing_document_sid") + self.phone_number: Optional[str] = payload.get("phone_number") + self.capabilities: Optional[str] = payload.get("capabilities") + self.friendly_name: Optional[str] = payload.get("friendly_name") + self.status: Optional["HostedNumberOrderInstance.Status"] = payload.get( + "status" + ) + self.failure_reason: Optional[str] = payload.get("failure_reason") + 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.email: Optional[str] = payload.get("email") + self.cc_emails: Optional[List[str]] = payload.get("cc_emails") + self.url: Optional[str] = payload.get("url") + self.contact_title: Optional[str] = payload.get("contact_title") + self.contact_phone_number: Optional[str] = payload.get("contact_phone_number") + self.bulk_hosting_request_sid: Optional[str] = payload.get( + "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, + } + self._context: Optional[HostedNumberOrderContext] = None + + @property + def _proxy(self) -> "HostedNumberOrderContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: HostedNumberOrderContext for this HostedNumberOrderInstance + """ + if self._context is None: + self._context = HostedNumberOrderContext( + self._version, + sid=self._solution["sid"], + ) + return self._context + + def delete(self) -> bool: + """ + Deletes the HostedNumberOrderInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._proxy.delete() + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the HostedNumberOrderInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._proxy.delete_async() + + def fetch(self) -> "HostedNumberOrderInstance": + """ + Fetch the HostedNumberOrderInstance + + + :returns: The fetched HostedNumberOrderInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "HostedNumberOrderInstance": + """ + Asynchronous coroutine to fetch the HostedNumberOrderInstance + + + :returns: The fetched 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 + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class HostedNumberOrderContext(InstanceContext): + + def __init__(self, version: Version, sid: str): + """ + Initialize the HostedNumberOrderContext + + :param version: Version that contains the resource + :param sid: The SID of the HostedNumberOrder resource to update. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "sid": sid, + } + self._uri = "/HostedNumber/Orders/{sid}".format(**self._solution) + + def delete(self) -> bool: + """ + Deletes the HostedNumberOrderInstance + + + :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 HostedNumberOrderInstance + + + :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) -> HostedNumberOrderInstance: + """ + Fetch the HostedNumberOrderInstance + + + :returns: The fetched HostedNumberOrderInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return HostedNumberOrderInstance( + self._version, + payload, + sid=self._solution["sid"], + ) + + async def fetch_async(self) -> HostedNumberOrderInstance: + """ + Asynchronous coroutine to fetch the HostedNumberOrderInstance + + + :returns: The fetched HostedNumberOrderInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + return HostedNumberOrderInstance( + self._version, + payload, + 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 + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class HostedNumberOrderPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> HostedNumberOrderInstance: + """ + Build an instance of HostedNumberOrderInstance + + :param payload: Payload response from the API + """ + return HostedNumberOrderInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class HostedNumberOrderList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the HostedNumberOrderList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/HostedNumber/Orders" + + def create( + self, + phone_number: str, + contact_phone_number: str, + address_sid: str, + email: str, + account_sid: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + cc_emails: Union[List[str], object] = values.unset, + sms_url: Union[str, object] = values.unset, + sms_method: Union[str, object] = values.unset, + sms_fallback_url: Union[str, object] = values.unset, + sms_capability: Union[bool, object] = values.unset, + sms_fallback_method: Union[str, object] = values.unset, + status_callback_url: Union[str, object] = values.unset, + status_callback_method: Union[str, object] = values.unset, + sms_application_sid: Union[str, object] = values.unset, + contact_title: Union[str, object] = values.unset, + ) -> HostedNumberOrderInstance: + """ + Create the HostedNumberOrderInstance + + :param phone_number: The number to host in [+E.164](https://en.wikipedia.org/wiki/E.164) format + :param contact_phone_number: The contact phone number of the person authorized to sign the Authorization Document. + :param address_sid: Optional. A 34 character string that uniquely identifies the Address resource that represents the address of the owner of this phone number. + :param email: Optional. Email of the owner of this phone number that is being hosted. + :param account_sid: This defaults to the AccountSid of the authorization the user is using. This can be provided to specify a subaccount to add the HostedNumberOrder to. + :param friendly_name: A 128 character string that is a human readable text that describes this resource. + :param cc_emails: Optional. A list of emails that the LOA document for this HostedNumberOrder will be carbon copied to. + :param sms_url: The URL that Twilio should request when somebody sends an SMS to the phone number. This will be copied onto the IncomingPhoneNumber resource. + :param sms_method: The HTTP method that should be used to request the SmsUrl. Must be either `GET` or `POST`. This will be copied onto the IncomingPhoneNumber resource. + :param sms_fallback_url: A URL that Twilio will request if an error occurs requesting or executing the TwiML defined by SmsUrl. This will be copied onto the IncomingPhoneNumber resource. + :param sms_capability: Used to specify that the SMS capability will be hosted on Twilio's platform. + :param sms_fallback_method: The HTTP method that should be used to request the SmsFallbackUrl. Must be either `GET` or `POST`. This will be copied onto the IncomingPhoneNumber resource. + :param status_callback_url: Optional. The Status Callback URL attached to the IncomingPhoneNumber resource. + :param status_callback_method: Optional. The Status Callback Method attached to the IncomingPhoneNumber resource. + :param sms_application_sid: Optional. The 34 character sid of the application Twilio should use to handle SMS messages sent to this number. If a `SmsApplicationSid` is present, Twilio will ignore all of the SMS urls above and use those set on the application. + :param contact_title: The title of the person authorized to sign the Authorization Document for this phone number. + + :returns: The created HostedNumberOrderInstance + """ + + data = values.of( + { + "PhoneNumber": phone_number, + "ContactPhoneNumber": contact_phone_number, + "AddressSid": address_sid, + "Email": email, + "AccountSid": account_sid, + "FriendlyName": friendly_name, + "CcEmails": serialize.map(cc_emails, lambda e: e), + "SmsUrl": sms_url, + "SmsMethod": sms_method, + "SmsFallbackUrl": sms_fallback_url, + "SmsCapability": serialize.boolean_to_string(sms_capability), + "SmsFallbackMethod": sms_fallback_method, + "StatusCallbackUrl": status_callback_url, + "StatusCallbackMethod": status_callback_method, + "SmsApplicationSid": sms_application_sid, + "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, headers=headers + ) + + return HostedNumberOrderInstance(self._version, payload) + + async def create_async( + self, + phone_number: str, + contact_phone_number: str, + address_sid: str, + email: str, + account_sid: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + cc_emails: Union[List[str], object] = values.unset, + sms_url: Union[str, object] = values.unset, + sms_method: Union[str, object] = values.unset, + sms_fallback_url: Union[str, object] = values.unset, + sms_capability: Union[bool, object] = values.unset, + sms_fallback_method: Union[str, object] = values.unset, + status_callback_url: Union[str, object] = values.unset, + status_callback_method: Union[str, object] = values.unset, + sms_application_sid: Union[str, object] = values.unset, + contact_title: Union[str, object] = values.unset, + ) -> HostedNumberOrderInstance: + """ + Asynchronously create the HostedNumberOrderInstance + + :param phone_number: The number to host in [+E.164](https://en.wikipedia.org/wiki/E.164) format + :param contact_phone_number: The contact phone number of the person authorized to sign the Authorization Document. + :param address_sid: Optional. A 34 character string that uniquely identifies the Address resource that represents the address of the owner of this phone number. + :param email: Optional. Email of the owner of this phone number that is being hosted. + :param account_sid: This defaults to the AccountSid of the authorization the user is using. This can be provided to specify a subaccount to add the HostedNumberOrder to. + :param friendly_name: A 128 character string that is a human readable text that describes this resource. + :param cc_emails: Optional. A list of emails that the LOA document for this HostedNumberOrder will be carbon copied to. + :param sms_url: The URL that Twilio should request when somebody sends an SMS to the phone number. This will be copied onto the IncomingPhoneNumber resource. + :param sms_method: The HTTP method that should be used to request the SmsUrl. Must be either `GET` or `POST`. This will be copied onto the IncomingPhoneNumber resource. + :param sms_fallback_url: A URL that Twilio will request if an error occurs requesting or executing the TwiML defined by SmsUrl. This will be copied onto the IncomingPhoneNumber resource. + :param sms_capability: Used to specify that the SMS capability will be hosted on Twilio's platform. + :param sms_fallback_method: The HTTP method that should be used to request the SmsFallbackUrl. Must be either `GET` or `POST`. This will be copied onto the IncomingPhoneNumber resource. + :param status_callback_url: Optional. The Status Callback URL attached to the IncomingPhoneNumber resource. + :param status_callback_method: Optional. The Status Callback Method attached to the IncomingPhoneNumber resource. + :param sms_application_sid: Optional. The 34 character sid of the application Twilio should use to handle SMS messages sent to this number. If a `SmsApplicationSid` is present, Twilio will ignore all of the SMS urls above and use those set on the application. + :param contact_title: The title of the person authorized to sign the Authorization Document for this phone number. + + :returns: The created HostedNumberOrderInstance + """ + + data = values.of( + { + "PhoneNumber": phone_number, + "ContactPhoneNumber": contact_phone_number, + "AddressSid": address_sid, + "Email": email, + "AccountSid": account_sid, + "FriendlyName": friendly_name, + "CcEmails": serialize.map(cc_emails, lambda e: e), + "SmsUrl": sms_url, + "SmsMethod": sms_method, + "SmsFallbackUrl": sms_fallback_url, + "SmsCapability": serialize.boolean_to_string(sms_capability), + "SmsFallbackMethod": sms_fallback_method, + "StatusCallbackUrl": status_callback_url, + "StatusCallbackMethod": status_callback_method, + "SmsApplicationSid": sms_application_sid, + "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, headers=headers + ) + + return HostedNumberOrderInstance(self._version, payload) + + def stream( + self, + status: Union["HostedNumberOrderInstance.Status", object] = values.unset, + sms_capability: Union[bool, object] = values.unset, + phone_number: Union[str, object] = values.unset, + incoming_phone_number_sid: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[HostedNumberOrderInstance]: + """ + Streams HostedNumberOrderInstance 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 "HostedNumberOrderInstance.Status" status: The Status of this HostedNumberOrder. One of `received`, `pending-verification`, `verified`, `pending-loa`, `carrier-processing`, `testing`, `completed`, `failed`, or `action-required`. + :param bool sms_capability: Whether the SMS capability will be hosted on our platform. Can be `true` of `false`. + :param str phone_number: An E164 formatted phone number hosted by this HostedNumberOrder. + :param str incoming_phone_number_sid: A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder. + :param str friendly_name: A human readable description of this resource, up to 128 characters. + :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( + status=status, + sms_capability=sms_capability, + phone_number=phone_number, + incoming_phone_number_sid=incoming_phone_number_sid, + friendly_name=friendly_name, + page_size=limits["page_size"], + ) + + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + status: Union["HostedNumberOrderInstance.Status", object] = values.unset, + sms_capability: Union[bool, object] = values.unset, + phone_number: Union[str, object] = values.unset, + incoming_phone_number_sid: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[HostedNumberOrderInstance]: + """ + Asynchronously streams HostedNumberOrderInstance 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 "HostedNumberOrderInstance.Status" status: The Status of this HostedNumberOrder. One of `received`, `pending-verification`, `verified`, `pending-loa`, `carrier-processing`, `testing`, `completed`, `failed`, or `action-required`. + :param bool sms_capability: Whether the SMS capability will be hosted on our platform. Can be `true` of `false`. + :param str phone_number: An E164 formatted phone number hosted by this HostedNumberOrder. + :param str incoming_phone_number_sid: A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder. + :param str friendly_name: A human readable description of this resource, up to 128 characters. + :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( + status=status, + sms_capability=sms_capability, + phone_number=phone_number, + incoming_phone_number_sid=incoming_phone_number_sid, + friendly_name=friendly_name, + page_size=limits["page_size"], + ) + + return self._version.stream_async(page, limits["limit"]) + + def list( + self, + status: Union["HostedNumberOrderInstance.Status", object] = values.unset, + sms_capability: Union[bool, object] = values.unset, + phone_number: Union[str, object] = values.unset, + incoming_phone_number_sid: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[HostedNumberOrderInstance]: + """ + Lists HostedNumberOrderInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param "HostedNumberOrderInstance.Status" status: The Status of this HostedNumberOrder. One of `received`, `pending-verification`, `verified`, `pending-loa`, `carrier-processing`, `testing`, `completed`, `failed`, or `action-required`. + :param bool sms_capability: Whether the SMS capability will be hosted on our platform. Can be `true` of `false`. + :param str phone_number: An E164 formatted phone number hosted by this HostedNumberOrder. + :param str incoming_phone_number_sid: A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder. + :param str friendly_name: A human readable description of this resource, up to 128 characters. + :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( + status=status, + sms_capability=sms_capability, + phone_number=phone_number, + incoming_phone_number_sid=incoming_phone_number_sid, + friendly_name=friendly_name, + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + status: Union["HostedNumberOrderInstance.Status", object] = values.unset, + sms_capability: Union[bool, object] = values.unset, + phone_number: Union[str, object] = values.unset, + incoming_phone_number_sid: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[HostedNumberOrderInstance]: + """ + Asynchronously lists HostedNumberOrderInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param "HostedNumberOrderInstance.Status" status: The Status of this HostedNumberOrder. One of `received`, `pending-verification`, `verified`, `pending-loa`, `carrier-processing`, `testing`, `completed`, `failed`, or `action-required`. + :param bool sms_capability: Whether the SMS capability will be hosted on our platform. Can be `true` of `false`. + :param str phone_number: An E164 formatted phone number hosted by this HostedNumberOrder. + :param str incoming_phone_number_sid: A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder. + :param str friendly_name: A human readable description of this resource, up to 128 characters. + :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( + status=status, + sms_capability=sms_capability, + phone_number=phone_number, + incoming_phone_number_sid=incoming_phone_number_sid, + friendly_name=friendly_name, + limit=limit, + page_size=page_size, + ) + ] + + def page( + self, + status: Union["HostedNumberOrderInstance.Status", object] = values.unset, + sms_capability: Union[bool, object] = values.unset, + phone_number: Union[str, object] = values.unset, + incoming_phone_number_sid: Union[str, object] = values.unset, + friendly_name: 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, + ) -> HostedNumberOrderPage: + """ + Retrieve a single page of HostedNumberOrderInstance records from the API. + Request is executed immediately + + :param status: The Status of this HostedNumberOrder. One of `received`, `pending-verification`, `verified`, `pending-loa`, `carrier-processing`, `testing`, `completed`, `failed`, or `action-required`. + :param sms_capability: Whether the SMS capability will be hosted on our platform. Can be `true` of `false`. + :param phone_number: An E164 formatted phone number hosted by this HostedNumberOrder. + :param incoming_phone_number_sid: A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder. + :param friendly_name: A human readable description of this resource, up to 128 characters. + :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 HostedNumberOrderInstance + """ + data = values.of( + { + "Status": status, + "SmsCapability": serialize.boolean_to_string(sms_capability), + "PhoneNumber": phone_number, + "IncomingPhoneNumberSid": incoming_phone_number_sid, + "FriendlyName": friendly_name, + "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 HostedNumberOrderPage(self._version, response) + + async def page_async( + self, + status: Union["HostedNumberOrderInstance.Status", object] = values.unset, + sms_capability: Union[bool, object] = values.unset, + phone_number: Union[str, object] = values.unset, + incoming_phone_number_sid: Union[str, object] = values.unset, + friendly_name: 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, + ) -> HostedNumberOrderPage: + """ + Asynchronously retrieve a single page of HostedNumberOrderInstance records from the API. + Request is executed immediately + + :param status: The Status of this HostedNumberOrder. One of `received`, `pending-verification`, `verified`, `pending-loa`, `carrier-processing`, `testing`, `completed`, `failed`, or `action-required`. + :param sms_capability: Whether the SMS capability will be hosted on our platform. Can be `true` of `false`. + :param phone_number: An E164 formatted phone number hosted by this HostedNumberOrder. + :param incoming_phone_number_sid: A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder. + :param friendly_name: A human readable description of this resource, up to 128 characters. + :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 HostedNumberOrderInstance + """ + data = values.of( + { + "Status": status, + "SmsCapability": serialize.boolean_to_string(sms_capability), + "PhoneNumber": phone_number, + "IncomingPhoneNumberSid": incoming_phone_number_sid, + "FriendlyName": friendly_name, + "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 HostedNumberOrderPage(self._version, response) + + def get_page(self, target_url: str) -> HostedNumberOrderPage: + """ + Retrieve a specific page of HostedNumberOrderInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of HostedNumberOrderInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return HostedNumberOrderPage(self._version, response) + + async def get_page_async(self, target_url: str) -> HostedNumberOrderPage: + """ + Asynchronously retrieve a specific page of HostedNumberOrderInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of HostedNumberOrderInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return HostedNumberOrderPage(self._version, response) + + def get(self, sid: str) -> HostedNumberOrderContext: + """ + Constructs a HostedNumberOrderContext + + :param sid: The SID of the HostedNumberOrder resource to update. + """ + return HostedNumberOrderContext(self._version, sid=sid) + + def __call__(self, sid: str) -> HostedNumberOrderContext: + """ + Constructs a HostedNumberOrderContext + + :param sid: The SID of the HostedNumberOrder resource to update. + """ + return HostedNumberOrderContext(self._version, sid=sid) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/numbers/v2/regulatory_compliance/__init__.py b/twilio/rest/numbers/v2/regulatory_compliance/__init__.py index 9afca8a972..189117d85c 100644 --- a/twilio/rest/numbers/v2/regulatory_compliance/__init__.py +++ b/twilio/rest/numbers/v2/regulatory_compliance/__init__.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Optional @@ -32,6 +31,7 @@ class RegulatoryComplianceList(ListResource): + def __init__(self, version: Version): """ Initialize the RegulatoryComplianceList diff --git a/twilio/rest/numbers/v2/regulatory_compliance/bundle/__init__.py b/twilio/rest/numbers/v2/regulatory_compliance/bundle/__init__.py index ff7b1d7c01..079540d87b 100644 --- a/twilio/rest/numbers/v2/regulatory_compliance/bundle/__init__.py +++ b/twilio/rest/numbers/v2/regulatory_compliance/bundle/__init__.py @@ -12,7 +12,6 @@ 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 @@ -36,6 +35,7 @@ class BundleInstance(InstanceResource): + class EndUserType(object): INDIVIDUAL = "individual" BUSINESS = "business" @@ -238,6 +238,7 @@ def __repr__(self) -> str: class BundleContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the BundleContext @@ -265,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: """ @@ -277,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: @@ -290,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, @@ -309,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( @@ -337,6 +344,7 @@ def update( :returns: The updated BundleInstance """ + data = values.of( { "Status": status, @@ -345,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"]) @@ -371,6 +382,7 @@ async def update_async( :returns: The updated BundleInstance """ + data = values.of( { "Status": status, @@ -379,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"]) @@ -447,6 +462,7 @@ def __repr__(self) -> str: class BundlePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> BundleInstance: """ Build an instance of BundleInstance @@ -465,6 +481,7 @@ def __repr__(self) -> str: class BundleList(ListResource): + def __init__(self, version: Version): """ Initialize the BundleList @@ -485,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 @@ -495,10 +513,12 @@ 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 """ + data = values.of( { "FriendlyName": friendly_name, @@ -508,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) @@ -528,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 @@ -538,10 +563,12 @@ 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 """ + data = values.of( { "FriendlyName": friendly_name, @@ -551,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) @@ -588,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`. @@ -648,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`. @@ -707,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`. @@ -766,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`. @@ -826,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`. @@ -846,7 +877,7 @@ def page( "RegulationSid": regulation_sid, "IsoCountry": iso_country, "NumberType": number_type, - "HasValidUntilDate": has_valid_until_date, + "HasValidUntilDate": serialize.boolean_to_string(has_valid_until_date), "SortBy": sort_by, "SortDirection": sort_direction, "ValidUntilDate": serialize.iso8601_datetime(valid_until_date), @@ -858,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( @@ -886,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`. @@ -906,7 +943,7 @@ async def page_async( "RegulationSid": regulation_sid, "IsoCountry": iso_country, "NumberType": number_type, - "HasValidUntilDate": has_valid_until_date, + "HasValidUntilDate": serialize.boolean_to_string(has_valid_until_date), "SortBy": sort_by, "SortDirection": sort_direction, "ValidUntilDate": serialize.iso8601_datetime(valid_until_date), @@ -918,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 5a0cf036b9..d20a569690 100644 --- a/twilio/rest/numbers/v2/regulatory_compliance/bundle/bundle_copy.py +++ b/twilio/rest/numbers/v2/regulatory_compliance/bundle/bundle_copy.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class BundleCopyInstance(InstanceResource): + class Status(object): DRAFT = "draft" PENDING_REVIEW = "pending-review" @@ -80,6 +80,7 @@ def __repr__(self) -> str: class BundleCopyPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> BundleCopyInstance: """ Build an instance of BundleCopyInstance @@ -100,6 +101,7 @@ def __repr__(self) -> str: class BundleCopyList(ListResource): + def __init__(self, version: Version, bundle_sid: str): """ Initialize the BundleCopyList @@ -128,16 +130,20 @@ def create( :returns: The created BundleCopyInstance """ + data = values.of( { "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( @@ -154,16 +160,20 @@ async def create_async( :returns: The created BundleCopyInstance """ + data = values.of( { "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( @@ -297,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( @@ -324,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 53ad9d7694..fd45064808 100644 --- a/twilio/rest/numbers/v2/regulatory_compliance/bundle/evaluation.py +++ b/twilio/rest/numbers/v2/regulatory_compliance/bundle/evaluation.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class EvaluationInstance(InstanceResource): + class Status(object): COMPLIANT = "compliant" NONCOMPLIANT = "noncompliant" @@ -53,7 +53,7 @@ def __init__( self.regulation_sid: Optional[str] = payload.get("regulation_sid") self.bundle_sid: Optional[str] = payload.get("bundle_sid") self.status: Optional["EvaluationInstance.Status"] = payload.get("status") - self.results: Optional[List[object]] = payload.get("results") + self.results: Optional[List[Dict[str, object]]] = payload.get("results") self.date_created: Optional[datetime] = deserialize.iso8601_datetime( payload.get("date_created") ) @@ -110,6 +110,7 @@ def __repr__(self) -> str: class EvaluationContext(InstanceContext): + def __init__(self, version: Version, bundle_sid: str, sid: str): """ Initialize the EvaluationContext @@ -139,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, @@ -159,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( @@ -182,6 +187,7 @@ def __repr__(self) -> str: class EvaluationPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> EvaluationInstance: """ Build an instance of EvaluationInstance @@ -202,6 +208,7 @@ def __repr__(self) -> str: class EvaluationList(ListResource): + def __init__(self, version: Version, bundle_sid: str): """ Initialize the EvaluationList @@ -228,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"] @@ -245,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( @@ -381,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( @@ -408,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 f5f36206bf..4eb1fe2b33 100644 --- a/twilio/rest/numbers/v2/regulatory_compliance/bundle/item_assignment.py +++ b/twilio/rest/numbers/v2/regulatory_compliance/bundle/item_assignment.py @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class ItemAssignmentInstance(InstanceResource): - """ :ivar sid: The unique string that we created to identify the Item Assignment resource. :ivar bundle_sid: The unique string that we created to identify the Bundle resource. @@ -121,6 +119,7 @@ def __repr__(self) -> str: class ItemAssignmentContext(InstanceContext): + def __init__(self, version: Version, bundle_sid: str, sid: str): """ Initialize the ItemAssignmentContext @@ -149,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: """ @@ -161,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: @@ -174,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, @@ -194,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( @@ -217,6 +222,7 @@ def __repr__(self) -> str: class ItemAssignmentPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ItemAssignmentInstance: """ Build an instance of ItemAssignmentInstance @@ -237,6 +243,7 @@ def __repr__(self) -> str: class ItemAssignmentList(ListResource): + def __init__(self, version: Version, bundle_sid: str): """ Initialize the ItemAssignmentList @@ -263,16 +270,20 @@ def create(self, object_sid: str) -> ItemAssignmentInstance: :returns: The created ItemAssignmentInstance """ + data = values.of( { "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( @@ -287,16 +298,20 @@ async def create_async(self, object_sid: str) -> ItemAssignmentInstance: :returns: The created ItemAssignmentInstance """ + data = values.of( { "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( @@ -430,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( @@ -457,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 e8ab99ad71..a6a1de024d 100644 --- a/twilio/rest/numbers/v2/regulatory_compliance/bundle/replace_items.py +++ b/twilio/rest/numbers/v2/regulatory_compliance/bundle/replace_items.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import datetime from typing import Any, Dict, Optional from twilio.base import deserialize, values @@ -23,6 +22,7 @@ class ReplaceItemsInstance(InstanceResource): + class Status(object): DRAFT = "draft" PENDING_REVIEW = "pending-review" @@ -79,6 +79,7 @@ def __repr__(self) -> str: class ReplaceItemsList(ListResource): + def __init__(self, version: Version, bundle_sid: str): """ Initialize the ReplaceItemsList @@ -105,16 +106,20 @@ def create(self, from_bundle_sid: str) -> ReplaceItemsInstance: :returns: The created ReplaceItemsInstance """ + data = values.of( { "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( @@ -129,16 +134,20 @@ async def create_async(self, from_bundle_sid: str) -> ReplaceItemsInstance: :returns: The created ReplaceItemsInstance """ + data = values.of( { "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 f9bc9d270f..ab1803372a 100644 --- a/twilio/rest/numbers/v2/regulatory_compliance/end_user.py +++ b/twilio/rest/numbers/v2/regulatory_compliance/end_user.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class EndUserInstance(InstanceResource): + class Type(object): INDIVIDUAL = "individual" BUSINESS = "business" @@ -160,6 +160,7 @@ def __repr__(self) -> str: class EndUserContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the EndUserContext @@ -182,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: """ @@ -194,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: @@ -207,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, @@ -226,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( @@ -250,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"]) @@ -278,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"]) @@ -304,6 +319,7 @@ def __repr__(self) -> str: class EndUserPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> EndUserInstance: """ Build an instance of EndUserInstance @@ -322,6 +338,7 @@ def __repr__(self) -> str: class EndUserList(ListResource): + def __init__(self, version: Version): """ Initialize the EndUserList @@ -348,6 +365,7 @@ def create( :returns: The created EndUserInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -355,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) @@ -379,6 +400,7 @@ async def create_async( :returns: The created EndUserInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -386,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) @@ -522,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( @@ -549,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 0a762cea38..f14c8905c7 100644 --- a/twilio/rest/numbers/v2/regulatory_compliance/end_user_type.py +++ b/twilio/rest/numbers/v2/regulatory_compliance/end_user_type.py @@ -12,7 +12,6 @@ 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 @@ -23,7 +22,6 @@ class EndUserTypeInstance(InstanceResource): - """ :ivar sid: The unique string that identifies the End-User Type resource. :ivar friendly_name: A human-readable description that is assigned to describe the End-User Type resource. Examples can include first name, last name, email, business name, etc @@ -40,7 +38,7 @@ def __init__( self.sid: Optional[str] = payload.get("sid") self.friendly_name: Optional[str] = payload.get("friendly_name") self.machine_name: Optional[str] = payload.get("machine_name") - self.fields: Optional[List[object]] = payload.get("fields") + self.fields: Optional[List[Dict[str, object]]] = payload.get("fields") self.url: Optional[str] = payload.get("url") self._solution = { @@ -92,6 +90,7 @@ def __repr__(self) -> str: class EndUserTypeContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the EndUserTypeContext @@ -115,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, @@ -134,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( @@ -156,6 +159,7 @@ def __repr__(self) -> str: class EndUserTypePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> EndUserTypeInstance: """ Build an instance of EndUserTypeInstance @@ -174,6 +178,7 @@ def __repr__(self) -> str: class EndUserTypeList(ListResource): + def __init__(self, version: Version): """ Initialize the EndUserTypeList @@ -312,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( @@ -339,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 ab0bf1a332..9c1227905e 100644 --- a/twilio/rest/numbers/v2/regulatory_compliance/regulation.py +++ b/twilio/rest/numbers/v2/regulatory_compliance/regulation.py @@ -12,9 +12,8 @@ Do not edit the class manually. """ - 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 @@ -23,6 +22,7 @@ class RegulationInstance(InstanceResource): + class EndUserType(object): INDIVIDUAL = "individual" BUSINESS = "business" @@ -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: """ @@ -101,6 +111,7 @@ def __repr__(self) -> str: class RegulationContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the RegulationContext @@ -116,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( @@ -135,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( @@ -165,6 +200,7 @@ def __repr__(self) -> str: class RegulationPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> RegulationInstance: """ Build an instance of RegulationInstance @@ -183,6 +219,7 @@ def __repr__(self) -> str: class RegulationList(ListResource): + def __init__(self, version: Version): """ Initialize the RegulationList @@ -199,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]: @@ -211,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 @@ -225,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"], ) @@ -235,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]: @@ -247,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 @@ -261,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"], ) @@ -271,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]: @@ -282,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 @@ -296,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, ) @@ -306,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]: @@ -317,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 @@ -332,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, ) @@ -342,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, @@ -353,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 @@ -364,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( @@ -378,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, @@ -389,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 @@ -400,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 e619ecdc26..b72f993858 100644 --- a/twilio/rest/numbers/v2/regulatory_compliance/supporting_document.py +++ b/twilio/rest/numbers/v2/regulatory_compliance/supporting_document.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class SupportingDocumentInstance(InstanceResource): + class Status(object): DRAFT = "draft" PENDING_REVIEW = "pending-review" @@ -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( @@ -172,6 +174,7 @@ def __repr__(self) -> str: class SupportingDocumentContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the SupportingDocumentContext @@ -196,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: """ @@ -208,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: @@ -221,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, @@ -240,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( @@ -264,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( @@ -294,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( @@ -322,6 +339,7 @@ def __repr__(self) -> str: class SupportingDocumentPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> SupportingDocumentInstance: """ Build an instance of SupportingDocumentInstance @@ -340,6 +358,7 @@ def __repr__(self) -> str: class SupportingDocumentList(ListResource): + def __init__(self, version: Version): """ Initialize the SupportingDocumentList @@ -366,6 +385,7 @@ def create( :returns: The created SupportingDocumentInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -373,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) @@ -397,6 +420,7 @@ async def create_async( :returns: The created SupportingDocumentInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -404,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) @@ -540,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( @@ -567,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 65c097b994..692248cb45 100644 --- a/twilio/rest/numbers/v2/regulatory_compliance/supporting_document_type.py +++ b/twilio/rest/numbers/v2/regulatory_compliance/supporting_document_type.py @@ -12,7 +12,6 @@ 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 @@ -23,7 +22,6 @@ class SupportingDocumentTypeInstance(InstanceResource): - """ :ivar sid: The unique string that identifies the Supporting Document Type resource. :ivar friendly_name: A human-readable description of the Supporting Document Type resource. @@ -40,7 +38,7 @@ def __init__( self.sid: Optional[str] = payload.get("sid") self.friendly_name: Optional[str] = payload.get("friendly_name") self.machine_name: Optional[str] = payload.get("machine_name") - self.fields: Optional[List[object]] = payload.get("fields") + self.fields: Optional[List[Dict[str, object]]] = payload.get("fields") self.url: Optional[str] = payload.get("url") self._solution = { @@ -92,6 +90,7 @@ def __repr__(self) -> str: class SupportingDocumentTypeContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the SupportingDocumentTypeContext @@ -117,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, @@ -136,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( @@ -158,6 +161,7 @@ def __repr__(self) -> str: class SupportingDocumentTypePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> SupportingDocumentTypeInstance: """ Build an instance of SupportingDocumentTypeInstance @@ -176,6 +180,7 @@ def __repr__(self) -> str: class SupportingDocumentTypeList(ListResource): + def __init__(self, version: Version): """ Initialize the SupportingDocumentTypeList @@ -314,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( @@ -341,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/OauthBase.py b/twilio/rest/oauth/OauthBase.py index 3df051d0fc..87cbbac248 100644 --- a/twilio/rest/oauth/OauthBase.py +++ b/twilio/rest/oauth/OauthBase.py @@ -17,6 +17,7 @@ class OauthBase(Domain): + def __init__(self, twilio: Client): """ Initialize the Oauth Domain 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/__init__.py b/twilio/rest/oauth/v1/__init__.py index 36aaa90ff3..e05c7de520 100644 --- a/twilio/rest/oauth/v1/__init__.py +++ b/twilio/rest/oauth/v1/__init__.py @@ -15,14 +15,12 @@ from typing import Optional from twilio.base.version import Version from twilio.base.domain import Domain -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.authorize import AuthorizeList from twilio.rest.oauth.v1.token import TokenList -from twilio.rest.oauth.v1.user_info import UserInfoList class V1(Version): + def __init__(self, domain: Domain): """ Initialize the V1 version of Oauth @@ -30,29 +28,14 @@ def __init__(self, domain: Domain): :param domain: The Twilio.oauth domain """ super().__init__(domain, "v1") - self._device_code: Optional[DeviceCodeList] = None - self._oauth: Optional[OauthList] = None - self._openid_discovery: Optional[OpenidDiscoveryList] = None + self._authorize: Optional[AuthorizeList] = None self._token: Optional[TokenList] = None - self._user_info: Optional[UserInfoList] = None - - @property - def device_code(self) -> DeviceCodeList: - if self._device_code is None: - self._device_code = DeviceCodeList(self) - return self._device_code @property - def oauth(self) -> OauthList: - if self._oauth is None: - self._oauth = OauthList(self) - return self._oauth - - @property - def openid_discovery(self) -> OpenidDiscoveryList: - if self._openid_discovery is None: - self._openid_discovery = OpenidDiscoveryList(self) - return self._openid_discovery + def authorize(self) -> AuthorizeList: + if self._authorize is None: + self._authorize = AuthorizeList(self) + return self._authorize @property def token(self) -> TokenList: @@ -60,12 +43,6 @@ def token(self) -> TokenList: self._token = TokenList(self) return self._token - @property - def user_info(self) -> UserInfoList: - if self._user_info is None: - self._user_info = UserInfoList(self) - return self._user_info - def __repr__(self) -> str: """ Provide a friendly representation diff --git a/twilio/rest/oauth/v1/authorize.py b/twilio/rest/oauth/v1/authorize.py new file mode 100644 index 0000000000..a353c4b8e0 --- /dev/null +++ b/twilio/rest/oauth/v1/authorize.py @@ -0,0 +1,130 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Oauth + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from typing import Any, Dict, Optional, 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( + { + "ResponseType": response_type, + "ClientId": client_id, + "RedirectUri": 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( + { + "ResponseType": response_type, + "ClientId": client_id, + "RedirectUri": 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/oauth/v1/device_code.py b/twilio/rest/oauth/v1/device_code.py deleted file mode 100644 index ed0998ee94..0000000000 --- a/twilio/rest/oauth/v1/device_code.py +++ /dev/null @@ -1,137 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Oauth - This is the public Twilio REST API. - - NOTE: This class is auto generated by OpenAPI Generator. - https://openapi-generator.tech - Do not edit the class manually. -""" - - -from typing import Any, Dict, 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 DeviceCodeInstance(InstanceResource): - - """ - :ivar device_code: The device verification code. - :ivar user_code: The verification code which end user uses to verify authorization request. - :ivar verification_uri: The URI that the end user visits to verify authorization request. - :ivar verification_uri_complete: The URI with user_code that the end-user alternatively visits to verify authorization request. - :ivar expires_in: The expiration time of the device_code and user_code in seconds. - :ivar interval: The minimum amount of time in seconds that the client should wait between polling requests to the token endpoint. - """ - - def __init__(self, version: Version, payload: Dict[str, Any]): - super().__init__(version) - - self.device_code: Optional[str] = payload.get("device_code") - self.user_code: Optional[str] = payload.get("user_code") - self.verification_uri: Optional[str] = payload.get("verification_uri") - self.verification_uri_complete: Optional[str] = payload.get( - "verification_uri_complete" - ) - self.expires_in: Optional[int] = payload.get("expires_in") - self.interval: Optional[int] = deserialize.integer(payload.get("interval")) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - - return "" - - -class DeviceCodeList(ListResource): - def __init__(self, version: Version): - """ - Initialize the DeviceCodeList - - :param version: Version that contains the resource - - """ - super().__init__(version) - - self._uri = "/device/code" - - def create( - self, - client_sid: str, - scopes: List[str], - audiences: Union[List[str], object] = values.unset, - ) -> DeviceCodeInstance: - """ - Create the DeviceCodeInstance - - :param client_sid: A 34 character string that uniquely identifies this OAuth App. - :param scopes: An Array of scopes for authorization request - :param audiences: An array of intended audiences for token requests - - :returns: The created DeviceCodeInstance - """ - data = values.of( - { - "ClientSid": client_sid, - "Scopes": serialize.map(scopes, lambda e: e), - "Audiences": serialize.map(audiences, lambda e: e), - } - ) - - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) - - return DeviceCodeInstance(self._version, payload) - - async def create_async( - self, - client_sid: str, - scopes: List[str], - audiences: Union[List[str], object] = values.unset, - ) -> DeviceCodeInstance: - """ - Asynchronously create the DeviceCodeInstance - - :param client_sid: A 34 character string that uniquely identifies this OAuth App. - :param scopes: An Array of scopes for authorization request - :param audiences: An array of intended audiences for token requests - - :returns: The created DeviceCodeInstance - """ - data = values.of( - { - "ClientSid": client_sid, - "Scopes": serialize.map(scopes, lambda e: e), - "Audiences": serialize.map(audiences, lambda e: e), - } - ) - - payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, - ) - - return DeviceCodeInstance(self._version, payload) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/oauth/v1/oauth.py b/twilio/rest/oauth/v1/oauth.py deleted file mode 100644 index 3765b65180..0000000000 --- a/twilio/rest/oauth/v1/oauth.py +++ /dev/null @@ -1,167 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Oauth - This is the public Twilio REST API. - - NOTE: This class is auto generated by OpenAPI Generator. - https://openapi-generator.tech - Do not edit the class manually. -""" - - -from typing import Any, Dict, Optional -from twilio.base.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 OauthInstance(InstanceResource): - - """ - :ivar keys: A collection of certificates where are signed Twilio-issued tokens. - :ivar url: - """ - - def __init__(self, version: Version, payload: Dict[str, Any]): - super().__init__(version) - - self.keys: Optional[Dict[str, object]] = payload.get("keys") - self.url: Optional[str] = payload.get("url") - - self._context: Optional[OauthContext] = None - - @property - def _proxy(self) -> "OauthContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: OauthContext for this OauthInstance - """ - if self._context is None: - self._context = OauthContext( - self._version, - ) - return self._context - - def fetch(self) -> "OauthInstance": - """ - Fetch the OauthInstance - - - :returns: The fetched OauthInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "OauthInstance": - """ - Asynchronous coroutine to fetch the OauthInstance - - - :returns: The fetched OauthInstance - """ - return await self._proxy.fetch_async() - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - - return "" - - -class OauthContext(InstanceContext): - def __init__(self, version: Version): - """ - Initialize the OauthContext - - :param version: Version that contains the resource - """ - super().__init__(version) - - self._uri = "/certs" - - def fetch(self) -> OauthInstance: - """ - Fetch the OauthInstance - - - :returns: The fetched OauthInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return OauthInstance( - self._version, - payload, - ) - - async def fetch_async(self) -> OauthInstance: - """ - Asynchronous coroutine to fetch the OauthInstance - - - :returns: The fetched OauthInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return OauthInstance( - self._version, - payload, - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - - return "" - - -class OauthList(ListResource): - def __init__(self, version: Version): - """ - Initialize the OauthList - - :param version: Version that contains the resource - - """ - super().__init__(version) - - def get(self) -> OauthContext: - """ - Constructs a OauthContext - - """ - return OauthContext(self._version) - - def __call__(self) -> OauthContext: - """ - Constructs a OauthContext - - """ - return OauthContext(self._version) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/oauth/v1/openid_discovery.py b/twilio/rest/oauth/v1/openid_discovery.py deleted file mode 100644 index 00a551a2fe..0000000000 --- a/twilio/rest/oauth/v1/openid_discovery.py +++ /dev/null @@ -1,199 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Oauth - This is the public Twilio REST API. - - NOTE: This class is auto generated by OpenAPI Generator. - https://openapi-generator.tech - Do not edit the class manually. -""" - - -from typing import Any, Dict, List, Optional -from twilio.base.instance_context import InstanceContext -from twilio.base.instance_resource import InstanceResource -from twilio.base.list_resource import ListResource -from twilio.base.version import Version - - -class OpenidDiscoveryInstance(InstanceResource): - - """ - :ivar issuer: The URL of the party that will create the token and sign it with its private key. - :ivar authorization_endpoint: The endpoint that validates all authorization requests. - :ivar device_authorization_endpoint: The endpoint that validates all device code related authorization requests. - :ivar token_endpoint: The URL of the token endpoint. After a client has received an authorization code, that code is presented to the token endpoint and exchanged for an identity token, an access token, and a refresh token. - :ivar userinfo_endpoint: The URL of the user info endpoint, which returns user profile information to a client. Keep in mind that the user info endpoint returns only the information that has been requested. - :ivar revocation_endpoint: The endpoint used to revoke access or refresh tokens issued by the authorization server. - :ivar jwk_uri: The URL of your JSON Web Key Set. This set is a collection of JSON Web Keys, a standard method for representing cryptographic keys in a JSON structure. - :ivar response_type_supported: A collection of response type supported by authorization server. - :ivar subject_type_supported: A collection of subject by authorization server. - :ivar id_token_signing_alg_values_supported: A collection of JWS signing algorithms supported by authorization server to sign identity token. - :ivar scopes_supported: A collection of scopes supported by authorization server for identity token - :ivar claims_supported: A collection of claims supported by authorization server for identity token - :ivar url: - """ - - def __init__(self, version: Version, payload: Dict[str, Any]): - super().__init__(version) - - self.issuer: Optional[str] = payload.get("issuer") - self.authorization_endpoint: Optional[str] = payload.get( - "authorization_endpoint" - ) - self.device_authorization_endpoint: Optional[str] = payload.get( - "device_authorization_endpoint" - ) - self.token_endpoint: Optional[str] = payload.get("token_endpoint") - self.userinfo_endpoint: Optional[str] = payload.get("userinfo_endpoint") - self.revocation_endpoint: Optional[str] = payload.get("revocation_endpoint") - self.jwk_uri: Optional[str] = payload.get("jwk_uri") - self.response_type_supported: Optional[List[str]] = payload.get( - "response_type_supported" - ) - self.subject_type_supported: Optional[List[str]] = payload.get( - "subject_type_supported" - ) - self.id_token_signing_alg_values_supported: Optional[List[str]] = payload.get( - "id_token_signing_alg_values_supported" - ) - self.scopes_supported: Optional[List[str]] = payload.get("scopes_supported") - self.claims_supported: Optional[List[str]] = payload.get("claims_supported") - self.url: Optional[str] = payload.get("url") - - self._context: Optional[OpenidDiscoveryContext] = None - - @property - def _proxy(self) -> "OpenidDiscoveryContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: OpenidDiscoveryContext for this OpenidDiscoveryInstance - """ - if self._context is None: - self._context = OpenidDiscoveryContext( - self._version, - ) - return self._context - - def fetch(self) -> "OpenidDiscoveryInstance": - """ - Fetch the OpenidDiscoveryInstance - - - :returns: The fetched OpenidDiscoveryInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "OpenidDiscoveryInstance": - """ - Asynchronous coroutine to fetch the OpenidDiscoveryInstance - - - :returns: The fetched OpenidDiscoveryInstance - """ - return await self._proxy.fetch_async() - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - - return "" - - -class OpenidDiscoveryContext(InstanceContext): - def __init__(self, version: Version): - """ - Initialize the OpenidDiscoveryContext - - :param version: Version that contains the resource - """ - super().__init__(version) - - self._uri = "/.well-known/openid-configuration" - - def fetch(self) -> OpenidDiscoveryInstance: - """ - Fetch the OpenidDiscoveryInstance - - - :returns: The fetched OpenidDiscoveryInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return OpenidDiscoveryInstance( - self._version, - payload, - ) - - async def fetch_async(self) -> OpenidDiscoveryInstance: - """ - Asynchronous coroutine to fetch the OpenidDiscoveryInstance - - - :returns: The fetched OpenidDiscoveryInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return OpenidDiscoveryInstance( - self._version, - payload, - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - - return "" - - -class OpenidDiscoveryList(ListResource): - def __init__(self, version: Version): - """ - Initialize the OpenidDiscoveryList - - :param version: Version that contains the resource - - """ - super().__init__(version) - - def get(self) -> OpenidDiscoveryContext: - """ - Constructs a OpenidDiscoveryContext - - """ - return OpenidDiscoveryContext(self._version) - - def __call__(self) -> OpenidDiscoveryContext: - """ - Constructs a OpenidDiscoveryContext - - """ - return OpenidDiscoveryContext(self._version) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/oauth/v1/token.py b/twilio/rest/oauth/v1/token.py index d236731a9f..18de1008cb 100644 --- a/twilio/rest/oauth/v1/token.py +++ b/twilio/rest/oauth/v1/token.py @@ -12,10 +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 @@ -23,13 +21,12 @@ 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: - :ivar refresh_token_expires_at: The date and time in GMT when the refresh token expires in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. - :ivar access_token_expires_at: The date and time in GMT when the refresh token expires in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. + :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]): @@ -38,12 +35,8 @@ def __init__(self, version: Version, payload: Dict[str, Any]): 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.refresh_token_expires_at: Optional[ - datetime - ] = deserialize.iso8601_datetime(payload.get("refresh_token_expires_at")) - self.access_token_expires_at: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("access_token_expires_at") - ) + self.token_type: Optional[str] = payload.get("token_type") + self.expires_in: Optional[int] = payload.get("expires_in") def __repr__(self) -> str: """ @@ -56,6 +49,7 @@ def __repr__(self) -> str: class TokenList(ListResource): + def __init__(self, version: Version): """ Initialize the TokenList @@ -70,45 +64,49 @@ def __init__(self, version: Version): def create( self, grant_type: str, - client_sid: str, + client_id: str, client_secret: Union[str, object] = values.unset, code: Union[str, object] = values.unset, - code_verifier: Union[str, object] = values.unset, - device_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, - device_id: 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_sid: A 34 character string that uniquely identifies this OAuth App. + :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 code_verifier: A code which is generation cryptographically. - :param device_code: JWT token related to the device code grant type. - :param refresh_token: JWT token related to the refresh token grant type. - :param device_id: The Id of the device associated with the token (refresh token). + :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( { "GrantType": grant_type, - "ClientSid": client_sid, + "ClientId": client_id, "ClientSecret": client_secret, "Code": code, - "CodeVerifier": code_verifier, - "DeviceCode": device_code, + "RedirectUri": redirect_uri, + "Audience": audience, "RefreshToken": refresh_token, - "DeviceId": device_id, + "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) @@ -116,45 +114,49 @@ def create( async def create_async( self, grant_type: str, - client_sid: str, + client_id: str, client_secret: Union[str, object] = values.unset, code: Union[str, object] = values.unset, - code_verifier: Union[str, object] = values.unset, - device_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, - device_id: 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_sid: A 34 character string that uniquely identifies this OAuth App. + :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 code_verifier: A code which is generation cryptographically. - :param device_code: JWT token related to the device code grant type. - :param refresh_token: JWT token related to the refresh token grant type. - :param device_id: The Id of the device associated with the token (refresh token). + :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( { "GrantType": grant_type, - "ClientSid": client_sid, + "ClientId": client_id, "ClientSecret": client_secret, "Code": code, - "CodeVerifier": code_verifier, - "DeviceCode": device_code, + "RedirectUri": redirect_uri, + "Audience": audience, "RefreshToken": refresh_token, - "DeviceId": device_id, + "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/oauth/v1/user_info.py b/twilio/rest/oauth/v1/user_info.py deleted file mode 100644 index f7b7f0f5df..0000000000 --- a/twilio/rest/oauth/v1/user_info.py +++ /dev/null @@ -1,175 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Oauth - This is the public Twilio REST API. - - NOTE: This class is auto generated by OpenAPI Generator. - https://openapi-generator.tech - Do not edit the class manually. -""" - - -from typing import Any, Dict, Optional -from twilio.base.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 UserInfoInstance(InstanceResource): - - """ - :ivar user_sid: The URL of the party that will create the token and sign it with its private key. - :ivar first_name: The first name of the end-user. - :ivar last_name: The last name of the end-user. - :ivar friendly_name: The friendly name of the end-user. - :ivar email: The end-user's preferred email address. - :ivar url: - """ - - def __init__(self, version: Version, payload: Dict[str, Any]): - super().__init__(version) - - self.user_sid: Optional[str] = payload.get("user_sid") - self.first_name: Optional[str] = payload.get("first_name") - self.last_name: Optional[str] = payload.get("last_name") - self.friendly_name: Optional[str] = payload.get("friendly_name") - self.email: Optional[str] = payload.get("email") - self.url: Optional[str] = payload.get("url") - - self._context: Optional[UserInfoContext] = None - - @property - def _proxy(self) -> "UserInfoContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: UserInfoContext for this UserInfoInstance - """ - if self._context is None: - self._context = UserInfoContext( - self._version, - ) - return self._context - - def fetch(self) -> "UserInfoInstance": - """ - Fetch the UserInfoInstance - - - :returns: The fetched UserInfoInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "UserInfoInstance": - """ - Asynchronous coroutine to fetch the UserInfoInstance - - - :returns: The fetched UserInfoInstance - """ - return await self._proxy.fetch_async() - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - - return "" - - -class UserInfoContext(InstanceContext): - def __init__(self, version: Version): - """ - Initialize the UserInfoContext - - :param version: Version that contains the resource - """ - super().__init__(version) - - self._uri = "/userinfo" - - def fetch(self) -> UserInfoInstance: - """ - Fetch the UserInfoInstance - - - :returns: The fetched UserInfoInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return UserInfoInstance( - self._version, - payload, - ) - - async def fetch_async(self) -> UserInfoInstance: - """ - Asynchronous coroutine to fetch the UserInfoInstance - - - :returns: The fetched UserInfoInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return UserInfoInstance( - self._version, - payload, - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - - return "" - - -class UserInfoList(ListResource): - def __init__(self, version: Version): - """ - Initialize the UserInfoList - - :param version: Version that contains the resource - - """ - super().__init__(version) - - def get(self) -> UserInfoContext: - """ - Constructs a UserInfoContext - - """ - return UserInfoContext(self._version) - - def __call__(self) -> UserInfoContext: - """ - Constructs a UserInfoContext - - """ - return UserInfoContext(self._version) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview/PreviewBase.py b/twilio/rest/preview/PreviewBase.py index 73d5aac4bd..dd8317b4c0 100644 --- a/twilio/rest/preview/PreviewBase.py +++ b/twilio/rest/preview/PreviewBase.py @@ -13,15 +13,13 @@ 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.understand import Understand from twilio.rest.preview.wireless import Wireless class PreviewBase(Domain): + def __init__(self, twilio: Client): """ Initialize the Preview Domain @@ -29,22 +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._understand: Optional[Understand] = 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: """ @@ -54,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: """ @@ -72,15 +49,6 @@ def marketplace(self) -> Marketplace: self._marketplace = Marketplace(self) return self._marketplace - @property - def understand(self) -> Understand: - """ - :returns: Versions understand of Preview - """ - if self._understand is None: - self._understand = Understand(self) - return self._understand - @property def wireless(self) -> Wireless: """ diff --git a/twilio/rest/preview/__init__.py b/twilio/rest/preview/__init__.py index 6933f3627c..7a175b902a 100644 --- a/twilio/rest/preview/__init__.py +++ b/twilio/rest/preview/__init__.py @@ -1,29 +1,18 @@ 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, ) from twilio.rest.preview.hosted_numbers.hosted_number_order import HostedNumberOrderList from twilio.rest.preview.marketplace.available_add_on import AvailableAddOnList from twilio.rest.preview.marketplace.installed_add_on import InstalledAddOnList -from twilio.rest.preview.sync.service import ServiceList -from twilio.rest.preview.understand.assistant import AssistantList from twilio.rest.preview.wireless.command import CommandList from twilio.rest.preview.wireless.rate_plan import RatePlanList from twilio.rest.preview.wireless.sim import SimList 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: @@ -70,15 +59,6 @@ def services(self) -> ServiceList: ) return self.sync.services - @property - def assistants(self) -> AssistantList: - warn( - "assistants is deprecated. Use understand.assistants instead.", - DeprecationWarning, - stacklevel=2, - ) - return self.understand.assistants - @property def commands(self) -> CommandList: warn( 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 cb0c45498a..0000000000 --- a/twilio/rest/preview/deployed_devices/fleet/__init__.py +++ /dev/null @@ -1,673 +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 a6654de67e..0000000000 --- a/twilio/rest/preview/deployed_devices/fleet/certificate.py +++ /dev/null @@ -1,655 +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 5dbda65c66..0000000000 --- a/twilio/rest/preview/deployed_devices/fleet/deployment.py +++ /dev/null @@ -1,629 +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 afaa0fce2a..0000000000 --- a/twilio/rest/preview/deployed_devices/fleet/device.py +++ /dev/null @@ -1,699 +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 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": 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": 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": 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": 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 9bcfd8fb0f..0000000000 --- a/twilio/rest/preview/deployed_devices/fleet/key.py +++ /dev/null @@ -1,645 +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/__init__.py b/twilio/rest/preview/hosted_numbers/__init__.py index fd46160426..7b3a767eef 100644 --- a/twilio/rest/preview/hosted_numbers/__init__.py +++ b/twilio/rest/preview/hosted_numbers/__init__.py @@ -22,6 +22,7 @@ class HostedNumbers(Version): + def __init__(self, domain: Domain): """ Initialize the HostedNumbers version of Preview diff --git a/twilio/rest/preview/hosted_numbers/authorization_document/__init__.py b/twilio/rest/preview/hosted_numbers/authorization_document/__init__.py index 8d04498859..49d3d40da5 100644 --- a/twilio/rest/preview/hosted_numbers/authorization_document/__init__.py +++ b/twilio/rest/preview/hosted_numbers/authorization_document/__init__.py @@ -12,7 +12,6 @@ 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 @@ -27,6 +26,7 @@ class AuthorizationDocumentInstance(InstanceResource): + class Status(object): OPENED = "opened" SIGNING = "signing" @@ -191,12 +191,13 @@ def __repr__(self) -> str: class AuthorizationDocumentContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the AuthorizationDocumentContext :param version: Version that contains the resource - :param sid: + :param sid: A 34 character string that uniquely identifies this AuthorizationDocument. """ super().__init__(version) @@ -218,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, @@ -237,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( @@ -271,6 +276,7 @@ def update( :returns: The updated AuthorizationDocumentInstance """ + data = values.of( { "HostedNumberOrderSids": serialize.map( @@ -284,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( @@ -318,6 +327,7 @@ async def update_async( :returns: The updated AuthorizationDocumentInstance """ + data = values.of( { "HostedNumberOrderSids": serialize.map( @@ -331,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( @@ -367,6 +380,7 @@ def __repr__(self) -> str: class AuthorizationDocumentPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> AuthorizationDocumentInstance: """ Build an instance of AuthorizationDocumentInstance @@ -385,6 +399,7 @@ def __repr__(self) -> str: class AuthorizationDocumentList(ListResource): + def __init__(self, version: Version): """ Initialize the AuthorizationDocumentList @@ -417,6 +432,7 @@ def create( :returns: The created AuthorizationDocumentInstance """ + data = values.of( { "HostedNumberOrderSids": serialize.map( @@ -429,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) @@ -459,6 +478,7 @@ async def create_async( :returns: The created AuthorizationDocumentInstance """ + data = values.of( { "HostedNumberOrderSids": serialize.map( @@ -471,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) @@ -494,7 +517,7 @@ def stream( The results are returned as a generator, so this operation is memory efficient. :param str email: Email that this AuthorizationDocument will be sent to for signing. - :param "AuthorizationDocumentInstance.Status" status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/api/phone-numbers/hosted-number-authorization-documents#status-values) for more information on each of these statuses. + :param "AuthorizationDocumentInstance.Status" status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses. :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 @@ -523,7 +546,7 @@ async def stream_async( The results are returned as a generator, so this operation is memory efficient. :param str email: Email that this AuthorizationDocument will be sent to for signing. - :param "AuthorizationDocumentInstance.Status" status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/api/phone-numbers/hosted-number-authorization-documents#status-values) for more information on each of these statuses. + :param "AuthorizationDocumentInstance.Status" status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses. :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 @@ -553,7 +576,7 @@ def list( memory before returning. :param str email: Email that this AuthorizationDocument will be sent to for signing. - :param "AuthorizationDocumentInstance.Status" status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/api/phone-numbers/hosted-number-authorization-documents#status-values) for more information on each of these statuses. + :param "AuthorizationDocumentInstance.Status" status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses. :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 @@ -585,7 +608,7 @@ async def list_async( memory before returning. :param str email: Email that this AuthorizationDocument will be sent to for signing. - :param "AuthorizationDocumentInstance.Status" status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/api/phone-numbers/hosted-number-authorization-documents#status-values) for more information on each of these statuses. + :param "AuthorizationDocumentInstance.Status" status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses. :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 @@ -618,7 +641,7 @@ def page( Request is executed immediately :param email: Email that this AuthorizationDocument will be sent to for signing. - :param status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/api/phone-numbers/hosted-number-authorization-documents#status-values) for more information on each of these statuses. + :param status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses. :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 @@ -635,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( @@ -651,7 +680,7 @@ async def page_async( Request is executed immediately :param email: Email that this AuthorizationDocument will be sent to for signing. - :param status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/api/phone-numbers/hosted-number-authorization-documents#status-values) for more information on each of these statuses. + :param status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses. :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 @@ -668,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) @@ -701,7 +734,7 @@ def get(self, sid: str) -> AuthorizationDocumentContext: """ Constructs a AuthorizationDocumentContext - :param sid: + :param sid: A 34 character string that uniquely identifies this AuthorizationDocument. """ return AuthorizationDocumentContext(self._version, sid=sid) @@ -709,7 +742,7 @@ def __call__(self, sid: str) -> AuthorizationDocumentContext: """ Constructs a AuthorizationDocumentContext - :param sid: + :param sid: A 34 character string that uniquely identifies this AuthorizationDocument. """ return AuthorizationDocumentContext(self._version, sid=sid) 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 836c06fd99..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 @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class DependentHostedNumberOrderInstance(InstanceResource): + class Status(object): RECEIVED = "received" PENDING_VERIFICATION = "pending-verification" @@ -80,9 +80,9 @@ def __init__( self.capabilities: Optional[str] = payload.get("capabilities") self.friendly_name: Optional[str] = payload.get("friendly_name") self.unique_name: Optional[str] = payload.get("unique_name") - self.status: Optional[ - "DependentHostedNumberOrderInstance.Status" - ] = payload.get("status") + self.status: Optional["DependentHostedNumberOrderInstance.Status"] = ( + payload.get("status") + ) self.failure_reason: Optional[str] = payload.get("failure_reason") self.date_created: Optional[datetime] = deserialize.iso8601_datetime( payload.get("date_created") @@ -125,6 +125,7 @@ def __repr__(self) -> str: class DependentHostedNumberOrderPage(Page): + def get_instance( self, payload: Dict[str, Any] ) -> DependentHostedNumberOrderInstance: @@ -149,12 +150,13 @@ def __repr__(self) -> str: class DependentHostedNumberOrderList(ListResource): + def __init__(self, version: Version, signing_document_sid: str): """ Initialize the DependentHostedNumberOrderList :param version: Version that contains the resource - :param signing_document_sid: + :param signing_document_sid: A 34 character string that uniquely identifies the LOA document associated with this HostedNumberOrder. """ super().__init__(version) @@ -185,7 +187,7 @@ def stream( is reached. The results are returned as a generator, so this operation is memory efficient. - :param "DependentHostedNumberOrderInstance.Status" status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/api/phone-numbers/hosted-number-authorization-documents#status-values) for more information on each of these statuses. + :param "DependentHostedNumberOrderInstance.Status" status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses. :param str phone_number: An E164 formatted phone number hosted by this HostedNumberOrder. :param str incoming_phone_number_sid: A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder. :param str friendly_name: A human readable description of this resource, up to 64 characters. @@ -229,7 +231,7 @@ async def stream_async( is reached. The results are returned as a generator, so this operation is memory efficient. - :param "DependentHostedNumberOrderInstance.Status" status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/api/phone-numbers/hosted-number-authorization-documents#status-values) for more information on each of these statuses. + :param "DependentHostedNumberOrderInstance.Status" status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses. :param str phone_number: An E164 formatted phone number hosted by this HostedNumberOrder. :param str incoming_phone_number_sid: A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder. :param str friendly_name: A human readable description of this resource, up to 64 characters. @@ -272,7 +274,7 @@ def list( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param "DependentHostedNumberOrderInstance.Status" status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/api/phone-numbers/hosted-number-authorization-documents#status-values) for more information on each of these statuses. + :param "DependentHostedNumberOrderInstance.Status" status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses. :param str phone_number: An E164 formatted phone number hosted by this HostedNumberOrder. :param str incoming_phone_number_sid: A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder. :param str friendly_name: A human readable description of this resource, up to 64 characters. @@ -315,7 +317,7 @@ async def list_async( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param "DependentHostedNumberOrderInstance.Status" status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/api/phone-numbers/hosted-number-authorization-documents#status-values) for more information on each of these statuses. + :param "DependentHostedNumberOrderInstance.Status" status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses. :param str phone_number: An E164 formatted phone number hosted by this HostedNumberOrder. :param str incoming_phone_number_sid: A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder. :param str friendly_name: A human readable description of this resource, up to 64 characters. @@ -359,7 +361,7 @@ def page( Retrieve a single page of DependentHostedNumberOrderInstance records from the API. Request is executed immediately - :param status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/api/phone-numbers/hosted-number-authorization-documents#status-values) for more information on each of these statuses. + :param status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses. :param phone_number: An E164 formatted phone number hosted by this HostedNumberOrder. :param incoming_phone_number_sid: A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder. :param friendly_name: A human readable description of this resource, up to 64 characters. @@ -383,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( @@ -403,7 +411,7 @@ async def page_async( Asynchronously retrieve a single page of DependentHostedNumberOrderInstance records from the API. Request is executed immediately - :param status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/api/phone-numbers/hosted-number-authorization-documents#status-values) for more information on each of these statuses. + :param status: Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource#status-values) for more information on each of these statuses. :param phone_number: An E164 formatted phone number hosted by this HostedNumberOrder. :param incoming_phone_number_sid: A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder. :param friendly_name: A human readable description of this resource, up to 64 characters. @@ -427,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 1c34e99769..0c20af8791 100644 --- a/twilio/rest/preview/hosted_numbers/hosted_number_order.py +++ b/twilio/rest/preview/hosted_numbers/hosted_number_order.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class HostedNumberOrderInstance(InstanceResource): + class Status(object): RECEIVED = "received" PENDING_VERIFICATION = "pending-verification" @@ -42,9 +42,9 @@ class VerificationType(object): """ :ivar sid: A 34 character string that uniquely identifies this HostedNumberOrder. :ivar account_sid: A 34 character string that uniquely identifies the account. - :ivar incoming_phone_number_sid: A 34 character string that uniquely identifies the [IncomingPhoneNumber](https://www.twilio.com/docs/api/rest/incoming-phone-numbers) resource that represents the phone number being hosted. + :ivar incoming_phone_number_sid: A 34 character string that uniquely identifies the [IncomingPhoneNumber](https://www.twilio.com/docs/phone-numbers/api/incomingphonenumber-resource) resource that represents the phone number being hosted. :ivar address_sid: A 34 character string that uniquely identifies the Address resource that represents the address of the owner of this phone number. - :ivar signing_document_sid: A 34 character string that uniquely identifies the [Authorization Document](https://www.twilio.com/docs/api/phone-numbers/hosted-number-authorization-documents) the user needs to sign. + :ivar signing_document_sid: A 34 character string that uniquely identifies the [Authorization Document](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource) the user needs to sign. :ivar phone_number: Phone number to be hosted. This must be in [E.164](https://en.wikipedia.org/wiki/E.164) format, e.g., +16175551212 :ivar capabilities: :ivar friendly_name: A 64 character string that is a human-readable text that describes this resource. @@ -267,12 +267,13 @@ def __repr__(self) -> str: class HostedNumberOrderContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the HostedNumberOrderContext :param version: Version that contains the resource - :param sid: + :param sid: A 34 character string that uniquely identifies this HostedNumberOrder. """ super().__init__(version) @@ -289,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: """ @@ -301,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: @@ -314,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, @@ -333,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( @@ -375,6 +382,7 @@ def update( :returns: The updated HostedNumberOrderInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -389,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( @@ -431,6 +442,7 @@ async def update_async( :returns: The updated HostedNumberOrderInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -445,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( @@ -469,6 +484,7 @@ def __repr__(self) -> str: class HostedNumberOrderPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> HostedNumberOrderInstance: """ Build an instance of HostedNumberOrderInstance @@ -487,6 +503,7 @@ def __repr__(self) -> str: class HostedNumberOrderList(ListResource): + def __init__(self, version: Version): """ Initialize the HostedNumberOrderList @@ -543,10 +560,11 @@ def create( :returns: The created HostedNumberOrderInstance """ + data = values.of( { "PhoneNumber": phone_number, - "SmsCapability": sms_capability, + "SmsCapability": serialize.boolean_to_string(sms_capability), "AccountSid": account_sid, "FriendlyName": friendly_name, "UniqueName": unique_name, @@ -564,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) @@ -618,10 +639,11 @@ async def create_async( :returns: The created HostedNumberOrderInstance """ + data = values.of( { "PhoneNumber": phone_number, - "SmsCapability": sms_capability, + "SmsCapability": serialize.boolean_to_string(sms_capability), "AccountSid": account_sid, "FriendlyName": friendly_name, "UniqueName": unique_name, @@ -639,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) @@ -854,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( @@ -896,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) @@ -929,7 +964,7 @@ def get(self, sid: str) -> HostedNumberOrderContext: """ Constructs a HostedNumberOrderContext - :param sid: + :param sid: A 34 character string that uniquely identifies this HostedNumberOrder. """ return HostedNumberOrderContext(self._version, sid=sid) @@ -937,7 +972,7 @@ def __call__(self, sid: str) -> HostedNumberOrderContext: """ Constructs a HostedNumberOrderContext - :param sid: + :param sid: A 34 character string that uniquely identifies this HostedNumberOrder. """ return HostedNumberOrderContext(self._version, sid=sid) diff --git a/twilio/rest/preview/marketplace/__init__.py b/twilio/rest/preview/marketplace/__init__.py index d12d3ab0a5..fcc99a4112 100644 --- a/twilio/rest/preview/marketplace/__init__.py +++ b/twilio/rest/preview/marketplace/__init__.py @@ -20,6 +20,7 @@ class Marketplace(Version): + def __init__(self, domain: Domain): """ Initialize the Marketplace version of Preview diff --git a/twilio/rest/preview/marketplace/available_add_on/__init__.py b/twilio/rest/preview/marketplace/available_add_on/__init__.py index 776a33e9d9..e81ec649de 100644 --- a/twilio/rest/preview/marketplace/available_add_on/__init__.py +++ b/twilio/rest/preview/marketplace/available_add_on/__init__.py @@ -12,7 +12,6 @@ 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 @@ -26,7 +25,6 @@ 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. @@ -108,6 +106,7 @@ def __repr__(self) -> str: class AvailableAddOnContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the AvailableAddOnContext @@ -133,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, @@ -152,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( @@ -186,6 +189,7 @@ def __repr__(self) -> str: class AvailableAddOnPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> AvailableAddOnInstance: """ Build an instance of AvailableAddOnInstance @@ -204,6 +208,7 @@ def __repr__(self) -> str: class AvailableAddOnList(ListResource): + def __init__(self, version: Version): """ Initialize the AvailableAddOnList @@ -342,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( @@ -369,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 218b48ee3f..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 @@ -12,7 +12,6 @@ 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 @@ -23,7 +22,6 @@ 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. @@ -102,6 +100,7 @@ def __repr__(self) -> str: class AvailableAddOnExtensionContext(InstanceContext): + def __init__(self, version: Version, available_add_on_sid: str, sid: str): """ Initialize the AvailableAddOnExtensionContext @@ -129,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, @@ -149,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( @@ -174,6 +177,7 @@ def __repr__(self) -> str: class AvailableAddOnExtensionPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> AvailableAddOnExtensionInstance: """ Build an instance of AvailableAddOnExtensionInstance @@ -196,6 +200,7 @@ def __repr__(self) -> str: class AvailableAddOnExtensionList(ListResource): + def __init__(self, version: Version, available_add_on_sid: str): """ Initialize the AvailableAddOnExtensionList @@ -341,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( @@ -368,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 87d0926728..7f1fadc510 100644 --- a/twilio/rest/preview/marketplace/installed_add_on/__init__.py +++ b/twilio/rest/preview/marketplace/installed_add_on/__init__.py @@ -12,7 +12,6 @@ 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 @@ -27,7 +26,6 @@ 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. @@ -171,6 +169,7 @@ def __repr__(self) -> str: class InstalledAddOnContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the InstalledAddOnContext @@ -195,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: """ @@ -207,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: @@ -220,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, @@ -239,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( @@ -263,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"]) @@ -291,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"]) @@ -329,6 +342,7 @@ def __repr__(self) -> str: class InstalledAddOnPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> InstalledAddOnInstance: """ Build an instance of InstalledAddOnInstance @@ -347,6 +361,7 @@ def __repr__(self) -> str: class InstalledAddOnList(ListResource): + def __init__(self, version: Version): """ Initialize the InstalledAddOnList @@ -375,19 +390,25 @@ def create( :returns: The created InstalledAddOnInstance """ + data = values.of( { "AvailableAddOnSid": available_add_on_sid, - "AcceptTermsOfService": accept_terms_of_service, + "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, + method="POST", uri=self._uri, data=data, headers=headers ) return InstalledAddOnInstance(self._version, payload) @@ -409,19 +430,25 @@ async def create_async( :returns: The created InstalledAddOnInstance """ + data = values.of( { "AvailableAddOnSid": available_add_on_sid, - "AcceptTermsOfService": accept_terms_of_service, + "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, + method="POST", uri=self._uri, data=data, headers=headers ) return InstalledAddOnInstance(self._version, payload) @@ -553,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( @@ -580,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 e191c8c48f..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 @@ -12,9 +12,8 @@ Do not edit the class manually. """ - 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 @@ -23,7 +22,6 @@ 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. @@ -128,6 +126,7 @@ def __repr__(self) -> str: class InstalledAddOnExtensionContext(InstanceContext): + def __init__(self, version: Version, installed_add_on_sid: str, sid: str): """ Initialize the InstalledAddOnExtensionContext @@ -155,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, @@ -175,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( @@ -195,16 +198,20 @@ def update(self, enabled: bool) -> InstalledAddOnExtensionInstance: :returns: The updated InstalledAddOnExtensionInstance """ + data = values.of( { - "Enabled": enabled, + "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( @@ -222,16 +229,20 @@ async def update_async(self, enabled: bool) -> InstalledAddOnExtensionInstance: :returns: The updated InstalledAddOnExtensionInstance """ + data = values.of( { - "Enabled": enabled, + "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( @@ -254,6 +265,7 @@ def __repr__(self) -> str: class InstalledAddOnExtensionPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> InstalledAddOnExtensionInstance: """ Build an instance of InstalledAddOnExtensionInstance @@ -276,6 +288,7 @@ def __repr__(self) -> str: class InstalledAddOnExtensionList(ListResource): + def __init__(self, version: Version, installed_add_on_sid: str): """ Initialize the InstalledAddOnExtensionList @@ -421,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( @@ -448,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/__init__.py b/twilio/rest/preview/sync/__init__.py deleted file mode 100644 index fad9f85c49..0000000000 --- a/twilio/rest/preview/sync/__init__.py +++ /dev/null @@ -1,42 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Preview - This is the public Twilio REST API. - - NOTE: This class is auto generated by OpenAPI Generator. - https://openapi-generator.tech - Do not edit the class manually. -""" - -from typing import Optional -from twilio.base.version import Version -from twilio.base.domain import Domain -from twilio.rest.preview.sync.service import ServiceList - - -class Sync(Version): - def __init__(self, domain: Domain): - """ - Initialize the Sync version of Preview - - :param domain: The Twilio.preview domain - """ - super().__init__(domain, "Sync") - self._services: Optional[ServiceList] = None - - @property - def services(self) -> ServiceList: - if self._services is None: - self._services = ServiceList(self) - return self._services - - def __repr__(self) -> str: - """ - Provide a friendly representation - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview/sync/service/__init__.py b/twilio/rest/preview/sync/service/__init__.py deleted file mode 100644 index c9f33d19bf..0000000000 --- a/twilio/rest/preview/sync/service/__init__.py +++ /dev/null @@ -1,700 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Preview - This is the public Twilio REST API. - - NOTE: This class is auto generated by OpenAPI Generator. - https://openapi-generator.tech - Do not edit the class manually. -""" - - -from datetime import datetime -from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator -from twilio.base import deserialize, 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": reachability_webhooks_enabled, - "AclEnabled": 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": reachability_webhooks_enabled, - "AclEnabled": 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": reachability_webhooks_enabled, - "AclEnabled": 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": reachability_webhooks_enabled, - "AclEnabled": 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/__init__.py b/twilio/rest/preview/sync/service/document/__init__.py deleted file mode 100644 index ebd08889f9..0000000000 --- a/twilio/rest/preview/sync/service/document/__init__.py +++ /dev/null @@ -1,656 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Preview - This is the public Twilio REST API. - - NOTE: This class is auto generated by OpenAPI Generator. - https://openapi-generator.tech - Do not edit the class manually. -""" - - -from datetime import datetime -from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator -from twilio.base import deserialize, serialize, values -from twilio.base.instance_context import InstanceContext -from twilio.base.instance_resource import InstanceResource -from twilio.base.list_resource import ListResource -from twilio.base.version import Version -from twilio.base.page import Page -from twilio.rest.preview.sync.service.document.document_permission import ( - DocumentPermissionList, -) - - -class DocumentInstance(InstanceResource): - - """ - :ivar sid: - :ivar unique_name: - :ivar account_sid: - :ivar service_sid: - :ivar url: - :ivar links: - :ivar revision: - :ivar data: - :ivar date_created: - :ivar date_updated: - :ivar created_by: - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - service_sid: str, - sid: Optional[str] = None, - ): - super().__init__(version) - - self.sid: Optional[str] = payload.get("sid") - self.unique_name: Optional[str] = payload.get("unique_name") - self.account_sid: Optional[str] = payload.get("account_sid") - self.service_sid: Optional[str] = payload.get("service_sid") - self.url: Optional[str] = payload.get("url") - self.links: Optional[Dict[str, object]] = payload.get("links") - self.revision: Optional[str] = payload.get("revision") - self.data: Optional[Dict[str, object]] = payload.get("data") - self.date_created: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("date_created") - ) - self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("date_updated") - ) - self.created_by: Optional[str] = payload.get("created_by") - - self._solution = { - "service_sid": service_sid, - "sid": sid or self.sid, - } - self._context: Optional[DocumentContext] = None - - @property - def _proxy(self) -> "DocumentContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: DocumentContext for this DocumentInstance - """ - if self._context is None: - self._context = DocumentContext( - self._version, - service_sid=self._solution["service_sid"], - sid=self._solution["sid"], - ) - return self._context - - def delete(self) -> bool: - """ - Deletes the DocumentInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the DocumentInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def fetch(self) -> "DocumentInstance": - """ - Fetch the DocumentInstance - - - :returns: The fetched DocumentInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "DocumentInstance": - """ - Asynchronous coroutine to fetch the DocumentInstance - - - :returns: The fetched DocumentInstance - """ - return await self._proxy.fetch_async() - - def update( - self, data: object, if_match: Union[str, object] = values.unset - ) -> "DocumentInstance": - """ - Update the DocumentInstance - - :param data: - :param if_match: The If-Match HTTP request header - - :returns: The updated DocumentInstance - """ - return self._proxy.update( - data=data, - if_match=if_match, - ) - - async def update_async( - self, data: object, if_match: Union[str, object] = values.unset - ) -> "DocumentInstance": - """ - Asynchronous coroutine to update the DocumentInstance - - :param data: - :param if_match: The If-Match HTTP request header - - :returns: The updated DocumentInstance - """ - return await self._proxy.update_async( - data=data, - if_match=if_match, - ) - - @property - def document_permissions(self) -> DocumentPermissionList: - """ - Access the document_permissions - """ - return self._proxy.document_permissions - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) - return "".format(context) - - -class DocumentContext(InstanceContext): - def __init__(self, version: Version, service_sid: str, sid: str): - """ - Initialize the DocumentContext - - :param version: Version that contains the resource - :param service_sid: - :param sid: - """ - super().__init__(version) - - # Path Solution - self._solution = { - "service_sid": service_sid, - "sid": sid, - } - self._uri = "/Services/{service_sid}/Documents/{sid}".format(**self._solution) - - self._document_permissions: Optional[DocumentPermissionList] = None - - def delete(self) -> bool: - """ - Deletes the DocumentInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the DocumentInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._version.delete_async( - method="DELETE", - uri=self._uri, - ) - - def fetch(self) -> DocumentInstance: - """ - Fetch the DocumentInstance - - - :returns: The fetched DocumentInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return DocumentInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - sid=self._solution["sid"], - ) - - async def fetch_async(self) -> DocumentInstance: - """ - Asynchronous coroutine to fetch the DocumentInstance - - - :returns: The fetched DocumentInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return DocumentInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - sid=self._solution["sid"], - ) - - def update( - self, data: object, if_match: Union[str, object] = values.unset - ) -> DocumentInstance: - """ - Update the DocumentInstance - - :param data: - :param if_match: The If-Match HTTP request header - - :returns: The updated DocumentInstance - """ - data = values.of( - { - "Data": serialize.object(data), - } - ) - headers = values.of( - { - "If-Match": if_match, - } - ) - - payload = self._version.update( - method="POST", uri=self._uri, data=data, headers=headers - ) - - return DocumentInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - sid=self._solution["sid"], - ) - - async def update_async( - self, data: object, if_match: Union[str, object] = values.unset - ) -> DocumentInstance: - """ - Asynchronous coroutine to update the DocumentInstance - - :param data: - :param if_match: The If-Match HTTP request header - - :returns: The updated DocumentInstance - """ - data = values.of( - { - "Data": serialize.object(data), - } - ) - headers = values.of( - { - "If-Match": if_match, - } - ) - - payload = await self._version.update_async( - method="POST", uri=self._uri, data=data, headers=headers - ) - - return DocumentInstance( - self._version, - payload, - service_sid=self._solution["service_sid"], - sid=self._solution["sid"], - ) - - @property - def document_permissions(self) -> DocumentPermissionList: - """ - Access the document_permissions - """ - if self._document_permissions is None: - self._document_permissions = DocumentPermissionList( - self._version, - self._solution["service_sid"], - self._solution["sid"], - ) - return self._document_permissions - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) - return "".format(context) - - -class DocumentPage(Page): - def get_instance(self, payload: Dict[str, Any]) -> DocumentInstance: - """ - Build an instance of DocumentInstance - - :param payload: Payload response from the API - """ - return DocumentInstance( - self._version, payload, service_sid=self._solution["service_sid"] - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class DocumentList(ListResource): - def __init__(self, version: Version, service_sid: str): - """ - Initialize the DocumentList - - :param version: Version that contains the resource - :param service_sid: - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "service_sid": service_sid, - } - self._uri = "/Services/{service_sid}/Documents".format(**self._solution) - - def create( - self, - unique_name: Union[str, object] = values.unset, - data: Union[object, object] = values.unset, - ) -> DocumentInstance: - """ - Create the DocumentInstance - - :param unique_name: - :param data: - - :returns: The created DocumentInstance - """ - data = values.of( - { - "UniqueName": unique_name, - "Data": serialize.object(data), - } - ) - - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) - - return DocumentInstance( - self._version, payload, service_sid=self._solution["service_sid"] - ) - - async def create_async( - self, - unique_name: Union[str, object] = values.unset, - data: Union[object, object] = values.unset, - ) -> DocumentInstance: - """ - Asynchronously create the DocumentInstance - - :param unique_name: - :param data: - - :returns: The created DocumentInstance - """ - data = values.of( - { - "UniqueName": unique_name, - "Data": serialize.object(data), - } - ) - - payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, - ) - - return DocumentInstance( - self._version, payload, service_sid=self._solution["service_sid"] - ) - - def stream( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[DocumentInstance]: - """ - Streams DocumentInstance records from the API as a generator stream. - This operation lazily loads records as efficiently as possible until the limit - is reached. - The results are returned as a generator, so this operation is memory efficient. - - :param limit: Upper limit for the number of records to return. stream() - guarantees to never return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, stream() will attempt to read the - limit with the most efficient page size, i.e. min(limit, 1000) - - :returns: Generator that will yield up to limit results - """ - limits = self._version.read_limits(limit, page_size) - page = self.page(page_size=limits["page_size"]) - - return self._version.stream(page, limits["limit"]) - - async def stream_async( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> AsyncIterator[DocumentInstance]: - """ - Asynchronously streams DocumentInstance records from the API as a generator stream. - This operation lazily loads records as efficiently as possible until the limit - is reached. - The results are returned as a generator, so this operation is memory efficient. - - :param limit: Upper limit for the number of records to return. stream() - guarantees to never return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, stream() will attempt to read the - limit with the most efficient page size, i.e. min(limit, 1000) - - :returns: Generator that will yield up to limit results - """ - limits = self._version.read_limits(limit, page_size) - page = await self.page_async(page_size=limits["page_size"]) - - return self._version.stream_async(page, limits["limit"]) - - def list( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[DocumentInstance]: - """ - Lists DocumentInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param limit: Upper limit for the number of records to return. list() guarantees - never to return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, list() will attempt to read the limit - with the most efficient page size, i.e. min(limit, 1000) - - :returns: list that will contain up to limit results - """ - return list( - self.stream( - limit=limit, - page_size=page_size, - ) - ) - - async def list_async( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[DocumentInstance]: - """ - Asynchronously lists DocumentInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param limit: Upper limit for the number of records to return. list() guarantees - never to return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, list() will attempt to read the limit - with the most efficient page size, i.e. min(limit, 1000) - - :returns: list that will contain up to limit results - """ - return [ - record - async for record in await self.stream_async( - limit=limit, - page_size=page_size, - ) - ] - - def page( - self, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> DocumentPage: - """ - Retrieve a single page of DocumentInstance records from the API. - Request is executed immediately - - :param page_token: PageToken provided by the API - :param page_number: Page Number, this value is simply for client state - :param page_size: Number of records to return, defaults to 50 - - :returns: Page of DocumentInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = self._version.page(method="GET", uri=self._uri, params=data) - return DocumentPage(self._version, response, self._solution) - - async def page_async( - self, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> DocumentPage: - """ - Asynchronously retrieve a single page of DocumentInstance records from the API. - Request is executed immediately - - :param page_token: PageToken provided by the API - :param page_number: Page Number, this value is simply for client state - :param page_size: Number of records to return, defaults to 50 - - :returns: Page of DocumentInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = await self._version.page_async( - method="GET", uri=self._uri, params=data - ) - return DocumentPage(self._version, response, self._solution) - - def get_page(self, target_url: str) -> DocumentPage: - """ - Retrieve a specific page of DocumentInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of DocumentInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return DocumentPage(self._version, response, self._solution) - - async def get_page_async(self, target_url: str) -> DocumentPage: - """ - Asynchronously retrieve a specific page of DocumentInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of DocumentInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return DocumentPage(self._version, response, self._solution) - - def get(self, sid: str) -> DocumentContext: - """ - Constructs a DocumentContext - - :param sid: - """ - return DocumentContext( - self._version, service_sid=self._solution["service_sid"], sid=sid - ) - - def __call__(self, sid: str) -> DocumentContext: - """ - Constructs a DocumentContext - - :param sid: - """ - return DocumentContext( - self._version, service_sid=self._solution["service_sid"], sid=sid - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview/sync/service/document/document_permission.py b/twilio/rest/preview/sync/service/document/document_permission.py deleted file mode 100644 index 1b43dc9fcf..0000000000 --- a/twilio/rest/preview/sync/service/document/document_permission.py +++ /dev/null @@ -1,592 +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 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": read, - "Write": write, - "Manage": 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": read, - "Write": write, - "Manage": 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 592f84a3c4..0000000000 --- a/twilio/rest/preview/sync/service/sync_list/sync_list_item.py +++ /dev/null @@ -1,722 +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 7e1a2db968..0000000000 --- a/twilio/rest/preview/sync/service/sync_list/sync_list_permission.py +++ /dev/null @@ -1,592 +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 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": read, - "Write": write, - "Manage": 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": read, - "Write": write, - "Manage": 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 ef42e77d38..0000000000 --- a/twilio/rest/preview/sync/service/sync_map/sync_map_item.py +++ /dev/null @@ -1,726 +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 3b3230fe17..0000000000 --- a/twilio/rest/preview/sync/service/sync_map/sync_map_permission.py +++ /dev/null @@ -1,590 +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 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": read, - "Write": write, - "Manage": 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": read, - "Write": write, - "Manage": 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/understand/assistant/__init__.py b/twilio/rest/preview/understand/assistant/__init__.py deleted file mode 100644 index 27970ca4da..0000000000 --- a/twilio/rest/preview/understand/assistant/__init__.py +++ /dev/null @@ -1,887 +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.understand.assistant.assistant_fallback_actions import ( - AssistantFallbackActionsList, -) -from twilio.rest.preview.understand.assistant.assistant_initiation_actions import ( - AssistantInitiationActionsList, -) -from twilio.rest.preview.understand.assistant.dialogue import DialogueList -from twilio.rest.preview.understand.assistant.field_type import FieldTypeList -from twilio.rest.preview.understand.assistant.model_build import ModelBuildList -from twilio.rest.preview.understand.assistant.query import QueryList -from twilio.rest.preview.understand.assistant.style_sheet import StyleSheetList -from twilio.rest.preview.understand.assistant.task import TaskList - - -class AssistantInstance(InstanceResource): - - """ - :ivar account_sid: The unique ID of the Account that created this Assistant. - :ivar date_created: The date that this resource was created - :ivar date_updated: The date that this resource was last updated - :ivar friendly_name: A text description for the Assistant. It is non-unique and can up to 255 characters long. - :ivar latest_model_build_sid: The unique ID (Sid) of the latest model build. Null if no model has been built. - :ivar links: - :ivar log_queries: A boolean that specifies whether queries should be logged for 30 days further training. If false, no queries will be stored, if true, queries will be stored for 30 days and deleted thereafter. - :ivar sid: A 34 character string that uniquely identifies this resource. - :ivar unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. You can use the unique name in the URL path. Unique up to 64 characters long. - :ivar url: - :ivar callback_url: A user-provided URL to send event callbacks to. - :ivar callback_events: Space-separated list of callback events that will trigger callbacks. - """ - - 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.friendly_name: Optional[str] = payload.get("friendly_name") - self.latest_model_build_sid: Optional[str] = payload.get( - "latest_model_build_sid" - ) - self.links: Optional[Dict[str, object]] = payload.get("links") - self.log_queries: Optional[bool] = payload.get("log_queries") - self.sid: Optional[str] = payload.get("sid") - self.unique_name: Optional[str] = payload.get("unique_name") - self.url: Optional[str] = payload.get("url") - self.callback_url: Optional[str] = payload.get("callback_url") - self.callback_events: Optional[str] = payload.get("callback_events") - - self._solution = { - "sid": sid or self.sid, - } - 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, - sid=self._solution["sid"], - ) - 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, - friendly_name: Union[str, object] = values.unset, - log_queries: Union[bool, object] = values.unset, - unique_name: Union[str, object] = values.unset, - callback_url: Union[str, object] = values.unset, - callback_events: Union[str, object] = values.unset, - fallback_actions: Union[object, object] = values.unset, - initiation_actions: Union[object, object] = values.unset, - style_sheet: Union[object, object] = values.unset, - ) -> "AssistantInstance": - """ - Update the AssistantInstance - - :param friendly_name: A text description for the Assistant. It is non-unique and can up to 255 characters long. - :param log_queries: A boolean that specifies whether queries should be logged for 30 days further training. If false, no queries will be stored, if true, queries will be stored for 30 days and deleted thereafter. Defaults to true if no value is provided. - :param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - :param callback_url: A user-provided URL to send event callbacks to. - :param callback_events: Space-separated list of callback events that will trigger callbacks. - :param fallback_actions: The JSON actions to be executed when the user's input is not recognized as matching any Task. - :param initiation_actions: The JSON actions to be executed on inbound phone calls when the Assistant has to say something first. - :param style_sheet: The JSON object that holds the style sheet for the assistant - - :returns: The updated AssistantInstance - """ - return self._proxy.update( - friendly_name=friendly_name, - log_queries=log_queries, - unique_name=unique_name, - callback_url=callback_url, - callback_events=callback_events, - fallback_actions=fallback_actions, - initiation_actions=initiation_actions, - style_sheet=style_sheet, - ) - - async def update_async( - self, - friendly_name: Union[str, object] = values.unset, - log_queries: Union[bool, object] = values.unset, - unique_name: Union[str, object] = values.unset, - callback_url: Union[str, object] = values.unset, - callback_events: Union[str, object] = values.unset, - fallback_actions: Union[object, object] = values.unset, - initiation_actions: Union[object, object] = values.unset, - style_sheet: Union[object, object] = values.unset, - ) -> "AssistantInstance": - """ - Asynchronous coroutine to update the AssistantInstance - - :param friendly_name: A text description for the Assistant. It is non-unique and can up to 255 characters long. - :param log_queries: A boolean that specifies whether queries should be logged for 30 days further training. If false, no queries will be stored, if true, queries will be stored for 30 days and deleted thereafter. Defaults to true if no value is provided. - :param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - :param callback_url: A user-provided URL to send event callbacks to. - :param callback_events: Space-separated list of callback events that will trigger callbacks. - :param fallback_actions: The JSON actions to be executed when the user's input is not recognized as matching any Task. - :param initiation_actions: The JSON actions to be executed on inbound phone calls when the Assistant has to say something first. - :param style_sheet: The JSON object that holds the style sheet for the assistant - - :returns: The updated AssistantInstance - """ - return await self._proxy.update_async( - friendly_name=friendly_name, - log_queries=log_queries, - unique_name=unique_name, - callback_url=callback_url, - callback_events=callback_events, - fallback_actions=fallback_actions, - initiation_actions=initiation_actions, - style_sheet=style_sheet, - ) - - @property - def assistant_fallback_actions(self) -> AssistantFallbackActionsList: - """ - Access the assistant_fallback_actions - """ - return self._proxy.assistant_fallback_actions - - @property - def assistant_initiation_actions(self) -> AssistantInitiationActionsList: - """ - Access the assistant_initiation_actions - """ - return self._proxy.assistant_initiation_actions - - @property - def dialogues(self) -> DialogueList: - """ - Access the dialogues - """ - return self._proxy.dialogues - - @property - def field_types(self) -> FieldTypeList: - """ - Access the field_types - """ - return self._proxy.field_types - - @property - def model_builds(self) -> ModelBuildList: - """ - Access the model_builds - """ - return self._proxy.model_builds - - @property - def queries(self) -> QueryList: - """ - Access the queries - """ - return self._proxy.queries - - @property - def style_sheet(self) -> StyleSheetList: - """ - Access the style_sheet - """ - return self._proxy.style_sheet - - @property - def tasks(self) -> TaskList: - """ - Access the tasks - """ - return self._proxy.tasks - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) - return "".format(context) - - -class AssistantContext(InstanceContext): - def __init__(self, version: Version, sid: str): - """ - Initialize the AssistantContext - - :param version: Version that contains the resource - :param sid: A 34 character string that uniquely identifies this resource. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "sid": sid, - } - self._uri = "/Assistants/{sid}".format(**self._solution) - - self._assistant_fallback_actions: Optional[AssistantFallbackActionsList] = None - self._assistant_initiation_actions: Optional[ - AssistantInitiationActionsList - ] = None - self._dialogues: Optional[DialogueList] = None - self._field_types: Optional[FieldTypeList] = None - self._model_builds: Optional[ModelBuildList] = None - self._queries: Optional[QueryList] = None - self._style_sheet: Optional[StyleSheetList] = None - self._tasks: Optional[TaskList] = None - - def delete(self) -> bool: - """ - Deletes the AssistantInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._version.delete( - method="DELETE", - uri=self._uri, - ) - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the AssistantInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._version.delete_async( - method="DELETE", - uri=self._uri, - ) - - def fetch(self) -> AssistantInstance: - """ - Fetch the AssistantInstance - - - :returns: The fetched AssistantInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return AssistantInstance( - self._version, - payload, - sid=self._solution["sid"], - ) - - async def fetch_async(self) -> AssistantInstance: - """ - Asynchronous coroutine to fetch the AssistantInstance - - - :returns: The fetched AssistantInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return AssistantInstance( - self._version, - payload, - sid=self._solution["sid"], - ) - - def update( - self, - friendly_name: Union[str, object] = values.unset, - log_queries: Union[bool, object] = values.unset, - unique_name: Union[str, object] = values.unset, - callback_url: Union[str, object] = values.unset, - callback_events: Union[str, object] = values.unset, - fallback_actions: Union[object, object] = values.unset, - initiation_actions: Union[object, object] = values.unset, - style_sheet: Union[object, object] = values.unset, - ) -> AssistantInstance: - """ - Update the AssistantInstance - - :param friendly_name: A text description for the Assistant. It is non-unique and can up to 255 characters long. - :param log_queries: A boolean that specifies whether queries should be logged for 30 days further training. If false, no queries will be stored, if true, queries will be stored for 30 days and deleted thereafter. Defaults to true if no value is provided. - :param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - :param callback_url: A user-provided URL to send event callbacks to. - :param callback_events: Space-separated list of callback events that will trigger callbacks. - :param fallback_actions: The JSON actions to be executed when the user's input is not recognized as matching any Task. - :param initiation_actions: The JSON actions to be executed on inbound phone calls when the Assistant has to say something first. - :param style_sheet: The JSON object that holds the style sheet for the assistant - - :returns: The updated AssistantInstance - """ - data = values.of( - { - "FriendlyName": friendly_name, - "LogQueries": log_queries, - "UniqueName": unique_name, - "CallbackUrl": callback_url, - "CallbackEvents": callback_events, - "FallbackActions": serialize.object(fallback_actions), - "InitiationActions": serialize.object(initiation_actions), - "StyleSheet": serialize.object(style_sheet), - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return AssistantInstance(self._version, payload, sid=self._solution["sid"]) - - async def update_async( - self, - friendly_name: Union[str, object] = values.unset, - log_queries: Union[bool, object] = values.unset, - unique_name: Union[str, object] = values.unset, - callback_url: Union[str, object] = values.unset, - callback_events: Union[str, object] = values.unset, - fallback_actions: Union[object, object] = values.unset, - initiation_actions: Union[object, object] = values.unset, - style_sheet: Union[object, object] = values.unset, - ) -> AssistantInstance: - """ - Asynchronous coroutine to update the AssistantInstance - - :param friendly_name: A text description for the Assistant. It is non-unique and can up to 255 characters long. - :param log_queries: A boolean that specifies whether queries should be logged for 30 days further training. If false, no queries will be stored, if true, queries will be stored for 30 days and deleted thereafter. Defaults to true if no value is provided. - :param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - :param callback_url: A user-provided URL to send event callbacks to. - :param callback_events: Space-separated list of callback events that will trigger callbacks. - :param fallback_actions: The JSON actions to be executed when the user's input is not recognized as matching any Task. - :param initiation_actions: The JSON actions to be executed on inbound phone calls when the Assistant has to say something first. - :param style_sheet: The JSON object that holds the style sheet for the assistant - - :returns: The updated AssistantInstance - """ - data = values.of( - { - "FriendlyName": friendly_name, - "LogQueries": log_queries, - "UniqueName": unique_name, - "CallbackUrl": callback_url, - "CallbackEvents": callback_events, - "FallbackActions": serialize.object(fallback_actions), - "InitiationActions": serialize.object(initiation_actions), - "StyleSheet": serialize.object(style_sheet), - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return AssistantInstance(self._version, payload, sid=self._solution["sid"]) - - @property - def assistant_fallback_actions(self) -> AssistantFallbackActionsList: - """ - Access the assistant_fallback_actions - """ - if self._assistant_fallback_actions is None: - self._assistant_fallback_actions = AssistantFallbackActionsList( - self._version, - self._solution["sid"], - ) - return self._assistant_fallback_actions - - @property - def assistant_initiation_actions(self) -> AssistantInitiationActionsList: - """ - Access the assistant_initiation_actions - """ - if self._assistant_initiation_actions is None: - self._assistant_initiation_actions = AssistantInitiationActionsList( - self._version, - self._solution["sid"], - ) - return self._assistant_initiation_actions - - @property - def dialogues(self) -> DialogueList: - """ - Access the dialogues - """ - if self._dialogues is None: - self._dialogues = DialogueList( - self._version, - self._solution["sid"], - ) - return self._dialogues - - @property - def field_types(self) -> FieldTypeList: - """ - Access the field_types - """ - if self._field_types is None: - self._field_types = FieldTypeList( - self._version, - self._solution["sid"], - ) - return self._field_types - - @property - def model_builds(self) -> ModelBuildList: - """ - Access the model_builds - """ - if self._model_builds is None: - self._model_builds = ModelBuildList( - self._version, - self._solution["sid"], - ) - return self._model_builds - - @property - def queries(self) -> QueryList: - """ - Access the queries - """ - if self._queries is None: - self._queries = QueryList( - self._version, - self._solution["sid"], - ) - return self._queries - - @property - def style_sheet(self) -> StyleSheetList: - """ - Access the style_sheet - """ - if self._style_sheet is None: - self._style_sheet = StyleSheetList( - self._version, - self._solution["sid"], - ) - return self._style_sheet - - @property - def tasks(self) -> TaskList: - """ - Access the tasks - """ - if self._tasks is None: - self._tasks = TaskList( - self._version, - self._solution["sid"], - ) - return self._tasks - - 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): - def __init__(self, version: Version): - """ - Initialize the AssistantList - - :param version: Version that contains the resource - - """ - super().__init__(version) - - self._uri = "/Assistants" - - def create( - self, - friendly_name: Union[str, object] = values.unset, - log_queries: Union[bool, object] = values.unset, - unique_name: Union[str, object] = values.unset, - callback_url: Union[str, object] = values.unset, - callback_events: Union[str, object] = values.unset, - fallback_actions: Union[object, object] = values.unset, - initiation_actions: Union[object, object] = values.unset, - style_sheet: Union[object, object] = values.unset, - ) -> AssistantInstance: - """ - Create the AssistantInstance - - :param friendly_name: A text description for the Assistant. It is non-unique and can up to 255 characters long. - :param log_queries: A boolean that specifies whether queries should be logged for 30 days further training. If false, no queries will be stored, if true, queries will be stored for 30 days and deleted thereafter. Defaults to true if no value is provided. - :param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - :param callback_url: A user-provided URL to send event callbacks to. - :param callback_events: Space-separated list of callback events that will trigger callbacks. - :param fallback_actions: The JSON actions to be executed when the user's input is not recognized as matching any Task. - :param initiation_actions: The JSON actions to be executed on inbound phone calls when the Assistant has to say something first. - :param style_sheet: The JSON object that holds the style sheet for the assistant - - :returns: The created AssistantInstance - """ - data = values.of( - { - "FriendlyName": friendly_name, - "LogQueries": log_queries, - "UniqueName": unique_name, - "CallbackUrl": callback_url, - "CallbackEvents": callback_events, - "FallbackActions": serialize.object(fallback_actions), - "InitiationActions": serialize.object(initiation_actions), - "StyleSheet": serialize.object(style_sheet), - } - ) - - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) - - return AssistantInstance(self._version, payload) - - async def create_async( - self, - friendly_name: Union[str, object] = values.unset, - log_queries: Union[bool, object] = values.unset, - unique_name: Union[str, object] = values.unset, - callback_url: Union[str, object] = values.unset, - callback_events: Union[str, object] = values.unset, - fallback_actions: Union[object, object] = values.unset, - initiation_actions: Union[object, object] = values.unset, - style_sheet: Union[object, object] = values.unset, - ) -> AssistantInstance: - """ - Asynchronously create the AssistantInstance - - :param friendly_name: A text description for the Assistant. It is non-unique and can up to 255 characters long. - :param log_queries: A boolean that specifies whether queries should be logged for 30 days further training. If false, no queries will be stored, if true, queries will be stored for 30 days and deleted thereafter. Defaults to true if no value is provided. - :param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - :param callback_url: A user-provided URL to send event callbacks to. - :param callback_events: Space-separated list of callback events that will trigger callbacks. - :param fallback_actions: The JSON actions to be executed when the user's input is not recognized as matching any Task. - :param initiation_actions: The JSON actions to be executed on inbound phone calls when the Assistant has to say something first. - :param style_sheet: The JSON object that holds the style sheet for the assistant - - :returns: The created AssistantInstance - """ - data = values.of( - { - "FriendlyName": friendly_name, - "LogQueries": log_queries, - "UniqueName": unique_name, - "CallbackUrl": callback_url, - "CallbackEvents": callback_events, - "FallbackActions": serialize.object(fallback_actions), - "InitiationActions": serialize.object(initiation_actions), - "StyleSheet": serialize.object(style_sheet), - } - ) - - payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, - ) - - return AssistantInstance(self._version, payload) - - def stream( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[AssistantInstance]: - """ - Streams AssistantInstance records from the API as a generator stream. - This operation lazily loads records as efficiently as possible until the limit - is reached. - The results are returned as a generator, so this operation is memory efficient. - - :param limit: Upper limit for the number of records to return. stream() - guarantees to never return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, stream() will attempt to read the - limit with the most efficient page size, i.e. min(limit, 1000) - - :returns: Generator that will yield up to limit results - """ - limits = self._version.read_limits(limit, page_size) - page = self.page(page_size=limits["page_size"]) - - return self._version.stream(page, limits["limit"]) - - async def stream_async( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> AsyncIterator[AssistantInstance]: - """ - Asynchronously streams AssistantInstance records from the API as a generator stream. - This operation lazily loads records as efficiently as possible until the limit - is reached. - The results are returned as a generator, so this operation is memory efficient. - - :param limit: Upper limit for the number of records to return. stream() - guarantees to never return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, stream() will attempt to read the - limit with the most efficient page size, i.e. min(limit, 1000) - - :returns: Generator that will yield up to limit results - """ - limits = self._version.read_limits(limit, page_size) - page = await self.page_async(page_size=limits["page_size"]) - - return self._version.stream_async(page, limits["limit"]) - - def list( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[AssistantInstance]: - """ - Lists AssistantInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param limit: Upper limit for the number of records to return. list() guarantees - never to return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, list() will attempt to read the limit - with the most efficient page size, i.e. min(limit, 1000) - - :returns: list that will contain up to limit results - """ - return list( - self.stream( - limit=limit, - page_size=page_size, - ) - ) - - async def list_async( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[AssistantInstance]: - """ - Asynchronously lists AssistantInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param limit: Upper limit for the number of records to return. list() guarantees - never to return more than limit. Default is no limit - :param page_size: Number of records to fetch per request, when not set will use - the default value of 50 records. If no page_size is defined - but a limit is defined, list() will attempt to read the limit - with the most efficient page size, i.e. min(limit, 1000) - - :returns: list that will contain up to limit results - """ - return [ - record - async for record in await self.stream_async( - limit=limit, - page_size=page_size, - ) - ] - - def page( - self, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> AssistantPage: - """ - Retrieve a single page of AssistantInstance records from the API. - Request is executed immediately - - :param page_token: PageToken provided by the API - :param page_number: Page Number, this value is simply for client state - :param page_size: Number of records to return, defaults to 50 - - :returns: Page of AssistantInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = self._version.page(method="GET", uri=self._uri, params=data) - return AssistantPage(self._version, response) - - async def page_async( - self, - page_token: Union[str, object] = values.unset, - page_number: Union[int, object] = values.unset, - page_size: Union[int, object] = values.unset, - ) -> AssistantPage: - """ - Asynchronously retrieve a single page of AssistantInstance records from the API. - Request is executed immediately - - :param page_token: PageToken provided by the API - :param page_number: Page Number, this value is simply for client state - :param page_size: Number of records to return, defaults to 50 - - :returns: Page of AssistantInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = await self._version.page_async( - method="GET", uri=self._uri, params=data - ) - return AssistantPage(self._version, response) - - def get_page(self, target_url: str) -> AssistantPage: - """ - Retrieve a specific page of AssistantInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of AssistantInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return AssistantPage(self._version, response) - - async def get_page_async(self, target_url: str) -> AssistantPage: - """ - Asynchronously retrieve a specific page of AssistantInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of AssistantInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return AssistantPage(self._version, response) - - def get(self, sid: str) -> AssistantContext: - """ - Constructs a AssistantContext - - :param sid: A 34 character string that uniquely identifies this resource. - """ - return AssistantContext(self._version, sid=sid) - - def __call__(self, sid: str) -> AssistantContext: - """ - Constructs a AssistantContext - - :param sid: A 34 character string that uniquely identifies this resource. - """ - return AssistantContext(self._version, sid=sid) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview/understand/assistant/assistant_fallback_actions.py b/twilio/rest/preview/understand/assistant/assistant_fallback_actions.py deleted file mode 100644 index 84e964de0e..0000000000 --- a/twilio/rest/preview/understand/assistant/assistant_fallback_actions.py +++ /dev/null @@ -1,279 +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, 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 - - -class AssistantFallbackActionsInstance(InstanceResource): - - """ - :ivar account_sid: - :ivar assistant_sid: - :ivar url: - :ivar data: - """ - - def __init__(self, version: Version, payload: Dict[str, Any], assistant_sid: str): - super().__init__(version) - - self.account_sid: Optional[str] = payload.get("account_sid") - self.assistant_sid: Optional[str] = payload.get("assistant_sid") - self.url: Optional[str] = payload.get("url") - self.data: Optional[Dict[str, object]] = payload.get("data") - - self._solution = { - "assistant_sid": assistant_sid, - } - self._context: Optional[AssistantFallbackActionsContext] = None - - @property - def _proxy(self) -> "AssistantFallbackActionsContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: AssistantFallbackActionsContext for this AssistantFallbackActionsInstance - """ - if self._context is None: - self._context = AssistantFallbackActionsContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - ) - return self._context - - def fetch(self) -> "AssistantFallbackActionsInstance": - """ - Fetch the AssistantFallbackActionsInstance - - - :returns: The fetched AssistantFallbackActionsInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "AssistantFallbackActionsInstance": - """ - Asynchronous coroutine to fetch the AssistantFallbackActionsInstance - - - :returns: The fetched AssistantFallbackActionsInstance - """ - return await self._proxy.fetch_async() - - def update( - self, fallback_actions: Union[object, object] = values.unset - ) -> "AssistantFallbackActionsInstance": - """ - Update the AssistantFallbackActionsInstance - - :param fallback_actions: - - :returns: The updated AssistantFallbackActionsInstance - """ - return self._proxy.update( - fallback_actions=fallback_actions, - ) - - async def update_async( - self, fallback_actions: Union[object, object] = values.unset - ) -> "AssistantFallbackActionsInstance": - """ - Asynchronous coroutine to update the AssistantFallbackActionsInstance - - :param fallback_actions: - - :returns: The updated AssistantFallbackActionsInstance - """ - return await self._proxy.update_async( - fallback_actions=fallback_actions, - ) - - 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 AssistantFallbackActionsContext(InstanceContext): - def __init__(self, version: Version, assistant_sid: str): - """ - Initialize the AssistantFallbackActionsContext - - :param version: Version that contains the resource - :param assistant_sid: - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - } - self._uri = "/Assistants/{assistant_sid}/FallbackActions".format( - **self._solution - ) - - def fetch(self) -> AssistantFallbackActionsInstance: - """ - Fetch the AssistantFallbackActionsInstance - - - :returns: The fetched AssistantFallbackActionsInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return AssistantFallbackActionsInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - ) - - async def fetch_async(self) -> AssistantFallbackActionsInstance: - """ - Asynchronous coroutine to fetch the AssistantFallbackActionsInstance - - - :returns: The fetched AssistantFallbackActionsInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return AssistantFallbackActionsInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - ) - - def update( - self, fallback_actions: Union[object, object] = values.unset - ) -> AssistantFallbackActionsInstance: - """ - Update the AssistantFallbackActionsInstance - - :param fallback_actions: - - :returns: The updated AssistantFallbackActionsInstance - """ - data = values.of( - { - "FallbackActions": serialize.object(fallback_actions), - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return AssistantFallbackActionsInstance( - self._version, payload, assistant_sid=self._solution["assistant_sid"] - ) - - async def update_async( - self, fallback_actions: Union[object, object] = values.unset - ) -> AssistantFallbackActionsInstance: - """ - Asynchronous coroutine to update the AssistantFallbackActionsInstance - - :param fallback_actions: - - :returns: The updated AssistantFallbackActionsInstance - """ - data = values.of( - { - "FallbackActions": serialize.object(fallback_actions), - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return AssistantFallbackActionsInstance( - self._version, payload, assistant_sid=self._solution["assistant_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 AssistantFallbackActionsList(ListResource): - def __init__(self, version: Version, assistant_sid: str): - """ - Initialize the AssistantFallbackActionsList - - :param version: Version that contains the resource - :param assistant_sid: - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - } - - def get(self) -> AssistantFallbackActionsContext: - """ - Constructs a AssistantFallbackActionsContext - - """ - return AssistantFallbackActionsContext( - self._version, assistant_sid=self._solution["assistant_sid"] - ) - - def __call__(self) -> AssistantFallbackActionsContext: - """ - Constructs a AssistantFallbackActionsContext - - """ - return AssistantFallbackActionsContext( - self._version, assistant_sid=self._solution["assistant_sid"] - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview/understand/assistant/assistant_initiation_actions.py b/twilio/rest/preview/understand/assistant/assistant_initiation_actions.py deleted file mode 100644 index 544154f658..0000000000 --- a/twilio/rest/preview/understand/assistant/assistant_initiation_actions.py +++ /dev/null @@ -1,283 +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, 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 - - -class AssistantInitiationActionsInstance(InstanceResource): - - """ - :ivar account_sid: - :ivar assistant_sid: - :ivar url: - :ivar data: - """ - - def __init__(self, version: Version, payload: Dict[str, Any], assistant_sid: str): - super().__init__(version) - - self.account_sid: Optional[str] = payload.get("account_sid") - self.assistant_sid: Optional[str] = payload.get("assistant_sid") - self.url: Optional[str] = payload.get("url") - self.data: Optional[Dict[str, object]] = payload.get("data") - - self._solution = { - "assistant_sid": assistant_sid, - } - self._context: Optional[AssistantInitiationActionsContext] = None - - @property - def _proxy(self) -> "AssistantInitiationActionsContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: AssistantInitiationActionsContext for this AssistantInitiationActionsInstance - """ - if self._context is None: - self._context = AssistantInitiationActionsContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - ) - return self._context - - def fetch(self) -> "AssistantInitiationActionsInstance": - """ - Fetch the AssistantInitiationActionsInstance - - - :returns: The fetched AssistantInitiationActionsInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "AssistantInitiationActionsInstance": - """ - Asynchronous coroutine to fetch the AssistantInitiationActionsInstance - - - :returns: The fetched AssistantInitiationActionsInstance - """ - return await self._proxy.fetch_async() - - def update( - self, initiation_actions: Union[object, object] = values.unset - ) -> "AssistantInitiationActionsInstance": - """ - Update the AssistantInitiationActionsInstance - - :param initiation_actions: - - :returns: The updated AssistantInitiationActionsInstance - """ - return self._proxy.update( - initiation_actions=initiation_actions, - ) - - async def update_async( - self, initiation_actions: Union[object, object] = values.unset - ) -> "AssistantInitiationActionsInstance": - """ - Asynchronous coroutine to update the AssistantInitiationActionsInstance - - :param initiation_actions: - - :returns: The updated AssistantInitiationActionsInstance - """ - return await self._proxy.update_async( - initiation_actions=initiation_actions, - ) - - 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 AssistantInitiationActionsContext(InstanceContext): - def __init__(self, version: Version, assistant_sid: str): - """ - Initialize the AssistantInitiationActionsContext - - :param version: Version that contains the resource - :param assistant_sid: - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - } - self._uri = "/Assistants/{assistant_sid}/InitiationActions".format( - **self._solution - ) - - def fetch(self) -> AssistantInitiationActionsInstance: - """ - Fetch the AssistantInitiationActionsInstance - - - :returns: The fetched AssistantInitiationActionsInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return AssistantInitiationActionsInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - ) - - async def fetch_async(self) -> AssistantInitiationActionsInstance: - """ - Asynchronous coroutine to fetch the AssistantInitiationActionsInstance - - - :returns: The fetched AssistantInitiationActionsInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return AssistantInitiationActionsInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - ) - - def update( - self, initiation_actions: Union[object, object] = values.unset - ) -> AssistantInitiationActionsInstance: - """ - Update the AssistantInitiationActionsInstance - - :param initiation_actions: - - :returns: The updated AssistantInitiationActionsInstance - """ - data = values.of( - { - "InitiationActions": serialize.object(initiation_actions), - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return AssistantInitiationActionsInstance( - self._version, payload, assistant_sid=self._solution["assistant_sid"] - ) - - async def update_async( - self, initiation_actions: Union[object, object] = values.unset - ) -> AssistantInitiationActionsInstance: - """ - Asynchronous coroutine to update the AssistantInitiationActionsInstance - - :param initiation_actions: - - :returns: The updated AssistantInitiationActionsInstance - """ - data = values.of( - { - "InitiationActions": serialize.object(initiation_actions), - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return AssistantInitiationActionsInstance( - self._version, payload, assistant_sid=self._solution["assistant_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 AssistantInitiationActionsList(ListResource): - def __init__(self, version: Version, assistant_sid: str): - """ - Initialize the AssistantInitiationActionsList - - :param version: Version that contains the resource - :param assistant_sid: - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - } - - def get(self) -> AssistantInitiationActionsContext: - """ - Constructs a AssistantInitiationActionsContext - - """ - return AssistantInitiationActionsContext( - self._version, assistant_sid=self._solution["assistant_sid"] - ) - - def __call__(self) -> AssistantInitiationActionsContext: - """ - Constructs a AssistantInitiationActionsContext - - """ - return AssistantInitiationActionsContext( - self._version, assistant_sid=self._solution["assistant_sid"] - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview/understand/assistant/dialogue.py b/twilio/rest/preview/understand/assistant/dialogue.py deleted file mode 100644 index 57b0016ec2..0000000000 --- a/twilio/rest/preview/understand/assistant/dialogue.py +++ /dev/null @@ -1,210 +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, Optional -from twilio.base.instance_context import InstanceContext -from twilio.base.instance_resource import InstanceResource -from twilio.base.list_resource import ListResource -from twilio.base.version import Version - - -class DialogueInstance(InstanceResource): - - """ - :ivar account_sid: The unique ID of the Account that created this Field. - :ivar assistant_sid: The unique ID of the parent Assistant. - :ivar sid: The unique ID of the Dialogue - :ivar data: The dialogue memory object as json - :ivar url: - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - assistant_sid: str, - sid: Optional[str] = None, - ): - super().__init__(version) - - self.account_sid: Optional[str] = payload.get("account_sid") - self.assistant_sid: Optional[str] = payload.get("assistant_sid") - self.sid: Optional[str] = payload.get("sid") - self.data: Optional[Dict[str, object]] = payload.get("data") - self.url: Optional[str] = payload.get("url") - - self._solution = { - "assistant_sid": assistant_sid, - "sid": sid or self.sid, - } - self._context: Optional[DialogueContext] = None - - @property - def _proxy(self) -> "DialogueContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: DialogueContext for this DialogueInstance - """ - if self._context is None: - self._context = DialogueContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - return self._context - - def fetch(self) -> "DialogueInstance": - """ - Fetch the DialogueInstance - - - :returns: The fetched DialogueInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "DialogueInstance": - """ - Asynchronous coroutine to fetch the DialogueInstance - - - :returns: The fetched DialogueInstance - """ - 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 DialogueContext(InstanceContext): - def __init__(self, version: Version, assistant_sid: str, sid: str): - """ - Initialize the DialogueContext - - :param version: Version that contains the resource - :param assistant_sid: - :param sid: - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - "sid": sid, - } - self._uri = "/Assistants/{assistant_sid}/Dialogues/{sid}".format( - **self._solution - ) - - def fetch(self) -> DialogueInstance: - """ - Fetch the DialogueInstance - - - :returns: The fetched DialogueInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return DialogueInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - - async def fetch_async(self) -> DialogueInstance: - """ - Asynchronous coroutine to fetch the DialogueInstance - - - :returns: The fetched DialogueInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return DialogueInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_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 DialogueList(ListResource): - def __init__(self, version: Version, assistant_sid: str): - """ - Initialize the DialogueList - - :param version: Version that contains the resource - :param assistant_sid: - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - } - - def get(self, sid: str) -> DialogueContext: - """ - Constructs a DialogueContext - - :param sid: - """ - return DialogueContext( - self._version, assistant_sid=self._solution["assistant_sid"], sid=sid - ) - - def __call__(self, sid: str) -> DialogueContext: - """ - Constructs a DialogueContext - - :param sid: - """ - return DialogueContext( - self._version, assistant_sid=self._solution["assistant_sid"], sid=sid - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview/understand/assistant/field_type/__init__.py b/twilio/rest/preview/understand/assistant/field_type/__init__.py deleted file mode 100644 index 0deb38faf1..0000000000 --- a/twilio/rest/preview/understand/assistant/field_type/__init__.py +++ /dev/null @@ -1,654 +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.understand.assistant.field_type.field_value import ( - FieldValueList, -) - - -class FieldTypeInstance(InstanceResource): - - """ - :ivar account_sid: The unique ID of the Account that created this Field Type. - :ivar date_created: The date that this resource was created - :ivar date_updated: The date that this resource was last updated - :ivar friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long. - :ivar links: - :ivar assistant_sid: The unique ID of the Assistant. - :ivar sid: A 34 character string that uniquely identifies this resource. - :ivar unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - :ivar url: - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - assistant_sid: str, - 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.friendly_name: Optional[str] = payload.get("friendly_name") - self.links: Optional[Dict[str, object]] = payload.get("links") - self.assistant_sid: Optional[str] = payload.get("assistant_sid") - self.sid: Optional[str] = payload.get("sid") - self.unique_name: Optional[str] = payload.get("unique_name") - self.url: Optional[str] = payload.get("url") - - self._solution = { - "assistant_sid": assistant_sid, - "sid": sid or self.sid, - } - self._context: Optional[FieldTypeContext] = None - - @property - def _proxy(self) -> "FieldTypeContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: FieldTypeContext for this FieldTypeInstance - """ - if self._context is None: - self._context = FieldTypeContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - return self._context - - def delete(self) -> bool: - """ - Deletes the FieldTypeInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the FieldTypeInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def fetch(self) -> "FieldTypeInstance": - """ - Fetch the FieldTypeInstance - - - :returns: The fetched FieldTypeInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "FieldTypeInstance": - """ - Asynchronous coroutine to fetch the FieldTypeInstance - - - :returns: The fetched FieldTypeInstance - """ - return await self._proxy.fetch_async() - - def update( - self, - friendly_name: Union[str, object] = values.unset, - unique_name: Union[str, object] = values.unset, - ) -> "FieldTypeInstance": - """ - Update the FieldTypeInstance - - :param friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long. - :param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - - :returns: The updated FieldTypeInstance - """ - return self._proxy.update( - friendly_name=friendly_name, - unique_name=unique_name, - ) - - async def update_async( - self, - friendly_name: Union[str, object] = values.unset, - unique_name: Union[str, object] = values.unset, - ) -> "FieldTypeInstance": - """ - Asynchronous coroutine to update the FieldTypeInstance - - :param friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long. - :param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - - :returns: The updated FieldTypeInstance - """ - return await self._proxy.update_async( - friendly_name=friendly_name, - unique_name=unique_name, - ) - - @property - def field_values(self) -> FieldValueList: - """ - Access the field_values - """ - return self._proxy.field_values - - 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 FieldTypeContext(InstanceContext): - def __init__(self, version: Version, assistant_sid: str, sid: str): - """ - Initialize the FieldTypeContext - - :param version: Version that contains the resource - :param assistant_sid: - :param sid: - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - "sid": sid, - } - self._uri = "/Assistants/{assistant_sid}/FieldTypes/{sid}".format( - **self._solution - ) - - self._field_values: Optional[FieldValueList] = None - - def delete(self) -> bool: - """ - Deletes the FieldTypeInstance - - - :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 FieldTypeInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._version.delete_async( - method="DELETE", - uri=self._uri, - ) - - def fetch(self) -> FieldTypeInstance: - """ - Fetch the FieldTypeInstance - - - :returns: The fetched FieldTypeInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return FieldTypeInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - - async def fetch_async(self) -> FieldTypeInstance: - """ - Asynchronous coroutine to fetch the FieldTypeInstance - - - :returns: The fetched FieldTypeInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return FieldTypeInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - - def update( - self, - friendly_name: Union[str, object] = values.unset, - unique_name: Union[str, object] = values.unset, - ) -> FieldTypeInstance: - """ - Update the FieldTypeInstance - - :param friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long. - :param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - - :returns: The updated FieldTypeInstance - """ - data = values.of( - { - "FriendlyName": friendly_name, - "UniqueName": unique_name, - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return FieldTypeInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - - async def update_async( - self, - friendly_name: Union[str, object] = values.unset, - unique_name: Union[str, object] = values.unset, - ) -> FieldTypeInstance: - """ - Asynchronous coroutine to update the FieldTypeInstance - - :param friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long. - :param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - - :returns: The updated FieldTypeInstance - """ - data = values.of( - { - "FriendlyName": friendly_name, - "UniqueName": unique_name, - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return FieldTypeInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - - @property - def field_values(self) -> FieldValueList: - """ - Access the field_values - """ - if self._field_values is None: - self._field_values = FieldValueList( - self._version, - self._solution["assistant_sid"], - self._solution["sid"], - ) - return self._field_values - - 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 FieldTypePage(Page): - def get_instance(self, payload: Dict[str, Any]) -> FieldTypeInstance: - """ - Build an instance of FieldTypeInstance - - :param payload: Payload response from the API - """ - return FieldTypeInstance( - self._version, payload, assistant_sid=self._solution["assistant_sid"] - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class FieldTypeList(ListResource): - def __init__(self, version: Version, assistant_sid: str): - """ - Initialize the FieldTypeList - - :param version: Version that contains the resource - :param assistant_sid: - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - } - self._uri = "/Assistants/{assistant_sid}/FieldTypes".format(**self._solution) - - def create( - self, unique_name: str, friendly_name: Union[str, object] = values.unset - ) -> FieldTypeInstance: - """ - Create the FieldTypeInstance - - :param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - :param friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long. - - :returns: The created FieldTypeInstance - """ - data = values.of( - { - "UniqueName": unique_name, - "FriendlyName": friendly_name, - } - ) - - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) - - return FieldTypeInstance( - self._version, payload, assistant_sid=self._solution["assistant_sid"] - ) - - async def create_async( - self, unique_name: str, friendly_name: Union[str, object] = values.unset - ) -> FieldTypeInstance: - """ - Asynchronously create the FieldTypeInstance - - :param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - :param friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long. - - :returns: The created FieldTypeInstance - """ - data = values.of( - { - "UniqueName": unique_name, - "FriendlyName": friendly_name, - } - ) - - payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, - ) - - return FieldTypeInstance( - self._version, payload, assistant_sid=self._solution["assistant_sid"] - ) - - def stream( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[FieldTypeInstance]: - """ - Streams FieldTypeInstance 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[FieldTypeInstance]: - """ - Asynchronously streams FieldTypeInstance 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[FieldTypeInstance]: - """ - Lists FieldTypeInstance 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[FieldTypeInstance]: - """ - Asynchronously lists FieldTypeInstance 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, - ) -> FieldTypePage: - """ - Retrieve a single page of FieldTypeInstance 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 FieldTypeInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = self._version.page(method="GET", uri=self._uri, params=data) - return FieldTypePage(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, - ) -> FieldTypePage: - """ - Asynchronously retrieve a single page of FieldTypeInstance 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 FieldTypeInstance - """ - 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 FieldTypePage(self._version, response, self._solution) - - def get_page(self, target_url: str) -> FieldTypePage: - """ - Retrieve a specific page of FieldTypeInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of FieldTypeInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return FieldTypePage(self._version, response, self._solution) - - async def get_page_async(self, target_url: str) -> FieldTypePage: - """ - Asynchronously retrieve a specific page of FieldTypeInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of FieldTypeInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return FieldTypePage(self._version, response, self._solution) - - def get(self, sid: str) -> FieldTypeContext: - """ - Constructs a FieldTypeContext - - :param sid: - """ - return FieldTypeContext( - self._version, assistant_sid=self._solution["assistant_sid"], sid=sid - ) - - def __call__(self, sid: str) -> FieldTypeContext: - """ - Constructs a FieldTypeContext - - :param sid: - """ - return FieldTypeContext( - self._version, assistant_sid=self._solution["assistant_sid"], sid=sid - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview/understand/assistant/field_type/field_value.py b/twilio/rest/preview/understand/assistant/field_type/field_value.py deleted file mode 100644 index 87fb7df94b..0000000000 --- a/twilio/rest/preview/understand/assistant/field_type/field_value.py +++ /dev/null @@ -1,577 +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 FieldValueInstance(InstanceResource): - - """ - :ivar account_sid: The unique ID of the Account that created this Field Value. - :ivar date_created: The date that this resource was created - :ivar date_updated: The date that this resource was last updated - :ivar field_type_sid: The unique ID of the Field Type associated with this Field Value. - :ivar language: An ISO language-country string of the value. - :ivar assistant_sid: The unique ID of the Assistant. - :ivar sid: A 34 character string that uniquely identifies this resource. - :ivar value: The Field Value itself. - :ivar url: - :ivar synonym_of: A value that indicates this field value is a synonym of. Empty if the value is not a synonym. - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - assistant_sid: str, - field_type_sid: str, - 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.field_type_sid: Optional[str] = payload.get("field_type_sid") - self.language: Optional[str] = payload.get("language") - self.assistant_sid: Optional[str] = payload.get("assistant_sid") - self.sid: Optional[str] = payload.get("sid") - self.value: Optional[str] = payload.get("value") - self.url: Optional[str] = payload.get("url") - self.synonym_of: Optional[str] = payload.get("synonym_of") - - self._solution = { - "assistant_sid": assistant_sid, - "field_type_sid": field_type_sid, - "sid": sid or self.sid, - } - self._context: Optional[FieldValueContext] = None - - @property - def _proxy(self) -> "FieldValueContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: FieldValueContext for this FieldValueInstance - """ - if self._context is None: - self._context = FieldValueContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - field_type_sid=self._solution["field_type_sid"], - sid=self._solution["sid"], - ) - return self._context - - def delete(self) -> bool: - """ - Deletes the FieldValueInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the FieldValueInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def fetch(self) -> "FieldValueInstance": - """ - Fetch the FieldValueInstance - - - :returns: The fetched FieldValueInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "FieldValueInstance": - """ - Asynchronous coroutine to fetch the FieldValueInstance - - - :returns: The fetched FieldValueInstance - """ - 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 FieldValueContext(InstanceContext): - def __init__( - self, version: Version, assistant_sid: str, field_type_sid: str, sid: str - ): - """ - Initialize the FieldValueContext - - :param version: Version that contains the resource - :param assistant_sid: - :param field_type_sid: - :param sid: - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - "field_type_sid": field_type_sid, - "sid": sid, - } - self._uri = "/Assistants/{assistant_sid}/FieldTypes/{field_type_sid}/FieldValues/{sid}".format( - **self._solution - ) - - def delete(self) -> bool: - """ - Deletes the FieldValueInstance - - - :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 FieldValueInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._version.delete_async( - method="DELETE", - uri=self._uri, - ) - - def fetch(self) -> FieldValueInstance: - """ - Fetch the FieldValueInstance - - - :returns: The fetched FieldValueInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return FieldValueInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - field_type_sid=self._solution["field_type_sid"], - sid=self._solution["sid"], - ) - - async def fetch_async(self) -> FieldValueInstance: - """ - Asynchronous coroutine to fetch the FieldValueInstance - - - :returns: The fetched FieldValueInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return FieldValueInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - field_type_sid=self._solution["field_type_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 FieldValuePage(Page): - def get_instance(self, payload: Dict[str, Any]) -> FieldValueInstance: - """ - Build an instance of FieldValueInstance - - :param payload: Payload response from the API - """ - return FieldValueInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - field_type_sid=self._solution["field_type_sid"], - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class FieldValueList(ListResource): - def __init__(self, version: Version, assistant_sid: str, field_type_sid: str): - """ - Initialize the FieldValueList - - :param version: Version that contains the resource - :param assistant_sid: - :param field_type_sid: - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - "field_type_sid": field_type_sid, - } - self._uri = "/Assistants/{assistant_sid}/FieldTypes/{field_type_sid}/FieldValues".format( - **self._solution - ) - - def create( - self, language: str, value: str, synonym_of: Union[str, object] = values.unset - ) -> FieldValueInstance: - """ - Create the FieldValueInstance - - :param language: An ISO language-country string of the value. - :param value: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - :param synonym_of: A value that indicates this field value is a synonym of. Empty if the value is not a synonym. - - :returns: The created FieldValueInstance - """ - data = values.of( - { - "Language": language, - "Value": value, - "SynonymOf": synonym_of, - } - ) - - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) - - return FieldValueInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - field_type_sid=self._solution["field_type_sid"], - ) - - async def create_async( - self, language: str, value: str, synonym_of: Union[str, object] = values.unset - ) -> FieldValueInstance: - """ - Asynchronously create the FieldValueInstance - - :param language: An ISO language-country string of the value. - :param value: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - :param synonym_of: A value that indicates this field value is a synonym of. Empty if the value is not a synonym. - - :returns: The created FieldValueInstance - """ - data = values.of( - { - "Language": language, - "Value": value, - "SynonymOf": synonym_of, - } - ) - - payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, - ) - - return FieldValueInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - field_type_sid=self._solution["field_type_sid"], - ) - - def stream( - self, - language: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[FieldValueInstance]: - """ - Streams FieldValueInstance 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 language: An ISO language-country string of the value. For example: *en-US* - :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(language=language, page_size=limits["page_size"]) - - return self._version.stream(page, limits["limit"]) - - async def stream_async( - self, - language: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> AsyncIterator[FieldValueInstance]: - """ - Asynchronously streams FieldValueInstance 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 language: An ISO language-country string of the value. For example: *en-US* - :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(language=language, page_size=limits["page_size"]) - - return self._version.stream_async(page, limits["limit"]) - - def list( - self, - language: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[FieldValueInstance]: - """ - Lists FieldValueInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param str language: An ISO language-country string of the value. For example: *en-US* - :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( - language=language, - limit=limit, - page_size=page_size, - ) - ) - - async def list_async( - self, - language: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[FieldValueInstance]: - """ - Asynchronously lists FieldValueInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param str language: An ISO language-country string of the value. For example: *en-US* - :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( - language=language, - limit=limit, - page_size=page_size, - ) - ] - - def page( - self, - language: 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, - ) -> FieldValuePage: - """ - Retrieve a single page of FieldValueInstance records from the API. - Request is executed immediately - - :param language: An ISO language-country string of the value. For example: *en-US* - :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 FieldValueInstance - """ - data = values.of( - { - "Language": language, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = self._version.page(method="GET", uri=self._uri, params=data) - return FieldValuePage(self._version, response, self._solution) - - async def page_async( - self, - language: 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, - ) -> FieldValuePage: - """ - Asynchronously retrieve a single page of FieldValueInstance records from the API. - Request is executed immediately - - :param language: An ISO language-country string of the value. For example: *en-US* - :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 FieldValueInstance - """ - data = values.of( - { - "Language": language, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = await self._version.page_async( - method="GET", uri=self._uri, params=data - ) - return FieldValuePage(self._version, response, self._solution) - - def get_page(self, target_url: str) -> FieldValuePage: - """ - Retrieve a specific page of FieldValueInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of FieldValueInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return FieldValuePage(self._version, response, self._solution) - - async def get_page_async(self, target_url: str) -> FieldValuePage: - """ - Asynchronously retrieve a specific page of FieldValueInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of FieldValueInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return FieldValuePage(self._version, response, self._solution) - - def get(self, sid: str) -> FieldValueContext: - """ - Constructs a FieldValueContext - - :param sid: - """ - return FieldValueContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - field_type_sid=self._solution["field_type_sid"], - sid=sid, - ) - - def __call__(self, sid: str) -> FieldValueContext: - """ - Constructs a FieldValueContext - - :param sid: - """ - return FieldValueContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - field_type_sid=self._solution["field_type_sid"], - sid=sid, - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview/understand/assistant/model_build.py b/twilio/rest/preview/understand/assistant/model_build.py deleted file mode 100644 index 8b45b76dc0..0000000000 --- a/twilio/rest/preview/understand/assistant/model_build.py +++ /dev/null @@ -1,627 +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 ModelBuildInstance(InstanceResource): - class Status(object): - ENQUEUED = "enqueued" - BUILDING = "building" - COMPLETED = "completed" - FAILED = "failed" - CANCELED = "canceled" - - """ - :ivar account_sid: The unique ID of the Account that created this Model Build. - :ivar date_created: The date that this resource was created - :ivar date_updated: The date that this resource was last updated - :ivar assistant_sid: The unique ID of the parent Assistant. - :ivar sid: A 34 character string that uniquely identifies this resource. - :ivar status: - :ivar unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - :ivar url: - :ivar build_duration: The time in seconds it took to build the model. - :ivar error_code: - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - assistant_sid: str, - 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.assistant_sid: Optional[str] = payload.get("assistant_sid") - self.sid: Optional[str] = payload.get("sid") - self.status: Optional["ModelBuildInstance.Status"] = payload.get("status") - self.unique_name: Optional[str] = payload.get("unique_name") - self.url: Optional[str] = payload.get("url") - self.build_duration: Optional[int] = deserialize.integer( - payload.get("build_duration") - ) - self.error_code: Optional[int] = deserialize.integer(payload.get("error_code")) - - self._solution = { - "assistant_sid": assistant_sid, - "sid": sid or self.sid, - } - self._context: Optional[ModelBuildContext] = None - - @property - def _proxy(self) -> "ModelBuildContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: ModelBuildContext for this ModelBuildInstance - """ - if self._context is None: - self._context = ModelBuildContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - return self._context - - def delete(self) -> bool: - """ - Deletes the ModelBuildInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the ModelBuildInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def fetch(self) -> "ModelBuildInstance": - """ - Fetch the ModelBuildInstance - - - :returns: The fetched ModelBuildInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "ModelBuildInstance": - """ - Asynchronous coroutine to fetch the ModelBuildInstance - - - :returns: The fetched ModelBuildInstance - """ - return await self._proxy.fetch_async() - - def update( - self, unique_name: Union[str, object] = values.unset - ) -> "ModelBuildInstance": - """ - Update the ModelBuildInstance - - :param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. For example: v0.1 - - :returns: The updated ModelBuildInstance - """ - return self._proxy.update( - unique_name=unique_name, - ) - - async def update_async( - self, unique_name: Union[str, object] = values.unset - ) -> "ModelBuildInstance": - """ - Asynchronous coroutine to update the ModelBuildInstance - - :param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. For example: v0.1 - - :returns: The updated ModelBuildInstance - """ - return await self._proxy.update_async( - unique_name=unique_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 ModelBuildContext(InstanceContext): - def __init__(self, version: Version, assistant_sid: str, sid: str): - """ - Initialize the ModelBuildContext - - :param version: Version that contains the resource - :param assistant_sid: - :param sid: - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - "sid": sid, - } - self._uri = "/Assistants/{assistant_sid}/ModelBuilds/{sid}".format( - **self._solution - ) - - def delete(self) -> bool: - """ - Deletes the ModelBuildInstance - - - :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 ModelBuildInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._version.delete_async( - method="DELETE", - uri=self._uri, - ) - - def fetch(self) -> ModelBuildInstance: - """ - Fetch the ModelBuildInstance - - - :returns: The fetched ModelBuildInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return ModelBuildInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - - async def fetch_async(self) -> ModelBuildInstance: - """ - Asynchronous coroutine to fetch the ModelBuildInstance - - - :returns: The fetched ModelBuildInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return ModelBuildInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - - def update( - self, unique_name: Union[str, object] = values.unset - ) -> ModelBuildInstance: - """ - Update the ModelBuildInstance - - :param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. For example: v0.1 - - :returns: The updated ModelBuildInstance - """ - data = values.of( - { - "UniqueName": unique_name, - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return ModelBuildInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - - async def update_async( - self, unique_name: Union[str, object] = values.unset - ) -> ModelBuildInstance: - """ - Asynchronous coroutine to update the ModelBuildInstance - - :param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. For example: v0.1 - - :returns: The updated ModelBuildInstance - """ - data = values.of( - { - "UniqueName": unique_name, - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return ModelBuildInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_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 ModelBuildPage(Page): - def get_instance(self, payload: Dict[str, Any]) -> ModelBuildInstance: - """ - Build an instance of ModelBuildInstance - - :param payload: Payload response from the API - """ - return ModelBuildInstance( - self._version, payload, assistant_sid=self._solution["assistant_sid"] - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class ModelBuildList(ListResource): - def __init__(self, version: Version, assistant_sid: str): - """ - Initialize the ModelBuildList - - :param version: Version that contains the resource - :param assistant_sid: - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - } - self._uri = "/Assistants/{assistant_sid}/ModelBuilds".format(**self._solution) - - def create( - self, - status_callback: Union[str, object] = values.unset, - unique_name: Union[str, object] = values.unset, - ) -> ModelBuildInstance: - """ - Create the ModelBuildInstance - - :param status_callback: - :param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. For example: v0.1 - - :returns: The created ModelBuildInstance - """ - data = values.of( - { - "StatusCallback": status_callback, - "UniqueName": unique_name, - } - ) - - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) - - return ModelBuildInstance( - self._version, payload, assistant_sid=self._solution["assistant_sid"] - ) - - async def create_async( - self, - status_callback: Union[str, object] = values.unset, - unique_name: Union[str, object] = values.unset, - ) -> ModelBuildInstance: - """ - Asynchronously create the ModelBuildInstance - - :param status_callback: - :param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. For example: v0.1 - - :returns: The created ModelBuildInstance - """ - data = values.of( - { - "StatusCallback": status_callback, - "UniqueName": unique_name, - } - ) - - payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, - ) - - return ModelBuildInstance( - self._version, payload, assistant_sid=self._solution["assistant_sid"] - ) - - def stream( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[ModelBuildInstance]: - """ - Streams ModelBuildInstance 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[ModelBuildInstance]: - """ - Asynchronously streams ModelBuildInstance 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[ModelBuildInstance]: - """ - Lists ModelBuildInstance 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[ModelBuildInstance]: - """ - Asynchronously lists ModelBuildInstance 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, - ) -> ModelBuildPage: - """ - Retrieve a single page of ModelBuildInstance 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 ModelBuildInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = self._version.page(method="GET", uri=self._uri, params=data) - return ModelBuildPage(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, - ) -> ModelBuildPage: - """ - Asynchronously retrieve a single page of ModelBuildInstance 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 ModelBuildInstance - """ - 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 ModelBuildPage(self._version, response, self._solution) - - def get_page(self, target_url: str) -> ModelBuildPage: - """ - Retrieve a specific page of ModelBuildInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of ModelBuildInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return ModelBuildPage(self._version, response, self._solution) - - async def get_page_async(self, target_url: str) -> ModelBuildPage: - """ - Asynchronously retrieve a specific page of ModelBuildInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of ModelBuildInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return ModelBuildPage(self._version, response, self._solution) - - def get(self, sid: str) -> ModelBuildContext: - """ - Constructs a ModelBuildContext - - :param sid: - """ - return ModelBuildContext( - self._version, assistant_sid=self._solution["assistant_sid"], sid=sid - ) - - def __call__(self, sid: str) -> ModelBuildContext: - """ - Constructs a ModelBuildContext - - :param sid: - """ - return ModelBuildContext( - self._version, assistant_sid=self._solution["assistant_sid"], sid=sid - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview/understand/assistant/query.py b/twilio/rest/preview/understand/assistant/query.py deleted file mode 100644 index 62fb2e3e11..0000000000 --- a/twilio/rest/preview/understand/assistant/query.py +++ /dev/null @@ -1,715 +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 QueryInstance(InstanceResource): - - """ - :ivar account_sid: The unique ID of the Account that created this Query. - :ivar date_created: The date that this resource was created - :ivar date_updated: The date that this resource was last updated - :ivar results: The natural language analysis results which include the Task recognized, the confidence score and a list of identified Fields. - :ivar language: An ISO language-country string of the sample. - :ivar model_build_sid: The unique ID of the Model Build queried. - :ivar query: The end-user's natural language input. - :ivar sample_sid: An optional reference to the Sample created from this query. - :ivar assistant_sid: The unique ID of the parent Assistant. - :ivar sid: A 34 character string that uniquely identifies this resource. - :ivar status: A string that described the query status. The values can be: pending_review, reviewed, discarded - :ivar url: - :ivar source_channel: The communication channel where this end-user input came from - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - assistant_sid: str, - 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.results: Optional[Dict[str, object]] = payload.get("results") - self.language: Optional[str] = payload.get("language") - self.model_build_sid: Optional[str] = payload.get("model_build_sid") - self.query: Optional[str] = payload.get("query") - self.sample_sid: Optional[str] = payload.get("sample_sid") - self.assistant_sid: Optional[str] = payload.get("assistant_sid") - self.sid: Optional[str] = payload.get("sid") - self.status: Optional[str] = payload.get("status") - self.url: Optional[str] = payload.get("url") - self.source_channel: Optional[str] = payload.get("source_channel") - - self._solution = { - "assistant_sid": assistant_sid, - "sid": sid or self.sid, - } - self._context: Optional[QueryContext] = None - - @property - def _proxy(self) -> "QueryContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: QueryContext for this QueryInstance - """ - if self._context is None: - self._context = QueryContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - return self._context - - def delete(self) -> bool: - """ - Deletes the QueryInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the QueryInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def fetch(self) -> "QueryInstance": - """ - Fetch the QueryInstance - - - :returns: The fetched QueryInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "QueryInstance": - """ - Asynchronous coroutine to fetch the QueryInstance - - - :returns: The fetched QueryInstance - """ - return await self._proxy.fetch_async() - - def update( - self, - sample_sid: Union[str, object] = values.unset, - status: Union[str, object] = values.unset, - ) -> "QueryInstance": - """ - Update the QueryInstance - - :param sample_sid: An optional reference to the Sample created from this query. - :param status: A string that described the query status. The values can be: pending_review, reviewed, discarded - - :returns: The updated QueryInstance - """ - return self._proxy.update( - sample_sid=sample_sid, - status=status, - ) - - async def update_async( - self, - sample_sid: Union[str, object] = values.unset, - status: Union[str, object] = values.unset, - ) -> "QueryInstance": - """ - Asynchronous coroutine to update the QueryInstance - - :param sample_sid: An optional reference to the Sample created from this query. - :param status: A string that described the query status. The values can be: pending_review, reviewed, discarded - - :returns: The updated QueryInstance - """ - return await self._proxy.update_async( - sample_sid=sample_sid, - 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 QueryContext(InstanceContext): - def __init__(self, version: Version, assistant_sid: str, sid: str): - """ - Initialize the QueryContext - - :param version: Version that contains the resource - :param assistant_sid: The unique ID of the parent Assistant. - :param sid: A 34 character string that uniquely identifies this resource. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - "sid": sid, - } - self._uri = "/Assistants/{assistant_sid}/Queries/{sid}".format(**self._solution) - - def delete(self) -> bool: - """ - Deletes the QueryInstance - - - :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 QueryInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._version.delete_async( - method="DELETE", - uri=self._uri, - ) - - def fetch(self) -> QueryInstance: - """ - Fetch the QueryInstance - - - :returns: The fetched QueryInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return QueryInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - - async def fetch_async(self) -> QueryInstance: - """ - Asynchronous coroutine to fetch the QueryInstance - - - :returns: The fetched QueryInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return QueryInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - - def update( - self, - sample_sid: Union[str, object] = values.unset, - status: Union[str, object] = values.unset, - ) -> QueryInstance: - """ - Update the QueryInstance - - :param sample_sid: An optional reference to the Sample created from this query. - :param status: A string that described the query status. The values can be: pending_review, reviewed, discarded - - :returns: The updated QueryInstance - """ - data = values.of( - { - "SampleSid": sample_sid, - "Status": status, - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return QueryInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - - async def update_async( - self, - sample_sid: Union[str, object] = values.unset, - status: Union[str, object] = values.unset, - ) -> QueryInstance: - """ - Asynchronous coroutine to update the QueryInstance - - :param sample_sid: An optional reference to the Sample created from this query. - :param status: A string that described the query status. The values can be: pending_review, reviewed, discarded - - :returns: The updated QueryInstance - """ - data = values.of( - { - "SampleSid": sample_sid, - "Status": status, - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return QueryInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_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 QueryPage(Page): - def get_instance(self, payload: Dict[str, Any]) -> QueryInstance: - """ - Build an instance of QueryInstance - - :param payload: Payload response from the API - """ - return QueryInstance( - self._version, payload, assistant_sid=self._solution["assistant_sid"] - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class QueryList(ListResource): - def __init__(self, version: Version, assistant_sid: str): - """ - Initialize the QueryList - - :param version: Version that contains the resource - :param assistant_sid: The unique ID of the parent Assistant. - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - } - self._uri = "/Assistants/{assistant_sid}/Queries".format(**self._solution) - - def create( - self, - language: str, - query: str, - tasks: Union[str, object] = values.unset, - model_build: Union[str, object] = values.unset, - field: Union[str, object] = values.unset, - ) -> QueryInstance: - """ - Create the QueryInstance - - :param language: An ISO language-country string of the sample. - :param query: A user-provided string that uniquely identifies this resource as an alternative to the sid. It can be up to 2048 characters long. - :param tasks: Constraints the query to a set of tasks. Useful when you need to constrain the paths the user can take. Tasks should be comma separated *task-unique-name-1*, *task-unique-name-2* - :param model_build: The Model Build Sid or unique name of the Model Build to be queried. - :param field: Constraints the query to a given Field with an task. Useful when you know the Field you are expecting. It accepts one field in the format *task-unique-name-1*:*field-unique-name* - - :returns: The created QueryInstance - """ - data = values.of( - { - "Language": language, - "Query": query, - "Tasks": tasks, - "ModelBuild": model_build, - "Field": field, - } - ) - - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) - - return QueryInstance( - self._version, payload, assistant_sid=self._solution["assistant_sid"] - ) - - async def create_async( - self, - language: str, - query: str, - tasks: Union[str, object] = values.unset, - model_build: Union[str, object] = values.unset, - field: Union[str, object] = values.unset, - ) -> QueryInstance: - """ - Asynchronously create the QueryInstance - - :param language: An ISO language-country string of the sample. - :param query: A user-provided string that uniquely identifies this resource as an alternative to the sid. It can be up to 2048 characters long. - :param tasks: Constraints the query to a set of tasks. Useful when you need to constrain the paths the user can take. Tasks should be comma separated *task-unique-name-1*, *task-unique-name-2* - :param model_build: The Model Build Sid or unique name of the Model Build to be queried. - :param field: Constraints the query to a given Field with an task. Useful when you know the Field you are expecting. It accepts one field in the format *task-unique-name-1*:*field-unique-name* - - :returns: The created QueryInstance - """ - data = values.of( - { - "Language": language, - "Query": query, - "Tasks": tasks, - "ModelBuild": model_build, - "Field": field, - } - ) - - payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, - ) - - return QueryInstance( - self._version, payload, assistant_sid=self._solution["assistant_sid"] - ) - - def stream( - self, - language: Union[str, object] = values.unset, - model_build: Union[str, object] = values.unset, - status: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[QueryInstance]: - """ - Streams QueryInstance 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 language: An ISO language-country string of the sample. - :param str model_build: The Model Build Sid or unique name of the Model Build to be queried. - :param str status: A string that described the query status. The values can be: pending_review, reviewed, discarded - :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( - language=language, - model_build=model_build, - status=status, - page_size=limits["page_size"], - ) - - return self._version.stream(page, limits["limit"]) - - async def stream_async( - self, - language: Union[str, object] = values.unset, - model_build: Union[str, object] = values.unset, - status: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> AsyncIterator[QueryInstance]: - """ - Asynchronously streams QueryInstance 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 language: An ISO language-country string of the sample. - :param str model_build: The Model Build Sid or unique name of the Model Build to be queried. - :param str status: A string that described the query status. The values can be: pending_review, reviewed, discarded - :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( - language=language, - model_build=model_build, - status=status, - page_size=limits["page_size"], - ) - - return self._version.stream_async(page, limits["limit"]) - - def list( - self, - language: Union[str, object] = values.unset, - model_build: Union[str, object] = values.unset, - status: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[QueryInstance]: - """ - Lists QueryInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param str language: An ISO language-country string of the sample. - :param str model_build: The Model Build Sid or unique name of the Model Build to be queried. - :param str status: A string that described the query status. The values can be: pending_review, reviewed, discarded - :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( - language=language, - model_build=model_build, - status=status, - limit=limit, - page_size=page_size, - ) - ) - - async def list_async( - self, - language: Union[str, object] = values.unset, - model_build: Union[str, object] = values.unset, - status: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[QueryInstance]: - """ - Asynchronously lists QueryInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param str language: An ISO language-country string of the sample. - :param str model_build: The Model Build Sid or unique name of the Model Build to be queried. - :param str status: A string that described the query status. The values can be: pending_review, reviewed, discarded - :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( - language=language, - model_build=model_build, - status=status, - limit=limit, - page_size=page_size, - ) - ] - - def page( - self, - language: Union[str, object] = values.unset, - model_build: Union[str, object] = values.unset, - status: 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, - ) -> QueryPage: - """ - Retrieve a single page of QueryInstance records from the API. - Request is executed immediately - - :param language: An ISO language-country string of the sample. - :param model_build: The Model Build Sid or unique name of the Model Build to be queried. - :param status: A string that described the query status. The values can be: pending_review, reviewed, discarded - :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 QueryInstance - """ - data = values.of( - { - "Language": language, - "ModelBuild": model_build, - "Status": status, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = self._version.page(method="GET", uri=self._uri, params=data) - return QueryPage(self._version, response, self._solution) - - async def page_async( - self, - language: Union[str, object] = values.unset, - model_build: Union[str, object] = values.unset, - status: 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, - ) -> QueryPage: - """ - Asynchronously retrieve a single page of QueryInstance records from the API. - Request is executed immediately - - :param language: An ISO language-country string of the sample. - :param model_build: The Model Build Sid or unique name of the Model Build to be queried. - :param status: A string that described the query status. The values can be: pending_review, reviewed, discarded - :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 QueryInstance - """ - data = values.of( - { - "Language": language, - "ModelBuild": model_build, - "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 QueryPage(self._version, response, self._solution) - - def get_page(self, target_url: str) -> QueryPage: - """ - Retrieve a specific page of QueryInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of QueryInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return QueryPage(self._version, response, self._solution) - - async def get_page_async(self, target_url: str) -> QueryPage: - """ - Asynchronously retrieve a specific page of QueryInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of QueryInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return QueryPage(self._version, response, self._solution) - - def get(self, sid: str) -> QueryContext: - """ - Constructs a QueryContext - - :param sid: A 34 character string that uniquely identifies this resource. - """ - return QueryContext( - self._version, assistant_sid=self._solution["assistant_sid"], sid=sid - ) - - def __call__(self, sid: str) -> QueryContext: - """ - Constructs a QueryContext - - :param sid: A 34 character string that uniquely identifies this resource. - """ - return QueryContext( - self._version, assistant_sid=self._solution["assistant_sid"], sid=sid - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview/understand/assistant/style_sheet.py b/twilio/rest/preview/understand/assistant/style_sheet.py deleted file mode 100644 index 4571fc4cb1..0000000000 --- a/twilio/rest/preview/understand/assistant/style_sheet.py +++ /dev/null @@ -1,273 +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, 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 - - -class StyleSheetInstance(InstanceResource): - - """ - :ivar account_sid: The unique ID of the Account that created this Assistant - :ivar assistant_sid: The unique ID of the Assistant - :ivar url: - :ivar data: The JSON style sheet object - """ - - def __init__(self, version: Version, payload: Dict[str, Any], assistant_sid: str): - super().__init__(version) - - self.account_sid: Optional[str] = payload.get("account_sid") - self.assistant_sid: Optional[str] = payload.get("assistant_sid") - self.url: Optional[str] = payload.get("url") - self.data: Optional[Dict[str, object]] = payload.get("data") - - self._solution = { - "assistant_sid": assistant_sid, - } - self._context: Optional[StyleSheetContext] = None - - @property - def _proxy(self) -> "StyleSheetContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: StyleSheetContext for this StyleSheetInstance - """ - if self._context is None: - self._context = StyleSheetContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - ) - return self._context - - def fetch(self) -> "StyleSheetInstance": - """ - Fetch the StyleSheetInstance - - - :returns: The fetched StyleSheetInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "StyleSheetInstance": - """ - Asynchronous coroutine to fetch the StyleSheetInstance - - - :returns: The fetched StyleSheetInstance - """ - return await self._proxy.fetch_async() - - def update( - self, style_sheet: Union[object, object] = values.unset - ) -> "StyleSheetInstance": - """ - Update the StyleSheetInstance - - :param style_sheet: The JSON Style sheet string - - :returns: The updated StyleSheetInstance - """ - return self._proxy.update( - style_sheet=style_sheet, - ) - - async def update_async( - self, style_sheet: Union[object, object] = values.unset - ) -> "StyleSheetInstance": - """ - Asynchronous coroutine to update the StyleSheetInstance - - :param style_sheet: The JSON Style sheet string - - :returns: The updated StyleSheetInstance - """ - return await self._proxy.update_async( - style_sheet=style_sheet, - ) - - 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 StyleSheetContext(InstanceContext): - def __init__(self, version: Version, assistant_sid: str): - """ - Initialize the StyleSheetContext - - :param version: Version that contains the resource - :param assistant_sid: The unique ID of the Assistant - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - } - self._uri = "/Assistants/{assistant_sid}/StyleSheet".format(**self._solution) - - def fetch(self) -> StyleSheetInstance: - """ - Fetch the StyleSheetInstance - - - :returns: The fetched StyleSheetInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return StyleSheetInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - ) - - async def fetch_async(self) -> StyleSheetInstance: - """ - Asynchronous coroutine to fetch the StyleSheetInstance - - - :returns: The fetched StyleSheetInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return StyleSheetInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - ) - - def update( - self, style_sheet: Union[object, object] = values.unset - ) -> StyleSheetInstance: - """ - Update the StyleSheetInstance - - :param style_sheet: The JSON Style sheet string - - :returns: The updated StyleSheetInstance - """ - data = values.of( - { - "StyleSheet": serialize.object(style_sheet), - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return StyleSheetInstance( - self._version, payload, assistant_sid=self._solution["assistant_sid"] - ) - - async def update_async( - self, style_sheet: Union[object, object] = values.unset - ) -> StyleSheetInstance: - """ - Asynchronous coroutine to update the StyleSheetInstance - - :param style_sheet: The JSON Style sheet string - - :returns: The updated StyleSheetInstance - """ - data = values.of( - { - "StyleSheet": serialize.object(style_sheet), - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return StyleSheetInstance( - self._version, payload, assistant_sid=self._solution["assistant_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 StyleSheetList(ListResource): - def __init__(self, version: Version, assistant_sid: str): - """ - Initialize the StyleSheetList - - :param version: Version that contains the resource - :param assistant_sid: The unique ID of the Assistant - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - } - - def get(self) -> StyleSheetContext: - """ - Constructs a StyleSheetContext - - """ - return StyleSheetContext( - self._version, assistant_sid=self._solution["assistant_sid"] - ) - - def __call__(self) -> StyleSheetContext: - """ - Constructs a StyleSheetContext - - """ - return StyleSheetContext( - self._version, assistant_sid=self._solution["assistant_sid"] - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview/understand/assistant/task/__init__.py b/twilio/rest/preview/understand/assistant/task/__init__.py deleted file mode 100644 index 135a421ec6..0000000000 --- a/twilio/rest/preview/understand/assistant/task/__init__.py +++ /dev/null @@ -1,760 +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.understand.assistant.task.field import FieldList -from twilio.rest.preview.understand.assistant.task.sample import SampleList -from twilio.rest.preview.understand.assistant.task.task_actions import TaskActionsList -from twilio.rest.preview.understand.assistant.task.task_statistics import ( - TaskStatisticsList, -) - - -class TaskInstance(InstanceResource): - - """ - :ivar account_sid: The unique ID of the Account that created this Task. - :ivar date_created: The date that this resource was created - :ivar date_updated: The date that this resource was last updated - :ivar friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long. - :ivar links: - :ivar assistant_sid: The unique ID of the Assistant. - :ivar sid: A 34 character string that uniquely identifies this resource. - :ivar unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - :ivar actions_url: User-provided HTTP endpoint where from the assistant fetches actions - :ivar url: - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - assistant_sid: str, - 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.friendly_name: Optional[str] = payload.get("friendly_name") - self.links: Optional[Dict[str, object]] = payload.get("links") - self.assistant_sid: Optional[str] = payload.get("assistant_sid") - self.sid: Optional[str] = payload.get("sid") - self.unique_name: Optional[str] = payload.get("unique_name") - self.actions_url: Optional[str] = payload.get("actions_url") - self.url: Optional[str] = payload.get("url") - - self._solution = { - "assistant_sid": assistant_sid, - "sid": sid or self.sid, - } - self._context: Optional[TaskContext] = None - - @property - def _proxy(self) -> "TaskContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: TaskContext for this TaskInstance - """ - if self._context is None: - self._context = TaskContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - return self._context - - def delete(self) -> bool: - """ - Deletes the TaskInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the TaskInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def fetch(self) -> "TaskInstance": - """ - Fetch the TaskInstance - - - :returns: The fetched TaskInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "TaskInstance": - """ - Asynchronous coroutine to fetch the TaskInstance - - - :returns: The fetched TaskInstance - """ - return await self._proxy.fetch_async() - - def update( - self, - friendly_name: Union[str, object] = values.unset, - unique_name: Union[str, object] = values.unset, - actions: Union[object, object] = values.unset, - actions_url: Union[str, object] = values.unset, - ) -> "TaskInstance": - """ - Update the TaskInstance - - :param friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long. - :param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - :param actions: A user-provided JSON object encoded as a string to specify the actions for this task. It is optional and non-unique. - :param actions_url: User-provided HTTP endpoint where from the assistant fetches actions - - :returns: The updated TaskInstance - """ - return self._proxy.update( - friendly_name=friendly_name, - unique_name=unique_name, - actions=actions, - actions_url=actions_url, - ) - - async def update_async( - self, - friendly_name: Union[str, object] = values.unset, - unique_name: Union[str, object] = values.unset, - actions: Union[object, object] = values.unset, - actions_url: Union[str, object] = values.unset, - ) -> "TaskInstance": - """ - Asynchronous coroutine to update the TaskInstance - - :param friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long. - :param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - :param actions: A user-provided JSON object encoded as a string to specify the actions for this task. It is optional and non-unique. - :param actions_url: User-provided HTTP endpoint where from the assistant fetches actions - - :returns: The updated TaskInstance - """ - return await self._proxy.update_async( - friendly_name=friendly_name, - unique_name=unique_name, - actions=actions, - actions_url=actions_url, - ) - - @property - def fields(self) -> FieldList: - """ - Access the fields - """ - return self._proxy.fields - - @property - def samples(self) -> SampleList: - """ - Access the samples - """ - return self._proxy.samples - - @property - def task_actions(self) -> TaskActionsList: - """ - Access the task_actions - """ - return self._proxy.task_actions - - @property - def statistics(self) -> TaskStatisticsList: - """ - Access the statistics - """ - return self._proxy.statistics - - 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 TaskContext(InstanceContext): - def __init__(self, version: Version, assistant_sid: str, sid: str): - """ - Initialize the TaskContext - - :param version: Version that contains the resource - :param assistant_sid: The unique ID of the Assistant. - :param sid: A 34 character string that uniquely identifies this resource. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - "sid": sid, - } - self._uri = "/Assistants/{assistant_sid}/Tasks/{sid}".format(**self._solution) - - self._fields: Optional[FieldList] = None - self._samples: Optional[SampleList] = None - self._task_actions: Optional[TaskActionsList] = None - self._statistics: Optional[TaskStatisticsList] = None - - def delete(self) -> bool: - """ - Deletes the TaskInstance - - - :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 TaskInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._version.delete_async( - method="DELETE", - uri=self._uri, - ) - - def fetch(self) -> TaskInstance: - """ - Fetch the TaskInstance - - - :returns: The fetched TaskInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return TaskInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - - async def fetch_async(self) -> TaskInstance: - """ - Asynchronous coroutine to fetch the TaskInstance - - - :returns: The fetched TaskInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return TaskInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - - def update( - self, - friendly_name: Union[str, object] = values.unset, - unique_name: Union[str, object] = values.unset, - actions: Union[object, object] = values.unset, - actions_url: Union[str, object] = values.unset, - ) -> TaskInstance: - """ - Update the TaskInstance - - :param friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long. - :param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - :param actions: A user-provided JSON object encoded as a string to specify the actions for this task. It is optional and non-unique. - :param actions_url: User-provided HTTP endpoint where from the assistant fetches actions - - :returns: The updated TaskInstance - """ - data = values.of( - { - "FriendlyName": friendly_name, - "UniqueName": unique_name, - "Actions": serialize.object(actions), - "ActionsUrl": actions_url, - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return TaskInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - - async def update_async( - self, - friendly_name: Union[str, object] = values.unset, - unique_name: Union[str, object] = values.unset, - actions: Union[object, object] = values.unset, - actions_url: Union[str, object] = values.unset, - ) -> TaskInstance: - """ - Asynchronous coroutine to update the TaskInstance - - :param friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long. - :param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - :param actions: A user-provided JSON object encoded as a string to specify the actions for this task. It is optional and non-unique. - :param actions_url: User-provided HTTP endpoint where from the assistant fetches actions - - :returns: The updated TaskInstance - """ - data = values.of( - { - "FriendlyName": friendly_name, - "UniqueName": unique_name, - "Actions": serialize.object(actions), - "ActionsUrl": actions_url, - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return TaskInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - sid=self._solution["sid"], - ) - - @property - def fields(self) -> FieldList: - """ - Access the fields - """ - if self._fields is None: - self._fields = FieldList( - self._version, - self._solution["assistant_sid"], - self._solution["sid"], - ) - return self._fields - - @property - def samples(self) -> SampleList: - """ - Access the samples - """ - if self._samples is None: - self._samples = SampleList( - self._version, - self._solution["assistant_sid"], - self._solution["sid"], - ) - return self._samples - - @property - def task_actions(self) -> TaskActionsList: - """ - Access the task_actions - """ - if self._task_actions is None: - self._task_actions = TaskActionsList( - self._version, - self._solution["assistant_sid"], - self._solution["sid"], - ) - return self._task_actions - - @property - def statistics(self) -> TaskStatisticsList: - """ - Access the statistics - """ - if self._statistics is None: - self._statistics = TaskStatisticsList( - self._version, - self._solution["assistant_sid"], - self._solution["sid"], - ) - return self._statistics - - 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 TaskPage(Page): - def get_instance(self, payload: Dict[str, Any]) -> TaskInstance: - """ - Build an instance of TaskInstance - - :param payload: Payload response from the API - """ - return TaskInstance( - self._version, payload, assistant_sid=self._solution["assistant_sid"] - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class TaskList(ListResource): - def __init__(self, version: Version, assistant_sid: str): - """ - Initialize the TaskList - - :param version: Version that contains the resource - :param assistant_sid: The unique ID of the Assistant. - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - } - self._uri = "/Assistants/{assistant_sid}/Tasks".format(**self._solution) - - def create( - self, - unique_name: str, - friendly_name: Union[str, object] = values.unset, - actions: Union[object, object] = values.unset, - actions_url: Union[str, object] = values.unset, - ) -> TaskInstance: - """ - Create the TaskInstance - - :param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - :param friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long. - :param actions: A user-provided JSON object encoded as a string to specify the actions for this task. It is optional and non-unique. - :param actions_url: User-provided HTTP endpoint where from the assistant fetches actions - - :returns: The created TaskInstance - """ - data = values.of( - { - "UniqueName": unique_name, - "FriendlyName": friendly_name, - "Actions": serialize.object(actions), - "ActionsUrl": actions_url, - } - ) - - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) - - return TaskInstance( - self._version, payload, assistant_sid=self._solution["assistant_sid"] - ) - - async def create_async( - self, - unique_name: str, - friendly_name: Union[str, object] = values.unset, - actions: Union[object, object] = values.unset, - actions_url: Union[str, object] = values.unset, - ) -> TaskInstance: - """ - Asynchronously create the TaskInstance - - :param unique_name: A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long. - :param friendly_name: A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long. - :param actions: A user-provided JSON object encoded as a string to specify the actions for this task. It is optional and non-unique. - :param actions_url: User-provided HTTP endpoint where from the assistant fetches actions - - :returns: The created TaskInstance - """ - data = values.of( - { - "UniqueName": unique_name, - "FriendlyName": friendly_name, - "Actions": serialize.object(actions), - "ActionsUrl": actions_url, - } - ) - - payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, - ) - - return TaskInstance( - self._version, payload, assistant_sid=self._solution["assistant_sid"] - ) - - def stream( - self, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[TaskInstance]: - """ - Streams TaskInstance 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[TaskInstance]: - """ - Asynchronously streams TaskInstance 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[TaskInstance]: - """ - Lists TaskInstance 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[TaskInstance]: - """ - Asynchronously lists TaskInstance 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, - ) -> TaskPage: - """ - Retrieve a single page of TaskInstance 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 TaskInstance - """ - data = values.of( - { - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = self._version.page(method="GET", uri=self._uri, params=data) - return TaskPage(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, - ) -> TaskPage: - """ - Asynchronously retrieve a single page of TaskInstance 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 TaskInstance - """ - 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 TaskPage(self._version, response, self._solution) - - def get_page(self, target_url: str) -> TaskPage: - """ - Retrieve a specific page of TaskInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of TaskInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return TaskPage(self._version, response, self._solution) - - async def get_page_async(self, target_url: str) -> TaskPage: - """ - Asynchronously retrieve a specific page of TaskInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of TaskInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return TaskPage(self._version, response, self._solution) - - def get(self, sid: str) -> TaskContext: - """ - Constructs a TaskContext - - :param sid: A 34 character string that uniquely identifies this resource. - """ - return TaskContext( - self._version, assistant_sid=self._solution["assistant_sid"], sid=sid - ) - - def __call__(self, sid: str) -> TaskContext: - """ - Constructs a TaskContext - - :param sid: A 34 character string that uniquely identifies this resource. - """ - return TaskContext( - self._version, assistant_sid=self._solution["assistant_sid"], sid=sid - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview/understand/assistant/task/sample.py b/twilio/rest/preview/understand/assistant/task/sample.py deleted file mode 100644 index ef8719c6ac..0000000000 --- a/twilio/rest/preview/understand/assistant/task/sample.py +++ /dev/null @@ -1,697 +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 SampleInstance(InstanceResource): - - """ - :ivar account_sid: The unique ID of the Account that created this Sample. - :ivar date_created: The date that this resource was created - :ivar date_updated: The date that this resource was last updated - :ivar task_sid: The unique ID of the Task associated with this Sample. - :ivar language: An ISO language-country string of the sample. - :ivar assistant_sid: The unique ID of the Assistant. - :ivar sid: A 34 character string that uniquely identifies this resource. - :ivar tagged_text: The text example of how end-users may express this task. The sample may contain Field tag blocks. - :ivar url: - :ivar source_channel: The communication channel the sample was captured. It can be: *voice*, *sms*, *chat*, *alexa*, *google-assistant*, or *slack*. If not included the value will be null - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - assistant_sid: str, - task_sid: str, - 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.task_sid: Optional[str] = payload.get("task_sid") - self.language: Optional[str] = payload.get("language") - self.assistant_sid: Optional[str] = payload.get("assistant_sid") - self.sid: Optional[str] = payload.get("sid") - self.tagged_text: Optional[str] = payload.get("tagged_text") - self.url: Optional[str] = payload.get("url") - self.source_channel: Optional[str] = payload.get("source_channel") - - self._solution = { - "assistant_sid": assistant_sid, - "task_sid": task_sid, - "sid": sid or self.sid, - } - self._context: Optional[SampleContext] = None - - @property - def _proxy(self) -> "SampleContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: SampleContext for this SampleInstance - """ - if self._context is None: - self._context = SampleContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - sid=self._solution["sid"], - ) - return self._context - - def delete(self) -> bool: - """ - Deletes the SampleInstance - - - :returns: True if delete succeeds, False otherwise - """ - return self._proxy.delete() - - async def delete_async(self) -> bool: - """ - Asynchronous coroutine that deletes the SampleInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._proxy.delete_async() - - def fetch(self) -> "SampleInstance": - """ - Fetch the SampleInstance - - - :returns: The fetched SampleInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "SampleInstance": - """ - Asynchronous coroutine to fetch the SampleInstance - - - :returns: The fetched SampleInstance - """ - return await self._proxy.fetch_async() - - def update( - self, - language: Union[str, object] = values.unset, - tagged_text: Union[str, object] = values.unset, - source_channel: Union[str, object] = values.unset, - ) -> "SampleInstance": - """ - Update the SampleInstance - - :param language: An ISO language-country string of the sample. - :param tagged_text: The text example of how end-users may express this task. The sample may contain Field tag blocks. - :param source_channel: The communication channel the sample was captured. It can be: *voice*, *sms*, *chat*, *alexa*, *google-assistant*, or *slack*. If not included the value will be null - - :returns: The updated SampleInstance - """ - return self._proxy.update( - language=language, - tagged_text=tagged_text, - source_channel=source_channel, - ) - - async def update_async( - self, - language: Union[str, object] = values.unset, - tagged_text: Union[str, object] = values.unset, - source_channel: Union[str, object] = values.unset, - ) -> "SampleInstance": - """ - Asynchronous coroutine to update the SampleInstance - - :param language: An ISO language-country string of the sample. - :param tagged_text: The text example of how end-users may express this task. The sample may contain Field tag blocks. - :param source_channel: The communication channel the sample was captured. It can be: *voice*, *sms*, *chat*, *alexa*, *google-assistant*, or *slack*. If not included the value will be null - - :returns: The updated SampleInstance - """ - return await self._proxy.update_async( - language=language, - tagged_text=tagged_text, - source_channel=source_channel, - ) - - 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 SampleContext(InstanceContext): - def __init__(self, version: Version, assistant_sid: str, task_sid: str, sid: str): - """ - Initialize the SampleContext - - :param version: Version that contains the resource - :param assistant_sid: The unique ID of the Assistant. - :param task_sid: The unique ID of the Task associated with this Sample. - :param sid: A 34 character string that uniquely identifies this resource. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - "task_sid": task_sid, - "sid": sid, - } - self._uri = "/Assistants/{assistant_sid}/Tasks/{task_sid}/Samples/{sid}".format( - **self._solution - ) - - def delete(self) -> bool: - """ - Deletes the SampleInstance - - - :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 SampleInstance - - - :returns: True if delete succeeds, False otherwise - """ - return await self._version.delete_async( - method="DELETE", - uri=self._uri, - ) - - def fetch(self) -> SampleInstance: - """ - Fetch the SampleInstance - - - :returns: The fetched SampleInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return SampleInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - sid=self._solution["sid"], - ) - - async def fetch_async(self) -> SampleInstance: - """ - Asynchronous coroutine to fetch the SampleInstance - - - :returns: The fetched SampleInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return SampleInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - sid=self._solution["sid"], - ) - - def update( - self, - language: Union[str, object] = values.unset, - tagged_text: Union[str, object] = values.unset, - source_channel: Union[str, object] = values.unset, - ) -> SampleInstance: - """ - Update the SampleInstance - - :param language: An ISO language-country string of the sample. - :param tagged_text: The text example of how end-users may express this task. The sample may contain Field tag blocks. - :param source_channel: The communication channel the sample was captured. It can be: *voice*, *sms*, *chat*, *alexa*, *google-assistant*, or *slack*. If not included the value will be null - - :returns: The updated SampleInstance - """ - data = values.of( - { - "Language": language, - "TaggedText": tagged_text, - "SourceChannel": source_channel, - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return SampleInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - sid=self._solution["sid"], - ) - - async def update_async( - self, - language: Union[str, object] = values.unset, - tagged_text: Union[str, object] = values.unset, - source_channel: Union[str, object] = values.unset, - ) -> SampleInstance: - """ - Asynchronous coroutine to update the SampleInstance - - :param language: An ISO language-country string of the sample. - :param tagged_text: The text example of how end-users may express this task. The sample may contain Field tag blocks. - :param source_channel: The communication channel the sample was captured. It can be: *voice*, *sms*, *chat*, *alexa*, *google-assistant*, or *slack*. If not included the value will be null - - :returns: The updated SampleInstance - """ - data = values.of( - { - "Language": language, - "TaggedText": tagged_text, - "SourceChannel": source_channel, - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return SampleInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_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 SamplePage(Page): - def get_instance(self, payload: Dict[str, Any]) -> SampleInstance: - """ - Build an instance of SampleInstance - - :param payload: Payload response from the API - """ - return SampleInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" - - -class SampleList(ListResource): - def __init__(self, version: Version, assistant_sid: str, task_sid: str): - """ - Initialize the SampleList - - :param version: Version that contains the resource - :param assistant_sid: The unique ID of the Assistant. - :param task_sid: The unique ID of the Task associated with this Sample. - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - "task_sid": task_sid, - } - self._uri = "/Assistants/{assistant_sid}/Tasks/{task_sid}/Samples".format( - **self._solution - ) - - def create( - self, - language: str, - tagged_text: str, - source_channel: Union[str, object] = values.unset, - ) -> SampleInstance: - """ - Create the SampleInstance - - :param language: An ISO language-country string of the sample. - :param tagged_text: The text example of how end-users may express this task. The sample may contain Field tag blocks. - :param source_channel: The communication channel the sample was captured. It can be: *voice*, *sms*, *chat*, *alexa*, *google-assistant*, or *slack*. If not included the value will be null - - :returns: The created SampleInstance - """ - data = values.of( - { - "Language": language, - "TaggedText": tagged_text, - "SourceChannel": source_channel, - } - ) - - payload = self._version.create( - method="POST", - uri=self._uri, - data=data, - ) - - return SampleInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - ) - - async def create_async( - self, - language: str, - tagged_text: str, - source_channel: Union[str, object] = values.unset, - ) -> SampleInstance: - """ - Asynchronously create the SampleInstance - - :param language: An ISO language-country string of the sample. - :param tagged_text: The text example of how end-users may express this task. The sample may contain Field tag blocks. - :param source_channel: The communication channel the sample was captured. It can be: *voice*, *sms*, *chat*, *alexa*, *google-assistant*, or *slack*. If not included the value will be null - - :returns: The created SampleInstance - """ - data = values.of( - { - "Language": language, - "TaggedText": tagged_text, - "SourceChannel": source_channel, - } - ) - - payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, - ) - - return SampleInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - ) - - def stream( - self, - language: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> Iterator[SampleInstance]: - """ - Streams SampleInstance 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 language: An ISO language-country string of the sample. - :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(language=language, page_size=limits["page_size"]) - - return self._version.stream(page, limits["limit"]) - - async def stream_async( - self, - language: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> AsyncIterator[SampleInstance]: - """ - Asynchronously streams SampleInstance 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 language: An ISO language-country string of the sample. - :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(language=language, page_size=limits["page_size"]) - - return self._version.stream_async(page, limits["limit"]) - - def list( - self, - language: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[SampleInstance]: - """ - Lists SampleInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param str language: An ISO language-country string of the sample. - :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( - language=language, - limit=limit, - page_size=page_size, - ) - ) - - async def list_async( - self, - language: Union[str, object] = values.unset, - limit: Optional[int] = None, - page_size: Optional[int] = None, - ) -> List[SampleInstance]: - """ - Asynchronously lists SampleInstance records from the API as a list. - Unlike stream(), this operation is eager and will load `limit` records into - memory before returning. - - :param str language: An ISO language-country string of the sample. - :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( - language=language, - limit=limit, - page_size=page_size, - ) - ] - - def page( - self, - language: 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, - ) -> SamplePage: - """ - Retrieve a single page of SampleInstance records from the API. - Request is executed immediately - - :param language: An ISO language-country string of the sample. - :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 SampleInstance - """ - data = values.of( - { - "Language": language, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = self._version.page(method="GET", uri=self._uri, params=data) - return SamplePage(self._version, response, self._solution) - - async def page_async( - self, - language: 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, - ) -> SamplePage: - """ - Asynchronously retrieve a single page of SampleInstance records from the API. - Request is executed immediately - - :param language: An ISO language-country string of the sample. - :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 SampleInstance - """ - data = values.of( - { - "Language": language, - "PageToken": page_token, - "Page": page_number, - "PageSize": page_size, - } - ) - - response = await self._version.page_async( - method="GET", uri=self._uri, params=data - ) - return SamplePage(self._version, response, self._solution) - - def get_page(self, target_url: str) -> SamplePage: - """ - Retrieve a specific page of SampleInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of SampleInstance - """ - response = self._version.domain.twilio.request("GET", target_url) - return SamplePage(self._version, response, self._solution) - - async def get_page_async(self, target_url: str) -> SamplePage: - """ - Asynchronously retrieve a specific page of SampleInstance records from the API. - Request is executed immediately - - :param target_url: API-generated URL for the requested results page - - :returns: Page of SampleInstance - """ - response = await self._version.domain.twilio.request_async("GET", target_url) - return SamplePage(self._version, response, self._solution) - - def get(self, sid: str) -> SampleContext: - """ - Constructs a SampleContext - - :param sid: A 34 character string that uniquely identifies this resource. - """ - return SampleContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - sid=sid, - ) - - def __call__(self, sid: str) -> SampleContext: - """ - Constructs a SampleContext - - :param sid: A 34 character string that uniquely identifies this resource. - """ - return SampleContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - sid=sid, - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview/understand/assistant/task/task_actions.py b/twilio/rest/preview/understand/assistant/task/task_actions.py deleted file mode 100644 index 41366bbb96..0000000000 --- a/twilio/rest/preview/understand/assistant/task/task_actions.py +++ /dev/null @@ -1,301 +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, 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 - - -class TaskActionsInstance(InstanceResource): - - """ - :ivar account_sid: The unique ID of the Account that created this Field. - :ivar assistant_sid: The unique ID of the parent Assistant. - :ivar task_sid: The unique ID of the Task. - :ivar url: - :ivar data: - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - assistant_sid: str, - task_sid: str, - ): - super().__init__(version) - - self.account_sid: Optional[str] = payload.get("account_sid") - self.assistant_sid: Optional[str] = payload.get("assistant_sid") - self.task_sid: Optional[str] = payload.get("task_sid") - self.url: Optional[str] = payload.get("url") - self.data: Optional[Dict[str, object]] = payload.get("data") - - self._solution = { - "assistant_sid": assistant_sid, - "task_sid": task_sid, - } - self._context: Optional[TaskActionsContext] = None - - @property - def _proxy(self) -> "TaskActionsContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: TaskActionsContext for this TaskActionsInstance - """ - if self._context is None: - self._context = TaskActionsContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - ) - return self._context - - def fetch(self) -> "TaskActionsInstance": - """ - Fetch the TaskActionsInstance - - - :returns: The fetched TaskActionsInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "TaskActionsInstance": - """ - Asynchronous coroutine to fetch the TaskActionsInstance - - - :returns: The fetched TaskActionsInstance - """ - return await self._proxy.fetch_async() - - def update( - self, actions: Union[object, object] = values.unset - ) -> "TaskActionsInstance": - """ - Update the TaskActionsInstance - - :param actions: The JSON actions that instruct the Assistant how to perform this task. - - :returns: The updated TaskActionsInstance - """ - return self._proxy.update( - actions=actions, - ) - - async def update_async( - self, actions: Union[object, object] = values.unset - ) -> "TaskActionsInstance": - """ - Asynchronous coroutine to update the TaskActionsInstance - - :param actions: The JSON actions that instruct the Assistant how to perform this task. - - :returns: The updated TaskActionsInstance - """ - return await self._proxy.update_async( - actions=actions, - ) - - 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 TaskActionsContext(InstanceContext): - def __init__(self, version: Version, assistant_sid: str, task_sid: str): - """ - Initialize the TaskActionsContext - - :param version: Version that contains the resource - :param assistant_sid: The unique ID of the parent Assistant. - :param task_sid: The unique ID of the Task. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - "task_sid": task_sid, - } - self._uri = "/Assistants/{assistant_sid}/Tasks/{task_sid}/Actions".format( - **self._solution - ) - - def fetch(self) -> TaskActionsInstance: - """ - Fetch the TaskActionsInstance - - - :returns: The fetched TaskActionsInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return TaskActionsInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - ) - - async def fetch_async(self) -> TaskActionsInstance: - """ - Asynchronous coroutine to fetch the TaskActionsInstance - - - :returns: The fetched TaskActionsInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return TaskActionsInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - ) - - def update( - self, actions: Union[object, object] = values.unset - ) -> TaskActionsInstance: - """ - Update the TaskActionsInstance - - :param actions: The JSON actions that instruct the Assistant how to perform this task. - - :returns: The updated TaskActionsInstance - """ - data = values.of( - { - "Actions": serialize.object(actions), - } - ) - - payload = self._version.update( - method="POST", - uri=self._uri, - data=data, - ) - - return TaskActionsInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - ) - - async def update_async( - self, actions: Union[object, object] = values.unset - ) -> TaskActionsInstance: - """ - Asynchronous coroutine to update the TaskActionsInstance - - :param actions: The JSON actions that instruct the Assistant how to perform this task. - - :returns: The updated TaskActionsInstance - """ - data = values.of( - { - "Actions": serialize.object(actions), - } - ) - - payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, - ) - - return TaskActionsInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_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 TaskActionsList(ListResource): - def __init__(self, version: Version, assistant_sid: str, task_sid: str): - """ - Initialize the TaskActionsList - - :param version: Version that contains the resource - :param assistant_sid: The unique ID of the parent Assistant. - :param task_sid: The unique ID of the Task. - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - "task_sid": task_sid, - } - - def get(self) -> TaskActionsContext: - """ - Constructs a TaskActionsContext - - """ - return TaskActionsContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - ) - - def __call__(self) -> TaskActionsContext: - """ - Constructs a TaskActionsContext - - """ - return TaskActionsContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview/understand/assistant/task/task_statistics.py b/twilio/rest/preview/understand/assistant/task/task_statistics.py deleted file mode 100644 index 07375954c7..0000000000 --- a/twilio/rest/preview/understand/assistant/task/task_statistics.py +++ /dev/null @@ -1,221 +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, 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 TaskStatisticsInstance(InstanceResource): - - """ - :ivar account_sid: The unique ID of the Account that created this Field. - :ivar assistant_sid: The unique ID of the parent Assistant. - :ivar task_sid: The unique ID of the Task associated with this Field. - :ivar samples_count: The total number of Samples associated with this Task. - :ivar fields_count: The total number of Fields associated with this Task. - :ivar url: - """ - - def __init__( - self, - version: Version, - payload: Dict[str, Any], - assistant_sid: str, - task_sid: str, - ): - super().__init__(version) - - self.account_sid: Optional[str] = payload.get("account_sid") - self.assistant_sid: Optional[str] = payload.get("assistant_sid") - self.task_sid: Optional[str] = payload.get("task_sid") - self.samples_count: Optional[int] = deserialize.integer( - payload.get("samples_count") - ) - self.fields_count: Optional[int] = deserialize.integer( - payload.get("fields_count") - ) - self.url: Optional[str] = payload.get("url") - - self._solution = { - "assistant_sid": assistant_sid, - "task_sid": task_sid, - } - self._context: Optional[TaskStatisticsContext] = None - - @property - def _proxy(self) -> "TaskStatisticsContext": - """ - Generate an instance context for the instance, the context is capable of - performing various actions. All instance actions are proxied to the context - - :returns: TaskStatisticsContext for this TaskStatisticsInstance - """ - if self._context is None: - self._context = TaskStatisticsContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - ) - return self._context - - def fetch(self) -> "TaskStatisticsInstance": - """ - Fetch the TaskStatisticsInstance - - - :returns: The fetched TaskStatisticsInstance - """ - return self._proxy.fetch() - - async def fetch_async(self) -> "TaskStatisticsInstance": - """ - Asynchronous coroutine to fetch the TaskStatisticsInstance - - - :returns: The fetched TaskStatisticsInstance - """ - 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 TaskStatisticsContext(InstanceContext): - def __init__(self, version: Version, assistant_sid: str, task_sid: str): - """ - Initialize the TaskStatisticsContext - - :param version: Version that contains the resource - :param assistant_sid: The unique ID of the parent Assistant. - :param task_sid: The unique ID of the Task associated with this Field. - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - "task_sid": task_sid, - } - self._uri = "/Assistants/{assistant_sid}/Tasks/{task_sid}/Statistics".format( - **self._solution - ) - - def fetch(self) -> TaskStatisticsInstance: - """ - Fetch the TaskStatisticsInstance - - - :returns: The fetched TaskStatisticsInstance - """ - - payload = self._version.fetch( - method="GET", - uri=self._uri, - ) - - return TaskStatisticsInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - ) - - async def fetch_async(self) -> TaskStatisticsInstance: - """ - Asynchronous coroutine to fetch the TaskStatisticsInstance - - - :returns: The fetched TaskStatisticsInstance - """ - - payload = await self._version.fetch_async( - method="GET", - uri=self._uri, - ) - - return TaskStatisticsInstance( - self._version, - payload, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_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 TaskStatisticsList(ListResource): - def __init__(self, version: Version, assistant_sid: str, task_sid: str): - """ - Initialize the TaskStatisticsList - - :param version: Version that contains the resource - :param assistant_sid: The unique ID of the parent Assistant. - :param task_sid: The unique ID of the Task associated with this Field. - - """ - super().__init__(version) - - # Path Solution - self._solution = { - "assistant_sid": assistant_sid, - "task_sid": task_sid, - } - - def get(self) -> TaskStatisticsContext: - """ - Constructs a TaskStatisticsContext - - """ - return TaskStatisticsContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - ) - - def __call__(self) -> TaskStatisticsContext: - """ - Constructs a TaskStatisticsContext - - """ - return TaskStatisticsContext( - self._version, - assistant_sid=self._solution["assistant_sid"], - task_sid=self._solution["task_sid"], - ) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/preview/wireless/__init__.py b/twilio/rest/preview/wireless/__init__.py index 24f2ea0f0d..85ed4fb54d 100644 --- a/twilio/rest/preview/wireless/__init__.py +++ b/twilio/rest/preview/wireless/__init__.py @@ -21,6 +21,7 @@ class Wireless(Version): + def __init__(self, domain: Domain): """ Initialize the Wireless version of Preview diff --git a/twilio/rest/preview/wireless/command.py b/twilio/rest/preview/wireless/command.py index 4f3e4603af..8e715e09ef 100644 --- a/twilio/rest/preview/wireless/command.py +++ b/twilio/rest/preview/wireless/command.py @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class CommandInstance(InstanceResource): - """ :ivar sid: :ivar account_sid: @@ -109,6 +107,7 @@ def __repr__(self) -> str: class CommandContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the CommandContext @@ -132,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, @@ -151,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( @@ -173,6 +176,7 @@ def __repr__(self) -> str: class CommandPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> CommandInstance: """ Build an instance of CommandInstance @@ -191,6 +195,7 @@ def __repr__(self) -> str: class CommandList(ListResource): + def __init__(self, version: Version): """ Initialize the CommandList @@ -225,6 +230,7 @@ def create( :returns: The created CommandInstance """ + data = values.of( { "Command": command, @@ -236,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) @@ -268,6 +277,7 @@ async def create_async( :returns: The created CommandInstance """ + data = values.of( { "Command": command, @@ -279,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) @@ -479,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( @@ -518,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 04b16f5b38..95e45f1ef2 100644 --- a/twilio/rest/preview/wireless/rate_plan.py +++ b/twilio/rest/preview/wireless/rate_plan.py @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class RatePlanInstance(InstanceResource): - """ :ivar sid: :ivar unique_name: @@ -173,6 +171,7 @@ def __repr__(self) -> str: class RatePlanContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the RatePlanContext @@ -195,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: """ @@ -207,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: @@ -220,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, @@ -239,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( @@ -263,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"]) @@ -291,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"]) @@ -317,6 +330,7 @@ def __repr__(self) -> str: class RatePlanPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> RatePlanInstance: """ Build an instance of RatePlanInstance @@ -335,6 +349,7 @@ def __repr__(self) -> str: class RatePlanList(ListResource): + def __init__(self, version: Version): """ Initialize the RatePlanList @@ -375,27 +390,33 @@ def create( :returns: The created RatePlanInstance """ + data = values.of( { "UniqueName": unique_name, "FriendlyName": friendly_name, - "DataEnabled": data_enabled, + "DataEnabled": serialize.boolean_to_string(data_enabled), "DataLimit": data_limit, "DataMetering": data_metering, - "MessagingEnabled": messaging_enabled, - "VoiceEnabled": voice_enabled, - "CommandsEnabled": commands_enabled, - "NationalRoamingEnabled": national_roaming_enabled, + "MessagingEnabled": serialize.boolean_to_string(messaging_enabled), + "VoiceEnabled": serialize.boolean_to_string(voice_enabled), + "CommandsEnabled": serialize.boolean_to_string(commands_enabled), + "NationalRoamingEnabled": serialize.boolean_to_string( + national_roaming_enabled + ), "InternationalRoaming": serialize.map( international_roaming, 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 RatePlanInstance(self._version, payload) @@ -429,27 +450,33 @@ async def create_async( :returns: The created RatePlanInstance """ + data = values.of( { "UniqueName": unique_name, "FriendlyName": friendly_name, - "DataEnabled": data_enabled, + "DataEnabled": serialize.boolean_to_string(data_enabled), "DataLimit": data_limit, "DataMetering": data_metering, - "MessagingEnabled": messaging_enabled, - "VoiceEnabled": voice_enabled, - "CommandsEnabled": commands_enabled, - "NationalRoamingEnabled": national_roaming_enabled, + "MessagingEnabled": serialize.boolean_to_string(messaging_enabled), + "VoiceEnabled": serialize.boolean_to_string(voice_enabled), + "CommandsEnabled": serialize.boolean_to_string(commands_enabled), + "NationalRoamingEnabled": serialize.boolean_to_string( + national_roaming_enabled + ), "InternationalRoaming": serialize.map( international_roaming, 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 RatePlanInstance(self._version, payload) @@ -581,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( @@ -608,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 3a5dd7e770..07a9e74da0 100644 --- a/twilio/rest/preview/wireless/sim/__init__.py +++ b/twilio/rest/preview/wireless/sim/__init__.py @@ -12,7 +12,6 @@ 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 @@ -25,7 +24,6 @@ class SimInstance(InstanceResource): - """ :ivar sid: :ivar unique_name: @@ -261,6 +259,7 @@ def __repr__(self) -> str: class SimContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the SimContext @@ -286,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, @@ -305,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( @@ -357,6 +360,7 @@ def update( :returns: The updated SimInstance """ + data = values.of( { "UniqueName": unique_name, @@ -377,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"]) @@ -427,6 +434,7 @@ async def update_async( :returns: The updated SimInstance """ + data = values.of( { "UniqueName": unique_name, @@ -447,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"]) @@ -479,6 +490,7 @@ def __repr__(self) -> str: class SimPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> SimInstance: """ Build an instance of SimInstance @@ -497,6 +509,7 @@ def __repr__(self) -> str: class SimList(ListResource): + def __init__(self, version: Version): """ Initialize the SimList @@ -714,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( @@ -756,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 de1ca5a035..aff3731b51 100644 --- a/twilio/rest/preview/wireless/sim/usage.py +++ b/twilio/rest/preview/wireless/sim/usage.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, Optional, Union from twilio.base import values from twilio.base.instance_context import InstanceContext @@ -22,7 +21,6 @@ class UsageInstance(InstanceResource): - """ :ivar sim_sid: :ivar sim_unique_name: @@ -115,6 +113,7 @@ def __repr__(self) -> str: class UsageContext(InstanceContext): + def __init__(self, version: Version, sim_sid: str): """ Initialize the UsageContext @@ -151,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, @@ -180,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( @@ -201,6 +210,7 @@ def __repr__(self) -> str: class UsageList(ListResource): + def __init__(self, version: Version, sim_sid: str): """ Initialize the UsageList diff --git a/twilio/rest/autopilot/AutopilotBase.py b/twilio/rest/preview_iam/PreviewIamBase.py similarity index 75% rename from twilio/rest/autopilot/AutopilotBase.py rename to twilio/rest/preview_iam/PreviewIamBase.py index 3b1a7f7112..22fcbe70b1 100644 --- a/twilio/rest/autopilot/AutopilotBase.py +++ b/twilio/rest/preview_iam/PreviewIamBase.py @@ -13,23 +13,24 @@ from twilio.base.domain import Domain from twilio.rest import Client -from twilio.rest.autopilot.v1 import V1 +from twilio.rest.preview_iam.v1 import V1 -class AutopilotBase(Domain): +class PreviewIamBase(Domain): + def __init__(self, twilio: Client): """ - Initialize the Autopilot Domain + Initialize the PreviewIam Domain - :returns: Domain for Autopilot + :returns: Domain for PreviewIam """ - super().__init__(twilio, "https://autopilot.twilio.com") + super().__init__(twilio, "https://preview-iam.twilio.com") self._v1: Optional[V1] = None @property def v1(self) -> V1: """ - :returns: Versions v1 of Autopilot + :returns: Versions v1 of PreviewIam """ if self._v1 is None: self._v1 = V1(self) @@ -40,4 +41,4 @@ def __repr__(self) -> str: Provide a friendly representation :returns: Machine friendly representation """ - return "" + 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/autopilot/v1/__init__.py b/twilio/rest/preview_iam/v1/__init__.py similarity index 50% rename from twilio/rest/autopilot/v1/__init__.py rename to twilio/rest/preview_iam/v1/__init__.py index fd23e47670..2243277793 100644 --- a/twilio/rest/autopilot/v1/__init__.py +++ b/twilio/rest/preview_iam/v1/__init__.py @@ -4,8 +4,8 @@ | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - Twilio - Autopilot - This is the public Twilio REST API. + 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 @@ -15,36 +15,37 @@ from typing import Optional from twilio.base.version import Version from twilio.base.domain import Domain -from twilio.rest.autopilot.v1.assistant import AssistantList -from twilio.rest.autopilot.v1.restore_assistant import RestoreAssistantList +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 Autopilot + Initialize the V1 version of PreviewIam - :param domain: The Twilio.autopilot domain + :param domain: The Twilio.preview_iam domain """ super().__init__(domain, "v1") - self._assistants: Optional[AssistantList] = None - self._restore_assistant: Optional[RestoreAssistantList] = None + self._authorize: Optional[AuthorizeList] = None + self._token: Optional[TokenList] = None @property - def assistants(self) -> AssistantList: - if self._assistants is None: - self._assistants = AssistantList(self) - return self._assistants + def authorize(self) -> AuthorizeList: + if self._authorize is None: + self._authorize = AuthorizeList(self) + return self._authorize @property - def restore_assistant(self) -> RestoreAssistantList: - if self._restore_assistant is None: - self._restore_assistant = RestoreAssistantList(self) - return self._restore_assistant + 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 "" + 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/understand/__init__.py b/twilio/rest/preview_iam/versionless/__init__.py similarity index 52% rename from twilio/rest/preview/understand/__init__.py rename to twilio/rest/preview_iam/versionless/__init__.py index da659fd3a6..7d6d210f14 100644 --- a/twilio/rest/preview/understand/__init__.py +++ b/twilio/rest/preview_iam/versionless/__init__.py @@ -4,8 +4,8 @@ | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - Twilio - Preview - This is the public Twilio REST API. + 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 @@ -15,28 +15,29 @@ from typing import Optional from twilio.base.version import Version from twilio.base.domain import Domain -from twilio.rest.preview.understand.assistant import AssistantList +from twilio.rest.preview_iam.versionless.organization import OrganizationList -class Understand(Version): +class Versionless(Version): + def __init__(self, domain: Domain): """ - Initialize the Understand version of Preview + Initialize the Versionless version of PreviewIam - :param domain: The Twilio.preview domain + :param domain: The Twilio.preview_iam domain """ - super().__init__(domain, "understand") - self._assistants: Optional[AssistantList] = None + super().__init__(domain, "Organizations") + self._organization: Optional[OrganizationList] = None @property - def assistants(self) -> AssistantList: - if self._assistants is None: - self._assistants = AssistantList(self) - return self._assistants + 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 "" + 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/pricing/PricingBase.py b/twilio/rest/pricing/PricingBase.py index 35028ee350..cf624e1867 100644 --- a/twilio/rest/pricing/PricingBase.py +++ b/twilio/rest/pricing/PricingBase.py @@ -18,6 +18,7 @@ class PricingBase(Domain): + def __init__(self, twilio: Client): """ Initialize the Pricing Domain diff --git a/twilio/rest/pricing/v1/__init__.py b/twilio/rest/pricing/v1/__init__.py index 2227d163d4..ba8b65885d 100644 --- a/twilio/rest/pricing/v1/__init__.py +++ b/twilio/rest/pricing/v1/__init__.py @@ -21,6 +21,7 @@ class V1(Version): + def __init__(self, domain: Domain): """ Initialize the V1 version of Pricing diff --git a/twilio/rest/pricing/v1/messaging/__init__.py b/twilio/rest/pricing/v1/messaging/__init__.py index 32230c7135..df5c148b81 100644 --- a/twilio/rest/pricing/v1/messaging/__init__.py +++ b/twilio/rest/pricing/v1/messaging/__init__.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Optional @@ -23,6 +22,7 @@ class MessagingList(ListResource): + def __init__(self, version: Version): """ Initialize the MessagingList diff --git a/twilio/rest/pricing/v1/messaging/country.py b/twilio/rest/pricing/v1/messaging/country.py index fba539fc68..49360cd85c 100644 --- a/twilio/rest/pricing/v1/messaging/country.py +++ b/twilio/rest/pricing/v1/messaging/country.py @@ -12,7 +12,6 @@ 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 @@ -23,7 +22,6 @@ class CountryInstance(InstanceResource): - """ :ivar country: The name of the country. :ivar iso_country: The [ISO country code](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). @@ -99,6 +97,7 @@ def __repr__(self) -> str: class CountryContext(InstanceContext): + def __init__(self, version: Version, iso_country: str): """ Initialize the CountryContext @@ -122,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, @@ -141,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( @@ -163,6 +166,7 @@ def __repr__(self) -> str: class CountryPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> CountryInstance: """ Build an instance of CountryInstance @@ -181,6 +185,7 @@ def __repr__(self) -> str: class CountryList(ListResource): + def __init__(self, version: Version): """ Initialize the CountryList @@ -319,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( @@ -346,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/__init__.py b/twilio/rest/pricing/v1/phone_number/__init__.py index b3cfbe50e4..429ce9b14c 100644 --- a/twilio/rest/pricing/v1/phone_number/__init__.py +++ b/twilio/rest/pricing/v1/phone_number/__init__.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Optional @@ -23,6 +22,7 @@ class PhoneNumberList(ListResource): + def __init__(self, version: Version): """ Initialize the PhoneNumberList diff --git a/twilio/rest/pricing/v1/phone_number/country.py b/twilio/rest/pricing/v1/phone_number/country.py index 30a0eeb475..2d11cd1c3e 100644 --- a/twilio/rest/pricing/v1/phone_number/country.py +++ b/twilio/rest/pricing/v1/phone_number/country.py @@ -12,7 +12,6 @@ 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 @@ -23,7 +22,6 @@ class CountryInstance(InstanceResource): - """ :ivar country: The name of the country. :ivar iso_country: The [ISO country code](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). @@ -97,6 +95,7 @@ def __repr__(self) -> str: class CountryContext(InstanceContext): + def __init__(self, version: Version, iso_country: str): """ Initialize the CountryContext @@ -120,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, @@ -139,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( @@ -161,6 +164,7 @@ def __repr__(self) -> str: class CountryPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> CountryInstance: """ Build an instance of CountryInstance @@ -179,6 +183,7 @@ def __repr__(self) -> str: class CountryList(ListResource): + def __init__(self, version: Version): """ Initialize the CountryList @@ -317,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( @@ -344,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/__init__.py b/twilio/rest/pricing/v1/voice/__init__.py index 4d91f382c9..a801a30089 100644 --- a/twilio/rest/pricing/v1/voice/__init__.py +++ b/twilio/rest/pricing/v1/voice/__init__.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Optional @@ -24,6 +23,7 @@ class VoiceList(ListResource): + def __init__(self, version: Version): """ Initialize the VoiceList diff --git a/twilio/rest/pricing/v1/voice/country.py b/twilio/rest/pricing/v1/voice/country.py index c65df83f41..7fb0da883a 100644 --- a/twilio/rest/pricing/v1/voice/country.py +++ b/twilio/rest/pricing/v1/voice/country.py @@ -12,7 +12,6 @@ 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 @@ -23,7 +22,6 @@ class CountryInstance(InstanceResource): - """ :ivar country: The name of the country. :ivar iso_country: The [ISO country code](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). @@ -101,6 +99,7 @@ def __repr__(self) -> str: class CountryContext(InstanceContext): + def __init__(self, version: Version, iso_country: str): """ Initialize the CountryContext @@ -124,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, @@ -143,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( @@ -165,6 +168,7 @@ def __repr__(self) -> str: class CountryPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> CountryInstance: """ Build an instance of CountryInstance @@ -183,6 +187,7 @@ def __repr__(self) -> str: class CountryList(ListResource): + def __init__(self, version: Version): """ Initialize the CountryList @@ -321,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( @@ -348,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 dfdf4b63f8..5bff8cd5d6 100644 --- a/twilio/rest/pricing/v1/voice/number.py +++ b/twilio/rest/pricing/v1/voice/number.py @@ -12,8 +12,8 @@ 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 @@ -21,7 +21,6 @@ class NumberInstance(InstanceResource): - """ :ivar number: The phone number. :ivar country: The name of the country. @@ -94,6 +93,7 @@ def __repr__(self) -> str: class NumberContext(InstanceContext): + def __init__(self, version: Version, number: str): """ Initialize the NumberContext @@ -117,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, @@ -136,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( @@ -158,6 +162,7 @@ def __repr__(self) -> str: class NumberList(ListResource): + def __init__(self, version: Version): """ Initialize the NumberList diff --git a/twilio/rest/pricing/v2/__init__.py b/twilio/rest/pricing/v2/__init__.py index f034595cb2..d0fd67f737 100644 --- a/twilio/rest/pricing/v2/__init__.py +++ b/twilio/rest/pricing/v2/__init__.py @@ -21,6 +21,7 @@ class V2(Version): + def __init__(self, domain: Domain): """ Initialize the V2 version of Pricing diff --git a/twilio/rest/pricing/v2/country.py b/twilio/rest/pricing/v2/country.py index 6842359b88..30672235a8 100644 --- a/twilio/rest/pricing/v2/country.py +++ b/twilio/rest/pricing/v2/country.py @@ -12,7 +12,6 @@ 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 @@ -23,7 +22,6 @@ class CountryInstance(InstanceResource): - """ :ivar country: The name of the country. :ivar iso_country: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). @@ -101,6 +99,7 @@ def __repr__(self) -> str: class CountryContext(InstanceContext): + def __init__(self, version: Version, iso_country: str): """ Initialize the CountryContext @@ -124,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, @@ -143,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( @@ -165,6 +168,7 @@ def __repr__(self) -> str: class CountryPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> CountryInstance: """ Build an instance of CountryInstance @@ -183,6 +187,7 @@ def __repr__(self) -> str: class CountryList(ListResource): + def __init__(self, version: Version): """ Initialize the CountryList @@ -321,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( @@ -348,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 39d8eb4783..1dead39347 100644 --- a/twilio/rest/pricing/v2/number.py +++ b/twilio/rest/pricing/v2/number.py @@ -12,7 +12,6 @@ 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 @@ -22,7 +21,6 @@ class NumberInstance(InstanceResource): - """ :ivar destination_number: The destination phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number. :ivar origination_number: The origination phone number in [[E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number. @@ -114,6 +112,7 @@ def __repr__(self) -> str: class NumberContext(InstanceContext): + def __init__(self, version: Version, destination_number: str): """ Initialize the NumberContext @@ -146,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, @@ -171,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( @@ -192,6 +201,7 @@ def __repr__(self) -> str: class NumberList(ListResource): + def __init__(self, version: Version): """ Initialize the NumberList diff --git a/twilio/rest/pricing/v2/voice/__init__.py b/twilio/rest/pricing/v2/voice/__init__.py index 6539469636..1ebbcbb644 100644 --- a/twilio/rest/pricing/v2/voice/__init__.py +++ b/twilio/rest/pricing/v2/voice/__init__.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Optional @@ -24,6 +23,7 @@ class VoiceList(ListResource): + def __init__(self, version: Version): """ Initialize the VoiceList diff --git a/twilio/rest/pricing/v2/voice/country.py b/twilio/rest/pricing/v2/voice/country.py index a06ed0a762..997f368462 100644 --- a/twilio/rest/pricing/v2/voice/country.py +++ b/twilio/rest/pricing/v2/voice/country.py @@ -12,7 +12,6 @@ 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 @@ -23,7 +22,6 @@ class CountryInstance(InstanceResource): - """ :ivar country: The name of the country. :ivar iso_country: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). @@ -101,6 +99,7 @@ def __repr__(self) -> str: class CountryContext(InstanceContext): + def __init__(self, version: Version, iso_country: str): """ Initialize the CountryContext @@ -124,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, @@ -143,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( @@ -165,6 +168,7 @@ def __repr__(self) -> str: class CountryPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> CountryInstance: """ Build an instance of CountryInstance @@ -183,6 +187,7 @@ def __repr__(self) -> str: class CountryList(ListResource): + def __init__(self, version: Version): """ Initialize the CountryList @@ -321,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( @@ -348,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 6d4f1bddb3..97a3a526ff 100644 --- a/twilio/rest/pricing/v2/voice/number.py +++ b/twilio/rest/pricing/v2/voice/number.py @@ -12,7 +12,6 @@ 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 @@ -22,7 +21,6 @@ class NumberInstance(InstanceResource): - """ :ivar destination_number: The destination phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number. :ivar origination_number: The origination phone number in [[E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number. @@ -112,6 +110,7 @@ def __repr__(self) -> str: class NumberContext(InstanceContext): + def __init__(self, version: Version, destination_number: str): """ Initialize the NumberContext @@ -144,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, @@ -169,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( @@ -190,6 +199,7 @@ def __repr__(self) -> str: class NumberList(ListResource): + def __init__(self, version: Version): """ Initialize the NumberList diff --git a/twilio/rest/proxy/ProxyBase.py b/twilio/rest/proxy/ProxyBase.py index b4d4d0e84d..da1baec178 100644 --- a/twilio/rest/proxy/ProxyBase.py +++ b/twilio/rest/proxy/ProxyBase.py @@ -17,6 +17,7 @@ class ProxyBase(Domain): + def __init__(self, twilio: Client): """ Initialize the Proxy Domain diff --git a/twilio/rest/proxy/v1/__init__.py b/twilio/rest/proxy/v1/__init__.py index 87a58d3ff2..83737dc0fb 100644 --- a/twilio/rest/proxy/v1/__init__.py +++ b/twilio/rest/proxy/v1/__init__.py @@ -19,6 +19,7 @@ class V1(Version): + def __init__(self, domain: Domain): """ Initialize the V1 version of Proxy diff --git a/twilio/rest/proxy/v1/service/__init__.py b/twilio/rest/proxy/v1/service/__init__.py index a86444ebe4..8e35536547 100644 --- a/twilio/rest/proxy/v1/service/__init__.py +++ b/twilio/rest/proxy/v1/service/__init__.py @@ -12,7 +12,6 @@ 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 @@ -23,10 +22,10 @@ from twilio.base.page import Page from twilio.rest.proxy.v1.service.phone_number import PhoneNumberList from twilio.rest.proxy.v1.service.session import SessionList -from twilio.rest.proxy.v1.service.short_code import ShortCodeList class ServiceInstance(InstanceResource): + class GeoMatchLevel(object): AREA_CODE = "area-code" OVERLAY = "overlay" @@ -47,7 +46,7 @@ class NumberSelectionBehavior(object): :ivar number_selection_behavior: :ivar geo_match_level: :ivar intercept_callback_url: The URL we call on each interaction. If we receive a 403 status, we block the interaction; otherwise the interaction continues. - :ivar out_of_session_callback_url: The URL we call when an inbound call or SMS action occurs on a closed or non-existent Session. If your server (or a Twilio [function](https://www.twilio.com/functions)) responds with valid [TwiML](https://www.twilio.com/docs/voice/twiml), we will process it. This means it is possible, for example, to play a message for a call, send an automated text message response, or redirect a call to another Phone Number. See [Out-of-Session Callback Response Guide](https://www.twilio.com/docs/proxy/out-session-callback-response-guide) for more information. + :ivar out_of_session_callback_url: The URL we call when an inbound call or SMS action occurs on a closed or non-existent Session. If your server (or a Twilio [function](https://www.twilio.com/en-us/serverless/functions)) responds with valid [TwiML](https://www.twilio.com/docs/voice/twiml), we will process it. This means it is possible, for example, to play a message for a call, send an automated text message response, or redirect a call to another Phone Number. See [Out-of-Session Callback Response Guide](https://www.twilio.com/docs/proxy/out-session-callback-response-guide) for more information. :ivar date_created: The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time in GMT when the resource was created. :ivar date_updated: The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time in GMT when the resource was last updated. :ivar url: The absolute URL of the Service resource. @@ -166,7 +165,7 @@ def update( :param geo_match_level: :param number_selection_behavior: :param intercept_callback_url: The URL we call on each interaction. If we receive a 403 status, we block the interaction; otherwise the interaction continues. - :param out_of_session_callback_url: The URL we should call when an inbound call or SMS action occurs on a closed or non-existent Session. If your server (or a Twilio [function](https://www.twilio.com/functions)) responds with valid [TwiML](https://www.twilio.com/docs/voice/twiml), we will process it. This means it is possible, for example, to play a message for a call, send an automated text message response, or redirect a call to another Phone Number. See [Out-of-Session Callback Response Guide](https://www.twilio.com/docs/proxy/out-session-callback-response-guide) for more information. + :param out_of_session_callback_url: The URL we should call when an inbound call or SMS action occurs on a closed or non-existent Session. If your server (or a Twilio [function](https://www.twilio.com/en-us/serverless/functions)) responds with valid [TwiML](https://www.twilio.com/docs/voice/twiml), we will process it. This means it is possible, for example, to play a message for a call, send an automated text message response, or redirect a call to another Phone Number. See [Out-of-Session Callback Response Guide](https://www.twilio.com/docs/proxy/out-session-callback-response-guide) for more information. :param chat_instance_sid: The SID of the Chat Service Instance managed by Proxy Service. The Chat Service enables Proxy to forward SMS and channel messages to this chat instance. This is a one-to-one relationship. :returns: The updated ServiceInstance @@ -204,7 +203,7 @@ async def update_async( :param geo_match_level: :param number_selection_behavior: :param intercept_callback_url: The URL we call on each interaction. If we receive a 403 status, we block the interaction; otherwise the interaction continues. - :param out_of_session_callback_url: The URL we should call when an inbound call or SMS action occurs on a closed or non-existent Session. If your server (or a Twilio [function](https://www.twilio.com/functions)) responds with valid [TwiML](https://www.twilio.com/docs/voice/twiml), we will process it. This means it is possible, for example, to play a message for a call, send an automated text message response, or redirect a call to another Phone Number. See [Out-of-Session Callback Response Guide](https://www.twilio.com/docs/proxy/out-session-callback-response-guide) for more information. + :param out_of_session_callback_url: The URL we should call when an inbound call or SMS action occurs on a closed or non-existent Session. If your server (or a Twilio [function](https://www.twilio.com/en-us/serverless/functions)) responds with valid [TwiML](https://www.twilio.com/docs/voice/twiml), we will process it. This means it is possible, for example, to play a message for a call, send an automated text message response, or redirect a call to another Phone Number. See [Out-of-Session Callback Response Guide](https://www.twilio.com/docs/proxy/out-session-callback-response-guide) for more information. :param chat_instance_sid: The SID of the Chat Service Instance managed by Proxy Service. The Chat Service enables Proxy to forward SMS and channel messages to this chat instance. This is a one-to-one relationship. :returns: The updated ServiceInstance @@ -234,13 +233,6 @@ def sessions(self) -> SessionList: """ return self._proxy.sessions - @property - def short_codes(self) -> ShortCodeList: - """ - Access the short_codes - """ - return self._proxy.short_codes - def __repr__(self) -> str: """ Provide a friendly representation @@ -252,6 +244,7 @@ def __repr__(self) -> str: class ServiceContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the ServiceContext @@ -269,7 +262,6 @@ def __init__(self, version: Version, sid: str): self._phone_numbers: Optional[PhoneNumberList] = None self._sessions: Optional[SessionList] = None - self._short_codes: Optional[ShortCodeList] = None def delete(self) -> bool: """ @@ -278,10 +270,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: """ @@ -290,9 +282,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: @@ -303,10 +297,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, @@ -322,9 +317,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( @@ -355,11 +353,12 @@ def update( :param geo_match_level: :param number_selection_behavior: :param intercept_callback_url: The URL we call on each interaction. If we receive a 403 status, we block the interaction; otherwise the interaction continues. - :param out_of_session_callback_url: The URL we should call when an inbound call or SMS action occurs on a closed or non-existent Session. If your server (or a Twilio [function](https://www.twilio.com/functions)) responds with valid [TwiML](https://www.twilio.com/docs/voice/twiml), we will process it. This means it is possible, for example, to play a message for a call, send an automated text message response, or redirect a call to another Phone Number. See [Out-of-Session Callback Response Guide](https://www.twilio.com/docs/proxy/out-session-callback-response-guide) for more information. + :param out_of_session_callback_url: The URL we should call when an inbound call or SMS action occurs on a closed or non-existent Session. If your server (or a Twilio [function](https://www.twilio.com/en-us/serverless/functions)) responds with valid [TwiML](https://www.twilio.com/docs/voice/twiml), we will process it. This means it is possible, for example, to play a message for a call, send an automated text message response, or redirect a call to another Phone Number. See [Out-of-Session Callback Response Guide](https://www.twilio.com/docs/proxy/out-session-callback-response-guide) for more information. :param chat_instance_sid: The SID of the Chat Service Instance managed by Proxy Service. The Chat Service enables Proxy to forward SMS and channel messages to this chat instance. This is a one-to-one relationship. :returns: The updated ServiceInstance """ + data = values.of( { "UniqueName": unique_name, @@ -372,11 +371,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"]) @@ -403,11 +405,12 @@ async def update_async( :param geo_match_level: :param number_selection_behavior: :param intercept_callback_url: The URL we call on each interaction. If we receive a 403 status, we block the interaction; otherwise the interaction continues. - :param out_of_session_callback_url: The URL we should call when an inbound call or SMS action occurs on a closed or non-existent Session. If your server (or a Twilio [function](https://www.twilio.com/functions)) responds with valid [TwiML](https://www.twilio.com/docs/voice/twiml), we will process it. This means it is possible, for example, to play a message for a call, send an automated text message response, or redirect a call to another Phone Number. See [Out-of-Session Callback Response Guide](https://www.twilio.com/docs/proxy/out-session-callback-response-guide) for more information. + :param out_of_session_callback_url: The URL we should call when an inbound call or SMS action occurs on a closed or non-existent Session. If your server (or a Twilio [function](https://www.twilio.com/en-us/serverless/functions)) responds with valid [TwiML](https://www.twilio.com/docs/voice/twiml), we will process it. This means it is possible, for example, to play a message for a call, send an automated text message response, or redirect a call to another Phone Number. See [Out-of-Session Callback Response Guide](https://www.twilio.com/docs/proxy/out-session-callback-response-guide) for more information. :param chat_instance_sid: The SID of the Chat Service Instance managed by Proxy Service. The Chat Service enables Proxy to forward SMS and channel messages to this chat instance. This is a one-to-one relationship. :returns: The updated ServiceInstance """ + data = values.of( { "UniqueName": unique_name, @@ -420,11 +423,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"]) @@ -453,18 +459,6 @@ def sessions(self) -> SessionList: ) return self._sessions - @property - def short_codes(self) -> ShortCodeList: - """ - Access the short_codes - """ - if self._short_codes is None: - self._short_codes = ShortCodeList( - self._version, - self._solution["sid"], - ) - return self._short_codes - def __repr__(self) -> str: """ Provide a friendly representation @@ -476,6 +470,7 @@ def __repr__(self) -> str: class ServicePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ServiceInstance: """ Build an instance of ServiceInstance @@ -494,6 +489,7 @@ def __repr__(self) -> str: class ServiceList(ListResource): + def __init__(self, version: Version): """ Initialize the ServiceList @@ -527,11 +523,12 @@ def create( :param geo_match_level: :param number_selection_behavior: :param intercept_callback_url: The URL we call on each interaction. If we receive a 403 status, we block the interaction; otherwise the interaction continues. - :param out_of_session_callback_url: The URL we should call when an inbound call or SMS action occurs on a closed or non-existent Session. If your server (or a Twilio [function](https://www.twilio.com/functions)) responds with valid [TwiML](https://www.twilio.com/docs/voice/twiml), we will process it. This means it is possible, for example, to play a message for a call, send an automated text message response, or redirect a call to another Phone Number. See [Out-of-Session Callback Response Guide](https://www.twilio.com/docs/proxy/out-session-callback-response-guide) for more information. + :param out_of_session_callback_url: The URL we should call when an inbound call or SMS action occurs on a closed or non-existent Session. If your server (or a Twilio [function](https://www.twilio.com/en-us/serverless/functions)) responds with valid [TwiML](https://www.twilio.com/docs/voice/twiml), we will process it. This means it is possible, for example, to play a message for a call, send an automated text message response, or redirect a call to another Phone Number. See [Out-of-Session Callback Response Guide](https://www.twilio.com/docs/proxy/out-session-callback-response-guide) for more information. :param chat_instance_sid: The SID of the Chat Service Instance managed by Proxy Service. The Chat Service enables Proxy to forward SMS and channel messages to this chat instance. This is a one-to-one relationship. :returns: The created ServiceInstance """ + data = values.of( { "UniqueName": unique_name, @@ -544,11 +541,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) @@ -575,11 +575,12 @@ async def create_async( :param geo_match_level: :param number_selection_behavior: :param intercept_callback_url: The URL we call on each interaction. If we receive a 403 status, we block the interaction; otherwise the interaction continues. - :param out_of_session_callback_url: The URL we should call when an inbound call or SMS action occurs on a closed or non-existent Session. If your server (or a Twilio [function](https://www.twilio.com/functions)) responds with valid [TwiML](https://www.twilio.com/docs/voice/twiml), we will process it. This means it is possible, for example, to play a message for a call, send an automated text message response, or redirect a call to another Phone Number. See [Out-of-Session Callback Response Guide](https://www.twilio.com/docs/proxy/out-session-callback-response-guide) for more information. + :param out_of_session_callback_url: The URL we should call when an inbound call or SMS action occurs on a closed or non-existent Session. If your server (or a Twilio [function](https://www.twilio.com/en-us/serverless/functions)) responds with valid [TwiML](https://www.twilio.com/docs/voice/twiml), we will process it. This means it is possible, for example, to play a message for a call, send an automated text message response, or redirect a call to another Phone Number. See [Out-of-Session Callback Response Guide](https://www.twilio.com/docs/proxy/out-session-callback-response-guide) for more information. :param chat_instance_sid: The SID of the Chat Service Instance managed by Proxy Service. The Chat Service enables Proxy to forward SMS and channel messages to this chat instance. This is a one-to-one relationship. :returns: The created ServiceInstance """ + data = values.of( { "UniqueName": unique_name, @@ -592,11 +593,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) @@ -728,7 +732,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-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( @@ -755,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 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 fc8c514f13..3c8517cedd 100644 --- a/twilio/rest/proxy/v1/service/phone_number.py +++ b/twilio/rest/proxy/v1/service/phone_number.py @@ -12,10 +12,9 @@ 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 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 @@ -24,7 +23,6 @@ class PhoneNumberInstance(InstanceResource): - """ :ivar sid: The unique string that we created to identify the PhoneNumber resource. :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the PhoneNumber resource. @@ -163,6 +161,7 @@ def __repr__(self) -> str: class PhoneNumberContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, sid: str): """ Initialize the PhoneNumberContext @@ -189,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: """ @@ -201,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: @@ -214,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, @@ -234,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( @@ -256,16 +261,20 @@ def update( :returns: The updated PhoneNumberInstance """ + data = values.of( { - "IsReserved": is_reserved, + "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( @@ -285,16 +294,20 @@ async def update_async( :returns: The updated PhoneNumberInstance """ + data = values.of( { - "IsReserved": is_reserved, + "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( @@ -315,6 +328,7 @@ def __repr__(self) -> str: class PhoneNumberPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> PhoneNumberInstance: """ Build an instance of PhoneNumberInstance @@ -335,6 +349,7 @@ def __repr__(self) -> str: class PhoneNumberList(ListResource): + def __init__(self, version: Version, service_sid: str): """ Initialize the PhoneNumberList @@ -366,18 +381,22 @@ def create( :returns: The created PhoneNumberInstance """ + data = values.of( { "Sid": sid, "PhoneNumber": phone_number, - "IsReserved": is_reserved, + "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( @@ -399,18 +418,22 @@ async def create_async( :returns: The created PhoneNumberInstance """ + data = values.of( { "Sid": sid, "PhoneNumber": phone_number, - "IsReserved": is_reserved, + "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( @@ -544,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( @@ -571,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 7ce76fcab5..839db075c3 100644 --- a/twilio/rest/proxy/v1/service/session/__init__.py +++ b/twilio/rest/proxy/v1/service/session/__init__.py @@ -12,7 +12,6 @@ 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 @@ -26,6 +25,7 @@ class SessionInstance(InstanceResource): + class Mode(object): MESSAGE_ONLY = "message-only" VOICE_ONLY = "voice-only" @@ -220,6 +220,7 @@ def __repr__(self) -> str: class SessionContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, sid: str): """ Initialize the SessionContext @@ -247,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: """ @@ -259,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: @@ -272,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, @@ -292,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( @@ -319,6 +326,7 @@ def update( :returns: The updated SessionInstance """ + data = values.of( { "DateExpiry": serialize.iso8601_datetime(date_expiry), @@ -326,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( @@ -355,6 +366,7 @@ async def update_async( :returns: The updated SessionInstance """ + data = values.of( { "DateExpiry": serialize.iso8601_datetime(date_expiry), @@ -362,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( @@ -413,6 +428,7 @@ def __repr__(self) -> str: class SessionPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> SessionInstance: """ Build an instance of SessionInstance @@ -433,6 +449,7 @@ def __repr__(self) -> str: class SessionList(ListResource): + def __init__(self, version: Version, service_sid: str): """ Initialize the SessionList @@ -470,6 +487,7 @@ def create( :returns: The created SessionInstance """ + data = values.of( { "UniqueName": unique_name, @@ -482,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( @@ -514,6 +535,7 @@ async def create_async( :returns: The created SessionInstance """ + data = values.of( { "UniqueName": unique_name, @@ -526,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( @@ -664,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( @@ -691,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 145da3a703..7eeccda5bc 100644 --- a/twilio/rest/proxy/v1/service/session/interaction.py +++ b/twilio/rest/proxy/v1/service/session/interaction.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class InteractionInstance(InstanceResource): + class ResourceStatus(object): ACCEPTED = "accepted" ANSWERED = "answered" @@ -60,7 +60,7 @@ class Type(object): :ivar data: A JSON string that includes the message body of message interactions (e.g. `{\"body\": \"hello\"}`) or the call duration (when available) of a call (e.g. `{\"duration\": \"5\"}`). :ivar type: :ivar inbound_participant_sid: The SID of the inbound [Participant](https://www.twilio.com/docs/proxy/api/participant) resource. - :ivar inbound_resource_sid: The SID of the inbound resource; either the [Call](https://www.twilio.com/docs/voice/api/call-resource) or [Message](https://www.twilio.com/docs/sms/api/message. + :ivar inbound_resource_sid: The SID of the inbound resource; either the [Call](https://www.twilio.com/docs/voice/api/call-resource) or [Message](https://www.twilio.com/docs/sms/api/message-resource). :ivar inbound_resource_status: :ivar inbound_resource_type: The inbound resource type. Can be [Call](https://www.twilio.com/docs/voice/api/call-resource) or [Message](https://www.twilio.com/docs/sms/api/message-resource). :ivar inbound_resource_url: The URL of the Twilio inbound resource @@ -94,9 +94,9 @@ def __init__( "inbound_participant_sid" ) self.inbound_resource_sid: Optional[str] = payload.get("inbound_resource_sid") - self.inbound_resource_status: Optional[ - "InteractionInstance.ResourceStatus" - ] = payload.get("inbound_resource_status") + self.inbound_resource_status: Optional["InteractionInstance.ResourceStatus"] = ( + payload.get("inbound_resource_status") + ) self.inbound_resource_type: Optional[str] = payload.get("inbound_resource_type") self.inbound_resource_url: Optional[str] = payload.get("inbound_resource_url") self.outbound_participant_sid: Optional[str] = payload.get( @@ -189,6 +189,7 @@ def __repr__(self) -> str: class InteractionContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, session_sid: str, sid: str): """ Initialize the InteractionContext @@ -219,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: """ @@ -231,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: @@ -244,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, @@ -265,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( @@ -289,6 +296,7 @@ def __repr__(self) -> str: class InteractionPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> InteractionInstance: """ Build an instance of InteractionInstance @@ -312,6 +320,7 @@ def __repr__(self) -> str: class InteractionList(ListResource): + def __init__(self, version: Version, service_sid: str, session_sid: str): """ Initialize the InteractionList @@ -461,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( @@ -488,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 ce3c16abd0..7ad20fcffb 100644 --- a/twilio/rest/proxy/v1/service/session/participant/__init__.py +++ b/twilio/rest/proxy/v1/service/session/participant/__init__.py @@ -12,7 +12,6 @@ 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 @@ -27,7 +26,6 @@ class ParticipantInstance(InstanceResource): - """ :ivar sid: The unique string that we created to identify the Participant resource. :ivar session_sid: The SID of the parent [Session](https://www.twilio.com/docs/proxy/api/session) resource. @@ -152,6 +150,7 @@ def __repr__(self) -> str: class ParticipantContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, session_sid: str, sid: str): """ Initialize the ParticipantContext @@ -184,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: """ @@ -196,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: @@ -209,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, @@ -230,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( @@ -268,6 +273,7 @@ def __repr__(self) -> str: class ParticipantPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ParticipantInstance: """ Build an instance of ParticipantInstance @@ -291,6 +297,7 @@ def __repr__(self) -> str: class ParticipantList(ListResource): + def __init__(self, version: Version, service_sid: str, session_sid: str): """ Initialize the ParticipantList @@ -330,6 +337,7 @@ def create( :returns: The created ParticipantInstance """ + data = values.of( { "Identifier": identifier, @@ -338,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( @@ -369,6 +380,7 @@ async def create_async( :returns: The created ParticipantInstance """ + data = values.of( { "Identifier": identifier, @@ -377,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( @@ -518,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( @@ -545,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 b07b1782fa..4ffe67965b 100644 --- a/twilio/rest/proxy/v1/service/session/participant/message_interaction.py +++ b/twilio/rest/proxy/v1/service/session/participant/message_interaction.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class MessageInteractionInstance(InstanceResource): + class ResourceStatus(object): ACCEPTED = "accepted" ANSWERED = "answered" @@ -176,6 +176,7 @@ def __repr__(self) -> str: class MessageInteractionContext(InstanceContext): + def __init__( self, version: Version, @@ -214,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, @@ -236,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( @@ -261,6 +266,7 @@ def __repr__(self) -> str: class MessageInteractionPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> MessageInteractionInstance: """ Build an instance of MessageInteractionInstance @@ -285,6 +291,7 @@ def __repr__(self) -> str: class MessageInteractionList(ListResource): + def __init__( self, version: Version, service_sid: str, session_sid: str, participant_sid: str ): @@ -322,17 +329,21 @@ def create( :returns: The created MessageInteractionInstance """ + data = values.of( { "Body": body, "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( @@ -356,17 +367,21 @@ async def create_async( :returns: The created MessageInteractionInstance """ + data = values.of( { "Body": body, "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( @@ -504,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( @@ -531,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/routes/RoutesBase.py b/twilio/rest/routes/RoutesBase.py index 86a85dd3da..a47d67f093 100644 --- a/twilio/rest/routes/RoutesBase.py +++ b/twilio/rest/routes/RoutesBase.py @@ -17,6 +17,7 @@ class RoutesBase(Domain): + def __init__(self, twilio: Client): """ Initialize the Routes Domain diff --git a/twilio/rest/routes/v2/__init__.py b/twilio/rest/routes/v2/__init__.py index b3852c1a6d..56a140efc3 100644 --- a/twilio/rest/routes/v2/__init__.py +++ b/twilio/rest/routes/v2/__init__.py @@ -21,6 +21,7 @@ class V2(Version): + def __init__(self, domain: Domain): """ Initialize the V2 version of Routes diff --git a/twilio/rest/routes/v2/phone_number.py b/twilio/rest/routes/v2/phone_number.py index 496a3de2ba..1b67509bb0 100644 --- a/twilio/rest/routes/v2/phone_number.py +++ b/twilio/rest/routes/v2/phone_number.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import datetime from typing import Any, Dict, Optional, Union from twilio.base import deserialize, values @@ -23,7 +22,6 @@ class PhoneNumberInstance(InstanceResource): - """ :ivar phone_number: The phone number in E.164 format :ivar url: The absolute URL of the resource. @@ -141,6 +139,7 @@ def __repr__(self) -> str: class PhoneNumberContext(InstanceContext): + def __init__(self, version: Version, phone_number: str): """ Initialize the PhoneNumberContext @@ -164,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, @@ -183,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( @@ -207,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( @@ -237,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( @@ -265,6 +276,7 @@ def __repr__(self) -> str: class PhoneNumberList(ListResource): + def __init__(self, version: Version): """ Initialize the PhoneNumberList diff --git a/twilio/rest/routes/v2/sip_domain.py b/twilio/rest/routes/v2/sip_domain.py index 42755a43fc..2326a5dbc1 100644 --- a/twilio/rest/routes/v2/sip_domain.py +++ b/twilio/rest/routes/v2/sip_domain.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import datetime from typing import Any, Dict, Optional, Union from twilio.base import deserialize, values @@ -23,7 +22,6 @@ class SipDomainInstance(InstanceResource): - """ :ivar sip_domain: :ivar url: @@ -141,6 +139,7 @@ def __repr__(self) -> str: class SipDomainContext(InstanceContext): + def __init__(self, version: Version, sip_domain: str): """ Initialize the SipDomainContext @@ -164,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, @@ -183,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( @@ -207,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( @@ -237,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( @@ -265,6 +276,7 @@ def __repr__(self) -> str: class SipDomainList(ListResource): + def __init__(self, version: Version): """ Initialize the SipDomainList diff --git a/twilio/rest/routes/v2/trunk.py b/twilio/rest/routes/v2/trunk.py index cf02b000b1..f783ce92ca 100644 --- a/twilio/rest/routes/v2/trunk.py +++ b/twilio/rest/routes/v2/trunk.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import datetime from typing import Any, Dict, Optional, Union from twilio.base import deserialize, values @@ -23,7 +22,6 @@ class TrunkInstance(InstanceResource): - """ :ivar sip_trunk_domain: The absolute URL of the SIP Trunk :ivar url: The absolute URL of the resource. @@ -141,6 +139,7 @@ def __repr__(self) -> str: class TrunkContext(InstanceContext): + def __init__(self, version: Version, sip_trunk_domain: str): """ Initialize the TrunkContext @@ -164,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, @@ -183,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( @@ -207,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( @@ -237,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( @@ -265,6 +276,7 @@ def __repr__(self) -> str: class TrunkList(ListResource): + def __init__(self, version: Version): """ Initialize the TrunkList diff --git a/twilio/rest/serverless/ServerlessBase.py b/twilio/rest/serverless/ServerlessBase.py index 803c63dece..d6e227c0b7 100644 --- a/twilio/rest/serverless/ServerlessBase.py +++ b/twilio/rest/serverless/ServerlessBase.py @@ -17,6 +17,7 @@ class ServerlessBase(Domain): + def __init__(self, twilio: Client): """ Initialize the Serverless Domain diff --git a/twilio/rest/serverless/v1/__init__.py b/twilio/rest/serverless/v1/__init__.py index ea6b4e9db2..e494615caf 100644 --- a/twilio/rest/serverless/v1/__init__.py +++ b/twilio/rest/serverless/v1/__init__.py @@ -19,6 +19,7 @@ class V1(Version): + def __init__(self, domain: Domain): """ Initialize the V1 version of Serverless diff --git a/twilio/rest/serverless/v1/service/__init__.py b/twilio/rest/serverless/v1/service/__init__.py index 146827d812..f6e4e5841e 100644 --- a/twilio/rest/serverless/v1/service/__init__.py +++ b/twilio/rest/serverless/v1/service/__init__.py @@ -12,10 +12,9 @@ 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 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 @@ -28,7 +27,6 @@ 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. @@ -201,6 +199,7 @@ def __repr__(self) -> str: class ServiceContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the ServiceContext @@ -228,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: """ @@ -240,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: @@ -253,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, @@ -272,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( @@ -298,18 +303,22 @@ def update( :returns: The updated ServiceInstance """ + data = values.of( { - "IncludeCredentials": include_credentials, + "IncludeCredentials": serialize.boolean_to_string(include_credentials), "FriendlyName": friendly_name, - "UiEditable": ui_editable, + "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"]) @@ -329,18 +338,22 @@ async def update_async( :returns: The updated ServiceInstance """ + data = values.of( { - "IncludeCredentials": include_credentials, + "IncludeCredentials": serialize.boolean_to_string(include_credentials), "FriendlyName": friendly_name, - "UiEditable": ui_editable, + "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"]) @@ -404,6 +417,7 @@ def __repr__(self) -> str: class ServicePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ServiceInstance: """ Build an instance of ServiceInstance @@ -422,6 +436,7 @@ def __repr__(self) -> str: class ServiceList(ListResource): + def __init__(self, version: Version): """ Initialize the ServiceList @@ -450,19 +465,23 @@ def create( :returns: The created ServiceInstance """ + data = values.of( { "UniqueName": unique_name, "FriendlyName": friendly_name, - "IncludeCredentials": include_credentials, - "UiEditable": ui_editable, + "IncludeCredentials": serialize.boolean_to_string(include_credentials), + "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) @@ -484,19 +503,23 @@ async def create_async( :returns: The created ServiceInstance """ + data = values.of( { "UniqueName": unique_name, "FriendlyName": friendly_name, - "IncludeCredentials": include_credentials, - "UiEditable": ui_editable, + "IncludeCredentials": serialize.boolean_to_string(include_credentials), + "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) @@ -628,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( @@ -655,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 7b70adf1c4..de68b969be 100644 --- a/twilio/rest/serverless/v1/service/asset/__init__.py +++ b/twilio/rest/serverless/v1/service/asset/__init__.py @@ -12,7 +12,6 @@ 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 @@ -25,7 +24,6 @@ class AssetInstance(InstanceResource): - """ :ivar sid: The unique string that we created to identify the Asset resource. :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Asset resource. @@ -159,6 +157,7 @@ def __repr__(self) -> str: class AssetContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, sid: str): """ Initialize the AssetContext @@ -185,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: """ @@ -197,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: @@ -210,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, @@ -230,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( @@ -250,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( @@ -277,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( @@ -320,6 +333,7 @@ def __repr__(self) -> str: class AssetPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> AssetInstance: """ Build an instance of AssetInstance @@ -340,6 +354,7 @@ def __repr__(self) -> str: class AssetList(ListResource): + def __init__(self, version: Version, service_sid: str): """ Initialize the AssetList @@ -364,16 +379,20 @@ def create(self, friendly_name: str) -> AssetInstance: :returns: The created AssetInstance """ + data = values.of( { "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( @@ -388,16 +407,20 @@ async def create_async(self, friendly_name: str) -> AssetInstance: :returns: The created AssetInstance """ + data = values.of( { "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( @@ -531,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( @@ -558,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 34ebb07ef0..31f85d4c29 100644 --- a/twilio/rest/serverless/v1/service/asset/asset_version.py +++ b/twilio/rest/serverless/v1/service/asset/asset_version.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class AssetVersionInstance(InstanceResource): + class Visibility(object): PUBLIC = "public" PRIVATE = "private" @@ -116,6 +116,7 @@ def __repr__(self) -> str: class AssetVersionContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, asset_sid: str, sid: str): """ Initialize the AssetVersionContext @@ -145,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, @@ -166,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( @@ -190,6 +195,7 @@ def __repr__(self) -> str: class AssetVersionPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> AssetVersionInstance: """ Build an instance of AssetVersionInstance @@ -213,6 +219,7 @@ def __repr__(self) -> str: class AssetVersionList(ListResource): + def __init__(self, version: Version, service_sid: str, asset_sid: str): """ Initialize the AssetVersionList @@ -360,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( @@ -387,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 0fe3b8f923..5a7b6b7023 100644 --- a/twilio/rest/serverless/v1/service/build/__init__.py +++ b/twilio/rest/serverless/v1/service/build/__init__.py @@ -26,12 +26,16 @@ class BuildInstance(InstanceResource): + class Runtime(object): NODE8 = "node8" NODE10 = "node10" NODE12 = "node12" NODE14 = "node14" NODE16 = "node16" + NODE18 = "node18" + NODE20 = "node20" + NODE22 = "node22" class Status(object): BUILDING = "building" @@ -61,9 +65,9 @@ def __init__(self, version: Version, payload: Dict[str, Any], service_sid: str, self.account_sid: Optional[str] = payload.get("account_sid") self.service_sid: Optional[str] = payload.get("service_sid") self.status: Optional["BuildInstance.Status"] = payload.get("status") - self.asset_versions: Optional[List[object]] = payload.get("asset_versions") - self.function_versions: Optional[List[object]] = payload.get("function_versions") - self.dependencies: Optional[List[object]] = payload.get("dependencies") + self.asset_versions: Optional[List[Dict[str, object]]] = payload.get("asset_versions") + self.function_versions: Optional[List[Dict[str, object]]] = payload.get("function_versions") + self.dependencies: Optional[List[Dict[str, object]]] = payload.get("dependencies") self.runtime: Optional["BuildInstance.Runtime"] = payload.get("runtime") self.date_created: Optional[datetime] = deserialize.iso8601_datetime(payload.get("date_created")) self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(payload.get("date_updated")) @@ -172,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: """ @@ -181,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: @@ -192,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, @@ -210,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, @@ -274,7 +301,7 @@ def __repr__(self) -> str: class BuildList(ListResource): - + def __init__(self, version: Version, service_sid: str): """ Initialize the BuildList @@ -305,14 +332,24 @@ def create(self, asset_versions: Union[List[str], object]=values.unset, function :returns: The created BuildInstance """ + data = values.of({ 'AssetVersions': serialize.map(asset_versions, lambda e: e), 'FunctionVersions': serialize.map(function_versions, lambda e: e), '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']) @@ -327,14 +364,24 @@ async def create_async(self, asset_versions: Union[List[str], object]=values.uns :returns: The created BuildInstance """ + data = values.of({ 'AssetVersions': serialize.map(asset_versions, lambda e: e), 'FunctionVersions': serialize.map(function_versions, lambda e: e), '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 = await self._version.create_async(method='POST', uri=self._uri, data=data,) + 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']) @@ -463,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, @@ -488,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 c127f89a4f..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, @@ -164,7 +178,7 @@ def __repr__(self) -> str: class BuildStatusList(ListResource): - + def __init__(self, version: Version, service_sid: str, sid: str): """ Initialize the BuildStatusList diff --git a/twilio/rest/serverless/v1/service/environment/__init__.py b/twilio/rest/serverless/v1/service/environment/__init__.py index dac46b9744..cdad0504a7 100644 --- a/twilio/rest/serverless/v1/service/environment/__init__.py +++ b/twilio/rest/serverless/v1/service/environment/__init__.py @@ -12,7 +12,6 @@ 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 @@ -27,7 +26,6 @@ class EnvironmentInstance(InstanceResource): - """ :ivar sid: The unique string that we created to identify the Environment resource. :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Environment resource. @@ -157,6 +155,7 @@ def __repr__(self) -> str: class EnvironmentContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, sid: str): """ Initialize the EnvironmentContext @@ -187,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: """ @@ -199,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: @@ -212,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, @@ -232,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( @@ -294,6 +299,7 @@ def __repr__(self) -> str: class EnvironmentPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> EnvironmentInstance: """ Build an instance of EnvironmentInstance @@ -314,6 +320,7 @@ def __repr__(self) -> str: class EnvironmentList(ListResource): + def __init__(self, version: Version, service_sid: str): """ Initialize the EnvironmentList @@ -341,17 +348,21 @@ def create( :returns: The created EnvironmentInstance """ + data = values.of( { "UniqueName": unique_name, "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( @@ -369,17 +380,21 @@ async def create_async( :returns: The created EnvironmentInstance """ + data = values.of( { "UniqueName": unique_name, "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( @@ -513,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( @@ -540,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 f0f6b50037..d28a4b8db1 100644 --- a/twilio/rest/serverless/v1/service/environment/deployment.py +++ b/twilio/rest/serverless/v1/service/environment/deployment.py @@ -12,10 +12,9 @@ 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 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 @@ -24,7 +23,6 @@ class DeploymentInstance(InstanceResource): - """ :ivar sid: The unique string that we created to identify the Deployment resource. :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Deployment resource. @@ -112,6 +110,7 @@ def __repr__(self) -> str: class DeploymentContext(InstanceContext): + def __init__( self, version: Version, service_sid: str, environment_sid: str, sid: str ): @@ -143,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, @@ -164,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( @@ -188,6 +191,7 @@ def __repr__(self) -> str: class DeploymentPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> DeploymentInstance: """ Build an instance of DeploymentInstance @@ -211,6 +215,7 @@ def __repr__(self) -> str: class DeploymentList(ListResource): + def __init__(self, version: Version, service_sid: str, environment_sid: str): """ Initialize the DeploymentList @@ -234,25 +239,33 @@ 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 """ + 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( @@ -263,25 +276,33 @@ 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 """ + 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( @@ -418,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( @@ -445,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 d856ba75d8..e8d9281060 100644 --- a/twilio/rest/serverless/v1/service/environment/log.py +++ b/twilio/rest/serverless/v1/service/environment/log.py @@ -12,7 +12,6 @@ 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 @@ -24,11 +23,6 @@ class LogInstance(InstanceResource): - class Level(object): - INFO = "info" - WARN = "warn" - ERROR = "error" - """ :ivar sid: The unique string that we created to identify the Log resource. :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Log resource. @@ -38,7 +32,7 @@ class Level(object): :ivar deployment_sid: The SID of the deployment that corresponds to the log. :ivar function_sid: The SID of the function whose invocation produced the log. :ivar request_sid: The SID of the request associated with the log. - :ivar level: + :ivar level: The log level. :ivar message: The log message. :ivar date_created: The date and time in GMT when the Log resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. :ivar url: The absolute URL of the Log resource. @@ -62,7 +56,7 @@ def __init__( self.deployment_sid: Optional[str] = payload.get("deployment_sid") self.function_sid: Optional[str] = payload.get("function_sid") self.request_sid: Optional[str] = payload.get("request_sid") - self.level: Optional["LogInstance.Level"] = payload.get("level") + self.level: Optional[str] = payload.get("level") self.message: Optional[str] = payload.get("message") self.date_created: Optional[datetime] = deserialize.iso8601_datetime( payload.get("date_created") @@ -122,6 +116,7 @@ def __repr__(self) -> str: class LogContext(InstanceContext): + def __init__( self, version: Version, service_sid: str, environment_sid: str, sid: str ): @@ -155,10 +150,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, @@ -176,9 +172,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( @@ -200,6 +199,7 @@ def __repr__(self) -> str: class LogPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> LogInstance: """ Build an instance of LogInstance @@ -223,6 +223,7 @@ def __repr__(self) -> str: class LogList(ListResource): + def __init__(self, version: Version, service_sid: str, environment_sid: str): """ Initialize the LogList @@ -421,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 LogPage(self._version, response, self._solution) async def page_async( @@ -457,8 +464,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/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 b619e3a655..fbc6b48ac8 100644 --- a/twilio/rest/serverless/v1/service/environment/variable.py +++ b/twilio/rest/serverless/v1/service/environment/variable.py @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class VariableInstance(InstanceResource): - """ :ivar sid: The unique string that we created to identify the Variable resource. :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Variable resource. @@ -168,6 +166,7 @@ def __repr__(self) -> str: class VariableContext(InstanceContext): + def __init__( self, version: Version, service_sid: str, environment_sid: str, sid: str ): @@ -198,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: """ @@ -210,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: @@ -223,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, @@ -244,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( @@ -270,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( @@ -304,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( @@ -336,6 +349,7 @@ def __repr__(self) -> str: class VariablePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> VariableInstance: """ Build an instance of VariableInstance @@ -359,6 +373,7 @@ def __repr__(self) -> str: class VariableList(ListResource): + def __init__(self, version: Version, service_sid: str, environment_sid: str): """ Initialize the VariableList @@ -390,17 +405,21 @@ def create(self, key: str, value: str) -> VariableInstance: :returns: The created VariableInstance """ + data = values.of( { "Key": key, "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( @@ -419,17 +438,21 @@ async def create_async(self, key: str, value: str) -> VariableInstance: :returns: The created VariableInstance """ + data = values.of( { "Key": key, "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( @@ -566,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( @@ -593,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 3f2919316d..7697587e60 100644 --- a/twilio/rest/serverless/v1/service/function/__init__.py +++ b/twilio/rest/serverless/v1/service/function/__init__.py @@ -12,7 +12,6 @@ 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 @@ -27,7 +26,6 @@ class FunctionInstance(InstanceResource): - """ :ivar sid: The unique string that we created to identify the Function resource. :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Function resource. @@ -161,6 +159,7 @@ def __repr__(self) -> str: class FunctionContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, sid: str): """ Initialize the FunctionContext @@ -187,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: """ @@ -199,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: @@ -212,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, @@ -232,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( @@ -252,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( @@ -279,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( @@ -322,6 +335,7 @@ def __repr__(self) -> str: class FunctionPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> FunctionInstance: """ Build an instance of FunctionInstance @@ -342,6 +356,7 @@ def __repr__(self) -> str: class FunctionList(ListResource): + def __init__(self, version: Version, service_sid: str): """ Initialize the FunctionList @@ -366,16 +381,20 @@ def create(self, friendly_name: str) -> FunctionInstance: :returns: The created FunctionInstance """ + data = values.of( { "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( @@ -390,16 +409,20 @@ async def create_async(self, friendly_name: str) -> FunctionInstance: :returns: The created FunctionInstance """ + data = values.of( { "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( @@ -533,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( @@ -560,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 73443897a9..88b666208c 100644 --- a/twilio/rest/serverless/v1/service/function/function_version/__init__.py +++ b/twilio/rest/serverless/v1/service/function/function_version/__init__.py @@ -12,7 +12,6 @@ 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 @@ -27,6 +26,7 @@ class FunctionVersionInstance(InstanceResource): + class Visibility(object): PUBLIC = "public" PRIVATE = "private" @@ -128,6 +128,7 @@ def __repr__(self) -> str: class FunctionVersionContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, function_sid: str, sid: str): """ Initialize the FunctionVersionContext @@ -161,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, @@ -182,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( @@ -220,6 +225,7 @@ def __repr__(self) -> str: class FunctionVersionPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> FunctionVersionInstance: """ Build an instance of FunctionVersionInstance @@ -243,6 +249,7 @@ def __repr__(self) -> str: class FunctionVersionList(ListResource): + def __init__(self, version: Version, service_sid: str, function_sid: str): """ Initialize the FunctionVersionList @@ -390,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( @@ -417,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 c39f9f0710..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 @@ -12,8 +12,8 @@ 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 @@ -21,7 +21,6 @@ class FunctionVersionContentInstance(InstanceResource): - """ :ivar sid: The unique string that we created to identify the Function Version resource. :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Function Version resource. @@ -103,6 +102,7 @@ def __repr__(self) -> str: class FunctionVersionContentContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, function_sid: str, sid: str): """ Initialize the FunctionVersionContentContext @@ -132,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, @@ -153,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( @@ -177,6 +181,7 @@ def __repr__(self) -> str: class FunctionVersionContentList(ListResource): + def __init__(self, version: Version, service_sid: str, function_sid: str, sid: str): """ Initialize the FunctionVersionContentList diff --git a/twilio/rest/studio/StudioBase.py b/twilio/rest/studio/StudioBase.py index e1b2374226..3b218775c8 100644 --- a/twilio/rest/studio/StudioBase.py +++ b/twilio/rest/studio/StudioBase.py @@ -18,6 +18,7 @@ class StudioBase(Domain): + def __init__(self, twilio: Client): """ Initialize the Studio Domain diff --git a/twilio/rest/studio/v1/__init__.py b/twilio/rest/studio/v1/__init__.py index d5ca90bb68..8ab7d71b6c 100644 --- a/twilio/rest/studio/v1/__init__.py +++ b/twilio/rest/studio/v1/__init__.py @@ -19,6 +19,7 @@ class V1(Version): + def __init__(self, domain: Domain): """ Initialize the V1 version of Studio diff --git a/twilio/rest/studio/v1/flow/__init__.py b/twilio/rest/studio/v1/flow/__init__.py index a7c5756e04..533c1a45f5 100644 --- a/twilio/rest/studio/v1/flow/__init__.py +++ b/twilio/rest/studio/v1/flow/__init__.py @@ -12,7 +12,6 @@ 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 @@ -26,6 +25,7 @@ class FlowInstance(InstanceResource): + class Status(object): DRAFT = "draft" PUBLISHED = "published" @@ -142,6 +142,7 @@ def __repr__(self) -> str: class FlowContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the FlowContext @@ -167,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: """ @@ -179,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: @@ -192,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, @@ -211,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( @@ -257,6 +264,7 @@ def __repr__(self) -> str: class FlowPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> FlowInstance: """ Build an instance of FlowInstance @@ -275,6 +283,7 @@ def __repr__(self) -> str: class FlowList(ListResource): + def __init__(self, version: Version): """ Initialize the FlowList @@ -413,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( @@ -440,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 e0f56dbaf7..759d92506c 100644 --- a/twilio/rest/studio/v1/flow/engagement/__init__.py +++ b/twilio/rest/studio/v1/flow/engagement/__init__.py @@ -12,7 +12,6 @@ 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 @@ -28,6 +27,7 @@ class EngagementInstance(InstanceResource): + class Status(object): ACTIVE = "active" ENDED = "ended" @@ -156,6 +156,7 @@ def __repr__(self) -> str: class EngagementContext(InstanceContext): + def __init__(self, version: Version, flow_sid: str, sid: str): """ Initialize the EngagementContext @@ -183,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: """ @@ -195,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: @@ -208,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, @@ -228,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( @@ -277,6 +284,7 @@ def __repr__(self) -> str: class EngagementPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> EngagementInstance: """ Build an instance of EngagementInstance @@ -297,6 +305,7 @@ def __repr__(self) -> str: class EngagementList(ListResource): + def __init__(self, version: Version, flow_sid: str): """ Initialize the EngagementList @@ -325,6 +334,7 @@ def create( :returns: The created EngagementInstance """ + data = values.of( { "To": to, @@ -332,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( @@ -355,6 +368,7 @@ async def create_async( :returns: The created EngagementInstance """ + data = values.of( { "To": to, @@ -362,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( @@ -500,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( @@ -527,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 d558b38bed..73161011eb 100644 --- a/twilio/rest/studio/v1/flow/engagement/engagement_context.py +++ b/twilio/rest/studio/v1/flow/engagement/engagement_context.py @@ -12,8 +12,8 @@ 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 @@ -21,7 +21,6 @@ class EngagementContextInstance(InstanceResource): - """ :ivar account_sid: The SID of the Account. :ivar context: As your flow executes, we save the state in what's called the Flow Context. Any data in the flow context can be accessed by your widgets as variables, either in configuration fields or in text areas as variable substitution. @@ -96,6 +95,7 @@ def __repr__(self) -> str: class EngagementContextContext(InstanceContext): + def __init__(self, version: Version, flow_sid: str, engagement_sid: str): """ Initialize the EngagementContextContext @@ -123,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, @@ -143,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( @@ -166,6 +170,7 @@ def __repr__(self) -> str: class EngagementContextList(ListResource): + def __init__(self, version: Version, flow_sid: str, engagement_sid: str): """ Initialize the EngagementContextList diff --git a/twilio/rest/studio/v1/flow/engagement/step/__init__.py b/twilio/rest/studio/v1/flow/engagement/step/__init__.py index c1638f29cf..a5017c3313 100644 --- a/twilio/rest/studio/v1/flow/engagement/step/__init__.py +++ b/twilio/rest/studio/v1/flow/engagement/step/__init__.py @@ -12,7 +12,6 @@ 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 @@ -25,7 +24,6 @@ class StepInstance(InstanceResource): - """ :ivar sid: The unique string that we created to identify the Step resource. :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Step resource. @@ -33,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. @@ -57,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( @@ -128,6 +128,7 @@ def __repr__(self) -> str: class StepContext(InstanceContext): + def __init__(self, version: Version, flow_sid: str, engagement_sid: str, sid: str): """ Initialize the StepContext @@ -159,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, @@ -180,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( @@ -218,6 +223,7 @@ def __repr__(self) -> str: class StepPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> StepInstance: """ Build an instance of StepInstance @@ -241,6 +247,7 @@ def __repr__(self) -> str: class StepList(ListResource): + def __init__(self, version: Version, flow_sid: str, engagement_sid: str): """ Initialize the StepList @@ -388,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( @@ -415,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 c1555d05ab..6b299ebe5d 100644 --- a/twilio/rest/studio/v1/flow/engagement/step/step_context.py +++ b/twilio/rest/studio/v1/flow/engagement/step/step_context.py @@ -12,8 +12,8 @@ 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 @@ -21,7 +21,6 @@ class StepContextInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the StepContext resource. :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. @@ -101,6 +100,7 @@ def __repr__(self) -> str: class StepContextContext(InstanceContext): + def __init__( self, version: Version, flow_sid: str, engagement_sid: str, step_sid: str ): @@ -132,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, @@ -153,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( @@ -177,6 +181,7 @@ def __repr__(self) -> str: class StepContextList(ListResource): + def __init__( self, version: Version, flow_sid: str, engagement_sid: str, step_sid: str ): diff --git a/twilio/rest/studio/v1/flow/execution/__init__.py b/twilio/rest/studio/v1/flow/execution/__init__.py index d0ad05b67a..624b381768 100644 --- a/twilio/rest/studio/v1/flow/execution/__init__.py +++ b/twilio/rest/studio/v1/flow/execution/__init__.py @@ -12,7 +12,6 @@ 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 @@ -26,6 +25,7 @@ class ExecutionInstance(InstanceResource): + class Status(object): ACTIVE = "active" ENDED = "ended" @@ -180,6 +180,7 @@ def __repr__(self) -> str: class ExecutionContext(InstanceContext): + def __init__(self, version: Version, flow_sid: str, sid: str): """ Initialize the ExecutionContext @@ -207,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: """ @@ -219,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: @@ -232,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, @@ -252,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( @@ -272,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( @@ -301,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( @@ -357,6 +372,7 @@ def __repr__(self) -> str: class ExecutionPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ExecutionInstance: """ Build an instance of ExecutionInstance @@ -377,6 +393,7 @@ def __repr__(self) -> str: class ExecutionList(ListResource): + def __init__(self, version: Version, flow_sid: str): """ Initialize the ExecutionList @@ -405,6 +422,7 @@ def create( :returns: The created ExecutionInstance """ + data = values.of( { "To": to, @@ -412,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( @@ -435,6 +456,7 @@ async def create_async( :returns: The created ExecutionInstance """ + data = values.of( { "To": to, @@ -442,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( @@ -614,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( @@ -647,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 d84431d12a..0841a9ef24 100644 --- a/twilio/rest/studio/v1/flow/execution/execution_context.py +++ b/twilio/rest/studio/v1/flow/execution/execution_context.py @@ -12,8 +12,8 @@ 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 @@ -21,7 +21,6 @@ class ExecutionContextInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the ExecutionContext resource. :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. @@ -96,6 +95,7 @@ def __repr__(self) -> str: class ExecutionContextContext(InstanceContext): + def __init__(self, version: Version, flow_sid: str, execution_sid: str): """ Initialize the ExecutionContextContext @@ -123,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, @@ -143,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( @@ -166,6 +170,7 @@ def __repr__(self) -> str: class ExecutionContextList(ListResource): + def __init__(self, version: Version, flow_sid: str, execution_sid: str): """ Initialize the ExecutionContextList 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 462e5322b4..50a1e2371d 100644 --- a/twilio/rest/studio/v1/flow/execution/execution_step/__init__.py +++ b/twilio/rest/studio/v1/flow/execution/execution_step/__init__.py @@ -12,7 +12,6 @@ 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 @@ -27,12 +26,12 @@ class ExecutionStepInstance(InstanceResource): - """ :ivar sid: The unique string that we created to identify the ExecutionStep resource. :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. @@ -57,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") @@ -130,6 +130,7 @@ def __repr__(self) -> str: class ExecutionStepContext(InstanceContext): + def __init__(self, version: Version, flow_sid: str, execution_sid: str, sid: str): """ Initialize the ExecutionStepContext @@ -161,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, @@ -182,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( @@ -220,6 +225,7 @@ def __repr__(self) -> str: class ExecutionStepPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ExecutionStepInstance: """ Build an instance of ExecutionStepInstance @@ -243,6 +249,7 @@ def __repr__(self) -> str: class ExecutionStepList(ListResource): + def __init__(self, version: Version, flow_sid: str, execution_sid: str): """ Initialize the ExecutionStepList @@ -390,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( @@ -417,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 1463adec6b..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 @@ -12,8 +12,8 @@ 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 @@ -21,7 +21,6 @@ class ExecutionStepContextInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the ExecutionStepContext resource. :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. @@ -101,6 +100,7 @@ def __repr__(self) -> str: class ExecutionStepContextContext(InstanceContext): + def __init__( self, version: Version, flow_sid: str, execution_sid: str, step_sid: str ): @@ -132,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, @@ -153,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( @@ -177,6 +181,7 @@ def __repr__(self) -> str: class ExecutionStepContextList(ListResource): + def __init__( self, version: Version, flow_sid: str, execution_sid: str, step_sid: str ): diff --git a/twilio/rest/studio/v2/__init__.py b/twilio/rest/studio/v2/__init__.py index 2ad61768ad..83ccc8e0a9 100644 --- a/twilio/rest/studio/v2/__init__.py +++ b/twilio/rest/studio/v2/__init__.py @@ -20,6 +20,7 @@ class V2(Version): + def __init__(self, domain: Domain): """ Initialize the V2 version of Studio diff --git a/twilio/rest/studio/v2/flow/__init__.py b/twilio/rest/studio/v2/flow/__init__.py index 408e29cc7b..b4c542fdc0 100644 --- a/twilio/rest/studio/v2/flow/__init__.py +++ b/twilio/rest/studio/v2/flow/__init__.py @@ -12,7 +12,6 @@ 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 @@ -27,6 +26,7 @@ class FlowInstance(InstanceResource): + class Status(object): DRAFT = "draft" PUBLISHED = "published" @@ -62,8 +62,8 @@ def __init__( self.revision: Optional[int] = deserialize.integer(payload.get("revision")) self.commit_message: Optional[str] = payload.get("commit_message") self.valid: Optional[bool] = payload.get("valid") - self.errors: Optional[List[object]] = payload.get("errors") - self.warnings: Optional[List[object]] = payload.get("warnings") + self.errors: Optional[List[Dict[str, object]]] = payload.get("errors") + self.warnings: Optional[List[Dict[str, object]]] = payload.get("warnings") self.date_created: Optional[datetime] = deserialize.iso8601_datetime( payload.get("date_created") ) @@ -210,6 +210,7 @@ def __repr__(self) -> str: class FlowContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the FlowContext @@ -236,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: """ @@ -248,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: @@ -261,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, @@ -280,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( @@ -308,6 +315,7 @@ def update( :returns: The updated FlowInstance """ + data = values.of( { "Status": status, @@ -316,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"]) @@ -342,6 +353,7 @@ async def update_async( :returns: The updated FlowInstance """ + data = values.of( { "Status": status, @@ -350,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"]) @@ -406,6 +421,7 @@ def __repr__(self) -> str: class FlowPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> FlowInstance: """ Build an instance of FlowInstance @@ -424,6 +440,7 @@ def __repr__(self) -> str: class FlowList(ListResource): + def __init__(self, version: Version): """ Initialize the FlowList @@ -452,6 +469,7 @@ def create( :returns: The created FlowInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -460,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) @@ -486,6 +507,7 @@ async def create_async( :returns: The created FlowInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -494,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) @@ -630,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( @@ -657,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 1173683525..c47a3fbbc0 100644 --- a/twilio/rest/studio/v2/flow/execution/__init__.py +++ b/twilio/rest/studio/v2/flow/execution/__init__.py @@ -12,7 +12,6 @@ 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 @@ -26,6 +25,7 @@ class ExecutionInstance(InstanceResource): + class Status(object): ACTIVE = "active" ENDED = "ended" @@ -178,6 +178,7 @@ def __repr__(self) -> str: class ExecutionContext(InstanceContext): + def __init__(self, version: Version, flow_sid: str, sid: str): """ Initialize the ExecutionContext @@ -205,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: """ @@ -217,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: @@ -230,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, @@ -250,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( @@ -270,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( @@ -299,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( @@ -355,6 +370,7 @@ def __repr__(self) -> str: class ExecutionPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ExecutionInstance: """ Build an instance of ExecutionInstance @@ -375,6 +391,7 @@ def __repr__(self) -> str: class ExecutionList(ListResource): + def __init__(self, version: Version, flow_sid: str): """ Initialize the ExecutionList @@ -403,6 +420,7 @@ def create( :returns: The created ExecutionInstance """ + data = values.of( { "To": to, @@ -410,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( @@ -433,6 +454,7 @@ async def create_async( :returns: The created ExecutionInstance """ + data = values.of( { "To": to, @@ -440,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( @@ -612,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( @@ -645,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 47628b1ea9..4c18f81d11 100644 --- a/twilio/rest/studio/v2/flow/execution/execution_context.py +++ b/twilio/rest/studio/v2/flow/execution/execution_context.py @@ -12,8 +12,8 @@ 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 @@ -21,7 +21,6 @@ class ExecutionContextInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the ExecutionContext resource. :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. @@ -96,6 +95,7 @@ def __repr__(self) -> str: class ExecutionContextContext(InstanceContext): + def __init__(self, version: Version, flow_sid: str, execution_sid: str): """ Initialize the ExecutionContextContext @@ -123,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, @@ -143,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( @@ -166,6 +170,7 @@ def __repr__(self) -> str: class ExecutionContextList(ListResource): + def __init__(self, version: Version, flow_sid: str, execution_sid: str): """ Initialize the ExecutionContextList 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 7b43ad5eee..9ffb2502e6 100644 --- a/twilio/rest/studio/v2/flow/execution/execution_step/__init__.py +++ b/twilio/rest/studio/v2/flow/execution/execution_step/__init__.py @@ -12,7 +12,6 @@ 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 @@ -27,12 +26,12 @@ class ExecutionStepInstance(InstanceResource): - """ :ivar sid: The unique string that we created to identify the ExecutionStep resource. :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. @@ -57,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") @@ -130,6 +130,7 @@ def __repr__(self) -> str: class ExecutionStepContext(InstanceContext): + def __init__(self, version: Version, flow_sid: str, execution_sid: str, sid: str): """ Initialize the ExecutionStepContext @@ -161,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, @@ -182,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( @@ -220,6 +225,7 @@ def __repr__(self) -> str: class ExecutionStepPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ExecutionStepInstance: """ Build an instance of ExecutionStepInstance @@ -243,6 +249,7 @@ def __repr__(self) -> str: class ExecutionStepList(ListResource): + def __init__(self, version: Version, flow_sid: str, execution_sid: str): """ Initialize the ExecutionStepList @@ -390,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( @@ -417,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 5a88321590..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 @@ -12,8 +12,8 @@ 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 @@ -21,7 +21,6 @@ class ExecutionStepContextInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the ExecutionStepContext resource. :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. @@ -101,6 +100,7 @@ def __repr__(self) -> str: class ExecutionStepContextContext(InstanceContext): + def __init__( self, version: Version, flow_sid: str, execution_sid: str, step_sid: str ): @@ -132,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, @@ -153,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( @@ -177,6 +181,7 @@ def __repr__(self) -> str: class ExecutionStepContextList(ListResource): + def __init__( self, version: Version, flow_sid: str, execution_sid: str, step_sid: str ): diff --git a/twilio/rest/studio/v2/flow/flow_revision.py b/twilio/rest/studio/v2/flow/flow_revision.py index a9a5394a4f..aa065074d1 100644 --- a/twilio/rest/studio/v2/flow/flow_revision.py +++ b/twilio/rest/studio/v2/flow/flow_revision.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class FlowRevisionInstance(InstanceResource): + class Status(object): DRAFT = "draft" PUBLISHED = "published" @@ -60,7 +60,7 @@ def __init__( self.revision: Optional[int] = deserialize.integer(payload.get("revision")) self.commit_message: Optional[str] = payload.get("commit_message") self.valid: Optional[bool] = payload.get("valid") - self.errors: Optional[List[object]] = payload.get("errors") + self.errors: Optional[List[Dict[str, object]]] = payload.get("errors") self.date_created: Optional[datetime] = deserialize.iso8601_datetime( payload.get("date_created") ) @@ -120,6 +120,7 @@ def __repr__(self) -> str: class FlowRevisionContext(InstanceContext): + def __init__(self, version: Version, sid: str, revision: str): """ Initialize the FlowRevisionContext @@ -145,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, @@ -165,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( @@ -188,6 +193,7 @@ def __repr__(self) -> str: class FlowRevisionPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> FlowRevisionInstance: """ Build an instance of FlowRevisionInstance @@ -206,6 +212,7 @@ def __repr__(self) -> str: class FlowRevisionList(ListResource): + def __init__(self, version: Version, sid: str): """ Initialize the FlowRevisionList @@ -349,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( @@ -376,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 d5dbee7d68..cff41cd7e2 100644 --- a/twilio/rest/studio/v2/flow/flow_test_user.py +++ b/twilio/rest/studio/v2/flow/flow_test_user.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, List, Optional from twilio.base import serialize, values from twilio.base.instance_context import InstanceContext @@ -22,7 +21,6 @@ class FlowTestUserInstance(InstanceResource): - """ :ivar sid: Unique identifier of the flow. :ivar test_users: List of test user identities that can test draft versions of the flow. @@ -109,6 +107,7 @@ def __repr__(self) -> str: class FlowTestUserContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the FlowTestUserContext @@ -132,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, @@ -151,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( @@ -170,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"]) @@ -192,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"]) @@ -217,6 +228,7 @@ def __repr__(self) -> str: class FlowTestUserList(ListResource): + def __init__(self, version: Version, sid: str): """ Initialize the FlowTestUserList diff --git a/twilio/rest/studio/v2/flow_validate.py b/twilio/rest/studio/v2/flow_validate.py index 74ddfa2362..5f8b308547 100644 --- a/twilio/rest/studio/v2/flow_validate.py +++ b/twilio/rest/studio/v2/flow_validate.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, Optional, Union from twilio.base import serialize, values @@ -22,6 +21,7 @@ class FlowValidateInstance(InstanceResource): + class Status(object): DRAFT = "draft" PUBLISHED = "published" @@ -46,6 +46,7 @@ def __repr__(self) -> str: class FlowValidateList(ListResource): + def __init__(self, version: Version): """ Initialize the FlowValidateList @@ -74,6 +75,7 @@ def update( :returns: The created FlowValidateInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -82,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) @@ -108,6 +113,7 @@ async def update_async( :returns: The created FlowValidateInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -116,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/SupersimBase.py b/twilio/rest/supersim/SupersimBase.py index d85c382641..dd73d12223 100644 --- a/twilio/rest/supersim/SupersimBase.py +++ b/twilio/rest/supersim/SupersimBase.py @@ -17,6 +17,7 @@ class SupersimBase(Domain): + def __init__(self, twilio: Client): """ Initialize the Supersim Domain diff --git a/twilio/rest/supersim/v1/__init__.py b/twilio/rest/supersim/v1/__init__.py index 480787bcab..2336da2616 100644 --- a/twilio/rest/supersim/v1/__init__.py +++ b/twilio/rest/supersim/v1/__init__.py @@ -27,6 +27,7 @@ class V1(Version): + def __init__(self, domain: Domain): """ Initialize the V1 version of Supersim diff --git a/twilio/rest/supersim/v1/esim_profile.py b/twilio/rest/supersim/v1/esim_profile.py index 2b8472aa84..d12bb9b73f 100644 --- a/twilio/rest/supersim/v1/esim_profile.py +++ b/twilio/rest/supersim/v1/esim_profile.py @@ -12,10 +12,9 @@ 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 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 @@ -24,6 +23,7 @@ class EsimProfileInstance(InstanceResource): + class Status(object): NEW = "new" RESERVING = "reserving" @@ -36,7 +36,7 @@ class Status(object): :ivar sid: The unique string that we created to identify the eSIM Profile resource. :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) to which the eSIM Profile resource belongs. :ivar iccid: The [ICCID](https://en.wikipedia.org/wiki/Subscriber_identity_module#ICCID) associated with the Sim resource. - :ivar sim_sid: The SID of the [Sim](https://www.twilio.com/docs/wireless/api/sim-resource) resource that this eSIM Profile controls. + :ivar sim_sid: The SID of the [Sim](https://www.twilio.com/docs/iot/supersim/api/sim-resource) resource that this eSIM Profile controls. :ivar status: :ivar eid: Identifier of the eUICC that can claim the eSIM Profile. :ivar smdp_plus_address: Address of the SM-DP+ server from which the Profile will be downloaded. The URL will appear once the eSIM Profile reaches the status `available`. @@ -122,6 +122,7 @@ def __repr__(self) -> str: class EsimProfileContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the EsimProfileContext @@ -145,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, @@ -164,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( @@ -186,6 +191,7 @@ def __repr__(self) -> str: class EsimProfilePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> EsimProfileInstance: """ Build an instance of EsimProfileInstance @@ -204,6 +210,7 @@ def __repr__(self) -> str: class EsimProfileList(ListResource): + def __init__(self, version: Version): """ Initialize the EsimProfileList @@ -232,19 +239,23 @@ def create( :returns: The created EsimProfileInstance """ + data = values.of( { "CallbackUrl": callback_url, "CallbackMethod": callback_method, - "GenerateMatchingId": generate_matching_id, + "GenerateMatchingId": serialize.boolean_to_string(generate_matching_id), "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) @@ -266,19 +277,23 @@ async def create_async( :returns: The created EsimProfileInstance """ + data = values.of( { "CallbackUrl": callback_url, "CallbackMethod": callback_method, - "GenerateMatchingId": generate_matching_id, + "GenerateMatchingId": serialize.boolean_to_string(generate_matching_id), "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) @@ -298,7 +313,7 @@ def stream( The results are returned as a generator, so this operation is memory efficient. :param str eid: List the eSIM Profiles that have been associated with an EId. - :param str sim_sid: Find the eSIM Profile resource related to a [Sim](https://www.twilio.com/docs/wireless/api/sim-resource) resource by providing the SIM SID. Will always return an array with either 1 or 0 records. + :param str sim_sid: Find the eSIM Profile resource related to a [Sim](https://www.twilio.com/docs/iot/supersim/api/sim-resource) resource by providing the SIM SID. Will always return an array with either 1 or 0 records. :param "EsimProfileInstance.Status" status: List the eSIM Profiles that are in a given status. :param limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit @@ -331,7 +346,7 @@ async def stream_async( The results are returned as a generator, so this operation is memory efficient. :param str eid: List the eSIM Profiles that have been associated with an EId. - :param str sim_sid: Find the eSIM Profile resource related to a [Sim](https://www.twilio.com/docs/wireless/api/sim-resource) resource by providing the SIM SID. Will always return an array with either 1 or 0 records. + :param str sim_sid: Find the eSIM Profile resource related to a [Sim](https://www.twilio.com/docs/iot/supersim/api/sim-resource) resource by providing the SIM SID. Will always return an array with either 1 or 0 records. :param "EsimProfileInstance.Status" status: List the eSIM Profiles that are in a given status. :param limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit @@ -363,7 +378,7 @@ def list( memory before returning. :param str eid: List the eSIM Profiles that have been associated with an EId. - :param str sim_sid: Find the eSIM Profile resource related to a [Sim](https://www.twilio.com/docs/wireless/api/sim-resource) resource by providing the SIM SID. Will always return an array with either 1 or 0 records. + :param str sim_sid: Find the eSIM Profile resource related to a [Sim](https://www.twilio.com/docs/iot/supersim/api/sim-resource) resource by providing the SIM SID. Will always return an array with either 1 or 0 records. :param "EsimProfileInstance.Status" status: List the eSIM Profiles that are in a given status. :param limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit @@ -398,7 +413,7 @@ async def list_async( memory before returning. :param str eid: List the eSIM Profiles that have been associated with an EId. - :param str sim_sid: Find the eSIM Profile resource related to a [Sim](https://www.twilio.com/docs/wireless/api/sim-resource) resource by providing the SIM SID. Will always return an array with either 1 or 0 records. + :param str sim_sid: Find the eSIM Profile resource related to a [Sim](https://www.twilio.com/docs/iot/supersim/api/sim-resource) resource by providing the SIM SID. Will always return an array with either 1 or 0 records. :param "EsimProfileInstance.Status" status: List the eSIM Profiles that are in a given status. :param limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit @@ -434,7 +449,7 @@ def page( Request is executed immediately :param eid: List the eSIM Profiles that have been associated with an EId. - :param sim_sid: Find the eSIM Profile resource related to a [Sim](https://www.twilio.com/docs/wireless/api/sim-resource) resource by providing the SIM SID. Will always return an array with either 1 or 0 records. + :param sim_sid: Find the eSIM Profile resource related to a [Sim](https://www.twilio.com/docs/iot/supersim/api/sim-resource) resource by providing the SIM SID. Will always return an array with either 1 or 0 records. :param status: List the eSIM Profiles that are in a given status. :param page_token: PageToken provided by the API :param page_number: Page Number, this value is simply for client state @@ -453,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( @@ -470,7 +491,7 @@ async def page_async( Request is executed immediately :param eid: List the eSIM Profiles that have been associated with an EId. - :param sim_sid: Find the eSIM Profile resource related to a [Sim](https://www.twilio.com/docs/wireless/api/sim-resource) resource by providing the SIM SID. Will always return an array with either 1 or 0 records. + :param sim_sid: Find the eSIM Profile resource related to a [Sim](https://www.twilio.com/docs/iot/supersim/api/sim-resource) resource by providing the SIM SID. Will always return an array with either 1 or 0 records. :param status: List the eSIM Profiles that are in a given status. :param page_token: PageToken provided by the API :param page_number: Page Number, this value is simply for client state @@ -489,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 7ba3ce7a12..3ea067cff2 100644 --- a/twilio/rest/supersim/v1/fleet.py +++ b/twilio/rest/supersim/v1/fleet.py @@ -12,10 +12,9 @@ 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 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 @@ -24,6 +23,7 @@ class FleetInstance(InstanceResource): + class DataMetering(object): PAYG = "payg" @@ -35,9 +35,9 @@ class DataMetering(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 Fleet resource. :ivar data_enabled: Defines whether SIMs in the Fleet are capable of using 2G/3G/4G/LTE/CAT-M data connectivity. Defaults to `true`. - :ivar data_limit: The total data usage (download and upload combined) in Megabytes that each Super SIM assigned to the Fleet can consume during a billing period (normally one month). Value must be between 1MB (1) and 2TB (2,000,000). Defaults to 1GB (1,000). + :ivar data_limit: The total data usage (download and upload combined) in Megabytes that each Super SIM assigned to the Fleet can consume during a billing period (normally one month). Value must be between 1MB (1) and 2TB (2,000,000). Defaults to 250MB. :ivar data_metering: - :ivar sms_commands_enabled: Defines whether SIMs in the Fleet are capable of sending and receiving machine-to-machine SMS via Commands. Defaults to `true`. + :ivar sms_commands_enabled: Defines whether SIMs in the Fleet are capable of sending and receiving machine-to-machine SMS via Commands. Defaults to `false`. :ivar sms_commands_url: The URL that will receive a webhook when a Super SIM in the Fleet is used to send an SMS from your device to the SMS Commands number. Your server should respond with an HTTP status code in the 200 range; any response body will be ignored. :ivar sms_commands_method: A string representing the HTTP method to use when making a request to `sms_commands_url`. Can be one of `POST` or `GET`. Defaults to `POST`. :ivar network_access_profile_sid: The SID of the Network Access Profile that controls which cellular networks the Fleet's SIMs can connect to. @@ -189,6 +189,7 @@ def __repr__(self) -> str: class FleetContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the FleetContext @@ -212,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, @@ -231,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( @@ -265,6 +270,7 @@ def update( :returns: The updated FleetInstance """ + data = values.of( { "UniqueName": unique_name, @@ -276,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"]) @@ -308,6 +317,7 @@ async def update_async( :returns: The updated FleetInstance """ + data = values.of( { "UniqueName": unique_name, @@ -319,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"]) @@ -339,6 +352,7 @@ def __repr__(self) -> str: class FleetPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> FleetInstance: """ Build an instance of FleetInstance @@ -357,6 +371,7 @@ def __repr__(self) -> str: class FleetList(ListResource): + def __init__(self, version: Version): """ Initialize the FleetList @@ -395,24 +410,28 @@ def create( :returns: The created FleetInstance """ + data = values.of( { "NetworkAccessProfile": network_access_profile, "UniqueName": unique_name, - "DataEnabled": data_enabled, + "DataEnabled": serialize.boolean_to_string(data_enabled), "DataLimit": data_limit, "IpCommandsUrl": ip_commands_url, "IpCommandsMethod": ip_commands_method, - "SmsCommandsEnabled": sms_commands_enabled, + "SmsCommandsEnabled": serialize.boolean_to_string(sms_commands_enabled), "SmsCommandsUrl": sms_commands_url, "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) @@ -444,24 +463,28 @@ async def create_async( :returns: The created FleetInstance """ + data = values.of( { "NetworkAccessProfile": network_access_profile, "UniqueName": unique_name, - "DataEnabled": data_enabled, + "DataEnabled": serialize.boolean_to_string(data_enabled), "DataLimit": data_limit, "IpCommandsUrl": ip_commands_url, "IpCommandsMethod": ip_commands_method, - "SmsCommandsEnabled": sms_commands_enabled, + "SmsCommandsEnabled": serialize.boolean_to_string(sms_commands_enabled), "SmsCommandsUrl": sms_commands_url, "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) @@ -610,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( @@ -640,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 331ef26de2..72bf78297f 100644 --- a/twilio/rest/supersim/v1/ip_command.py +++ b/twilio/rest/supersim/v1/ip_command.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class IpCommandInstance(InstanceResource): + class Direction(object): TO_SIM = "to_sim" FROM_SIM = "from_sim" @@ -132,6 +132,7 @@ def __repr__(self) -> str: class IpCommandContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the IpCommandContext @@ -155,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, @@ -174,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( @@ -196,6 +201,7 @@ def __repr__(self) -> str: class IpCommandPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> IpCommandInstance: """ Build an instance of IpCommandInstance @@ -214,6 +220,7 @@ def __repr__(self) -> str: class IpCommandList(ListResource): + def __init__(self, version: Version): """ Initialize the IpCommandList @@ -246,6 +253,7 @@ def create( :returns: The created IpCommandInstance """ + data = values.of( { "Sim": sim, @@ -256,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) @@ -286,6 +297,7 @@ async def create_async( :returns: The created IpCommandInstance """ + data = values.of( { "Sim": sim, @@ -296,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) @@ -322,7 +337,7 @@ def stream( :param str sim: The SID or unique name of the Sim resource that IP Command was sent to or from. :param str sim_iccid: The ICCID of the Sim resource that IP Command was sent to or from. - :param "IpCommandInstance.Status" status: The status of the IP Command. Can be: `queued`, `sent`, `received` or `failed`. See the [IP Command Status Values](https://www.twilio.com/docs/wireless/api/ipcommand-resource#status-values) for a description of each. + :param "IpCommandInstance.Status" status: The status of the IP Command. Can be: `queued`, `sent`, `received` or `failed`. See the [IP Command Status Values](https://www.twilio.com/docs/iot/supersim/api/ipcommand-resource#status-values) for a description of each. :param "IpCommandInstance.Direction" direction: The direction of the IP Command. Can be `to_sim` or `from_sim`. The value of `to_sim` is synonymous with the term `mobile terminated`, and `from_sim` is synonymous with the term `mobile originated`. :param limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit @@ -361,7 +376,7 @@ async def stream_async( :param str sim: The SID or unique name of the Sim resource that IP Command was sent to or from. :param str sim_iccid: The ICCID of the Sim resource that IP Command was sent to or from. - :param "IpCommandInstance.Status" status: The status of the IP Command. Can be: `queued`, `sent`, `received` or `failed`. See the [IP Command Status Values](https://www.twilio.com/docs/wireless/api/ipcommand-resource#status-values) for a description of each. + :param "IpCommandInstance.Status" status: The status of the IP Command. Can be: `queued`, `sent`, `received` or `failed`. See the [IP Command Status Values](https://www.twilio.com/docs/iot/supersim/api/ipcommand-resource#status-values) for a description of each. :param "IpCommandInstance.Direction" direction: The direction of the IP Command. Can be `to_sim` or `from_sim`. The value of `to_sim` is synonymous with the term `mobile terminated`, and `from_sim` is synonymous with the term `mobile originated`. :param limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit @@ -399,7 +414,7 @@ def list( :param str sim: The SID or unique name of the Sim resource that IP Command was sent to or from. :param str sim_iccid: The ICCID of the Sim resource that IP Command was sent to or from. - :param "IpCommandInstance.Status" status: The status of the IP Command. Can be: `queued`, `sent`, `received` or `failed`. See the [IP Command Status Values](https://www.twilio.com/docs/wireless/api/ipcommand-resource#status-values) for a description of each. + :param "IpCommandInstance.Status" status: The status of the IP Command. Can be: `queued`, `sent`, `received` or `failed`. See the [IP Command Status Values](https://www.twilio.com/docs/iot/supersim/api/ipcommand-resource#status-values) for a description of each. :param "IpCommandInstance.Direction" direction: The direction of the IP Command. Can be `to_sim` or `from_sim`. The value of `to_sim` is synonymous with the term `mobile terminated`, and `from_sim` is synonymous with the term `mobile originated`. :param limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit @@ -437,7 +452,7 @@ async def list_async( :param str sim: The SID or unique name of the Sim resource that IP Command was sent to or from. :param str sim_iccid: The ICCID of the Sim resource that IP Command was sent to or from. - :param "IpCommandInstance.Status" status: The status of the IP Command. Can be: `queued`, `sent`, `received` or `failed`. See the [IP Command Status Values](https://www.twilio.com/docs/wireless/api/ipcommand-resource#status-values) for a description of each. + :param "IpCommandInstance.Status" status: The status of the IP Command. Can be: `queued`, `sent`, `received` or `failed`. See the [IP Command Status Values](https://www.twilio.com/docs/iot/supersim/api/ipcommand-resource#status-values) for a description of each. :param "IpCommandInstance.Direction" direction: The direction of the IP Command. Can be `to_sim` or `from_sim`. The value of `to_sim` is synonymous with the term `mobile terminated`, and `from_sim` is synonymous with the term `mobile originated`. :param limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit @@ -476,7 +491,7 @@ def page( :param sim: The SID or unique name of the Sim resource that IP Command was sent to or from. :param sim_iccid: The ICCID of the Sim resource that IP Command was sent to or from. - :param status: The status of the IP Command. Can be: `queued`, `sent`, `received` or `failed`. See the [IP Command Status Values](https://www.twilio.com/docs/wireless/api/ipcommand-resource#status-values) for a description of each. + :param status: The status of the IP Command. Can be: `queued`, `sent`, `received` or `failed`. See the [IP Command Status Values](https://www.twilio.com/docs/iot/supersim/api/ipcommand-resource#status-values) for a description of each. :param direction: The direction of the IP Command. Can be `to_sim` or `from_sim`. The value of `to_sim` is synonymous with the term `mobile terminated`, and `from_sim` is synonymous with the term `mobile originated`. :param page_token: PageToken provided by the API :param page_number: Page Number, this value is simply for client state @@ -496,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( @@ -515,7 +536,7 @@ async def page_async( :param sim: The SID or unique name of the Sim resource that IP Command was sent to or from. :param sim_iccid: The ICCID of the Sim resource that IP Command was sent to or from. - :param status: The status of the IP Command. Can be: `queued`, `sent`, `received` or `failed`. See the [IP Command Status Values](https://www.twilio.com/docs/wireless/api/ipcommand-resource#status-values) for a description of each. + :param status: The status of the IP Command. Can be: `queued`, `sent`, `received` or `failed`. See the [IP Command Status Values](https://www.twilio.com/docs/iot/supersim/api/ipcommand-resource#status-values) for a description of each. :param direction: The direction of the IP Command. Can be `to_sim` or `from_sim`. The value of `to_sim` is synonymous with the term `mobile terminated`, and `from_sim` is synonymous with the term `mobile originated`. :param page_token: PageToken provided by the API :param page_number: Page Number, this value is simply for client state @@ -535,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 7364105c88..211068d075 100644 --- a/twilio/rest/supersim/v1/network.py +++ b/twilio/rest/supersim/v1/network.py @@ -12,7 +12,6 @@ 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 @@ -23,7 +22,6 @@ class NetworkInstance(InstanceResource): - """ :ivar sid: The unique string that we created to identify the Network resource. :ivar friendly_name: A human readable identifier of this resource. @@ -41,7 +39,7 @@ def __init__( self.friendly_name: Optional[str] = payload.get("friendly_name") self.url: Optional[str] = payload.get("url") self.iso_country: Optional[str] = payload.get("iso_country") - self.identifiers: Optional[List[object]] = payload.get("identifiers") + self.identifiers: Optional[List[Dict[str, object]]] = payload.get("identifiers") self._solution = { "sid": sid or self.sid, @@ -92,6 +90,7 @@ def __repr__(self) -> str: class NetworkContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the NetworkContext @@ -115,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, @@ -134,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( @@ -156,6 +159,7 @@ def __repr__(self) -> str: class NetworkPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> NetworkInstance: """ Build an instance of NetworkInstance @@ -174,6 +178,7 @@ def __repr__(self) -> str: class NetworkList(ListResource): + def __init__(self, version: Version): """ Initialize the NetworkList @@ -355,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( @@ -391,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 0712dbe653..15b0cc5695 100644 --- a/twilio/rest/supersim/v1/network_access_profile/__init__.py +++ b/twilio/rest/supersim/v1/network_access_profile/__init__.py @@ -12,7 +12,6 @@ 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 @@ -27,7 +26,6 @@ class NetworkAccessProfileInstance(InstanceResource): - """ :ivar sid: The unique string that identifies the Network Access Profile 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. @@ -139,6 +137,7 @@ def __repr__(self) -> str: class NetworkAccessProfileContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the NetworkAccessProfileContext @@ -164,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, @@ -183,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( @@ -204,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( @@ -230,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( @@ -269,6 +280,7 @@ def __repr__(self) -> str: class NetworkAccessProfilePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> NetworkAccessProfileInstance: """ Build an instance of NetworkAccessProfileInstance @@ -287,6 +299,7 @@ def __repr__(self) -> str: class NetworkAccessProfileList(ListResource): + def __init__(self, version: Version): """ Initialize the NetworkAccessProfileList @@ -311,17 +324,21 @@ def create( :returns: The created NetworkAccessProfileInstance """ + data = values.of( { "UniqueName": unique_name, "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) @@ -339,17 +356,21 @@ async def create_async( :returns: The created NetworkAccessProfileInstance """ + data = values.of( { "UniqueName": unique_name, "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) @@ -481,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( @@ -508,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 065418f39d..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 @@ -12,7 +12,6 @@ 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 @@ -23,7 +22,6 @@ class NetworkAccessProfileNetworkInstance(InstanceResource): - """ :ivar sid: The unique string that identifies the Network resource. :ivar network_access_profile_sid: The unique string that identifies the Network resource's Network Access Profile resource. @@ -48,7 +46,7 @@ def __init__( ) self.friendly_name: Optional[str] = payload.get("friendly_name") self.iso_country: Optional[str] = payload.get("iso_country") - self.identifiers: Optional[List[object]] = payload.get("identifiers") + self.identifiers: Optional[List[Dict[str, object]]] = payload.get("identifiers") self.url: Optional[str] = payload.get("url") self._solution = { @@ -122,6 +120,7 @@ def __repr__(self) -> str: class NetworkAccessProfileNetworkContext(InstanceContext): + def __init__(self, version: Version, network_access_profile_sid: str, sid: str): """ Initialize the NetworkAccessProfileNetworkContext @@ -150,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: """ @@ -162,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: @@ -175,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, @@ -195,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( @@ -220,6 +225,7 @@ def __repr__(self) -> str: class NetworkAccessProfileNetworkPage(Page): + def get_instance( self, payload: Dict[str, Any] ) -> NetworkAccessProfileNetworkInstance: @@ -244,6 +250,7 @@ def __repr__(self) -> str: class NetworkAccessProfileNetworkList(ListResource): + def __init__(self, version: Version, network_access_profile_sid: str): """ Initialize the NetworkAccessProfileNetworkList @@ -272,16 +279,20 @@ def create(self, network: str) -> NetworkAccessProfileNetworkInstance: :returns: The created NetworkAccessProfileNetworkInstance """ + data = values.of( { "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( @@ -298,16 +309,20 @@ async def create_async(self, network: str) -> NetworkAccessProfileNetworkInstanc :returns: The created NetworkAccessProfileNetworkInstance """ + data = values.of( { "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( @@ -443,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( @@ -470,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 d9b00143ad..294e1102ce 100644 --- a/twilio/rest/supersim/v1/settings_update.py +++ b/twilio/rest/supersim/v1/settings_update.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class SettingsUpdateInstance(InstanceResource): + class Status(object): SCHEDULED = "scheduled" IN_PROGRESS = "in-progress" @@ -48,7 +48,7 @@ def __init__(self, version: Version, payload: Dict[str, Any]): self.iccid: Optional[str] = payload.get("iccid") self.sim_sid: Optional[str] = payload.get("sim_sid") self.status: Optional["SettingsUpdateInstance.Status"] = payload.get("status") - self.packages: Optional[List[object]] = payload.get("packages") + self.packages: Optional[List[Dict[str, object]]] = payload.get("packages") self.date_completed: Optional[datetime] = deserialize.iso8601_datetime( payload.get("date_completed") ) @@ -70,6 +70,7 @@ def __repr__(self) -> str: class SettingsUpdatePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> SettingsUpdateInstance: """ Build an instance of SettingsUpdateInstance @@ -88,6 +89,7 @@ def __repr__(self) -> str: class SettingsUpdateList(ListResource): + def __init__(self, version: Version): """ Initialize the SettingsUpdateList @@ -254,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( @@ -287,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 fae9427497..fa878a16df 100644 --- a/twilio/rest/supersim/v1/sim/__init__.py +++ b/twilio/rest/supersim/v1/sim/__init__.py @@ -12,7 +12,6 @@ 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 @@ -26,6 +25,7 @@ class SimInstance(InstanceResource): + class Status(object): NEW = "new" READY = "ready" @@ -194,6 +194,7 @@ def __repr__(self) -> str: class SimContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the SimContext @@ -220,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, @@ -239,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( @@ -271,6 +276,7 @@ def update( :returns: The updated SimInstance """ + data = values.of( { "UniqueName": unique_name, @@ -281,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"]) @@ -311,6 +320,7 @@ async def update_async( :returns: The updated SimInstance """ + data = values.of( { "UniqueName": unique_name, @@ -321,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"]) @@ -365,6 +378,7 @@ def __repr__(self) -> str: class SimPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> SimInstance: """ Build an instance of SimInstance @@ -383,6 +397,7 @@ def __repr__(self) -> str: class SimList(ListResource): + def __init__(self, version: Version): """ Initialize the SimList @@ -403,17 +418,21 @@ def create(self, iccid: str, registration_code: str) -> SimInstance: :returns: The created SimInstance """ + data = values.of( { "Iccid": iccid, "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) @@ -427,17 +446,21 @@ async def create_async(self, iccid: str, registration_code: str) -> SimInstance: :returns: The created SimInstance """ + data = values.of( { "Iccid": iccid, "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) @@ -612,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( @@ -648,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 52afd38c70..27cbe1222e 100644 --- a/twilio/rest/supersim/v1/sim/billing_period.py +++ b/twilio/rest/supersim/v1/sim/billing_period.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class BillingPeriodInstance(InstanceResource): + class BpType(object): READY = "ready" ACTIVE = "active" @@ -76,6 +76,7 @@ def __repr__(self) -> str: class BillingPeriodPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> BillingPeriodInstance: """ Build an instance of BillingPeriodInstance @@ -96,6 +97,7 @@ def __repr__(self) -> str: class BillingPeriodList(ListResource): + def __init__(self, version: Version, sim_sid: str): """ Initialize the BillingPeriodList @@ -239,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( @@ -266,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 42911d1372..0c4c3163b6 100644 --- a/twilio/rest/supersim/v1/sim/sim_ip_address.py +++ b/twilio/rest/supersim/v1/sim/sim_ip_address.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import values @@ -23,6 +22,7 @@ class SimIpAddressInstance(InstanceResource): + class IpAddressVersion(object): IPV4 = "IPv4" IPV6 = "IPv6" @@ -36,9 +36,9 @@ def __init__(self, version: Version, payload: Dict[str, Any], sim_sid: str): super().__init__(version) self.ip_address: Optional[str] = payload.get("ip_address") - self.ip_address_version: Optional[ - "SimIpAddressInstance.IpAddressVersion" - ] = payload.get("ip_address_version") + self.ip_address_version: Optional["SimIpAddressInstance.IpAddressVersion"] = ( + payload.get("ip_address_version") + ) self._solution = { "sim_sid": sim_sid, @@ -55,6 +55,7 @@ def __repr__(self) -> str: class SimIpAddressPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> SimIpAddressInstance: """ Build an instance of SimIpAddressInstance @@ -75,6 +76,7 @@ def __repr__(self) -> str: class SimIpAddressList(ListResource): + def __init__(self, version: Version, sim_sid: str): """ Initialize the SimIpAddressList @@ -218,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( @@ -245,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 83601dd7ce..dd70d2425e 100644 --- a/twilio/rest/supersim/v1/sms_command.py +++ b/twilio/rest/supersim/v1/sms_command.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class SmsCommandInstance(InstanceResource): + class Direction(object): TO_SIM = "to_sim" FROM_SIM = "from_sim" @@ -117,6 +117,7 @@ def __repr__(self) -> str: class SmsCommandContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the SmsCommandContext @@ -140,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, @@ -159,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( @@ -181,6 +186,7 @@ def __repr__(self) -> str: class SmsCommandPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> SmsCommandInstance: """ Build an instance of SmsCommandInstance @@ -199,6 +205,7 @@ def __repr__(self) -> str: class SmsCommandList(ListResource): + def __init__(self, version: Version): """ Initialize the SmsCommandList @@ -227,6 +234,7 @@ def create( :returns: The created SmsCommandInstance """ + data = values.of( { "Sim": sim, @@ -235,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) @@ -261,6 +272,7 @@ async def create_async( :returns: The created SmsCommandInstance """ + data = values.of( { "Sim": sim, @@ -269,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) @@ -448,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( @@ -484,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 5962a59951..94072a51fb 100644 --- a/twilio/rest/supersim/v1/usage_record.py +++ b/twilio/rest/supersim/v1/usage_record.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class UsageRecordInstance(InstanceResource): + class Granularity(object): HOUR = "hour" DAY = "day" @@ -77,6 +77,7 @@ def __repr__(self) -> str: class UsageRecordPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> UsageRecordInstance: """ Build an instance of UsageRecordInstance @@ -95,6 +96,7 @@ def __repr__(self) -> str: class UsageRecordList(ListResource): + def __init__(self, version: Version): """ Initialize the UsageRecordList @@ -357,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( @@ -408,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/SyncBase.py b/twilio/rest/sync/SyncBase.py index 35c4fa9846..113cac0390 100644 --- a/twilio/rest/sync/SyncBase.py +++ b/twilio/rest/sync/SyncBase.py @@ -17,6 +17,7 @@ class SyncBase(Domain): + def __init__(self, twilio: Client): """ Initialize the Sync Domain diff --git a/twilio/rest/sync/v1/__init__.py b/twilio/rest/sync/v1/__init__.py index db6c478992..e98201bd41 100644 --- a/twilio/rest/sync/v1/__init__.py +++ b/twilio/rest/sync/v1/__init__.py @@ -19,6 +19,7 @@ class V1(Version): + def __init__(self, domain: Domain): """ Initialize the V1 version of Sync diff --git a/twilio/rest/sync/v1/service/__init__.py b/twilio/rest/sync/v1/service/__init__.py index 7db062b90d..d17491d3cb 100644 --- a/twilio/rest/sync/v1/service/__init__.py +++ b/twilio/rest/sync/v1/service/__init__.py @@ -12,10 +12,9 @@ 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 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 @@ -28,7 +27,6 @@ class ServiceInstance(InstanceResource): - """ :ivar sid: The unique string that we created to identify the Service 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. It is a read-only property, it cannot be assigned using REST API. @@ -239,6 +237,7 @@ def __repr__(self) -> str: class ServiceContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the ServiceContext @@ -266,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: """ @@ -278,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: @@ -291,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, @@ -310,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( @@ -344,22 +349,32 @@ def update( :returns: The updated ServiceInstance """ + data = values.of( { "WebhookUrl": webhook_url, "FriendlyName": friendly_name, - "ReachabilityWebhooksEnabled": reachability_webhooks_enabled, - "AclEnabled": acl_enabled, - "ReachabilityDebouncingEnabled": reachability_debouncing_enabled, + "ReachabilityWebhooksEnabled": serialize.boolean_to_string( + reachability_webhooks_enabled + ), + "AclEnabled": serialize.boolean_to_string(acl_enabled), + "ReachabilityDebouncingEnabled": serialize.boolean_to_string( + reachability_debouncing_enabled + ), "ReachabilityDebouncingWindow": reachability_debouncing_window, - "WebhooksFromRestEnabled": webhooks_from_rest_enabled, + "WebhooksFromRestEnabled": serialize.boolean_to_string( + webhooks_from_rest_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"]) @@ -387,22 +402,32 @@ async def update_async( :returns: The updated ServiceInstance """ + data = values.of( { "WebhookUrl": webhook_url, "FriendlyName": friendly_name, - "ReachabilityWebhooksEnabled": reachability_webhooks_enabled, - "AclEnabled": acl_enabled, - "ReachabilityDebouncingEnabled": reachability_debouncing_enabled, + "ReachabilityWebhooksEnabled": serialize.boolean_to_string( + reachability_webhooks_enabled + ), + "AclEnabled": serialize.boolean_to_string(acl_enabled), + "ReachabilityDebouncingEnabled": serialize.boolean_to_string( + reachability_debouncing_enabled + ), "ReachabilityDebouncingWindow": reachability_debouncing_window, - "WebhooksFromRestEnabled": webhooks_from_rest_enabled, + "WebhooksFromRestEnabled": serialize.boolean_to_string( + webhooks_from_rest_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"]) @@ -466,6 +491,7 @@ def __repr__(self) -> str: class ServicePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ServiceInstance: """ Build an instance of ServiceInstance @@ -484,6 +510,7 @@ def __repr__(self) -> str: class ServiceList(ListResource): + def __init__(self, version: Version): """ Initialize the ServiceList @@ -518,22 +545,32 @@ def create( :returns: The created ServiceInstance """ + data = values.of( { "FriendlyName": friendly_name, "WebhookUrl": webhook_url, - "ReachabilityWebhooksEnabled": reachability_webhooks_enabled, - "AclEnabled": acl_enabled, - "ReachabilityDebouncingEnabled": reachability_debouncing_enabled, + "ReachabilityWebhooksEnabled": serialize.boolean_to_string( + reachability_webhooks_enabled + ), + "AclEnabled": serialize.boolean_to_string(acl_enabled), + "ReachabilityDebouncingEnabled": serialize.boolean_to_string( + reachability_debouncing_enabled + ), "ReachabilityDebouncingWindow": reachability_debouncing_window, - "WebhooksFromRestEnabled": webhooks_from_rest_enabled, + "WebhooksFromRestEnabled": serialize.boolean_to_string( + webhooks_from_rest_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) @@ -561,22 +598,32 @@ async def create_async( :returns: The created ServiceInstance """ + data = values.of( { "FriendlyName": friendly_name, "WebhookUrl": webhook_url, - "ReachabilityWebhooksEnabled": reachability_webhooks_enabled, - "AclEnabled": acl_enabled, - "ReachabilityDebouncingEnabled": reachability_debouncing_enabled, + "ReachabilityWebhooksEnabled": serialize.boolean_to_string( + reachability_webhooks_enabled + ), + "AclEnabled": serialize.boolean_to_string(acl_enabled), + "ReachabilityDebouncingEnabled": serialize.boolean_to_string( + reachability_debouncing_enabled + ), "ReachabilityDebouncingWindow": reachability_debouncing_window, - "WebhooksFromRestEnabled": webhooks_from_rest_enabled, + "WebhooksFromRestEnabled": serialize.boolean_to_string( + webhooks_from_rest_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) @@ -708,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( @@ -735,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 5689594a8a..fe64f629a8 100644 --- a/twilio/rest/sync/v1/service/document/__init__.py +++ b/twilio/rest/sync/v1/service/document/__init__.py @@ -12,7 +12,6 @@ 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 @@ -27,7 +26,6 @@ class DocumentInstance(InstanceResource): - """ :ivar sid: The unique string that we created to identify the Document 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 and can be up to 320 characters long. @@ -189,6 +187,7 @@ def __repr__(self) -> str: class DocumentContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, sid: str): """ Initialize the DocumentContext @@ -215,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: """ @@ -227,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: @@ -240,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, @@ -260,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( @@ -287,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 @@ -325,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 @@ -372,6 +389,7 @@ def __repr__(self) -> str: class DocumentPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> DocumentInstance: """ Build an instance of DocumentInstance @@ -392,6 +410,7 @@ def __repr__(self) -> str: class DocumentList(ListResource): + def __init__(self, version: Version, service_sid: str): """ Initialize the DocumentList @@ -423,6 +442,7 @@ def create( :returns: The created DocumentInstance """ + data = values.of( { "UniqueName": unique_name, @@ -430,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( @@ -456,6 +479,7 @@ async def create_async( :returns: The created DocumentInstance """ + data = values.of( { "UniqueName": unique_name, @@ -463,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( @@ -601,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( @@ -628,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 da0241f552..75a27c969a 100644 --- a/twilio/rest/sync/v1/service/document/document_permission.py +++ b/twilio/rest/sync/v1/service/document/document_permission.py @@ -12,9 +12,8 @@ Do not edit the class manually. """ - 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 @@ -23,7 +22,6 @@ class DocumentPermissionInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Document Permission resource. :ivar service_sid: The SID of the [Sync Service](https://www.twilio.com/docs/sync/api/service) the resource is associated with. @@ -161,6 +159,7 @@ def __repr__(self) -> str: class DocumentPermissionContext(InstanceContext): + def __init__( self, version: Version, service_sid: str, document_sid: str, identity: str ): @@ -191,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: """ @@ -203,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: @@ -216,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, @@ -237,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( @@ -262,18 +267,22 @@ def update( :returns: The updated DocumentPermissionInstance """ + data = values.of( { - "Read": read, - "Write": write, - "Manage": manage, + "Read": serialize.boolean_to_string(read), + "Write": serialize.boolean_to_string(write), + "Manage": serialize.boolean_to_string(manage), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return DocumentPermissionInstance( @@ -296,18 +305,22 @@ async def update_async( :returns: The updated DocumentPermissionInstance """ + data = values.of( { - "Read": read, - "Write": write, - "Manage": manage, + "Read": serialize.boolean_to_string(read), + "Write": serialize.boolean_to_string(write), + "Manage": serialize.boolean_to_string(manage), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return DocumentPermissionInstance( @@ -329,6 +342,7 @@ def __repr__(self) -> str: class DocumentPermissionPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> DocumentPermissionInstance: """ Build an instance of DocumentPermissionInstance @@ -352,6 +366,7 @@ def __repr__(self) -> str: class DocumentPermissionList(ListResource): + def __init__(self, version: Version, service_sid: str, document_sid: str): """ Initialize the DocumentPermissionList @@ -501,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( @@ -528,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 545ebee389..1b8e54aff8 100644 --- a/twilio/rest/sync/v1/service/sync_list/__init__.py +++ b/twilio/rest/sync/v1/service/sync_list/__init__.py @@ -12,7 +12,6 @@ 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 @@ -28,7 +27,6 @@ class SyncListInstance(InstanceResource): - """ :ivar sid: The unique string that we created to identify the Sync List 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. @@ -189,6 +187,7 @@ def __repr__(self) -> str: class SyncListContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, sid: str): """ Initialize the SyncListContext @@ -216,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: """ @@ -228,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: @@ -241,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, @@ -261,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( @@ -286,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( @@ -319,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( @@ -376,6 +389,7 @@ def __repr__(self) -> str: class SyncListPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> SyncListInstance: """ Build an instance of SyncListInstance @@ -396,6 +410,7 @@ def __repr__(self) -> str: class SyncListList(ListResource): + def __init__(self, version: Version, service_sid: str): """ Initialize the SyncListList @@ -427,6 +442,7 @@ def create( :returns: The created SyncListInstance """ + data = values.of( { "UniqueName": unique_name, @@ -434,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( @@ -460,6 +479,7 @@ async def create_async( :returns: The created SyncListInstance """ + data = values.of( { "UniqueName": unique_name, @@ -467,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( @@ -605,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( @@ -632,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 640b4c38ce..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 @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class SyncListItemInstance(InstanceResource): + class QueryFromBoundType(object): INCLUSIVE = "inclusive" EXCLUSIVE = "exclusive" @@ -205,6 +205,7 @@ def __repr__(self) -> str: class SyncListItemContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, list_sid: str, index: int): """ Initialize the SyncListItemContext @@ -240,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: @@ -256,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 ) @@ -268,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, @@ -289,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( @@ -321,6 +330,7 @@ def update( :returns: The updated SyncListItemInstance """ + data = values.of( { "Data": serialize.object(data), @@ -329,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 @@ -366,6 +381,7 @@ async def update_async( :returns: The updated SyncListItemInstance """ + data = values.of( { "Data": serialize.object(data), @@ -374,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 @@ -403,6 +424,7 @@ def __repr__(self) -> str: class SyncListItemPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> SyncListItemInstance: """ Build an instance of SyncListItemInstance @@ -426,6 +448,7 @@ def __repr__(self) -> str: class SyncListItemList(ListResource): + def __init__(self, version: Version, service_sid: str, list_sid: str): """ Initialize the SyncListItemList @@ -463,6 +486,7 @@ def create( :returns: The created SyncListItemInstance """ + data = values.of( { "Data": serialize.object(data), @@ -471,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( @@ -502,6 +529,7 @@ async def create_async( :returns: The created SyncListItemInstance """ + data = values.of( { "Data": serialize.object(data), @@ -510,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( @@ -694,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( @@ -730,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 f0d970b18d..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 @@ -12,9 +12,8 @@ Do not edit the class manually. """ - 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 @@ -23,7 +22,6 @@ class SyncListPermissionInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Sync List Permission resource. :ivar service_sid: The SID of the [Sync Service](https://www.twilio.com/docs/sync/api/service) the resource is associated with. @@ -161,6 +159,7 @@ def __repr__(self) -> str: class SyncListPermissionContext(InstanceContext): + def __init__( self, version: Version, service_sid: str, list_sid: str, identity: str ): @@ -193,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: """ @@ -205,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: @@ -218,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, @@ -239,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( @@ -264,18 +269,22 @@ def update( :returns: The updated SyncListPermissionInstance """ + data = values.of( { - "Read": read, - "Write": write, - "Manage": manage, + "Read": serialize.boolean_to_string(read), + "Write": serialize.boolean_to_string(write), + "Manage": serialize.boolean_to_string(manage), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SyncListPermissionInstance( @@ -298,18 +307,22 @@ async def update_async( :returns: The updated SyncListPermissionInstance """ + data = values.of( { - "Read": read, - "Write": write, - "Manage": manage, + "Read": serialize.boolean_to_string(read), + "Write": serialize.boolean_to_string(write), + "Manage": serialize.boolean_to_string(manage), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SyncListPermissionInstance( @@ -331,6 +344,7 @@ def __repr__(self) -> str: class SyncListPermissionPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> SyncListPermissionInstance: """ Build an instance of SyncListPermissionInstance @@ -354,6 +368,7 @@ def __repr__(self) -> str: class SyncListPermissionList(ListResource): + def __init__(self, version: Version, service_sid: str, list_sid: str): """ Initialize the SyncListPermissionList @@ -501,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( @@ -528,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 5b38378f2b..c6bb1ce556 100644 --- a/twilio/rest/sync/v1/service/sync_map/__init__.py +++ b/twilio/rest/sync/v1/service/sync_map/__init__.py @@ -12,7 +12,6 @@ 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 @@ -28,7 +27,6 @@ class SyncMapInstance(InstanceResource): - """ :ivar sid: The unique string that we created to identify the Sync Map 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. @@ -189,6 +187,7 @@ def __repr__(self) -> str: class SyncMapContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, sid: str): """ Initialize the SyncMapContext @@ -216,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: """ @@ -228,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: @@ -241,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, @@ -261,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( @@ -286,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( @@ -319,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( @@ -376,6 +389,7 @@ def __repr__(self) -> str: class SyncMapPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> SyncMapInstance: """ Build an instance of SyncMapInstance @@ -396,6 +410,7 @@ def __repr__(self) -> str: class SyncMapList(ListResource): + def __init__(self, version: Version, service_sid: str): """ Initialize the SyncMapList @@ -427,6 +442,7 @@ def create( :returns: The created SyncMapInstance """ + data = values.of( { "UniqueName": unique_name, @@ -434,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( @@ -460,6 +479,7 @@ async def create_async( :returns: The created SyncMapInstance """ + data = values.of( { "UniqueName": unique_name, @@ -467,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( @@ -605,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( @@ -632,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 ef290caab2..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 @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class SyncMapItemInstance(InstanceResource): + class QueryFromBoundType(object): INCLUSIVE = "inclusive" EXCLUSIVE = "exclusive" @@ -205,6 +205,7 @@ def __repr__(self) -> str: class SyncMapItemContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, map_sid: str, key: str): """ Initialize the SyncMapItemContext @@ -240,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: @@ -256,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 ) @@ -268,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, @@ -289,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( @@ -321,6 +330,7 @@ def update( :returns: The updated SyncMapItemInstance """ + data = values.of( { "Data": serialize.object(data), @@ -329,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 @@ -366,6 +381,7 @@ async def update_async( :returns: The updated SyncMapItemInstance """ + data = values.of( { "Data": serialize.object(data), @@ -374,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 @@ -403,6 +424,7 @@ def __repr__(self) -> str: class SyncMapItemPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> SyncMapItemInstance: """ Build an instance of SyncMapItemInstance @@ -426,6 +448,7 @@ def __repr__(self) -> str: class SyncMapItemList(ListResource): + def __init__(self, version: Version, service_sid: str, map_sid: str): """ Initialize the SyncMapItemList @@ -465,6 +488,7 @@ def create( :returns: The created SyncMapItemInstance """ + data = values.of( { "Key": key, @@ -474,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( @@ -507,6 +534,7 @@ async def create_async( :returns: The created SyncMapItemInstance """ + data = values.of( { "Key": key, @@ -516,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( @@ -700,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( @@ -736,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 ee34694dd4..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 @@ -12,9 +12,8 @@ Do not edit the class manually. """ - 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 @@ -23,7 +22,6 @@ class SyncMapPermissionInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Sync Map Permission resource. :ivar service_sid: The SID of the [Sync Service](https://www.twilio.com/docs/sync/api/service) the resource is associated with. @@ -161,6 +159,7 @@ def __repr__(self) -> str: class SyncMapPermissionContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, map_sid: str, identity: str): """ Initialize the SyncMapPermissionContext @@ -191,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: """ @@ -203,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: @@ -216,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, @@ -237,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( @@ -262,18 +267,22 @@ def update( :returns: The updated SyncMapPermissionInstance """ + data = values.of( { - "Read": read, - "Write": write, - "Manage": manage, + "Read": serialize.boolean_to_string(read), + "Write": serialize.boolean_to_string(write), + "Manage": serialize.boolean_to_string(manage), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.update( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SyncMapPermissionInstance( @@ -296,18 +305,22 @@ async def update_async( :returns: The updated SyncMapPermissionInstance """ + data = values.of( { - "Read": read, - "Write": write, - "Manage": manage, + "Read": serialize.boolean_to_string(read), + "Write": serialize.boolean_to_string(write), + "Manage": serialize.boolean_to_string(manage), } ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.update_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return SyncMapPermissionInstance( @@ -329,6 +342,7 @@ def __repr__(self) -> str: class SyncMapPermissionPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> SyncMapPermissionInstance: """ Build an instance of SyncMapPermissionInstance @@ -352,6 +366,7 @@ def __repr__(self) -> str: class SyncMapPermissionList(ListResource): + def __init__(self, version: Version, service_sid: str, map_sid: str): """ Initialize the SyncMapPermissionList @@ -499,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( @@ -526,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 59507674dd..a7f4128e05 100644 --- a/twilio/rest/sync/v1/service/sync_stream/__init__.py +++ b/twilio/rest/sync/v1/service/sync_stream/__init__.py @@ -12,7 +12,6 @@ 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 @@ -25,7 +24,6 @@ class SyncStreamInstance(InstanceResource): - """ :ivar sid: The unique string that we created to identify the Sync Stream 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. @@ -167,6 +165,7 @@ def __repr__(self) -> str: class SyncStreamContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, sid: str): """ Initialize the SyncStreamContext @@ -193,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: """ @@ -205,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: @@ -218,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, @@ -238,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( @@ -258,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( @@ -287,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( @@ -330,6 +343,7 @@ def __repr__(self) -> str: class SyncStreamPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> SyncStreamInstance: """ Build an instance of SyncStreamInstance @@ -350,6 +364,7 @@ def __repr__(self) -> str: class SyncStreamList(ListResource): + def __init__(self, version: Version, service_sid: str): """ Initialize the SyncStreamList @@ -379,17 +394,21 @@ def create( :returns: The created SyncStreamInstance """ + data = values.of( { "UniqueName": unique_name, "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( @@ -409,17 +428,21 @@ async def create_async( :returns: The created SyncStreamInstance """ + data = values.of( { "UniqueName": unique_name, "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( @@ -553,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( @@ -580,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 5227bb076b..bcce239975 100644 --- a/twilio/rest/sync/v1/service/sync_stream/stream_message.py +++ b/twilio/rest/sync/v1/service/sync_stream/stream_message.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, Optional from twilio.base import serialize, values @@ -22,7 +21,6 @@ class StreamMessageInstance(InstanceResource): - """ :ivar sid: The unique string that we created to identify the Stream Message resource. :ivar data: An arbitrary, schema-less object that contains the Stream Message body. Can be up to 4 KiB in length. @@ -56,6 +54,7 @@ def __repr__(self) -> str: class StreamMessageList(ListResource): + def __init__(self, version: Version, service_sid: str, stream_sid: str): """ Initialize the StreamMessageList @@ -84,16 +83,20 @@ def create(self, data: object) -> StreamMessageInstance: :returns: The created StreamMessageInstance """ + data = values.of( { "Data": serialize.object(data), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = self._version.create( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return StreamMessageInstance( @@ -111,16 +114,20 @@ async def create_async(self, data: object) -> StreamMessageInstance: :returns: The created StreamMessageInstance """ + data = values.of( { "Data": serialize.object(data), } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" payload = await self._version.create_async( - method="POST", - uri=self._uri, - data=data, + method="POST", uri=self._uri, data=data, headers=headers ) return StreamMessageInstance( diff --git a/twilio/rest/taskrouter/TaskrouterBase.py b/twilio/rest/taskrouter/TaskrouterBase.py index ee7fbfd7e8..4bbbdb602e 100644 --- a/twilio/rest/taskrouter/TaskrouterBase.py +++ b/twilio/rest/taskrouter/TaskrouterBase.py @@ -17,6 +17,7 @@ class TaskrouterBase(Domain): + def __init__(self, twilio: Client): """ Initialize the Taskrouter Domain diff --git a/twilio/rest/taskrouter/v1/__init__.py b/twilio/rest/taskrouter/v1/__init__.py index a331fb3497..a17eeccc2a 100644 --- a/twilio/rest/taskrouter/v1/__init__.py +++ b/twilio/rest/taskrouter/v1/__init__.py @@ -19,6 +19,7 @@ class V1(Version): + def __init__(self, domain: Domain): """ Initialize the V1 version of Taskrouter diff --git a/twilio/rest/taskrouter/v1/workspace/__init__.py b/twilio/rest/taskrouter/v1/workspace/__init__.py index 886ba65c93..086e3e1747 100644 --- a/twilio/rest/taskrouter/v1/workspace/__init__.py +++ b/twilio/rest/taskrouter/v1/workspace/__init__.py @@ -12,10 +12,9 @@ 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 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 @@ -40,6 +39,7 @@ class WorkspaceInstance(InstanceResource): + class QueueOrder(object): FIFO = "FIFO" LIFO = "LIFO" @@ -83,9 +83,9 @@ def __init__( self.sid: Optional[str] = payload.get("sid") self.timeout_activity_name: Optional[str] = payload.get("timeout_activity_name") self.timeout_activity_sid: Optional[str] = payload.get("timeout_activity_sid") - self.prioritize_queue_order: Optional[ - "WorkspaceInstance.QueueOrder" - ] = payload.get("prioritize_queue_order") + self.prioritize_queue_order: Optional["WorkspaceInstance.QueueOrder"] = ( + payload.get("prioritize_queue_order") + ) self.url: Optional[str] = payload.get("url") self.links: Optional[Dict[str, object]] = payload.get("links") @@ -296,6 +296,7 @@ def __repr__(self) -> str: class WorkspaceContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the WorkspaceContext @@ -329,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: """ @@ -341,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: @@ -354,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, @@ -373,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( @@ -409,22 +416,26 @@ def update( :returns: The updated WorkspaceInstance """ + data = values.of( { "DefaultActivitySid": default_activity_sid, "EventCallbackUrl": event_callback_url, "EventsFilter": events_filter, "FriendlyName": friendly_name, - "MultiTaskEnabled": multi_task_enabled, + "MultiTaskEnabled": serialize.boolean_to_string(multi_task_enabled), "TimeoutActivitySid": timeout_activity_sid, "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"]) @@ -454,22 +465,26 @@ async def update_async( :returns: The updated WorkspaceInstance """ + data = values.of( { "DefaultActivitySid": default_activity_sid, "EventCallbackUrl": event_callback_url, "EventsFilter": events_filter, "FriendlyName": friendly_name, - "MultiTaskEnabled": multi_task_enabled, + "MultiTaskEnabled": serialize.boolean_to_string(multi_task_enabled), "TimeoutActivitySid": timeout_activity_sid, "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"]) @@ -605,6 +620,7 @@ def __repr__(self) -> str: class WorkspacePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> WorkspaceInstance: """ Build an instance of WorkspaceInstance @@ -623,6 +639,7 @@ def __repr__(self) -> str: class WorkspaceList(ListResource): + def __init__(self, version: Version): """ Initialize the WorkspaceList @@ -657,21 +674,25 @@ def create( :returns: The created WorkspaceInstance """ + data = values.of( { "FriendlyName": friendly_name, "EventCallbackUrl": event_callback_url, "EventsFilter": events_filter, - "MultiTaskEnabled": multi_task_enabled, + "MultiTaskEnabled": serialize.boolean_to_string(multi_task_enabled), "Template": template, "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) @@ -699,21 +720,25 @@ async def create_async( :returns: The created WorkspaceInstance """ + data = values.of( { "FriendlyName": friendly_name, "EventCallbackUrl": event_callback_url, "EventsFilter": events_filter, - "MultiTaskEnabled": multi_task_enabled, + "MultiTaskEnabled": serialize.boolean_to_string(multi_task_enabled), "Template": template, "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) @@ -860,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( @@ -890,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 b233113d33..4e3e416af7 100644 --- a/twilio/rest/taskrouter/v1/workspace/activity.py +++ b/twilio/rest/taskrouter/v1/workspace/activity.py @@ -12,10 +12,9 @@ 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 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 @@ -24,7 +23,6 @@ class ActivityInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Activity resource. :ivar available: Whether the Worker is eligible to receive a Task when it occupies the Activity. A value of `true`, `1`, or `yes` indicates the Activity is available. All other values indicate that it is not. The value cannot be changed after the Activity is created. @@ -157,6 +155,7 @@ def __repr__(self) -> str: class ActivityContext(InstanceContext): + def __init__(self, version: Version, workspace_sid: str, sid: str): """ Initialize the ActivityContext @@ -183,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: """ @@ -195,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: @@ -208,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, @@ -228,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( @@ -250,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( @@ -279,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( @@ -309,6 +322,7 @@ def __repr__(self) -> str: class ActivityPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ActivityInstance: """ Build an instance of ActivityInstance @@ -329,6 +343,7 @@ def __repr__(self) -> str: class ActivityList(ListResource): + def __init__(self, version: Version, workspace_sid: str): """ Initialize the ActivityList @@ -356,17 +371,21 @@ def create( :returns: The created ActivityInstance """ + data = values.of( { "FriendlyName": friendly_name, - "Available": available, + "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( @@ -384,17 +403,21 @@ async def create_async( :returns: The created ActivityInstance """ + data = values.of( { "FriendlyName": friendly_name, - "Available": available, + "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( @@ -562,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( @@ -595,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 82f71317e2..1b7f289e5e 100644 --- a/twilio/rest/taskrouter/v1/workspace/event.py +++ b/twilio/rest/taskrouter/v1/workspace/event.py @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ 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 resource that triggered the event. @@ -125,6 +123,7 @@ def __repr__(self) -> str: class EventContext(InstanceContext): + def __init__(self, version: Version, workspace_sid: str, sid: str): """ Initialize the EventContext @@ -150,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, @@ -170,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( @@ -193,6 +196,7 @@ def __repr__(self) -> str: class EventPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> EventInstance: """ Build an instance of EventInstance @@ -213,6 +217,7 @@ def __repr__(self) -> str: class EventList(ListResource): + def __init__(self, version: Version, workspace_sid: str): """ Initialize the EventList @@ -525,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( @@ -585,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 5b9ed673ac..e7560a66e8 100644 --- a/twilio/rest/taskrouter/v1/workspace/task/__init__.py +++ b/twilio/rest/taskrouter/v1/workspace/task/__init__.py @@ -12,7 +12,6 @@ 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 @@ -25,6 +24,7 @@ class TaskInstance(InstanceResource): + class Status(object): PENDING = "pending" RESERVED = "reserved" @@ -38,7 +38,7 @@ class Status(object): :ivar age: The number of seconds since the Task was created. :ivar assignment_status: :ivar attributes: The JSON string with custom attributes of the work. **Note** If this property has been assigned a value, it will only be displayed in FETCH action that returns a single resource. Otherwise, it will be null. - :ivar addons: An object that contains the [addon](https://www.twilio.com/docs/taskrouter/marketplace) data for all installed addons. + :ivar addons: An object that contains the [Add-on](https://www.twilio.com/docs/add-ons) data for all installed Add-ons. :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 task_queue_entered_date: The date and time in GMT when the Task entered the TaskQueue, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. @@ -55,6 +55,9 @@ class Status(object): :ivar workspace_sid: The SID of the Workspace that contains the Task. :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__( @@ -101,6 +104,11 @@ def __init__( self.workspace_sid: Optional[str] = payload.get("workspace_sid") self.url: Optional[str] = payload.get("url") self.links: Optional[Dict[str, object]] = payload.get("links") + 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, @@ -174,6 +182,7 @@ def update( reason: Union[str, object] = values.unset, priority: Union[int, object] = values.unset, task_channel: Union[str, object] = values.unset, + virtual_start_time: Union[datetime, object] = values.unset, ) -> "TaskInstance": """ Update the TaskInstance @@ -184,6 +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 or before the year of 1900. :returns: The updated TaskInstance """ @@ -194,6 +204,7 @@ def update( reason=reason, priority=priority, task_channel=task_channel, + virtual_start_time=virtual_start_time, ) async def update_async( @@ -204,6 +215,7 @@ async def update_async( reason: Union[str, object] = values.unset, priority: Union[int, object] = values.unset, task_channel: Union[str, object] = values.unset, + virtual_start_time: Union[datetime, object] = values.unset, ) -> "TaskInstance": """ Asynchronous coroutine to update the TaskInstance @@ -214,6 +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 or before the year of 1900. :returns: The updated TaskInstance """ @@ -224,6 +237,7 @@ async def update_async( reason=reason, priority=priority, task_channel=task_channel, + virtual_start_time=virtual_start_time, ) @property @@ -244,6 +258,7 @@ def __repr__(self) -> str: class TaskContext(InstanceContext): + def __init__(self, version: Version, workspace_sid: str, sid: str): """ Initialize the TaskContext @@ -277,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: @@ -293,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 ) @@ -305,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, @@ -325,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( @@ -345,6 +368,7 @@ def update( reason: Union[str, object] = values.unset, priority: Union[int, object] = values.unset, task_channel: Union[str, object] = values.unset, + virtual_start_time: Union[datetime, object] = values.unset, ) -> TaskInstance: """ Update the TaskInstance @@ -355,9 +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 or before the year of 1900. :returns: The updated TaskInstance """ + data = values.of( { "Attributes": attributes, @@ -365,13 +391,19 @@ def update( "Reason": reason, "Priority": priority, "TaskChannel": task_channel, + "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 @@ -392,6 +424,7 @@ async def update_async( reason: Union[str, object] = values.unset, priority: Union[int, object] = values.unset, task_channel: Union[str, object] = values.unset, + virtual_start_time: Union[datetime, object] = values.unset, ) -> TaskInstance: """ Asynchronous coroutine to update the TaskInstance @@ -402,9 +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 or before the year of 1900. :returns: The updated TaskInstance """ + data = values.of( { "Attributes": attributes, @@ -412,13 +447,19 @@ async def update_async( "Reason": reason, "Priority": priority, "TaskChannel": task_channel, + "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 @@ -455,6 +496,7 @@ def __repr__(self) -> str: class TaskPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> TaskInstance: """ Build an instance of TaskInstance @@ -475,6 +517,7 @@ def __repr__(self) -> str: class TaskList(ListResource): + def __init__(self, version: Version, workspace_sid: str): """ Initialize the TaskList @@ -498,6 +541,10 @@ def create( task_channel: Union[str, object] = values.unset, 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 @@ -506,10 +553,15 @@ def create( :param priority: The priority to assign the new task and override the default. When supplied, the new Task will have this priority unless it matches a Workflow Target with a Priority set. When not supplied, the new Task will have the priority of the matching Workflow Target. Value can be 0 to 2^31^ (2,147,483,647). :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 attributes: A 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 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 """ + data = values.of( { "Timeout": timeout, @@ -517,13 +569,20 @@ def create( "TaskChannel": task_channel, "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( @@ -537,6 +596,10 @@ async def create_async( task_channel: Union[str, object] = values.unset, 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 @@ -545,10 +608,15 @@ async def create_async( :param priority: The priority to assign the new task and override the default. When supplied, the new Task will have this priority unless it matches a Workflow Target with a Priority set. When not supplied, the new Task will have the priority of the matching Workflow Target. Value can be 0 to 2^31^ (2,147,483,647). :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 attributes: A 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 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 """ + data = values.of( { "Timeout": timeout, @@ -556,13 +624,20 @@ async def create_async( "TaskChannel": task_channel, "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( @@ -578,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, @@ -596,8 +672,9 @@ 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 ordering: How to order the returned Task resources. y default, Tasks are sorted by ascending DateCreated. This value is specified as: `Attribute:Order`, where `Attribute` can be either `Priority` or `DateCreated` and `Order` can be either `asc` or `desc`. For example, `Priority:desc` returns Tasks ordered in descending order of their Priority. Multiple 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. - :param bool has_addons: Whether to read Tasks with addons. If `true`, returns only Tasks with addons. If `false`, returns only Tasks without addons. + :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() 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 @@ -616,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"], @@ -632,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, @@ -650,8 +729,9 @@ 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 ordering: How to order the returned Task resources. y default, Tasks are sorted by ascending DateCreated. This value is specified as: `Attribute:Order`, where `Attribute` can be either `Priority` or `DateCreated` and `Order` can be either `asc` or `desc`. For example, `Priority:desc` returns Tasks ordered in descending order of their Priority. Multiple 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. - :param bool has_addons: Whether to read Tasks with addons. If `true`, returns only Tasks with addons. If `false`, returns only Tasks without addons. + :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() 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 @@ -670,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"], @@ -686,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, @@ -703,8 +785,9 @@ 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 ordering: How to order the returned Task resources. y default, Tasks are sorted by ascending DateCreated. This value is specified as: `Attribute:Order`, where `Attribute` can be either `Priority` or `DateCreated` and `Order` can be either `asc` or `desc`. For example, `Priority:desc` returns Tasks ordered in descending order of their Priority. Multiple 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. - :param bool has_addons: Whether to read Tasks with addons. If `true`, returns only Tasks with addons. If `false`, returns only Tasks without addons. + :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 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 @@ -723,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, @@ -739,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, @@ -756,8 +841,9 @@ 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 ordering: How to order the returned Task resources. y default, Tasks are sorted by ascending DateCreated. This value is specified as: `Attribute:Order`, where `Attribute` can be either `Priority` or `DateCreated` and `Order` can be either `asc` or `desc`. For example, `Priority:desc` returns Tasks ordered in descending order of their Priority. Multiple 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. - :param bool has_addons: Whether to read Tasks with addons. If `true`, returns only Tasks with addons. If `false`, returns only Tasks without addons. + :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 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 @@ -777,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, @@ -793,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, @@ -810,8 +898,9 @@ 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 ordering: How to order the returned Task resources. y default, Tasks are sorted by ascending DateCreated. This value is specified as: `Attribute:Order`, where `Attribute` can be either `Priority` or `DateCreated` and `Order` can be either `asc` or `desc`. For example, `Priority:desc` returns Tasks ordered in descending order of their Priority. Multiple 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. - :param has_addons: Whether to read Tasks with addons. If `true`, returns only Tasks with addons. If `false`, returns only Tasks without addons. + :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 :param page_number: Page Number, this value is simply for client state :param page_size: Number of records to return, defaults to 50 @@ -827,15 +916,22 @@ def page( "TaskQueueSid": task_queue_sid, "TaskQueueName": task_queue_name, "EvaluateTaskAttributes": evaluate_task_attributes, + "RoutingTarget": routing_target, "Ordering": ordering, - "HasAddons": has_addons, + "HasAddons": serialize.boolean_to_string(has_addons), "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 TaskPage(self._version, response, self._solution) async def page_async( @@ -847,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, @@ -864,8 +961,9 @@ 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 ordering: How to order the returned Task resources. y default, Tasks are sorted by ascending DateCreated. This value is specified as: `Attribute:Order`, where `Attribute` can be either `Priority` or `DateCreated` and `Order` can be either `asc` or `desc`. For example, `Priority:desc` returns Tasks ordered in descending order of their Priority. Multiple 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. - :param has_addons: Whether to read Tasks with addons. If `true`, returns only Tasks with addons. If `false`, returns only Tasks without addons. + :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 :param page_number: Page Number, this value is simply for client state :param page_size: Number of records to return, defaults to 50 @@ -881,16 +979,21 @@ async def page_async( "TaskQueueSid": task_queue_sid, "TaskQueueName": task_queue_name, "EvaluateTaskAttributes": evaluate_task_attributes, + "RoutingTarget": routing_target, "Ordering": ordering, - "HasAddons": has_addons, + "HasAddons": serialize.boolean_to_string(has_addons), "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 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 32e7c6b4da..28cb03339a 100644 --- a/twilio/rest/taskrouter/v1/workspace/task/reservation.py +++ b/twilio/rest/taskrouter/v1/workspace/task/reservation.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class ReservationInstance(InstanceResource): + class CallStatus(object): INITIATED = "initiated" RINGING = "ringing" @@ -200,6 +200,7 @@ def update( supervisor: Union[str, object] = values.unset, end_conference_on_customer_exit: Union[bool, object] = values.unset, beep_on_customer_entrance: Union[bool, object] = values.unset, + jitter_buffer_size: Union[str, object] = values.unset, ) -> "ReservationInstance": """ Update the ReservationInstance @@ -249,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. @@ -258,6 +259,7 @@ def update( :param supervisor: The Supervisor SID/URI when executing the Supervise instruction. :param end_conference_on_customer_exit: Whether to end the conference when the customer leaves. :param beep_on_customer_entrance: Whether to play a notification beep when the customer joins. + :param jitter_buffer_size: The jitter buffer size for conference. Can be: `small`, `medium`, `large`, `off`. :returns: The updated ReservationInstance """ @@ -316,6 +318,7 @@ def update( supervisor=supervisor, end_conference_on_customer_exit=end_conference_on_customer_exit, beep_on_customer_entrance=beep_on_customer_entrance, + jitter_buffer_size=jitter_buffer_size, ) async def update_async( @@ -380,6 +383,7 @@ async def update_async( supervisor: Union[str, object] = values.unset, end_conference_on_customer_exit: Union[bool, object] = values.unset, beep_on_customer_entrance: Union[bool, object] = values.unset, + jitter_buffer_size: Union[str, object] = values.unset, ) -> "ReservationInstance": """ Asynchronous coroutine to update the ReservationInstance @@ -429,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. @@ -438,6 +442,7 @@ async def update_async( :param supervisor: The Supervisor SID/URI when executing the Supervise instruction. :param end_conference_on_customer_exit: Whether to end the conference when the customer leaves. :param beep_on_customer_entrance: Whether to play a notification beep when the customer joins. + :param jitter_buffer_size: The jitter buffer size for conference. Can be: `small`, `medium`, `large`, `off`. :returns: The updated ReservationInstance """ @@ -496,6 +501,7 @@ async def update_async( supervisor=supervisor, end_conference_on_customer_exit=end_conference_on_customer_exit, beep_on_customer_entrance=beep_on_customer_entrance, + jitter_buffer_size=jitter_buffer_size, ) def __repr__(self) -> str: @@ -509,6 +515,7 @@ def __repr__(self) -> str: class ReservationContext(InstanceContext): + def __init__(self, version: Version, workspace_sid: str, task_sid: str, sid: str): """ Initialize the ReservationContext @@ -540,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, @@ -561,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( @@ -636,6 +647,7 @@ def update( supervisor: Union[str, object] = values.unset, end_conference_on_customer_exit: Union[bool, object] = values.unset, beep_on_customer_entrance: Union[bool, object] = values.unset, + jitter_buffer_size: Union[str, object] = values.unset, ) -> ReservationInstance: """ Update the ReservationInstance @@ -685,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. @@ -694,9 +706,11 @@ def update( :param supervisor: The Supervisor SID/URI when executing the Supervise instruction. :param end_conference_on_customer_exit: Whether to end the conference when the customer leaves. :param beep_on_customer_entrance: Whether to play a notification beep when the customer joins. + :param jitter_buffer_size: The jitter buffer size for conference. Can be: `small`, `medium`, `large`, `off`. :returns: The updated ReservationInstance """ + data = values.of( { "ReservationStatus": reservation_status, @@ -714,9 +728,9 @@ def update( "CallTo": call_to, "CallUrl": call_url, "CallStatusCallbackUrl": call_status_callback_url, - "CallAccept": call_accept, + "CallAccept": serialize.boolean_to_string(call_accept), "RedirectCallSid": redirect_call_sid, - "RedirectAccept": redirect_accept, + "RedirectAccept": serialize.boolean_to_string(redirect_accept), "RedirectUrl": redirect_url, "To": to, "From": from_, @@ -726,14 +740,18 @@ def update( status_callback_event, lambda e: e ), "Timeout": timeout, - "Record": record, - "Muted": muted, + "Record": serialize.boolean_to_string(record), + "Muted": serialize.boolean_to_string(muted), "Beep": beep, - "StartConferenceOnEnter": start_conference_on_enter, - "EndConferenceOnExit": end_conference_on_exit, + "StartConferenceOnEnter": serialize.boolean_to_string( + start_conference_on_enter + ), + "EndConferenceOnExit": serialize.boolean_to_string( + end_conference_on_exit + ), "WaitUrl": wait_url, "WaitMethod": wait_method, - "EarlyMedia": early_media, + "EarlyMedia": serialize.boolean_to_string(early_media), "MaxParticipants": max_participants, "ConferenceStatusCallback": conference_status_callback, "ConferenceStatusCallbackMethod": conference_status_callback_method, @@ -756,15 +774,25 @@ def update( "PostWorkActivitySid": post_work_activity_sid, "SupervisorMode": supervisor_mode, "Supervisor": supervisor, - "EndConferenceOnCustomerExit": end_conference_on_customer_exit, - "BeepOnCustomerEntrance": beep_on_customer_entrance, - } - ) - headers = values.of( - { - "If-Match": if_match, + "EndConferenceOnCustomerExit": serialize.boolean_to_string( + end_conference_on_customer_exit + ), + "BeepOnCustomerEntrance": serialize.boolean_to_string( + beep_on_customer_entrance + ), + "JitterBufferSize": jitter_buffer_size, } ) + 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 @@ -840,6 +868,7 @@ async def update_async( supervisor: Union[str, object] = values.unset, end_conference_on_customer_exit: Union[bool, object] = values.unset, beep_on_customer_entrance: Union[bool, object] = values.unset, + jitter_buffer_size: Union[str, object] = values.unset, ) -> ReservationInstance: """ Asynchronous coroutine to update the ReservationInstance @@ -889,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. @@ -898,9 +927,11 @@ async def update_async( :param supervisor: The Supervisor SID/URI when executing the Supervise instruction. :param end_conference_on_customer_exit: Whether to end the conference when the customer leaves. :param beep_on_customer_entrance: Whether to play a notification beep when the customer joins. + :param jitter_buffer_size: The jitter buffer size for conference. Can be: `small`, `medium`, `large`, `off`. :returns: The updated ReservationInstance """ + data = values.of( { "ReservationStatus": reservation_status, @@ -918,9 +949,9 @@ async def update_async( "CallTo": call_to, "CallUrl": call_url, "CallStatusCallbackUrl": call_status_callback_url, - "CallAccept": call_accept, + "CallAccept": serialize.boolean_to_string(call_accept), "RedirectCallSid": redirect_call_sid, - "RedirectAccept": redirect_accept, + "RedirectAccept": serialize.boolean_to_string(redirect_accept), "RedirectUrl": redirect_url, "To": to, "From": from_, @@ -930,14 +961,18 @@ async def update_async( status_callback_event, lambda e: e ), "Timeout": timeout, - "Record": record, - "Muted": muted, + "Record": serialize.boolean_to_string(record), + "Muted": serialize.boolean_to_string(muted), "Beep": beep, - "StartConferenceOnEnter": start_conference_on_enter, - "EndConferenceOnExit": end_conference_on_exit, + "StartConferenceOnEnter": serialize.boolean_to_string( + start_conference_on_enter + ), + "EndConferenceOnExit": serialize.boolean_to_string( + end_conference_on_exit + ), "WaitUrl": wait_url, "WaitMethod": wait_method, - "EarlyMedia": early_media, + "EarlyMedia": serialize.boolean_to_string(early_media), "MaxParticipants": max_participants, "ConferenceStatusCallback": conference_status_callback, "ConferenceStatusCallbackMethod": conference_status_callback_method, @@ -960,15 +995,25 @@ async def update_async( "PostWorkActivitySid": post_work_activity_sid, "SupervisorMode": supervisor_mode, "Supervisor": supervisor, - "EndConferenceOnCustomerExit": end_conference_on_customer_exit, - "BeepOnCustomerEntrance": beep_on_customer_entrance, - } - ) - headers = values.of( - { - "If-Match": if_match, + "EndConferenceOnCustomerExit": serialize.boolean_to_string( + end_conference_on_customer_exit + ), + "BeepOnCustomerEntrance": serialize.boolean_to_string( + beep_on_customer_entrance + ), + "JitterBufferSize": jitter_buffer_size, } ) + 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 @@ -993,6 +1038,7 @@ def __repr__(self) -> str: class ReservationPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ReservationInstance: """ Build an instance of ReservationInstance @@ -1016,6 +1062,7 @@ def __repr__(self) -> str: class ReservationList(ListResource): + def __init__(self, version: Version, workspace_sid: str, task_sid: str): """ Initialize the ReservationList @@ -1197,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( @@ -1230,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 d6408dcd74..3a4b0a6b9e 100644 --- a/twilio/rest/taskrouter/v1/workspace/task_channel.py +++ b/twilio/rest/taskrouter/v1/workspace/task_channel.py @@ -12,10 +12,9 @@ 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 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 @@ -24,7 +23,6 @@ class TaskChannelInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Task Channel 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. @@ -169,6 +167,7 @@ def __repr__(self) -> str: class TaskChannelContext(InstanceContext): + def __init__(self, version: Version, workspace_sid: str, sid: str): """ Initialize the TaskChannelContext @@ -195,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: """ @@ -207,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: @@ -220,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, @@ -240,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( @@ -265,17 +270,23 @@ def update( :returns: The updated TaskChannelInstance """ + data = values.of( { "FriendlyName": friendly_name, - "ChannelOptimizedRouting": channel_optimized_routing, + "ChannelOptimizedRouting": serialize.boolean_to_string( + channel_optimized_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 TaskChannelInstance( @@ -298,17 +309,23 @@ async def update_async( :returns: The updated TaskChannelInstance """ + data = values.of( { "FriendlyName": friendly_name, - "ChannelOptimizedRouting": channel_optimized_routing, + "ChannelOptimizedRouting": serialize.boolean_to_string( + channel_optimized_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 TaskChannelInstance( @@ -329,6 +346,7 @@ def __repr__(self) -> str: class TaskChannelPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> TaskChannelInstance: """ Build an instance of TaskChannelInstance @@ -349,6 +367,7 @@ def __repr__(self) -> str: class TaskChannelList(ListResource): + def __init__(self, version: Version, workspace_sid: str): """ Initialize the TaskChannelList @@ -380,18 +399,24 @@ def create( :returns: The created TaskChannelInstance """ + data = values.of( { "FriendlyName": friendly_name, "UniqueName": unique_name, - "ChannelOptimizedRouting": channel_optimized_routing, + "ChannelOptimizedRouting": serialize.boolean_to_string( + channel_optimized_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 TaskChannelInstance( @@ -413,18 +438,24 @@ async def create_async( :returns: The created TaskChannelInstance """ + data = values.of( { "FriendlyName": friendly_name, "UniqueName": unique_name, - "ChannelOptimizedRouting": channel_optimized_routing, + "ChannelOptimizedRouting": serialize.boolean_to_string( + channel_optimized_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 TaskChannelInstance( @@ -558,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( @@ -585,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 cc523c8514..4511a55310 100644 --- a/twilio/rest/taskrouter/v1/workspace/task_queue/__init__.py +++ b/twilio/rest/taskrouter/v1/workspace/task_queue/__init__.py @@ -12,7 +12,6 @@ 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 @@ -21,6 +20,9 @@ from twilio.base.list_resource import ListResource from twilio.base.version import Version from twilio.base.page import Page +from twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_bulk_real_time_statistics import ( + TaskQueueBulkRealTimeStatisticsList, +) from twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_cumulative_statistics import ( TaskQueueCumulativeStatisticsList, ) @@ -36,6 +38,7 @@ class TaskQueueInstance(InstanceResource): + class TaskOrder(object): FIFO = "FIFO" LIFO = "LIFO" @@ -249,6 +252,7 @@ def __repr__(self) -> str: class TaskQueueContext(InstanceContext): + def __init__(self, version: Version, workspace_sid: str, sid: str): """ Initialize the TaskQueueContext @@ -279,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: """ @@ -291,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: @@ -304,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, @@ -324,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( @@ -357,6 +367,7 @@ def update( :returns: The updated TaskQueueInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -367,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( @@ -402,6 +416,7 @@ async def update_async( :returns: The updated TaskQueueInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -412,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( @@ -476,6 +494,7 @@ def __repr__(self) -> str: class TaskQueuePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> TaskQueueInstance: """ Build an instance of TaskQueueInstance @@ -496,6 +515,7 @@ def __repr__(self) -> str: class TaskQueueList(ListResource): + def __init__(self, version: Version, workspace_sid: str): """ Initialize the TaskQueueList @@ -512,6 +532,9 @@ def __init__(self, version: Version, workspace_sid: str): } self._uri = "/Workspaces/{workspace_sid}/TaskQueues".format(**self._solution) + self._bulk_real_time_statistics: Optional[ + TaskQueueBulkRealTimeStatisticsList + ] = None self._statistics: Optional[TaskQueuesStatisticsList] = None def create( @@ -535,6 +558,7 @@ def create( :returns: The created TaskQueueInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -545,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( @@ -577,6 +604,7 @@ async def create_async( :returns: The created TaskQueueInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -587,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( @@ -789,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( @@ -828,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) @@ -857,6 +898,17 @@ async def get_page_async(self, target_url: str) -> TaskQueuePage: response = await self._version.domain.twilio.request_async("GET", target_url) return TaskQueuePage(self._version, response, self._solution) + @property + def bulk_real_time_statistics(self) -> TaskQueueBulkRealTimeStatisticsList: + """ + Access the bulk_real_time_statistics + """ + if self._bulk_real_time_statistics is None: + self._bulk_real_time_statistics = TaskQueueBulkRealTimeStatisticsList( + self._version, workspace_sid=self._solution["workspace_sid"] + ) + return self._bulk_real_time_statistics + @property def statistics(self) -> TaskQueuesStatisticsList: """ 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 new file mode 100644 index 0000000000..90400c7930 --- /dev/null +++ b/twilio/rest/taskrouter/v1/workspace/task_queue/task_queue_bulk_real_time_statistics.py @@ -0,0 +1,141 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Taskrouter + 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 deserialize, values + +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + + +class TaskQueueBulkRealTimeStatisticsInstance(InstanceResource): + """ + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the TaskQueue resource. + :ivar workspace_sid: The SID of the Workspace that contains the TaskQueue. + :ivar task_queue_data: The real-time statistics for each requested TaskQueue SID. `task_queue_data` returns the following attributes: `task_queue_sid`: The SID of the TaskQueue from which these statistics were calculated. `total_available_workers`: The total number of Workers available for Tasks in the TaskQueue. `total_eligible_workers`: The total number of Workers eligible for Tasks in the TaskQueue, regardless of their Activity state. `total_tasks`: The total number of Tasks. `longest_task_waiting_age`: The age of the longest waiting Task. `longest_task_waiting_sid`: The SID of the longest waiting Task. `tasks_by_status`: The number of Tasks grouped by their current status. `tasks_by_priority`: The number of Tasks grouped by priority. `activity_statistics`: The number of current Workers grouped by Activity. + :ivar task_queue_response_count: The number of TaskQueue statistics received in task_queue_data. + :ivar url: The absolute URL of the TaskQueue statistics resource. + """ + + def __init__(self, version: Version, payload: Dict[str, Any], workspace_sid: str): + super().__init__(version) + + self.account_sid: Optional[str] = payload.get("account_sid") + self.workspace_sid: Optional[str] = payload.get("workspace_sid") + self.task_queue_data: Optional[List[Dict[str, object]]] = payload.get( + "task_queue_data" + ) + self.task_queue_response_count: Optional[int] = deserialize.integer( + payload.get("task_queue_response_count") + ) + self.url: Optional[str] = payload.get("url") + + self._solution = { + "workspace_sid": workspace_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 TaskQueueBulkRealTimeStatisticsList(ListResource): + + def __init__(self, version: Version, workspace_sid: str): + """ + Initialize the TaskQueueBulkRealTimeStatisticsList + + :param version: Version that contains the resource + :param workspace_sid: The unique SID identifier of the Workspace. + + """ + super().__init__(version) + + # Path Solution + self._solution = { + "workspace_sid": workspace_sid, + } + self._uri = "/Workspaces/{workspace_sid}/TaskQueues/RealTimeStatistics".format( + **self._solution + ) + + def create( + self, body: Union[object, object] = values.unset + ) -> TaskQueueBulkRealTimeStatisticsInstance: + """ + Create the TaskQueueBulkRealTimeStatisticsInstance + + :param body: + + :returns: The created TaskQueueBulkRealTimeStatisticsInstance + """ + 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 TaskQueueBulkRealTimeStatisticsInstance( + self._version, payload, workspace_sid=self._solution["workspace_sid"] + ) + + async def create_async( + self, body: Union[object, object] = values.unset + ) -> TaskQueueBulkRealTimeStatisticsInstance: + """ + Asynchronously create the TaskQueueBulkRealTimeStatisticsInstance + + :param body: + + :returns: The created TaskQueueBulkRealTimeStatisticsInstance + """ + 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 TaskQueueBulkRealTimeStatisticsInstance( + self._version, payload, workspace_sid=self._solution["workspace_sid"] + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" 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 94c213b626..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 @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import datetime from typing import Any, Dict, Optional, Union from twilio.base import deserialize, serialize, values @@ -23,7 +22,6 @@ class TaskQueueCumulativeStatisticsInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the TaskQueue resource. :ivar avg_task_acceptance_time: The average time in seconds between Task creation and acceptance. @@ -96,9 +94,9 @@ def __init__( self.wait_duration_until_canceled: Optional[Dict[str, object]] = payload.get( "wait_duration_until_canceled" ) - self.wait_duration_in_queue_until_accepted: Optional[ - Dict[str, object] - ] = payload.get("wait_duration_in_queue_until_accepted") + self.wait_duration_in_queue_until_accepted: Optional[Dict[str, object]] = ( + payload.get("wait_duration_in_queue_until_accepted") + ) self.tasks_canceled: Optional[int] = deserialize.integer( payload.get("tasks_canceled") ) @@ -206,6 +204,7 @@ def __repr__(self) -> str: class TaskQueueCumulativeStatisticsContext(InstanceContext): + def __init__(self, version: Version, workspace_sid: str, task_queue_sid: str): """ Initialize the TaskQueueCumulativeStatisticsContext @@ -255,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, @@ -294,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( @@ -318,6 +327,7 @@ def __repr__(self) -> str: class TaskQueueCumulativeStatisticsList(ListResource): + def __init__(self, version: Version, workspace_sid: str, task_queue_sid: str): """ Initialize the TaskQueueCumulativeStatisticsList 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 d588f99d4d..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 @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, List, Optional, Union from twilio.base import deserialize, values from twilio.base.instance_context import InstanceContext @@ -22,7 +21,6 @@ class TaskQueueRealTimeStatisticsInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the TaskQueue resource. :ivar activity_statistics: The number of current Workers by Activity. @@ -33,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. @@ -50,7 +48,7 @@ def __init__( super().__init__(version) self.account_sid: Optional[str] = payload.get("account_sid") - self.activity_statistics: Optional[List[object]] = payload.get( + self.activity_statistics: Optional[List[Dict[str, object]]] = payload.get( "activity_statistics" ) self.longest_task_waiting_age: Optional[int] = deserialize.integer( @@ -147,6 +145,7 @@ def __repr__(self) -> str: class TaskQueueRealTimeStatisticsContext(InstanceContext): + def __init__(self, version: Version, workspace_sid: str, task_queue_sid: str): """ Initialize the TaskQueueRealTimeStatisticsContext @@ -183,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, @@ -209,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( @@ -233,6 +242,7 @@ def __repr__(self) -> str: class TaskQueueRealTimeStatisticsList(ListResource): + def __init__(self, version: Version, workspace_sid: str, task_queue_sid: str): """ Initialize the TaskQueueRealTimeStatisticsList 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 97fef95c2c..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 @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import datetime from typing import Any, Dict, Optional, Union from twilio.base import serialize, values @@ -23,7 +22,6 @@ class TaskQueueStatisticsInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the TaskQueue resource. :ivar cumulative: An object that contains the cumulative statistics for the TaskQueue. @@ -136,6 +134,7 @@ def __repr__(self) -> str: class TaskQueueStatisticsContext(InstanceContext): + def __init__(self, version: Version, workspace_sid: str, task_queue_sid: str): """ Initialize the TaskQueueStatisticsContext @@ -187,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, @@ -226,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( @@ -248,6 +257,7 @@ def __repr__(self) -> str: class TaskQueueStatisticsList(ListResource): + def __init__(self, version: Version, workspace_sid: str, task_queue_sid: str): """ Initialize the TaskQueueStatisticsList 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 091715e7dd..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 @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import datetime from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import serialize, values @@ -24,7 +23,6 @@ class TaskQueuesStatisticsInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the TaskQueue resource. :ivar cumulative: An object that contains the cumulative statistics for the TaskQueues. @@ -57,6 +55,7 @@ def __repr__(self) -> str: class TaskQueuesStatisticsPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> TaskQueuesStatisticsInstance: """ Build an instance of TaskQueuesStatisticsInstance @@ -77,6 +76,7 @@ def __repr__(self) -> str: class TaskQueuesStatisticsList(ListResource): + def __init__(self, version: Version, workspace_sid: str): """ Initialize the TaskQueuesStatisticsList @@ -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 0e12630f2c..38aede84bb 100644 --- a/twilio/rest/taskrouter/v1/workspace/worker/__init__.py +++ b/twilio/rest/taskrouter/v1/workspace/worker/__init__.py @@ -12,10 +12,9 @@ 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 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 @@ -38,7 +37,6 @@ class WorkerInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Worker resource. :ivar activity_name: The `friendly_name` of the Worker's current Activity. @@ -234,6 +232,7 @@ def __repr__(self) -> str: class WorkerContext(InstanceContext): + def __init__(self, version: Version, workspace_sid: str, sid: str): """ Initialize the WorkerContext @@ -269,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: @@ -285,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 ) @@ -297,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, @@ -317,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( @@ -348,19 +355,27 @@ def update( :returns: The updated WorkerInstance """ + data = values.of( { "ActivitySid": activity_sid, "Attributes": attributes, "FriendlyName": friendly_name, - "RejectPendingReservations": reject_pending_reservations, - } - ) - headers = values.of( - { - "If-Match": if_match, + "RejectPendingReservations": serialize.boolean_to_string( + reject_pending_reservations + ), } ) + 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 @@ -392,19 +407,27 @@ async def update_async( :returns: The updated WorkerInstance """ + data = values.of( { "ActivitySid": activity_sid, "Attributes": attributes, "FriendlyName": friendly_name, - "RejectPendingReservations": reject_pending_reservations, - } - ) - headers = values.of( - { - "If-Match": if_match, + "RejectPendingReservations": serialize.boolean_to_string( + reject_pending_reservations + ), } ) + 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 @@ -467,6 +490,7 @@ def __repr__(self) -> str: class WorkerPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> WorkerInstance: """ Build an instance of WorkerInstance @@ -487,6 +511,7 @@ def __repr__(self) -> str: class WorkerList(ListResource): + def __init__(self, version: Version, workspace_sid: str): """ Initialize the WorkerList @@ -522,6 +547,7 @@ def create( :returns: The created WorkerInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -529,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( @@ -555,6 +584,7 @@ async def create_async( :returns: The created WorkerInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -562,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( @@ -596,7 +629,7 @@ def stream( :param str activity_sid: The `activity_sid` of the Worker resources to read. :param str available: Whether to return only Worker resources that are available or unavailable. Can be `true`, `1`, or `yes` to return Worker resources that are available, and `false`, or any value returns the Worker resources that are not available. :param str friendly_name: The `friendly_name` of the Worker resources to read. - :param str target_workers_expression: Filter by Workers that would match an expression on a TaskQueue. This is helpful for debugging which Workers would match a potential queue. + :param str target_workers_expression: Filter by Workers that would match an expression. In addition to fields in the workers' attributes, the expression can include the following worker fields: `sid`, `friendly_name`, `activity_sid`, or `activity_name` :param str task_queue_name: The `friendly_name` of the TaskQueue that the Workers to read are eligible for. :param str task_queue_sid: The SID of the TaskQueue that the Workers to read are eligible for. :param str ordering: Sorting parameter for Workers @@ -647,7 +680,7 @@ async def stream_async( :param str activity_sid: The `activity_sid` of the Worker resources to read. :param str available: Whether to return only Worker resources that are available or unavailable. Can be `true`, `1`, or `yes` to return Worker resources that are available, and `false`, or any value returns the Worker resources that are not available. :param str friendly_name: The `friendly_name` of the Worker resources to read. - :param str target_workers_expression: Filter by Workers that would match an expression on a TaskQueue. This is helpful for debugging which Workers would match a potential queue. + :param str target_workers_expression: Filter by Workers that would match an expression. In addition to fields in the workers' attributes, the expression can include the following worker fields: `sid`, `friendly_name`, `activity_sid`, or `activity_name` :param str task_queue_name: The `friendly_name` of the TaskQueue that the Workers to read are eligible for. :param str task_queue_sid: The SID of the TaskQueue that the Workers to read are eligible for. :param str ordering: Sorting parameter for Workers @@ -697,7 +730,7 @@ def list( :param str activity_sid: The `activity_sid` of the Worker resources to read. :param str available: Whether to return only Worker resources that are available or unavailable. Can be `true`, `1`, or `yes` to return Worker resources that are available, and `false`, or any value returns the Worker resources that are not available. :param str friendly_name: The `friendly_name` of the Worker resources to read. - :param str target_workers_expression: Filter by Workers that would match an expression on a TaskQueue. This is helpful for debugging which Workers would match a potential queue. + :param str target_workers_expression: Filter by Workers that would match an expression. In addition to fields in the workers' attributes, the expression can include the following worker fields: `sid`, `friendly_name`, `activity_sid`, or `activity_name` :param str task_queue_name: The `friendly_name` of the TaskQueue that the Workers to read are eligible for. :param str task_queue_sid: The SID of the TaskQueue that the Workers to read are eligible for. :param str ordering: Sorting parameter for Workers @@ -747,7 +780,7 @@ async def list_async( :param str activity_sid: The `activity_sid` of the Worker resources to read. :param str available: Whether to return only Worker resources that are available or unavailable. Can be `true`, `1`, or `yes` to return Worker resources that are available, and `false`, or any value returns the Worker resources that are not available. :param str friendly_name: The `friendly_name` of the Worker resources to read. - :param str target_workers_expression: Filter by Workers that would match an expression on a TaskQueue. This is helpful for debugging which Workers would match a potential queue. + :param str target_workers_expression: Filter by Workers that would match an expression. In addition to fields in the workers' attributes, the expression can include the following worker fields: `sid`, `friendly_name`, `activity_sid`, or `activity_name` :param str task_queue_name: The `friendly_name` of the TaskQueue that the Workers to read are eligible for. :param str task_queue_sid: The SID of the TaskQueue that the Workers to read are eligible for. :param str ordering: Sorting parameter for Workers @@ -798,7 +831,7 @@ def page( :param activity_sid: The `activity_sid` of the Worker resources to read. :param available: Whether to return only Worker resources that are available or unavailable. Can be `true`, `1`, or `yes` to return Worker resources that are available, and `false`, or any value returns the Worker resources that are not available. :param friendly_name: The `friendly_name` of the Worker resources to read. - :param target_workers_expression: Filter by Workers that would match an expression on a TaskQueue. This is helpful for debugging which Workers would match a potential queue. + :param target_workers_expression: Filter by Workers that would match an expression. In addition to fields in the workers' attributes, the expression can include the following worker fields: `sid`, `friendly_name`, `activity_sid`, or `activity_name` :param task_queue_name: The `friendly_name` of the TaskQueue that the Workers to read are eligible for. :param task_queue_sid: The SID of the TaskQueue that the Workers to read are eligible for. :param ordering: Sorting parameter for Workers @@ -824,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( @@ -849,7 +888,7 @@ async def page_async( :param activity_sid: The `activity_sid` of the Worker resources to read. :param available: Whether to return only Worker resources that are available or unavailable. Can be `true`, `1`, or `yes` to return Worker resources that are available, and `false`, or any value returns the Worker resources that are not available. :param friendly_name: The `friendly_name` of the Worker resources to read. - :param target_workers_expression: Filter by Workers that would match an expression on a TaskQueue. This is helpful for debugging which Workers would match a potential queue. + :param target_workers_expression: Filter by Workers that would match an expression. In addition to fields in the workers' attributes, the expression can include the following worker fields: `sid`, `friendly_name`, `activity_sid`, or `activity_name` :param task_queue_name: The `friendly_name` of the TaskQueue that the Workers to read are eligible for. :param task_queue_sid: The SID of the TaskQueue that the Workers to read are eligible for. :param ordering: Sorting parameter for Workers @@ -875,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 e99705d669..7f24057806 100644 --- a/twilio/rest/taskrouter/v1/workspace/worker/reservation.py +++ b/twilio/rest/taskrouter/v1/workspace/worker/reservation.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class ReservationInstance(InstanceResource): + class CallStatus(object): INITIATED = "initiated" RINGING = "ringing" @@ -191,6 +191,7 @@ def update( post_work_activity_sid: Union[str, object] = values.unset, end_conference_on_customer_exit: Union[bool, object] = values.unset, beep_on_customer_entrance: Union[bool, object] = values.unset, + jitter_buffer_size: Union[str, object] = values.unset, ) -> "ReservationInstance": """ Update the ReservationInstance @@ -240,13 +241,14 @@ 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. :param post_work_activity_sid: The new worker activity SID after executing a Conference instruction. :param end_conference_on_customer_exit: Whether to end the conference when the customer leaves. :param beep_on_customer_entrance: Whether to play a notification beep when the customer joins. + :param jitter_buffer_size: The jitter buffer size for conference. Can be: `small`, `medium`, `large`, `off`. :returns: The updated ReservationInstance """ @@ -303,6 +305,7 @@ def update( post_work_activity_sid=post_work_activity_sid, end_conference_on_customer_exit=end_conference_on_customer_exit, beep_on_customer_entrance=beep_on_customer_entrance, + jitter_buffer_size=jitter_buffer_size, ) async def update_async( @@ -363,6 +366,7 @@ async def update_async( post_work_activity_sid: Union[str, object] = values.unset, end_conference_on_customer_exit: Union[bool, object] = values.unset, beep_on_customer_entrance: Union[bool, object] = values.unset, + jitter_buffer_size: Union[str, object] = values.unset, ) -> "ReservationInstance": """ Asynchronous coroutine to update the ReservationInstance @@ -412,13 +416,14 @@ 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. :param post_work_activity_sid: The new worker activity SID after executing a Conference instruction. :param end_conference_on_customer_exit: Whether to end the conference when the customer leaves. :param beep_on_customer_entrance: Whether to play a notification beep when the customer joins. + :param jitter_buffer_size: The jitter buffer size for conference. Can be: `small`, `medium`, `large`, `off`. :returns: The updated ReservationInstance """ @@ -475,6 +480,7 @@ async def update_async( post_work_activity_sid=post_work_activity_sid, end_conference_on_customer_exit=end_conference_on_customer_exit, beep_on_customer_entrance=beep_on_customer_entrance, + jitter_buffer_size=jitter_buffer_size, ) def __repr__(self) -> str: @@ -488,6 +494,7 @@ def __repr__(self) -> str: class ReservationContext(InstanceContext): + def __init__(self, version: Version, workspace_sid: str, worker_sid: str, sid: str): """ Initialize the ReservationContext @@ -517,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, @@ -538,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( @@ -609,6 +620,7 @@ def update( post_work_activity_sid: Union[str, object] = values.unset, end_conference_on_customer_exit: Union[bool, object] = values.unset, beep_on_customer_entrance: Union[bool, object] = values.unset, + jitter_buffer_size: Union[str, object] = values.unset, ) -> ReservationInstance: """ Update the ReservationInstance @@ -658,16 +670,18 @@ 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. :param post_work_activity_sid: The new worker activity SID after executing a Conference instruction. :param end_conference_on_customer_exit: Whether to end the conference when the customer leaves. :param beep_on_customer_entrance: Whether to play a notification beep when the customer joins. + :param jitter_buffer_size: The jitter buffer size for conference. Can be: `small`, `medium`, `large`, `off`. :returns: The updated ReservationInstance """ + data = values.of( { "ReservationStatus": reservation_status, @@ -685,9 +699,9 @@ def update( "CallTo": call_to, "CallUrl": call_url, "CallStatusCallbackUrl": call_status_callback_url, - "CallAccept": call_accept, + "CallAccept": serialize.boolean_to_string(call_accept), "RedirectCallSid": redirect_call_sid, - "RedirectAccept": redirect_accept, + "RedirectAccept": serialize.boolean_to_string(redirect_accept), "RedirectUrl": redirect_url, "To": to, "From": from_, @@ -697,14 +711,18 @@ def update( status_callback_event, lambda e: e ), "Timeout": timeout, - "Record": record, - "Muted": muted, + "Record": serialize.boolean_to_string(record), + "Muted": serialize.boolean_to_string(muted), "Beep": beep, - "StartConferenceOnEnter": start_conference_on_enter, - "EndConferenceOnExit": end_conference_on_exit, + "StartConferenceOnEnter": serialize.boolean_to_string( + start_conference_on_enter + ), + "EndConferenceOnExit": serialize.boolean_to_string( + end_conference_on_exit + ), "WaitUrl": wait_url, "WaitMethod": wait_method, - "EarlyMedia": early_media, + "EarlyMedia": serialize.boolean_to_string(early_media), "MaxParticipants": max_participants, "ConferenceStatusCallback": conference_status_callback, "ConferenceStatusCallbackMethod": conference_status_callback_method, @@ -725,15 +743,25 @@ def update( dequeue_status_callback_event, lambda e: e ), "PostWorkActivitySid": post_work_activity_sid, - "EndConferenceOnCustomerExit": end_conference_on_customer_exit, - "BeepOnCustomerEntrance": beep_on_customer_entrance, - } - ) - headers = values.of( - { - "If-Match": if_match, + "EndConferenceOnCustomerExit": serialize.boolean_to_string( + end_conference_on_customer_exit + ), + "BeepOnCustomerEntrance": serialize.boolean_to_string( + beep_on_customer_entrance + ), + "JitterBufferSize": jitter_buffer_size, } ) + 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 @@ -805,6 +833,7 @@ async def update_async( post_work_activity_sid: Union[str, object] = values.unset, end_conference_on_customer_exit: Union[bool, object] = values.unset, beep_on_customer_entrance: Union[bool, object] = values.unset, + jitter_buffer_size: Union[str, object] = values.unset, ) -> ReservationInstance: """ Asynchronous coroutine to update the ReservationInstance @@ -854,16 +883,18 @@ 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. :param post_work_activity_sid: The new worker activity SID after executing a Conference instruction. :param end_conference_on_customer_exit: Whether to end the conference when the customer leaves. :param beep_on_customer_entrance: Whether to play a notification beep when the customer joins. + :param jitter_buffer_size: The jitter buffer size for conference. Can be: `small`, `medium`, `large`, `off`. :returns: The updated ReservationInstance """ + data = values.of( { "ReservationStatus": reservation_status, @@ -881,9 +912,9 @@ async def update_async( "CallTo": call_to, "CallUrl": call_url, "CallStatusCallbackUrl": call_status_callback_url, - "CallAccept": call_accept, + "CallAccept": serialize.boolean_to_string(call_accept), "RedirectCallSid": redirect_call_sid, - "RedirectAccept": redirect_accept, + "RedirectAccept": serialize.boolean_to_string(redirect_accept), "RedirectUrl": redirect_url, "To": to, "From": from_, @@ -893,14 +924,18 @@ async def update_async( status_callback_event, lambda e: e ), "Timeout": timeout, - "Record": record, - "Muted": muted, + "Record": serialize.boolean_to_string(record), + "Muted": serialize.boolean_to_string(muted), "Beep": beep, - "StartConferenceOnEnter": start_conference_on_enter, - "EndConferenceOnExit": end_conference_on_exit, + "StartConferenceOnEnter": serialize.boolean_to_string( + start_conference_on_enter + ), + "EndConferenceOnExit": serialize.boolean_to_string( + end_conference_on_exit + ), "WaitUrl": wait_url, "WaitMethod": wait_method, - "EarlyMedia": early_media, + "EarlyMedia": serialize.boolean_to_string(early_media), "MaxParticipants": max_participants, "ConferenceStatusCallback": conference_status_callback, "ConferenceStatusCallbackMethod": conference_status_callback_method, @@ -921,15 +956,25 @@ async def update_async( dequeue_status_callback_event, lambda e: e ), "PostWorkActivitySid": post_work_activity_sid, - "EndConferenceOnCustomerExit": end_conference_on_customer_exit, - "BeepOnCustomerEntrance": beep_on_customer_entrance, - } - ) - headers = values.of( - { - "If-Match": if_match, + "EndConferenceOnCustomerExit": serialize.boolean_to_string( + end_conference_on_customer_exit + ), + "BeepOnCustomerEntrance": serialize.boolean_to_string( + beep_on_customer_entrance + ), + "JitterBufferSize": jitter_buffer_size, } ) + 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 @@ -954,6 +999,7 @@ def __repr__(self) -> str: class ReservationPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ReservationInstance: """ Build an instance of ReservationInstance @@ -977,6 +1023,7 @@ def __repr__(self) -> str: class ReservationList(ListResource): + def __init__(self, version: Version, workspace_sid: str, worker_sid: str): """ Initialize the ReservationList @@ -1143,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( @@ -1173,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 74c8531af6..6e3cc9c1dd 100644 --- a/twilio/rest/taskrouter/v1/workspace/worker/worker_channel.py +++ b/twilio/rest/taskrouter/v1/workspace/worker/worker_channel.py @@ -12,10 +12,9 @@ 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 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 @@ -24,7 +23,6 @@ class WorkerChannelInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Worker resource. :ivar assigned_tasks: The total number of Tasks assigned to Worker for the TaskChannel type. @@ -166,6 +164,7 @@ def __repr__(self) -> str: class WorkerChannelContext(InstanceContext): + def __init__(self, version: Version, workspace_sid: str, worker_sid: str, sid: str): """ Initialize the WorkerChannelContext @@ -197,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, @@ -218,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( @@ -244,17 +247,21 @@ def update( :returns: The updated WorkerChannelInstance """ + data = values.of( { "Capacity": capacity, - "Available": available, + "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( @@ -278,17 +285,21 @@ async def update_async( :returns: The updated WorkerChannelInstance """ + data = values.of( { "Capacity": capacity, - "Available": available, + "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( @@ -310,6 +321,7 @@ def __repr__(self) -> str: class WorkerChannelPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> WorkerChannelInstance: """ Build an instance of WorkerChannelInstance @@ -333,6 +345,7 @@ def __repr__(self) -> str: class WorkerChannelList(ListResource): + def __init__(self, version: Version, workspace_sid: str, worker_sid: str): """ Initialize the WorkerChannelList @@ -480,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( @@ -507,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 7724d5caf0..eea670aa7d 100644 --- a/twilio/rest/taskrouter/v1/workspace/worker/worker_statistics.py +++ b/twilio/rest/taskrouter/v1/workspace/worker/worker_statistics.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import datetime from typing import Any, Dict, Optional, Union from twilio.base import serialize, values @@ -23,7 +22,6 @@ class WorkerStatisticsInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Worker resource. :ivar cumulative: An object that contains the cumulative statistics for the Worker. @@ -128,6 +126,7 @@ def __repr__(self) -> str: class WorkerStatisticsContext(InstanceContext): + def __init__(self, version: Version, workspace_sid: str, worker_sid: str): """ Initialize the WorkerStatisticsContext @@ -176,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, @@ -212,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( @@ -234,6 +243,7 @@ def __repr__(self) -> str: class WorkerStatisticsList(ListResource): + def __init__(self, version: Version, workspace_sid: str, worker_sid: str): """ Initialize the WorkerStatisticsList 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 14310b05bb..48a78710e2 100644 --- a/twilio/rest/taskrouter/v1/workspace/worker/workers_cumulative_statistics.py +++ b/twilio/rest/taskrouter/v1/workspace/worker/workers_cumulative_statistics.py @@ -12,7 +12,6 @@ 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 @@ -23,7 +22,6 @@ class WorkersCumulativeStatisticsInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Worker resource. :ivar start_time: The beginning of the interval during which these statistics were calculated, in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. @@ -49,7 +47,7 @@ def __init__(self, version: Version, payload: Dict[str, Any], workspace_sid: str self.end_time: Optional[datetime] = deserialize.iso8601_datetime( payload.get("end_time") ) - self.activity_durations: Optional[List[object]] = payload.get( + self.activity_durations: Optional[List[Dict[str, object]]] = payload.get( "activity_durations" ) self.reservations_created: Optional[int] = deserialize.integer( @@ -154,6 +152,7 @@ def __repr__(self) -> str: class WorkersCumulativeStatisticsContext(InstanceContext): + def __init__(self, version: Version, workspace_sid: str): """ Initialize the WorkersCumulativeStatisticsContext @@ -198,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, @@ -233,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( @@ -256,6 +265,7 @@ def __repr__(self) -> str: class WorkersCumulativeStatisticsList(ListResource): + def __init__(self, version: Version, workspace_sid: str): """ Initialize the WorkersCumulativeStatisticsList 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 c59611dcfa..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 @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, List, Optional, Union from twilio.base import deserialize, values from twilio.base.instance_context import InstanceContext @@ -22,7 +21,6 @@ class WorkersRealTimeStatisticsInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Worker resource. :ivar activity_statistics: The number of current Workers by Activity. @@ -35,7 +33,7 @@ def __init__(self, version: Version, payload: Dict[str, Any], workspace_sid: str super().__init__(version) self.account_sid: Optional[str] = payload.get("account_sid") - self.activity_statistics: Optional[List[object]] = payload.get( + self.activity_statistics: Optional[List[Dict[str, object]]] = payload.get( "activity_statistics" ) self.total_workers: Optional[int] = deserialize.integer( @@ -105,6 +103,7 @@ def __repr__(self) -> str: class WorkersRealTimeStatisticsContext(InstanceContext): + def __init__(self, version: Version, workspace_sid: str): """ Initialize the WorkersRealTimeStatisticsContext @@ -139,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, @@ -164,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( @@ -187,6 +196,7 @@ def __repr__(self) -> str: class WorkersRealTimeStatisticsList(ListResource): + def __init__(self, version: Version, workspace_sid: str): """ Initialize the WorkersRealTimeStatisticsList diff --git a/twilio/rest/taskrouter/v1/workspace/worker/workers_statistics.py b/twilio/rest/taskrouter/v1/workspace/worker/workers_statistics.py index 58ef59969b..31c79ee6ba 100644 --- a/twilio/rest/taskrouter/v1/workspace/worker/workers_statistics.py +++ b/twilio/rest/taskrouter/v1/workspace/worker/workers_statistics.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import datetime from typing import Any, Dict, Optional, Union from twilio.base import serialize, values @@ -23,7 +22,6 @@ class WorkersStatisticsInstance(InstanceResource): - """ :ivar realtime: An object that contains the real-time statistics for the Worker. :ivar cumulative: An object that contains the cumulative statistics for the Worker. @@ -138,6 +136,7 @@ def __repr__(self) -> str: class WorkersStatisticsContext(InstanceContext): + def __init__(self, version: Version, workspace_sid: str): """ Initialize the WorkersStatisticsContext @@ -191,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, @@ -235,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( @@ -256,6 +265,7 @@ def __repr__(self) -> str: class WorkersStatisticsList(ListResource): + def __init__(self, version: Version, workspace_sid: str): """ Initialize the WorkersStatisticsList diff --git a/twilio/rest/taskrouter/v1/workspace/workflow/__init__.py b/twilio/rest/taskrouter/v1/workspace/workflow/__init__.py index 04cbba20b7..619ae1bce9 100644 --- a/twilio/rest/taskrouter/v1/workspace/workflow/__init__.py +++ b/twilio/rest/taskrouter/v1/workspace/workflow/__init__.py @@ -12,7 +12,6 @@ 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 @@ -33,7 +32,6 @@ class WorkflowInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Workflow resource. :ivar assignment_callback_url: The URL that we call when a task managed by the Workflow is assigned to a Worker. See Assignment Callback URL for more information. @@ -233,6 +231,7 @@ def __repr__(self) -> str: class WorkflowContext(InstanceContext): + def __init__(self, version: Version, workspace_sid: str, sid: str): """ Initialize the WorkflowContext @@ -263,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: """ @@ -275,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: @@ -288,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, @@ -308,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( @@ -341,6 +346,7 @@ def update( :returns: The updated WorkflowInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -351,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( @@ -386,6 +395,7 @@ async def update_async( :returns: The updated WorkflowInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -396,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( @@ -460,6 +473,7 @@ def __repr__(self) -> str: class WorkflowPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> WorkflowInstance: """ Build an instance of WorkflowInstance @@ -480,6 +494,7 @@ def __repr__(self) -> str: class WorkflowList(ListResource): + def __init__(self, version: Version, workspace_sid: str): """ Initialize the WorkflowList @@ -515,6 +530,7 @@ def create( :returns: The created WorkflowInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -524,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( @@ -554,6 +573,7 @@ async def create_async( :returns: The created WorkflowInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -563,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( @@ -716,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( @@ -746,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 28e557b8c2..d6d7c094cc 100644 --- a/twilio/rest/taskrouter/v1/workspace/workflow/workflow_cumulative_statistics.py +++ b/twilio/rest/taskrouter/v1/workspace/workflow/workflow_cumulative_statistics.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import datetime from typing import Any, Dict, Optional, Union from twilio.base import deserialize, serialize, values @@ -23,7 +22,6 @@ class WorkflowCumulativeStatisticsInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Workflow resource. :ivar avg_task_acceptance_time: The average time in seconds between Task creation and acceptance. @@ -206,6 +204,7 @@ def __repr__(self) -> str: class WorkflowCumulativeStatisticsContext(InstanceContext): + def __init__(self, version: Version, workspace_sid: str, workflow_sid: str): """ Initialize the WorkflowCumulativeStatisticsContext @@ -255,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, @@ -294,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( @@ -318,6 +327,7 @@ def __repr__(self) -> str: class WorkflowCumulativeStatisticsList(ListResource): + def __init__(self, version: Version, workspace_sid: str, workflow_sid: str): """ Initialize the WorkflowCumulativeStatisticsList 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 55a41f5d84..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 @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, Optional, Union from twilio.base import deserialize, values from twilio.base.instance_context import InstanceContext @@ -22,7 +21,6 @@ class WorkflowRealTimeStatisticsInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Workflow resource. :ivar longest_task_waiting_age: The age of the longest waiting Task. @@ -127,6 +125,7 @@ def __repr__(self) -> str: class WorkflowRealTimeStatisticsContext(InstanceContext): + def __init__(self, version: Version, workspace_sid: str, workflow_sid: str): """ Initialize the WorkflowRealTimeStatisticsContext @@ -163,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, @@ -189,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( @@ -213,6 +222,7 @@ def __repr__(self) -> str: class WorkflowRealTimeStatisticsList(ListResource): + def __init__(self, version: Version, workspace_sid: str, workflow_sid: str): """ Initialize the WorkflowRealTimeStatisticsList diff --git a/twilio/rest/taskrouter/v1/workspace/workflow/workflow_statistics.py b/twilio/rest/taskrouter/v1/workspace/workflow/workflow_statistics.py index 521b2921b7..e49bd32d6e 100644 --- a/twilio/rest/taskrouter/v1/workspace/workflow/workflow_statistics.py +++ b/twilio/rest/taskrouter/v1/workspace/workflow/workflow_statistics.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import datetime from typing import Any, Dict, Optional, Union from twilio.base import serialize, values @@ -23,7 +22,6 @@ class WorkflowStatisticsInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Workflow resource. :ivar cumulative: An object that contains the cumulative statistics for the Workflow. @@ -136,6 +134,7 @@ def __repr__(self) -> str: class WorkflowStatisticsContext(InstanceContext): + def __init__(self, version: Version, workspace_sid: str, workflow_sid: str): """ Initialize the WorkflowStatisticsContext @@ -187,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, @@ -226,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( @@ -248,6 +257,7 @@ def __repr__(self) -> str: class WorkflowStatisticsList(ListResource): + def __init__(self, version: Version, workspace_sid: str, workflow_sid: str): """ Initialize the WorkflowStatisticsList diff --git a/twilio/rest/taskrouter/v1/workspace/workspace_cumulative_statistics.py b/twilio/rest/taskrouter/v1/workspace/workspace_cumulative_statistics.py index 71e8a56a7a..3747b395d2 100644 --- a/twilio/rest/taskrouter/v1/workspace/workspace_cumulative_statistics.py +++ b/twilio/rest/taskrouter/v1/workspace/workspace_cumulative_statistics.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import datetime from typing import Any, Dict, Optional, Union from twilio.base import deserialize, serialize, values @@ -23,7 +22,6 @@ class WorkspaceCumulativeStatisticsInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Workspace resource. :ivar avg_task_acceptance_time: The average time in seconds between Task creation and acceptance. @@ -196,6 +194,7 @@ def __repr__(self) -> str: class WorkspaceCumulativeStatisticsContext(InstanceContext): + def __init__(self, version: Version, workspace_sid: str): """ Initialize the WorkspaceCumulativeStatisticsContext @@ -243,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, @@ -281,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( @@ -304,6 +313,7 @@ def __repr__(self) -> str: class WorkspaceCumulativeStatisticsList(ListResource): + def __init__(self, version: Version, workspace_sid: str): """ Initialize the WorkspaceCumulativeStatisticsList 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 d69600d7f2..923a94bf3a 100644 --- a/twilio/rest/taskrouter/v1/workspace/workspace_real_time_statistics.py +++ b/twilio/rest/taskrouter/v1/workspace/workspace_real_time_statistics.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, List, Optional, Union from twilio.base import deserialize, values from twilio.base.instance_context import InstanceContext @@ -22,7 +21,6 @@ class WorkspaceRealTimeStatisticsInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Workspace resource. :ivar activity_statistics: The number of current Workers by Activity. @@ -40,7 +38,7 @@ def __init__(self, version: Version, payload: Dict[str, Any], workspace_sid: str super().__init__(version) self.account_sid: Optional[str] = payload.get("account_sid") - self.activity_statistics: Optional[List[object]] = payload.get( + self.activity_statistics: Optional[List[Dict[str, object]]] = payload.get( "activity_statistics" ) self.longest_task_waiting_age: Optional[int] = deserialize.integer( @@ -125,6 +123,7 @@ def __repr__(self) -> str: class WorkspaceRealTimeStatisticsContext(InstanceContext): + def __init__(self, version: Version, workspace_sid: str): """ Initialize the WorkspaceRealTimeStatisticsContext @@ -159,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, @@ -184,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( @@ -207,6 +216,7 @@ def __repr__(self) -> str: class WorkspaceRealTimeStatisticsList(ListResource): + def __init__(self, version: Version, workspace_sid: str): """ Initialize the WorkspaceRealTimeStatisticsList diff --git a/twilio/rest/taskrouter/v1/workspace/workspace_statistics.py b/twilio/rest/taskrouter/v1/workspace/workspace_statistics.py index 443ee93903..b8414a5c6c 100644 --- a/twilio/rest/taskrouter/v1/workspace/workspace_statistics.py +++ b/twilio/rest/taskrouter/v1/workspace/workspace_statistics.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import datetime from typing import Any, Dict, Optional, Union from twilio.base import serialize, values @@ -23,7 +22,6 @@ class WorkspaceStatisticsInstance(InstanceResource): - """ :ivar realtime: An object that contains the real-time statistics for the Workspace. :ivar cumulative: An object that contains the cumulative statistics for the Workspace. @@ -126,6 +124,7 @@ def __repr__(self) -> str: class WorkspaceStatisticsContext(InstanceContext): + def __init__(self, version: Version, workspace_sid: str): """ Initialize the WorkspaceStatisticsContext @@ -171,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, @@ -209,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( @@ -230,6 +239,7 @@ def __repr__(self) -> str: class WorkspaceStatisticsList(ListResource): + def __init__(self, version: Version, workspace_sid: str): """ Initialize the WorkspaceStatisticsList diff --git a/twilio/rest/trunking/TrunkingBase.py b/twilio/rest/trunking/TrunkingBase.py index 627790454d..bed8f9a2a9 100644 --- a/twilio/rest/trunking/TrunkingBase.py +++ b/twilio/rest/trunking/TrunkingBase.py @@ -17,6 +17,7 @@ class TrunkingBase(Domain): + def __init__(self, twilio: Client): """ Initialize the Trunking Domain diff --git a/twilio/rest/trunking/v1/__init__.py b/twilio/rest/trunking/v1/__init__.py index 89dc5c1087..af530b97c7 100644 --- a/twilio/rest/trunking/v1/__init__.py +++ b/twilio/rest/trunking/v1/__init__.py @@ -19,6 +19,7 @@ class V1(Version): + def __init__(self, domain: Domain): """ Initialize the V1 version of Trunking diff --git a/twilio/rest/trunking/v1/trunk/__init__.py b/twilio/rest/trunking/v1/trunk/__init__.py index e7a0aa5cfd..8d6898fe14 100644 --- a/twilio/rest/trunking/v1/trunk/__init__.py +++ b/twilio/rest/trunking/v1/trunk/__init__.py @@ -12,10 +12,9 @@ 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 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 @@ -29,6 +28,7 @@ class TrunkInstance(InstanceResource): + class TransferCallerId(object): FROM_TRANSFEREE = "from-transferee" FROM_TRANSFEROR = "from-transferor" @@ -50,6 +50,7 @@ class TransferSetting(object): :ivar transfer_caller_id: :ivar cnam_lookup_enabled: Whether Caller ID Name (CNAM) lookup is enabled for the trunk. If enabled, all inbound calls to the SIP Trunk from the United States and Canada automatically perform a CNAM Lookup and display Caller ID data on your phone. See [CNAM Lookups](https://www.twilio.com/docs/sip-trunking#CNAM) for more information. :ivar auth_type: The types of authentication mapped to the domain. Can be: `IP_ACL` and `CREDENTIAL_LIST`. If both are mapped, the values are returned in a comma delimited list. If empty, the domain will not receive any traffic. + :ivar symmetric_rtp_enabled: Whether Symmetric RTP is enabled for the trunk. When Symmetric RTP is disabled, Twilio will send RTP to the destination negotiated in the SDP. Disabling Symmetric RTP is considered to be more secure and therefore recommended. See [Symmetric RTP](https://www.twilio.com/docs/sip-trunking#symmetric-rtp) for more information. :ivar auth_type_set: Reserved. :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. @@ -75,11 +76,14 @@ def __init__( self.transfer_mode: Optional["TrunkInstance.TransferSetting"] = payload.get( "transfer_mode" ) - self.transfer_caller_id: Optional[ - "TrunkInstance.TransferCallerId" - ] = payload.get("transfer_caller_id") + self.transfer_caller_id: Optional["TrunkInstance.TransferCallerId"] = ( + payload.get("transfer_caller_id") + ) self.cnam_lookup_enabled: Optional[bool] = payload.get("cnam_lookup_enabled") self.auth_type: Optional[str] = payload.get("auth_type") + self.symmetric_rtp_enabled: Optional[bool] = payload.get( + "symmetric_rtp_enabled" + ) self.auth_type_set: Optional[List[str]] = payload.get("auth_type_set") self.date_created: Optional[datetime] = deserialize.iso8601_datetime( payload.get("date_created") @@ -269,6 +273,7 @@ def __repr__(self) -> str: class TrunkContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the TrunkContext @@ -297,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: """ @@ -309,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) -> TrunkInstance: @@ -322,10 +329,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, @@ -341,9 +349,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( @@ -379,6 +390,7 @@ def update( :returns: The updated TrunkInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -386,16 +398,19 @@ def update( "DisasterRecoveryUrl": disaster_recovery_url, "DisasterRecoveryMethod": disaster_recovery_method, "TransferMode": transfer_mode, - "Secure": secure, - "CnamLookupEnabled": cnam_lookup_enabled, + "Secure": serialize.boolean_to_string(secure), + "CnamLookupEnabled": serialize.boolean_to_string(cnam_lookup_enabled), "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"]) @@ -427,6 +442,7 @@ async def update_async( :returns: The updated TrunkInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -434,16 +450,19 @@ async def update_async( "DisasterRecoveryUrl": disaster_recovery_url, "DisasterRecoveryMethod": disaster_recovery_method, "TransferMode": transfer_mode, - "Secure": secure, - "CnamLookupEnabled": cnam_lookup_enabled, + "Secure": serialize.boolean_to_string(secure), + "CnamLookupEnabled": serialize.boolean_to_string(cnam_lookup_enabled), "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"]) @@ -519,6 +538,7 @@ def __repr__(self) -> str: class TrunkPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> TrunkInstance: """ Build an instance of TrunkInstance @@ -537,6 +557,7 @@ def __repr__(self) -> str: class TrunkList(ListResource): + def __init__(self, version: Version): """ Initialize the TrunkList @@ -575,6 +596,7 @@ def create( :returns: The created TrunkInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -582,16 +604,19 @@ def create( "DisasterRecoveryUrl": disaster_recovery_url, "DisasterRecoveryMethod": disaster_recovery_method, "TransferMode": transfer_mode, - "Secure": secure, - "CnamLookupEnabled": cnam_lookup_enabled, + "Secure": serialize.boolean_to_string(secure), + "CnamLookupEnabled": serialize.boolean_to_string(cnam_lookup_enabled), "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) @@ -623,6 +648,7 @@ async def create_async( :returns: The created TrunkInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -630,16 +656,19 @@ async def create_async( "DisasterRecoveryUrl": disaster_recovery_url, "DisasterRecoveryMethod": disaster_recovery_method, "TransferMode": transfer_mode, - "Secure": secure, - "CnamLookupEnabled": cnam_lookup_enabled, + "Secure": serialize.boolean_to_string(secure), + "CnamLookupEnabled": serialize.boolean_to_string(cnam_lookup_enabled), "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) @@ -771,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 TrunkPage(self._version, response) async def page_async( @@ -798,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 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 805d66260d..09ffc99260 100644 --- a/twilio/rest/trunking/v1/trunk/credential_list.py +++ b/twilio/rest/trunking/v1/trunk/credential_list.py @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class CredentialListInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the CredentialList resource. :ivar sid: The unique string that we created to identify the CredentialList resource. @@ -125,6 +123,7 @@ def __repr__(self) -> str: class CredentialListContext(InstanceContext): + def __init__(self, version: Version, trunk_sid: str, sid: str): """ Initialize the CredentialListContext @@ -149,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: """ @@ -161,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: @@ -174,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, @@ -194,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( @@ -217,6 +222,7 @@ def __repr__(self) -> str: class CredentialListPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> CredentialListInstance: """ Build an instance of CredentialListInstance @@ -237,6 +243,7 @@ def __repr__(self) -> str: class CredentialListList(ListResource): + def __init__(self, version: Version, trunk_sid: str): """ Initialize the CredentialListList @@ -261,16 +268,20 @@ def create(self, credential_list_sid: str) -> CredentialListInstance: :returns: The created CredentialListInstance """ + data = values.of( { "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( @@ -285,16 +296,20 @@ async def create_async(self, credential_list_sid: str) -> CredentialListInstance :returns: The created CredentialListInstance """ + data = values.of( { "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( @@ -428,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( @@ -455,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 e528e0b1c3..ec5a59de69 100644 --- a/twilio/rest/trunking/v1/trunk/ip_access_control_list.py +++ b/twilio/rest/trunking/v1/trunk/ip_access_control_list.py @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class IpAccessControlListInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the IpAccessControlList resource. :ivar sid: The unique string that we created to identify the IpAccessControlList resource. @@ -125,6 +123,7 @@ def __repr__(self) -> str: class IpAccessControlListContext(InstanceContext): + def __init__(self, version: Version, trunk_sid: str, sid: str): """ Initialize the IpAccessControlListContext @@ -151,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: """ @@ -163,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: @@ -176,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, @@ -196,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( @@ -219,6 +224,7 @@ def __repr__(self) -> str: class IpAccessControlListPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> IpAccessControlListInstance: """ Build an instance of IpAccessControlListInstance @@ -239,6 +245,7 @@ def __repr__(self) -> str: class IpAccessControlListList(ListResource): + def __init__(self, version: Version, trunk_sid: str): """ Initialize the IpAccessControlListList @@ -263,16 +270,20 @@ def create(self, ip_access_control_list_sid: str) -> IpAccessControlListInstance :returns: The created IpAccessControlListInstance """ + data = values.of( { "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( @@ -289,16 +300,20 @@ async def create_async( :returns: The created IpAccessControlListInstance """ + data = values.of( { "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( @@ -432,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( @@ -459,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 79dca9387b..082fa34beb 100644 --- a/twilio/rest/trunking/v1/trunk/origination_url.py +++ b/twilio/rest/trunking/v1/trunk/origination_url.py @@ -12,10 +12,9 @@ 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 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 @@ -24,7 +23,6 @@ class OriginationUrlInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the OriginationUrl resource. :ivar sid: The unique string that we created to identify the OriginationUrl resource. @@ -187,6 +185,7 @@ def __repr__(self) -> str: class OriginationUrlContext(InstanceContext): + def __init__(self, version: Version, trunk_sid: str, sid: str): """ Initialize the OriginationUrlContext @@ -211,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: """ @@ -223,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: @@ -236,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, @@ -256,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( @@ -287,20 +292,24 @@ def update( :returns: The updated OriginationUrlInstance """ + data = values.of( { "Weight": weight, "Priority": priority, - "Enabled": enabled, + "Enabled": serialize.boolean_to_string(enabled), "FriendlyName": friendly_name, "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( @@ -329,20 +338,24 @@ async def update_async( :returns: The updated OriginationUrlInstance """ + data = values.of( { "Weight": weight, "Priority": priority, - "Enabled": enabled, + "Enabled": serialize.boolean_to_string(enabled), "FriendlyName": friendly_name, "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( @@ -363,6 +376,7 @@ def __repr__(self) -> str: class OriginationUrlPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> OriginationUrlInstance: """ Build an instance of OriginationUrlInstance @@ -383,6 +397,7 @@ def __repr__(self) -> str: class OriginationUrlList(ListResource): + def __init__(self, version: Version, trunk_sid: str): """ Initialize the OriginationUrlList @@ -418,20 +433,24 @@ def create( :returns: The created OriginationUrlInstance """ + data = values.of( { "Weight": weight, "Priority": priority, - "Enabled": enabled, + "Enabled": serialize.boolean_to_string(enabled), "FriendlyName": friendly_name, "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( @@ -457,20 +476,24 @@ async def create_async( :returns: The created OriginationUrlInstance """ + data = values.of( { "Weight": weight, "Priority": priority, - "Enabled": enabled, + "Enabled": serialize.boolean_to_string(enabled), "FriendlyName": friendly_name, "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( @@ -604,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( @@ -631,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 98f53c408f..a7c3dbe20d 100644 --- a/twilio/rest/trunking/v1/trunk/phone_number.py +++ b/twilio/rest/trunking/v1/trunk/phone_number.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class PhoneNumberInstance(InstanceResource): + class AddressRequirement(object): NONE = "none" ANY = "any" @@ -174,6 +174,7 @@ def __repr__(self) -> str: class PhoneNumberContext(InstanceContext): + def __init__(self, version: Version, trunk_sid: str, sid: str): """ Initialize the PhoneNumberContext @@ -198,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: """ @@ -210,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: @@ -223,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, @@ -243,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( @@ -266,6 +273,7 @@ def __repr__(self) -> str: class PhoneNumberPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> PhoneNumberInstance: """ Build an instance of PhoneNumberInstance @@ -286,6 +294,7 @@ def __repr__(self) -> str: class PhoneNumberList(ListResource): + def __init__(self, version: Version, trunk_sid: str): """ Initialize the PhoneNumberList @@ -310,16 +319,20 @@ def create(self, phone_number_sid: str) -> PhoneNumberInstance: :returns: The created PhoneNumberInstance """ + data = values.of( { "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( @@ -334,16 +347,20 @@ async def create_async(self, phone_number_sid: str) -> PhoneNumberInstance: :returns: The created PhoneNumberInstance """ + data = values.of( { "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( @@ -477,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( @@ -504,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 02d9ca290d..0507662f24 100644 --- a/twilio/rest/trunking/v1/trunk/recording.py +++ b/twilio/rest/trunking/v1/trunk/recording.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, Optional, Union from twilio.base import values from twilio.base.instance_context import InstanceContext @@ -22,6 +21,7 @@ class RecordingInstance(InstanceResource): + class RecordingMode(object): DO_NOT_RECORD = "do-not-record" RECORD_FROM_RINGING = "record-from-ringing" @@ -129,6 +129,7 @@ def __repr__(self) -> str: class RecordingContext(InstanceContext): + def __init__(self, version: Version, trunk_sid: str): """ Initialize the RecordingContext @@ -152,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, @@ -171,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( @@ -195,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( @@ -225,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( @@ -253,6 +266,7 @@ def __repr__(self) -> str: class RecordingList(ListResource): + def __init__(self, version: Version, trunk_sid: str): """ Initialize the RecordingList diff --git a/twilio/rest/trusthub/TrusthubBase.py b/twilio/rest/trusthub/TrusthubBase.py index f58cc7cfec..97fd32f9b7 100644 --- a/twilio/rest/trusthub/TrusthubBase.py +++ b/twilio/rest/trusthub/TrusthubBase.py @@ -17,6 +17,7 @@ class TrusthubBase(Domain): + def __init__(self, twilio: Client): """ Initialize the Trusthub Domain diff --git a/twilio/rest/trusthub/v1/__init__.py b/twilio/rest/trusthub/v1/__init__.py index 76692aee0d..596c5ea758 100644 --- a/twilio/rest/trusthub/v1/__init__.py +++ b/twilio/rest/trusthub/v1/__init__.py @@ -15,6 +15,13 @@ from typing import Optional from twilio.base.version import Version from twilio.base.domain import Domain +from twilio.rest.trusthub.v1.compliance_inquiries import ComplianceInquiriesList +from twilio.rest.trusthub.v1.compliance_registration_inquiries import ( + ComplianceRegistrationInquiriesList, +) +from twilio.rest.trusthub.v1.compliance_tollfree_inquiries import ( + ComplianceTollfreeInquiriesList, +) from twilio.rest.trusthub.v1.customer_profiles import CustomerProfilesList from twilio.rest.trusthub.v1.end_user import EndUserList from twilio.rest.trusthub.v1.end_user_type import EndUserTypeList @@ -25,6 +32,7 @@ class V1(Version): + def __init__(self, domain: Domain): """ Initialize the V1 version of Trusthub @@ -32,6 +40,13 @@ def __init__(self, domain: Domain): :param domain: The Twilio.trusthub domain """ super().__init__(domain, "v1") + self._compliance_inquiries: Optional[ComplianceInquiriesList] = None + self._compliance_registration_inquiries: Optional[ + ComplianceRegistrationInquiriesList + ] = None + self._compliance_tollfree_inquiries: Optional[ + ComplianceTollfreeInquiriesList + ] = None self._customer_profiles: Optional[CustomerProfilesList] = None self._end_users: Optional[EndUserList] = None self._end_user_types: Optional[EndUserTypeList] = None @@ -40,6 +55,26 @@ def __init__(self, domain: Domain): self._supporting_document_types: Optional[SupportingDocumentTypeList] = None self._trust_products: Optional[TrustProductsList] = None + @property + def compliance_inquiries(self) -> ComplianceInquiriesList: + if self._compliance_inquiries is None: + self._compliance_inquiries = ComplianceInquiriesList(self) + return self._compliance_inquiries + + @property + def compliance_registration_inquiries(self) -> ComplianceRegistrationInquiriesList: + if self._compliance_registration_inquiries is None: + self._compliance_registration_inquiries = ( + ComplianceRegistrationInquiriesList(self) + ) + return self._compliance_registration_inquiries + + @property + def compliance_tollfree_inquiries(self) -> ComplianceTollfreeInquiriesList: + if self._compliance_tollfree_inquiries is None: + self._compliance_tollfree_inquiries = ComplianceTollfreeInquiriesList(self) + return self._compliance_tollfree_inquiries + @property def customer_profiles(self) -> CustomerProfilesList: if self._customer_profiles is None: diff --git a/twilio/rest/trusthub/v1/compliance_inquiries.py b/twilio/rest/trusthub/v1/compliance_inquiries.py new file mode 100644 index 0000000000..3c1abd596a --- /dev/null +++ b/twilio/rest/trusthub/v1/compliance_inquiries.py @@ -0,0 +1,304 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Trusthub + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from typing import Any, Dict, Optional, 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 ComplianceInquiriesInstance(InstanceResource): + """ + :ivar inquiry_id: The unique ID used to start an embedded compliance registration session. + :ivar inquiry_session_token: The session token used to start an embedded compliance registration session. + :ivar customer_id: The CustomerID matching the Customer Profile that should be resumed or resubmitted for editing. + :ivar url: The URL of this resource. + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + customer_id: Optional[str] = None, + ): + super().__init__(version) + + self.inquiry_id: Optional[str] = payload.get("inquiry_id") + self.inquiry_session_token: Optional[str] = payload.get("inquiry_session_token") + self.customer_id: Optional[str] = payload.get("customer_id") + self.url: Optional[str] = payload.get("url") + + self._solution = { + "customer_id": customer_id or self.customer_id, + } + self._context: Optional[ComplianceInquiriesContext] = None + + @property + def _proxy(self) -> "ComplianceInquiriesContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: ComplianceInquiriesContext for this ComplianceInquiriesInstance + """ + if self._context is None: + self._context = ComplianceInquiriesContext( + self._version, + customer_id=self._solution["customer_id"], + ) + return self._context + + 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, 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: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class ComplianceInquiriesContext(InstanceContext): + + def __init__(self, version: Version, customer_id: str): + """ + Initialize the ComplianceInquiriesContext + + :param version: Version that contains the resource + :param customer_id: The unique CustomerId matching the Customer Profile/Compliance Inquiry that should be resumed or resubmitted. This value will have been returned by the initial Compliance Inquiry creation call. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "customer_id": customer_id, + } + self._uri = "/ComplianceInquiries/Customers/{customer_id}/Initialize".format( + **self._solution + ) + + 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, headers=headers + ) + + return ComplianceInquiriesInstance( + self._version, payload, customer_id=self._solution["customer_id"] + ) + + async def update_async( + 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, headers=headers + ) + + return ComplianceInquiriesInstance( + self._version, payload, customer_id=self._solution["customer_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 ComplianceInquiriesList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the ComplianceInquiriesList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/ComplianceInquiries/Customers/Initialize" + + 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 + """ + + data = values.of( + { + "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, headers=headers + ) + + return ComplianceInquiriesInstance(self._version, payload) + + 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 + """ + + data = values.of( + { + "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, headers=headers + ) + + return ComplianceInquiriesInstance(self._version, payload) + + def get(self, customer_id: str) -> ComplianceInquiriesContext: + """ + Constructs a ComplianceInquiriesContext + + :param customer_id: The unique CustomerId matching the Customer Profile/Compliance Inquiry that should be resumed or resubmitted. This value will have been returned by the initial Compliance Inquiry creation call. + """ + return ComplianceInquiriesContext(self._version, customer_id=customer_id) + + def __call__(self, customer_id: str) -> ComplianceInquiriesContext: + """ + Constructs a ComplianceInquiriesContext + + :param customer_id: The unique CustomerId matching the Customer Profile/Compliance Inquiry that should be resumed or resubmitted. This value will have been returned by the initial Compliance Inquiry creation call. + """ + return ComplianceInquiriesContext(self._version, customer_id=customer_id) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/trusthub/v1/compliance_registration_inquiries.py b/twilio/rest/trusthub/v1/compliance_registration_inquiries.py new file mode 100644 index 0000000000..eccd1ac8cf --- /dev/null +++ b/twilio/rest/trusthub/v1/compliance_registration_inquiries.py @@ -0,0 +1,579 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Trusthub + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from typing import Any, Dict, Optional, 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 + + +class ComplianceRegistrationInquiriesInstance(InstanceResource): + + class BusinessIdentityType(object): + DIRECT_CUSTOMER = "direct_customer" + ISV_RESELLER_OR_PARTNER = "isv_reseller_or_partner" + UNKNOWN = "unknown" + + class BusinessRegistrationAuthority(object): + UK_CRN = "UK:CRN" + US_EIN = "US:EIN" + CA_CBN = "CA:CBN" + AU_ACN = "AU:ACN" + OTHER = "Other" + + class EndUserType(object): + INDIVIDUAL = "Individual" + BUSINESS = "Business" + + class PhoneNumberType(object): + LOCAL = "local" + NATIONAL = "national" + MOBILE = "mobile" + TOLL_FREE = "toll-free" + + """ + :ivar inquiry_id: The unique ID used to start an embedded compliance registration session. + :ivar inquiry_session_token: The session token used to start an embedded compliance registration session. + :ivar registration_id: The RegistrationId matching the Registration Profile that should be resumed or resubmitted for editing. + :ivar url: The URL of this resource. + """ + + 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") + self.inquiry_session_token: Optional[str] = payload.get("inquiry_session_token") + 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 + + :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): + + def __init__(self, version: Version): + """ + Initialize the ComplianceRegistrationInquiriesList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = ( + "/ComplianceInquiries/Registration/RegulatoryCompliance/GB/Initialize" + ) + + def create( + self, + end_user_type: "ComplianceRegistrationInquiriesInstance.EndUserType", + phone_number_type: "ComplianceRegistrationInquiriesInstance.PhoneNumberType", + business_identity_type: Union[ + "ComplianceRegistrationInquiriesInstance.BusinessIdentityType", object + ] = values.unset, + business_registration_authority: Union[ + "ComplianceRegistrationInquiriesInstance.BusinessRegistrationAuthority", + object, + ] = values.unset, + business_legal_name: Union[str, object] = values.unset, + notification_email: Union[str, object] = values.unset, + accepted_notification_receipt: Union[bool, object] = values.unset, + business_registration_number: Union[str, object] = values.unset, + business_website_url: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + authorized_representative1_first_name: Union[str, object] = values.unset, + authorized_representative1_last_name: Union[str, object] = values.unset, + authorized_representative1_phone: Union[str, object] = values.unset, + authorized_representative1_email: Union[str, object] = values.unset, + authorized_representative1_date_of_birth: Union[str, object] = values.unset, + address_street: Union[str, object] = values.unset, + address_street_secondary: Union[str, object] = values.unset, + address_city: Union[str, object] = values.unset, + address_subdivision: Union[str, object] = values.unset, + address_postal_code: Union[str, object] = values.unset, + address_country_code: Union[str, object] = values.unset, + emergency_address_street: Union[str, object] = values.unset, + emergency_address_street_secondary: Union[str, object] = values.unset, + emergency_address_city: Union[str, object] = values.unset, + emergency_address_subdivision: Union[str, object] = values.unset, + emergency_address_postal_code: Union[str, object] = values.unset, + emergency_address_country_code: Union[str, object] = values.unset, + use_address_as_emergency_address: Union[bool, object] = values.unset, + file_name: Union[str, object] = values.unset, + file: Union[str, object] = values.unset, + first_name: Union[str, object] = values.unset, + last_name: Union[str, object] = values.unset, + date_of_birth: Union[str, object] = values.unset, + individual_email: Union[str, object] = values.unset, + individual_phone: Union[str, object] = values.unset, + 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 + + :param end_user_type: + :param phone_number_type: + :param business_identity_type: + :param business_registration_authority: + :param business_legal_name: he name of the business or organization using the Tollfree number. + :param notification_email: he email address to receive the notification about the verification result. + :param accepted_notification_receipt: The email address to receive the notification about the verification result. + :param business_registration_number: Business registration number of the business + :param business_website_url: The URL of the business website + :param friendly_name: Friendly name for your business information + :param authorized_representative1_first_name: First name of the authorized representative + :param authorized_representative1_last_name: Last name of the authorized representative + :param authorized_representative1_phone: Phone number of the authorized representative + :param authorized_representative1_email: Email address of the authorized representative + :param authorized_representative1_date_of_birth: Birthdate of the authorized representative + :param address_street: Street address of the business + :param address_street_secondary: Street address of the business + :param address_city: City of the business + :param address_subdivision: State or province of the business + :param address_postal_code: Postal code of the business + :param address_country_code: Country code of the business + :param emergency_address_street: Street address of the business + :param emergency_address_street_secondary: Street address of the business + :param emergency_address_city: City of the business + :param emergency_address_subdivision: State or province of the business + :param emergency_address_postal_code: Postal code of the business + :param emergency_address_country_code: Country code of the business + :param use_address_as_emergency_address: Use the business address as the emergency address + :param file_name: The name of the verification document to upload + :param file: The verification document to upload + :param first_name: The first name of the Individual User. + :param last_name: The last name of the Individual User. + :param date_of_birth: The date of birth of the Individual User. + :param individual_email: The email address of the Individual User. + :param individual_phone: The phone number of the Individual User. + :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 + """ + + data = values.of( + { + "EndUserType": end_user_type, + "PhoneNumberType": phone_number_type, + "BusinessIdentityType": business_identity_type, + "BusinessRegistrationAuthority": business_registration_authority, + "BusinessLegalName": business_legal_name, + "NotificationEmail": notification_email, + "AcceptedNotificationReceipt": serialize.boolean_to_string( + accepted_notification_receipt + ), + "BusinessRegistrationNumber": business_registration_number, + "BusinessWebsiteUrl": business_website_url, + "FriendlyName": friendly_name, + "AuthorizedRepresentative1FirstName": authorized_representative1_first_name, + "AuthorizedRepresentative1LastName": authorized_representative1_last_name, + "AuthorizedRepresentative1Phone": authorized_representative1_phone, + "AuthorizedRepresentative1Email": authorized_representative1_email, + "AuthorizedRepresentative1DateOfBirth": authorized_representative1_date_of_birth, + "AddressStreet": address_street, + "AddressStreetSecondary": address_street_secondary, + "AddressCity": address_city, + "AddressSubdivision": address_subdivision, + "AddressPostalCode": address_postal_code, + "AddressCountryCode": address_country_code, + "EmergencyAddressStreet": emergency_address_street, + "EmergencyAddressStreetSecondary": emergency_address_street_secondary, + "EmergencyAddressCity": emergency_address_city, + "EmergencyAddressSubdivision": emergency_address_subdivision, + "EmergencyAddressPostalCode": emergency_address_postal_code, + "EmergencyAddressCountryCode": emergency_address_country_code, + "UseAddressAsEmergencyAddress": serialize.boolean_to_string( + use_address_as_emergency_address + ), + "FileName": file_name, + "File": file, + "FirstName": first_name, + "LastName": last_name, + "DateOfBirth": date_of_birth, + "IndividualEmail": individual_email, + "IndividualPhone": individual_phone, + "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, headers=headers + ) + + return ComplianceRegistrationInquiriesInstance(self._version, payload) + + async def create_async( + self, + end_user_type: "ComplianceRegistrationInquiriesInstance.EndUserType", + phone_number_type: "ComplianceRegistrationInquiriesInstance.PhoneNumberType", + business_identity_type: Union[ + "ComplianceRegistrationInquiriesInstance.BusinessIdentityType", object + ] = values.unset, + business_registration_authority: Union[ + "ComplianceRegistrationInquiriesInstance.BusinessRegistrationAuthority", + object, + ] = values.unset, + business_legal_name: Union[str, object] = values.unset, + notification_email: Union[str, object] = values.unset, + accepted_notification_receipt: Union[bool, object] = values.unset, + business_registration_number: Union[str, object] = values.unset, + business_website_url: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + authorized_representative1_first_name: Union[str, object] = values.unset, + authorized_representative1_last_name: Union[str, object] = values.unset, + authorized_representative1_phone: Union[str, object] = values.unset, + authorized_representative1_email: Union[str, object] = values.unset, + authorized_representative1_date_of_birth: Union[str, object] = values.unset, + address_street: Union[str, object] = values.unset, + address_street_secondary: Union[str, object] = values.unset, + address_city: Union[str, object] = values.unset, + address_subdivision: Union[str, object] = values.unset, + address_postal_code: Union[str, object] = values.unset, + address_country_code: Union[str, object] = values.unset, + emergency_address_street: Union[str, object] = values.unset, + emergency_address_street_secondary: Union[str, object] = values.unset, + emergency_address_city: Union[str, object] = values.unset, + emergency_address_subdivision: Union[str, object] = values.unset, + emergency_address_postal_code: Union[str, object] = values.unset, + emergency_address_country_code: Union[str, object] = values.unset, + use_address_as_emergency_address: Union[bool, object] = values.unset, + file_name: Union[str, object] = values.unset, + file: Union[str, object] = values.unset, + first_name: Union[str, object] = values.unset, + last_name: Union[str, object] = values.unset, + date_of_birth: Union[str, object] = values.unset, + individual_email: Union[str, object] = values.unset, + individual_phone: Union[str, object] = values.unset, + 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 + + :param end_user_type: + :param phone_number_type: + :param business_identity_type: + :param business_registration_authority: + :param business_legal_name: he name of the business or organization using the Tollfree number. + :param notification_email: he email address to receive the notification about the verification result. + :param accepted_notification_receipt: The email address to receive the notification about the verification result. + :param business_registration_number: Business registration number of the business + :param business_website_url: The URL of the business website + :param friendly_name: Friendly name for your business information + :param authorized_representative1_first_name: First name of the authorized representative + :param authorized_representative1_last_name: Last name of the authorized representative + :param authorized_representative1_phone: Phone number of the authorized representative + :param authorized_representative1_email: Email address of the authorized representative + :param authorized_representative1_date_of_birth: Birthdate of the authorized representative + :param address_street: Street address of the business + :param address_street_secondary: Street address of the business + :param address_city: City of the business + :param address_subdivision: State or province of the business + :param address_postal_code: Postal code of the business + :param address_country_code: Country code of the business + :param emergency_address_street: Street address of the business + :param emergency_address_street_secondary: Street address of the business + :param emergency_address_city: City of the business + :param emergency_address_subdivision: State or province of the business + :param emergency_address_postal_code: Postal code of the business + :param emergency_address_country_code: Country code of the business + :param use_address_as_emergency_address: Use the business address as the emergency address + :param file_name: The name of the verification document to upload + :param file: The verification document to upload + :param first_name: The first name of the Individual User. + :param last_name: The last name of the Individual User. + :param date_of_birth: The date of birth of the Individual User. + :param individual_email: The email address of the Individual User. + :param individual_phone: The phone number of the Individual User. + :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 + """ + + data = values.of( + { + "EndUserType": end_user_type, + "PhoneNumberType": phone_number_type, + "BusinessIdentityType": business_identity_type, + "BusinessRegistrationAuthority": business_registration_authority, + "BusinessLegalName": business_legal_name, + "NotificationEmail": notification_email, + "AcceptedNotificationReceipt": serialize.boolean_to_string( + accepted_notification_receipt + ), + "BusinessRegistrationNumber": business_registration_number, + "BusinessWebsiteUrl": business_website_url, + "FriendlyName": friendly_name, + "AuthorizedRepresentative1FirstName": authorized_representative1_first_name, + "AuthorizedRepresentative1LastName": authorized_representative1_last_name, + "AuthorizedRepresentative1Phone": authorized_representative1_phone, + "AuthorizedRepresentative1Email": authorized_representative1_email, + "AuthorizedRepresentative1DateOfBirth": authorized_representative1_date_of_birth, + "AddressStreet": address_street, + "AddressStreetSecondary": address_street_secondary, + "AddressCity": address_city, + "AddressSubdivision": address_subdivision, + "AddressPostalCode": address_postal_code, + "AddressCountryCode": address_country_code, + "EmergencyAddressStreet": emergency_address_street, + "EmergencyAddressStreetSecondary": emergency_address_street_secondary, + "EmergencyAddressCity": emergency_address_city, + "EmergencyAddressSubdivision": emergency_address_subdivision, + "EmergencyAddressPostalCode": emergency_address_postal_code, + "EmergencyAddressCountryCode": emergency_address_country_code, + "UseAddressAsEmergencyAddress": serialize.boolean_to_string( + use_address_as_emergency_address + ), + "FileName": file_name, + "File": file, + "FirstName": first_name, + "LastName": last_name, + "DateOfBirth": date_of_birth, + "IndividualEmail": individual_email, + "IndividualPhone": individual_phone, + "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, 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 + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/trusthub/v1/compliance_tollfree_inquiries.py b/twilio/rest/trusthub/v1/compliance_tollfree_inquiries.py new file mode 100644 index 0000000000..9cf259a318 --- /dev/null +++ b/twilio/rest/trusthub/v1/compliance_tollfree_inquiries.py @@ -0,0 +1,274 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Trusthub + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from typing import Any, Dict, List, Optional, Union +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 ComplianceTollfreeInquiriesInstance(InstanceResource): + + class OptInType(object): + VERBAL = "VERBAL" + WEB_FORM = "WEB_FORM" + PAPER_FORM = "PAPER_FORM" + VIA_TEXT = "VIA_TEXT" + MOBILE_QR_CODE = "MOBILE_QR_CODE" + + """ + :ivar inquiry_id: The unique ID used to start an embedded compliance registration session. + :ivar inquiry_session_token: The session token used to start an embedded compliance registration session. + :ivar registration_id: The TolfreeId matching the Tollfree Profile that should be resumed or resubmitted for editing. + :ivar url: The URL of this resource. + """ + + def __init__(self, version: Version, payload: Dict[str, Any]): + super().__init__(version) + + self.inquiry_id: Optional[str] = payload.get("inquiry_id") + self.inquiry_session_token: Optional[str] = payload.get("inquiry_session_token") + self.registration_id: Optional[str] = payload.get("registration_id") + self.url: Optional[str] = payload.get("url") + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + + return "" + + +class ComplianceTollfreeInquiriesList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the ComplianceTollfreeInquiriesList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + self._uri = "/ComplianceInquiries/Tollfree/Initialize" + + def create( + self, + tollfree_phone_number: str, + notification_email: str, + business_name: Union[str, object] = values.unset, + business_website: Union[str, object] = values.unset, + use_case_categories: Union[List[str], object] = values.unset, + use_case_summary: Union[str, object] = values.unset, + production_message_sample: Union[str, object] = values.unset, + opt_in_image_urls: Union[List[str], object] = values.unset, + opt_in_type: Union[ + "ComplianceTollfreeInquiriesInstance.OptInType", object + ] = values.unset, + message_volume: Union[str, object] = values.unset, + business_street_address: Union[str, object] = values.unset, + business_street_address2: Union[str, object] = values.unset, + business_city: Union[str, object] = values.unset, + business_state_province_region: Union[str, object] = values.unset, + business_postal_code: Union[str, object] = values.unset, + business_country: Union[str, object] = values.unset, + additional_information: Union[str, object] = values.unset, + business_contact_first_name: Union[str, object] = values.unset, + 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 + + :param tollfree_phone_number: The Tollfree phone number to be verified + :param notification_email: The email address to receive the notification about the verification result. + :param business_name: The name of the business or organization using the Tollfree number. + :param business_website: The website of the business or organization using the Tollfree number. + :param use_case_categories: The category of the use case for the Tollfree Number. List as many are applicable.. + :param use_case_summary: Use this to further explain how messaging is used by the business or organization. + :param production_message_sample: An example of message content, i.e. a sample message. + :param opt_in_image_urls: Link to an image that shows the opt-in workflow. Multiple images allowed and must be a publicly hosted URL. + :param opt_in_type: + :param message_volume: Estimate monthly volume of messages from the Tollfree Number. + :param business_street_address: The address of the business or organization using the Tollfree number. + :param business_street_address2: The address of the business or organization using the Tollfree number. + :param business_city: The city of the business or organization using the Tollfree number. + :param business_state_province_region: The state/province/region of the business or organization using the Tollfree number. + :param business_postal_code: The postal code of the business or organization using the Tollfree number. + :param business_country: The country of the business or organization using the Tollfree number. + :param additional_information: Additional information to be provided for verification. + :param business_contact_first_name: The first name of the contact for the business or organization using the Tollfree number. + :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 + """ + + data = values.of( + { + "TollfreePhoneNumber": tollfree_phone_number, + "NotificationEmail": notification_email, + "BusinessName": business_name, + "BusinessWebsite": business_website, + "UseCaseCategories": serialize.map(use_case_categories, lambda e: e), + "UseCaseSummary": use_case_summary, + "ProductionMessageSample": production_message_sample, + "OptInImageUrls": serialize.map(opt_in_image_urls, lambda e: e), + "OptInType": opt_in_type, + "MessageVolume": message_volume, + "BusinessStreetAddress": business_street_address, + "BusinessStreetAddress2": business_street_address2, + "BusinessCity": business_city, + "BusinessStateProvinceRegion": business_state_province_region, + "BusinessPostalCode": business_postal_code, + "BusinessCountry": business_country, + "AdditionalInformation": additional_information, + "BusinessContactFirstName": business_contact_first_name, + "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, headers=headers + ) + + return ComplianceTollfreeInquiriesInstance(self._version, payload) + + async def create_async( + self, + tollfree_phone_number: str, + notification_email: str, + business_name: Union[str, object] = values.unset, + business_website: Union[str, object] = values.unset, + use_case_categories: Union[List[str], object] = values.unset, + use_case_summary: Union[str, object] = values.unset, + production_message_sample: Union[str, object] = values.unset, + opt_in_image_urls: Union[List[str], object] = values.unset, + opt_in_type: Union[ + "ComplianceTollfreeInquiriesInstance.OptInType", object + ] = values.unset, + message_volume: Union[str, object] = values.unset, + business_street_address: Union[str, object] = values.unset, + business_street_address2: Union[str, object] = values.unset, + business_city: Union[str, object] = values.unset, + business_state_province_region: Union[str, object] = values.unset, + business_postal_code: Union[str, object] = values.unset, + business_country: Union[str, object] = values.unset, + additional_information: Union[str, object] = values.unset, + business_contact_first_name: Union[str, object] = values.unset, + 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 + + :param tollfree_phone_number: The Tollfree phone number to be verified + :param notification_email: The email address to receive the notification about the verification result. + :param business_name: The name of the business or organization using the Tollfree number. + :param business_website: The website of the business or organization using the Tollfree number. + :param use_case_categories: The category of the use case for the Tollfree Number. List as many are applicable.. + :param use_case_summary: Use this to further explain how messaging is used by the business or organization. + :param production_message_sample: An example of message content, i.e. a sample message. + :param opt_in_image_urls: Link to an image that shows the opt-in workflow. Multiple images allowed and must be a publicly hosted URL. + :param opt_in_type: + :param message_volume: Estimate monthly volume of messages from the Tollfree Number. + :param business_street_address: The address of the business or organization using the Tollfree number. + :param business_street_address2: The address of the business or organization using the Tollfree number. + :param business_city: The city of the business or organization using the Tollfree number. + :param business_state_province_region: The state/province/region of the business or organization using the Tollfree number. + :param business_postal_code: The postal code of the business or organization using the Tollfree number. + :param business_country: The country of the business or organization using the Tollfree number. + :param additional_information: Additional information to be provided for verification. + :param business_contact_first_name: The first name of the contact for the business or organization using the Tollfree number. + :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 + """ + + data = values.of( + { + "TollfreePhoneNumber": tollfree_phone_number, + "NotificationEmail": notification_email, + "BusinessName": business_name, + "BusinessWebsite": business_website, + "UseCaseCategories": serialize.map(use_case_categories, lambda e: e), + "UseCaseSummary": use_case_summary, + "ProductionMessageSample": production_message_sample, + "OptInImageUrls": serialize.map(opt_in_image_urls, lambda e: e), + "OptInType": opt_in_type, + "MessageVolume": message_volume, + "BusinessStreetAddress": business_street_address, + "BusinessStreetAddress2": business_street_address2, + "BusinessCity": business_city, + "BusinessStateProvinceRegion": business_state_province_region, + "BusinessPostalCode": business_postal_code, + "BusinessCountry": business_country, + "AdditionalInformation": additional_information, + "BusinessContactFirstName": business_contact_first_name, + "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, headers=headers + ) + + return ComplianceTollfreeInquiriesInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/trusthub/v1/customer_profiles/__init__.py b/twilio/rest/trusthub/v1/customer_profiles/__init__.py index a82fafa4da..bf5264e31d 100644 --- a/twilio/rest/trusthub/v1/customer_profiles/__init__.py +++ b/twilio/rest/trusthub/v1/customer_profiles/__init__.py @@ -12,7 +12,6 @@ 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 @@ -33,6 +32,7 @@ class CustomerProfilesInstance(InstanceResource): + class Status(object): DRAFT = "draft" PENDING_REVIEW = "pending-review" @@ -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, @@ -219,6 +221,7 @@ def __repr__(self) -> str: class CustomerProfilesContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the CustomerProfilesContext @@ -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) -> CustomerProfilesInstance: @@ -276,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, @@ -295,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( @@ -323,6 +332,7 @@ def update( :returns: The updated CustomerProfilesInstance """ + data = values.of( { "Status": status, @@ -331,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( @@ -359,6 +372,7 @@ async def update_async( :returns: The updated CustomerProfilesInstance """ + data = values.of( { "Status": status, @@ -367,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( @@ -433,6 +450,7 @@ def __repr__(self) -> str: class CustomerProfilesPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> CustomerProfilesInstance: """ Build an instance of CustomerProfilesInstance @@ -451,6 +469,7 @@ def __repr__(self) -> str: class CustomerProfilesList(ListResource): + def __init__(self, version: Version): """ Initialize the CustomerProfilesList @@ -479,6 +498,7 @@ def create( :returns: The created CustomerProfilesInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -487,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) @@ -513,6 +536,7 @@ async def create_async( :returns: The created CustomerProfilesInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -521,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) @@ -706,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( @@ -742,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 e1905c1ac5..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 @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class CustomerProfilesChannelEndpointAssignmentInstance(InstanceResource): - """ :ivar sid: The unique string that we created to identify the Item Assignment resource. :ivar customer_profile_sid: The unique string that we created to identify the CustomerProfile resource. @@ -125,6 +123,7 @@ def __repr__(self) -> str: class CustomerProfilesChannelEndpointAssignmentContext(InstanceContext): + def __init__(self, version: Version, customer_profile_sid: str, sid: str): """ Initialize the CustomerProfilesChannelEndpointAssignmentContext @@ -151,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: """ @@ -163,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: @@ -176,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, @@ -196,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( @@ -221,6 +226,7 @@ def __repr__(self) -> str: class CustomerProfilesChannelEndpointAssignmentPage(Page): + def get_instance( self, payload: Dict[str, Any] ) -> CustomerProfilesChannelEndpointAssignmentInstance: @@ -245,6 +251,7 @@ def __repr__(self) -> str: class CustomerProfilesChannelEndpointAssignmentList(ListResource): + def __init__(self, version: Version, customer_profile_sid: str): """ Initialize the CustomerProfilesChannelEndpointAssignmentList @@ -274,17 +281,21 @@ def create( :returns: The created CustomerProfilesChannelEndpointAssignmentInstance """ + data = values.of( { "ChannelEndpointType": channel_endpoint_type, "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( @@ -304,17 +315,21 @@ async def create_async( :returns: The created CustomerProfilesChannelEndpointAssignmentInstance """ + data = values.of( { "ChannelEndpointType": channel_endpoint_type, "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( @@ -484,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 ) @@ -519,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 c318b539cc..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 @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class CustomerProfilesEntityAssignmentsInstance(InstanceResource): - """ :ivar sid: The unique string that we created to identify the Item Assignment resource. :ivar customer_profile_sid: The unique string that we created to identify the CustomerProfile resource. @@ -125,6 +123,7 @@ def __repr__(self) -> str: class CustomerProfilesEntityAssignmentsContext(InstanceContext): + def __init__(self, version: Version, customer_profile_sid: str, sid: str): """ Initialize the CustomerProfilesEntityAssignmentsContext @@ -153,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: """ @@ -165,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: @@ -178,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, @@ -198,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( @@ -225,6 +230,7 @@ def __repr__(self) -> str: class CustomerProfilesEntityAssignmentsPage(Page): + def get_instance( self, payload: Dict[str, Any] ) -> CustomerProfilesEntityAssignmentsInstance: @@ -249,6 +255,7 @@ def __repr__(self) -> str: class CustomerProfilesEntityAssignmentsList(ListResource): + def __init__(self, version: Version, customer_profile_sid: str): """ Initialize the CustomerProfilesEntityAssignmentsList @@ -275,16 +282,20 @@ def create(self, object_sid: str) -> CustomerProfilesEntityAssignmentsInstance: :returns: The created CustomerProfilesEntityAssignmentsInstance """ + data = values.of( { "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( @@ -303,16 +314,20 @@ async def create_async( :returns: The created CustomerProfilesEntityAssignmentsInstance """ + data = values.of( { "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( @@ -323,6 +338,7 @@ async def create_async( def stream( self, + object_type: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, ) -> Iterator[CustomerProfilesEntityAssignmentsInstance]: @@ -332,6 +348,7 @@ def stream( is reached. The results are returned as a generator, so this operation is memory efficient. + :param str object_type: A string to filter the results by (EndUserType or SupportingDocumentType) machine-name. This is useful when you want to retrieve the entity-assignment of a specific end-user or supporting document. :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 @@ -342,12 +359,13 @@ def stream( :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"]) + page = self.page(object_type=object_type, page_size=limits["page_size"]) return self._version.stream(page, limits["limit"]) async def stream_async( self, + object_type: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, ) -> AsyncIterator[CustomerProfilesEntityAssignmentsInstance]: @@ -357,6 +375,7 @@ async def stream_async( is reached. The results are returned as a generator, so this operation is memory efficient. + :param str object_type: A string to filter the results by (EndUserType or SupportingDocumentType) machine-name. This is useful when you want to retrieve the entity-assignment of a specific end-user or supporting document. :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 @@ -367,12 +386,15 @@ 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(page_size=limits["page_size"]) + page = await self.page_async( + object_type=object_type, page_size=limits["page_size"] + ) return self._version.stream_async(page, limits["limit"]) def list( self, + object_type: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, ) -> List[CustomerProfilesEntityAssignmentsInstance]: @@ -381,6 +403,7 @@ def list( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. + :param str object_type: A string to filter the results by (EndUserType or SupportingDocumentType) machine-name. This is useful when you want to retrieve the entity-assignment of a specific end-user or supporting document. :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 @@ -392,6 +415,7 @@ def list( """ return list( self.stream( + object_type=object_type, limit=limit, page_size=page_size, ) @@ -399,6 +423,7 @@ def list( async def list_async( self, + object_type: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, ) -> List[CustomerProfilesEntityAssignmentsInstance]: @@ -407,6 +432,7 @@ async def list_async( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. + :param str object_type: A string to filter the results by (EndUserType or SupportingDocumentType) machine-name. This is useful when you want to retrieve the entity-assignment of a specific end-user or supporting document. :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 @@ -419,6 +445,7 @@ async def list_async( return [ record async for record in await self.stream_async( + object_type=object_type, limit=limit, page_size=page_size, ) @@ -426,6 +453,7 @@ async def list_async( def page( self, + object_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, @@ -434,6 +462,7 @@ def page( Retrieve a single page of CustomerProfilesEntityAssignmentsInstance records from the API. Request is executed immediately + :param object_type: A string to filter the results by (EndUserType or SupportingDocumentType) machine-name. This is useful when you want to retrieve the entity-assignment of a specific end-user or supporting document. :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 @@ -442,19 +471,27 @@ def page( """ data = values.of( { + "ObjectType": object_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 CustomerProfilesEntityAssignmentsPage( self._version, response, self._solution ) async def page_async( self, + object_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, @@ -463,6 +500,7 @@ async def page_async( Asynchronously retrieve a single page of CustomerProfilesEntityAssignmentsInstance records from the API. Request is executed immediately + :param object_type: A string to filter the results by (EndUserType or SupportingDocumentType) machine-name. This is useful when you want to retrieve the entity-assignment of a specific end-user or supporting document. :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 @@ -471,14 +509,19 @@ async def page_async( """ data = values.of( { + "ObjectType": object_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 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 c3611f7647..648467aac6 100644 --- a/twilio/rest/trusthub/v1/customer_profiles/customer_profiles_evaluations.py +++ b/twilio/rest/trusthub/v1/customer_profiles/customer_profiles_evaluations.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class CustomerProfilesEvaluationsInstance(InstanceResource): + class Status(object): COMPLIANT = "compliant" NONCOMPLIANT = "noncompliant" @@ -52,10 +52,10 @@ def __init__( self.account_sid: Optional[str] = payload.get("account_sid") self.policy_sid: Optional[str] = payload.get("policy_sid") self.customer_profile_sid: Optional[str] = payload.get("customer_profile_sid") - self.status: Optional[ - "CustomerProfilesEvaluationsInstance.Status" - ] = payload.get("status") - self.results: Optional[List[object]] = payload.get("results") + self.status: Optional["CustomerProfilesEvaluationsInstance.Status"] = ( + payload.get("status") + ) + self.results: Optional[List[Dict[str, object]]] = payload.get("results") self.date_created: Optional[datetime] = deserialize.iso8601_datetime( payload.get("date_created") ) @@ -114,6 +114,7 @@ def __repr__(self) -> str: class CustomerProfilesEvaluationsContext(InstanceContext): + def __init__(self, version: Version, customer_profile_sid: str, sid: str): """ Initialize the CustomerProfilesEvaluationsContext @@ -141,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, @@ -161,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( @@ -186,6 +191,7 @@ def __repr__(self) -> str: class CustomerProfilesEvaluationsPage(Page): + def get_instance( self, payload: Dict[str, Any] ) -> CustomerProfilesEvaluationsInstance: @@ -210,6 +216,7 @@ def __repr__(self) -> str: class CustomerProfilesEvaluationsList(ListResource): + def __init__(self, version: Version, customer_profile_sid: str): """ Initialize the CustomerProfilesEvaluationsList @@ -236,16 +243,20 @@ def create(self, policy_sid: str) -> CustomerProfilesEvaluationsInstance: :returns: The created CustomerProfilesEvaluationsInstance """ + data = values.of( { "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( @@ -264,16 +275,20 @@ async def create_async( :returns: The created CustomerProfilesEvaluationsInstance """ + data = values.of( { "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( @@ -409,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( @@ -436,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 05f096b6c3..5ce3b819d9 100644 --- a/twilio/rest/trusthub/v1/end_user.py +++ b/twilio/rest/trusthub/v1/end_user.py @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class EndUserInstance(InstanceResource): - """ :ivar sid: The unique string created by Twilio to identify the End User resource. :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the End User resource. @@ -157,6 +155,7 @@ def __repr__(self) -> str: class EndUserContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the EndUserContext @@ -179,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: """ @@ -191,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: @@ -204,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, @@ -223,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( @@ -247,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"]) @@ -275,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"]) @@ -301,6 +314,7 @@ def __repr__(self) -> str: class EndUserPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> EndUserInstance: """ Build an instance of EndUserInstance @@ -319,6 +333,7 @@ def __repr__(self) -> str: class EndUserList(ListResource): + def __init__(self, version: Version): """ Initialize the EndUserList @@ -345,6 +360,7 @@ def create( :returns: The created EndUserInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -352,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) @@ -376,6 +395,7 @@ async def create_async( :returns: The created EndUserInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -383,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) @@ -519,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( @@ -546,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 391012e1ac..0eb2957e0a 100644 --- a/twilio/rest/trusthub/v1/end_user_type.py +++ b/twilio/rest/trusthub/v1/end_user_type.py @@ -12,7 +12,6 @@ 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 @@ -23,7 +22,6 @@ class EndUserTypeInstance(InstanceResource): - """ :ivar sid: The unique string that identifies the End-User Type resource. :ivar friendly_name: A human-readable description that is assigned to describe the End-User Type resource. Examples can include first name, last name, email, business name, etc @@ -40,7 +38,7 @@ def __init__( self.sid: Optional[str] = payload.get("sid") self.friendly_name: Optional[str] = payload.get("friendly_name") self.machine_name: Optional[str] = payload.get("machine_name") - self.fields: Optional[List[object]] = payload.get("fields") + self.fields: Optional[List[Dict[str, object]]] = payload.get("fields") self.url: Optional[str] = payload.get("url") self._solution = { @@ -92,6 +90,7 @@ def __repr__(self) -> str: class EndUserTypeContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the EndUserTypeContext @@ -115,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, @@ -134,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( @@ -156,6 +159,7 @@ def __repr__(self) -> str: class EndUserTypePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> EndUserTypeInstance: """ Build an instance of EndUserTypeInstance @@ -174,6 +178,7 @@ def __repr__(self) -> str: class EndUserTypeList(ListResource): + def __init__(self, version: Version): """ Initialize the EndUserTypeList @@ -312,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( @@ -339,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 6c08335216..36a0916c51 100644 --- a/twilio/rest/trusthub/v1/policies.py +++ b/twilio/rest/trusthub/v1/policies.py @@ -12,7 +12,6 @@ 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 @@ -23,7 +22,6 @@ class PoliciesInstance(InstanceResource): - """ :ivar sid: The unique string that identifies the Policy resource. :ivar friendly_name: A human-readable description that is assigned to describe the Policy resource. Examples can include Primary Customer profile policy @@ -90,6 +88,7 @@ def __repr__(self) -> str: class PoliciesContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the PoliciesContext @@ -113,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, @@ -132,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( @@ -154,6 +157,7 @@ def __repr__(self) -> str: class PoliciesPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> PoliciesInstance: """ Build an instance of PoliciesInstance @@ -172,6 +176,7 @@ def __repr__(self) -> str: class PoliciesList(ListResource): + def __init__(self, version: Version): """ Initialize the PoliciesList @@ -310,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( @@ -337,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 f1f29a4afa..f2fd3b7e1c 100644 --- a/twilio/rest/trusthub/v1/supporting_document.py +++ b/twilio/rest/trusthub/v1/supporting_document.py @@ -12,7 +12,6 @@ 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 @@ -24,13 +23,14 @@ 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. @@ -170,6 +170,7 @@ def __repr__(self) -> str: class SupportingDocumentContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the SupportingDocumentContext @@ -192,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: """ @@ -204,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: @@ -217,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, @@ -236,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( @@ -260,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( @@ -290,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( @@ -318,6 +333,7 @@ def __repr__(self) -> str: class SupportingDocumentPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> SupportingDocumentInstance: """ Build an instance of SupportingDocumentInstance @@ -336,6 +352,7 @@ def __repr__(self) -> str: class SupportingDocumentList(ListResource): + def __init__(self, version: Version): """ Initialize the SupportingDocumentList @@ -362,6 +379,7 @@ def create( :returns: The created SupportingDocumentInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -369,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) @@ -393,6 +414,7 @@ async def create_async( :returns: The created SupportingDocumentInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -400,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) @@ -536,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( @@ -563,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 204c0b53a4..f107397a4c 100644 --- a/twilio/rest/trusthub/v1/supporting_document_type.py +++ b/twilio/rest/trusthub/v1/supporting_document_type.py @@ -12,7 +12,6 @@ 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 @@ -23,7 +22,6 @@ class SupportingDocumentTypeInstance(InstanceResource): - """ :ivar sid: The unique string that identifies the Supporting Document Type resource. :ivar friendly_name: A human-readable description of the Supporting Document Type resource. @@ -40,7 +38,7 @@ def __init__( self.sid: Optional[str] = payload.get("sid") self.friendly_name: Optional[str] = payload.get("friendly_name") self.machine_name: Optional[str] = payload.get("machine_name") - self.fields: Optional[List[object]] = payload.get("fields") + self.fields: Optional[List[Dict[str, object]]] = payload.get("fields") self.url: Optional[str] = payload.get("url") self._solution = { @@ -92,6 +90,7 @@ def __repr__(self) -> str: class SupportingDocumentTypeContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the SupportingDocumentTypeContext @@ -115,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, @@ -134,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( @@ -156,6 +159,7 @@ def __repr__(self) -> str: class SupportingDocumentTypePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> SupportingDocumentTypeInstance: """ Build an instance of SupportingDocumentTypeInstance @@ -174,6 +178,7 @@ def __repr__(self) -> str: class SupportingDocumentTypeList(ListResource): + def __init__(self, version: Version): """ Initialize the SupportingDocumentTypeList @@ -312,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( @@ -339,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 627cc5a090..6bb01d61dc 100644 --- a/twilio/rest/trusthub/v1/trust_products/__init__.py +++ b/twilio/rest/trusthub/v1/trust_products/__init__.py @@ -12,7 +12,6 @@ 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 @@ -33,6 +32,7 @@ class TrustProductsInstance(InstanceResource): + class Status(object): DRAFT = "draft" PENDING_REVIEW = "pending-review" @@ -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 """ @@ -217,12 +219,13 @@ def __repr__(self) -> str: class TrustProductsContext(InstanceContext): + 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) @@ -247,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: """ @@ -259,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: @@ -272,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, @@ -291,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( @@ -315,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, @@ -327,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"]) @@ -349,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, @@ -361,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"]) @@ -423,6 +440,7 @@ def __repr__(self) -> str: class TrustProductsPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> TrustProductsInstance: """ Build an instance of TrustProductsInstance @@ -441,6 +459,7 @@ def __repr__(self) -> str: class TrustProductsList(ListResource): + def __init__(self, version: Version): """ Initialize the TrustProductsList @@ -463,12 +482,13 @@ 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 """ + data = values.of( { "FriendlyName": friendly_name, @@ -477,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) @@ -497,12 +520,13 @@ 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 """ + data = values.of( { "FriendlyName": friendly_name, @@ -511,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) @@ -534,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 @@ -570,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 @@ -605,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 @@ -640,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 @@ -676,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 @@ -696,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( @@ -712,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 @@ -732,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) @@ -765,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) @@ -773,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 42b5923e6f..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 @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class TrustProductsChannelEndpointAssignmentInstance(InstanceResource): - """ :ivar sid: The unique string that we created to identify the Item Assignment resource. :ivar trust_product_sid: The unique string that we created to identify the CustomerProfile resource. @@ -125,6 +123,7 @@ def __repr__(self) -> str: class TrustProductsChannelEndpointAssignmentContext(InstanceContext): + def __init__(self, version: Version, trust_product_sid: str, sid: str): """ Initialize the TrustProductsChannelEndpointAssignmentContext @@ -151,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: """ @@ -163,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: @@ -176,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, @@ -196,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( @@ -221,6 +226,7 @@ def __repr__(self) -> str: class TrustProductsChannelEndpointAssignmentPage(Page): + def get_instance( self, payload: Dict[str, Any] ) -> TrustProductsChannelEndpointAssignmentInstance: @@ -245,6 +251,7 @@ def __repr__(self) -> str: class TrustProductsChannelEndpointAssignmentList(ListResource): + def __init__(self, version: Version, trust_product_sid: str): """ Initialize the TrustProductsChannelEndpointAssignmentList @@ -276,17 +283,21 @@ def create( :returns: The created TrustProductsChannelEndpointAssignmentInstance """ + data = values.of( { "ChannelEndpointType": channel_endpoint_type, "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( @@ -306,17 +317,21 @@ async def create_async( :returns: The created TrustProductsChannelEndpointAssignmentInstance """ + data = values.of( { "ChannelEndpointType": channel_endpoint_type, "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( @@ -486,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 ) @@ -521,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 306f9359b5..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 @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class TrustProductsEntityAssignmentsInstance(InstanceResource): - """ :ivar sid: The unique string that we created to identify the Item Assignment resource. :ivar trust_product_sid: The unique string that we created to identify the TrustProduct resource. @@ -123,6 +121,7 @@ def __repr__(self) -> str: class TrustProductsEntityAssignmentsContext(InstanceContext): + def __init__(self, version: Version, trust_product_sid: str, sid: str): """ Initialize the TrustProductsEntityAssignmentsContext @@ -149,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: """ @@ -161,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: @@ -174,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, @@ -194,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( @@ -219,6 +224,7 @@ def __repr__(self) -> str: class TrustProductsEntityAssignmentsPage(Page): + def get_instance( self, payload: Dict[str, Any] ) -> TrustProductsEntityAssignmentsInstance: @@ -243,6 +249,7 @@ def __repr__(self) -> str: class TrustProductsEntityAssignmentsList(ListResource): + def __init__(self, version: Version, trust_product_sid: str): """ Initialize the TrustProductsEntityAssignmentsList @@ -269,16 +276,20 @@ def create(self, object_sid: str) -> TrustProductsEntityAssignmentsInstance: :returns: The created TrustProductsEntityAssignmentsInstance """ + data = values.of( { "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( @@ -297,16 +308,20 @@ async def create_async( :returns: The created TrustProductsEntityAssignmentsInstance """ + data = values.of( { "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( @@ -317,6 +332,7 @@ async def create_async( def stream( self, + object_type: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, ) -> Iterator[TrustProductsEntityAssignmentsInstance]: @@ -326,6 +342,7 @@ def stream( is reached. The results are returned as a generator, so this operation is memory efficient. + :param str object_type: A string to filter the results by (EndUserType or SupportingDocumentType) machine-name. This is useful when you want to retrieve the entity-assignment of a specific end-user or supporting document. :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 @@ -336,12 +353,13 @@ def stream( :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"]) + page = self.page(object_type=object_type, page_size=limits["page_size"]) return self._version.stream(page, limits["limit"]) async def stream_async( self, + object_type: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, ) -> AsyncIterator[TrustProductsEntityAssignmentsInstance]: @@ -351,6 +369,7 @@ async def stream_async( is reached. The results are returned as a generator, so this operation is memory efficient. + :param str object_type: A string to filter the results by (EndUserType or SupportingDocumentType) machine-name. This is useful when you want to retrieve the entity-assignment of a specific end-user or supporting document. :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 @@ -361,12 +380,15 @@ 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(page_size=limits["page_size"]) + page = await self.page_async( + object_type=object_type, page_size=limits["page_size"] + ) return self._version.stream_async(page, limits["limit"]) def list( self, + object_type: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, ) -> List[TrustProductsEntityAssignmentsInstance]: @@ -375,6 +397,7 @@ def list( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. + :param str object_type: A string to filter the results by (EndUserType or SupportingDocumentType) machine-name. This is useful when you want to retrieve the entity-assignment of a specific end-user or supporting document. :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 @@ -386,6 +409,7 @@ def list( """ return list( self.stream( + object_type=object_type, limit=limit, page_size=page_size, ) @@ -393,6 +417,7 @@ def list( async def list_async( self, + object_type: Union[str, object] = values.unset, limit: Optional[int] = None, page_size: Optional[int] = None, ) -> List[TrustProductsEntityAssignmentsInstance]: @@ -401,6 +426,7 @@ async def list_async( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. + :param str object_type: A string to filter the results by (EndUserType or SupportingDocumentType) machine-name. This is useful when you want to retrieve the entity-assignment of a specific end-user or supporting document. :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 @@ -413,6 +439,7 @@ async def list_async( return [ record async for record in await self.stream_async( + object_type=object_type, limit=limit, page_size=page_size, ) @@ -420,6 +447,7 @@ async def list_async( def page( self, + object_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, @@ -428,6 +456,7 @@ def page( Retrieve a single page of TrustProductsEntityAssignmentsInstance records from the API. Request is executed immediately + :param object_type: A string to filter the results by (EndUserType or SupportingDocumentType) machine-name. This is useful when you want to retrieve the entity-assignment of a specific end-user or supporting document. :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 @@ -436,19 +465,27 @@ def page( """ data = values.of( { + "ObjectType": object_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 TrustProductsEntityAssignmentsPage( self._version, response, self._solution ) async def page_async( self, + object_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, @@ -457,6 +494,7 @@ async def page_async( Asynchronously retrieve a single page of TrustProductsEntityAssignmentsInstance records from the API. Request is executed immediately + :param object_type: A string to filter the results by (EndUserType or SupportingDocumentType) machine-name. This is useful when you want to retrieve the entity-assignment of a specific end-user or supporting document. :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 @@ -465,14 +503,19 @@ async def page_async( """ data = values.of( { + "ObjectType": object_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 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 f2d435c1cb..3691aa017b 100644 --- a/twilio/rest/trusthub/v1/trust_products/trust_products_evaluations.py +++ b/twilio/rest/trusthub/v1/trust_products/trust_products_evaluations.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class TrustProductsEvaluationsInstance(InstanceResource): + class Status(object): COMPLIANT = "compliant" NONCOMPLIANT = "noncompliant" @@ -55,7 +55,7 @@ def __init__( self.status: Optional["TrustProductsEvaluationsInstance.Status"] = payload.get( "status" ) - self.results: Optional[List[object]] = payload.get("results") + self.results: Optional[List[Dict[str, object]]] = payload.get("results") self.date_created: Optional[datetime] = deserialize.iso8601_datetime( payload.get("date_created") ) @@ -114,6 +114,7 @@ def __repr__(self) -> str: class TrustProductsEvaluationsContext(InstanceContext): + def __init__(self, version: Version, trust_product_sid: str, sid: str): """ Initialize the TrustProductsEvaluationsContext @@ -141,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, @@ -161,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( @@ -184,6 +189,7 @@ def __repr__(self) -> str: class TrustProductsEvaluationsPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> TrustProductsEvaluationsInstance: """ Build an instance of TrustProductsEvaluationsInstance @@ -206,6 +212,7 @@ def __repr__(self) -> str: class TrustProductsEvaluationsList(ListResource): + def __init__(self, version: Version, trust_product_sid: str): """ Initialize the TrustProductsEvaluationsList @@ -232,16 +239,20 @@ def create(self, policy_sid: str) -> TrustProductsEvaluationsInstance: :returns: The created TrustProductsEvaluationsInstance """ + data = values.of( { "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( @@ -258,16 +269,20 @@ async def create_async(self, policy_sid: str) -> TrustProductsEvaluationsInstanc :returns: The created TrustProductsEvaluationsInstance """ + data = values.of( { "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( @@ -403,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( @@ -430,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/VerifyBase.py b/twilio/rest/verify/VerifyBase.py index 8977a50430..076f063147 100644 --- a/twilio/rest/verify/VerifyBase.py +++ b/twilio/rest/verify/VerifyBase.py @@ -17,6 +17,7 @@ class VerifyBase(Domain): + def __init__(self, twilio: Client): """ Initialize the Verify Domain diff --git a/twilio/rest/verify/v2/__init__.py b/twilio/rest/verify/v2/__init__.py index c4f94aea30..01bee13b0d 100644 --- a/twilio/rest/verify/v2/__init__.py +++ b/twilio/rest/verify/v2/__init__.py @@ -26,6 +26,7 @@ class V2(Version): + def __init__(self, domain: Domain): """ Initialize the V2 version of Verify diff --git a/twilio/rest/verify/v2/form.py b/twilio/rest/verify/v2/form.py index 9b17da9e48..454030208d 100644 --- a/twilio/rest/verify/v2/form.py +++ b/twilio/rest/verify/v2/form.py @@ -12,8 +12,8 @@ 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 @@ -21,6 +21,7 @@ class FormInstance(InstanceResource): + class FormTypes(object): FORM_PUSH = "form-push" @@ -93,6 +94,7 @@ def __repr__(self) -> str: class FormContext(InstanceContext): + def __init__(self, version: Version, form_type: "FormInstance.FormTypes"): """ Initialize the FormContext @@ -116,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, @@ -135,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( @@ -157,6 +163,7 @@ def __repr__(self) -> str: class FormList(ListResource): + def __init__(self, version: Version): """ Initialize the FormList diff --git a/twilio/rest/verify/v2/safelist.py b/twilio/rest/verify/v2/safelist.py index 45e5b220e1..00fc0976f7 100644 --- a/twilio/rest/verify/v2/safelist.py +++ b/twilio/rest/verify/v2/safelist.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, Optional from twilio.base import values from twilio.base.instance_context import InstanceContext @@ -22,7 +21,6 @@ class SafelistInstance(InstanceResource): - """ :ivar sid: The unique string that we created to identify the SafeList resource. :ivar phone_number: The phone number in SafeList. @@ -108,6 +106,7 @@ def __repr__(self) -> str: class SafelistContext(InstanceContext): + def __init__(self, version: Version, phone_number: str): """ Initialize the SafelistContext @@ -130,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: """ @@ -142,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: @@ -155,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, @@ -174,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( @@ -196,6 +201,7 @@ def __repr__(self) -> str: class SafelistList(ListResource): + def __init__(self, version: Version): """ Initialize the SafelistList @@ -215,16 +221,20 @@ def create(self, phone_number: str) -> SafelistInstance: :returns: The created SafelistInstance """ + data = values.of( { "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) @@ -237,16 +247,20 @@ async def create_async(self, phone_number: str) -> SafelistInstance: :returns: The created SafelistInstance """ + data = values.of( { "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 c9f3f4ea26..a64ab7a552 100644 --- a/twilio/rest/verify/v2/service/__init__.py +++ b/twilio/rest/verify/v2/service/__init__.py @@ -12,10 +12,9 @@ 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 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 @@ -33,11 +32,10 @@ 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. **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. It cannot contain more than 4 (consecutive or non-consecutive) digits. **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. @@ -45,10 +43,12 @@ 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. :ivar url: The absolute URL of the resource. @@ -80,6 +80,10 @@ 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" + ) self.date_created: Optional[datetime] = deserialize.iso8601_datetime( payload.get("date_created") ) @@ -164,11 +168,14 @@ 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": """ Update the ServiceInstance - :param friendly_name: A descriptive string that you create to describe the verification service. It can be up to 30 characters long. **This value should not contain PII.** + :param friendly_name: A descriptive string that you create to describe the verification service. It can be up to 32 characters long. **This value should not contain PII.** :param code_length: The length of the verification code to generate. Must be an integer value between 4 and 10, inclusive. :param lookup_enabled: Whether to perform a lookup with each verification started and return info about the phone number. :param skip_sms_to_landlines: Whether to skip sending SMS verifications to landlines. Requires `lookup_enabled`. @@ -176,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) @@ -185,6 +192,9 @@ 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 """ @@ -206,6 +216,9 @@ 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, ) async def update_async( @@ -227,11 +240,14 @@ 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": """ Asynchronous coroutine to update the ServiceInstance - :param friendly_name: A descriptive string that you create to describe the verification service. It can be up to 30 characters long. **This value should not contain PII.** + :param friendly_name: A descriptive string that you create to describe the verification service. It can be up to 32 characters long. **This value should not contain PII.** :param code_length: The length of the verification code to generate. Must be an integer value between 4 and 10, inclusive. :param lookup_enabled: Whether to perform a lookup with each verification started and return info about the phone number. :param skip_sms_to_landlines: Whether to skip sending SMS verifications to landlines. Requires `lookup_enabled`. @@ -239,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) @@ -248,6 +264,9 @@ 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 """ @@ -269,6 +288,9 @@ 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, ) @property @@ -331,6 +353,7 @@ def __repr__(self) -> str: class ServiceContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the ServiceContext @@ -361,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: """ @@ -373,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: @@ -386,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, @@ -405,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( @@ -435,11 +464,14 @@ 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: """ Update the ServiceInstance - :param friendly_name: A descriptive string that you create to describe the verification service. It can be up to 30 characters long. **This value should not contain PII.** + :param friendly_name: A descriptive string that you create to describe the verification service. It can be up to 32 characters long. **This value should not contain PII.** :param code_length: The length of the verification code to generate. Must be an integer value between 4 and 10, inclusive. :param lookup_enabled: Whether to perform a lookup with each verification started and return info about the phone number. :param skip_sms_to_landlines: Whether to skip sending SMS verifications to landlines. Requires `lookup_enabled`. @@ -447,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) @@ -456,21 +488,29 @@ 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, "CodeLength": code_length, - "LookupEnabled": lookup_enabled, - "SkipSmsToLandlines": skip_sms_to_landlines, - "DtmfInputRequired": dtmf_input_required, + "LookupEnabled": serialize.boolean_to_string(lookup_enabled), + "SkipSmsToLandlines": serialize.boolean_to_string( + skip_sms_to_landlines + ), + "DtmfInputRequired": serialize.boolean_to_string(dtmf_input_required), "TtsName": tts_name, - "Psd2Enabled": psd2_enabled, - "DoNotShareWarningEnabled": do_not_share_warning_enabled, - "CustomCodeEnabled": custom_code_enabled, - "Push.IncludeDate": push_include_date, + "Psd2Enabled": serialize.boolean_to_string(psd2_enabled), + "DoNotShareWarningEnabled": serialize.boolean_to_string( + do_not_share_warning_enabled + ), + "CustomCodeEnabled": serialize.boolean_to_string(custom_code_enabled), + "Push.IncludeDate": serialize.boolean_to_string(push_include_date), "Push.ApnCredentialSid": push_apn_credential_sid, "Push.FcmCredentialSid": push_fcm_credential_sid, "Totp.Issuer": totp_issuer, @@ -478,13 +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"]) @@ -508,11 +556,14 @@ 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: """ Asynchronous coroutine to update the ServiceInstance - :param friendly_name: A descriptive string that you create to describe the verification service. It can be up to 30 characters long. **This value should not contain PII.** + :param friendly_name: A descriptive string that you create to describe the verification service. It can be up to 32 characters long. **This value should not contain PII.** :param code_length: The length of the verification code to generate. Must be an integer value between 4 and 10, inclusive. :param lookup_enabled: Whether to perform a lookup with each verification started and return info about the phone number. :param skip_sms_to_landlines: Whether to skip sending SMS verifications to landlines. Requires `lookup_enabled`. @@ -520,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) @@ -529,21 +580,29 @@ 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, "CodeLength": code_length, - "LookupEnabled": lookup_enabled, - "SkipSmsToLandlines": skip_sms_to_landlines, - "DtmfInputRequired": dtmf_input_required, + "LookupEnabled": serialize.boolean_to_string(lookup_enabled), + "SkipSmsToLandlines": serialize.boolean_to_string( + skip_sms_to_landlines + ), + "DtmfInputRequired": serialize.boolean_to_string(dtmf_input_required), "TtsName": tts_name, - "Psd2Enabled": psd2_enabled, - "DoNotShareWarningEnabled": do_not_share_warning_enabled, - "CustomCodeEnabled": custom_code_enabled, - "Push.IncludeDate": push_include_date, + "Psd2Enabled": serialize.boolean_to_string(psd2_enabled), + "DoNotShareWarningEnabled": serialize.boolean_to_string( + do_not_share_warning_enabled + ), + "CustomCodeEnabled": serialize.boolean_to_string(custom_code_enabled), + "Push.IncludeDate": serialize.boolean_to_string(push_include_date), "Push.ApnCredentialSid": push_apn_credential_sid, "Push.FcmCredentialSid": push_fcm_credential_sid, "Totp.Issuer": totp_issuer, @@ -551,13 +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"]) @@ -657,6 +724,7 @@ def __repr__(self) -> str: class ServicePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ServiceInstance: """ Build an instance of ServiceInstance @@ -675,6 +743,7 @@ def __repr__(self) -> str: class ServiceList(ListResource): + def __init__(self, version: Version): """ Initialize the ServiceList @@ -705,11 +774,14 @@ 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: """ Create the ServiceInstance - :param friendly_name: A descriptive string that you create to describe the verification service. It can be up to 30 characters long. **This value should not contain PII.** + :param friendly_name: A descriptive string that you create to describe the verification service. It can be up to 32 characters long. **This value should not contain PII.** :param code_length: The length of the verification code to generate. Must be an integer value between 4 and 10, inclusive. :param lookup_enabled: Whether to perform a lookup with each verification started and return info about the phone number. :param skip_sms_to_landlines: Whether to skip sending SMS verifications to landlines. Requires `lookup_enabled`. @@ -717,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) @@ -726,21 +798,29 @@ 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 """ + data = values.of( { "FriendlyName": friendly_name, "CodeLength": code_length, - "LookupEnabled": lookup_enabled, - "SkipSmsToLandlines": skip_sms_to_landlines, - "DtmfInputRequired": dtmf_input_required, + "LookupEnabled": serialize.boolean_to_string(lookup_enabled), + "SkipSmsToLandlines": serialize.boolean_to_string( + skip_sms_to_landlines + ), + "DtmfInputRequired": serialize.boolean_to_string(dtmf_input_required), "TtsName": tts_name, - "Psd2Enabled": psd2_enabled, - "DoNotShareWarningEnabled": do_not_share_warning_enabled, - "CustomCodeEnabled": custom_code_enabled, - "Push.IncludeDate": push_include_date, + "Psd2Enabled": serialize.boolean_to_string(psd2_enabled), + "DoNotShareWarningEnabled": serialize.boolean_to_string( + do_not_share_warning_enabled + ), + "CustomCodeEnabled": serialize.boolean_to_string(custom_code_enabled), + "Push.IncludeDate": serialize.boolean_to_string(push_include_date), "Push.ApnCredentialSid": push_apn_credential_sid, "Push.FcmCredentialSid": push_fcm_credential_sid, "Totp.Issuer": totp_issuer, @@ -748,13 +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) @@ -778,11 +866,14 @@ 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: """ Asynchronously create the ServiceInstance - :param friendly_name: A descriptive string that you create to describe the verification service. It can be up to 30 characters long. **This value should not contain PII.** + :param friendly_name: A descriptive string that you create to describe the verification service. It can be up to 32 characters long. **This value should not contain PII.** :param code_length: The length of the verification code to generate. Must be an integer value between 4 and 10, inclusive. :param lookup_enabled: Whether to perform a lookup with each verification started and return info about the phone number. :param skip_sms_to_landlines: Whether to skip sending SMS verifications to landlines. Requires `lookup_enabled`. @@ -790,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) @@ -799,21 +890,29 @@ 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 """ + data = values.of( { "FriendlyName": friendly_name, "CodeLength": code_length, - "LookupEnabled": lookup_enabled, - "SkipSmsToLandlines": skip_sms_to_landlines, - "DtmfInputRequired": dtmf_input_required, + "LookupEnabled": serialize.boolean_to_string(lookup_enabled), + "SkipSmsToLandlines": serialize.boolean_to_string( + skip_sms_to_landlines + ), + "DtmfInputRequired": serialize.boolean_to_string(dtmf_input_required), "TtsName": tts_name, - "Psd2Enabled": psd2_enabled, - "DoNotShareWarningEnabled": do_not_share_warning_enabled, - "CustomCodeEnabled": custom_code_enabled, - "Push.IncludeDate": push_include_date, + "Psd2Enabled": serialize.boolean_to_string(psd2_enabled), + "DoNotShareWarningEnabled": serialize.boolean_to_string( + do_not_share_warning_enabled + ), + "CustomCodeEnabled": serialize.boolean_to_string(custom_code_enabled), + "Push.IncludeDate": serialize.boolean_to_string(push_include_date), "Push.ApnCredentialSid": push_apn_credential_sid, "Push.FcmCredentialSid": push_fcm_credential_sid, "Totp.Issuer": totp_issuer, @@ -821,13 +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) @@ -959,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( @@ -986,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 8c1bc46f8f..45a0094e52 100644 --- a/twilio/rest/verify/v2/service/access_token.py +++ b/twilio/rest/verify/v2/service/access_token.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import datetime from typing import Any, Dict, Optional, Union from twilio.base import deserialize, values @@ -23,6 +22,7 @@ class AccessTokenInstance(InstanceResource): + class FactorTypes(object): PUSH = "push" @@ -114,6 +114,7 @@ def __repr__(self) -> str: class AccessTokenContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, sid: str): """ Initialize the AccessTokenContext @@ -141,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, @@ -161,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( @@ -184,6 +189,7 @@ def __repr__(self) -> str: class AccessTokenList(ListResource): + def __init__(self, version: Version, service_sid: str): """ Initialize the AccessTokenList @@ -217,6 +223,7 @@ def create( :returns: The created AccessTokenInstance """ + data = values.of( { "Identity": identity, @@ -225,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( @@ -253,6 +263,7 @@ async def create_async( :returns: The created AccessTokenInstance """ + data = values.of( { "Identity": identity, @@ -261,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 74629d9bb2..fa4bc1df12 100644 --- a/twilio/rest/verify/v2/service/entity/__init__.py +++ b/twilio/rest/verify/v2/service/entity/__init__.py @@ -12,7 +12,6 @@ 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 @@ -27,7 +26,6 @@ class EntityInstance(InstanceResource): - """ :ivar sid: A 34 character string that uniquely identifies this Entity. :ivar identity: The unique external identifier for the Entity of the Service. This identifier should be immutable, not PII, length between 8 and 64 characters, and generated by your external system, such as your user's UUID, GUID, or SID. It can only contain dash (-) separated alphanumeric characters. @@ -151,6 +149,7 @@ def __repr__(self) -> str: class EntityContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, identity: str): """ Initialize the EntityContext @@ -181,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: """ @@ -193,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: @@ -206,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, @@ -226,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( @@ -288,6 +293,7 @@ def __repr__(self) -> str: class EntityPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> EntityInstance: """ Build an instance of EntityInstance @@ -308,6 +314,7 @@ def __repr__(self) -> str: class EntityList(ListResource): + def __init__(self, version: Version, service_sid: str): """ Initialize the EntityList @@ -332,16 +339,20 @@ def create(self, identity: str) -> EntityInstance: :returns: The created EntityInstance """ + data = values.of( { "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( @@ -356,16 +367,20 @@ async def create_async(self, identity: str) -> EntityInstance: :returns: The created EntityInstance """ + data = values.of( { "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( @@ -499,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( @@ -526,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 65aab902b1..146a95d959 100644 --- a/twilio/rest/verify/v2/service/entity/challenge/__init__.py +++ b/twilio/rest/verify/v2/service/entity/challenge/__init__.py @@ -12,7 +12,6 @@ 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 @@ -25,6 +24,7 @@ class ChallengeInstance(InstanceResource): + class ChallengeReasons(object): NONE = "none" NOT_NEEDED = "not_needed" @@ -96,9 +96,9 @@ def __init__( self.status: Optional["ChallengeInstance.ChallengeStatuses"] = payload.get( "status" ) - self.responded_reason: Optional[ - "ChallengeInstance.ChallengeReasons" - ] = payload.get("responded_reason") + self.responded_reason: Optional["ChallengeInstance.ChallengeReasons"] = ( + payload.get("responded_reason") + ) self.details: Optional[Dict[str, object]] = payload.get("details") self.hidden_details: Optional[Dict[str, object]] = payload.get("hidden_details") self.metadata: Optional[Dict[str, object]] = payload.get("metadata") @@ -204,6 +204,7 @@ def __repr__(self) -> str: class ChallengeContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, identity: str, sid: str): """ Initialize the ChallengeContext @@ -237,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, @@ -258,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( @@ -284,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( @@ -318,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( @@ -364,6 +377,7 @@ def __repr__(self) -> str: class ChallengePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ChallengeInstance: """ Build an instance of ChallengeInstance @@ -387,6 +401,7 @@ def __repr__(self) -> str: class ChallengeList(ListResource): + def __init__(self, version: Version, service_sid: str, identity: str): """ Initialize the ChallengeList @@ -428,6 +443,7 @@ def create( :returns: The created ChallengeInstance """ + data = values.of( { "FactorSid": factor_sid, @@ -440,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( @@ -475,6 +494,7 @@ async def create_async( :returns: The created ChallengeInstance """ + data = values.of( { "FactorSid": factor_sid, @@ -487,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( @@ -677,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( @@ -713,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 a04fea65ed..3802cc1a08 100644 --- a/twilio/rest/verify/v2/service/entity/challenge/notification.py +++ b/twilio/rest/verify/v2/service/entity/challenge/notification.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import datetime from typing import Any, Dict, Optional, Union from twilio.base import deserialize, values @@ -23,7 +22,6 @@ class NotificationInstance(InstanceResource): - """ :ivar sid: A 34 character string that uniquely identifies this Notification. :ivar account_sid: The unique SID identifier of the Account. @@ -75,6 +73,7 @@ def __repr__(self) -> str: class NotificationList(ListResource): + def __init__( self, version: Version, service_sid: str, identity: str, challenge_sid: str ): @@ -107,16 +106,20 @@ def create(self, ttl: Union[int, object] = values.unset) -> NotificationInstance :returns: The created NotificationInstance """ + data = values.of( { "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( @@ -137,16 +140,20 @@ async def create_async( :returns: The created NotificationInstance """ + data = values.of( { "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 b46a643717..7bf91cd870 100644 --- a/twilio/rest/verify/v2/service/entity/factor.py +++ b/twilio/rest/verify/v2/service/entity/factor.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class FactorInstance(InstanceResource): + class FactorStatuses(object): UNVERIFIED = "unverified" VERIFIED = "verified" @@ -232,6 +232,7 @@ def __repr__(self) -> str: class FactorContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, identity: str, sid: str): """ Initialize the FactorContext @@ -260,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: """ @@ -272,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: @@ -285,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, @@ -306,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( @@ -346,6 +353,7 @@ def update( :returns: The updated FactorInstance """ + data = values.of( { "AuthPayload": auth_payload, @@ -359,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( @@ -401,6 +412,7 @@ async def update_async( :returns: The updated FactorInstance """ + data = values.of( { "AuthPayload": auth_payload, @@ -414,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( @@ -440,6 +455,7 @@ def __repr__(self) -> str: class FactorPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> FactorInstance: """ Build an instance of FactorInstance @@ -463,6 +479,7 @@ def __repr__(self) -> str: class FactorList(ListResource): + def __init__(self, version: Version, service_sid: str, identity: str): """ Initialize the FactorList @@ -610,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( @@ -637,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 71c793cc65..2a2d77d512 100644 --- a/twilio/rest/verify/v2/service/entity/new_factor.py +++ b/twilio/rest/verify/v2/service/entity/new_factor.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import datetime from typing import Any, Dict, Optional, Union from twilio.base import deserialize, serialize, values @@ -23,6 +22,7 @@ class NewFactorInstance(InstanceResource): + class FactorStatuses(object): UNVERIFIED = "unverified" VERIFIED = "verified" @@ -102,6 +102,7 @@ def __repr__(self) -> str: class NewFactorList(ListResource): + def __init__(self, version: Version, service_sid: str, identity: str): """ Initialize the NewFactorList @@ -161,6 +162,7 @@ def create( :returns: The created NewFactorInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -179,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( @@ -232,6 +237,7 @@ async def create_async( :returns: The created NewFactorInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -250,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 9d6092d543..03f494f6e9 100644 --- a/twilio/rest/verify/v2/service/messaging_configuration.py +++ b/twilio/rest/verify/v2/service/messaging_configuration.py @@ -12,7 +12,6 @@ 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 @@ -24,12 +23,11 @@ class MessagingConfigurationInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Service resource. :ivar service_sid: The SID of the [Service](https://www.twilio.com/docs/verify/api/service) that the resource is associated with. :ivar country: The [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of the country this configuration will be applied to. If this is a global configuration, Country will take the value `all`. - :ivar messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/sms/services/api) to be used to send SMS to the country of this configuration. + :ivar messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) to be used to send SMS to the country of this configuration. :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. :ivar url: The URL of this resource. @@ -118,7 +116,7 @@ def update(self, messaging_service_sid: str) -> "MessagingConfigurationInstance" """ Update the MessagingConfigurationInstance - :param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/sms/services/api) to be used to send SMS to the country of this configuration. + :param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) to be used to send SMS to the country of this configuration. :returns: The updated MessagingConfigurationInstance """ @@ -132,7 +130,7 @@ async def update_async( """ Asynchronous coroutine to update the MessagingConfigurationInstance - :param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/sms/services/api) to be used to send SMS to the country of this configuration. + :param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) to be used to send SMS to the country of this configuration. :returns: The updated MessagingConfigurationInstance """ @@ -151,6 +149,7 @@ def __repr__(self) -> str: class MessagingConfigurationContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, country: str): """ Initialize the MessagingConfigurationContext @@ -177,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: """ @@ -189,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: @@ -202,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, @@ -222,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( @@ -238,20 +243,24 @@ def update(self, messaging_service_sid: str) -> MessagingConfigurationInstance: """ Update the MessagingConfigurationInstance - :param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/sms/services/api) to be used to send SMS to the country of this configuration. + :param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) to be used to send SMS to the country of this configuration. :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( @@ -267,20 +276,24 @@ async def update_async( """ Asynchronous coroutine to update the MessagingConfigurationInstance - :param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/sms/services/api) to be used to send SMS to the country of this configuration. + :param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) to be used to send SMS to the country of this configuration. :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( @@ -301,6 +314,7 @@ def __repr__(self) -> str: class MessagingConfigurationPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> MessagingConfigurationInstance: """ Build an instance of MessagingConfigurationInstance @@ -321,6 +335,7 @@ def __repr__(self) -> str: class MessagingConfigurationList(ListResource): + def __init__(self, version: Version, service_sid: str): """ Initialize the MessagingConfigurationList @@ -346,21 +361,25 @@ def create( Create the MessagingConfigurationInstance :param country: The [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of the country this configuration will be applied to. If this is a global configuration, Country will take the value `all`. - :param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/sms/services/api) to be used to send SMS to the country of this configuration. + :param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) to be used to send SMS to the country of this configuration. :returns: The created MessagingConfigurationInstance """ + data = values.of( { "Country": country, "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( @@ -374,21 +393,25 @@ async def create_async( Asynchronously create the MessagingConfigurationInstance :param country: The [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of the country this configuration will be applied to. If this is a global configuration, Country will take the value `all`. - :param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/sms/services/api) to be used to send SMS to the country of this configuration. + :param messaging_service_sid: The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) to be used to send SMS to the country of this configuration. :returns: The created MessagingConfigurationInstance """ + data = values.of( { "Country": country, "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( @@ -522,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( @@ -549,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 f411c57e65..ced5ab6a64 100644 --- a/twilio/rest/verify/v2/service/rate_limit/__init__.py +++ b/twilio/rest/verify/v2/service/rate_limit/__init__.py @@ -12,7 +12,6 @@ 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 @@ -25,7 +24,6 @@ class RateLimitInstance(InstanceResource): - """ :ivar sid: A 34 character string that uniquely identifies this Rate Limit. :ivar service_sid: The SID of the [Service](https://www.twilio.com/docs/verify/api/service) the resource is associated with. @@ -165,6 +163,7 @@ def __repr__(self) -> str: class RateLimitContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, sid: str): """ Initialize the RateLimitContext @@ -191,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: """ @@ -203,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: @@ -216,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, @@ -236,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( @@ -258,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( @@ -287,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( @@ -330,6 +343,7 @@ def __repr__(self) -> str: class RateLimitPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> RateLimitInstance: """ Build an instance of RateLimitInstance @@ -350,6 +364,7 @@ def __repr__(self) -> str: class RateLimitList(ListResource): + def __init__(self, version: Version, service_sid: str): """ Initialize the RateLimitList @@ -377,17 +392,21 @@ def create( :returns: The created RateLimitInstance """ + data = values.of( { "UniqueName": unique_name, "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( @@ -405,17 +424,21 @@ async def create_async( :returns: The created RateLimitInstance """ + data = values.of( { "UniqueName": unique_name, "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( @@ -549,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( @@ -576,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 a97b1e0171..4ac50cfc2f 100644 --- a/twilio/rest/verify/v2/service/rate_limit/bucket.py +++ b/twilio/rest/verify/v2/service/rate_limit/bucket.py @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class BucketInstance(InstanceResource): - """ :ivar sid: A 34 character string that uniquely identifies this Bucket. :ivar rate_limit_sid: The Twilio-provided string that uniquely identifies the Rate Limit resource. @@ -168,6 +166,7 @@ def __repr__(self) -> str: class BucketContext(InstanceContext): + def __init__( self, version: Version, service_sid: str, rate_limit_sid: str, sid: str ): @@ -200,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: """ @@ -212,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: @@ -225,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, @@ -246,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( @@ -272,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( @@ -306,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( @@ -338,6 +351,7 @@ def __repr__(self) -> str: class BucketPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> BucketInstance: """ Build an instance of BucketInstance @@ -361,6 +375,7 @@ def __repr__(self) -> str: class BucketList(ListResource): + def __init__(self, version: Version, service_sid: str, rate_limit_sid: str): """ Initialize the BucketList @@ -392,17 +407,21 @@ def create(self, max: int, interval: int) -> BucketInstance: :returns: The created BucketInstance """ + data = values.of( { "Max": max, "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( @@ -421,17 +440,21 @@ async def create_async(self, max: int, interval: int) -> BucketInstance: :returns: The created BucketInstance """ + data = values.of( { "Max": max, "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( @@ -568,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( @@ -595,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 2a72f7e110..64988a5983 100644 --- a/twilio/rest/verify/v2/service/verification.py +++ b/twilio/rest/verify/v2/service/verification.py @@ -12,7 +12,6 @@ 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 @@ -23,6 +22,7 @@ class VerificationInstance(InstanceResource): + class Channel(object): SMS = "sms" CALL = "call" @@ -30,6 +30,10 @@ class Channel(object): WHATSAPP = "whatsapp" SNA = "sna" + class RiskCheck(object): + ENABLE = "enable" + DISABLE = "disable" + class Status(object): CANCELED = "canceled" APPROVED = "approved" @@ -40,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. @@ -71,7 +75,7 @@ def __init__( self.lookup: Optional[Dict[str, object]] = payload.get("lookup") self.amount: Optional[str] = payload.get("amount") self.payee: Optional[str] = payload.get("payee") - self.send_code_attempts: Optional[List[object]] = payload.get( + self.send_code_attempts: Optional[List[Dict[str, object]]] = payload.get( "send_code_attempts" ) self.date_created: Optional[datetime] = deserialize.iso8601_datetime( @@ -160,6 +164,7 @@ def __repr__(self) -> str: class VerificationContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, sid: str): """ Initialize the VerificationContext @@ -187,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, @@ -207,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( @@ -227,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( @@ -256,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( @@ -286,6 +303,7 @@ def __repr__(self) -> str: class VerificationList(ListResource): + def __init__(self, version: Version, service_sid: str): """ Initialize the VerificationList @@ -319,6 +337,9 @@ 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: """ Create the VerificationInstance @@ -338,9 +359,13 @@ 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. :returns: The created VerificationInstance """ + data = values.of( { "To": to, @@ -358,13 +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( @@ -388,6 +421,9 @@ 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: """ Asynchronously create the VerificationInstance @@ -407,9 +443,13 @@ 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. :returns: The created VerificationInstance """ + data = values.of( { "To": to, @@ -427,13 +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 05a8399f87..c09057ebe1 100644 --- a/twilio/rest/verify/v2/service/verification_check.py +++ b/twilio/rest/verify/v2/service/verification_check.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import datetime from typing import Any, Dict, List, Optional, Union from twilio.base import deserialize, values @@ -23,6 +22,7 @@ class VerificationCheckInstance(InstanceResource): + class Channel(object): SMS = "sms" CALL = "call" @@ -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. @@ -65,7 +65,7 @@ def __init__(self, version: Version, payload: Dict[str, Any], service_sid: str): self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( payload.get("date_updated") ) - self.sna_attempts_error_codes: Optional[List[object]] = payload.get( + self.sna_attempts_error_codes: Optional[List[Dict[str, object]]] = payload.get( "sna_attempts_error_codes" ) @@ -84,6 +84,7 @@ def __repr__(self) -> str: class VerificationCheckList(ListResource): + def __init__(self, version: Version, service_sid: str): """ Initialize the VerificationCheckList @@ -107,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 @@ -116,9 +118,11 @@ 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 """ + data = values.of( { "Code": code, @@ -126,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( @@ -146,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 @@ -155,9 +164,11 @@ 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 """ + data = values.of( { "Code": code, @@ -165,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 c7924db4bf..dd68cf301b 100644 --- a/twilio/rest/verify/v2/service/webhook.py +++ b/twilio/rest/verify/v2/service/webhook.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class WebhookInstance(InstanceResource): + class Methods(object): GET = "GET" POST = "POST" @@ -202,6 +202,7 @@ def __repr__(self) -> str: class WebhookContext(InstanceContext): + def __init__(self, version: Version, service_sid: str, sid: str): """ Initialize the WebhookContext @@ -226,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: """ @@ -238,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: @@ -251,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, @@ -271,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( @@ -302,6 +309,7 @@ def update( :returns: The updated WebhookInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -311,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( @@ -344,6 +355,7 @@ async def update_async( :returns: The updated WebhookInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -353,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( @@ -378,6 +393,7 @@ def __repr__(self) -> str: class WebhookPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> WebhookInstance: """ Build an instance of WebhookInstance @@ -398,6 +414,7 @@ def __repr__(self) -> str: class WebhookList(ListResource): + def __init__(self, version: Version, service_sid: str): """ Initialize the WebhookList @@ -433,6 +450,7 @@ def create( :returns: The created WebhookInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -442,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( @@ -472,6 +493,7 @@ async def create_async( :returns: The created WebhookInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -481,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( @@ -619,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( @@ -646,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 c644746fc5..5a242c153e 100644 --- a/twilio/rest/verify/v2/template.py +++ b/twilio/rest/verify/v2/template.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import values @@ -23,12 +22,11 @@ class TemplateInstance(InstanceResource): - """ :ivar sid: A 34 character string that uniquely identifies a Verification Template. :ivar account_sid: The unique SID identifier of the Account. - :ivar friendly_name: A descriptive string that you create to describe a Template. - :ivar channels: A list of channels that support the Template. Can include: sms, voice + :ivar friendly_name: A descriptive string that you create to describe a Template. It can be up to 32 characters long. + :ivar channels: A list of channels that support the Template. Can include: sms, voice. :ivar translations: An object that contains the different translations of the template. Every translation is identified by the language short name and contains its respective information as the approval status, text and created/modified date. """ @@ -52,6 +50,7 @@ def __repr__(self) -> str: class TemplatePage(Page): + def get_instance(self, payload: Dict[str, Any]) -> TemplateInstance: """ Build an instance of TemplateInstance @@ -70,6 +69,7 @@ def __repr__(self) -> str: class TemplateList(ListResource): + def __init__(self, version: Version): """ Initialize the TemplateList @@ -93,7 +93,7 @@ def stream( is reached. The results are returned as a generator, so this operation is memory efficient. - :param str friendly_name: String filter used to query templates with a given friendly name + :param str friendly_name: String filter used to query templates with a given friendly name. :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 @@ -120,7 +120,7 @@ async def stream_async( is reached. The results are returned as a generator, so this operation is memory efficient. - :param str friendly_name: String filter used to query templates with a given friendly name + :param str friendly_name: String filter used to query templates with a given friendly name. :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 @@ -148,7 +148,7 @@ def list( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param str friendly_name: String filter used to query templates with a given friendly name + :param str friendly_name: String filter used to query templates with a given friendly name. :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 @@ -177,7 +177,7 @@ async def list_async( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param str friendly_name: String filter used to query templates with a given friendly name + :param str friendly_name: String filter used to query templates with a given friendly name. :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 @@ -207,7 +207,7 @@ def page( Retrieve a single page of TemplateInstance records from the API. Request is executed immediately - :param friendly_name: String filter used to query templates with a given friendly name + :param friendly_name: String filter used to query templates with a given friendly name. :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 @@ -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( @@ -237,7 +243,7 @@ async def page_async( Asynchronously retrieve a single page of TemplateInstance records from the API. Request is executed immediately - :param friendly_name: String filter used to query templates with a given friendly name + :param friendly_name: String filter used to query templates with a given friendly name. :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 @@ -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 1e7f827d27..8014924567 100644 --- a/twilio/rest/verify/v2/verification_attempt.py +++ b/twilio/rest/verify/v2/verification_attempt.py @@ -12,7 +12,6 @@ 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 @@ -24,11 +23,13 @@ class VerificationAttemptInstance(InstanceResource): + class Channels(object): SMS = "sms" CALL = "call" EMAIL = "email" WHATSAPP = "whatsapp" + RBM = "rbm" class ConversionStatus(object): CONVERTED = "converted" @@ -43,7 +44,7 @@ class ConversionStatus(object): :ivar date_updated: The date that this Attempt was updated, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. :ivar conversion_status: :ivar channel: - :ivar price: An object containing the charge for this verification attempt related to the channel costs and the currency used. The costs related to the succeeded verifications are not included. May not be immediately available. More information on pricing is available [here](https://www.twilio.com/verify/pricing). + :ivar price: An object containing the charge for this verification attempt related to the channel costs and the currency used. The costs related to the succeeded verifications are not included. May not be immediately available. More information on pricing is available [here](https://www.twilio.com/en-us/verify/pricing). :ivar channel_data: An object containing the channel specific information for an attempt. :ivar url: """ @@ -122,6 +123,7 @@ def __repr__(self) -> str: class VerificationAttemptContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the VerificationAttemptContext @@ -145,10 +147,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, @@ -164,9 +167,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( @@ -186,6 +192,7 @@ def __repr__(self) -> str: class VerificationAttemptPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> VerificationAttemptInstance: """ Build an instance of VerificationAttemptInstance @@ -204,6 +211,7 @@ def __repr__(self) -> str: class VerificationAttemptList(ListResource): + def __init__(self, version: Version): """ Initialize the VerificationAttemptList @@ -236,11 +244,11 @@ def stream( is reached. The results are returned as a generator, so this operation is memory efficient. - :param datetime date_created_after: Datetime filter used to query Verification Attempts created after this datetime. Given as GMT in RFC 2822 format. - :param datetime date_created_before: Datetime filter used to query Verification Attempts created before this datetime. Given as GMT in RFC 2822 format. + :param datetime date_created_after: Datetime filter used to consider only Verification Attempts created after this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z. + :param datetime date_created_before: Datetime filter used to consider only Verification Attempts created before this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z. :param str channel_data_to: Destination of a verification. It is phone number in E.164 format. :param str country: Filter used to query Verification Attempts sent to the specified destination country. - :param "VerificationAttemptInstance.Channels" channel: Filter used to query Verification Attempts by communication channel. Valid values are `SMS` and `CALL` + :param "VerificationAttemptInstance.Channels" channel: Filter used to query Verification Attempts by communication channel. :param str verify_service_sid: Filter used to query Verification Attempts by verify service. Only attempts of the provided SID will be returned. :param str verification_sid: Filter used to return all the Verification Attempts of a single verification. Only attempts of the provided verification SID will be returned. :param "VerificationAttemptInstance.ConversionStatus" status: Filter used to query Verification Attempts by conversion status. Valid values are `UNCONVERTED`, for attempts that were not converted, and `CONVERTED`, for attempts that were confirmed. @@ -289,11 +297,11 @@ async def stream_async( is reached. The results are returned as a generator, so this operation is memory efficient. - :param datetime date_created_after: Datetime filter used to query Verification Attempts created after this datetime. Given as GMT in RFC 2822 format. - :param datetime date_created_before: Datetime filter used to query Verification Attempts created before this datetime. Given as GMT in RFC 2822 format. + :param datetime date_created_after: Datetime filter used to consider only Verification Attempts created after this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z. + :param datetime date_created_before: Datetime filter used to consider only Verification Attempts created before this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z. :param str channel_data_to: Destination of a verification. It is phone number in E.164 format. :param str country: Filter used to query Verification Attempts sent to the specified destination country. - :param "VerificationAttemptInstance.Channels" channel: Filter used to query Verification Attempts by communication channel. Valid values are `SMS` and `CALL` + :param "VerificationAttemptInstance.Channels" channel: Filter used to query Verification Attempts by communication channel. :param str verify_service_sid: Filter used to query Verification Attempts by verify service. Only attempts of the provided SID will be returned. :param str verification_sid: Filter used to return all the Verification Attempts of a single verification. Only attempts of the provided verification SID will be returned. :param "VerificationAttemptInstance.ConversionStatus" status: Filter used to query Verification Attempts by conversion status. Valid values are `UNCONVERTED`, for attempts that were not converted, and `CONVERTED`, for attempts that were confirmed. @@ -341,11 +349,11 @@ def list( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param datetime date_created_after: Datetime filter used to query Verification Attempts created after this datetime. Given as GMT in RFC 2822 format. - :param datetime date_created_before: Datetime filter used to query Verification Attempts created before this datetime. Given as GMT in RFC 2822 format. + :param datetime date_created_after: Datetime filter used to consider only Verification Attempts created after this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z. + :param datetime date_created_before: Datetime filter used to consider only Verification Attempts created before this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z. :param str channel_data_to: Destination of a verification. It is phone number in E.164 format. :param str country: Filter used to query Verification Attempts sent to the specified destination country. - :param "VerificationAttemptInstance.Channels" channel: Filter used to query Verification Attempts by communication channel. Valid values are `SMS` and `CALL` + :param "VerificationAttemptInstance.Channels" channel: Filter used to query Verification Attempts by communication channel. :param str verify_service_sid: Filter used to query Verification Attempts by verify service. Only attempts of the provided SID will be returned. :param str verification_sid: Filter used to return all the Verification Attempts of a single verification. Only attempts of the provided verification SID will be returned. :param "VerificationAttemptInstance.ConversionStatus" status: Filter used to query Verification Attempts by conversion status. Valid values are `UNCONVERTED`, for attempts that were not converted, and `CONVERTED`, for attempts that were confirmed. @@ -393,11 +401,11 @@ async def list_async( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param datetime date_created_after: Datetime filter used to query Verification Attempts created after this datetime. Given as GMT in RFC 2822 format. - :param datetime date_created_before: Datetime filter used to query Verification Attempts created before this datetime. Given as GMT in RFC 2822 format. + :param datetime date_created_after: Datetime filter used to consider only Verification Attempts created after this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z. + :param datetime date_created_before: Datetime filter used to consider only Verification Attempts created before this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z. :param str channel_data_to: Destination of a verification. It is phone number in E.164 format. :param str country: Filter used to query Verification Attempts sent to the specified destination country. - :param "VerificationAttemptInstance.Channels" channel: Filter used to query Verification Attempts by communication channel. Valid values are `SMS` and `CALL` + :param "VerificationAttemptInstance.Channels" channel: Filter used to query Verification Attempts by communication channel. :param str verify_service_sid: Filter used to query Verification Attempts by verify service. Only attempts of the provided SID will be returned. :param str verification_sid: Filter used to return all the Verification Attempts of a single verification. Only attempts of the provided verification SID will be returned. :param "VerificationAttemptInstance.ConversionStatus" status: Filter used to query Verification Attempts by conversion status. Valid values are `UNCONVERTED`, for attempts that were not converted, and `CONVERTED`, for attempts that were confirmed. @@ -446,11 +454,11 @@ def page( Retrieve a single page of VerificationAttemptInstance records from the API. Request is executed immediately - :param date_created_after: Datetime filter used to query Verification Attempts created after this datetime. Given as GMT in RFC 2822 format. - :param date_created_before: Datetime filter used to query Verification Attempts created before this datetime. Given as GMT in RFC 2822 format. + :param date_created_after: Datetime filter used to consider only Verification Attempts created after this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z. + :param date_created_before: Datetime filter used to consider only Verification Attempts created before this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z. :param channel_data_to: Destination of a verification. It is phone number in E.164 format. :param country: Filter used to query Verification Attempts sent to the specified destination country. - :param channel: Filter used to query Verification Attempts by communication channel. Valid values are `SMS` and `CALL` + :param channel: Filter used to query Verification Attempts by communication channel. :param verify_service_sid: Filter used to query Verification Attempts by verify service. Only attempts of the provided SID will be returned. :param verification_sid: Filter used to return all the Verification Attempts of a single verification. Only attempts of the provided verification SID will be returned. :param status: Filter used to query Verification Attempts by conversion status. Valid values are `UNCONVERTED`, for attempts that were not converted, and `CONVERTED`, for attempts that were confirmed. @@ -476,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 VerificationAttemptPage(self._version, response) async def page_async( @@ -499,11 +513,11 @@ async def page_async( Asynchronously retrieve a single page of VerificationAttemptInstance records from the API. Request is executed immediately - :param date_created_after: Datetime filter used to query Verification Attempts created after this datetime. Given as GMT in RFC 2822 format. - :param date_created_before: Datetime filter used to query Verification Attempts created before this datetime. Given as GMT in RFC 2822 format. + :param date_created_after: Datetime filter used to consider only Verification Attempts created after this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z. + :param date_created_before: Datetime filter used to consider only Verification Attempts created before this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z. :param channel_data_to: Destination of a verification. It is phone number in E.164 format. :param country: Filter used to query Verification Attempts sent to the specified destination country. - :param channel: Filter used to query Verification Attempts by communication channel. Valid values are `SMS` and `CALL` + :param channel: Filter used to query Verification Attempts by communication channel. :param verify_service_sid: Filter used to query Verification Attempts by verify service. Only attempts of the provided SID will be returned. :param verification_sid: Filter used to return all the Verification Attempts of a single verification. Only attempts of the provided verification SID will be returned. :param status: Filter used to query Verification Attempts by conversion status. Valid values are `UNCONVERTED`, for attempts that were not converted, and `CONVERTED`, for attempts that were confirmed. @@ -529,8 +543,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/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 d516143708..7c9c22b76b 100644 --- a/twilio/rest/verify/v2/verification_attempts_summary.py +++ b/twilio/rest/verify/v2/verification_attempts_summary.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import datetime from typing import Any, Dict, Optional, Union from twilio.base import deserialize, serialize, values @@ -23,11 +22,13 @@ class VerificationAttemptsSummaryInstance(InstanceResource): + class Channels(object): SMS = "sms" CALL = "call" EMAIL = "email" WHATSAPP = "whatsapp" + RBM = "rbm" """ :ivar total_attempts: Total of attempts made according to the provided filters @@ -49,8 +50,8 @@ def __init__(self, version: Version, payload: Dict[str, Any]): self.total_unconverted: Optional[int] = deserialize.integer( payload.get("total_unconverted") ) - self.conversion_rate_percentage: Optional[float] = deserialize.decimal( - payload.get("conversion_rate_percentage") + self.conversion_rate_percentage: Optional[str] = payload.get( + "conversion_rate_percentage" ) self.url: Optional[str] = payload.get("url") @@ -85,10 +86,10 @@ def fetch( Fetch the VerificationAttemptsSummaryInstance :param verify_service_sid: Filter used to consider only Verification Attempts of the given verify service on the summary aggregation. - :param date_created_after: Datetime filter used to consider only Verification Attempts created after this datetime on the summary aggregation. Given as GMT in RFC 2822 format. - :param date_created_before: Datetime filter used to consider only Verification Attempts created before this datetime on the summary aggregation. Given as GMT in RFC 2822 format. + :param date_created_after: Datetime filter used to consider only Verification Attempts created after this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z. + :param date_created_before: Datetime filter used to consider only Verification Attempts created before this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z. :param country: Filter used to consider only Verification Attempts sent to the specified destination country on the summary aggregation. - :param channel: Filter Verification Attempts considered on the summary aggregation by communication channel. Valid values are `SMS` and `CALL` + :param channel: Filter Verification Attempts considered on the summary aggregation by communication channel. :param destination_prefix: Filter the Verification Attempts considered on the summary aggregation by Destination prefix. It is the prefix of a phone number in E.164 format. :returns: The fetched VerificationAttemptsSummaryInstance @@ -117,10 +118,10 @@ async def fetch_async( Asynchronous coroutine to fetch the VerificationAttemptsSummaryInstance :param verify_service_sid: Filter used to consider only Verification Attempts of the given verify service on the summary aggregation. - :param date_created_after: Datetime filter used to consider only Verification Attempts created after this datetime on the summary aggregation. Given as GMT in RFC 2822 format. - :param date_created_before: Datetime filter used to consider only Verification Attempts created before this datetime on the summary aggregation. Given as GMT in RFC 2822 format. + :param date_created_after: Datetime filter used to consider only Verification Attempts created after this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z. + :param date_created_before: Datetime filter used to consider only Verification Attempts created before this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z. :param country: Filter used to consider only Verification Attempts sent to the specified destination country on the summary aggregation. - :param channel: Filter Verification Attempts considered on the summary aggregation by communication channel. Valid values are `SMS` and `CALL` + :param channel: Filter Verification Attempts considered on the summary aggregation by communication channel. :param destination_prefix: Filter the Verification Attempts considered on the summary aggregation by Destination prefix. It is the prefix of a phone number in E.164 format. :returns: The fetched VerificationAttemptsSummaryInstance @@ -145,6 +146,7 @@ def __repr__(self) -> str: class VerificationAttemptsSummaryContext(InstanceContext): + def __init__(self, version: Version): """ Initialize the VerificationAttemptsSummaryContext @@ -170,10 +172,10 @@ def fetch( Fetch the VerificationAttemptsSummaryInstance :param verify_service_sid: Filter used to consider only Verification Attempts of the given verify service on the summary aggregation. - :param date_created_after: Datetime filter used to consider only Verification Attempts created after this datetime on the summary aggregation. Given as GMT in RFC 2822 format. - :param date_created_before: Datetime filter used to consider only Verification Attempts created before this datetime on the summary aggregation. Given as GMT in RFC 2822 format. + :param date_created_after: Datetime filter used to consider only Verification Attempts created after this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z. + :param date_created_before: Datetime filter used to consider only Verification Attempts created before this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z. :param country: Filter used to consider only Verification Attempts sent to the specified destination country on the summary aggregation. - :param channel: Filter Verification Attempts considered on the summary aggregation by communication channel. Valid values are `SMS` and `CALL` + :param channel: Filter Verification Attempts considered on the summary aggregation by communication channel. :param destination_prefix: Filter the Verification Attempts considered on the summary aggregation by Destination prefix. It is the prefix of a phone number in E.164 format. :returns: The fetched VerificationAttemptsSummaryInstance @@ -190,7 +192,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, @@ -212,10 +220,10 @@ async def fetch_async( Asynchronous coroutine to fetch the VerificationAttemptsSummaryInstance :param verify_service_sid: Filter used to consider only Verification Attempts of the given verify service on the summary aggregation. - :param date_created_after: Datetime filter used to consider only Verification Attempts created after this datetime on the summary aggregation. Given as GMT in RFC 2822 format. - :param date_created_before: Datetime filter used to consider only Verification Attempts created before this datetime on the summary aggregation. Given as GMT in RFC 2822 format. + :param date_created_after: Datetime filter used to consider only Verification Attempts created after this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z. + :param date_created_before: Datetime filter used to consider only Verification Attempts created before this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd'T'HH:mm:ss'Z. :param country: Filter used to consider only Verification Attempts sent to the specified destination country on the summary aggregation. - :param channel: Filter Verification Attempts considered on the summary aggregation by communication channel. Valid values are `SMS` and `CALL` + :param channel: Filter Verification Attempts considered on the summary aggregation by communication channel. :param destination_prefix: Filter the Verification Attempts considered on the summary aggregation by Destination prefix. It is the prefix of a phone number in E.164 format. :returns: The fetched VerificationAttemptsSummaryInstance @@ -232,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 VerificationAttemptsSummaryInstance( @@ -252,6 +264,7 @@ def __repr__(self) -> str: class VerificationAttemptsSummaryList(ListResource): + def __init__(self, version: Version): """ Initialize the VerificationAttemptsSummaryList diff --git a/twilio/rest/video/VideoBase.py b/twilio/rest/video/VideoBase.py index 2a25345662..0d2cf7e364 100644 --- a/twilio/rest/video/VideoBase.py +++ b/twilio/rest/video/VideoBase.py @@ -17,6 +17,7 @@ class VideoBase(Domain): + def __init__(self, twilio: Client): """ Initialize the Video Domain diff --git a/twilio/rest/video/v1/__init__.py b/twilio/rest/video/v1/__init__.py index 9cd9fcf352..0667596a3f 100644 --- a/twilio/rest/video/v1/__init__.py +++ b/twilio/rest/video/v1/__init__.py @@ -24,6 +24,7 @@ class V1(Version): + def __init__(self, domain: Domain): """ Initialize the V1 version of Video diff --git a/twilio/rest/video/v1/composition.py b/twilio/rest/video/v1/composition.py index 2fead14204..06f4d05f5f 100644 --- a/twilio/rest/video/v1/composition.py +++ b/twilio/rest/video/v1/composition.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class CompositionInstance(InstanceResource): + class Format(object): MP4 = "mp4" WEBM = "webm" @@ -165,6 +165,7 @@ def __repr__(self) -> str: class CompositionContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the CompositionContext @@ -187,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: """ @@ -199,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: @@ -212,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, @@ -231,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( @@ -253,6 +260,7 @@ def __repr__(self) -> str: class CompositionPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> CompositionInstance: """ Build an instance of CompositionInstance @@ -271,6 +279,7 @@ def __repr__(self) -> str: class CompositionList(ListResource): + def __init__(self, version: Version): """ Initialize the CompositionList @@ -309,6 +318,7 @@ def create( :returns: The created CompositionInstance """ + data = values.of( { "RoomSid": room_sid, @@ -321,14 +331,17 @@ def create( "Format": format, "StatusCallback": status_callback, "StatusCallbackMethod": status_callback_method, - "Trim": trim, + "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) @@ -360,6 +373,7 @@ async def create_async( :returns: The created CompositionInstance """ + data = values.of( { "RoomSid": room_sid, @@ -372,14 +386,17 @@ async def create_async( "Format": format, "StatusCallback": status_callback, "StatusCallbackMethod": status_callback_method, - "Trim": trim, + "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) @@ -575,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( @@ -614,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 e15c43c4ac..30fead17b0 100644 --- a/twilio/rest/video/v1/composition_hook.py +++ b/twilio/rest/video/v1/composition_hook.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class CompositionHookInstance(InstanceResource): + class Format(object): MP4 = "mp4" WEBM = "webm" @@ -226,6 +226,7 @@ def __repr__(self) -> str: class CompositionHookContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the CompositionHookContext @@ -248,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: """ @@ -260,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: @@ -273,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, @@ -292,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( @@ -332,27 +339,31 @@ def update( :returns: The updated CompositionHookInstance """ + data = values.of( { "FriendlyName": friendly_name, - "Enabled": enabled, + "Enabled": serialize.boolean_to_string(enabled), "VideoLayout": serialize.object(video_layout), "AudioSources": serialize.map(audio_sources, lambda e: e), "AudioSourcesExcluded": serialize.map( audio_sources_excluded, lambda e: e ), - "Trim": trim, + "Trim": serialize.boolean_to_string(trim), "Format": format, "Resolution": resolution, "StatusCallback": status_callback, "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( @@ -388,27 +399,31 @@ async def update_async( :returns: The updated CompositionHookInstance """ + data = values.of( { "FriendlyName": friendly_name, - "Enabled": enabled, + "Enabled": serialize.boolean_to_string(enabled), "VideoLayout": serialize.object(video_layout), "AudioSources": serialize.map(audio_sources, lambda e: e), "AudioSourcesExcluded": serialize.map( audio_sources_excluded, lambda e: e ), - "Trim": trim, + "Trim": serialize.boolean_to_string(trim), "Format": format, "Resolution": resolution, "StatusCallback": status_callback, "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( @@ -426,6 +441,7 @@ def __repr__(self) -> str: class CompositionHookPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> CompositionHookInstance: """ Build an instance of CompositionHookInstance @@ -444,6 +460,7 @@ def __repr__(self) -> str: class CompositionHookList(ListResource): + def __init__(self, version: Version): """ Initialize the CompositionHookList @@ -484,10 +501,11 @@ def create( :returns: The created CompositionHookInstance """ + data = values.of( { "FriendlyName": friendly_name, - "Enabled": enabled, + "Enabled": serialize.boolean_to_string(enabled), "VideoLayout": serialize.object(video_layout), "AudioSources": serialize.map(audio_sources, lambda e: e), "AudioSourcesExcluded": serialize.map( @@ -497,14 +515,17 @@ def create( "Format": format, "StatusCallback": status_callback, "StatusCallbackMethod": status_callback_method, - "Trim": trim, + "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) @@ -538,10 +559,11 @@ async def create_async( :returns: The created CompositionHookInstance """ + data = values.of( { "FriendlyName": friendly_name, - "Enabled": enabled, + "Enabled": serialize.boolean_to_string(enabled), "VideoLayout": serialize.object(video_layout), "AudioSources": serialize.map(audio_sources, lambda e: e), "AudioSourcesExcluded": serialize.map( @@ -551,14 +573,17 @@ async def create_async( "Format": format, "StatusCallback": status_callback, "StatusCallbackMethod": status_callback_method, - "Trim": trim, + "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) @@ -744,7 +769,7 @@ def page( """ data = values.of( { - "Enabled": enabled, + "Enabled": serialize.boolean_to_string(enabled), "DateCreatedAfter": serialize.iso8601_datetime(date_created_after), "DateCreatedBefore": serialize.iso8601_datetime(date_created_before), "FriendlyName": friendly_name, @@ -754,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( @@ -783,7 +814,7 @@ async def page_async( """ data = values.of( { - "Enabled": enabled, + "Enabled": serialize.boolean_to_string(enabled), "DateCreatedAfter": serialize.iso8601_datetime(date_created_after), "DateCreatedBefore": serialize.iso8601_datetime(date_created_before), "FriendlyName": friendly_name, @@ -793,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 42d10368d2..384ae692e8 100644 --- a/twilio/rest/video/v1/composition_settings.py +++ b/twilio/rest/video/v1/composition_settings.py @@ -12,9 +12,8 @@ Do not edit the class manually. """ - from typing import Any, Dict, Optional, Union -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 @@ -22,12 +21,11 @@ class CompositionSettingsInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the CompositionSettings resource. :ivar friendly_name: The string that you assigned to describe the resource and that will be shown in the console :ivar aws_credentials_sid: The SID of the stored Credential resource. - :ivar aws_s3_url: The URL of the AWS S3 bucket where the compositions are stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/compositions`, where `compositions` is the path in which you want the compositions to be stored. This URL accepts only URI-valid characters, as described in the RFC 3986. + :ivar aws_s3_url: The URL of the AWS S3 bucket where the compositions are stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/compositions`, where `compositions` is the path in which you want the compositions to be stored. This URL accepts only URI-valid characters, as described in the [RFC 3986](https://tools.ietf.org/html/rfc3986#section-2). :ivar aws_storage_enabled: Whether all compositions are written to the `aws_s3_url`. When `false`, all compositions are stored in our cloud. :ivar encryption_key_sid: The SID of the Public Key resource used for encryption. :ivar encryption_enabled: Whether all compositions are stored in an encrypted form. The default is `false`. @@ -77,7 +75,7 @@ def create( :param friendly_name: A descriptive string that you create to describe the resource and show to the user in the console :param aws_credentials_sid: The SID of the stored Credential resource. :param encryption_key_sid: The SID of the Public Key resource to use for encryption. - :param aws_s3_url: The URL of the AWS S3 bucket where the compositions should be stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/compositions`, where `compositions` is the path in which you want the compositions to be stored. This URL accepts only URI-valid characters, as described in the RFC 3986. + :param aws_s3_url: The URL of the AWS S3 bucket where the compositions should be stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/compositions`, where `compositions` is the path in which you want the compositions to be stored. This URL accepts only URI-valid characters, as described in the [RFC 3986](https://tools.ietf.org/html/rfc3986#section-2). :param aws_storage_enabled: Whether all compositions should be written to the `aws_s3_url`. When `false`, all compositions are stored in our cloud. :param encryption_enabled: Whether all compositions should be stored in an encrypted form. The default is `false`. @@ -107,7 +105,7 @@ async def create_async( :param friendly_name: A descriptive string that you create to describe the resource and show to the user in the console :param aws_credentials_sid: The SID of the stored Credential resource. :param encryption_key_sid: The SID of the Public Key resource to use for encryption. - :param aws_s3_url: The URL of the AWS S3 bucket where the compositions should be stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/compositions`, where `compositions` is the path in which you want the compositions to be stored. This URL accepts only URI-valid characters, as described in the RFC 3986. + :param aws_s3_url: The URL of the AWS S3 bucket where the compositions should be stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/compositions`, where `compositions` is the path in which you want the compositions to be stored. This URL accepts only URI-valid characters, as described in the [RFC 3986](https://tools.ietf.org/html/rfc3986#section-2). :param aws_storage_enabled: Whether all compositions should be written to the `aws_s3_url`. When `false`, all compositions are stored in our cloud. :param encryption_enabled: Whether all compositions should be stored in an encrypted form. The default is `false`. @@ -151,6 +149,7 @@ def __repr__(self) -> str: class CompositionSettingsContext(InstanceContext): + def __init__(self, version: Version): """ Initialize the CompositionSettingsContext @@ -176,7 +175,7 @@ def create( :param friendly_name: A descriptive string that you create to describe the resource and show to the user in the console :param aws_credentials_sid: The SID of the stored Credential resource. :param encryption_key_sid: The SID of the Public Key resource to use for encryption. - :param aws_s3_url: The URL of the AWS S3 bucket where the compositions should be stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/compositions`, where `compositions` is the path in which you want the compositions to be stored. This URL accepts only URI-valid characters, as described in the RFC 3986. + :param aws_s3_url: The URL of the AWS S3 bucket where the compositions should be stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/compositions`, where `compositions` is the path in which you want the compositions to be stored. This URL accepts only URI-valid characters, as described in the [RFC 3986](https://tools.ietf.org/html/rfc3986#section-2). :param aws_storage_enabled: Whether all compositions should be written to the `aws_s3_url`. When `false`, all compositions are stored in our cloud. :param encryption_enabled: Whether all compositions should be stored in an encrypted form. The default is `false`. @@ -188,8 +187,8 @@ def create( "AwsCredentialsSid": aws_credentials_sid, "EncryptionKeySid": encryption_key_sid, "AwsS3Url": aws_s3_url, - "AwsStorageEnabled": aws_storage_enabled, - "EncryptionEnabled": encryption_enabled, + "AwsStorageEnabled": serialize.boolean_to_string(aws_storage_enabled), + "EncryptionEnabled": serialize.boolean_to_string(encryption_enabled), } ) @@ -212,7 +211,7 @@ async def create_async( :param friendly_name: A descriptive string that you create to describe the resource and show to the user in the console :param aws_credentials_sid: The SID of the stored Credential resource. :param encryption_key_sid: The SID of the Public Key resource to use for encryption. - :param aws_s3_url: The URL of the AWS S3 bucket where the compositions should be stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/compositions`, where `compositions` is the path in which you want the compositions to be stored. This URL accepts only URI-valid characters, as described in the RFC 3986. + :param aws_s3_url: The URL of the AWS S3 bucket where the compositions should be stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/compositions`, where `compositions` is the path in which you want the compositions to be stored. This URL accepts only URI-valid characters, as described in the [RFC 3986](https://tools.ietf.org/html/rfc3986#section-2). :param aws_storage_enabled: Whether all compositions should be written to the `aws_s3_url`. When `false`, all compositions are stored in our cloud. :param encryption_enabled: Whether all compositions should be stored in an encrypted form. The default is `false`. @@ -224,8 +223,8 @@ async def create_async( "AwsCredentialsSid": aws_credentials_sid, "EncryptionKeySid": encryption_key_sid, "AwsS3Url": aws_s3_url, - "AwsStorageEnabled": aws_storage_enabled, - "EncryptionEnabled": encryption_enabled, + "AwsStorageEnabled": serialize.boolean_to_string(aws_storage_enabled), + "EncryptionEnabled": serialize.boolean_to_string(encryption_enabled), } ) @@ -243,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, @@ -261,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( @@ -282,6 +285,7 @@ def __repr__(self) -> str: class CompositionSettingsList(ListResource): + def __init__(self, version: Version): """ Initialize the CompositionSettingsList diff --git a/twilio/rest/video/v1/recording.py b/twilio/rest/video/v1/recording.py index af0973776f..f474345fe0 100644 --- a/twilio/rest/video/v1/recording.py +++ b/twilio/rest/video/v1/recording.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class RecordingInstance(InstanceResource): + class Codec(object): VP8 = "VP8" H264 = "H264" @@ -165,6 +165,7 @@ def __repr__(self) -> str: class RecordingContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the RecordingContext @@ -187,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: """ @@ -199,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: @@ -212,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, @@ -231,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( @@ -253,6 +260,7 @@ def __repr__(self) -> str: class RecordingPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> RecordingInstance: """ Build an instance of RecordingInstance @@ -271,6 +279,7 @@ def __repr__(self) -> str: class RecordingList(ListResource): + def __init__(self, version: Version): """ Initialize the RecordingList @@ -503,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( @@ -548,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 2e3a4750f6..46259b6cf8 100644 --- a/twilio/rest/video/v1/recording_settings.py +++ b/twilio/rest/video/v1/recording_settings.py @@ -12,9 +12,8 @@ Do not edit the class manually. """ - from typing import Any, Dict, Optional, Union -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 @@ -22,12 +21,11 @@ class RecordingSettingsInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the RecordingSettings resource. :ivar friendly_name: The string that you assigned to describe the resource and show the user in the console :ivar aws_credentials_sid: The SID of the stored Credential resource. - :ivar aws_s3_url: The URL of the AWS S3 bucket where the recordings are stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/recordings`, where `recordings` is the path in which you want the recordings to be stored. This URL accepts only URI-valid characters, as described in the RFC 3986. + :ivar aws_s3_url: The URL of the AWS S3 bucket where the recordings are stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/recordings`, where `recordings` is the path in which you want the recordings to be stored. This URL accepts only URI-valid characters, as described in the [RFC 3986](https://tools.ietf.org/html/rfc3986#section-2). :ivar aws_storage_enabled: Whether all recordings are written to the `aws_s3_url`. When `false`, all recordings are stored in our cloud. :ivar encryption_key_sid: The SID of the Public Key resource used for encryption. :ivar encryption_enabled: Whether all recordings are stored in an encrypted form. The default is `false`. @@ -77,7 +75,7 @@ def create( :param friendly_name: A descriptive string that you create to describe the resource and be shown to users in the console :param aws_credentials_sid: The SID of the stored Credential resource. :param encryption_key_sid: The SID of the Public Key resource to use for encryption. - :param aws_s3_url: The URL of the AWS S3 bucket where the recordings should be stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/recordings`, where `recordings` is the path in which you want the recordings to be stored. This URL accepts only URI-valid characters, as described in the RFC 3986. + :param aws_s3_url: The URL of the AWS S3 bucket where the recordings should be stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/recordings`, where `recordings` is the path in which you want the recordings to be stored. This URL accepts only URI-valid characters, as described in the [RFC 3986](https://tools.ietf.org/html/rfc3986#section-2). :param aws_storage_enabled: Whether all recordings should be written to the `aws_s3_url`. When `false`, all recordings are stored in our cloud. :param encryption_enabled: Whether all recordings should be stored in an encrypted form. The default is `false`. @@ -107,7 +105,7 @@ async def create_async( :param friendly_name: A descriptive string that you create to describe the resource and be shown to users in the console :param aws_credentials_sid: The SID of the stored Credential resource. :param encryption_key_sid: The SID of the Public Key resource to use for encryption. - :param aws_s3_url: The URL of the AWS S3 bucket where the recordings should be stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/recordings`, where `recordings` is the path in which you want the recordings to be stored. This URL accepts only URI-valid characters, as described in the RFC 3986. + :param aws_s3_url: The URL of the AWS S3 bucket where the recordings should be stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/recordings`, where `recordings` is the path in which you want the recordings to be stored. This URL accepts only URI-valid characters, as described in the [RFC 3986](https://tools.ietf.org/html/rfc3986#section-2). :param aws_storage_enabled: Whether all recordings should be written to the `aws_s3_url`. When `false`, all recordings are stored in our cloud. :param encryption_enabled: Whether all recordings should be stored in an encrypted form. The default is `false`. @@ -151,6 +149,7 @@ def __repr__(self) -> str: class RecordingSettingsContext(InstanceContext): + def __init__(self, version: Version): """ Initialize the RecordingSettingsContext @@ -176,7 +175,7 @@ def create( :param friendly_name: A descriptive string that you create to describe the resource and be shown to users in the console :param aws_credentials_sid: The SID of the stored Credential resource. :param encryption_key_sid: The SID of the Public Key resource to use for encryption. - :param aws_s3_url: The URL of the AWS S3 bucket where the recordings should be stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/recordings`, where `recordings` is the path in which you want the recordings to be stored. This URL accepts only URI-valid characters, as described in the RFC 3986. + :param aws_s3_url: The URL of the AWS S3 bucket where the recordings should be stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/recordings`, where `recordings` is the path in which you want the recordings to be stored. This URL accepts only URI-valid characters, as described in the [RFC 3986](https://tools.ietf.org/html/rfc3986#section-2). :param aws_storage_enabled: Whether all recordings should be written to the `aws_s3_url`. When `false`, all recordings are stored in our cloud. :param encryption_enabled: Whether all recordings should be stored in an encrypted form. The default is `false`. @@ -188,8 +187,8 @@ def create( "AwsCredentialsSid": aws_credentials_sid, "EncryptionKeySid": encryption_key_sid, "AwsS3Url": aws_s3_url, - "AwsStorageEnabled": aws_storage_enabled, - "EncryptionEnabled": encryption_enabled, + "AwsStorageEnabled": serialize.boolean_to_string(aws_storage_enabled), + "EncryptionEnabled": serialize.boolean_to_string(encryption_enabled), } ) @@ -212,7 +211,7 @@ async def create_async( :param friendly_name: A descriptive string that you create to describe the resource and be shown to users in the console :param aws_credentials_sid: The SID of the stored Credential resource. :param encryption_key_sid: The SID of the Public Key resource to use for encryption. - :param aws_s3_url: The URL of the AWS S3 bucket where the recordings should be stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/recordings`, where `recordings` is the path in which you want the recordings to be stored. This URL accepts only URI-valid characters, as described in the RFC 3986. + :param aws_s3_url: The URL of the AWS S3 bucket where the recordings should be stored. We only support DNS-compliant URLs like `https://documentation-example-twilio-bucket/recordings`, where `recordings` is the path in which you want the recordings to be stored. This URL accepts only URI-valid characters, as described in the [RFC 3986](https://tools.ietf.org/html/rfc3986#section-2). :param aws_storage_enabled: Whether all recordings should be written to the `aws_s3_url`. When `false`, all recordings are stored in our cloud. :param encryption_enabled: Whether all recordings should be stored in an encrypted form. The default is `false`. @@ -224,8 +223,8 @@ async def create_async( "AwsCredentialsSid": aws_credentials_sid, "EncryptionKeySid": encryption_key_sid, "AwsS3Url": aws_s3_url, - "AwsStorageEnabled": aws_storage_enabled, - "EncryptionEnabled": encryption_enabled, + "AwsStorageEnabled": serialize.boolean_to_string(aws_storage_enabled), + "EncryptionEnabled": serialize.boolean_to_string(encryption_enabled), } ) @@ -243,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, @@ -261,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( @@ -282,6 +285,7 @@ def __repr__(self) -> str: class RecordingSettingsList(ListResource): + def __init__(self, version: Version): """ Initialize the RecordingSettingsList diff --git a/twilio/rest/video/v1/room/__init__.py b/twilio/rest/video/v1/room/__init__.py index a3a4256590..12854e9bfe 100644 --- a/twilio/rest/video/v1/room/__init__.py +++ b/twilio/rest/video/v1/room/__init__.py @@ -12,7 +12,6 @@ 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 @@ -24,9 +23,11 @@ from twilio.rest.video.v1.room.participant import ParticipantList from twilio.rest.video.v1.room.recording_rules import RecordingRulesList from twilio.rest.video.v1.room.room_recording import RoomRecordingList +from twilio.rest.video.v1.room.transcriptions import TranscriptionsList class RoomInstance(InstanceResource): + class RoomStatus(object): IN_PROGRESS = "in-progress" COMPLETED = "completed" @@ -43,25 +44,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-address-whitelisting#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. @@ -204,6 +205,13 @@ def recordings(self) -> RoomRecordingList: """ return self._proxy.recordings + @property + def transcriptions(self) -> TranscriptionsList: + """ + Access the transcriptions + """ + return self._proxy.transcriptions + def __repr__(self) -> str: """ Provide a friendly representation @@ -215,6 +223,7 @@ def __repr__(self) -> str: class RoomContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the RoomContext @@ -233,6 +242,7 @@ def __init__(self, version: Version, sid: str): self._participants: Optional[ParticipantList] = None self._recording_rules: Optional[RecordingRulesList] = None self._recordings: Optional[RoomRecordingList] = None + self._transcriptions: Optional[TranscriptionsList] = None def fetch(self) -> RoomInstance: """ @@ -242,10 +252,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, @@ -261,9 +272,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( @@ -280,16 +294,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"]) @@ -302,16 +320,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"]) @@ -352,6 +374,18 @@ def recordings(self) -> RoomRecordingList: ) return self._recordings + @property + def transcriptions(self) -> TranscriptionsList: + """ + Access the transcriptions + """ + if self._transcriptions is None: + self._transcriptions = TranscriptionsList( + self._version, + self._solution["sid"], + ) + return self._transcriptions + def __repr__(self) -> str: """ Provide a friendly representation @@ -363,6 +397,7 @@ def __repr__(self) -> str: class RoomPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> RoomInstance: """ Build an instance of RoomInstance @@ -381,6 +416,7 @@ def __repr__(self) -> str: class RoomList(ListResource): + def __init__(self, version: Version): """ Initialize the RoomList @@ -401,9 +437,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, @@ -416,14 +454,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-address-whitelisting#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). @@ -431,30 +471,42 @@ def create( :returns: The created RoomInstance """ + data = values.of( { - "EnableTurn": enable_turn, + "EnableTurn": serialize.boolean_to_string(enable_turn), "Type": type, "UniqueName": unique_name, "StatusCallback": status_callback, "StatusCallbackMethod": status_callback_method, "MaxParticipants": max_participants, - "RecordParticipantsOnConnect": record_participants_on_connect, + "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), - "AudioOnly": audio_only, + "TranscriptionsConfiguration": serialize.object( + transcriptions_configuration + ), + "AudioOnly": serialize.boolean_to_string(audio_only), "MaxParticipantDuration": max_participant_duration, "EmptyRoomTimeout": empty_room_timeout, "UnusedRoomTimeout": unused_room_timeout, - "LargeRoom": large_room, + "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) @@ -468,9 +520,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, @@ -483,14 +537,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-address-whitelisting#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). @@ -498,30 +554,42 @@ async def create_async( :returns: The created RoomInstance """ + data = values.of( { - "EnableTurn": enable_turn, + "EnableTurn": serialize.boolean_to_string(enable_turn), "Type": type, "UniqueName": unique_name, "StatusCallback": status_callback, "StatusCallbackMethod": status_callback_method, "MaxParticipants": max_participants, - "RecordParticipantsOnConnect": record_participants_on_connect, + "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), - "AudioOnly": audio_only, + "TranscriptionsConfiguration": serialize.object( + transcriptions_configuration + ), + "AudioOnly": serialize.boolean_to_string(audio_only), "MaxParticipantDuration": max_participant_duration, "EmptyRoomTimeout": empty_room_timeout, "UnusedRoomTimeout": unused_room_timeout, - "LargeRoom": large_room, + "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) @@ -717,7 +785,13 @@ def page( } ) - response = self._version.page(method="GET", uri=self._uri, params=data) + headers = values.of({"Content-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( @@ -756,8 +830,12 @@ async def page_async( } ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/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 f8a21ba6a1..7e012e8d37 100644 --- a/twilio/rest/video/v1/room/participant/__init__.py +++ b/twilio/rest/video/v1/room/participant/__init__.py @@ -12,7 +12,6 @@ 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 @@ -28,9 +27,11 @@ 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. @@ -184,6 +185,7 @@ def __repr__(self) -> str: class ParticipantContext(InstanceContext): + def __init__(self, version: Version, room_sid: str, sid: str): """ Initialize the ParticipantContext @@ -214,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, @@ -234,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( @@ -256,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( @@ -285,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( @@ -367,6 +381,7 @@ def __repr__(self) -> str: class ParticipantPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ParticipantInstance: """ Build an instance of ParticipantInstance @@ -387,6 +402,7 @@ def __repr__(self) -> str: class ParticipantList(ListResource): + def __init__(self, version: Version, room_sid: str): """ Initialize the ParticipantList @@ -594,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( @@ -633,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 415c5b1f20..0560d3eff4 100644 --- a/twilio/rest/video/v1/room/participant/anonymize.py +++ b/twilio/rest/video/v1/room/participant/anonymize.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import datetime from typing import Any, Dict, Optional from twilio.base import deserialize, values @@ -23,6 +22,7 @@ class AnonymizeInstance(InstanceResource): + class Status(object): CONNECTED = "connected" DISCONNECTED = "disconnected" @@ -117,6 +117,7 @@ def __repr__(self) -> str: class AnonymizeContext(InstanceContext): + def __init__(self, version: Version, room_sid: str, sid: str): """ Initialize the AnonymizeContext @@ -143,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( @@ -165,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( @@ -191,6 +196,7 @@ def __repr__(self) -> str: class AnonymizeList(ListResource): + def __init__(self, version: Version, room_sid: str, sid: str): """ Initialize the AnonymizeList diff --git a/twilio/rest/video/v1/room/participant/published_track.py b/twilio/rest/video/v1/room/participant/published_track.py index a5156fee8f..a766b276ab 100644 --- a/twilio/rest/video/v1/room/participant/published_track.py +++ b/twilio/rest/video/v1/room/participant/published_track.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class PublishedTrackInstance(InstanceResource): + class Kind(object): AUDIO = "audio" VIDEO = "video" @@ -118,6 +118,7 @@ def __repr__(self) -> str: class PublishedTrackContext(InstanceContext): + def __init__(self, version: Version, room_sid: str, participant_sid: str, sid: str): """ Initialize the PublishedTrackContext @@ -147,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, @@ -168,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( @@ -192,6 +197,7 @@ def __repr__(self) -> str: class PublishedTrackPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> PublishedTrackInstance: """ Build an instance of PublishedTrackInstance @@ -215,6 +221,7 @@ def __repr__(self) -> str: class PublishedTrackList(ListResource): + def __init__(self, version: Version, room_sid: str, participant_sid: str): """ Initialize the PublishedTrackList @@ -364,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( @@ -391,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 28e3976d15..992f8a374b 100644 --- a/twilio/rest/video/v1/room/participant/subscribe_rules.py +++ b/twilio/rest/video/v1/room/participant/subscribe_rules.py @@ -12,7 +12,6 @@ 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 @@ -23,7 +22,6 @@ class SubscribeRulesInstance(InstanceResource): - """ :ivar participant_sid: The SID of the Participant resource for the Subscribe Rules. :ivar room_sid: The SID of the Room resource for the Subscribe Rules @@ -67,6 +65,7 @@ def __repr__(self) -> str: class SubscribeRulesList(ListResource): + def __init__(self, version: Version, room_sid: str, participant_sid: str): """ Initialize the SubscribeRulesList @@ -93,9 +92,14 @@ def fetch(self) -> SubscribeRulesInstance: """ Asynchronously fetch the SubscribeRulesInstance + :returns: The fetched SubscribeRulesInstance """ - payload = self._version.fetch(method="GET", uri=self._uri) + 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 SubscribeRulesInstance( self._version, @@ -108,9 +112,16 @@ async def fetch_async(self) -> SubscribeRulesInstance: """ Asynchronously fetch the SubscribeRulesInstance + :returns: The fetched SubscribeRulesInstance """ - payload = await self._version.fetch_async(method="GET", uri=self._uri) + 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 SubscribeRulesInstance( self._version, @@ -129,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( @@ -158,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 627015a44a..8baea148dc 100644 --- a/twilio/rest/video/v1/room/participant/subscribed_track.py +++ b/twilio/rest/video/v1/room/participant/subscribed_track.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class SubscribedTrackInstance(InstanceResource): + class Kind(object): AUDIO = "audio" VIDEO = "video" @@ -120,6 +120,7 @@ def __repr__(self) -> str: class SubscribedTrackContext(InstanceContext): + def __init__(self, version: Version, room_sid: str, participant_sid: str, sid: str): """ Initialize the SubscribedTrackContext @@ -149,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, @@ -170,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( @@ -194,6 +199,7 @@ def __repr__(self) -> str: class SubscribedTrackPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> SubscribedTrackInstance: """ Build an instance of SubscribedTrackInstance @@ -217,6 +223,7 @@ def __repr__(self) -> str: class SubscribedTrackList(ListResource): + def __init__(self, version: Version, room_sid: str, participant_sid: str): """ Initialize the SubscribedTrackList @@ -366,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( @@ -393,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 68adaed070..d79d465c28 100644 --- a/twilio/rest/video/v1/room/recording_rules.py +++ b/twilio/rest/video/v1/room/recording_rules.py @@ -12,7 +12,6 @@ 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 @@ -23,7 +22,6 @@ class RecordingRulesInstance(InstanceResource): - """ :ivar room_sid: The SID of the Room resource for the Recording Rules :ivar rules: A collection of Recording Rules that describe how to include or exclude matching tracks for recording @@ -58,6 +56,7 @@ def __repr__(self) -> str: class RecordingRulesList(ListResource): + def __init__(self, version: Version, room_sid: str): """ Initialize the RecordingRulesList @@ -78,9 +77,14 @@ def fetch(self) -> RecordingRulesInstance: """ Asynchronously fetch the RecordingRulesInstance + :returns: The fetched RecordingRulesInstance """ - payload = self._version.fetch(method="GET", uri=self._uri) + 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 RecordingRulesInstance( self._version, payload, room_sid=self._solution["room_sid"] @@ -90,9 +94,16 @@ async def fetch_async(self) -> RecordingRulesInstance: """ Asynchronously fetch the RecordingRulesInstance + :returns: The fetched RecordingRulesInstance """ - payload = await self._version.fetch_async(method="GET", uri=self._uri) + 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 RecordingRulesInstance( self._version, payload, room_sid=self._solution["room_sid"] @@ -108,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( @@ -134,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 481422eacb..21d433ce38 100644 --- a/twilio/rest/video/v1/room/room_recording.py +++ b/twilio/rest/video/v1/room/room_recording.py @@ -12,7 +12,6 @@ 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 @@ -24,6 +23,7 @@ class RoomRecordingInstance(InstanceResource): + class Codec(object): VP8 = "VP8" H264 = "H264" @@ -167,6 +167,7 @@ def __repr__(self) -> str: class RoomRecordingContext(InstanceContext): + def __init__(self, version: Version, room_sid: str, sid: str): """ Initialize the RoomRecordingContext @@ -191,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: """ @@ -203,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: @@ -216,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, @@ -236,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( @@ -259,6 +266,7 @@ def __repr__(self) -> str: class RoomRecordingPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> RoomRecordingInstance: """ Build an instance of RoomRecordingInstance @@ -279,6 +287,7 @@ def __repr__(self) -> str: class RoomRecordingList(ListResource): + def __init__(self, version: Version, room_sid: str): """ Initialize the RoomRecordingList @@ -486,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( @@ -525,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/video/v1/room/transcriptions.py b/twilio/rest/video/v1/room/transcriptions.py new file mode 100644 index 0000000000..3754063038 --- /dev/null +++ b/twilio/rest/video/v1/room/transcriptions.py @@ -0,0 +1,610 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Video + 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 TranscriptionsInstance(InstanceResource): + + class Status(object): + STARTED = "started" + STOPPED = "stopped" + FAILED = "failed" + + """ + :ivar ttid: The unique string that we created to identify the transcriptions resource. + :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Room resource. + :ivar room_sid: The SID of the transcriptions's room. + :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 start_time: The time of transcriptions connected to the room in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#UTC) format. + :ivar end_time: The time when the transcriptions disconnected from the room in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#UTC) format. + :ivar duration: The duration in seconds that the transcriptions were `connected`. Populated only after the transcriptions is `stopped`. + :ivar url: The absolute URL of the resource. + :ivar configuration: An JSON object that describes the video layout of the composition in terms of regions. See [Specifying Video Layouts](https://www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info. + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + room_sid: str, + ttid: Optional[str] = None, + ): + super().__init__(version) + + self.ttid: Optional[str] = payload.get("ttid") + self.account_sid: Optional[str] = payload.get("account_sid") + self.room_sid: Optional[str] = payload.get("room_sid") + self.status: Optional["TranscriptionsInstance.Status"] = payload.get("status") + 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.start_time: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("start_time") + ) + self.end_time: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("end_time") + ) + self.duration: Optional[int] = deserialize.integer(payload.get("duration")) + self.url: Optional[str] = payload.get("url") + self.configuration: Optional[Dict[str, object]] = payload.get("configuration") + + self._solution = { + "room_sid": room_sid, + "ttid": ttid or self.ttid, + } + self._context: Optional[TranscriptionsContext] = None + + @property + def _proxy(self) -> "TranscriptionsContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: TranscriptionsContext for this TranscriptionsInstance + """ + if self._context is None: + self._context = TranscriptionsContext( + self._version, + room_sid=self._solution["room_sid"], + ttid=self._solution["ttid"], + ) + return self._context + + def fetch(self) -> "TranscriptionsInstance": + """ + Fetch the TranscriptionsInstance + + + :returns: The fetched TranscriptionsInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "TranscriptionsInstance": + """ + Asynchronous coroutine to fetch the TranscriptionsInstance + + + :returns: The fetched TranscriptionsInstance + """ + return await self._proxy.fetch_async() + + def update( + self, status: Union["TranscriptionsInstance.Status", object] = values.unset + ) -> "TranscriptionsInstance": + """ + Update the TranscriptionsInstance + + :param status: + + :returns: The updated TranscriptionsInstance + """ + return self._proxy.update( + status=status, + ) + + async def update_async( + self, status: Union["TranscriptionsInstance.Status", object] = values.unset + ) -> "TranscriptionsInstance": + """ + Asynchronous coroutine to update the TranscriptionsInstance + + :param status: + + :returns: The updated TranscriptionsInstance + """ + 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 TranscriptionsContext(InstanceContext): + + def __init__(self, version: Version, room_sid: str, ttid: str): + """ + Initialize the TranscriptionsContext + + :param version: Version that contains the resource + :param room_sid: The SID of the room with the transcriptions resource to update. + :param ttid: The Twilio type id of the transcriptions resource to update. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "room_sid": room_sid, + "ttid": ttid, + } + self._uri = "/Rooms/{room_sid}/Transcriptions/{ttid}".format(**self._solution) + + def fetch(self) -> TranscriptionsInstance: + """ + Fetch the TranscriptionsInstance + + + :returns: The fetched TranscriptionsInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = self._version.fetch(method="GET", uri=self._uri, headers=headers) + + return TranscriptionsInstance( + self._version, + payload, + room_sid=self._solution["room_sid"], + ttid=self._solution["ttid"], + ) + + async def fetch_async(self) -> TranscriptionsInstance: + """ + Asynchronous coroutine to fetch the TranscriptionsInstance + + + :returns: The fetched TranscriptionsInstance + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + payload = await self._version.fetch_async( + method="GET", uri=self._uri, headers=headers + ) + + return TranscriptionsInstance( + self._version, + payload, + room_sid=self._solution["room_sid"], + ttid=self._solution["ttid"], + ) + + def update( + self, status: Union["TranscriptionsInstance.Status", object] = values.unset + ) -> TranscriptionsInstance: + """ + Update the TranscriptionsInstance + + :param status: + + :returns: The updated TranscriptionsInstance + """ + + 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 TranscriptionsInstance( + self._version, + payload, + room_sid=self._solution["room_sid"], + ttid=self._solution["ttid"], + ) + + async def update_async( + self, status: Union["TranscriptionsInstance.Status", object] = values.unset + ) -> TranscriptionsInstance: + """ + Asynchronous coroutine to update the TranscriptionsInstance + + :param status: + + :returns: The updated TranscriptionsInstance + """ + + 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 TranscriptionsInstance( + self._version, + payload, + room_sid=self._solution["room_sid"], + ttid=self._solution["ttid"], + ) + + 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 TranscriptionsPage(Page): + + def get_instance(self, payload: Dict[str, Any]) -> TranscriptionsInstance: + """ + Build an instance of TranscriptionsInstance + + :param payload: Payload response from the API + """ + return TranscriptionsInstance( + self._version, payload, room_sid=self._solution["room_sid"] + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" + + +class TranscriptionsList(ListResource): + + def __init__(self, version: Version, room_sid: str): + """ + Initialize the TranscriptionsList + + :param version: Version that contains the resource + :param room_sid: The SID of the room with the transcriptions resources to read. + + """ + super().__init__(version) + + # Path Solution + self._solution = { + "room_sid": room_sid, + } + self._uri = "/Rooms/{room_sid}/Transcriptions".format(**self._solution) + + def create( + self, configuration: Union[object, object] = values.unset + ) -> TranscriptionsInstance: + """ + Create the TranscriptionsInstance + + :param configuration: A collection of properties that describe transcription behaviour. + + :returns: The created TranscriptionsInstance + """ + + data = values.of( + { + "Configuration": serialize.object(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 TranscriptionsInstance( + self._version, payload, room_sid=self._solution["room_sid"] + ) + + async def create_async( + self, configuration: Union[object, object] = values.unset + ) -> TranscriptionsInstance: + """ + Asynchronously create the TranscriptionsInstance + + :param configuration: A collection of properties that describe transcription behaviour. + + :returns: The created TranscriptionsInstance + """ + + data = values.of( + { + "Configuration": serialize.object(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 TranscriptionsInstance( + self._version, payload, room_sid=self._solution["room_sid"] + ) + + def stream( + self, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[TranscriptionsInstance]: + """ + Streams TranscriptionsInstance 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[TranscriptionsInstance]: + """ + Asynchronously streams TranscriptionsInstance 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[TranscriptionsInstance]: + """ + Lists TranscriptionsInstance 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[TranscriptionsInstance]: + """ + Asynchronously lists TranscriptionsInstance 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, + ) -> TranscriptionsPage: + """ + Retrieve a single page of TranscriptionsInstance 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 TranscriptionsInstance + """ + 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 TranscriptionsPage(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, + ) -> TranscriptionsPage: + """ + Asynchronously retrieve a single page of TranscriptionsInstance 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 TranscriptionsInstance + """ + 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 TranscriptionsPage(self._version, response, self._solution) + + def get_page(self, target_url: str) -> TranscriptionsPage: + """ + Retrieve a specific page of TranscriptionsInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of TranscriptionsInstance + """ + response = self._version.domain.twilio.request("GET", target_url) + return TranscriptionsPage(self._version, response, self._solution) + + async def get_page_async(self, target_url: str) -> TranscriptionsPage: + """ + Asynchronously retrieve a specific page of TranscriptionsInstance records from the API. + Request is executed immediately + + :param target_url: API-generated URL for the requested results page + + :returns: Page of TranscriptionsInstance + """ + response = await self._version.domain.twilio.request_async("GET", target_url) + return TranscriptionsPage(self._version, response, self._solution) + + def get(self, ttid: str) -> TranscriptionsContext: + """ + Constructs a TranscriptionsContext + + :param ttid: The Twilio type id of the transcriptions resource to update. + """ + return TranscriptionsContext( + self._version, room_sid=self._solution["room_sid"], ttid=ttid + ) + + def __call__(self, ttid: str) -> TranscriptionsContext: + """ + Constructs a TranscriptionsContext + + :param ttid: The Twilio type id of the transcriptions resource to update. + """ + return TranscriptionsContext( + self._version, room_sid=self._solution["room_sid"], ttid=ttid + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/voice/VoiceBase.py b/twilio/rest/voice/VoiceBase.py index 21a11ce350..4394ab1a2d 100644 --- a/twilio/rest/voice/VoiceBase.py +++ b/twilio/rest/voice/VoiceBase.py @@ -17,6 +17,7 @@ class VoiceBase(Domain): + def __init__(self, twilio: Client): """ Initialize the Voice Domain diff --git a/twilio/rest/voice/v1/__init__.py b/twilio/rest/voice/v1/__init__.py index 2014cd1626..75c0c7fc74 100644 --- a/twilio/rest/voice/v1/__init__.py +++ b/twilio/rest/voice/v1/__init__.py @@ -24,6 +24,7 @@ class V1(Version): + def __init__(self, domain: Domain): """ Initialize the V1 version of Voice diff --git a/twilio/rest/voice/v1/archived_call.py b/twilio/rest/voice/v1/archived_call.py index de13e682da..939f1a03e2 100644 --- a/twilio/rest/voice/v1/archived_call.py +++ b/twilio/rest/voice/v1/archived_call.py @@ -12,8 +12,8 @@ Do not edit the class manually. """ - from datetime import date +from twilio.base import values from twilio.base.instance_context import InstanceContext from twilio.base.list_resource import ListResource @@ -21,6 +21,7 @@ class ArchivedCallContext(InstanceContext): + def __init__(self, version: Version, date: date, sid: str): """ Initialize the ArchivedCallContext @@ -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: @@ -73,6 +76,7 @@ def __repr__(self) -> str: class ArchivedCallList(ListResource): + def __init__(self, version: Version): """ Initialize the ArchivedCallList diff --git a/twilio/rest/voice/v1/byoc_trunk.py b/twilio/rest/voice/v1/byoc_trunk.py index 88ed49dcbc..304bdd78a5 100644 --- a/twilio/rest/voice/v1/byoc_trunk.py +++ b/twilio/rest/voice/v1/byoc_trunk.py @@ -12,10 +12,9 @@ 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 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 @@ -24,7 +23,6 @@ class ByocTrunkInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the BYOC Trunk resource. :ivar sid: The unique string that that we created to identify the BYOC Trunk resource. @@ -221,6 +219,7 @@ def __repr__(self) -> str: class ByocTrunkContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the ByocTrunkContext @@ -243,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: """ @@ -255,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: @@ -268,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, @@ -287,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( @@ -327,6 +332,7 @@ def update( :returns: The updated ByocTrunkInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -336,16 +342,19 @@ def update( "VoiceFallbackMethod": voice_fallback_method, "StatusCallbackUrl": status_callback_url, "StatusCallbackMethod": status_callback_method, - "CnamLookupEnabled": cnam_lookup_enabled, + "CnamLookupEnabled": serialize.boolean_to_string(cnam_lookup_enabled), "ConnectionPolicySid": connection_policy_sid, "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"]) @@ -379,6 +388,7 @@ async def update_async( :returns: The updated ByocTrunkInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -388,16 +398,19 @@ async def update_async( "VoiceFallbackMethod": voice_fallback_method, "StatusCallbackUrl": status_callback_url, "StatusCallbackMethod": status_callback_method, - "CnamLookupEnabled": cnam_lookup_enabled, + "CnamLookupEnabled": serialize.boolean_to_string(cnam_lookup_enabled), "ConnectionPolicySid": connection_policy_sid, "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"]) @@ -413,6 +426,7 @@ def __repr__(self) -> str: class ByocTrunkPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ByocTrunkInstance: """ Build an instance of ByocTrunkInstance @@ -431,6 +445,7 @@ def __repr__(self) -> str: class ByocTrunkList(ListResource): + def __init__(self, version: Version): """ Initialize the ByocTrunkList @@ -471,6 +486,7 @@ def create( :returns: The created ByocTrunkInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -480,16 +496,19 @@ def create( "VoiceFallbackMethod": voice_fallback_method, "StatusCallbackUrl": status_callback_url, "StatusCallbackMethod": status_callback_method, - "CnamLookupEnabled": cnam_lookup_enabled, + "CnamLookupEnabled": serialize.boolean_to_string(cnam_lookup_enabled), "ConnectionPolicySid": connection_policy_sid, "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) @@ -523,6 +542,7 @@ async def create_async( :returns: The created ByocTrunkInstance """ + data = values.of( { "FriendlyName": friendly_name, @@ -532,16 +552,19 @@ async def create_async( "VoiceFallbackMethod": voice_fallback_method, "StatusCallbackUrl": status_callback_url, "StatusCallbackMethod": status_callback_method, - "CnamLookupEnabled": cnam_lookup_enabled, + "CnamLookupEnabled": serialize.boolean_to_string(cnam_lookup_enabled), "ConnectionPolicySid": connection_policy_sid, "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) @@ -673,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( @@ -700,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 e1c26dc495..e2a56929c7 100644 --- a/twilio/rest/voice/v1/connection_policy/__init__.py +++ b/twilio/rest/voice/v1/connection_policy/__init__.py @@ -12,7 +12,6 @@ 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 @@ -27,7 +26,6 @@ class ConnectionPolicyInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Connection Policy resource. :ivar sid: The unique string that we created to identify the Connection Policy resource. @@ -157,6 +155,7 @@ def __repr__(self) -> str: class ConnectionPolicyContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the ConnectionPolicyContext @@ -181,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: """ @@ -193,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: @@ -206,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, @@ -225,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( @@ -246,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( @@ -272,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( @@ -311,6 +324,7 @@ def __repr__(self) -> str: class ConnectionPolicyPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ConnectionPolicyInstance: """ Build an instance of ConnectionPolicyInstance @@ -329,6 +343,7 @@ def __repr__(self) -> str: class ConnectionPolicyList(ListResource): + def __init__(self, version: Version): """ Initialize the ConnectionPolicyList @@ -350,16 +365,20 @@ def create( :returns: The created ConnectionPolicyInstance """ + data = values.of( { "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) @@ -374,16 +393,20 @@ async def create_async( :returns: The created ConnectionPolicyInstance """ + data = values.of( { "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) @@ -515,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( @@ -542,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 e617072cb2..03f4fd607d 100644 --- a/twilio/rest/voice/v1/connection_policy/connection_policy_target.py +++ b/twilio/rest/voice/v1/connection_policy/connection_policy_target.py @@ -12,10 +12,9 @@ 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 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 @@ -24,7 +23,6 @@ class ConnectionPolicyTargetInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Target resource. :ivar connection_policy_sid: The SID of the Connection Policy that owns the Target. @@ -187,6 +185,7 @@ def __repr__(self) -> str: class ConnectionPolicyTargetContext(InstanceContext): + def __init__(self, version: Version, connection_policy_sid: str, sid: str): """ Initialize the ConnectionPolicyTargetContext @@ -213,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: """ @@ -225,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: @@ -238,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, @@ -258,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( @@ -289,20 +294,24 @@ def update( :returns: The updated ConnectionPolicyTargetInstance """ + data = values.of( { "FriendlyName": friendly_name, "Target": target, "Priority": priority, "Weight": weight, - "Enabled": enabled, + "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( @@ -331,20 +340,24 @@ async def update_async( :returns: The updated ConnectionPolicyTargetInstance """ + data = values.of( { "FriendlyName": friendly_name, "Target": target, "Priority": priority, "Weight": weight, - "Enabled": enabled, + "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( @@ -365,6 +378,7 @@ def __repr__(self) -> str: class ConnectionPolicyTargetPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> ConnectionPolicyTargetInstance: """ Build an instance of ConnectionPolicyTargetInstance @@ -387,6 +401,7 @@ def __repr__(self) -> str: class ConnectionPolicyTargetList(ListResource): + def __init__(self, version: Version, connection_policy_sid: str): """ Initialize the ConnectionPolicyTargetList @@ -424,20 +439,24 @@ def create( :returns: The created ConnectionPolicyTargetInstance """ + data = values.of( { "Target": target, "FriendlyName": friendly_name, "Priority": priority, "Weight": weight, - "Enabled": enabled, + "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( @@ -465,20 +484,24 @@ async def create_async( :returns: The created ConnectionPolicyTargetInstance """ + data = values.of( { "Target": target, "FriendlyName": friendly_name, "Priority": priority, "Weight": weight, - "Enabled": enabled, + "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( @@ -614,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( @@ -641,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/__init__.py b/twilio/rest/voice/v1/dialing_permissions/__init__.py index 2de126841e..2346430adc 100644 --- a/twilio/rest/voice/v1/dialing_permissions/__init__.py +++ b/twilio/rest/voice/v1/dialing_permissions/__init__.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Optional @@ -27,6 +26,7 @@ class DialingPermissionsList(ListResource): + def __init__(self, version: Version): """ Initialize the DialingPermissionsList 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 3e4966c72e..4059be8dd7 100644 --- a/twilio/rest/voice/v1/dialing_permissions/bulk_country_update.py +++ b/twilio/rest/voice/v1/dialing_permissions/bulk_country_update.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, Optional from twilio.base import deserialize, values @@ -22,7 +21,6 @@ class BulkCountryUpdateInstance(InstanceResource): - """ :ivar update_count: The number of countries updated :ivar update_request: A bulk update request to change voice dialing country permissions stored as a URL-encoded, JSON array of update objects. For example : `[ { \"iso_code\": \"GB\", \"low_risk_numbers_enabled\": \"true\", \"high_risk_special_numbers_enabled\":\"true\", \"high_risk_tollfraud_numbers_enabled\": \"false\" } ]` @@ -47,6 +45,7 @@ def __repr__(self) -> str: class BulkCountryUpdateList(ListResource): + def __init__(self, version: Version): """ Initialize the BulkCountryUpdateList @@ -66,16 +65,20 @@ def create(self, update_request: str) -> BulkCountryUpdateInstance: :returns: The created BulkCountryUpdateInstance """ + data = values.of( { "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) @@ -88,16 +91,20 @@ async def create_async(self, update_request: str) -> BulkCountryUpdateInstance: :returns: The created BulkCountryUpdateInstance """ + data = values.of( { "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 fa1ad785b5..6a60c23a2f 100644 --- a/twilio/rest/voice/v1/dialing_permissions/country/__init__.py +++ b/twilio/rest/voice/v1/dialing_permissions/country/__init__.py @@ -12,9 +12,8 @@ Do not edit the class manually. """ - 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 @@ -26,7 +25,6 @@ class CountryInstance(InstanceResource): - """ :ivar iso_code: The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). :ivar name: The name of the country. @@ -34,7 +32,7 @@ class CountryInstance(InstanceResource): :ivar country_codes: The E.164 assigned [country codes(s)](https://www.itu.int/itudoc/itu-t/ob-lists/icc/e164_763.html) :ivar low_risk_numbers_enabled: Whether dialing to low-risk numbers is enabled. :ivar high_risk_special_numbers_enabled: Whether dialing to high-risk special services numbers is enabled. These prefixes include number ranges allocated by the country and include premium numbers, special services, shared cost, and others - :ivar high_risk_tollfraud_numbers_enabled: Whether dialing to high-risk [toll fraud](https://www.twilio.com/learn/voice-and-video/toll-fraud) numbers is enabled. These prefixes include narrow number ranges that have a high-risk of international revenue sharing fraud (IRSF) attacks, also known as [toll fraud](https://www.twilio.com/learn/voice-and-video/toll-fraud). These prefixes are collected from anti-fraud databases and verified by analyzing calls on our network. These prefixes are not available for download and are updated frequently + :ivar high_risk_tollfraud_numbers_enabled: Whether dialing to high-risk [toll fraud](https://www.twilio.com/blog/how-to-protect-your-account-from-toll-fraud-with-voice-dialing-geo-permissions-html) numbers is enabled. These prefixes include narrow number ranges that have a high-risk of international revenue sharing fraud (IRSF) attacks, also known as [toll fraud](https://www.twilio.com/blog/how-to-protect-your-account-from-toll-fraud-with-voice-dialing-geo-permissions-html). These prefixes are collected from anti-fraud databases and verified by analyzing calls on our network. These prefixes are not available for download and are updated frequently :ivar url: The absolute URL of this resource. :ivar links: A list of URLs related to this resource. """ @@ -116,6 +114,7 @@ def __repr__(self) -> str: class CountryContext(InstanceContext): + def __init__(self, version: Version, iso_code: str): """ Initialize the CountryContext @@ -141,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, @@ -160,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( @@ -194,6 +197,7 @@ def __repr__(self) -> str: class CountryPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> CountryInstance: """ Build an instance of CountryInstance @@ -212,6 +216,7 @@ def __repr__(self) -> str: class CountryList(ListResource): + def __init__(self, version: Version): """ Initialize the CountryList @@ -245,7 +250,7 @@ def stream( :param str country_code: Filter the results by specified [country codes](https://www.itu.int/itudoc/itu-t/ob-lists/icc/e164_763.html) :param bool low_risk_numbers_enabled: Filter to retrieve the country permissions with dialing to low-risk numbers enabled. Can be: `true` or `false`. :param bool high_risk_special_numbers_enabled: Filter to retrieve the country permissions with dialing to high-risk special service numbers enabled. Can be: `true` or `false` - :param bool high_risk_tollfraud_numbers_enabled: Filter to retrieve the country permissions with dialing to high-risk [toll fraud](https://www.twilio.com/learn/voice-and-video/toll-fraud) numbers enabled. Can be: `true` or `false`. + :param bool high_risk_tollfraud_numbers_enabled: Filter to retrieve the country permissions with dialing to high-risk [toll fraud](https://www.twilio.com/blog/how-to-protect-your-account-from-toll-fraud-with-voice-dialing-geo-permissions-html) numbers enabled. Can be: `true` or `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 @@ -290,7 +295,7 @@ async def stream_async( :param str country_code: Filter the results by specified [country codes](https://www.itu.int/itudoc/itu-t/ob-lists/icc/e164_763.html) :param bool low_risk_numbers_enabled: Filter to retrieve the country permissions with dialing to low-risk numbers enabled. Can be: `true` or `false`. :param bool high_risk_special_numbers_enabled: Filter to retrieve the country permissions with dialing to high-risk special service numbers enabled. Can be: `true` or `false` - :param bool high_risk_tollfraud_numbers_enabled: Filter to retrieve the country permissions with dialing to high-risk [toll fraud](https://www.twilio.com/learn/voice-and-video/toll-fraud) numbers enabled. Can be: `true` or `false`. + :param bool high_risk_tollfraud_numbers_enabled: Filter to retrieve the country permissions with dialing to high-risk [toll fraud](https://www.twilio.com/blog/how-to-protect-your-account-from-toll-fraud-with-voice-dialing-geo-permissions-html) numbers enabled. Can be: `true` or `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 @@ -334,7 +339,7 @@ def list( :param str country_code: Filter the results by specified [country codes](https://www.itu.int/itudoc/itu-t/ob-lists/icc/e164_763.html) :param bool low_risk_numbers_enabled: Filter to retrieve the country permissions with dialing to low-risk numbers enabled. Can be: `true` or `false`. :param bool high_risk_special_numbers_enabled: Filter to retrieve the country permissions with dialing to high-risk special service numbers enabled. Can be: `true` or `false` - :param bool high_risk_tollfraud_numbers_enabled: Filter to retrieve the country permissions with dialing to high-risk [toll fraud](https://www.twilio.com/learn/voice-and-video/toll-fraud) numbers enabled. Can be: `true` or `false`. + :param bool high_risk_tollfraud_numbers_enabled: Filter to retrieve the country permissions with dialing to high-risk [toll fraud](https://www.twilio.com/blog/how-to-protect-your-account-from-toll-fraud-with-voice-dialing-geo-permissions-html) numbers enabled. Can be: `true` or `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 @@ -378,7 +383,7 @@ async def list_async( :param str country_code: Filter the results by specified [country codes](https://www.itu.int/itudoc/itu-t/ob-lists/icc/e164_763.html) :param bool low_risk_numbers_enabled: Filter to retrieve the country permissions with dialing to low-risk numbers enabled. Can be: `true` or `false`. :param bool high_risk_special_numbers_enabled: Filter to retrieve the country permissions with dialing to high-risk special service numbers enabled. Can be: `true` or `false` - :param bool high_risk_tollfraud_numbers_enabled: Filter to retrieve the country permissions with dialing to high-risk [toll fraud](https://www.twilio.com/learn/voice-and-video/toll-fraud) numbers enabled. Can be: `true` or `false`. + :param bool high_risk_tollfraud_numbers_enabled: Filter to retrieve the country permissions with dialing to high-risk [toll fraud](https://www.twilio.com/blog/how-to-protect-your-account-from-toll-fraud-with-voice-dialing-geo-permissions-html) numbers enabled. Can be: `true` or `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 @@ -423,7 +428,7 @@ def page( :param country_code: Filter the results by specified [country codes](https://www.itu.int/itudoc/itu-t/ob-lists/icc/e164_763.html) :param low_risk_numbers_enabled: Filter to retrieve the country permissions with dialing to low-risk numbers enabled. Can be: `true` or `false`. :param high_risk_special_numbers_enabled: Filter to retrieve the country permissions with dialing to high-risk special service numbers enabled. Can be: `true` or `false` - :param high_risk_tollfraud_numbers_enabled: Filter to retrieve the country permissions with dialing to high-risk [toll fraud](https://www.twilio.com/learn/voice-and-video/toll-fraud) numbers enabled. Can be: `true` or `false`. + :param high_risk_tollfraud_numbers_enabled: Filter to retrieve the country permissions with dialing to high-risk [toll fraud](https://www.twilio.com/blog/how-to-protect-your-account-from-toll-fraud-with-voice-dialing-geo-permissions-html) numbers enabled. Can be: `true` or `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 @@ -435,16 +440,28 @@ def page( "IsoCode": iso_code, "Continent": continent, "CountryCode": country_code, - "LowRiskNumbersEnabled": low_risk_numbers_enabled, - "HighRiskSpecialNumbersEnabled": high_risk_special_numbers_enabled, - "HighRiskTollfraudNumbersEnabled": high_risk_tollfraud_numbers_enabled, + "LowRiskNumbersEnabled": serialize.boolean_to_string( + low_risk_numbers_enabled + ), + "HighRiskSpecialNumbersEnabled": serialize.boolean_to_string( + high_risk_special_numbers_enabled + ), + "HighRiskTollfraudNumbersEnabled": serialize.boolean_to_string( + high_risk_tollfraud_numbers_enabled + ), "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 CountryPage(self._version, response) async def page_async( @@ -468,7 +485,7 @@ async def page_async( :param country_code: Filter the results by specified [country codes](https://www.itu.int/itudoc/itu-t/ob-lists/icc/e164_763.html) :param low_risk_numbers_enabled: Filter to retrieve the country permissions with dialing to low-risk numbers enabled. Can be: `true` or `false`. :param high_risk_special_numbers_enabled: Filter to retrieve the country permissions with dialing to high-risk special service numbers enabled. Can be: `true` or `false` - :param high_risk_tollfraud_numbers_enabled: Filter to retrieve the country permissions with dialing to high-risk [toll fraud](https://www.twilio.com/learn/voice-and-video/toll-fraud) numbers enabled. Can be: `true` or `false`. + :param high_risk_tollfraud_numbers_enabled: Filter to retrieve the country permissions with dialing to high-risk [toll fraud](https://www.twilio.com/blog/how-to-protect-your-account-from-toll-fraud-with-voice-dialing-geo-permissions-html) numbers enabled. Can be: `true` or `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 @@ -480,17 +497,27 @@ async def page_async( "IsoCode": iso_code, "Continent": continent, "CountryCode": country_code, - "LowRiskNumbersEnabled": low_risk_numbers_enabled, - "HighRiskSpecialNumbersEnabled": high_risk_special_numbers_enabled, - "HighRiskTollfraudNumbersEnabled": high_risk_tollfraud_numbers_enabled, + "LowRiskNumbersEnabled": serialize.boolean_to_string( + low_risk_numbers_enabled + ), + "HighRiskSpecialNumbersEnabled": serialize.boolean_to_string( + high_risk_special_numbers_enabled + ), + "HighRiskTollfraudNumbersEnabled": serialize.boolean_to_string( + high_risk_tollfraud_numbers_enabled + ), "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 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 ef46284f20..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 @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import values @@ -23,7 +22,6 @@ class HighriskSpecialPrefixInstance(InstanceResource): - """ :ivar prefix: A prefix is a contiguous number range for a block of E.164 numbers that includes the E.164 assigned country code. For example, a North American Numbering Plan prefix like `+1510720` written like `+1(510) 720` matches all numbers inclusive from `+1(510) 720-0000` to `+1(510) 720-9999`. """ @@ -48,6 +46,7 @@ def __repr__(self) -> str: class HighriskSpecialPrefixPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> HighriskSpecialPrefixInstance: """ Build an instance of HighriskSpecialPrefixInstance @@ -68,6 +67,7 @@ def __repr__(self) -> str: class HighriskSpecialPrefixList(ListResource): + def __init__(self, version: Version, iso_code: str): """ Initialize the HighriskSpecialPrefixList @@ -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 5b762c742a..9e7aa0babb 100644 --- a/twilio/rest/voice/v1/dialing_permissions/settings.py +++ b/twilio/rest/voice/v1/dialing_permissions/settings.py @@ -12,9 +12,8 @@ Do not edit the class manually. """ - from typing import Any, Dict, Optional, Union -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 @@ -22,7 +21,6 @@ class SettingsInstance(InstanceResource): - """ :ivar dialing_permissions_inheritance: `true` if the sub-account will inherit voice dialing permissions from the Master Project; otherwise `false`. :ivar url: The absolute URL of this resource. @@ -109,6 +107,7 @@ def __repr__(self) -> str: class SettingsContext(InstanceContext): + def __init__(self, version: Version): """ Initialize the SettingsContext @@ -127,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, @@ -145,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( @@ -165,16 +168,22 @@ def update( :returns: The updated SettingsInstance """ + data = values.of( { - "DialingPermissionsInheritance": dialing_permissions_inheritance, + "DialingPermissionsInheritance": serialize.boolean_to_string( + dialing_permissions_inheritance + ), } ) + 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) @@ -189,16 +198,22 @@ async def update_async( :returns: The updated SettingsInstance """ + data = values.of( { - "DialingPermissionsInheritance": dialing_permissions_inheritance, + "DialingPermissionsInheritance": serialize.boolean_to_string( + dialing_permissions_inheritance + ), } ) + 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) @@ -214,6 +229,7 @@ def __repr__(self) -> str: class SettingsList(ListResource): + def __init__(self, version: Version): """ Initialize the SettingsList diff --git a/twilio/rest/voice/v1/ip_record.py b/twilio/rest/voice/v1/ip_record.py index c81322d423..05e9741fa5 100644 --- a/twilio/rest/voice/v1/ip_record.py +++ b/twilio/rest/voice/v1/ip_record.py @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class IpRecordInstance(InstanceResource): - """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the IP Record resource. :ivar sid: The unique string that we created to identify the IP Record resource. @@ -151,6 +149,7 @@ def __repr__(self) -> str: class IpRecordContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the IpRecordContext @@ -173,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: """ @@ -185,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: @@ -198,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, @@ -217,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( @@ -238,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"]) @@ -262,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"]) @@ -287,6 +300,7 @@ def __repr__(self) -> str: class IpRecordPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> IpRecordInstance: """ Build an instance of IpRecordInstance @@ -305,6 +319,7 @@ def __repr__(self) -> str: class IpRecordList(ListResource): + def __init__(self, version: Version): """ Initialize the IpRecordList @@ -331,6 +346,7 @@ def create( :returns: The created IpRecordInstance """ + data = values.of( { "IpAddress": ip_address, @@ -338,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) @@ -362,6 +381,7 @@ async def create_async( :returns: The created IpRecordInstance """ + data = values.of( { "IpAddress": ip_address, @@ -369,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) @@ -505,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( @@ -532,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 b61bee9cc5..749d2b0034 100644 --- a/twilio/rest/voice/v1/source_ip_mapping.py +++ b/twilio/rest/voice/v1/source_ip_mapping.py @@ -12,7 +12,6 @@ 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 @@ -24,7 +23,6 @@ class SourceIpMappingInstance(InstanceResource): - """ :ivar sid: The unique string that we created to identify the IP Record resource. :ivar ip_record_sid: The Twilio-provided string that uniquely identifies the IP Record resource to map from. @@ -141,6 +139,7 @@ def __repr__(self) -> str: class SourceIpMappingContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the SourceIpMappingContext @@ -163,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: """ @@ -175,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: @@ -188,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, @@ -207,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( @@ -226,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( @@ -250,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( @@ -277,6 +290,7 @@ def __repr__(self) -> str: class SourceIpMappingPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> SourceIpMappingInstance: """ Build an instance of SourceIpMappingInstance @@ -295,6 +309,7 @@ def __repr__(self) -> str: class SourceIpMappingList(ListResource): + def __init__(self, version: Version): """ Initialize the SourceIpMappingList @@ -317,17 +332,21 @@ def create( :returns: The created SourceIpMappingInstance """ + data = values.of( { "IpRecordSid": ip_record_sid, "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) @@ -343,17 +362,21 @@ async def create_async( :returns: The created SourceIpMappingInstance """ + data = values.of( { "IpRecordSid": ip_record_sid, "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) @@ -485,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( @@ -512,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/WirelessBase.py b/twilio/rest/wireless/WirelessBase.py index 5bec36968e..0228c4d666 100644 --- a/twilio/rest/wireless/WirelessBase.py +++ b/twilio/rest/wireless/WirelessBase.py @@ -17,6 +17,7 @@ class WirelessBase(Domain): + def __init__(self, twilio: Client): """ Initialize the Wireless Domain diff --git a/twilio/rest/wireless/v1/__init__.py b/twilio/rest/wireless/v1/__init__.py index 7d94692e45..8f4d0dc5d7 100644 --- a/twilio/rest/wireless/v1/__init__.py +++ b/twilio/rest/wireless/v1/__init__.py @@ -22,6 +22,7 @@ class V1(Version): + def __init__(self, domain: Domain): """ Initialize the V1 version of Wireless diff --git a/twilio/rest/wireless/v1/command.py b/twilio/rest/wireless/v1/command.py index 49c2c74faf..a6e8f0b39d 100644 --- a/twilio/rest/wireless/v1/command.py +++ b/twilio/rest/wireless/v1/command.py @@ -12,10 +12,9 @@ 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 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 @@ -24,6 +23,7 @@ class CommandInstance(InstanceResource): + class CommandMode(object): TEXT = "text" BINARY = "binary" @@ -46,7 +46,7 @@ class Transport(object): """ :ivar sid: The unique string that we created to identify the Command resource. :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Command resource. - :ivar sim_sid: The SID of the [Sim resource](https://www.twilio.com/docs/wireless/api/sim-resource) that the Command was sent to or from. + :ivar sim_sid: The SID of the [Sim resource](https://www.twilio.com/docs/iot/wireless/api/sim-resource) that the Command was sent to or from. :ivar command: The message being sent to or from the SIM. For text mode messages, this can be up to 160 characters. For binary mode messages, this is a series of up to 140 bytes of data encoded using base64. :ivar command_mode: :ivar transport: @@ -151,6 +151,7 @@ def __repr__(self) -> str: class CommandContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the CommandContext @@ -173,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: """ @@ -185,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: @@ -198,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, @@ -217,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( @@ -239,6 +246,7 @@ def __repr__(self) -> str: class CommandPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> CommandInstance: """ Build an instance of CommandInstance @@ -257,6 +265,7 @@ def __repr__(self) -> str: class CommandList(ListResource): + def __init__(self, version: Version): """ Initialize the CommandList @@ -282,7 +291,7 @@ def create( Create the CommandInstance :param command: The message body of the Command. Can be plain text in text mode or a Base64 encoded byte string in binary mode. - :param sim: The `sid` or `unique_name` of the [SIM](https://www.twilio.com/docs/wireless/api/sim-resource) to send the Command to. + :param sim: The `sid` or `unique_name` of the [SIM](https://www.twilio.com/docs/iot/wireless/api/sim-resource) to send the Command to. :param callback_method: The HTTP method we use to call `callback_url`. Can be: `POST` or `GET`, and the default is `POST`. :param callback_url: The URL we call using the `callback_url` when the Command has finished sending, whether the command was delivered or it failed. :param command_mode: @@ -291,6 +300,7 @@ def create( :returns: The created CommandInstance """ + data = values.of( { "Command": command, @@ -299,14 +309,19 @@ def create( "CallbackUrl": callback_url, "CommandMode": command_mode, "IncludeSid": include_sid, - "DeliveryReceiptRequested": delivery_receipt_requested, + "DeliveryReceiptRequested": serialize.boolean_to_string( + delivery_receipt_requested + ), } ) + 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) @@ -325,7 +340,7 @@ async def create_async( Asynchronously create the CommandInstance :param command: The message body of the Command. Can be plain text in text mode or a Base64 encoded byte string in binary mode. - :param sim: The `sid` or `unique_name` of the [SIM](https://www.twilio.com/docs/wireless/api/sim-resource) to send the Command to. + :param sim: The `sid` or `unique_name` of the [SIM](https://www.twilio.com/docs/iot/wireless/api/sim-resource) to send the Command to. :param callback_method: The HTTP method we use to call `callback_url`. Can be: `POST` or `GET`, and the default is `POST`. :param callback_url: The URL we call using the `callback_url` when the Command has finished sending, whether the command was delivered or it failed. :param command_mode: @@ -334,6 +349,7 @@ async def create_async( :returns: The created CommandInstance """ + data = values.of( { "Command": command, @@ -342,14 +358,19 @@ async def create_async( "CallbackUrl": callback_url, "CommandMode": command_mode, "IncludeSid": include_sid, - "DeliveryReceiptRequested": delivery_receipt_requested, + "DeliveryReceiptRequested": serialize.boolean_to_string( + delivery_receipt_requested + ), } ) + 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) @@ -369,7 +390,7 @@ def stream( is reached. The results are returned as a generator, so this operation is memory efficient. - :param str sim: The `sid` or `unique_name` of the [Sim resources](https://www.twilio.com/docs/wireless/api/sim-resource) to read. + :param str sim: The `sid` or `unique_name` of the [Sim resources](https://www.twilio.com/docs/iot/wireless/api/sim-resource) to read. :param "CommandInstance.Status" status: The status of the resources to read. Can be: `queued`, `sent`, `delivered`, `received`, or `failed`. :param "CommandInstance.Direction" direction: Only return Commands with this direction value. :param "CommandInstance.Transport" transport: Only return Commands with this transport value. Can be: `sms` or `ip`. @@ -408,7 +429,7 @@ async def stream_async( is reached. The results are returned as a generator, so this operation is memory efficient. - :param str sim: The `sid` or `unique_name` of the [Sim resources](https://www.twilio.com/docs/wireless/api/sim-resource) to read. + :param str sim: The `sid` or `unique_name` of the [Sim resources](https://www.twilio.com/docs/iot/wireless/api/sim-resource) to read. :param "CommandInstance.Status" status: The status of the resources to read. Can be: `queued`, `sent`, `delivered`, `received`, or `failed`. :param "CommandInstance.Direction" direction: Only return Commands with this direction value. :param "CommandInstance.Transport" transport: Only return Commands with this transport value. Can be: `sms` or `ip`. @@ -446,7 +467,7 @@ def list( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param str sim: The `sid` or `unique_name` of the [Sim resources](https://www.twilio.com/docs/wireless/api/sim-resource) to read. + :param str sim: The `sid` or `unique_name` of the [Sim resources](https://www.twilio.com/docs/iot/wireless/api/sim-resource) to read. :param "CommandInstance.Status" status: The status of the resources to read. Can be: `queued`, `sent`, `delivered`, `received`, or `failed`. :param "CommandInstance.Direction" direction: Only return Commands with this direction value. :param "CommandInstance.Transport" transport: Only return Commands with this transport value. Can be: `sms` or `ip`. @@ -484,7 +505,7 @@ async def list_async( Unlike stream(), this operation is eager and will load `limit` records into memory before returning. - :param str sim: The `sid` or `unique_name` of the [Sim resources](https://www.twilio.com/docs/wireless/api/sim-resource) to read. + :param str sim: The `sid` or `unique_name` of the [Sim resources](https://www.twilio.com/docs/iot/wireless/api/sim-resource) to read. :param "CommandInstance.Status" status: The status of the resources to read. Can be: `queued`, `sent`, `delivered`, `received`, or `failed`. :param "CommandInstance.Direction" direction: Only return Commands with this direction value. :param "CommandInstance.Transport" transport: Only return Commands with this transport value. Can be: `sms` or `ip`. @@ -523,7 +544,7 @@ def page( Retrieve a single page of CommandInstance records from the API. Request is executed immediately - :param sim: The `sid` or `unique_name` of the [Sim resources](https://www.twilio.com/docs/wireless/api/sim-resource) to read. + :param sim: The `sid` or `unique_name` of the [Sim resources](https://www.twilio.com/docs/iot/wireless/api/sim-resource) to read. :param status: The status of the resources to read. Can be: `queued`, `sent`, `delivered`, `received`, or `failed`. :param direction: Only return Commands with this direction value. :param transport: Only return Commands with this transport value. Can be: `sms` or `ip`. @@ -545,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( @@ -562,7 +589,7 @@ async def page_async( Asynchronously retrieve a single page of CommandInstance records from the API. Request is executed immediately - :param sim: The `sid` or `unique_name` of the [Sim resources](https://www.twilio.com/docs/wireless/api/sim-resource) to read. + :param sim: The `sid` or `unique_name` of the [Sim resources](https://www.twilio.com/docs/iot/wireless/api/sim-resource) to read. :param status: The status of the resources to read. Can be: `queued`, `sent`, `delivered`, `received`, or `failed`. :param direction: Only return Commands with this direction value. :param transport: Only return Commands with this transport value. Can be: `sms` or `ip`. @@ -584,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 2e021e3d8f..23efabe9b0 100644 --- a/twilio/rest/wireless/v1/rate_plan.py +++ b/twilio/rest/wireless/v1/rate_plan.py @@ -12,7 +12,6 @@ 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 @@ -25,17 +24,21 @@ 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. :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the RatePlan resource. :ivar friendly_name: The string that you assigned to describe the resource. :ivar data_enabled: Whether SIMs can use GPRS/3G/4G/LTE data connectivity. - :ivar data_metering: The model used to meter data usage. Can be: `payg` and `quota-1`, `quota-10`, and `quota-50`. Learn more about the available [data metering models](https://www.twilio.com/docs/wireless/api/rateplan-resource#payg-vs-quota-data-plans). + :ivar data_metering: The model used to meter data usage. Can be: `payg` and `quota-1`, `quota-10`, and `quota-50`. Learn more about the available [data metering models](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource#payg-vs-quota-data-plans). :ivar data_limit: The total data usage (download and upload combined) in Megabytes that the Network allows during one month on the home network (T-Mobile USA). The metering period begins the day of activation and ends on the same day in the following month. Can be up to 2TB. - :ivar messaging_enabled: Whether SIMs can make, send, and receive SMS using [Commands](https://www.twilio.com/docs/wireless/api/command-resource). + :ivar messaging_enabled: Whether SIMs can make, send, and receive SMS using [Commands](https://www.twilio.com/docs/iot/wireless/api/command-resource). :ivar voice_enabled: Deprecated. Whether SIMs can make and receive voice calls. - :ivar national_roaming_enabled: Whether SIMs can roam on networks other than the home network (T-Mobile USA) in the United States. See [national roaming](https://www.twilio.com/docs/wireless/api/rateplan-resource#national-roaming). + :ivar national_roaming_enabled: Whether SIMs can roam on networks other than the home network (T-Mobile USA) in the United States. See [national roaming](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource#national-roaming). :ivar 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. :ivar 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`. :ivar 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. @@ -181,6 +184,7 @@ def __repr__(self) -> str: class RatePlanContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the RatePlanContext @@ -203,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: """ @@ -215,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: @@ -228,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, @@ -247,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( @@ -271,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"]) @@ -299,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"]) @@ -325,6 +343,7 @@ def __repr__(self) -> str: class RatePlanPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> RatePlanInstance: """ Build an instance of RatePlanInstance @@ -343,6 +362,7 @@ def __repr__(self) -> str: class RatePlanList(ListResource): + def __init__(self, version: Version): """ Initialize the RatePlanList @@ -367,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 @@ -375,38 +398,46 @@ def create( :param friendly_name: A descriptive string that you create to describe the resource. It does not have to be unique. :param data_enabled: Whether SIMs can use GPRS/3G/4G/LTE data connectivity. :param data_limit: The total data usage (download and upload combined) in Megabytes that the Network allows during one month on the home network (T-Mobile USA). The metering period begins the day of activation and ends on the same day in the following month. Can be up to 2TB and the default value is `1000`. - :param data_metering: The model used to meter data usage. Can be: `payg` and `quota-1`, `quota-10`, and `quota-50`. Learn more about the available [data metering models](https://www.twilio.com/docs/wireless/api/rateplan-resource#payg-vs-quota-data-plans). - :param messaging_enabled: Whether SIMs can make, send, and receive SMS using [Commands](https://www.twilio.com/docs/wireless/api/command-resource). + :param data_metering: The model used to meter data usage. Can be: `payg` and `quota-1`, `quota-10`, and `quota-50`. Learn more about the available [data metering models](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource#payg-vs-quota-data-plans). + :param messaging_enabled: Whether SIMs can make, send, and receive SMS using [Commands](https://www.twilio.com/docs/iot/wireless/api/command-resource). :param voice_enabled: Deprecated. - :param national_roaming_enabled: Whether SIMs can roam on networks other than the home network (T-Mobile USA) in the United States. See [national roaming](https://www.twilio.com/docs/wireless/api/rateplan-resource#national-roaming). + :param national_roaming_enabled: Whether SIMs can roam on networks other than the home network (T-Mobile USA) in the United States. See [national roaming](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource#national-roaming). :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/wireless/api/rateplan-resource#national-roaming) for more info. + :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 """ + data = values.of( { "UniqueName": unique_name, "FriendlyName": friendly_name, - "DataEnabled": data_enabled, + "DataEnabled": serialize.boolean_to_string(data_enabled), "DataLimit": data_limit, "DataMetering": data_metering, - "MessagingEnabled": messaging_enabled, - "VoiceEnabled": voice_enabled, - "NationalRoamingEnabled": national_roaming_enabled, + "MessagingEnabled": serialize.boolean_to_string(messaging_enabled), + "VoiceEnabled": serialize.boolean_to_string(voice_enabled), + "NationalRoamingEnabled": serialize.boolean_to_string( + national_roaming_enabled + ), "InternationalRoaming": serialize.map( international_roaming, lambda e: e ), "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) @@ -424,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 @@ -432,38 +466,46 @@ async def create_async( :param friendly_name: A descriptive string that you create to describe the resource. It does not have to be unique. :param data_enabled: Whether SIMs can use GPRS/3G/4G/LTE data connectivity. :param data_limit: The total data usage (download and upload combined) in Megabytes that the Network allows during one month on the home network (T-Mobile USA). The metering period begins the day of activation and ends on the same day in the following month. Can be up to 2TB and the default value is `1000`. - :param data_metering: The model used to meter data usage. Can be: `payg` and `quota-1`, `quota-10`, and `quota-50`. Learn more about the available [data metering models](https://www.twilio.com/docs/wireless/api/rateplan-resource#payg-vs-quota-data-plans). - :param messaging_enabled: Whether SIMs can make, send, and receive SMS using [Commands](https://www.twilio.com/docs/wireless/api/command-resource). + :param data_metering: The model used to meter data usage. Can be: `payg` and `quota-1`, `quota-10`, and `quota-50`. Learn more about the available [data metering models](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource#payg-vs-quota-data-plans). + :param messaging_enabled: Whether SIMs can make, send, and receive SMS using [Commands](https://www.twilio.com/docs/iot/wireless/api/command-resource). :param voice_enabled: Deprecated. - :param national_roaming_enabled: Whether SIMs can roam on networks other than the home network (T-Mobile USA) in the United States. See [national roaming](https://www.twilio.com/docs/wireless/api/rateplan-resource#national-roaming). + :param national_roaming_enabled: Whether SIMs can roam on networks other than the home network (T-Mobile USA) in the United States. See [national roaming](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource#national-roaming). :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/wireless/api/rateplan-resource#national-roaming) for more info. + :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 """ + data = values.of( { "UniqueName": unique_name, "FriendlyName": friendly_name, - "DataEnabled": data_enabled, + "DataEnabled": serialize.boolean_to_string(data_enabled), "DataLimit": data_limit, "DataMetering": data_metering, - "MessagingEnabled": messaging_enabled, - "VoiceEnabled": voice_enabled, - "NationalRoamingEnabled": national_roaming_enabled, + "MessagingEnabled": serialize.boolean_to_string(messaging_enabled), + "VoiceEnabled": serialize.boolean_to_string(voice_enabled), + "NationalRoamingEnabled": serialize.boolean_to_string( + national_roaming_enabled + ), "InternationalRoaming": serialize.map( international_roaming, lambda e: e ), "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) @@ -595,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( @@ -622,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 19387ee99e..cba0eeec71 100644 --- a/twilio/rest/wireless/v1/sim/__init__.py +++ b/twilio/rest/wireless/v1/sim/__init__.py @@ -12,7 +12,6 @@ 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 @@ -26,6 +25,7 @@ class SimInstance(InstanceResource): + class ResetStatus(object): RESETTING = "resetting" @@ -43,13 +43,13 @@ class Status(object): :ivar sid: The unique string that we created to identify the Sim 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. :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) to which the Sim resource belongs. - :ivar rate_plan_sid: The SID of the [RatePlan resource](https://www.twilio.com/docs/wireless/api/rateplan-resource) to which the Sim resource is assigned. + :ivar rate_plan_sid: The SID of the [RatePlan resource](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource) to which the Sim resource is assigned. :ivar friendly_name: The string that you assigned to describe the Sim resource. :ivar iccid: The [ICCID](https://en.wikipedia.org/wiki/SIM_card#ICCID) associated with the SIM. :ivar e_id: Deprecated. :ivar status: :ivar reset_status: - :ivar commands_callback_url: The URL we call using the `commands_callback_method` when the SIM originates a machine-to-machine [Command](https://www.twilio.com/docs/wireless/api/command-resource). Your server should respond with an HTTP status code in the 200 range; any response body will be ignored. + :ivar commands_callback_url: The URL we call using the `commands_callback_method` when the SIM originates a machine-to-machine [Command](https://www.twilio.com/docs/iot/wireless/api/command-resource). Your server should respond with an HTTP status code in the 200 range; any response body will be ignored. :ivar commands_callback_method: The HTTP method we use to call `commands_callback_url`. Can be: `POST` or `GET`. Default is `POST`. :ivar sms_fallback_method: Deprecated. :ivar sms_fallback_url: Deprecated. @@ -188,20 +188,20 @@ def update( :param callback_method: The HTTP method we should use to call `callback_url`. Can be: `POST` or `GET`. The default is `POST`. :param callback_url: The URL we should call using the `callback_url` when the SIM has finished updating. When the SIM transitions from `new` to `ready` or from any status to `deactivated`, we call this URL when the status changes to an intermediate status (`ready` or `deactivated`) and again when the status changes to its final status (`active` or `canceled`). :param friendly_name: A descriptive string that you create to describe the Sim resource. It does not need to be unique. - :param rate_plan: The SID or unique name of the [RatePlan resource](https://www.twilio.com/docs/wireless/api/rateplan-resource) to which the Sim resource should be assigned. + :param rate_plan: The SID or unique name of the [RatePlan resource](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource) to which the Sim resource should be assigned. :param status: :param commands_callback_method: The HTTP method we should use to call `commands_callback_url`. Can be: `POST` or `GET`. The default is `POST`. - :param commands_callback_url: The URL we should call using the `commands_callback_method` when the SIM sends a [Command](https://www.twilio.com/docs/wireless/api/command-resource). Your server should respond with an HTTP status code in the 200 range; any response body is ignored. + :param commands_callback_url: The URL we should call using the `commands_callback_method` when the SIM sends a [Command](https://www.twilio.com/docs/iot/wireless/api/command-resource). Your server should respond with an HTTP status code in the 200 range; any response body is ignored. :param sms_fallback_method: The HTTP method we should use to call `sms_fallback_url`. Can be: `GET` or `POST`. Default is `POST`. :param sms_fallback_url: The URL we should call using the `sms_fallback_method` when an error occurs while retrieving or executing the TwiML requested from `sms_url`. :param sms_method: The HTTP method we should use to call `sms_url`. Can be: `GET` or `POST`. Default is `POST`. - :param sms_url: The URL we should call using the `sms_method` when the SIM-connected device sends an SMS message that is not a [Command](https://www.twilio.com/docs/wireless/api/command-resource). + :param sms_url: The URL we should call using the `sms_method` when the SIM-connected device sends an SMS message that is not a [Command](https://www.twilio.com/docs/iot/wireless/api/command-resource). :param voice_fallback_method: Deprecated. :param voice_fallback_url: Deprecated. :param voice_method: Deprecated. :param voice_url: Deprecated. :param reset_status: - :param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) to which the Sim resource should belong. The Account SID can only be that of the requesting Account or that of a [Subaccount](https://www.twilio.com/docs/iam/api/subaccounts) of the requesting Account. Only valid when the Sim resource's status is `new`. For more information, see the [Move SIMs between Subaccounts documentation](https://www.twilio.com/docs/wireless/api/sim-resource#move-sims-between-subaccounts). + :param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) to which the Sim resource should belong. The Account SID can only be that of the requesting Account or that of a [Subaccount](https://www.twilio.com/docs/iam/api/subaccounts) of the requesting Account. Only valid when the Sim resource's status is `new`. For more information, see the [Move SIMs between Subaccounts documentation](https://www.twilio.com/docs/iot/wireless/api/sim-resource#move-sims-between-subaccounts). :returns: The updated SimInstance """ @@ -254,20 +254,20 @@ async def update_async( :param callback_method: The HTTP method we should use to call `callback_url`. Can be: `POST` or `GET`. The default is `POST`. :param callback_url: The URL we should call using the `callback_url` when the SIM has finished updating. When the SIM transitions from `new` to `ready` or from any status to `deactivated`, we call this URL when the status changes to an intermediate status (`ready` or `deactivated`) and again when the status changes to its final status (`active` or `canceled`). :param friendly_name: A descriptive string that you create to describe the Sim resource. It does not need to be unique. - :param rate_plan: The SID or unique name of the [RatePlan resource](https://www.twilio.com/docs/wireless/api/rateplan-resource) to which the Sim resource should be assigned. + :param rate_plan: The SID or unique name of the [RatePlan resource](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource) to which the Sim resource should be assigned. :param status: :param commands_callback_method: The HTTP method we should use to call `commands_callback_url`. Can be: `POST` or `GET`. The default is `POST`. - :param commands_callback_url: The URL we should call using the `commands_callback_method` when the SIM sends a [Command](https://www.twilio.com/docs/wireless/api/command-resource). Your server should respond with an HTTP status code in the 200 range; any response body is ignored. + :param commands_callback_url: The URL we should call using the `commands_callback_method` when the SIM sends a [Command](https://www.twilio.com/docs/iot/wireless/api/command-resource). Your server should respond with an HTTP status code in the 200 range; any response body is ignored. :param sms_fallback_method: The HTTP method we should use to call `sms_fallback_url`. Can be: `GET` or `POST`. Default is `POST`. :param sms_fallback_url: The URL we should call using the `sms_fallback_method` when an error occurs while retrieving or executing the TwiML requested from `sms_url`. :param sms_method: The HTTP method we should use to call `sms_url`. Can be: `GET` or `POST`. Default is `POST`. - :param sms_url: The URL we should call using the `sms_method` when the SIM-connected device sends an SMS message that is not a [Command](https://www.twilio.com/docs/wireless/api/command-resource). + :param sms_url: The URL we should call using the `sms_method` when the SIM-connected device sends an SMS message that is not a [Command](https://www.twilio.com/docs/iot/wireless/api/command-resource). :param voice_fallback_method: Deprecated. :param voice_fallback_url: Deprecated. :param voice_method: Deprecated. :param voice_url: Deprecated. :param reset_status: - :param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) to which the Sim resource should belong. The Account SID can only be that of the requesting Account or that of a [Subaccount](https://www.twilio.com/docs/iam/api/subaccounts) of the requesting Account. Only valid when the Sim resource's status is `new`. For more information, see the [Move SIMs between Subaccounts documentation](https://www.twilio.com/docs/wireless/api/sim-resource#move-sims-between-subaccounts). + :param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) to which the Sim resource should belong. The Account SID can only be that of the requesting Account or that of a [Subaccount](https://www.twilio.com/docs/iam/api/subaccounts) of the requesting Account. Only valid when the Sim resource's status is `new`. For more information, see the [Move SIMs between Subaccounts documentation](https://www.twilio.com/docs/iot/wireless/api/sim-resource#move-sims-between-subaccounts). :returns: The updated SimInstance """ @@ -317,6 +317,7 @@ def __repr__(self) -> str: class SimContext(InstanceContext): + def __init__(self, version: Version, sid: str): """ Initialize the SimContext @@ -342,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: """ @@ -354,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: @@ -367,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, @@ -386,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( @@ -425,23 +432,24 @@ def update( :param callback_method: The HTTP method we should use to call `callback_url`. Can be: `POST` or `GET`. The default is `POST`. :param callback_url: The URL we should call using the `callback_url` when the SIM has finished updating. When the SIM transitions from `new` to `ready` or from any status to `deactivated`, we call this URL when the status changes to an intermediate status (`ready` or `deactivated`) and again when the status changes to its final status (`active` or `canceled`). :param friendly_name: A descriptive string that you create to describe the Sim resource. It does not need to be unique. - :param rate_plan: The SID or unique name of the [RatePlan resource](https://www.twilio.com/docs/wireless/api/rateplan-resource) to which the Sim resource should be assigned. + :param rate_plan: The SID or unique name of the [RatePlan resource](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource) to which the Sim resource should be assigned. :param status: :param commands_callback_method: The HTTP method we should use to call `commands_callback_url`. Can be: `POST` or `GET`. The default is `POST`. - :param commands_callback_url: The URL we should call using the `commands_callback_method` when the SIM sends a [Command](https://www.twilio.com/docs/wireless/api/command-resource). Your server should respond with an HTTP status code in the 200 range; any response body is ignored. + :param commands_callback_url: The URL we should call using the `commands_callback_method` when the SIM sends a [Command](https://www.twilio.com/docs/iot/wireless/api/command-resource). Your server should respond with an HTTP status code in the 200 range; any response body is ignored. :param sms_fallback_method: The HTTP method we should use to call `sms_fallback_url`. Can be: `GET` or `POST`. Default is `POST`. :param sms_fallback_url: The URL we should call using the `sms_fallback_method` when an error occurs while retrieving or executing the TwiML requested from `sms_url`. :param sms_method: The HTTP method we should use to call `sms_url`. Can be: `GET` or `POST`. Default is `POST`. - :param sms_url: The URL we should call using the `sms_method` when the SIM-connected device sends an SMS message that is not a [Command](https://www.twilio.com/docs/wireless/api/command-resource). + :param sms_url: The URL we should call using the `sms_method` when the SIM-connected device sends an SMS message that is not a [Command](https://www.twilio.com/docs/iot/wireless/api/command-resource). :param voice_fallback_method: Deprecated. :param voice_fallback_url: Deprecated. :param voice_method: Deprecated. :param voice_url: Deprecated. :param reset_status: - :param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) to which the Sim resource should belong. The Account SID can only be that of the requesting Account or that of a [Subaccount](https://www.twilio.com/docs/iam/api/subaccounts) of the requesting Account. Only valid when the Sim resource's status is `new`. For more information, see the [Move SIMs between Subaccounts documentation](https://www.twilio.com/docs/wireless/api/sim-resource#move-sims-between-subaccounts). + :param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) to which the Sim resource should belong. The Account SID can only be that of the requesting Account or that of a [Subaccount](https://www.twilio.com/docs/iam/api/subaccounts) of the requesting Account. Only valid when the Sim resource's status is `new`. For more information, see the [Move SIMs between Subaccounts documentation](https://www.twilio.com/docs/iot/wireless/api/sim-resource#move-sims-between-subaccounts). :returns: The updated SimInstance """ + data = values.of( { "UniqueName": unique_name, @@ -464,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"]) @@ -501,23 +512,24 @@ async def update_async( :param callback_method: The HTTP method we should use to call `callback_url`. Can be: `POST` or `GET`. The default is `POST`. :param callback_url: The URL we should call using the `callback_url` when the SIM has finished updating. When the SIM transitions from `new` to `ready` or from any status to `deactivated`, we call this URL when the status changes to an intermediate status (`ready` or `deactivated`) and again when the status changes to its final status (`active` or `canceled`). :param friendly_name: A descriptive string that you create to describe the Sim resource. It does not need to be unique. - :param rate_plan: The SID or unique name of the [RatePlan resource](https://www.twilio.com/docs/wireless/api/rateplan-resource) to which the Sim resource should be assigned. + :param rate_plan: The SID or unique name of the [RatePlan resource](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource) to which the Sim resource should be assigned. :param status: :param commands_callback_method: The HTTP method we should use to call `commands_callback_url`. Can be: `POST` or `GET`. The default is `POST`. - :param commands_callback_url: The URL we should call using the `commands_callback_method` when the SIM sends a [Command](https://www.twilio.com/docs/wireless/api/command-resource). Your server should respond with an HTTP status code in the 200 range; any response body is ignored. + :param commands_callback_url: The URL we should call using the `commands_callback_method` when the SIM sends a [Command](https://www.twilio.com/docs/iot/wireless/api/command-resource). Your server should respond with an HTTP status code in the 200 range; any response body is ignored. :param sms_fallback_method: The HTTP method we should use to call `sms_fallback_url`. Can be: `GET` or `POST`. Default is `POST`. :param sms_fallback_url: The URL we should call using the `sms_fallback_method` when an error occurs while retrieving or executing the TwiML requested from `sms_url`. :param sms_method: The HTTP method we should use to call `sms_url`. Can be: `GET` or `POST`. Default is `POST`. - :param sms_url: The URL we should call using the `sms_method` when the SIM-connected device sends an SMS message that is not a [Command](https://www.twilio.com/docs/wireless/api/command-resource). + :param sms_url: The URL we should call using the `sms_method` when the SIM-connected device sends an SMS message that is not a [Command](https://www.twilio.com/docs/iot/wireless/api/command-resource). :param voice_fallback_method: Deprecated. :param voice_fallback_url: Deprecated. :param voice_method: Deprecated. :param voice_url: Deprecated. :param reset_status: - :param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) to which the Sim resource should belong. The Account SID can only be that of the requesting Account or that of a [Subaccount](https://www.twilio.com/docs/iam/api/subaccounts) of the requesting Account. Only valid when the Sim resource's status is `new`. For more information, see the [Move SIMs between Subaccounts documentation](https://www.twilio.com/docs/wireless/api/sim-resource#move-sims-between-subaccounts). + :param account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) to which the Sim resource should belong. The Account SID can only be that of the requesting Account or that of a [Subaccount](https://www.twilio.com/docs/iam/api/subaccounts) of the requesting Account. Only valid when the Sim resource's status is `new`. For more information, see the [Move SIMs between Subaccounts documentation](https://www.twilio.com/docs/iot/wireless/api/sim-resource#move-sims-between-subaccounts). :returns: The updated SimInstance """ + data = values.of( { "UniqueName": unique_name, @@ -540,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"]) @@ -584,6 +599,7 @@ def __repr__(self) -> str: class SimPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> SimInstance: """ Build an instance of SimInstance @@ -602,6 +618,7 @@ def __repr__(self) -> str: class SimList(ListResource): + def __init__(self, version: Version): """ Initialize the SimList @@ -631,7 +648,7 @@ def stream( :param "SimInstance.Status" status: Only return Sim resources with this status. :param str iccid: Only return Sim resources with this ICCID. This will return a list with a maximum size of 1. - :param str rate_plan: The SID or unique name of a [RatePlan resource](https://www.twilio.com/docs/wireless/api/rateplan-resource). Only return Sim resources assigned to this RatePlan resource. + :param str rate_plan: The SID or unique name of a [RatePlan resource](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource). Only return Sim resources assigned to this RatePlan resource. :param str e_id: Deprecated. :param str sim_registration_code: Only return Sim resources with this registration code. This will return a list with a maximum size of 1. :param limit: Upper limit for the number of records to return. stream() @@ -673,7 +690,7 @@ async def stream_async( :param "SimInstance.Status" status: Only return Sim resources with this status. :param str iccid: Only return Sim resources with this ICCID. This will return a list with a maximum size of 1. - :param str rate_plan: The SID or unique name of a [RatePlan resource](https://www.twilio.com/docs/wireless/api/rateplan-resource). Only return Sim resources assigned to this RatePlan resource. + :param str rate_plan: The SID or unique name of a [RatePlan resource](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource). Only return Sim resources assigned to this RatePlan resource. :param str e_id: Deprecated. :param str sim_registration_code: Only return Sim resources with this registration code. This will return a list with a maximum size of 1. :param limit: Upper limit for the number of records to return. stream() @@ -714,7 +731,7 @@ def list( :param "SimInstance.Status" status: Only return Sim resources with this status. :param str iccid: Only return Sim resources with this ICCID. This will return a list with a maximum size of 1. - :param str rate_plan: The SID or unique name of a [RatePlan resource](https://www.twilio.com/docs/wireless/api/rateplan-resource). Only return Sim resources assigned to this RatePlan resource. + :param str rate_plan: The SID or unique name of a [RatePlan resource](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource). Only return Sim resources assigned to this RatePlan resource. :param str e_id: Deprecated. :param str sim_registration_code: Only return Sim resources with this registration code. This will return a list with a maximum size of 1. :param limit: Upper limit for the number of records to return. list() guarantees @@ -755,7 +772,7 @@ async def list_async( :param "SimInstance.Status" status: Only return Sim resources with this status. :param str iccid: Only return Sim resources with this ICCID. This will return a list with a maximum size of 1. - :param str rate_plan: The SID or unique name of a [RatePlan resource](https://www.twilio.com/docs/wireless/api/rateplan-resource). Only return Sim resources assigned to this RatePlan resource. + :param str rate_plan: The SID or unique name of a [RatePlan resource](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource). Only return Sim resources assigned to this RatePlan resource. :param str e_id: Deprecated. :param str sim_registration_code: Only return Sim resources with this registration code. This will return a list with a maximum size of 1. :param limit: Upper limit for the number of records to return. list() guarantees @@ -797,7 +814,7 @@ def page( :param status: Only return Sim resources with this status. :param iccid: Only return Sim resources with this ICCID. This will return a list with a maximum size of 1. - :param rate_plan: The SID or unique name of a [RatePlan resource](https://www.twilio.com/docs/wireless/api/rateplan-resource). Only return Sim resources assigned to this RatePlan resource. + :param rate_plan: The SID or unique name of a [RatePlan resource](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource). Only return Sim resources assigned to this RatePlan resource. :param e_id: Deprecated. :param sim_registration_code: Only return Sim resources with this registration code. This will return a list with a maximum size of 1. :param page_token: PageToken provided by the API @@ -819,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( @@ -839,7 +862,7 @@ async def page_async( :param status: Only return Sim resources with this status. :param iccid: Only return Sim resources with this ICCID. This will return a list with a maximum size of 1. - :param rate_plan: The SID or unique name of a [RatePlan resource](https://www.twilio.com/docs/wireless/api/rateplan-resource). Only return Sim resources assigned to this RatePlan resource. + :param rate_plan: The SID or unique name of a [RatePlan resource](https://www.twilio.com/docs/iot/wireless/api/rateplan-resource). Only return Sim resources assigned to this RatePlan resource. :param e_id: Deprecated. :param sim_registration_code: Only return Sim resources with this registration code. This will return a list with a maximum size of 1. :param page_token: PageToken provided by the API @@ -861,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 6a9a576749..b4c50d608d 100644 --- a/twilio/rest/wireless/v1/sim/data_session.py +++ b/twilio/rest/wireless/v1/sim/data_session.py @@ -12,7 +12,6 @@ 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 @@ -24,18 +23,17 @@ class DataSessionInstance(InstanceResource): - """ :ivar sid: The unique string that we created to identify the DataSession resource. - :ivar sim_sid: The SID of the [Sim resource](https://www.twilio.com/docs/wireless/api/sim-resource) that the Data Session is for. + :ivar sim_sid: The SID of the [Sim resource](https://www.twilio.com/docs/iot/wireless/api/sim-resource) that the Data Session is for. :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the DataSession resource. :ivar radio_link: The generation of wireless technology that the device was using. :ivar operator_mcc: The 'mobile country code' is the unique ID of the home country where the Data Session took place. See: [MCC/MNC lookup](http://mcc-mnc.com/). :ivar operator_mnc: The 'mobile network code' is the unique ID specific to the mobile operator network where the Data Session took place. :ivar operator_country: The three letter country code representing where the device's Data Session took place. This is determined by looking up the `operator_mcc`. - :ivar operator_name: The friendly name of the mobile operator network that the [SIM](https://www.twilio.com/docs/wireless/api/sim-resource)-connected device is attached to. This is determined by looking up the `operator_mnc`. + :ivar operator_name: The friendly name of the mobile operator network that the [SIM](https://www.twilio.com/docs/iot/wireless/api/sim-resource)-connected device is attached to. This is determined by looking up the `operator_mnc`. :ivar cell_id: The unique ID of the cellular tower that the device was attached to at the moment when the Data Session was last updated. - :ivar cell_location_estimate: An object that describes the estimated location in latitude and longitude where the device's Data Session took place. The location is derived from the `cell_id` when the Data Session was last updated. See [Cell Location Estimate Object](https://www.twilio.com/docs/wireless/api/datasession-resource#cell-location-estimate-object). + :ivar cell_location_estimate: An object that describes the estimated location in latitude and longitude where the device's Data Session took place. The location is derived from the `cell_id` when the Data Session was last updated. See [Cell Location Estimate Object](https://www.twilio.com/docs/iot/wireless/api/datasession-resource#cell-location-estimate-object). :ivar packets_uploaded: The number of packets uploaded by the device between the `start` time and when the Data Session was last updated. :ivar packets_downloaded: The number of packets downloaded by the device between the `start` time and when the Data Session was last updated. :ivar last_updated: The date that the resource was last updated, given as GMT in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. @@ -89,6 +87,7 @@ def __repr__(self) -> str: class DataSessionPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> DataSessionInstance: """ Build an instance of DataSessionInstance @@ -109,12 +108,13 @@ def __repr__(self) -> str: class DataSessionList(ListResource): + def __init__(self, version: Version, sim_sid: str): """ Initialize the DataSessionList :param version: Version that contains the resource - :param sim_sid: The SID of the [Sim resource](https://www.twilio.com/docs/wireless/api/sim-resource) with the Data Sessions to read. + :param sim_sid: The SID of the [Sim resource](https://www.twilio.com/docs/iot/wireless/api/sim-resource) with the Data Sessions to read. """ super().__init__(version) @@ -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 2ee25ded7b..1cd26b6c2e 100644 --- a/twilio/rest/wireless/v1/sim/usage_record.py +++ b/twilio/rest/wireless/v1/sim/usage_record.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import datetime from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import serialize, values @@ -24,17 +23,18 @@ class UsageRecordInstance(InstanceResource): + class Granularity(object): HOURLY = "hourly" DAILY = "daily" ALL = "all" """ - :ivar sim_sid: The SID of the [Sim resource](https://www.twilio.com/docs/wireless/api/sim-resource) that this Usage Record is for. + :ivar sim_sid: The SID of the [Sim resource](https://www.twilio.com/docs/iot/wireless/api/sim-resource) that this Usage Record is for. :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the UsageRecord resource. :ivar period: The time period for which the usage is reported. Contains `start` and `end` datetime values given as GMT in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. - :ivar commands: An object that describes the SIM's usage of Commands during the specified period. See [Commands Usage Object](https://www.twilio.com/docs/wireless/api/sim-usagerecord-resource#commands-usage-object). - :ivar data: An object that describes the SIM's data usage during the specified period. See [Data Usage Object](https://www.twilio.com/docs/wireless/api/sim-usagerecord-resource#data-usage-object). + :ivar commands: An object that describes the SIM's usage of Commands during the specified period. See [Commands Usage Object](https://www.twilio.com/docs/iot/wireless/api/sim-usagerecord-resource#commands-usage-object). + :ivar data: An object that describes the SIM's data usage during the specified period. See [Data Usage Object](https://www.twilio.com/docs/iot/wireless/api/sim-usagerecord-resource#data-usage-object). """ def __init__(self, version: Version, payload: Dict[str, Any], sim_sid: str): @@ -61,6 +61,7 @@ def __repr__(self) -> str: class UsageRecordPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> UsageRecordInstance: """ Build an instance of UsageRecordInstance @@ -81,12 +82,13 @@ def __repr__(self) -> str: class UsageRecordList(ListResource): + def __init__(self, version: Version, sim_sid: str): """ Initialize the UsageRecordList :param version: Version that contains the resource - :param sim_sid: The SID of the [Sim resource](https://www.twilio.com/docs/wireless/api/sim-resource) to read the usage from. + :param sim_sid: The SID of the [Sim resource](https://www.twilio.com/docs/iot/wireless/api/sim-resource) to read the usage from. """ super().__init__(version) @@ -267,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( @@ -303,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 18f25ae59b..07135cf98b 100644 --- a/twilio/rest/wireless/v1/usage_record.py +++ b/twilio/rest/wireless/v1/usage_record.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ - from datetime import datetime from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import serialize, values @@ -24,6 +23,7 @@ class UsageRecordInstance(InstanceResource): + class Granularity(object): HOURLY = "hourly" DAILY = "daily" @@ -32,8 +32,8 @@ class Granularity(object): """ :ivar account_sid: The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the AccountUsageRecord resource. :ivar period: The time period for which usage is reported. Contains `start` and `end` properties that describe the period using GMT date-time values specified in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. - :ivar commands: An object that describes the aggregated Commands usage for all SIMs during the specified period. See [Commands Usage Object](https://www.twilio.com/docs/wireless/api/account-usagerecord-resource#commands-usage-object). - :ivar data: An object that describes the aggregated Data usage for all SIMs over the period. See [Data Usage Object](https://www.twilio.com/docs/wireless/api/account-usagerecord-resource#data-usage-object). + :ivar commands: An object that describes the aggregated Commands usage for all SIMs during the specified period. See [Commands Usage Object](https://www.twilio.com/docs/iot/wireless/api/account-usagerecord-resource#commands-usage-object). + :ivar data: An object that describes the aggregated Data usage for all SIMs over the period. See [Data Usage Object](https://www.twilio.com/docs/iot/wireless/api/account-usagerecord-resource#data-usage-object). """ def __init__(self, version: Version, payload: Dict[str, Any]): @@ -55,6 +55,7 @@ def __repr__(self) -> str: class UsageRecordPage(Page): + def get_instance(self, payload: Dict[str, Any]) -> UsageRecordInstance: """ Build an instance of UsageRecordInstance @@ -73,6 +74,7 @@ def __repr__(self) -> str: class UsageRecordList(ListResource): + def __init__(self, version: Version): """ Initialize the UsageRecordList @@ -254,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( @@ -290,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/messaging_response.py b/twilio/twiml/messaging_response.py index b938e16448..ec36c74c06 100644 --- a/twilio/twiml/messaging_response.py +++ b/twilio/twiml/messaging_response.py @@ -34,7 +34,7 @@ def message( :param body: Message Body :param to: Phone Number to send Message to :param from: Phone Number to send Message from - :param action: Action URL + :param action: A URL specifying where Twilio should send status callbacks for the created outbound message. :param method: Action URL Method :param status_callback: Status callback URL. Deprecated in favor of action. :param kwargs: additional attributes diff --git a/twilio/twiml/voice_response.py b/twilio/twiml/voice_response.py index 7fb59a4a83..32c31f310d 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 ) ) @@ -631,28 +634,116 @@ def stream( ) ) - def siprec(self, name=None, connector_name=None, track=None, **kwargs): + def siprec( + self, + name=None, + connector_name=None, + track=None, + status_callback=None, + status_callback_method=None, + **kwargs + ): """ Create a element :param name: Friendly name given to SIPREC :param connector_name: Unique name for Connector :param track: Track to be streamed to remote service + :param status_callback: Status Callback URL + :param status_callback_method: Status Callback URL method :param kwargs: additional attributes :returns: element """ return self.nest( - Siprec(name=name, connector_name=connector_name, track=track, **kwargs) + Siprec( + name=name, + connector_name=connector_name, + track=track, + status_callback=status_callback, + status_callback_method=status_callback_method, + **kwargs + ) ) + 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 -class Siprec(TwiML): - """ TwiML Noun""" + :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 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): """ @@ -675,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""" @@ -737,19 +856,95 @@ def stream( ) ) - def siprec(self, name=None, connector_name=None, track=None, **kwargs): + def siprec( + self, + name=None, + connector_name=None, + track=None, + status_callback=None, + status_callback_method=None, + **kwargs + ): """ Create a element :param name: Friendly name given to SIPREC :param connector_name: Unique name for Connector :param track: Track to be streamed to remote service + :param status_callback: Status Callback URL + :param status_callback_method: Status Callback URL method :param kwargs: additional attributes :returns: element """ return self.nest( - Siprec(name=name, connector_name=connector_name, track=track, **kwargs) + Siprec( + name=name, + connector_name=connector_name, + track=track, + status_callback=status_callback, + status_callback_method=status_callback_method, + **kwargs + ) + ) + + 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 + ) ) @@ -2260,6 +2455,50 @@ def application( ) ) + def whats_app( + self, + phone_number, + url=None, + method=None, + status_callback_event=None, + status_callback=None, + status_callback_method=None, + **kwargs + ): + """ + Create a element + + :param phone_number: WhatsApp Phone Number to dial + :param url: TwiML URL + :param method: TwiML URL Method + :param status_callback_event: Events to trigger status callback + :param status_callback: Status Callback URL + :param status_callback_method: Status Callback URL Method + :param kwargs: additional attributes + + :returns: element + """ + return self.nest( + WhatsApp( + phone_number, + url=url, + method=method, + status_callback_event=status_callback_event, + status_callback=status_callback, + status_callback_method=status_callback_method, + **kwargs + ) + ) + + +class WhatsApp(TwiML): + """ TwiML Noun""" + + def __init__(self, phone_number, **kwargs): + super(WhatsApp, self).__init__(**kwargs) + self.name = "WhatsApp" + self.value = phone_number + class Application(TwiML): """ TwiML Noun""" @@ -2539,6 +2778,278 @@ 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, + welcome_greeting_interruptible=None, + interruptible=None, + preemptible=None, + hints=None, + intelligence_service=None, + report_input_during_agent_speech=None, + elevenlabs_text_normalization=None, + interrupt_sensitivity=None, + debug=None, + **kwargs + ): + """ + Create a 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 welcome_greeting_interruptible: "Whether and how the input from a caller, such as speaking or DTMF can interrupt the welcome greeting + :param interruptible: Whether and how the input from a caller, such as speaking or DTMF can interrupt the play of text-to-speech + :param preemptible: Whether subsequent text-to-speech or play media can interrupt the on-going play of text-to-speech or media + :param hints: Phrases to help better accuracy in speech recognition of these pharases + :param intelligence_service: The Conversational Intelligence Service id or unique name to be used for the session + :param report_input_during_agent_speech: Whether prompts should be reported to WebSocket server when text-to-speech playing and interrupt is disabled + :param elevenlabs_text_normalization: When using ElevenLabs as TTS provider, this parameter allows you to enable or disable its text normalization feature + :param interrupt_sensitivity: Set the sensitivity of the interrupt feature for speech. The value can be low, medium, or high + :param debug: Multiple debug options to be used for troubleshooting + :param kwargs: additional attributes + + :returns: 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, + welcome_greeting_interruptible=welcome_greeting_interruptible, + interruptible=interruptible, + preemptible=preemptible, + hints=hints, + intelligence_service=intelligence_service, + report_input_during_agent_speech=report_input_during_agent_speech, + elevenlabs_text_normalization=elevenlabs_text_normalization, + interrupt_sensitivity=interrupt_sensitivity, + debug=debug, + **kwargs + ) + ) + + def assistant( + self, + id=None, + language=None, + tts_language=None, + transcription_language=None, + tts_provider=None, + voice=None, + transcription_provider=None, + speech_model=None, + profanity_filter=None, + dtmf_detection=None, + welcome_greeting=None, + partial_prompts=None, + welcome_greeting_interruptible=None, + interruptible=None, + preemptible=None, + hints=None, + intelligence_service=None, + report_input_during_agent_speech=None, + elevenlabs_text_normalization=None, + interrupt_sensitivity=None, + debug=None, + **kwargs + ): + """ + Create a element + + :param id: The assistant ID of the AI Assistant + :param language: Language to be used for both text-to-speech and transcription + :param tts_language: Language to be used for text-to-speech + :param transcription_language: Language to be used for transcription + :param tts_provider: Provider to be used for text-to-speech + :param voice: Voice to be used for text-to-speech + :param transcription_provider: Provider to be used for transcription + :param speech_model: Speech model to be used for transcription + :param profanity_filter: Whether profanities should be filtered out of the speech transcription + :param dtmf_detection: Whether DTMF tones should be detected and reported in speech transcription + :param welcome_greeting: The sentence to be played automatically when the session is connected + :param partial_prompts: Whether partial prompts should be reported to WebSocket server before the caller finishes speaking + :param welcome_greeting_interruptible: "Whether and how the input from a caller, such as speaking or DTMF can interrupt the welcome greeting + :param interruptible: Whether and how the input from a caller, such as speaking or DTMF can interrupt the play of text-to-speech + :param preemptible: Whether subsequent text-to-speech or play media can interrupt the on-going play of text-to-speech or media + :param hints: Phrases to help better accuracy in speech recognition of these pharases + :param intelligence_service: The Conversational Intelligence Service id or unique name to be used for the session + :param report_input_during_agent_speech: Whether prompts should be reported to WebSocket server when text-to-speech playing and interrupt is disabled + :param elevenlabs_text_normalization: When using ElevenLabs as TTS provider, this parameter allows you to enable or disable its text normalization feature + :param interrupt_sensitivity: Set the sensitivity of the interrupt feature for speech. The value can be low, medium, or high + :param debug: Multiple debug options to be used for troubleshooting + :param kwargs: additional attributes + + :returns: element + """ + return self.nest( + Assistant( + id=id, + language=language, + tts_language=tts_language, + transcription_language=transcription_language, + tts_provider=tts_provider, + voice=voice, + transcription_provider=transcription_provider, + speech_model=speech_model, + profanity_filter=profanity_filter, + dtmf_detection=dtmf_detection, + welcome_greeting=welcome_greeting, + partial_prompts=partial_prompts, + welcome_greeting_interruptible=welcome_greeting_interruptible, + interruptible=interruptible, + preemptible=preemptible, + hints=hints, + intelligence_service=intelligence_service, + report_input_during_agent_speech=report_input_during_agent_speech, + elevenlabs_text_normalization=elevenlabs_text_normalization, + interrupt_sensitivity=interrupt_sensitivity, + debug=debug, + **kwargs + ) + ) + + +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""" @@ -2580,14 +3091,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"""