pax_global_header00006660000000000000000000000064131747274260014527gustar00rootroot0000000000000052 comment=1062be805f5112e4d9585dd5d4d20ceaba1994d1 twilio-python-6.8.2/000077500000000000000000000000001317472742600143725ustar00rootroot00000000000000twilio-python-6.8.2/.gitignore000066400000000000000000000004421317472742600163620ustar00rootroot00000000000000*.py[co] # Packages *.egg *.egg-info dist build eggs parts bin develop-eggs .installed.cfg scratch env venv* # Installer logs pip-log.txt # Unit test / coverage reports .coverage .tox .DS_Store docs/ # PyCharm/IntelliJ .idea #htmlcov *htmlcov* # PyEnv .python-version README.md.baktwilio-python-6.8.2/.travis.yml000066400000000000000000000002661317472742600165070ustar00rootroot00000000000000language: python python: - "2.7" - "3.3" - "3.4" - "3.5" - "3.6" install: - pip install virtualenv --upgrade - make install - make test-install script: - make test twilio-python-6.8.2/AUTHORS.md000066400000000000000000000025031317472742600160410ustar00rootroot00000000000000# Authors We'd like to thank the following people who have contributed to the `twilio-python` repository. - Adam Ballai - Alex Brinsmead - Alex Chan - Andrew Benton - Chad Selph - Comrade DOS - Dan Yang - Dennis Pilarinos - Doug Black - Evan Fossier - Fabian Topfstedt - Florian Le Goff - Frank Tobia - Frederik De Bleser - Guillaume BINET - Hunter Blanks - Joël Franusic - Justin Van Koten - Kenneth Reitz - Kevin Burke - Kyle Conroy - Michael Parker - Moses Palmér - Ryan Horn - Sam Kimbrel - Skylar Saveland - Tiberiu Ana - Zachary Voase - aes - dnathe4th - isbo - negeorge - Evan Cooke - tysonholub - Brodan twilio-python-6.8.2/CHANGES.md000066400000000000000000000377211317472742600157760ustar00rootroot00000000000000twilio-python Changelog ======================= Here you can see the full list of changes between each twilio-python release. [2017-10-27] Version 6.8.2 --------------------------- **Chat** - Add Binding resource - Add UserBinding resource [2017-10-20] Version 6.8.1 --------------------------- **Library** - #394 Update request validator to remove port numbers from https urls. Thanks @Brodan! - #385 Add request logging and hooking. Thanks @tysonholub! **Api** - Add `address_sid` param to IncomingPhoneNumbers create and update - Add 'fax_enabled' option for Phone Number Search [2017-10-13] Version 6.8.0 --------------------------- **Api** - Add `smart_encoded` param for Messages - Add `identity_sid` param to IncomingPhoneNumbers create and update **Preview** - Make 'address_sid' and 'email' optional fields when creating a HostedNumberOrder - Add AuthorizationDocuments preview API. **Proxy** - Initial Release **Wireless** - Added `ip_address` to sim resource **Twiml** - Rename `number` to `phone_number` in Voice Number TwiML. *(breaking change)* - Rename `message` to `body` in Messaging TwiML. *(breaking change)* [2017-10-06] Version 6.7.1 --------------------------- **Preview** - Add `acc_security` (authy-phone-verification) initial api-definitions **Taskrouter** - [bi] Less verbose naming of cumulative and real time statistics [2017-09-28] Version 6.7.0 --------------------------- **Chat** - Make member accessible through identity - Make channel subresources accessible by channel unique name - Set get list 'max_page_size' parameter to 100 - Add service instance webhook retry configuration - Add media message capability - Make `body` an optional parameter on Message creation. *(breaking change)* **Notify** - `data`, `apn`, `gcm`, `fcm`, `sms` parameters in `Notifications` create resource are dicts/objects instead of strings. Passing manually stringified json will continue to work. **Taskrouter** - Add new query ability by TaskChannelSid or TaskChannelUniqueName - Move Events, Worker, Workers endpoint over to CPR - Add new RealTime and Cumulative Statistics endpoints **Video** - Create should allow an array of video_codecs. - Add video_codecs as a property of room to make it externally visible. [2017-09-15] Version 6.6.3 --------------------------- **Api** - Add `sip_registration` property on SIP Domains - Add new video and market usage category keys [2017-09-01] Version 6.6.2 --------------------------- - Added last_response and last_request to http_client [2017-09-01] Version 6.6.1 --------------------------- **Sync** - Add support for Streams **Wireless** - Added DataSessions sub-resource to Sims. [2017-08-25] Version 6.6.0 --------------------------- **Library** - Allow creating AccessTokens/Jwts without generating `nbf`. Passing `None` in the constructor will remove `nbf` from jwt payload. **Api** - Update `status` enum for Recordings to include 'failed' - Add `error_code` property on Recordings **Chat** - Add mutable parameters for channel, members and messages **Video** - New `media_region` parameter when creating a room, which controls which region media will be served out of. **Twiml** - Add support for `speech_timeout`, `max_speech_time`, and `profanity_filter` attributes on Gather verb. [2017-08-18] Version 6.5.2 --------------------------- **Library** - Remove bundled certificates, use `certifi` package via `requests`. - Add option to use connection pooling. This is enabled by default and will use one Session for all requests in Client. - To disable this, pass `pool_connections` parameter when creating your Twilio client. ```python from twilio.rest import Client from twilio.http.http_client import TwilioHttpClient client = Client( username, password, http_client=TwilioHttpClient(pool_connections=False) ) ``` **Api** - Add VoiceReceiveMode {'voice', 'fax'} option to IncomingPhoneNumber UPDATE requests **Chat** - Add channel message media information - Add service instance message media information **Preview** - Removed 'email' from bulk_exports configuration api [bi]. No migration plan needed because api has not been used yet. - Add DeployedDevices. **Sync** - Add support for Service Instance unique names [2017-08-10] Version 6.5.1 --------------------------- Fixed PyJWT >= 1.5.1 exception **Api** - Add New wireless usage keys added - Add `auto_correct_address` param for Addresses create and update - Add ChatGrant grant and deprecate IpMessagingGrant **Video** - Add `video_codec` enum and `video_codecs` parameter, which can be set to either `VP8` or `H264` during room creation. - Restrict recordings page size to 100 [2017-07-27] Version 6.5.0 --------------------------- This release adds Beta and Preview products to main artifact. Previously, Beta and Preview products were only included in the `alpha` artifact. They are now being included in the main artifact to ease product discoverability and the collective operational overhead of maintaining multiple artifacts per library. **Api** - Remove unused `encryption_type` property on Recordings *(breaking change)* - Update `status` enum for Messages to include 'accepted' **Messaging** - Fix incorrectly typed capabilities property for PhoneNumbers. **Notify** - Add `ToBinding` optional parameter on Notifications resource creation. Accepted values are json strings. **Preview** - Add `sms_application_sid` to HostedNumberOrders. **Taskrouter** - Fully support conference functionality in reservations. [2017-07-12] Version 6.4.3 --------------------------- **Api** - Update `AnnounceMethod` parameter naming for consistency **Notify** - Add `ToBinding` optional parameter on Notifications resource creation. Accepted values are json strings. **Preview** - Add `verification_attempts` to HostedNumberOrders. - Add `status_callback_url` and `status_callback_method` to HostedNumberOrders. **Video** - Filter recordings by date using the parameters `DateCreatedAfter` and `DateCreatedBefore`. - Override the default time-to-live of a recording's media URL through the `Ttl` parameter (in seconds, default value is 3600). - Add query parameters `SourceSid`, `Status`, `DateCreatedAfter` and `DateCreatedBefore` to the convenience method for retrieving Room recordings. **Wireless** - Added national and international data limits to the RatePlans resource. [2017-06-27] Version 6.4.2 -------------------------- - Pin PyJWT to below version `1.5.1` to fix broken build. - Fix json load error for python 3.3 - 3.5 [2017-06-16] Version 6.4.1 -------------------------- - Add several missing `` attributes. - `partial_result_callback` - `partial_result_callback_method` - `language` - `hints` - `barge_in` - `acknowledge_sound_url` - `input` - Remove client-side max page size validation. - Support `announce_url` and `announce_url_method` on Conference Participants. - TwiML docstring corrections. [2017-06-15] Version 6.4.0 -------------------------- - Remove support for Python 2.6. - Add `locality` field to `AvailablePhoneNumbers`. - Add `origin` field to `IncomingPhoneNumbers`. - Add `in_locality` parameter to `AvailablePhoneNumbers`. - Add `origin` parameter to `IncomingPhoneNumbers`. - Add new sync categories to `UsageRecords`. - Support unicode in `validation_client`. - Add `muted` parameter to `` Twiml. [2017-05-24] Version 6.3.0 -------------------------- - Rename RoomList to RoomRecordingsList. [2017-05-19] Version 6.2.0 -------------------------- - Add video domain. - Update usage record categories. - Add `get_page` method for reentrant paging. [2017-05-12] Version 6.1.2 ---------------------------------- - Allow *kwargs in TwiML Gather [2017-05-10] Version 6.1.1 ---------------------------------- - Add Task verb to VoiceResponse - Add Echo verb to VoiceResponse - Add Sim verb to VoiceResponse [2017-04-27] Version 6.1.0 -------------------------- - Add v2 of chat.twilio.com. - Add `recording_channels` parameter to Participant create and update. - Add `recording_status_callback` parameter to Participant create and update. - Add `recording_status_callback_method` parameter to Participant create and update. - Add `sip_auth_username` parameter to Participant create and update. - Add `region` parameter to Participant create and update. - Add `conference_recording_status_callback` parameter to Participant create and update. - Add `conference_recording_status_callback_method` parameter to Participant create and update. - Add `validity_period` parameter to Messages. [2017-04-03] Version 6.0.0 -------------------------- **New Major Version** The newest version of the `twilio-python` helper library! This version brings a host of changes to update and modernize the `twilio-python` helper library. It is auto-generated to produce a more consistent and correct product. - [Full API Documentation](https://twilio.github.io/twilio-python/) - [General Documentation](https://www.twilio.com/docs/libraries/python) Version 4.4.0 ------------- Released May 19, 2015: - Add support for the beta field to IncomingPhoneNumbers and AvailablePhoneNumbers Version 4.3.0 ------------- Released May 14, 2015: - Add support for Call Status Events in TwiML Version 4.2.0 ------------- Released May 7, 2015: - Add support for the Twilio Monitor APIs: Events and Alerts Version 4.1.0 ------------- Released May 6, 2015: - Add support for the Twilio Pricing API Version 4.0.0 ------------- Released April 16, 2015: - Remove the deprecated count function from ListResource Version 3.8.0 ------------- Released March 31, 2015: - Support for the new Twilio Lookups API Version 3.7.3 ------------- Released March 10, 2015: - Add missing docstrings and examples for TaskRouter Version 3.7.2 ------------- Released February 24, 2015: - Restore Tokens resource to TwilioRestClient Version 3.7.1 ------------- Released February 20, 2015: - Restore Python 2.6 and 3.x support Version 3.7.0 ------------- Released February 18, 2015: - Add TaskRouterClient and resources to support the new TaskRouter API - Stop prepending numeric error code to exception error messages Version 3.6.15 -------------- Released January 14, 2015 - Update request construction for Tokens Version 3.6.14 -------------- Released December 22, 2014 - Specify Python 3 dependencies in wheel package Version 3.6.12 -------------- Released November 24, 2014 - Fix compatibility issue for Python 3.4 Version 3.6.11 -------------- Released November 21, 2014 - Add support for the new Tokens endpoint Version 3.6.10 -------------- Released November 13, 2014 - Add support for DELETE to Call and Message records - Add support for redacting Message body fields Version 3.6.9 ------------- Released October 30, 2014 - Add Python 3.4 support - Add wheel packaging - Fix compatibility with earlier Python 2 releases Version 3.6.8 ------------- Released October 9, 2014 - Remove unneeded unittest2py3k dependency. - Restore backwards-compatible exception import paths. Version 3.6.7 ------------- Released August 6, 2014 - Fix Python 2.5 compatibility. - Add CallFeedback resources. - Typo fixes and formatting cleanup. - Refactor exception hierarchy and imports. - Documentation improvements. Version 3.6.6 -------------- Released on February 27, 2014 - Previously the error message was set based on the `tty` value; instead now we detect `tty` when you try to print the error message. The `msg` property of the exception is set to a decent value. - `twilio-python` now uses entirely relative imports, so it may be easier to include it as a part of another package. Version 3.6.5 -------------- - Remove unittest2 dependency. - Tests no longer run against Python 2.5. - update(), delete() work on Application, Transcription and UsageTrigger instance classes. Version 3.6.4 ------------- Released November 5, 2013 - Adds support for the 'digits' attribute of Play verbs in TwiML creation. - Updates documentation for Message TwiML verb - Bugfix for tty detection in error formatting Version 3.6.3 ------------- Released October 21, 2013 - Adds support for filtering by type to IncomingPhoneNumbers. - Adds support for filtering for mobile numbers to both IncomingPhoneNumbers and AvailablePhoneNumbers. Version 3.6.2 ------------- Released on September 24, 2013 - Adds support for HTTP and SOCKS4/5 proxies to the REST client. Version 3.6.0, 3.6.1 -------------------- Released on September 18, 2013 - Adds support for the new Message and SIP resources to the REST API client. - Adds support for the new Message verb to the TwiML generator. Version 3.5.3, 3.5.4 -------------------- Released on September 6, 2013 - twilio-python now includes an SSL certfication file to ensure that connections to api.twilio.com don't fail with SSLError. Version 3.5.2 ------------- Released on August 26, 2013 - You can now delete transcriptions Version 3.5.1 ------------- Released on May 21, 2013 - Fixes an issue in the 3.5.0 release where null dates would cause the library to raise a TypeError. Version 3.5.0 ------------- Released on May 21, 2013 - `date_created` and `date_updated` objects are now returned as Python `datetime.datetime` objects instead of as RFC 2822 formatted strings. This is a backwards incompatible change. (via [@abrinsmead](/abrinsmead)) - The library will not throw a UnicodeDecodeError when parsing API responses with Python 3. - You can pass integers to Twiml arguments. (via [@jvankoten](/jvankoten)) - Ensuring the tests always pass on Python 3. (via [@ftobia](/ftobia)) - Add the list of AUTHORS - Fixes a timing attack vector in signature validation. (via [@zacharyvoase](/zacharyvoase)) Version 3.4.5 ------------- Released on April 1, 2013 Allow the Account object to access usage records and usage trigger data, in addition to the client. Reporter: Trenton McManus Version 3.4.4 ------------- Adds support for Sip Version 3.4.3 ------------- Adds correct dependencies to the `setup.py` file. Version 3.4.2 ------------- Released on January 2, 2013 Adds a convenience function to retrieve the members of a queue by running client.members("QU123"). Version 3.4.1 ------------- Python3 support! Version 3.3.11 -------------- - Fix a bug where participants could not be kicked from a Conference Version 3.3.10 -------------- - Add support for Queue. Fix a bug where the library wouldn't work in Python 2.5 Version 3.3.9 ------------- - Fix an error introduced in 3.3.7 that prevented validation calls from succeeding. Version 3.3.8 ------------- - Use next_page_uri when iterating over a list resource Version 3.3.7 ------------- - Allow arbitrary keyword arguments on resource creation and listing Version 3.3.6 ------------- - Remove doc/tmp directory which was preventing installation on certain Windows machines - Add Travis CI integration - Update httplib2 dependency Version 3.3.5 ------------- Released on January 18, 2011 - Fix a bug with the deprecated `TwilioRestClient.request` method - Fix a bug in filtering SMS messages by DateSent Version 3.3.4 ------------- Released on December 16, 2011 - Allow both unicode strings and encoded byte strings in request data - Add support for SMS and Voice application sids to phone number updating - Fix documentation error relating to phone number purchasing - Include doc string information for decorated functions Version 3.3.3 ------------- Released on November 3, 2011 - Support unicode characters when validating requests - Add support for Great Britain language on the Say verb - Set Sms Application, Voice Application, and/or a Friendly Name when purchasing a number - Add missing parameters for resource creation and update Version 3.3.2 ------------- Released on September 29, 2011 - TwiML verbs can now be used as context managers Version 3.3.1 ------------- Released on September 27, 2011 - Allow phone numbers to be transferred between accounts and subaccounts Version 3.3.0 ------------- Released on September 21, 2011 - Add support for Twilio Connect. Connect applications and authorized Connect applications are now availble via the REST client. - Fix a problem where date and datetimes weren't coverted to strings when querying list resources twilio-python-6.8.2/CONTRIBUTING.md000066400000000000000000000133611317472742600166270ustar00rootroot00000000000000# Contributing to `twilio-python` We'd love for you to contribute to our source code and to make `twilio-python` even better than it is today! Here are the guidelines we'd like you to follow: - [Code of Conduct](#coc) - [Question or Problem?](#question) - [Issues and Bugs](#issue) - [Feature Requests](#feature) - [Documentation fixes](#docs) - [Submission Guidelines](#submit) - [Coding Rules](#rules) ## Code of Conduct Help us keep `twilio-python` open and inclusive. Please be kind to and considerate of other developers, as we all have the same goal: make `twilio-python` as good as it can be. ## Got an API/Product Question or Problem? If you have questions about how to use `twilio-python`, please see our [docs][docs-link], and if you don't find the answer there, please contact [help@twilio.com](mailto:help@twilio.com) with any issues you have. ## Found an Issue? If you find a bug in the source code or a mistake in the documentation, you can help us by submitting [an issue][issue-link]. If the file in which the error exists has this header: ``` """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ ``` then it is a generated file and the change will need to be made by us, but submitting an issue will help us track it and keep you up-to-date. If the file isn't generated, you can help us out even more by submitting a Pull Request with a fix. **Please see the [Submission Guidelines](#submit) below.** ## Want a Feature? You can request a new feature by submitting an issue to our [GitHub Repository][github]. If you would like to implement a new feature then consider what kind of change it is: * **Major Changes** that you wish to contribute to the project should be discussed first with `twilio-python` contributors in an issue or pull request so that we can develop a proper solution and better coordinate our efforts, prevent duplication of work, and help you to craft the change so that it is successfully accepted into the project. * **Small Changes** can be crafted and submitted to the [GitHub Repository][github] as a Pull Request. ## Want a Doc Fix? If you want to help improve the docs in the helper library, it's a good idea to let others know what you're working on to minimize duplication of effort. Create a new issue (or comment on a related existing one) to let others know what you're working on. For large fixes, please build and test the documentation before submitting the PR to be sure you haven't accidentally introduced layout or formatting issues. If you want to help improve the docs at [https://www.twilio.com/docs/libraries/python][docs-link], please contact [help@twilio.com](mailto:help@twilio.com). ## Submission Guidelines ### Submitting an Issue Before you submit your issue search the archive, maybe your question was already answered. If your issue appears to be a bug, and hasn't been reported, open a new issue. Help us to maximize the effort we can spend fixing issues and adding new features by not reporting duplicate issues. Providing the following information will increase the chances of your issue being dealt with quickly: * **Overview of the Issue** - if an error is being thrown a non-minified stack trace helps * **Motivation for or Use Case** - explain why this is a bug for you * **`twilio-python` Version(s)** - is it a regression? * **Operating System (if relevant)** - is this a problem with all systems or only specific ones? * **Reproduce the Error** - provide an isolated code snippet or an unambiguous set of steps. * **Related Issues** - has a similar issue been reported before? * **Suggest a Fix** - if you can't fix the bug yourself, perhaps you can point to what might be causing the problem (line of code or commit) **If you get help, help others. Good karma rules!** ### Submitting a Pull Request Before you submit your pull request consider the following guidelines: * Search [GitHub][github] for an open or closed Pull Request that relates to your submission. You don't want to duplicate effort. * Make your changes in a new git branch: ```shell git checkout -b my-fix-branch master ``` * Create your patch, **including appropriate test cases**. * Follow our [Coding Rules](#rules). * Run the full `twilio-python` test suite (aliased by `make test`), and ensure that all tests pass. * Commit your changes using a descriptive commit message. ```shell git commit -a ``` Note: the optional commit `-a` command line option will automatically "add" and "rm" edited files. * Build your changes locally to ensure all the tests pass: ```shell make test ``` * Push your branch to GitHub: ```shell git push origin my-fix-branch ``` In GitHub, send a pull request to `twilio-python:master`. If we suggest changes, then: * Make the required updates. * Re-run the `twilio-python` test suite to ensure tests are still passing. * Commit your changes to your branch (e.g. `my-fix-branch`). * Push the changes to your GitHub repository (this will update your Pull Request). That's it! Thank you for your contribution! #### After your pull request is merged After your pull request is merged, you can safely delete your branch and pull the changes from the main (upstream) repository. ## Coding Rules To ensure consistency throughout the source code, keep these rules in mind as you are working: * All features or bug fixes **must be tested** by one or more tests. * All classes and methods **must be documented**. [docs-link]: https://www.twilio.com/docs/libraries/python [issue-link]: https://github.com/twilio/twilio-python/issues/new [github]: https://github.com/twilio/twilio-pythontwilio-python-6.8.2/ISSUE_TEMPLATE.md000066400000000000000000000007171317472742600171040ustar00rootroot00000000000000*Note: These issues are for bugs and feature requests for the helper libraries. If you need help or support, please email help@twilio.com and one of our experts will assist you!* **Version:** ### Code Snippet ```python # paste code here ``` ### Exception/Log ``` ``` ### Steps to Reproduce 1. 2. 3. ### Feature Request _If this is a feature request, make sure you search Issues for an existing request before creating a new one!_twilio-python-6.8.2/LICENSE.md000066400000000000000000000020771317472742600160040ustar00rootroot00000000000000MIT License Copyright (C) 2017, 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 the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.twilio-python-6.8.2/MANIFEST.in000066400000000000000000000001451317472742600161300ustar00rootroot00000000000000# Include the SSL certificate file in the package distributed by pip recursive-include twilio/conf * twilio-python-6.8.2/Makefile000066400000000000000000000024331317472742600160340ustar00rootroot00000000000000.PHONY: clean install analysis test test-install develop docs docs-install venv: @python --version || (echo "Python is not installed, please install Python 2 or Python 3"; exit 1); virtualenv --python=python venv install: venv . venv/bin/activate; pip install . test-install: install . venv/bin/activate; pip install -r tests/requirements.txt develop: venv . venv/bin/activate; pip install -e . --use-mirrors . venv/bin/activate; pip install -r tests/requirements.txt analysis: . venv/bin/activate; flake8 --ignore=E123,E126,E128,E501,W391,W291,W293,F401 tests . venv/bin/activate; flake8 --ignore=E402,F401,W391,W291,W293 twilio --max-line-length=300 test: analysis . venv/bin/activate; \ find tests -type d | xargs nosetests cover: . venv/bin/activate; \ find tests -type d | xargs nosetests --with-coverage --cover-inclusive --cover-erase --cover-package=twilio docs-install: . venv/bin/activate; pip install pdoc docs: . venv/bin/activate; pdoc twilio --overwrite --html --html-dir docs release: . venv/bin/activate; python setup.py sdist upload . venv/bin/activate; python setup.py bdist_wheel upload build: test-install . venv/bin/activate; python setup.py sdist . venv/bin/activate; python setup.py bdist_wheel clean: rm -rf venv nopyc: find . -name \*.pyc -delete twilio-python-6.8.2/README.md000066400000000000000000000076421317472742600156620ustar00rootroot00000000000000# twilio-python [![Build Status](https://secure.travis-ci.org/twilio/twilio-python.png?branch=master)](http://travis-ci.org/twilio/twilio-python) [![PyPI](https://img.shields.io/pypi/v/twilio.svg)](https://pypi.python.org/pypi/twilio) [![PyPI](https://img.shields.io/pypi/pyversions/twilio.svg)](https://pypi.python.org/pypi/twilio) A module for using the Twilio REST API and generating valid [TwiML](http://www.twilio.com/docs/api/twiml/ "TwiML - Twilio Markup Language"). ## Recent Update As of release 6.5.0, Beta and Developer Preview products are now exposed via the main `twilio-python` artifact. Releases of the `alpha` branch have been discontinued. If you were using the `alpha` release line, you should be able to switch back to the normal release line without issue. If you were using the normal release line, you should now see several new product lines that were historically hidden from you due to their Beta or Developer Preview status. Such products are explicitly documented as Beta/Developer Preview both in the Twilio docs and console, as well as through in-line code documentation here in the library. ## Installation Install from PyPi using [pip](http://www.pip-installer.org/en/latest/), a package manager for Python. pip install twilio Don't have pip installed? Try installing it, by running this from the command line: $ curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python Or, you can [download the source code (ZIP)](https://github.com/twilio/twilio-python/zipball/master "twilio-python source code") for `twilio-python`, and then run: python setup.py install You may need to run the above commands with `sudo`. ### Migrate from 5.x Please consult the [official migration guide](https://www.twilio.com/docs/libraries/python/migration-guide) for information on upgrading your application using twilio-python 5.x to 6.x ## Feedback Report any feedback or problems with this Release Candidate to the [Github Issues](https://github.com/twilio/twilio-python/issues) for twilio-python. ## Getting Started Getting started with the Twilio API couldn't be easier. Create a `Client` and you're ready to go. ### API Credentials The `Twilio` needs your Twilio credentials. You can either pass these directly to the constructor (see the code below) or via environment variables. ```python from twilio.rest import Client account = "ACXXXXXXXXXXXXXXXXX" token = "YYYYYYYYYYYYYYYYYY" client = Client(account, token) ``` Alternately, a `Client` constructor without these parameters will look for `TWILIO_ACCOUNT_SID` and `TWILIO_AUTH_TOKEN` variables inside the current environment. We suggest storing your credentials as environment variables. Why? You'll never have to worry about committing your credentials and accidentally posting them somewhere public. ```python from twilio.rest import Client client = Client() ``` ### Make a Call ```python from twilio.rest import Client account = "ACXXXXXXXXXXXXXXXXX" token = "YYYYYYYYYYYYYYYYYY" client = Client(account, token) call = client.calls.create(to="9991231234", from_="9991231234", url="http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient") print(call.sid) ``` ### Send an SMS ```python from twilio.rest import Client account = "ACXXXXXXXXXXXXXXXXX" token = "YYYYYYYYYYYYYYYYYY" client = Client(account, token) message = client.messages.create(to="+12316851234", from_="+15555555555", body="Hello there!") ``` ### Handling a call using TwiML To control phone calls, your application needs to output [TwiML](http://www.twilio.com/docs/api/twiml/ "TwiML - Twilio Markup Language"). Use `twilio.twiml.Response` to easily create such responses. ```python from twilio.twiml.voice_response import VoiceResponse r = VoiceResponse() r.say("Welcome to twilio!") print(str(r)) ``` ```xml Welcome to twilio! ``` twilio-python-6.8.2/UPGRADE.md000066400000000000000000000013551317472742600160070ustar00rootroot00000000000000# Upgrade Guide _After `6.0.0` all `MINOR` and `MAJOR` version bumps will have upgrade notes posted here._ [2017-09-28] 6.6.x to 6.7.x --------------------------- ### CHANGED - `Body` parameter on Chat `Message` creation is no longer required. #### Rationale This was changed to add support for sending media in Chat messages, users can now either provide a `body` or a `media_sid`. #### 6.6.x ```python from twilio.rest import Client client = Client('AC123', 'auth') client.chat.v2.services('IS123').channels('CH123').messages.create("this is the body") ``` #### 6.7.x ```python from twilio.rest import Client client = Client('AC123', 'auth') client.chat.v2.services('IS123').channels('CH123').messages.create(body="this is the body") ``` twilio-python-6.8.2/VERSIONS.md000066400000000000000000000034171317472742600161710ustar00rootroot00000000000000# Versioning Strategy `twilio-python` uses a modified version of [Semantic Versioning][semver] for all changes to the helper library. It is strongly encouraged that you pin at least the major version and potentially the minor version to avoid pulling in breaking changes. Semantic Versions take the form of `MAJOR`.`MINOR`.`PATCH` When bugs are fixed in the library in a backwards compatible way, the `PATCH` level will be incremented by one. When new features are added to the library in a backwards compatible way, the `PATCH` level will be incremented by one. `PATCH` changes should _not_ break your code and are generally safe for upgrade. When a new large feature set comes online or a small breaking change is introduced, the `MINOR` version will be incremented by one and the `PATCH` version reset to zero. `MINOR` changes _may_ require some amount of manual code change for upgrade. These backwards-incompatible changes will generally be limited to a small number of function signature changes. The `MAJOR` version is used to indicate the family of technology represented by the helper library. Breaking changes that requires extensive reworking of code will case the `MAJOR` version to be incremented by one, and the `MINOR` and `PATCH` versions will be reset to zero. Twilio understands that this can be very disruptive, so we will only introduce this type of breaking change when absolutely necessary. New `MAJOR` versions will be communicated in advance with `Release Candidates` and a schedule. ## Supported Versions `twilio-python` follows an evergreen model of support. New features and functionality will only be added to the current version. The current version - 1 will continue to be supported with bug fixes and security updates, but no new features. [semver]: http://semver.org/twilio-python-6.8.2/deploy.py000066400000000000000000000043011317472742600162360ustar00rootroot00000000000000from __future__ import print_function import os import re from argparse import ArgumentParser from twilio import __version_info__, __version__ def main(version): current_version = __version__ if version is None: match = re.search(r'(\d+)$', __version_info__[-1]) if not match or match.group() is None: exit('Unable to auto bump version') patch = int(match.group()) patch += 1 prefix = __version_info__[-1][:(-1 * len(match.group()))] new_patch = '{}{}'.format(prefix, patch) version = '.'.join(__version_info__[:-1] + (new_patch, )) print('Deploying {} -> {}'.format(current_version, version)) info = version.split('.') init_src = ("__version_info__ = ({version_info})\n" "__version__ = '.'.join(__version_info__)\n") init_src = init_src.format(version_info=', '.join(["'{}'".format(i) for i in info])) print('Updating twilio/__init__.py ... ', end="") with open('twilio/__init__.py', 'w') as init_file: init_file.write(init_src) print('Done') new_readme = [] print('Updating README.md ... ', end="") with open('README.md', 'r') as readme: for line in readme.readlines(): if current_version in line: line = line.replace(current_version, version) new_readme.append(line) with open('README.md', 'w') as readme: readme.writelines(new_readme) print('Done') print('git commit version bump') os.system('git commit -am "Bumping version to {}"'.format(version)) os.system('git push') print('Done') print('Pushing to pypi') os.system('make release') print('Done') print('Adding git tag') os.system('git tag {}'.format(version)) os.system('git push --tags') print('Done') # TODO: Remove this once 6.x is Generally Available print('!' * 80) print('! {:^76} !'.format('Go hide latest RC and unhide latest 5.x')) print('!' * 80) os.system('open "https://pypi.python.org/pypi?:action=pkg_edit&name=twilio"') if __name__ == '__main__': parser = ArgumentParser() parser.add_argument('version', nargs='?') args = parser.parse_args() main(args.version) twilio-python-6.8.2/examples/000077500000000000000000000000001317472742600162105ustar00rootroot00000000000000twilio-python-6.8.2/examples/basic_usage.py000066400000000000000000000024551317472742600210350ustar00rootroot00000000000000import os from twilio.rest import Client from twilio.twiml.voice_response import VoiceResponse ACCOUNT_SID = os.environ.get('TWILIO_ACCOUNT_SID') AUTH_TOKEN = os.environ.get('TWILIO_AUTH_TOKEN') def example(): """ Some example usage of different twilio resources. """ client = Client(ACCOUNT_SID, AUTH_TOKEN) # Get all messages all_messages = client.messages.list() print('There are {} messages in your account.'.format(len(all_messages))) # Get only last 10 messages... some_messages = client.messages.list(limit=10) print('Here are the last 10 messages in your account:') for m in some_messages: print(m) # Get messages in smaller pages... all_messages = client.messages.list(page_size=10) print('There are {} messages in your account.'.format(len(all_messages))) print('Sending a message...') new_message = client.messages.create(to='XXXX', from_='YYYY', body='Twilio rocks!') print('Making a call...') new_call = client.calls.create(to='XXXX', from_='YYYY', method='GET') print('Serving TwiML') twiml_response = VoiceResponse() twiml_response.say('Hello!') twiml_response.hangup() twiml_xml = twiml_response.to_xml() print('Generated twiml: {}'.format(twiml_xml)) if __name__ == '__main__': example() twilio-python-6.8.2/examples/client_validation.py000066400000000000000000000044231317472742600222550ustar00rootroot00000000000000import os from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives.asymmetric import rsa from cryptography.hazmat.primitives.serialization import ( Encoding, PublicFormat, PrivateFormat, NoEncryption ) from twilio.http.validation_client import ValidationClient from twilio.rest import Client ACCOUNT_SID = os.environ.get('TWILIO_ACCOUNT_SID') AUTH_TOKEN = os.environ.get('TWILIO_AUTH_TOKEN') def example(): """ Example of using the ValidationClient for signed requests to Twilio. This is only available to enterprise customers. This will walkthrough creating an API Key, generating an RSA keypair, setting up a ValidationClient with these values and making requests with the client. """ client = Client(ACCOUNT_SID, AUTH_TOKEN) # Using Client Validation requires using API Keys for auth # First create an API key using the standard account sid, auth token client print('Creating new api key...') api_key = client.new_keys.create(friendly_name='ClientValidationApiKey') # Generate a new RSA Keypair print('Generating RSA key pair...') key_pair = rsa.generate_private_key( public_exponent=65537, key_size=2048, backend=default_backend() ) public_key = key_pair.public_key().public_bytes(Encoding.PEM, PublicFormat.SubjectPublicKeyInfo) private_key = key_pair.private_bytes(Encoding.PEM, PrivateFormat.PKCS8, NoEncryption()) # Register the public key with Twilio print('Registering public key with Twilio...') credential = client.accounts.credentials.public_key.create( public_key, friendly_name='ClientValidationPublicKey' ) # Create a new ValidationClient with the keys we created validation_client = ValidationClient( ACCOUNT_SID, api_key.sid, credential.sid, private_key ) # Create a REST Client using the validation_client client = Client(api_key.sid, api_key.secret, ACCOUNT_SID, http_client=validation_client) # Use the library as usual print('Trying out client validation...') messages = client.messages.list(limit=10) for m in messages: print('Message {}'.format(m.sid)) print('Client validation works!') if __name__ == '__main__': example() twilio-python-6.8.2/requirements.txt000066400000000000000000000000671317472742600176610ustar00rootroot00000000000000six requests>=2.0.0 socksipy-branch PyJWT==1.4.2 twine twilio-python-6.8.2/setup.cfg000066400000000000000000000002121317472742600162060ustar00rootroot00000000000000[bdist_wheel] universal = 1 [metadata] description-file = README.md [flake8] exclude = ./twilio/rest,./twilio/twiml,./tests/integration twilio-python-6.8.2/setup.py000077500000000000000000000042231317472742600161100ustar00rootroot00000000000000from __future__ import with_statement import sys from setuptools import setup, find_packages __version__ = None with open('twilio/__init__.py') as f: exec(f.read()) # To install the twilio-python library, open a Terminal shell, then run this # file by typing: # # python setup.py install # # You need to have the setuptools module installed. Try reading the setuptools # documentation: http://pypi.python.org/pypi/setuptools setup( name = "twilio", version = __version__, description = "Twilio API client and TwiML generator", author = "Twilio", author_email = "help@twilio.com", url = "https://github.com/twilio/twilio-python/", keywords = ["twilio","twiml"], install_requires = [ "six", "pytz", "PyJWT >= 1.4.2", ], extras_require={ ':python_version<"3.0"': [ "requests[security] >= 2.0.0", ], ':python_version>="3.0"': [ "requests >= 2.0.0", "pysocks", ], }, packages = find_packages(exclude=['tests', 'tests.*']), include_package_data=True, classifiers = [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Communications :: Telephony", ], long_description = """\ Python Twilio Helper Library ---------------------------- DESCRIPTION The Twilio REST SDK simplifies the process of making calls using the Twilio REST API. The Twilio REST API lets to you initiate outgoing calls, list previous calls, and much more. See https://www.github.com/twilio/twilio-python for more information. LICENSE The Twilio Python Helper Library is distributed under the MIT License """ ) twilio-python-6.8.2/tests/000077500000000000000000000000001317472742600155345ustar00rootroot00000000000000twilio-python-6.8.2/tests/__init__.py000066400000000000000000000007451317472742600176530ustar00rootroot00000000000000import unittest from tests.holodeck import Holodeck from twilio.rest import Client class IntegrationTestCase(unittest.TestCase): def setUp(self): super(IntegrationTestCase, self).setUp() self.account_sid = 'AC' + 'a' * 32 self.auth_token = 'AUTHTOKEN' self.holodeck = Holodeck() self.client = Client(username=self.account_sid, password=self.auth_token, http_client=self.holodeck) twilio-python-6.8.2/tests/holodeck.py000066400000000000000000000035651317472742600177070ustar00rootroot00000000000000from twilio.base.exceptions import TwilioRestException from twilio.http import HttpClient from twilio.http.request import Request class Hologram(object): def __init__(self, request, response): self.request = request self.response = response class Holodeck(HttpClient): def __init__(self): self._holograms = [] self._requests = [] def mock(self, response, request=None): request = request or Request() self._holograms.append(Hologram(request, response)) @property def requests(self): return self._requests def assert_has_request(self, request): for req in self.requests: if req == request: return message = '\nHolodeck never received a request matching: \n + {}\n'.format(request) if self._requests: message += 'Requests received:\n' message += '\n'.join(' * {}'.format(r) for r in self.requests) else: message += 'No Requests received' raise AssertionError(message) def request(self, method, url, params=None, data=None, headers=None, auth=None, timeout=None, allow_redirects=False): request = Request(method, url, auth, params, data, headers) self._requests.append(request) for hologram in self._holograms: if hologram.request == request: return hologram.response message = '\nHolodeck has no hologram for: {}\n'.format(request) if self._holograms: message += 'Holograms loaded:\n' message += '\n'.join(' - {}'.format(h.request) for h in self._holograms) else: message += 'No Holograms loaded' raise TwilioRestException(404, url, message, method=method) twilio-python-6.8.2/tests/integration/000077500000000000000000000000001317472742600200575ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/__init__.py000066400000000000000000000001701317472742600221660ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/accounts/000077500000000000000000000000001317472742600216765ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/accounts/__init__.py000066400000000000000000000001701317472742600240050ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/accounts/v1/000077500000000000000000000000001317472742600222245ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/accounts/v1/__init__.py000066400000000000000000000001701317472742600243330ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/accounts/v1/credential/000077500000000000000000000000001317472742600243365ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/accounts/v1/credential/__init__.py000066400000000000000000000001701317472742600264450ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/accounts/v1/credential/test_public_key.py000066400000000000000000000162341317472742600301030ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class PublicKeyTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.accounts.v1.credentials \ .public_key.list() self.holodeck.assert_has_request(Request( 'get', 'https://accounts.twilio.com/v1/Credentials/PublicKeys', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "credentials": [], "meta": { "first_page_url": "https://accounts.twilio.com/v1/Credentials/PublicKeys?PageSize=50&Page=0", "key": "credentials", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://accounts.twilio.com/v1/Credentials/PublicKeys?PageSize=50&Page=0" } } ''' )) actual = self.client.accounts.v1.credentials \ .public_key.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "credentials": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-31T04:00:00Z", "date_updated": "2015-07-31T04:00:00Z", "friendly_name": "friendly_name", "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://accounts.twilio.com/v1/Credentials/PublicKeys/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "meta": { "first_page_url": "https://accounts.twilio.com/v1/Credentials/PublicKeys?PageSize=50&Page=0", "key": "credentials", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://accounts.twilio.com/v1/Credentials/PublicKeys?PageSize=50&Page=0" } } ''' )) actual = self.client.accounts.v1.credentials \ .public_key.list() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.accounts.v1.credentials \ .public_key.create(public_key="publickey") values = {'PublicKey': "publickey",} self.holodeck.assert_has_request(Request( 'post', 'https://accounts.twilio.com/v1/Credentials/PublicKeys', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-31T04:00:00Z", "date_updated": "2015-07-31T04:00:00Z", "friendly_name": "friendly_name", "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://accounts.twilio.com/v1/Credentials/PublicKeys/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.accounts.v1.credentials \ .public_key.create(public_key="publickey") self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.accounts.v1.credentials \ .public_key(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://accounts.twilio.com/v1/Credentials/PublicKeys/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-31T04:00:00Z", "date_updated": "2015-07-31T04:00:00Z", "friendly_name": "friendly_name", "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://accounts.twilio.com/v1/Credentials/PublicKeys/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.accounts.v1.credentials \ .public_key(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.accounts.v1.credentials \ .public_key(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://accounts.twilio.com/v1/Credentials/PublicKeys/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-31T04:00:00Z", "date_updated": "2015-07-31T04:00:00Z", "friendly_name": "friendly_name", "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://accounts.twilio.com/v1/Credentials/PublicKeys/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.accounts.v1.credentials \ .public_key(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.accounts.v1.credentials \ .public_key(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://accounts.twilio.com/v1/Credentials/PublicKeys/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.accounts.v1.credentials \ .public_key(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) twilio-python-6.8.2/tests/integration/accounts/v1/test_credential.py000066400000000000000000000005301317472742600257450ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class CredentialTestCase(IntegrationTestCase): pass twilio-python-6.8.2/tests/integration/api/000077500000000000000000000000001317472742600206305ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/api/__init__.py000066400000000000000000000001701317472742600227370ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/api/v2010/000077500000000000000000000000001317472742600214005ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/api/v2010/__init__.py000066400000000000000000000001701317472742600235070ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/api/v2010/account/000077500000000000000000000000001317472742600230345ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/api/v2010/account/__init__.py000066400000000000000000000001701317472742600251430ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/api/v2010/account/address/000077500000000000000000000000001317472742600244615ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/api/v2010/account/address/__init__.py000066400000000000000000000001701317472742600265700ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/api/v2010/account/address/test_dependent_phone_number.py000066400000000000000000000071501317472742600326040ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class DependentPhoneNumberTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .addresses(sid="ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .dependent_phone_numbers.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses/ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/DependentPhoneNumbers.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "dependent_phone_numbers": [ { "address_requirements": "any", "capabilities": { "MMS": "false", "SMS": "true", "voice": "true" }, "friendly_name": "(510) 555-1212", "iso_country": "US", "lata": "722", "latitude": "37.780000", "longitude": "-122.380000", "phone_number": "+15105551212", "postal_code": "94703", "rate_center": "OKLD TRNID", "region": "CA" } ], "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses/ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/DependentPhoneNumbers.json?Page=0&PageSize=50", "next_page_uri": null, "page": 0, "page_size": 50, "previous_page_uri": null, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses/ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/DependentPhoneNumbers.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .addresses(sid="ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .dependent_phone_numbers.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "dependent_phone_numbers": [], "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses/ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/DependentPhoneNumbers.json?Page=0&PageSize=50", "next_page_uri": null, "page": 0, "page_size": 50, "previous_page_uri": null, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses/ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/DependentPhoneNumbers.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .addresses(sid="ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .dependent_phone_numbers.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/available_phone_number/000077500000000000000000000000001317472742600275155ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/api/v2010/account/available_phone_number/__init__.py000066400000000000000000000001701317472742600316240ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/api/v2010/account/available_phone_number/test_local.py000066400000000000000000000076421317472742600322310ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class LocalTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .available_phone_numbers(country_code="US") \ .local.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/Local.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "available_phone_numbers": [ { "address_requirements": "none", "beta": false, "capabilities": { "mms": true, "sms": false, "voice": true }, "friendly_name": "(808) 925-1571", "iso_country": "US", "lata": "834", "latitude": "19.720000", "locality": "Hilo", "longitude": "-155.090000", "phone_number": "+18089251571", "postal_code": "96720", "rate_center": "HILO", "region": "HI" } ], "end": 1, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/Local.json?PageSize=50&Page=0", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/Local.json?PageSize=50&Page=0", "next_page_uri": null, "num_pages": 1, "page": 0, "page_size": 50, "previous_page_uri": null, "start": 0, "total": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/Local.json?PageSize=1" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .available_phone_numbers(country_code="US") \ .local.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "available_phone_numbers": [], "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/Local.json?PageSize=50&Page=0", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/Local.json?PageSize=50&Page=0", "next_page_uri": null, "num_pages": 1, "page": 0, "page_size": 50, "previous_page_uri": null, "start": 0, "total": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/Local.json?PageSize=1" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .available_phone_numbers(country_code="US") \ .local.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/available_phone_number/test_mobile.py000066400000000000000000000075701317472742600324060ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class MobileTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .available_phone_numbers(country_code="US") \ .mobile.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/Mobile.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "available_phone_numbers": [ { "address_requirements": "none", "beta": false, "capabilities": { "mms": false, "sms": true, "voice": false }, "friendly_name": "+4759440374", "iso_country": "NO", "lata": null, "latitude": null, "locality": null, "longitude": null, "phone_number": "+4759440374", "postal_code": null, "rate_center": null, "region": null } ], "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/Mobile.json?PageSize=50&Page=0", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/Mobile.json?PageSize=50&Page=0", "next_page_uri": null, "num_pages": 1, "page": 0, "page_size": 50, "previous_page_uri": null, "start": 0, "total": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/Mobile.json?PageSize=1" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .available_phone_numbers(country_code="US") \ .mobile.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "available_phone_numbers": [], "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/Mobile.json?PageSize=50&Page=0", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/Mobile.json?PageSize=50&Page=0", "next_page_uri": null, "num_pages": 1, "page": 0, "page_size": 50, "previous_page_uri": null, "start": 0, "total": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/Mobile.json?PageSize=1" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .available_phone_numbers(country_code="US") \ .mobile.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/available_phone_number/test_toll_free.py000066400000000000000000000076231317472742600331110ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class TollFreeTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .available_phone_numbers(country_code="US") \ .toll_free.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/TollFree.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "available_phone_numbers": [ { "address_requirements": "none", "beta": false, "capabilities": { "mms": true, "sms": true, "voice": true }, "friendly_name": "(800) 100-0052", "iso_country": "US", "lata": null, "latitude": null, "locality": null, "longitude": null, "phone_number": "+18001000052", "postal_code": null, "rate_center": null, "region": null } ], "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/TollFree.json?PageSize=50&Page=0", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/TollFree.json?PageSize=50&Page=0", "next_page_uri": null, "num_pages": 1, "page": 0, "page_size": 50, "previous_page_uri": null, "start": 0, "total": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/TollFree.json?PageSize=1" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .available_phone_numbers(country_code="US") \ .toll_free.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "available_phone_numbers": [], "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/TollFree.json?PageSize=50&Page=0", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/TollFree.json?PageSize=50&Page=0", "next_page_uri": null, "num_pages": 1, "page": 0, "page_size": 50, "previous_page_uri": null, "start": 0, "total": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/TollFree.json?PageSize=1" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .available_phone_numbers(country_code="US") \ .toll_free.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/call/000077500000000000000000000000001317472742600237475ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/api/v2010/account/call/__init__.py000066400000000000000000000001701317472742600260560ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/api/v2010/account/call/test_feedback.py000066400000000000000000000114051317472742600271050ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class FeedbackTestCase(IntegrationTestCase): def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls(sid="CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .feedback().create(quality_score=1) values = {'QualityScore': 1,} self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Feedback.json', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Thu, 20 Aug 2015 21:45:46 +0000", "date_updated": "Thu, 20 Aug 2015 21:45:46 +0000", "issues": [ "imperfect-audio", "post-dial-delay" ], "quality_score": 5, "sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls(sid="CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .feedback().create(quality_score=1) self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls(sid="CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .feedback().fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Feedback.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Thu, 20 Aug 2015 21:45:46 +0000", "date_updated": "Thu, 20 Aug 2015 21:45:46 +0000", "issues": [ "imperfect-audio", "post-dial-delay" ], "quality_score": 5, "sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls(sid="CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .feedback().fetch() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls(sid="CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .feedback().update(quality_score=1) values = {'QualityScore': 1,} self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Feedback.json', data=values, )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Thu, 20 Aug 2015 21:45:46 +0000", "date_updated": "Thu, 20 Aug 2015 21:45:46 +0000", "issues": [ "imperfect-audio", "post-dial-delay" ], "quality_score": 5, "sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls(sid="CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .feedback().update(quality_score=1) self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/call/test_feedback_summary.py000066400000000000000000000125631317472742600306700ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from datetime import date from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base import serialize from twilio.base.exceptions import TwilioException from twilio.http.response import Response class FeedbackSummaryTestCase(IntegrationTestCase): def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls \ .feedback_summaries.create(start_date=date(2008, 1, 2), end_date=date(2008, 1, 2)) values = { 'StartDate': serialize.iso8601_date(date(2008, 1, 2)), 'EndDate': serialize.iso8601_date(date(2008, 1, 2)), } self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/FeedbackSummary.json', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "call_count": 10200, "call_feedback_count": 729, "end_date": "2011-01-01", "include_subaccounts": false, "issues": [ { "count": 45, "description": "imperfect-audio", "percentage_of_total_calls": "0.04%" } ], "quality_score_average": 4.5, "quality_score_median": 4, "quality_score_standard_deviation": 1, "sid": "FSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "start_date": "2011-01-01", "status": "completed", "date_created": "Tue, 31 Aug 2010 20:36:28 +0000", "date_updated": "Tue, 31 Aug 2010 20:36:44 +0000" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls \ .feedback_summaries.create(start_date=date(2008, 1, 2), end_date=date(2008, 1, 2)) self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls \ .feedback_summaries(sid="FSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/FeedbackSummary/FSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "call_count": 10200, "call_feedback_count": 729, "end_date": "2011-01-01", "include_subaccounts": false, "issues": [ { "count": 45, "description": "imperfect-audio", "percentage_of_total_calls": "0.04%" } ], "quality_score_average": 4.5, "quality_score_median": 4, "quality_score_standard_deviation": 1, "sid": "FSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "start_date": "2011-01-01", "status": "completed", "date_created": "Tue, 31 Aug 2010 20:36:28 +0000", "date_updated": "Tue, 31 Aug 2010 20:36:44 +0000" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls \ .feedback_summaries(sid="FSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls \ .feedback_summaries(sid="FSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/FeedbackSummary/FSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls \ .feedback_summaries(sid="FSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/call/test_notification.py000066400000000000000000000172721317472742600300570ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class NotificationTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls(sid="CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .notifications(sid="NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications/NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2008-08-01", "call_sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Tue, 18 Aug 2015 08:46:56 +0000", "date_updated": "Tue, 18 Aug 2015 08:46:57 +0000", "error_code": "15003", "log": "1", "message_date": "Tue, 18 Aug 2015 08:46:56 +0000", "message_text": "statusCallback=http%3A%2F%2Fexample.com%2Ffoo.xml&ErrorCode=15003&LogLevel=WARN&Msg=Got+HTTP+404+response+to+http%3A%2F%2Fexample.com%2Ffoo.xml", "more_info": "https://www.twilio.com/docs/errors/15003", "request_method": null, "request_url": "", "request_variables": "", "response_body": "", "response_headers": "", "sid": "NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications/NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls(sid="CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .notifications(sid="NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls(sid="CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .notifications(sid="NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications/NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls(sid="CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .notifications(sid="NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls(sid="CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .notifications.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json?PageSize=50&Page=0", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json?PageSize=50&Page=0", "next_page_uri": null, "notifications": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2008-08-01", "call_sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Tue, 18 Aug 2015 08:46:56 +0000", "date_updated": "Tue, 18 Aug 2015 08:46:57 +0000", "error_code": "15003", "log": "1", "message_date": "Tue, 18 Aug 2015 08:46:56 +0000", "message_text": "statusCallback=http%3A%2F%2Fexample.com%2Ffoo.xml&ErrorCode=15003&LogLevel=WARN&Msg=Got+HTTP+404+response+to+http%3A%2F%2Fexample.com%2Ffoo.xml", "more_info": "https://www.twilio.com/docs/errors/15003", "request_method": null, "request_url": "", "sid": "NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications/NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "num_pages": 1, "page": 0, "page_size": 50, "previous_page_uri": null, "start": 0, "total": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls(sid="CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .notifications.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json?PageSize=50&Page=0", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json?PageSize=50&Page=0", "next_page_uri": null, "notifications": [], "num_pages": 1, "page": 0, "page_size": 50, "previous_page_uri": null, "start": 0, "total": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls(sid="CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .notifications.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/call/test_recording.py000066400000000000000000000177761317472742600273560ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class RecordingTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls(sid="CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings(sid="REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2008-08-01", "call_sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Mon, 22 Aug 2011 20:58:45 +0000", "date_updated": "Mon, 22 Aug 2011 20:58:45 +0000", "duration": "6", "price": null, "sid": "REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json", "encryption_details": { "encryption_public_key_sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "encryption_cek": "OV4h6zrsxMIW7h0Zfqwfn6TI2GCNl54KALlg8wn8YB8KYZhXt6HlgvBWAmQTlfYVeLWydMiCewY0YkDDT1xmNe5huEo9vjuKBS5OmYK4CZkSx1NVv3XOGrZHpd2Pl/5WJHVhUK//AUO87uh5qnUP2E0KoLh1nyCLeGcEkXU0RfpPn/6nxjof/n6m6OzZOyeIRK4Oed5+rEtjqFDfqT0EVKjs6JAxv+f0DCc1xYRHl2yV8bahUPVKs+bHYdy4PVszFKa76M/Uae4jFA9Lv233JqWcxj+K2UoghuGhAFbV/JQIIswY2CBYI8JlVSifSqNEl9vvsTJ8bkVMm3MKbG2P7Q==", "encryption_iv": "8I2hhNIYNTrwxfHk" }, "error_code": null } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls(sid="CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings(sid="REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls(sid="CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings(sid="REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls(sid="CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings(sid="REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls(sid="CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json?PageSize=50&Page=0", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json?PageSize=50&Page=0", "next_page_uri": null, "num_pages": 1, "page": 0, "page_size": 50, "previous_page_uri": null, "recordings": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2008-08-01", "call_sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Mon, 22 Aug 2011 20:58:45 +0000", "date_updated": "Mon, 22 Aug 2011 20:58:45 +0000", "duration": "6", "price": null, "sid": "REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json", "encryption_details": { "encryption_public_key_sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "encryption_cek": "OV4h6zrsxMIW7h0Zfqwfn6TI2GCNl54KALlg8wn8YB8KYZhXt6HlgvBWAmQTlfYVeLWydMiCewY0YkDDT1xmNe5huEo9vjuKBS5OmYK4CZkSx1NVv3XOGrZHpd2Pl/5WJHVhUK//AUO87uh5qnUP2E0KoLh1nyCLeGcEkXU0RfpPn/6nxjof/n6m6OzZOyeIRK4Oed5+rEtjqFDfqT0EVKjs6JAxv+f0DCc1xYRHl2yV8bahUPVKs+bHYdy4PVszFKa76M/Uae4jFA9Lv233JqWcxj+K2UoghuGhAFbV/JQIIswY2CBYI8JlVSifSqNEl9vvsTJ8bkVMm3MKbG2P7Q==", "encryption_iv": "8I2hhNIYNTrwxfHk" }, "error_code": null } ], "start": 0, "total": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json?PageSize=50&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls(sid="CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json?PageSize=50&Page=0", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json?PageSize=50&Page=0", "next_page_uri": null, "num_pages": 1, "page": 0, "page_size": 50, "previous_page_uri": null, "recordings": [], "start": 0, "total": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json?PageSize=50&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls(sid="CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/conference/000077500000000000000000000000001317472742600251435ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/api/v2010/account/conference/__init__.py000066400000000000000000000001701317472742600272520ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/api/v2010/account/conference/test_participant.py000066400000000000000000000272351317472742600311030ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class ParticipantTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .conferences(sid="CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants(call_sid="CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "call_sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "conference_sid": "CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Fri, 18 Feb 2011 21:07:19 +0000", "date_updated": "Fri, 18 Feb 2011 21:07:19 +0000", "end_conference_on_exit": false, "muted": false, "hold": false, "status": "complete", "start_conference_on_enter": true, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .conferences(sid="CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants(call_sid="CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .conferences(sid="CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants(call_sid="CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "call_sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "conference_sid": "CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Fri, 18 Feb 2011 21:07:19 +0000", "date_updated": "Fri, 18 Feb 2011 21:07:19 +0000", "end_conference_on_exit": false, "muted": false, "hold": false, "status": "complete", "start_conference_on_enter": true, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .conferences(sid="CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants(call_sid="CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .conferences(sid="CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants.create(from_="+987654321", to="+123456789") values = {'From': "+987654321", 'To': "+123456789",} self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants.json', data=values, )) def test_create_with_sid_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "call_sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "conference_sid": "CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Fri, 18 Feb 2011 21:07:19 +0000", "date_updated": "Fri, 18 Feb 2011 21:07:19 +0000", "end_conference_on_exit": false, "muted": false, "hold": false, "status": "complete", "start_conference_on_enter": true, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .conferences(sid="CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants.create(from_="+987654321", to="+123456789") self.assertIsNotNone(actual) def test_create_with_friendly_name_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "call_sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "conference_sid": "CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Fri, 18 Feb 2011 21:07:19 +0000", "date_updated": "Fri, 18 Feb 2011 21:07:19 +0000", "end_conference_on_exit": false, "muted": false, "hold": false, "status": "complete", "start_conference_on_enter": true, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .conferences(sid="CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants.create(from_="+987654321", to="+123456789") self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .conferences(sid="CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants(call_sid="CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .conferences(sid="CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants(call_sid="CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .conferences(sid="CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants.json?Page=0&PageSize=50", "next_page_uri": null, "page": 0, "page_size": 50, "participants": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "call_sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "conference_sid": "CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Fri, 18 Feb 2011 21:07:19 +0000", "date_updated": "Fri, 18 Feb 2011 21:07:19 +0000", "end_conference_on_exit": false, "muted": false, "hold": false, "status": "complete", "start_conference_on_enter": true, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ], "previous_page_uri": null, "start": 0, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .conferences(sid="CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants.json?Page=0&PageSize=50", "next_page_uri": null, "page": 0, "page_size": 50, "participants": [], "previous_page_uri": null, "start": 0, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .conferences(sid="CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/incoming_phone_number/000077500000000000000000000000001317472742600274005ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/api/v2010/account/incoming_phone_number/__init__.py000066400000000000000000000001701317472742600315070ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/api/v2010/account/incoming_phone_number/assigned_add_on/000077500000000000000000000000001317472742600325015ustar00rootroot00000000000000__init__.py000066400000000000000000000001701317472742600345310ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/api/v2010/account/incoming_phone_number/assigned_add_on# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ test_assigned_add_on_extension.py000066400000000000000000000146701317472742600412400ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/api/v2010/account/incoming_phone_number/assigned_add_on# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class AssignedAddOnExtensionTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .assigned_add_ons(sid="XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .extensions(sid="XFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AssignedAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Extensions/XFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "XFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "assigned_add_on_sid": "XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "resource_sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Incoming Voice Call", "product_name": "Programmable Voice", "unique_name": "voice-incoming", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AssignedAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Extensions/XFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json", "enabled": true } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .assigned_add_ons(sid="XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .extensions(sid="XFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .assigned_add_ons(sid="XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .extensions.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AssignedAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Extensions.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AssignedAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Extensions.json?PageSize=50&Page=0", "next_page_uri": null, "page": 0, "page_size": 50, "previous_page_uri": null, "extensions": [ { "sid": "XFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "assigned_add_on_sid": "XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "resource_sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Incoming Voice Call", "product_name": "Programmable Voice", "unique_name": "voice-incoming", "enabled": true, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AssignedAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Extensions/XFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ], "start": 0, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AssignedAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Extensions.json?PageSize=50&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .assigned_add_ons(sid="XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .extensions.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AssignedAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Extensions.json?PageSize=50&Page=0", "next_page_uri": null, "page": 0, "page_size": 50, "previous_page_uri": null, "extensions": [], "start": 0, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AssignedAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Extensions.json?PageSize=50&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .assigned_add_ons(sid="XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .extensions.list() self.assertIsNotNone(actual) test_assigned_add_on.py000066400000000000000000000241131317472742600340340ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/api/v2010/account/incoming_phone_number# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class AssignedAddOnTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .assigned_add_ons(sid="XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AssignedAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "resource_sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "VoiceBase High Accuracy Transcription", "description": "Automatic Transcription and Keyword Extract...", "configuration": { "bad_words": true }, "unique_name": "voicebase_high_accuracy_transcription", "date_created": "Thu, 07 Apr 2016 23:52:28 +0000", "date_updated": "Thu, 07 Apr 2016 23:52:28 +0000", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AssignedAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json", "subresource_uris": { "extensions": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AssignedAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Extensions.json" } } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .assigned_add_ons(sid="XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .assigned_add_ons.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AssignedAddOns.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AssignedAddOns.json?PageSize=50&Page=0", "next_page_uri": null, "page": 0, "page_size": 50, "previous_page_uri": null, "assigned_add_ons": [ { "sid": "XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "resource_sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "VoiceBase High Accuracy Transcription", "description": "Automatic Transcription and Keyword Extract...", "configuration": { "bad_words": true }, "unique_name": "voicebase_high_accuracy_transcription", "date_created": "Thu, 07 Apr 2016 23:52:28 +0000", "date_updated": "Thu, 07 Apr 2016 23:52:28 +0000", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AssignedAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json", "subresource_uris": { "extensions": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AssignedAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Extensions.json" } } ], "start": 0, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AssignedAddOns.json?PageSize=50&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .assigned_add_ons.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AssignedAddOns.json?PageSize=50&Page=0", "next_page_uri": null, "page": 0, "page_size": 50, "previous_page_uri": null, "assigned_add_ons": [], "start": 0, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AssignedAddOns.json?PageSize=50&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .assigned_add_ons.list() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .assigned_add_ons.create(installed_add_on_sid="XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") values = {'InstalledAddOnSid': "XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",} self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AssignedAddOns.json', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "resource_sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "VoiceBase High Accuracy Transcription", "description": "Automatic Transcription and Keyword Extract...", "configuration": { "bad_words": true }, "unique_name": "voicebase_high_accuracy_transcription", "date_created": "Thu, 07 Apr 2016 23:52:28 +0000", "date_updated": "Thu, 07 Apr 2016 23:52:28 +0000", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AssignedAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json", "subresource_uris": { "extensions": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AssignedAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Extensions.json" } } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .assigned_add_ons.create(installed_add_on_sid="XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .assigned_add_ons(sid="XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AssignedAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .assigned_add_ons(sid="XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/incoming_phone_number/test_local.py000066400000000000000000000166271317472742600321170ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class LocalTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers \ .local.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/Local.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/Local.json?PageSize=1&Page=0", "incoming_phone_numbers": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "address_requirements": "none", "address_sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "beta": null, "capabilities": { "mms": true, "sms": false, "voice": true }, "date_created": "Thu, 30 Jul 2015 23:19:04 +0000", "date_updated": "Thu, 30 Jul 2015 23:19:04 +0000", "friendly_name": "(808) 925-5327", "identity_sid": "RIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "phone_number": "+18089255327", "origin": "origin", "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sms_application_sid": "", "sms_fallback_method": "POST", "sms_fallback_url": "", "sms_method": "POST", "sms_url": "", "status_callback": "", "status_callback_method": "POST", "trunk_sid": null, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json", "voice_application_sid": "", "voice_caller_id_lookup": false, "voice_fallback_method": "POST", "voice_fallback_url": null, "voice_method": "POST", "voice_url": null } ], "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/Local.json?PageSize=1&Page=2", "next_page_uri": null, "num_pages": 3, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "total": 3, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/Local.json?PageSize=1" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers \ .local.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/Local.json?PageSize=1&Page=0", "incoming_phone_numbers": [], "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/Local.json?PageSize=1&Page=2", "next_page_uri": null, "num_pages": 3, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "total": 3, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/Local.json?PageSize=1" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers \ .local.list() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers \ .local.create(phone_number="+987654321") values = {'PhoneNumber': "+987654321",} self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/Local.json', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "address_requirements": "none", "address_sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "beta": false, "capabilities": { "mms": true, "sms": false, "voice": true }, "date_created": "Thu, 30 Jul 2015 23:19:04 +0000", "date_updated": "Thu, 30 Jul 2015 23:19:04 +0000", "friendly_name": "(808) 925-5327", "identity_sid": "RIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "phone_number": "+18089255327", "origin": "origin", "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sms_application_sid": "", "sms_fallback_method": "POST", "sms_fallback_url": "", "sms_method": "POST", "sms_url": "", "status_callback": "", "status_callback_method": "POST", "trunk_sid": null, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json", "voice_application_sid": "", "voice_caller_id_lookup": false, "voice_fallback_method": "POST", "voice_fallback_url": null, "voice_method": "POST", "voice_url": null } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers \ .local.create(phone_number="+987654321") self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/incoming_phone_number/test_mobile.py000066400000000000000000000166231317472742600322700ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class MobileTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers \ .mobile.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/Mobile.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/Mobile.json?Page=0&PageSize=50", "incoming_phone_numbers": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "address_requirements": "none", "address_sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "beta": null, "capabilities": { "mms": false, "sms": true, "voice": false }, "date_created": "Tue, 08 Sep 2015 16:21:16 +0000", "date_updated": "Tue, 08 Sep 2015 16:21:16 +0000", "friendly_name": "61429099450", "identity_sid": "RIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "phone_number": "+61429099450", "origin": "origin", "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sms_application_sid": "", "sms_fallback_method": "POST", "sms_fallback_url": "", "sms_method": "POST", "sms_url": "", "status_callback": "", "status_callback_method": "POST", "trunk_sid": null, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json", "voice_application_sid": "", "voice_caller_id_lookup": false, "voice_fallback_method": "POST", "voice_fallback_url": null, "voice_method": "POST", "voice_url": null } ], "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/Mobile.json?Page=0&PageSize=50", "next_page_uri": null, "num_pages": 1, "page": 0, "page_size": 50, "previous_page_uri": null, "start": 0, "total": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/Mobile.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers \ .mobile.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/Mobile.json?Page=0&PageSize=50", "incoming_phone_numbers": [], "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/Mobile.json?Page=0&PageSize=50", "next_page_uri": null, "num_pages": 1, "page": 0, "page_size": 50, "previous_page_uri": null, "start": 0, "total": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/Mobile.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers \ .mobile.list() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers \ .mobile.create(phone_number="+987654321") values = {'PhoneNumber': "+987654321",} self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/Mobile.json', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "address_requirements": "none", "address_sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "beta": false, "capabilities": { "mms": true, "sms": false, "voice": true }, "date_created": "Thu, 30 Jul 2015 23:19:04 +0000", "date_updated": "Thu, 30 Jul 2015 23:19:04 +0000", "identity_sid": "RIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "(808) 925-5327", "phone_number": "+18089255327", "origin": "origin", "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sms_application_sid": "", "sms_fallback_method": "POST", "sms_fallback_url": "", "sms_method": "POST", "sms_url": "", "status_callback": "", "status_callback_method": "POST", "trunk_sid": null, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json", "voice_application_sid": "", "voice_caller_id_lookup": false, "voice_fallback_method": "POST", "voice_fallback_url": null, "voice_method": "POST", "voice_url": null } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers \ .mobile.create(phone_number="+987654321") self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/incoming_phone_number/test_toll_free.py000066400000000000000000000167061317472742600327760ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class TollFreeTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers \ .toll_free.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/TollFree.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/TollFree.json?PageSize=1&Page=0", "incoming_phone_numbers": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "address_requirements": "none", "address_sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "beta": null, "capabilities": { "mms": true, "sms": false, "voice": true }, "date_created": "Thu, 30 Jul 2015 23:19:04 +0000", "date_updated": "Thu, 30 Jul 2015 23:19:04 +0000", "friendly_name": "(808) 925-5327", "identity_sid": "RIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "phone_number": "+18089255327", "origin": "origin", "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sms_application_sid": "", "sms_fallback_method": "POST", "sms_fallback_url": "", "sms_method": "POST", "sms_url": "", "status_callback": "", "status_callback_method": "POST", "trunk_sid": null, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json", "voice_application_sid": "", "voice_caller_id_lookup": false, "voice_fallback_method": "POST", "voice_fallback_url": null, "voice_method": "POST", "voice_url": null } ], "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/TollFree.json?PageSize=1&Page=2", "next_page_uri": null, "num_pages": 3, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "total": 3, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/TollFree.json?PageSize=1" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers \ .toll_free.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/TollFree.json?PageSize=1&Page=0", "incoming_phone_numbers": [], "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/TollFree.json?PageSize=1&Page=2", "next_page_uri": null, "num_pages": 3, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "total": 3, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/TollFree.json?PageSize=1" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers \ .toll_free.list() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers \ .toll_free.create(phone_number="+987654321") values = {'PhoneNumber': "+987654321",} self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/TollFree.json', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "address_requirements": "none", "address_sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "beta": false, "capabilities": { "mms": true, "sms": false, "voice": true }, "date_created": "Thu, 30 Jul 2015 23:19:04 +0000", "date_updated": "Thu, 30 Jul 2015 23:19:04 +0000", "friendly_name": "(808) 925-5327", "identity_sid": "RIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "phone_number": "+18089255327", "origin": "origin", "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sms_application_sid": "", "sms_fallback_method": "POST", "sms_fallback_url": "", "sms_method": "POST", "sms_url": "", "status_callback": "", "status_callback_method": "POST", "trunk_sid": null, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json", "voice_application_sid": "", "voice_caller_id_lookup": false, "voice_fallback_method": "POST", "voice_fallback_url": null, "voice_method": "POST", "voice_url": null } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers \ .toll_free.create(phone_number="+987654321") self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/message/000077500000000000000000000000001317472742600244605ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/api/v2010/account/message/__init__.py000066400000000000000000000001701317472742600265670ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/api/v2010/account/message/test_feedback.py000066400000000000000000000032531317472742600276200ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class FeedbackTestCase(IntegrationTestCase): def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="MMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .feedback.create() self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/MMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Feedback.json', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Thu, 30 Jul 2015 20:00:00 +0000", "date_updated": "Thu, 30 Jul 2015 20:00:00 +0000", "message_sid": "MMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "outcome": "confirmed", "uri": "uri" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="MMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .feedback.create() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/message/test_media.py000066400000000000000000000152161317472742600271550ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class MediaTestCase(IntegrationTestCase): def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="MMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .media(sid="MEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/MMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media/MEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="MMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .media(sid="MEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="MMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .media(sid="MEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/MMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media/MEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "content_type": "image/jpeg", "date_created": "Sun, 16 Aug 2015 15:53:54 +0000", "date_updated": "Sun, 16 Aug 2015 15:53:55 +0000", "parent_sid": "SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "MEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media/MEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="MMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .media(sid="MEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="MMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .media.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/MMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media.json?PageSize=50&Page=0", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media.json?PageSize=50&Page=0", "media_list": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "content_type": "image/jpeg", "date_created": "Sun, 16 Aug 2015 15:53:54 +0000", "date_updated": "Sun, 16 Aug 2015 15:53:55 +0000", "parent_sid": "SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "MEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media/MEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ], "next_page_uri": null, "num_pages": 1, "page": 0, "page_size": 50, "previous_page_uri": null, "start": 0, "total": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media.json?PageSize=50&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="MMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .media.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media.json?PageSize=50&Page=0", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media.json?PageSize=50&Page=0", "media_list": [], "next_page_uri": null, "num_pages": 1, "page": 0, "page_size": 50, "previous_page_uri": null, "start": 0, "total": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media.json?PageSize=50&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="MMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .media.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/queue/000077500000000000000000000000001317472742600241605ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/api/v2010/account/queue/__init__.py000066400000000000000000000001701317472742600262670ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/api/v2010/account/queue/test_member.py000066400000000000000000000155261317472742600270510ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class MemberTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .queues(sid="QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members(call_sid="CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues/QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "call_sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_enqueued": "Tue, 07 Aug 2012 22:57:41 +0000", "position": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues/QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json", "wait_time": 143 } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .queues(sid="QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members(call_sid="CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .queues(sid="QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members(call_sid="CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update(url="https://example.com", method="GET") values = {'Url': "https://example.com", 'Method': "GET",} self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues/QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', data=values, )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "call_sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_enqueued": "Tue, 07 Aug 2012 22:57:41 +0000", "position": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues/QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json", "wait_time": 143 } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .queues(sid="QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members(call_sid="CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update(url="https://example.com", method="GET") self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .queues(sid="QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues/QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues/QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members.json?Page=0&PageSize=50", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues/QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members.json?Page=0&PageSize=50", "next_page_uri": null, "num_pages": 1, "page": 0, "page_size": 50, "previous_page_uri": null, "queue_members": [ { "call_sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_enqueued": "Tue, 07 Aug 2012 22:57:41 +0000", "position": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues/QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json", "wait_time": 124 } ], "start": 0, "total": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues/QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .queues(sid="QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues/QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members.json?Page=0&PageSize=50", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues/QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members.json?Page=0&PageSize=50", "next_page_uri": null, "num_pages": 1, "page": 0, "page_size": 50, "previous_page_uri": null, "queue_members": [], "start": 0, "total": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues/QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .queues(sid="QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/recording/000077500000000000000000000000001317472742600250105ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/api/v2010/account/recording/__init__.py000066400000000000000000000001701317472742600271170ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/api/v2010/account/recording/add_on_result/000077500000000000000000000000001317472742600276325ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/api/v2010/account/recording/add_on_result/__init__.py000066400000000000000000000001701317472742600317410ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/api/v2010/account/recording/add_on_result/test_payload.py000066400000000000000000000201551317472742600326770ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class PayloadTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings(sid="REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .add_on_results(sid="XRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .payloads(sid="XHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AddOnResults/XRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Payloads/XHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "XHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "reference_sid": "REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "add_on_sid": "XBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "add_on_configuration_sid": "XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "add_on_result_sid": "XRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "label": "XHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "content_type": "application/json", "date_created": "Wed, 01 Sep 2010 15:15:41 +0000", "date_updated": "Wed, 01 Sep 2010 15:15:41 +0000", "subresource_uris": { "data": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AddOnResults/XRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Payloads/XHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Data.json" } } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings(sid="REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .add_on_results(sid="XRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .payloads(sid="XHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings(sid="REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .add_on_results(sid="XRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .payloads.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AddOnResults/XRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Payloads.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AddOnResults/XRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Payloads.json?PageSize=50&Page=0", "next_page_uri": null, "page": 0, "page_size": 50, "previous_page_uri": null, "payloads": [ { "sid": "XHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "reference_sid": "REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "add_on_sid": "XBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "add_on_configuration_sid": "XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "add_on_result_sid": "XRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "label": "XHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "content_type": "application/json", "date_created": "Wed, 01 Sep 2010 15:15:41 +0000", "date_updated": "Wed, 01 Sep 2010 15:15:41 +0000", "subresource_uris": { "data": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AddOnResults/XRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Payloads/XHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Data.json" } } ], "start": 0, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AddOnResults/XRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Payloads.json?PageSize=50&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings(sid="REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .add_on_results(sid="XRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .payloads.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AddOnResults/XRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Payloads.json?PageSize=50&Page=0", "next_page_uri": null, "page": 0, "page_size": 50, "previous_page_uri": null, "payloads": [], "start": 0, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AddOnResults/XRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Payloads.json?PageSize=50&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings(sid="REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .add_on_results(sid="XRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .payloads.list() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings(sid="REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .add_on_results(sid="XRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .payloads(sid="XHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AddOnResults/XRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Payloads/XHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings(sid="REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .add_on_results(sid="XRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .payloads(sid="XHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/recording/test_add_on_result.py000066400000000000000000000157401317472742600312520ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class AddOnResultTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings(sid="REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .add_on_results(sid="XRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AddOnResults/XRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "XRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "reference_sid": "REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "completed", "add_on_sid": "XBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "add_on_configuration_sid": "XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Wed, 01 Sep 2010 15:15:41 +0000", "date_updated": "Wed, 01 Sep 2010 15:15:41 +0000", "date_completed": "Wed, 01 Sep 2010 15:15:41 +0000", "subresource_uris": { "payloads": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AddOnResults/XRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Payloads.json" } } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings(sid="REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .add_on_results(sid="XRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings(sid="REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .add_on_results.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AddOnResults.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AddOnResults.json?PageSize=50&Page=0", "next_page_uri": null, "page": 0, "page_size": 50, "previous_page_uri": null, "add_on_results": [ { "sid": "XRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "reference_sid": "REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "completed", "add_on_sid": "XBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "add_on_configuration_sid": "XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Wed, 01 Sep 2010 15:15:41 +0000", "date_updated": "Wed, 01 Sep 2010 15:15:41 +0000", "date_completed": "Wed, 01 Sep 2010 15:15:41 +0000", "subresource_uris": { "payloads": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AddOnResults/XRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Payloads.json" } } ], "start": 0, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AddOnResults.json?PageSize=50&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings(sid="REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .add_on_results.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AddOnResults.json?PageSize=50&Page=0", "next_page_uri": null, "page": 0, "page_size": 50, "previous_page_uri": null, "add_on_results": [], "start": 0, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AddOnResults.json?PageSize=50&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings(sid="REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .add_on_results.list() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings(sid="REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .add_on_results(sid="XRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AddOnResults/XRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings(sid="REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .add_on_results(sid="XRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/recording/test_transcription.py000066400000000000000000000164241317472742600313270ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class TranscriptionTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings(sid="REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .transcriptions(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2008-08-01", "date_created": "Mon, 22 Aug 2011 20:58:44 +0000", "date_updated": "Mon, 22 Aug 2011 20:58:44 +0000", "duration": "10", "price": "0.00000", "price_unit": "USD", "recording_sid": "REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "in-progress", "transcription_text": "THIS IS A TEST", "type": "fast", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings(sid="REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .transcriptions(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings(sid="REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .transcriptions(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings(sid="REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .transcriptions(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings(sid="REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .transcriptions.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions.json?PageSize=50&Page=0", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions.json?PageSize=50&Page=0", "next_page_uri": null, "num_pages": 1, "page": 0, "page_size": 50, "previous_page_uri": null, "start": 0, "total": 1, "transcriptions": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2008-08-01", "date_created": "Mon, 22 Aug 2011 20:58:44 +0000", "date_updated": "Mon, 22 Aug 2011 20:58:44 +0000", "duration": "10", "price": "0.00000", "price_unit": "USD", "recording_sid": "REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "in-progress", "transcription_text": "THIS IS A TEST", "type": "fast", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ], "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions.json?PageSize=50&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings(sid="REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .transcriptions.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions.json?PageSize=50&Page=0", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions.json?PageSize=50&Page=0", "next_page_uri": null, "num_pages": 1, "page": 0, "page_size": 50, "previous_page_uri": null, "start": 0, "total": 1, "transcriptions": [], "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions.json?PageSize=50&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings(sid="REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .transcriptions.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/sip/000077500000000000000000000000001317472742600236275ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/api/v2010/account/sip/__init__.py000066400000000000000000000001701317472742600257360ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/api/v2010/account/sip/credential_list/000077500000000000000000000000001317472742600267745ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/api/v2010/account/sip/credential_list/__init__.py000066400000000000000000000001701317472742600311030ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/api/v2010/account/sip/credential_list/test_credential.py000066400000000000000000000256221317472742600325260ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class CredentialTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .credential_lists(sid="CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .credentials.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Credentials.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "credentials": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "credential_list_sid": "CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Wed, 19 Aug 2015 19:48:45 +0000", "date_updated": "Wed, 19 Aug 2015 19:48:45 +0000", "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json", "username": "1440013725.28" } ], "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Credentials.json?PageSize=50&Page=0", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Credentials.json?PageSize=50&Page=0", "next_page_uri": null, "num_pages": 1, "page": 0, "page_size": 50, "previous_page_uri": null, "start": 0, "total": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Credentials.json?PageSize=50&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .credential_lists(sid="CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .credentials.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "credentials": [], "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Credentials.json?PageSize=50&Page=0", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Credentials.json?PageSize=50&Page=0", "next_page_uri": null, "num_pages": 1, "page": 0, "page_size": 50, "previous_page_uri": null, "start": 0, "total": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Credentials.json?PageSize=50&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .credential_lists(sid="CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .credentials.list() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .credential_lists(sid="CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .credentials.create(username="username", password="password") values = {'Username': "username", 'Password': "password",} self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Credentials.json', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "credential_list_sid": "CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Wed, 19 Aug 2015 19:48:45 +0000", "date_updated": "Wed, 19 Aug 2015 19:48:45 +0000", "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json", "username": "1440013725.28" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .credential_lists(sid="CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .credentials.create(username="username", password="password") self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .credential_lists(sid="CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .credentials(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "credential_list_sid": "CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Wed, 19 Aug 2015 19:48:45 +0000", "date_updated": "Wed, 19 Aug 2015 19:48:45 +0000", "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json", "username": "1440013725.28" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .credential_lists(sid="CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .credentials(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .credential_lists(sid="CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .credentials(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "credential_list_sid": "CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Wed, 19 Aug 2015 19:48:45 +0000", "date_updated": "Wed, 19 Aug 2015 19:48:45 +0000", "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json", "username": "1440013725.28" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .credential_lists(sid="CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .credentials(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .credential_lists(sid="CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .credentials(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .credential_lists(sid="CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .credentials(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/sip/domain/000077500000000000000000000000001317472742600250765ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/api/v2010/account/sip/domain/__init__.py000066400000000000000000000001701317472742600272050ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/api/v2010/account/sip/domain/test_credential_list_mapping.py000066400000000000000000000222041317472742600333670ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class CredentialListMappingTestCase(IntegrationTestCase): def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .domains(sid="SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .credential_list_mappings.create(credential_list_sid="CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") values = {'CredentialListSid': "CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",} self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialListMappings.json', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Wed, 11 Sep 2013 17:51:38 -0000", "date_updated": "Wed, 11 Sep 2013 17:51:38 -0000", "friendly_name": "Production Gateways IP Address - Scranton", "sid": "CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "subresource_uris": { "credentials": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Credentials.json" }, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .domains(sid="SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .credential_list_mappings.create(credential_list_sid="CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .domains(sid="SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .credential_list_mappings.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialListMappings.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "credential_list_mappings": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Wed, 11 Sep 2013 17:51:38 -0000", "date_updated": "Wed, 11 Sep 2013 17:51:38 -0000", "friendly_name": "Production Gateways IP Address - Scranton", "sid": "CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "subresource_uris": { "credentials": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Credentials.json" }, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ], "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialListMappings.json?PageSize=50&Page=0", "next_page_uri": null, "page": 0, "page_size": 50, "previous_page_uri": null, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialListMappings.json?PageSize=50&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .domains(sid="SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .credential_list_mappings.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "credential_list_mappings": [], "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialListMappings.json?PageSize=50&Page=0", "next_page_uri": null, "page": 0, "page_size": 50, "previous_page_uri": null, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialListMappings.json?PageSize=50&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .domains(sid="SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .credential_list_mappings.list() self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .domains(sid="SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .credential_list_mappings(sid="CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialListMappings/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Wed, 11 Sep 2013 17:51:38 -0000", "date_updated": "Wed, 11 Sep 2013 17:51:38 -0000", "friendly_name": "Production Gateways IP Address - Scranton", "sid": "CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "subresource_uris": { "credentials": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Credentials.json" }, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .domains(sid="SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .credential_list_mappings(sid="CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .domains(sid="SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .credential_list_mappings(sid="CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialListMappings/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .domains(sid="SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .credential_list_mappings(sid="CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) test_ip_access_control_list_mapping.py000066400000000000000000000237151317472742600346770ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/api/v2010/account/sip/domain# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class IpAccessControlListMappingTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .domains(sid="SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .ip_access_control_list_mappings(sid="ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlListMappings/ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Fri, 17 Jul 2015 21:25:15 +0000", "date_updated": "Fri, 17 Jul 2015 21:25:15 +0000", "friendly_name": "aaaa", "sid": "ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "subresource_uris": { "ip_addresses": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists/ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAddresses.json" }, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlListMappings/ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .domains(sid="SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .ip_access_control_list_mappings(sid="ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .domains(sid="SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .ip_access_control_list_mappings.create(ip_access_control_list_sid="ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") values = {'IpAccessControlListSid': "ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",} self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlListMappings.json', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Fri, 17 Jul 2015 21:25:15 +0000", "date_updated": "Fri, 17 Jul 2015 21:25:15 +0000", "friendly_name": "aaaa", "sid": "ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "subresource_uris": { "ip_addresses": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists/ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAddresses.json" }, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlListMappings/ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .domains(sid="SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .ip_access_control_list_mappings.create(ip_access_control_list_sid="ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .domains(sid="SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .ip_access_control_list_mappings.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlListMappings.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlListMappings.json?SipDomainSid=SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0", "ip_access_control_list_mappings": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Fri, 17 Jul 2015 21:25:15 +0000", "date_updated": "Fri, 17 Jul 2015 21:25:15 +0000", "friendly_name": "aaaa", "sid": "ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "subresource_uris": { "ip_addresses": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists/ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAddresses.json" }, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists/ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ], "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlListMappings.json?SipDomainSid=SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0", "next_page_uri": null, "num_pages": 1, "page": 0, "page_size": 50, "previous_page_uri": null, "start": 0, "total": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlListMappings.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .domains(sid="SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .ip_access_control_list_mappings.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlListMappings.json?SipDomainSid=SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0", "ip_access_control_list_mappings": [], "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlListMappings.json?SipDomainSid=SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&PageSize=50&Page=0", "next_page_uri": null, "num_pages": 1, "page": 0, "page_size": 50, "previous_page_uri": null, "start": 0, "total": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlListMappings.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .domains(sid="SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .ip_access_control_list_mappings.list() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .domains(sid="SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .ip_access_control_list_mappings(sid="ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlListMappings/ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .domains(sid="SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .ip_access_control_list_mappings(sid="ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/sip/ip_access_control_list/000077500000000000000000000000001317472742600303535ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/api/v2010/account/sip/ip_access_control_list/__init__.py000066400000000000000000000001701317472742600324620ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ test_ip_address.py000066400000000000000000000264321317472742600340310ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/api/v2010/account/sip/ip_access_control_list# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class IpAddressTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .ip_access_control_lists(sid="ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .ip_addresses.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists/ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAddresses.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists/ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAddresses.json?PageSize=50&Page=0", "ip_addresses": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Mon, 20 Jul 2015 17:27:10 +0000", "date_updated": "Mon, 20 Jul 2015 17:27:10 +0000", "friendly_name": "aaa", "ip_access_control_list_sid": "ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "ip_address": "192.1.1.2", "sid": "IPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists/ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAddresses/IPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ], "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists/ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAddresses.json?PageSize=50&Page=0", "next_page_uri": null, "num_pages": 1, "page": 0, "page_size": 50, "previous_page_uri": null, "start": 0, "total": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists/ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAddresses.json?PageSize=50&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .ip_access_control_lists(sid="ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .ip_addresses.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists/ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAddresses.json?PageSize=50&Page=0", "ip_addresses": [], "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists/ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAddresses.json?PageSize=50&Page=0", "next_page_uri": null, "num_pages": 1, "page": 0, "page_size": 50, "previous_page_uri": null, "start": 0, "total": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists/ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAddresses.json?PageSize=50&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .ip_access_control_lists(sid="ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .ip_addresses.list() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .ip_access_control_lists(sid="ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .ip_addresses.create(friendly_name="friendly_name", ip_address="ip_address") values = {'FriendlyName': "friendly_name", 'IpAddress': "ip_address",} self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists/ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAddresses.json', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Mon, 20 Jul 2015 17:27:10 +0000", "date_updated": "Mon, 20 Jul 2015 17:27:10 +0000", "friendly_name": "aaa", "ip_access_control_list_sid": "ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "ip_address": "192.1.1.2", "sid": "IPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists/ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAddresses/IPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .ip_access_control_lists(sid="ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .ip_addresses.create(friendly_name="friendly_name", ip_address="ip_address") self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .ip_access_control_lists(sid="ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .ip_addresses(sid="IPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists/ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAddresses/IPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Mon, 20 Jul 2015 17:27:10 +0000", "date_updated": "Mon, 20 Jul 2015 17:27:10 +0000", "friendly_name": "aaa", "ip_access_control_list_sid": "ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "ip_address": "192.1.1.2", "sid": "IPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists/ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAddresses/IPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .ip_access_control_lists(sid="ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .ip_addresses(sid="IPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .ip_access_control_lists(sid="ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .ip_addresses(sid="IPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists/ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAddresses/IPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Mon, 20 Jul 2015 17:27:10 +0000", "date_updated": "Mon, 20 Jul 2015 17:27:10 +0000", "friendly_name": "aaa", "ip_access_control_list_sid": "ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "ip_address": "192.1.1.2", "sid": "IPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists/ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAddresses/IPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .ip_access_control_lists(sid="ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .ip_addresses(sid="IPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .ip_access_control_lists(sid="ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .ip_addresses(sid="IPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists/ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAddresses/IPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .ip_access_control_lists(sid="ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .ip_addresses(sid="IPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/sip/test_credential_list.py000066400000000000000000000226521317472742600304140ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class CredentialListTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .credential_lists.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/CredentialLists.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "credential_lists": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Wed, 11 Sep 2013 17:51:38 -0000", "date_updated": "Wed, 11 Sep 2013 17:51:38 -0000", "friendly_name": "Low Rises", "sid": "CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "subresource_uris": { "credentials": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Credentials.json" }, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ], "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/CredentialLists.json?PageSize=50&Page=0", "next_page_uri": null, "page": 0, "page_size": 50, "previous_page_uri": null, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/CredentialLists.json?PageSize=50&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .credential_lists.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "credential_lists": [], "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/CredentialLists.json?PageSize=50&Page=0", "next_page_uri": null, "page": 0, "page_size": 50, "previous_page_uri": null, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/CredentialLists.json?PageSize=50&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .credential_lists.list() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .credential_lists.create(friendly_name="friendly_name") values = {'FriendlyName': "friendly_name",} self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/CredentialLists.json', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Wed, 11 Sep 2013 17:51:38 -0000", "date_updated": "Wed, 11 Sep 2013 17:51:38 -0000", "friendly_name": "Low Rises", "sid": "CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "subresource_uris": { "credentials": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Credentials.json" }, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .credential_lists.create(friendly_name="friendly_name") self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .credential_lists(sid="CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Wed, 11 Sep 2013 17:51:38 -0000", "date_updated": "Wed, 11 Sep 2013 17:51:38 -0000", "friendly_name": "Low Rises", "sid": "CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "subresource_uris": { "credentials": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Credentials.json" }, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .credential_lists(sid="CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .credential_lists(sid="CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update(friendly_name="friendly_name") values = {'FriendlyName': "friendly_name",} self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', data=values, )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Wed, 11 Sep 2013 17:51:38 -0000", "date_updated": "Wed, 11 Sep 2013 17:51:38 -0000", "friendly_name": "Low Rises", "sid": "CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "subresource_uris": { "credentials": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Credentials.json" }, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .credential_lists(sid="CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update(friendly_name="friendly_name") self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .credential_lists(sid="CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .credential_lists(sid="CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/sip/test_domain.py000066400000000000000000000300041317472742600265040ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class DomainTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .domains.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "domains": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "auth_type": "", "date_created": "Fri, 06 Sep 2013 18:48:50 -0000", "date_updated": "Fri, 06 Sep 2013 18:48:50 -0000", "domain_name": "dunder-mifflin-scranton.api.twilio.com", "friendly_name": "Scranton Office", "sip_registration": true, "sid": "SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "subresource_uris": { "credential_list_mappings": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialListMappings.json", "ip_access_control_list_mappings": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlListMappings.json" }, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json", "voice_fallback_method": "POST", "voice_fallback_url": null, "voice_method": "POST", "voice_status_callback_method": "POST", "voice_status_callback_url": null, "voice_url": "https://dundermifflin.example.com/twilio/app.php" } ], "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains.json?PageSize=50&Page=0", "next_page_uri": null, "page": 0, "page_size": 50, "previous_page_uri": null, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains.json?PageSize=50&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .domains.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "domains": [], "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains.json?PageSize=50&Page=0", "next_page_uri": null, "page": 0, "page_size": 50, "previous_page_uri": null, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains.json?PageSize=50&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .domains.list() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .domains.create(domain_name="domain_name") values = {'DomainName': "domain_name",} self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains.json', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "auth_type": "IP_ACL", "date_created": "Fri, 06 Sep 2013 19:18:30 -0000", "date_updated": "Fri, 06 Sep 2013 19:18:30 -0000", "domain_name": "dunder-mifflin-scranton.sip.twilio.com", "friendly_name": "Scranton Office", "sip_registration": true, "sid": "SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "subresource_uris": { "credential_list_mappings": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialListMappings.json", "ip_access_control_list_mappings": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlListMappings.json" }, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json", "voice_fallback_method": "POST", "voice_fallback_url": null, "voice_method": "POST", "voice_status_callback_method": "POST", "voice_status_callback_url": null, "voice_url": "https://dundermifflin.example.com/twilio/app.php" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .domains.create(domain_name="domain_name") self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .domains(sid="SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "auth_type": "IP_ACL", "date_created": "Fri, 06 Sep 2013 19:18:30 -0000", "date_updated": "Fri, 06 Sep 2013 19:18:30 -0000", "domain_name": "dunder-mifflin-scranton.sip.twilio.com", "friendly_name": "Scranton Office", "sip_registration": true, "sid": "SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "subresource_uris": { "credential_list_mappings": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialListMappings.json", "ip_access_control_list_mappings": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlListMappings.json" }, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json", "voice_fallback_method": "POST", "voice_fallback_url": null, "voice_method": "POST", "voice_status_callback_method": "POST", "voice_status_callback_url": null, "voice_url": "https://dundermifflin.example.com/twilio/app.php" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .domains(sid="SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .domains(sid="SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "auth_type": "IP_ACL", "date_created": "Fri, 06 Sep 2013 19:18:30 -0000", "date_updated": "Fri, 06 Sep 2013 19:18:30 -0000", "domain_name": "dunder-mifflin-scranton.sip.twilio.com", "friendly_name": "Scranton Office", "sip_registration": false, "sid": "SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "subresource_uris": { "credential_list_mappings": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialListMappings.json", "ip_access_control_list_mappings": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlListMappings.json" }, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json", "voice_fallback_method": "POST", "voice_fallback_url": null, "voice_method": "POST", "voice_status_callback_method": "POST", "voice_status_callback_url": null, "voice_url": "https://dundermifflin.example.com/twilio/app.php" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .domains(sid="SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .domains(sid="SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/Domains/SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .domains(sid="SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/sip/test_ip_access_control_list.py000066400000000000000000000241151317472742600317670ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class IpAccessControlListTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .ip_access_control_lists.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists.json?PageSize=50&Page=0", "ip_access_control_lists": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Fri, 17 Jul 2015 21:25:15 +0000", "date_updated": "Fri, 17 Jul 2015 21:25:15 +0000", "friendly_name": "aaaa", "sid": "ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "subresource_uris": { "ip_addresses": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists/ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAddresses.json" }, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists/ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ], "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists.json?PageSize=50&Page=0", "next_page_uri": null, "num_pages": 1, "page": 0, "page_size": 50, "previous_page_uri": null, "start": 0, "total": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists.json?PageSize=50&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .ip_access_control_lists.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists.json?PageSize=50&Page=0", "ip_access_control_lists": [], "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists.json?PageSize=50&Page=0", "next_page_uri": null, "num_pages": 1, "page": 0, "page_size": 50, "previous_page_uri": null, "start": 0, "total": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists.json?PageSize=50&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .ip_access_control_lists.list() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .ip_access_control_lists.create(friendly_name="friendly_name") values = {'FriendlyName': "friendly_name",} self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists.json', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Fri, 17 Jul 2015 21:25:15 +0000", "date_updated": "Fri, 17 Jul 2015 21:25:15 +0000", "friendly_name": "aaaa", "sid": "ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "subresource_uris": { "ip_addresses": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists/ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAddresses.json" }, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists/ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .ip_access_control_lists.create(friendly_name="friendly_name") self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .ip_access_control_lists(sid="ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists/ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Fri, 17 Jul 2015 21:25:15 +0000", "date_updated": "Fri, 17 Jul 2015 21:25:15 +0000", "friendly_name": "aaaa", "sid": "ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "subresource_uris": { "ip_addresses": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists/ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAddresses.json" }, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists/ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .ip_access_control_lists(sid="ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .ip_access_control_lists(sid="ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update(friendly_name="friendly_name") values = {'FriendlyName': "friendly_name",} self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists/ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', data=values, )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Fri, 17 Jul 2015 21:25:15 +0000", "date_updated": "Fri, 17 Jul 2015 21:25:15 +0000", "friendly_name": "aaaa", "sid": "ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "subresource_uris": { "ip_addresses": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists/ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAddresses.json" }, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists/ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .ip_access_control_lists(sid="ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update(friendly_name="friendly_name") self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .ip_access_control_lists(sid="ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP/IpAccessControlLists/ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sip \ .ip_access_control_lists(sid="ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/test_address.py000066400000000000000000000233431317472742600260770ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class AddressTestCase(IntegrationTestCase): def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .addresses.create(customer_name="customer_name", street="street", city="city", region="region", postal_code="postal_code", iso_country="US") values = { 'CustomerName': "customer_name", 'Street': "street", 'City': "city", 'Region': "region", 'PostalCode': "postal_code", 'IsoCountry': "US", } self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses.json', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "city": "SF", "customer_name": "name", "date_created": "Tue, 18 Aug 2015 17:07:30 +0000", "date_updated": "Tue, 18 Aug 2015 17:07:30 +0000", "emergency_enabled": false, "friendly_name": null, "iso_country": "US", "postal_code": "94019", "region": "CA", "sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "street": "4th", "validated": false, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses/ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .addresses.create(customer_name="customer_name", street="street", city="city", region="region", postal_code="postal_code", iso_country="US") self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .addresses(sid="ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses/ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .addresses(sid="ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .addresses(sid="ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses/ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "city": "SF", "customer_name": "name", "date_created": "Tue, 18 Aug 2015 17:07:30 +0000", "date_updated": "Tue, 18 Aug 2015 17:07:30 +0000", "emergency_enabled": false, "friendly_name": null, "iso_country": "US", "postal_code": "94019", "region": "CA", "sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "street": "4th", "validated": false, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses/ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .addresses(sid="ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .addresses(sid="ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses/ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "city": "SF", "customer_name": "name", "date_created": "Tue, 18 Aug 2015 17:07:30 +0000", "date_updated": "Tue, 18 Aug 2015 17:07:30 +0000", "emergency_enabled": false, "friendly_name": null, "iso_country": "US", "postal_code": "94019", "region": "CA", "sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "street": "4th", "validated": false, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses/ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .addresses(sid="ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .addresses.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "addresses": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "city": "SF", "customer_name": "name", "date_created": "Tue, 18 Aug 2015 17:07:30 +0000", "date_updated": "Tue, 18 Aug 2015 17:07:30 +0000", "emergency_enabled": false, "friendly_name": null, "iso_country": "US", "postal_code": "94019", "region": "CA", "sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "street": "4th", "validated": false, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses/ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ], "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses.json?PageSize=50&Page=0", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses.json?PageSize=50&Page=0", "next_page_uri": null, "num_pages": 1, "page": 0, "page_size": 50, "previous_page_uri": null, "start": 0, "total": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses.json?PageSize=50&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .addresses.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "addresses": [], "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses.json?PageSize=50&Page=0", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses.json?PageSize=50&Page=0", "next_page_uri": null, "num_pages": 1, "page": 0, "page_size": 50, "previous_page_uri": null, "start": 0, "total": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses.json?PageSize=50&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .addresses.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/test_application.py000066400000000000000000000266021317472742600267560ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class ApplicationTestCase(IntegrationTestCase): def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .applications.create(friendly_name="friendly_name") values = {'FriendlyName': "friendly_name",} self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Applications.json', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "date_created": "Mon, 22 Aug 2011 20:59:45 +0000", "date_updated": "Tue, 18 Aug 2015 16:48:57 +0000", "friendly_name": "Application Friendly Name", "message_status_callback": "http://www.example.com/sms-status-callback", "sid": "APaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sms_fallback_method": "GET", "sms_fallback_url": "http://www.example.com/sms-fallback", "sms_method": "GET", "sms_status_callback": "http://www.example.com/sms-status-callback", "sms_url": "http://example.com", "status_callback": "http://example.com", "status_callback_method": "GET", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Applications/APaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json", "voice_caller_id_lookup": false, "voice_fallback_method": "GET", "voice_fallback_url": "http://www.example.com/voice-callback", "voice_method": "GET", "voice_url": "http://example.com" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .applications.create(friendly_name="friendly_name") self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .applications(sid="APaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Applications/APaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .applications(sid="APaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .applications(sid="APaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Applications/APaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "date_created": "Mon, 22 Aug 2011 20:59:45 +0000", "date_updated": "Tue, 18 Aug 2015 16:48:57 +0000", "friendly_name": "Application Friendly Name", "message_status_callback": "http://www.example.com/sms-status-callback", "sid": "APaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sms_fallback_method": "GET", "sms_fallback_url": "http://www.example.com/sms-fallback", "sms_method": "GET", "sms_status_callback": "http://www.example.com/sms-status-callback", "sms_url": "http://example.com", "status_callback": "http://example.com", "status_callback_method": "GET", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Applications/APaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json", "voice_caller_id_lookup": false, "voice_fallback_method": "GET", "voice_fallback_url": "http://www.example.com/voice-callback", "voice_method": "GET", "voice_url": "http://example.com" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .applications(sid="APaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .applications.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Applications.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "applications": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "date_created": "Fri, 21 Aug 2015 00:07:25 +0000", "date_updated": "Fri, 21 Aug 2015 00:07:25 +0000", "friendly_name": "d8821fb7-4d01-48b2-bdc5-34e46252b90b", "message_status_callback": null, "sid": "APaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sms_fallback_method": "POST", "sms_fallback_url": null, "sms_method": "POST", "sms_status_callback": null, "sms_url": null, "status_callback": null, "status_callback_method": "POST", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Applications/APaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json", "voice_caller_id_lookup": false, "voice_fallback_method": "POST", "voice_fallback_url": null, "voice_method": "POST", "voice_url": null } ], "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Applications.json?PageSize=1&Page=0", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Applications.json?PageSize=1&Page=35", "next_page_uri": null, "num_pages": 36, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "total": 36, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Applications.json?PageSize=1&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .applications.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "applications": [], "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Applications.json?PageSize=1&Page=0", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Applications.json?PageSize=1&Page=35", "next_page_uri": null, "num_pages": 36, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "total": 36, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Applications.json?PageSize=1&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .applications.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .applications(sid="APaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Applications/APaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "date_created": "Mon, 22 Aug 2011 20:59:45 +0000", "date_updated": "Tue, 18 Aug 2015 16:48:57 +0000", "friendly_name": "Application Friendly Name", "message_status_callback": "http://www.example.com/sms-status-callback", "sid": "APaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sms_fallback_method": "GET", "sms_fallback_url": "http://www.example.com/sms-fallback", "sms_method": "GET", "sms_status_callback": "http://www.example.com/sms-status-callback", "sms_url": "http://example.com", "status_callback": "http://example.com", "status_callback_method": "GET", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Applications/APaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json", "voice_caller_id_lookup": false, "voice_fallback_method": "GET", "voice_fallback_url": "http://www.example.com/voice-callback", "voice_method": "GET", "voice_url": "http://example.com" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .applications(sid="APaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/test_authorized_connect_app.py000066400000000000000000000130031317472742600311710ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class AuthorizedConnectAppTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .authorized_connect_apps(connect_app_sid="CNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AuthorizedConnectApps/CNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "connect_app_company_name": "aaa", "connect_app_description": "alksjdfl;ajseifj;alsijfl;ajself;jasjfjas;lejflj", "connect_app_friendly_name": "aaa", "connect_app_homepage_url": "http://www.google.com", "connect_app_sid": "CNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Tue, 31 Aug 2010 20:36:28 +0000", "date_updated": "Tue, 31 Aug 2010 20:36:44 +0000", "permissions": [ "get-all" ], "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AuthorizedConnectApps/CNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .authorized_connect_apps(connect_app_sid="CNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .authorized_connect_apps.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AuthorizedConnectApps.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "authorized_connect_apps": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "connect_app_company_name": "YOUR OTHER MOM", "connect_app_description": "alksjdfl;ajseifj;alsijfl;ajself;jasjfjas;lejflj", "connect_app_friendly_name": "YOUR MOM", "connect_app_homepage_url": "http://www.google.com", "connect_app_sid": "CNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Tue, 31 Aug 2010 20:36:28 +0000", "date_updated": "Tue, 31 Aug 2010 20:36:44 +0000", "permissions": [ "get-all" ], "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AuthorizedConnectApps/CNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ], "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AuthorizedConnectApps.json?Page=0&PageSize=50", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AuthorizedConnectApps.json?Page=0&PageSize=50", "next_page_uri": null, "num_pages": 1, "page": 0, "page_size": 50, "previous_page_uri": null, "start": 0, "total": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AuthorizedConnectApps.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .authorized_connect_apps.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "authorized_connect_apps": [], "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AuthorizedConnectApps.json?Page=0&PageSize=50", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AuthorizedConnectApps.json?Page=0&PageSize=50", "next_page_uri": null, "num_pages": 1, "page": 0, "page_size": 50, "previous_page_uri": null, "start": 0, "total": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AuthorizedConnectApps.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .authorized_connect_apps.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/test_available_phone_number.py000066400000000000000000000110661317472742600311320ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class AvailablePhoneNumberCountryTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .available_phone_numbers.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "countries": [ { "beta": false, "country": "Denmark", "country_code": "DK", "subresource_uris": { "local": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/DK/Local.json" }, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/DK.json" } ], "end": 1, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/DK.json?PageSize=50&Page=0", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/DK.json?PageSize=50&Page=0", "next_page_uri": null, "num_pages": 1, "page": 0, "page_size": 50, "previous_page_uri": null, "start": 0, "total": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .available_phone_numbers.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "countries": [], "end": 1, "first_page_uri": null, "last_page_uri": null, "next_page_uri": null, "num_pages": 1, "page": 0, "page_size": 50, "previous_page_uri": null, "start": 0, "total": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .available_phone_numbers.list() self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .available_phone_numbers(country_code="US").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "beta": null, "country": "United States", "country_code": "US", "subresource_uris": { "local": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/Local.json", "toll_free": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US/TollFree.json" }, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers/US.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .available_phone_numbers(country_code="US").fetch() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/test_call.py000066400000000000000000000312621317472742600253640ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class CallTestCase(IntegrationTestCase): def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls.create(to="+123456789", from_="+987654321") values = {'To': "+123456789", 'From': "+987654321",} self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls.json', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "annotation": null, "answered_by": null, "api_version": "2010-04-01", "caller_name": null, "date_created": "Tue, 31 Aug 2010 20:36:28 +0000", "date_updated": "Tue, 31 Aug 2010 20:36:44 +0000", "direction": "inbound", "duration": "15", "end_time": "Tue, 31 Aug 2010 20:36:44 +0000", "forwarded_from": "+141586753093", "from": "+14158675308", "from_formatted": "(415) 867-5308", "group_sid": null, "parent_call_sid": null, "phone_number_sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "price": "-0.03000", "price_unit": "USD", "sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "start_time": "Tue, 31 Aug 2010 20:36:29 +0000", "status": "completed", "subresource_uris": { "notifications": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json", "recordings": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json", "feedback": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Feedback.json", "feedback_summaries": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/FeedbackSummary.json" }, "to": "+14158675309", "to_formatted": "(415) 867-5309", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls.create(to="+123456789", from_="+987654321") self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls(sid="CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls(sid="CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls(sid="CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "annotation": null, "answered_by": null, "api_version": "2010-04-01", "caller_name": null, "date_created": "Tue, 31 Aug 2010 20:36:28 +0000", "date_updated": "Tue, 31 Aug 2010 20:36:44 +0000", "direction": "inbound", "duration": "15", "end_time": "Tue, 31 Aug 2010 20:36:44 +0000", "forwarded_from": "+141586753093", "from": "+14158675308", "from_formatted": "(415) 867-5308", "group_sid": null, "parent_call_sid": null, "phone_number_sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "price": "-0.03000", "price_unit": "USD", "sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "start_time": "Tue, 31 Aug 2010 20:36:29 +0000", "status": "completed", "subresource_uris": { "notifications": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json", "recordings": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json" }, "to": "+14158675309", "to_formatted": "(415) 867-5309", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls(sid="CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "calls": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "annotation": null, "answered_by": null, "api_version": "2010-04-01", "caller_name": "", "date_created": "Fri, 04 Sep 2015 22:48:30 +0000", "date_updated": "Fri, 04 Sep 2015 22:48:35 +0000", "direction": "outbound-api", "duration": "0", "end_time": "Fri, 04 Sep 2015 22:48:35 +0000", "forwarded_from": null, "from": "kevin", "from_formatted": "kevin", "group_sid": null, "parent_call_sid": null, "phone_number_sid": "", "price": null, "price_unit": "USD", "sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "start_time": "Fri, 04 Sep 2015 22:48:31 +0000", "status": "failed", "subresource_uris": { "notifications": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json", "recordings": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json" }, "to": "sip:kevin@example.com", "to_formatted": "sip:kevin@example.com", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ], "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls.json?PageSize=1&Page=0", "next_page_uri": null, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls.json?PageSize=1&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "calls": [], "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls.json?PageSize=1&Page=0", "next_page_uri": null, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls.json?PageSize=1&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls(sid="CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "annotation": null, "answered_by": null, "api_version": "2010-04-01", "caller_name": null, "date_created": "Tue, 31 Aug 2010 20:36:28 +0000", "date_updated": "Tue, 31 Aug 2010 20:36:44 +0000", "direction": "inbound", "duration": "15", "end_time": "Tue, 31 Aug 2010 20:36:44 +0000", "forwarded_from": "+141586753093", "from": "+14158675308", "from_formatted": "(415) 867-5308", "group_sid": null, "parent_call_sid": null, "phone_number_sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "price": "-0.03000", "price_unit": "USD", "sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "start_time": "Tue, 31 Aug 2010 20:36:29 +0000", "status": "completed", "subresource_uris": { "notifications": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json", "recordings": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json" }, "to": "+14158675309", "to_formatted": "(415) 867-5309", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .calls(sid="CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/test_conference.py000066400000000000000000000152151317472742600265600ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class ConferenceTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .conferences(sid="CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2008-08-01", "date_created": "Fri, 18 Feb 2011 19:26:50 +0000", "date_updated": "Fri, 18 Feb 2011 19:27:33 +0000", "friendly_name": "AHH YEAH", "sid": "CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "region": "us1", "status": "completed", "subresource_uris": { "participants": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants.json" }, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .conferences(sid="CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .conferences.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "conferences": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "date_created": "Mon, 22 Aug 2011 20:58:45 +0000", "date_updated": "Mon, 22 Aug 2011 20:58:46 +0000", "friendly_name": null, "region": "us1", "sid": "CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "in-progress", "subresource_uris": { "participants": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants.json" }, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ], "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences.json?PageSize=1&Page=0", "next_page_uri": null, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences.json?PageSize=1" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .conferences.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "conferences": [], "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences.json?PageSize=1&Page=0", "next_page_uri": null, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences.json?PageSize=1" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .conferences.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .conferences(sid="CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_update_end_conference_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "date_created": "Mon, 22 Aug 2011 20:58:45 +0000", "date_updated": "Mon, 22 Aug 2011 20:58:46 +0000", "friendly_name": null, "region": "us1", "sid": "CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "completed", "subresource_uris": { "participants": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants.json" }, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .conferences(sid="CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/test_connect_app.py000066400000000000000000000154051317472742600267430ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class ConnectAppTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .connect_apps(sid="CNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ConnectApps/CNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "authorize_redirect_url": "http://example.com/redirect", "company_name": "Twilio", "deauthorize_callback_method": "GET", "deauthorize_callback_url": "http://example.com/deauth", "description": null, "friendly_name": "Connect app for deletion", "homepage_url": "http://example.com/home", "permissions": [], "sid": "CNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ConnectApps/CNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .connect_apps(sid="CNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .connect_apps(sid="CNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ConnectApps/CNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "authorize_redirect_url": "http://example.com/redirect", "company_name": "Twilio", "deauthorize_callback_method": "GET", "deauthorize_callback_url": "http://example.com/deauth", "description": null, "friendly_name": "Connect app for deletion", "homepage_url": "http://example.com/home", "permissions": [], "sid": "CNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ConnectApps/CNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .connect_apps(sid="CNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .connect_apps.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ConnectApps.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "connect_apps": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "authorize_redirect_url": "http://example.com/redirect", "company_name": "Twilio", "deauthorize_callback_method": "GET", "deauthorize_callback_url": "http://example.com/deauth", "description": null, "friendly_name": "Connect app for deletion", "homepage_url": "http://example.com/home", "permissions": [], "sid": "CNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ConnectApps/CNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ], "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ConnectApps.json?Page=0&PageSize=50", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ConnectApps.json?Page=0&PageSize=50", "next_page_uri": null, "num_pages": 1, "page": 0, "page_size": 50, "previous_page_uri": null, "start": 0, "total": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ConnectApps.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .connect_apps.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "connect_apps": [], "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ConnectApps.json?Page=0&PageSize=50", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ConnectApps.json?Page=0&PageSize=50", "next_page_uri": null, "num_pages": 1, "page": 0, "page_size": 50, "previous_page_uri": null, "start": 0, "total": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ConnectApps.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .connect_apps.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/test_incoming_phone_number.py000066400000000000000000000325251317472742600310200ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class IncomingPhoneNumberTestCase(IntegrationTestCase): def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "address_requirements": "none", "address_sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "beta": false, "capabilities": { "mms": true, "sms": false, "voice": true }, "date_created": "Thu, 30 Jul 2015 23:19:04 +0000", "date_updated": "Thu, 30 Jul 2015 23:19:04 +0000", "emergency_status": "Inactive", "emergency_address_sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "(808) 925-5327", "identity_sid": "RIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "origin": "origin", "phone_number": "+18089255327", "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sms_application_sid": "", "sms_fallback_method": "POST", "sms_fallback_url": "", "sms_method": "POST", "sms_url": "", "status_callback": "", "status_callback_method": "POST", "trunk_sid": null, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json", "voice_application_sid": "", "voice_caller_id_lookup": false, "voice_fallback_method": "POST", "voice_fallback_url": null, "voice_method": "POST", "voice_url": null } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "address_requirements": "none", "address_sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "beta": false, "capabilities": { "mms": true, "sms": false, "voice": true }, "date_created": "Thu, 30 Jul 2015 23:19:04 +0000", "date_updated": "Thu, 30 Jul 2015 23:19:04 +0000", "emergency_status": "Active", "emergency_address_sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "(808) 925-5327", "identity_sid": "RIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "origin": "origin", "phone_number": "+18089255327", "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sms_application_sid": "", "sms_fallback_method": "POST", "sms_fallback_url": "", "sms_method": "POST", "sms_url": "", "status_callback": "", "status_callback_method": "POST", "trunk_sid": null, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json", "voice_application_sid": "", "voice_caller_id_lookup": false, "voice_fallback_method": "POST", "voice_fallback_url": null, "voice_method": "POST", "voice_url": null } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers.json?PageSize=1&Page=0", "incoming_phone_numbers": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "address_requirements": "none", "address_sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "beta": null, "capabilities": { "mms": true, "sms": false, "voice": true }, "date_created": "Thu, 30 Jul 2015 23:19:04 +0000", "date_updated": "Thu, 30 Jul 2015 23:19:04 +0000", "emergency_status": "Active", "emergency_address_sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "(808) 925-5327", "identity_sid": "RIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "origin": "origin", "phone_number": "+18089255327", "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sms_application_sid": "", "sms_fallback_method": "POST", "sms_fallback_url": "", "sms_method": "POST", "sms_url": "", "status_callback": "", "status_callback_method": "POST", "trunk_sid": null, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json", "voice_application_sid": "", "voice_caller_id_lookup": false, "voice_fallback_method": "POST", "voice_fallback_url": null, "voice_method": "POST", "voice_url": null } ], "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers.json?PageSize=1&Page=2", "next_page_uri": null, "num_pages": 3, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "total": 3, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers.json?PageSize=1" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers.json?PageSize=1&Page=0", "incoming_phone_numbers": [], "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers.json?PageSize=1&Page=2", "next_page_uri": null, "num_pages": 3, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "total": 3, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers.json?PageSize=1" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers.list() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers.create() self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers.json', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "address_requirements": "none", "address_sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "beta": false, "capabilities": { "mms": true, "sms": false, "voice": true }, "date_created": "Thu, 30 Jul 2015 23:19:04 +0000", "date_updated": "Thu, 30 Jul 2015 23:19:04 +0000", "emergency_status": "Active", "emergency_address_sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "(808) 925-5327", "identity_sid": "RIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "origin": "origin", "phone_number": "+18089255327", "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sms_application_sid": "", "sms_fallback_method": "POST", "sms_fallback_url": "", "sms_method": "POST", "sms_url": "", "status_callback": "", "status_callback_method": "POST", "trunk_sid": null, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json", "voice_application_sid": "", "voice_caller_id_lookup": false, "voice_fallback_method": "POST", "voice_fallback_url": null, "voice_method": "POST", "voice_url": null } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .incoming_phone_numbers.create() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/test_key.py000066400000000000000000000133661317472742600252460ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class KeyTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .keys(sid="SKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Keys/SKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "SKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "foo", "date_created": "Mon, 13 Jun 2016 22:50:08 +0000", "date_updated": "Mon, 13 Jun 2016 22:50:08 +0000" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .keys(sid="SKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .keys(sid="SKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Keys/SKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "SKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "foo", "date_created": "Mon, 13 Jun 2016 22:50:08 +0000", "date_updated": "Mon, 13 Jun 2016 22:50:08 +0000" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .keys(sid="SKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .keys(sid="SKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Keys/SKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .keys(sid="SKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .keys.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Keys.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "keys": [ { "sid": "SKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "foo", "date_created": "Mon, 13 Jun 2016 22:50:08 +0000", "date_updated": "Mon, 13 Jun 2016 22:50:08 +0000" } ], "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Keys.json?PageSize=50&Page=0", "end": 0, "previous_page_uri": null, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Keys.json?PageSize=50&Page=0", "page_size": 50, "start": 0, "next_page_uri": null, "page": 0 } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .keys.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "keys": [], "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Keys.json?PageSize=50&Page=0", "end": 0, "previous_page_uri": null, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Keys.json?PageSize=50&Page=0", "page_size": 50, "start": 0, "next_page_uri": null, "page": 0 } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .keys.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/test_message.py000066400000000000000000000266141317472742600261020ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class MessageTestCase(IntegrationTestCase): def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages.create(to="+123456789") values = {'To': "+123456789",} self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages.json', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "body": "O Slash: \u00d8, PoP: \ud83d\udca9", "date_created": "Thu, 30 Jul 2015 20:12:31 +0000", "date_sent": "Thu, 30 Jul 2015 20:12:33 +0000", "date_updated": "Thu, 30 Jul 2015 20:12:33 +0000", "direction": "outbound-api", "error_code": null, "error_message": null, "from": "+14155552345", "messaging_service_sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "num_media": "0", "num_segments": "1", "price": "-0.00750", "price_unit": "USD", "sid": "SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "sent", "subresource_uris": { "media": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media.json" }, "to": "+14155552345", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages.create(to="+123456789") self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="MMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/MMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="MMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="MMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/MMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "body": "O Slash: \u00d8, PoP: \ud83d\udca9", "date_created": "Thu, 30 Jul 2015 20:12:31 +0000", "date_sent": "Thu, 30 Jul 2015 20:12:33 +0000", "date_updated": "Thu, 30 Jul 2015 20:12:33 +0000", "direction": "outbound-api", "error_code": null, "error_message": null, "from": "+14155552345", "messaging_service_sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "num_media": "0", "num_segments": "1", "price": "-0.00750", "price_unit": "USD", "sid": "SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "sent", "subresource_uris": { "media": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media.json" }, "to": "+14155552345", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="MMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages.json?PageSize=1&Page=0", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages.json?PageSize=1&Page=119771", "messages": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "body": "O Slash: \u00d8, PoP: \ud83d\udca9", "date_created": "Fri, 04 Sep 2015 22:54:39 +0000", "date_sent": "Fri, 04 Sep 2015 22:54:41 +0000", "date_updated": "Fri, 04 Sep 2015 22:54:41 +0000", "direction": "outbound-api", "error_code": null, "error_message": null, "from": "+14155552345", "messaging_service_sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "num_media": "0", "num_segments": "1", "price": "-0.00750", "price_unit": "USD", "sid": "SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "sent", "subresource_uris": { "media": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media.json" }, "to": "+14155552345", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ], "next_page_uri": null, "num_pages": 119772, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "total": 119772, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages.json?PageSize=1&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages.json?PageSize=1&Page=0", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages.json?PageSize=1&Page=119771", "messages": [], "next_page_uri": null, "num_pages": 119772, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "total": 119772, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages.json?PageSize=1&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="MMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update(body="body") values = {'Body': "body",} self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/MMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', data=values, )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "body": "O Slash: \u00d8, PoP: \ud83d\udca9", "date_created": "Thu, 30 Jul 2015 20:12:31 +0000", "date_sent": "Thu, 30 Jul 2015 20:12:33 +0000", "date_updated": "Thu, 30 Jul 2015 20:12:33 +0000", "direction": "outbound-api", "error_code": null, "error_message": null, "from": "+14155552345", "messaging_service_sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "num_media": "0", "num_segments": "1", "price": "-0.00750", "price_unit": "USD", "sid": "SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "sent", "subresource_uris": { "media": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media.json" }, "to": "+14155552345", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="MMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update(body="body") self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/test_new_key.py000066400000000000000000000025771317472742600261210ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class NewKeyTestCase(IntegrationTestCase): def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .new_keys.create() self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Keys.json', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "SKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "foo", "date_created": "Mon, 13 Jun 2016 22:50:08 +0000", "date_updated": "Mon, 13 Jun 2016 22:50:08 +0000", "secret": "foobar" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .new_keys.create() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/test_new_signing_key.py000066400000000000000000000026351317472742600276320ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class NewSigningKeyTestCase(IntegrationTestCase): def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .new_signing_keys.create() self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SigningKeys.json', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "SKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "foo", "date_created": "Mon, 13 Jun 2016 22:50:08 +0000", "date_updated": "Mon, 13 Jun 2016 22:50:08 +0000", "secret": "foobar" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .new_signing_keys.create() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/test_notification.py000066400000000000000000000165251317472742600271440ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class NotificationTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .notifications(sid="NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications/NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2008-08-01", "call_sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Mon, 13 Sep 2010 20:02:01 +0000", "date_updated": "Mon, 13 Sep 2010 20:02:01 +0000", "error_code": "11200", "log": "0", "message_date": "Mon, 13 Sep 2010 20:02:00 +0000", "message_text": "EmailNotification=false&LogLevel=ERROR&sourceComponent=12000&Msg=&httpResponse=500&ErrorCode=11200&url=http%3A%2F%2Fvoiceforms4000.appspot.com%2Ftwiml", "more_info": "http://www.twilio.com/docs/errors/11200", "request_method": "get", "request_url": "https://voiceforms4000.appspot.com/twiml/9436/question/0", "request_variables": "AccountSid=ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&CallStatus=in-progress&ToZip=94937&ToCity=INVERNESS&ToState=CA&Called=%2B14156694923&To=%2B14156694923&ToCountry=US&CalledZip=94937&Direction=inbound&ApiVersion=2010-04-01&Caller=%2B17378742833&CalledCity=INVERNESS&CalledCountry=US&CallSid=CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&CalledState=CA&From=%2B17378742833", "response_body": "blah blah", "response_headers": "Date=Mon%2C+13+Sep+2010+20%3A02%3A00+GMT&Content-Length=466&Connection=close&Content-Type=text%2Fhtml%3B+charset%3DUTF-8&Server=Google+Frontend", "sid": "NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications/NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .notifications(sid="NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .notifications(sid="NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications/NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .notifications(sid="NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .notifications.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json?PageSize=1&Page=0", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json?PageSize=1&Page=100", "next_page_uri": null, "notifications": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2008-08-01", "call_sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Thu, 30 Apr 2015 16:47:33 +0000", "date_updated": "Thu, 30 Apr 2015 16:47:35 +0000", "error_code": "21609", "log": "1", "message_date": "Thu, 30 Apr 2015 16:47:32 +0000", "message_text": "LogLevel=WARN&invalidStatusCallbackUrl=&Msg=Invalid+Url+for+callSid%3A+CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa+invalid+statusCallbackUrl%3A+&ErrorCode=21609", "more_info": "https://www.twilio.com/docs/errors/21609", "request_method": null, "request_url": "", "sid": "NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications/NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "num_pages": 101, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "total": 101, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json?PageSize=1&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .notifications.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json?PageSize=1&Page=0", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json?PageSize=1&Page=100", "next_page_uri": null, "notifications": [], "num_pages": 101, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "total": 101, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json?PageSize=1&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .notifications.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/test_outgoing_caller_id.py000066400000000000000000000162551317472742600303070ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class OutgoingCallerIdTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .outgoing_caller_ids(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OutgoingCallerIds/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Fri, 21 Aug 2009 00:11:24 +0000", "date_updated": "Fri, 21 Aug 2009 00:11:24 +0000", "friendly_name": "(415) 867-5309", "phone_number": "+141586753096", "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OutgoingCallerIds/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .outgoing_caller_ids(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .outgoing_caller_ids(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OutgoingCallerIds/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Fri, 21 Aug 2009 00:11:24 +0000", "date_updated": "Fri, 21 Aug 2009 00:11:24 +0000", "friendly_name": "(415) 867-5309", "phone_number": "+141586753096", "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OutgoingCallerIds/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .outgoing_caller_ids(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .outgoing_caller_ids(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OutgoingCallerIds/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .outgoing_caller_ids(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .outgoing_caller_ids.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OutgoingCallerIds.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OutgoingCallerIds.json?Page=0&PageSize=50", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OutgoingCallerIds.json?Page=0&PageSize=50", "next_page_uri": null, "num_pages": 1, "outgoing_caller_ids": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Fri, 21 Aug 2009 00:11:24 +0000", "date_updated": "Fri, 21 Aug 2009 00:11:24 +0000", "friendly_name": "(415) 867-5309", "phone_number": "+141586753096", "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OutgoingCallerIds/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ], "page": 0, "page_size": 50, "previous_page_uri": null, "start": 0, "total": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OutgoingCallerIds.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .outgoing_caller_ids.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OutgoingCallerIds.json?Page=0&PageSize=50", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OutgoingCallerIds.json?Page=0&PageSize=50", "next_page_uri": null, "num_pages": 1, "outgoing_caller_ids": [], "page": 0, "page_size": 50, "previous_page_uri": null, "start": 0, "total": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OutgoingCallerIds.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .outgoing_caller_ids.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/test_queue.py000066400000000000000000000211321317472742600255700ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class QueueTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .queues(sid="QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues/QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "average_wait_time": 0, "current_size": 0, "date_created": "Tue, 04 Aug 2015 18:39:09 +0000", "date_updated": "Tue, 04 Aug 2015 18:39:09 +0000", "friendly_name": "0.361280134646222", "max_size": 100, "sid": "QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues/QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .queues(sid="QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .queues(sid="QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues/QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "average_wait_time": 0, "current_size": 0, "date_created": "Tue, 04 Aug 2015 18:39:09 +0000", "date_updated": "Tue, 04 Aug 2015 18:39:09 +0000", "friendly_name": "0.361280134646222", "max_size": 100, "sid": "QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues/QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .queues(sid="QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .queues(sid="QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues/QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .queues(sid="QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .queues.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues.json?PageSize=1&Page=0", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues.json?PageSize=1&Page=12857", "next_page_uri": null, "num_pages": 12858, "page": 0, "page_size": 1, "previous_page_uri": null, "queues": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "average_wait_time": 0, "current_size": 0, "date_created": "Tue, 04 Aug 2015 18:39:09 +0000", "date_updated": "Tue, 04 Aug 2015 18:39:09 +0000", "friendly_name": "0.361280134646222", "max_size": 100, "sid": "QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues/QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ], "start": 0, "total": 12858, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues.json?PageSize=1&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .queues.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues.json?PageSize=1&Page=0", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues.json?PageSize=1&Page=12857", "next_page_uri": null, "num_pages": 12858, "page": 0, "page_size": 1, "previous_page_uri": null, "queues": [], "start": 0, "total": 12858, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues.json?PageSize=1&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .queues.list() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .queues.create(friendly_name="friendly_name") values = {'FriendlyName': "friendly_name",} self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues.json', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "average_wait_time": 0, "current_size": 0, "date_created": "Tue, 04 Aug 2015 18:39:09 +0000", "date_updated": "Tue, 04 Aug 2015 18:39:09 +0000", "friendly_name": "0.361280134646222", "max_size": 100, "sid": "QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues/QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .queues.create(friendly_name="friendly_name") self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/test_recording.py000066400000000000000000000165541317472742600264340ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class RecordingTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings(sid="REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "call_sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Wed, 01 Sep 2010 15:15:41 +0000", "date_updated": "Wed, 01 Sep 2010 15:15:41 +0000", "duration": "6", "sid": "REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "price": "0.04", "price_unit": "USD", "status": "completed", "channels": 1, "source": "Trunking", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json", "encryption_details": { "encryption_public_key_sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "encryption_cek": "OV4h6zrsxMIW7h0Zfqwfn6TI2GCNl54KALlg8wn8YB8KYZhXt6HlgvBWAmQTlfYVeLWydMiCewY0YkDDT1xmNe5huEo9vjuKBS5OmYK4CZkSx1NVv3XOGrZHpd2Pl/5WJHVhUK//AUO87uh5qnUP2E0KoLh1nyCLeGcEkXU0RfpPn/6nxjof/n6m6OzZOyeIRK4Oed5+rEtjqFDfqT0EVKjs6JAxv+f0DCc1xYRHl2yV8bahUPVKs+bHYdy4PVszFKa76M/Uae4jFA9Lv233JqWcxj+K2UoghuGhAFbV/JQIIswY2CBYI8JlVSifSqNEl9vvsTJ8bkVMm3MKbG2P7Q==", "encryption_iv": "8I2hhNIYNTrwxfHk" }, "error_code": null } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings(sid="REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings(sid="REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings(sid="REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json?PageSize=1&Page=0", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json?PageSize=1&Page=4", "next_page_uri": null, "num_pages": 5, "page": 0, "page_size": 1, "previous_page_uri": null, "recordings": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2008-08-01", "call_sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Wed, 22 Aug 2012 20:58:45 +0000", "date_updated": "Wed, 22 Aug 2012 20:58:45 +0000", "duration": null, "sid": "REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "price": "0.04", "price_unit": "USD", "status": "completed", "channels": 1, "source": "Trunking", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json", "encryption_details": { "encryption_public_key_sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "encryption_cek": "OV4h6zrsxMIW7h0Zfqwfn6TI2GCNl54KALlg8wn8YB8KYZhXt6HlgvBWAmQTlfYVeLWydMiCewY0YkDDT1xmNe5huEo9vjuKBS5OmYK4CZkSx1NVv3XOGrZHpd2Pl/5WJHVhUK//AUO87uh5qnUP2E0KoLh1nyCLeGcEkXU0RfpPn/6nxjof/n6m6OzZOyeIRK4Oed5+rEtjqFDfqT0EVKjs6JAxv+f0DCc1xYRHl2yV8bahUPVKs+bHYdy4PVszFKa76M/Uae4jFA9Lv233JqWcxj+K2UoghuGhAFbV/JQIIswY2CBYI8JlVSifSqNEl9vvsTJ8bkVMm3MKbG2P7Q==", "encryption_iv": "8I2hhNIYNTrwxfHk" }, "error_code": null } ], "start": 0, "total": 5, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json?PageSize=1&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json?PageSize=1&Page=0", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json?PageSize=1&Page=4", "next_page_uri": null, "num_pages": 5, "page": 0, "page_size": 1, "previous_page_uri": null, "recordings": [], "start": 0, "total": 5, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json?PageSize=1&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/test_short_code.py000066400000000000000000000152211317472742600265770ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class ShortCodeTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .short_codes(sid="SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SMS/ShortCodes/SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "date_created": null, "date_updated": null, "friendly_name": "API_CLUSTER_TEST_SHORT_CODE", "short_code": "99990", "sid": "SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sms_fallback_method": "POST", "sms_fallback_url": null, "sms_method": "POST", "sms_url": null, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SMS/ShortCodes/SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .short_codes(sid="SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .short_codes(sid="SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SMS/ShortCodes/SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "date_created": null, "date_updated": null, "friendly_name": "API_CLUSTER_TEST_SHORT_CODE", "short_code": "99990", "sid": "SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sms_fallback_method": "POST", "sms_fallback_url": null, "sms_method": "POST", "sms_url": null, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SMS/ShortCodes/SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .short_codes(sid="SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .short_codes.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SMS/ShortCodes.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SMS/ShortCodes.json?Page=0&PageSize=50", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SMS/ShortCodes.json?Page=0&PageSize=50", "next_page_uri": null, "num_pages": 1, "page": 0, "page_size": 50, "previous_page_uri": null, "short_codes": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "date_created": null, "date_updated": null, "friendly_name": "API_CLUSTER_TEST_SHORT_CODE", "short_code": "99990", "sid": "SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sms_fallback_method": "POST", "sms_fallback_url": null, "sms_method": "POST", "sms_url": null, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SMS/ShortCodes/SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ], "start": 0, "total": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SMS/ShortCodes.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .short_codes.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SMS/ShortCodes.json?Page=0&PageSize=50", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SMS/ShortCodes.json?Page=0&PageSize=50", "next_page_uri": null, "num_pages": 1, "page": 0, "page_size": 50, "previous_page_uri": null, "short_codes": [], "start": 0, "total": 1, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SMS/ShortCodes.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .short_codes.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/test_signing_key.py000066400000000000000000000136151317472742600267610ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class SigningKeyTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .signing_keys(sid="SKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SigningKeys/SKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "SKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "foo", "date_created": "Mon, 13 Jun 2016 22:50:08 +0000", "date_updated": "Mon, 13 Jun 2016 22:50:08 +0000" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .signing_keys(sid="SKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .signing_keys(sid="SKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SigningKeys/SKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "SKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "foo", "date_created": "Mon, 13 Jun 2016 22:50:08 +0000", "date_updated": "Mon, 13 Jun 2016 22:50:08 +0000" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .signing_keys(sid="SKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .signing_keys(sid="SKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SigningKeys/SKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .signing_keys(sid="SKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .signing_keys.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SigningKeys.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "signing_keys": [ { "sid": "SKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "foo", "date_created": "Mon, 13 Jun 2016 22:50:08 +0000", "date_updated": "Mon, 13 Jun 2016 22:50:08 +0000" } ], "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SigningKeys.json?PageSize=50&Page=0", "end": 0, "previous_page_uri": null, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SigningKeys.json?PageSize=50&Page=0", "page_size": 50, "start": 0, "next_page_uri": null, "page": 0 } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .signing_keys.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "signing_keys": [], "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SigningKeys.json?PageSize=50&Page=0", "end": 0, "previous_page_uri": null, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SigningKeys.json?PageSize=50&Page=0", "page_size": 50, "start": 0, "next_page_uri": null, "page": 0 } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .signing_keys.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/test_sip.py000066400000000000000000000005211317472742600252360ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class SipTestCase(IntegrationTestCase): pass twilio-python-6.8.2/tests/integration/api/v2010/account/test_token.py000066400000000000000000000037311317472742600255710ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class TokenTestCase(IntegrationTestCase): def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .tokens.create() self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tokens.json', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Fri, 24 Jul 2015 18:43:58 +0000", "date_updated": "Fri, 24 Jul 2015 18:43:58 +0000", "ice_servers": [ { "url": "stun:global.stun:3478?transport=udp" }, { "credential": "5SR2x8mZK1lTFJW3NVgLGw6UM9C0dja4jI/Hdw3xr+w=", "url": "turn:global.turn:3478?transport=udp", "username": "cda92e5006c7810494639fc466ecc80182cef8183fdf400f84c4126f3b59d0bb" } ], "password": "5SR2x8mZK1lTFJW3NVgLGw6UM9C0dja4jI/Hdw3xr+w=", "ttl": "86400", "username": "cda92e5006c7810494639fc466ecc80182cef8183fdf400f84c4126f3b59d0bb" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .tokens.create() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/test_transcription.py000066400000000000000000000143211317472742600273450ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class TranscriptionTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .transcriptions(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2008-08-01", "date_created": "Sun, 13 Feb 2011 02:12:08 +0000", "date_updated": "Sun, 13 Feb 2011 02:30:01 +0000", "duration": "1", "price": "-0.05000", "price_unit": "USD", "recording_sid": "REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "failed", "transcription_text": "(blank)", "type": "fast", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .transcriptions(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .transcriptions(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .transcriptions(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .transcriptions.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions.json?PageSize=1&Page=0", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions.json?PageSize=1&Page=3", "next_page_uri": null, "num_pages": 4, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "total": 4, "transcriptions": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2008-08-01", "date_created": "Thu, 25 Aug 2011 20:59:45 +0000", "date_updated": "Thu, 25 Aug 2011 20:59:45 +0000", "duration": "10", "price": "0.00000", "price_unit": "USD", "recording_sid": "REaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "completed", "transcription_text": null, "type": "fast", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ], "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions.json?PageSize=1&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .transcriptions.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions.json?PageSize=1&Page=0", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions.json?PageSize=1&Page=3", "next_page_uri": null, "num_pages": 4, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "total": 4, "transcriptions": [], "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions.json?PageSize=1&Page=0" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .transcriptions.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/test_usage.py000066400000000000000000000005231317472742600255510ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class UsageTestCase(IntegrationTestCase): pass twilio-python-6.8.2/tests/integration/api/v2010/account/test_validation_request.py000066400000000000000000000030531317472742600303500ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class ValidationRequestTestCase(IntegrationTestCase): def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .validation_requests.create(phone_number="+987654321") values = {'PhoneNumber': "+987654321",} self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OutgoingCallerIds.json', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "call_sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "phone_number": "+18001234567", "validation_code": 100 } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .validation_requests.create(phone_number="+987654321") self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/usage/000077500000000000000000000000001317472742600241405ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/api/v2010/account/usage/__init__.py000066400000000000000000000001701317472742600262470ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/api/v2010/account/usage/record/000077500000000000000000000000001317472742600254165ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/api/v2010/account/usage/record/__init__.py000066400000000000000000000001701317472742600275250ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/api/v2010/account/usage/record/test_all_time.py000066400000000000000000000122541317472742600306210ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class AllTimeTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .records \ .all_time.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/AllTime.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/AllTime?Page=0&PageSize=1", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/AllTime?Page=68&PageSize=1", "next_page_uri": null, "num_pages": 69, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "total": 69, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/AllTime", "usage_records": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "category": "sms-inbound-shortcode", "count": "0", "count_unit": "messages", "description": "Short Code Inbound SMS", "end_date": "2015-09-04", "price": "0", "price_unit": "usd", "start_date": "2011-08-23", "subresource_uris": { "all_time": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/AllTime.json?Category=sms-inbound-shortcode", "daily": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Daily.json?Category=sms-inbound-shortcode", "last_month": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/LastMonth.json?Category=sms-inbound-shortcode", "monthly": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Monthly.json?Category=sms-inbound-shortcode", "this_month": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/ThisMonth.json?Category=sms-inbound-shortcode", "today": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Today.json?Category=sms-inbound-shortcode", "yearly": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Yearly.json?Category=sms-inbound-shortcode", "yesterday": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Yesterday.json?Category=sms-inbound-shortcode" }, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/AllTime?Category=sms-inbound-shortcode&StartDate=2011-08-23&EndDate=2015-09-04", "usage": "0", "usage_unit": "messages" } ] } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .records \ .all_time.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/AllTime?Page=0&PageSize=1", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/AllTime?Page=68&PageSize=1", "next_page_uri": null, "num_pages": 69, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "total": 69, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/AllTime", "usage_records": [] } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .records \ .all_time.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/usage/record/test_daily.py000066400000000000000000000122511317472742600301320ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class DailyTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .records \ .daily.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Daily.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Daily?Page=0&PageSize=1", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Daily?Page=101843&PageSize=1", "next_page_uri": null, "num_pages": 101844, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "total": 101844, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Daily", "usage_records": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "category": "sms-inbound-shortcode", "count": "0", "count_unit": "messages", "description": "Short Code Inbound SMS", "end_date": "2015-09-06", "price": "0", "price_unit": "usd", "start_date": "2015-09-06", "subresource_uris": { "all_time": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/AllTime.json?Category=sms-inbound-shortcode", "daily": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Daily.json?Category=sms-inbound-shortcode", "last_month": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/LastMonth.json?Category=sms-inbound-shortcode", "monthly": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Monthly.json?Category=sms-inbound-shortcode", "this_month": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/ThisMonth.json?Category=sms-inbound-shortcode", "today": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Today.json?Category=sms-inbound-shortcode", "yearly": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Yearly.json?Category=sms-inbound-shortcode", "yesterday": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Yesterday.json?Category=sms-inbound-shortcode" }, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Daily?Category=sms-inbound-shortcode&StartDate=2015-09-06&EndDate=2015-09-06", "usage": "0", "usage_unit": "messages" } ] } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .records \ .daily.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Daily?Page=0&PageSize=1", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Daily?Page=101843&PageSize=1", "next_page_uri": null, "num_pages": 101844, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "total": 101844, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Daily", "usage_records": [] } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .records \ .daily.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/usage/record/test_last_month.py000066400000000000000000000123041317472742600311770ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class LastMonthTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .records \ .last_month.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/LastMonth.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/LastMonth?Page=0&PageSize=1", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/LastMonth?Page=68&PageSize=1", "next_page_uri": null, "num_pages": 69, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "total": 69, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/LastMonth", "usage_records": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "category": "sms-inbound-shortcode", "count": "0", "count_unit": "messages", "description": "Short Code Inbound SMS", "end_date": "2015-08-31", "price": "0", "price_unit": "usd", "start_date": "2015-08-01", "subresource_uris": { "all_time": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/AllTime.json?Category=sms-inbound-shortcode", "daily": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Daily.json?Category=sms-inbound-shortcode", "last_month": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/LastMonth.json?Category=sms-inbound-shortcode", "monthly": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Monthly.json?Category=sms-inbound-shortcode", "this_month": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/ThisMonth.json?Category=sms-inbound-shortcode", "today": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Today.json?Category=sms-inbound-shortcode", "yearly": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Yearly.json?Category=sms-inbound-shortcode", "yesterday": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Yesterday.json?Category=sms-inbound-shortcode" }, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/LastMonth?Category=sms-inbound-shortcode&StartDate=2015-08-01&EndDate=2015-08-31", "usage": "0", "usage_unit": "messages" } ] } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .records \ .last_month.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/LastMonth?Page=0&PageSize=1", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/LastMonth?Page=68&PageSize=1", "next_page_uri": null, "num_pages": 69, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "total": 69, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/LastMonth", "usage_records": [] } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .records \ .last_month.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/usage/record/test_monthly.py000066400000000000000000000122651317472742600305270ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class MonthlyTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .records \ .monthly.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Monthly.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Monthly?Page=0&PageSize=1", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Monthly?Page=3449&PageSize=1", "next_page_uri": null, "num_pages": 3450, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "total": 3450, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Monthly", "usage_records": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "category": "sms-inbound-shortcode", "count": "0", "count_unit": "messages", "description": "Short Code Inbound SMS", "end_date": "2015-09-04", "price": "0", "price_unit": "usd", "start_date": "2015-09-01", "subresource_uris": { "all_time": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/AllTime.json?Category=sms-inbound-shortcode", "daily": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Daily.json?Category=sms-inbound-shortcode", "last_month": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/LastMonth.json?Category=sms-inbound-shortcode", "monthly": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Monthly.json?Category=sms-inbound-shortcode", "this_month": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/ThisMonth.json?Category=sms-inbound-shortcode", "today": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Today.json?Category=sms-inbound-shortcode", "yearly": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Yearly.json?Category=sms-inbound-shortcode", "yesterday": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Yesterday.json?Category=sms-inbound-shortcode" }, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Monthly?Category=sms-inbound-shortcode&StartDate=2015-09-01&EndDate=2015-09-04", "usage": "0", "usage_unit": "messages" } ] } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .records \ .monthly.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Monthly?Page=0&PageSize=1", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Monthly?Page=3449&PageSize=1", "next_page_uri": null, "num_pages": 3450, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "total": 3450, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Monthly", "usage_records": [] } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .records \ .monthly.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/usage/record/test_this_month.py000066400000000000000000000123041317472742600312030ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class ThisMonthTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .records \ .this_month.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/ThisMonth.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/ThisMonth?Page=0&PageSize=1", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/ThisMonth?Page=68&PageSize=1", "next_page_uri": null, "num_pages": 69, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "total": 69, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/ThisMonth", "usage_records": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "category": "sms-inbound-shortcode", "count": "0", "count_unit": "messages", "description": "Short Code Inbound SMS", "end_date": "2015-09-04", "price": "0", "price_unit": "usd", "start_date": "2015-09-01", "subresource_uris": { "all_time": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/AllTime.json?Category=sms-inbound-shortcode", "daily": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Daily.json?Category=sms-inbound-shortcode", "last_month": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/LastMonth.json?Category=sms-inbound-shortcode", "monthly": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Monthly.json?Category=sms-inbound-shortcode", "this_month": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/ThisMonth.json?Category=sms-inbound-shortcode", "today": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Today.json?Category=sms-inbound-shortcode", "yearly": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Yearly.json?Category=sms-inbound-shortcode", "yesterday": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Yesterday.json?Category=sms-inbound-shortcode" }, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/ThisMonth?Category=sms-inbound-shortcode&StartDate=2015-09-01&EndDate=2015-09-04", "usage": "0", "usage_unit": "messages" } ] } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .records \ .this_month.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/ThisMonth?Page=0&PageSize=1", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/ThisMonth?Page=68&PageSize=1", "next_page_uri": null, "num_pages": 69, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "total": 69, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/ThisMonth", "usage_records": [] } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .records \ .this_month.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/usage/record/test_today.py000066400000000000000000000122211317472742600301450ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class TodayTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .records \ .today.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Today.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Today?Page=0&PageSize=1", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Today?Page=68&PageSize=1", "next_page_uri": null, "num_pages": 69, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "total": 69, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Today", "usage_records": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "category": "sms-inbound-shortcode", "count": "0", "count_unit": "messages", "description": "Short Code Inbound SMS", "end_date": "2015-09-04", "price": "0", "price_unit": "usd", "start_date": "2015-09-04", "subresource_uris": { "all_time": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/AllTime.json?Category=sms-inbound-shortcode", "daily": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Daily.json?Category=sms-inbound-shortcode", "last_month": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/LastMonth.json?Category=sms-inbound-shortcode", "monthly": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Monthly.json?Category=sms-inbound-shortcode", "this_month": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/ThisMonth.json?Category=sms-inbound-shortcode", "today": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Today.json?Category=sms-inbound-shortcode", "yearly": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Yearly.json?Category=sms-inbound-shortcode", "yesterday": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Yesterday.json?Category=sms-inbound-shortcode" }, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Today?Category=sms-inbound-shortcode&StartDate=2015-09-04&EndDate=2015-09-04", "usage": "0", "usage_unit": "messages" } ] } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .records \ .today.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Today?Page=0&PageSize=1", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Today?Page=68&PageSize=1", "next_page_uri": null, "num_pages": 69, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "total": 69, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Today", "usage_records": [] } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .records \ .today.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/usage/record/test_yearly.py000066400000000000000000000122431317472742600303360ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class YearlyTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .records \ .yearly.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Yearly.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Yearly?Page=0&PageSize=1", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Yearly?Page=344&PageSize=1", "next_page_uri": null, "num_pages": 345, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "total": 345, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Yearly", "usage_records": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "category": "sms-inbound-shortcode", "count": "0", "count_unit": "messages", "description": "Short Code Inbound SMS", "end_date": "2015-09-04", "price": "0", "price_unit": "usd", "start_date": "2015-01-01", "subresource_uris": { "all_time": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/AllTime.json?Category=sms-inbound-shortcode", "daily": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Daily.json?Category=sms-inbound-shortcode", "last_month": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/LastMonth.json?Category=sms-inbound-shortcode", "monthly": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Monthly.json?Category=sms-inbound-shortcode", "this_month": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/ThisMonth.json?Category=sms-inbound-shortcode", "today": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Today.json?Category=sms-inbound-shortcode", "yearly": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Yearly.json?Category=sms-inbound-shortcode", "yesterday": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Yesterday.json?Category=sms-inbound-shortcode" }, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Yearly?Category=sms-inbound-shortcode&StartDate=2015-01-01&EndDate=2015-09-04", "usage": "0", "usage_unit": "messages" } ] } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .records \ .yearly.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Yearly?Page=0&PageSize=1", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Yearly?Page=344&PageSize=1", "next_page_uri": null, "num_pages": 345, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "total": 345, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Yearly", "usage_records": [] } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .records \ .yearly.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/usage/record/test_yesterday.py000066400000000000000000000123011317472742600310350ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class YesterdayTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .records \ .yesterday.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Yesterday.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Yesterday?Page=0&PageSize=1", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Yesterday?Page=68&PageSize=1", "next_page_uri": null, "num_pages": 69, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "total": 69, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Yesterday", "usage_records": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "category": "sms-inbound-shortcode", "count": "0", "count_unit": "messages", "description": "Short Code Inbound SMS", "end_date": "2015-09-03", "price": "0", "price_unit": "usd", "start_date": "2015-09-03", "subresource_uris": { "all_time": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/AllTime.json?Category=sms-inbound-shortcode", "daily": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Daily.json?Category=sms-inbound-shortcode", "last_month": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/LastMonth.json?Category=sms-inbound-shortcode", "monthly": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Monthly.json?Category=sms-inbound-shortcode", "this_month": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/ThisMonth.json?Category=sms-inbound-shortcode", "today": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Today.json?Category=sms-inbound-shortcode", "yearly": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Yearly.json?Category=sms-inbound-shortcode", "yesterday": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Yesterday.json?Category=sms-inbound-shortcode" }, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Yesterday?Category=sms-inbound-shortcode&StartDate=2015-09-03&EndDate=2015-09-03", "usage": "0", "usage_unit": "messages" } ] } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .records \ .yesterday.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Yesterday?Page=0&PageSize=1", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Yesterday?Page=68&PageSize=1", "next_page_uri": null, "num_pages": 69, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "total": 69, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Yesterday", "usage_records": [] } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .records \ .yesterday.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/usage/test_record.py000066400000000000000000000115471317472742600270370ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class RecordTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .records.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records?Page=0&PageSize=1", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records?Page=68&PageSize=1", "next_page_uri": null, "num_pages": 69, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "total": 69, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records", "usage_records": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "category": "totalprice", "count": null, "count_unit": "", "description": "Total Price", "end_date": "2015-09-04", "price": "2192.84855", "price_unit": "usd", "start_date": "2011-08-23", "subresource_uris": { "all_time": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/AllTime.json?Category=totalprice", "daily": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Daily.json?Category=totalprice", "last_month": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/LastMonth.json?Category=totalprice", "monthly": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Monthly.json?Category=totalprice", "this_month": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/ThisMonth.json?Category=totalprice", "today": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Today.json?Category=totalprice", "yearly": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Yearly.json?Category=totalprice", "yesterday": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records/Yesterday.json?Category=totalprice" }, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records?Category=totalprice&StartDate=2011-08-23&EndDate=2015-09-04", "usage": "2192.84855", "usage_unit": "usd" } ] } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .records.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records?Page=0&PageSize=1", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records?Page=68&PageSize=1", "next_page_uri": null, "num_pages": 69, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "total": 69, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records", "usage_records": [] } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .records.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/account/usage/test_trigger.py000066400000000000000000000261701317472742600272220ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class TriggerTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .triggers(sid="UTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Triggers/UTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "callback_method": "GET", "callback_url": "http://cap.com/streetfight", "current_value": "0", "date_created": "Sun, 06 Sep 2015 12:58:45 +0000", "date_fired": null, "date_updated": "Sun, 06 Sep 2015 12:58:45 +0000", "friendly_name": "raphael-cluster-1441544325.86", "recurring": "yearly", "sid": "UTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "trigger_by": "price", "trigger_value": "50", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Triggers/UTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "usage_category": "totalprice", "usage_record_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records?Category=totalprice" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .triggers(sid="UTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .triggers(sid="UTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Triggers/UTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "callback_method": "GET", "callback_url": "http://cap.com/streetfight", "current_value": "0", "date_created": "Sun, 06 Sep 2015 12:58:45 +0000", "date_fired": null, "date_updated": "Sun, 06 Sep 2015 12:58:45 +0000", "friendly_name": "raphael-cluster-1441544325.86", "recurring": "yearly", "sid": "UTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "trigger_by": "price", "trigger_value": "50", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Triggers/UTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "usage_category": "totalprice", "usage_record_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records?Category=totalprice" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .triggers(sid="UTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .triggers(sid="UTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Triggers/UTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .triggers(sid="UTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .triggers.create(callback_url="https://example.com", trigger_value="trigger_value", usage_category="answering-machine-detection") values = { 'CallbackUrl': "https://example.com", 'TriggerValue': "trigger_value", 'UsageCategory': "answering-machine-detection", } self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Triggers.json', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "callback_method": "GET", "callback_url": "http://cap.com/streetfight", "current_value": "0", "date_created": "Sun, 06 Sep 2015 12:58:45 +0000", "date_fired": null, "date_updated": "Sun, 06 Sep 2015 12:58:45 +0000", "friendly_name": "raphael-cluster-1441544325.86", "recurring": "yearly", "sid": "UTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "trigger_by": "price", "trigger_value": "50", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Triggers/UTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "usage_category": "totalprice", "usage_record_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records?Category=totalprice" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .triggers.create(callback_url="https://example.com", trigger_value="trigger_value", usage_category="answering-machine-detection") self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .triggers.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Triggers.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Triggers?PageSize=1&Page=0", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Triggers?PageSize=1&Page=626", "next_page_uri": null, "num_pages": 627, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "total": 627, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Triggers", "usage_triggers": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "2010-04-01", "callback_method": "GET", "callback_url": "http://cap.com/streetfight", "current_value": "0", "date_created": "Sun, 06 Sep 2015 12:58:45 +0000", "date_fired": null, "date_updated": "Sun, 06 Sep 2015 12:58:45 +0000", "friendly_name": "raphael-cluster-1441544325.86", "recurring": "yearly", "sid": "UTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "trigger_by": "price", "trigger_value": "50", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Triggers/UTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "usage_category": "totalprice", "usage_record_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Records?Category=totalprice" } ] } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .triggers.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "end": 0, "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Triggers?PageSize=1&Page=0", "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Triggers?PageSize=1&Page=626", "next_page_uri": null, "num_pages": 627, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "total": 627, "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage/Triggers", "usage_triggers": [] } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage \ .triggers.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/api/v2010/test_account.py000066400000000000000000000271431317472742600244540ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class AccountTestCase(IntegrationTestCase): def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts.create() self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts.json', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "auth_token": "AUTHTOKEN", "date_created": "Sun, 15 Mar 2009 02:08:47 +0000", "date_updated": "Wed, 25 Aug 2010 01:30:09 +0000", "friendly_name": "Test Account", "sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "owner_account_sid": "ACbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "status": "active", "subresource_uris": { "available_phone_numbers": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers.json", "calls": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls.json", "conferences": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences.json", "incoming_phone_numbers": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers.json", "notifications": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json", "outgoing_caller_ids": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OutgoingCallerIds.json", "recordings": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json", "sms_messages": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SMS/Messages.json", "transcriptions": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions.json" }, "type": "Full", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts.create() self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "auth_token": "AUTHTOKEN", "date_created": "Sun, 15 Mar 2009 02:08:47 +0000", "date_updated": "Wed, 25 Aug 2010 01:30:09 +0000", "friendly_name": "Test Account", "sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "owner_account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "active", "subresource_uris": { "available_phone_numbers": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers.json", "calls": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls.json", "conferences": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences.json", "incoming_phone_numbers": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers.json", "notifications": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json", "outgoing_caller_ids": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OutgoingCallerIds.json", "recordings": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json", "sms_messages": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SMS/Messages.json", "transcriptions": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions.json" }, "type": "Full", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts.list() self.holodeck.assert_has_request(Request( 'get', 'https://api.twilio.com/2010-04-01/Accounts.json', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "accounts": [ { "auth_token": "foobar", "date_created": "Tue, 23 Aug 2011 20:58:45 +0000", "date_updated": "Fri, 04 Sep 2015 22:53:32 +0000", "friendly_name": "Sub account for testing requests authed with parent account", "owner_account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "active", "subresource_uris": { "applications": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Applications.json", "authorized_connect_apps": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AuthorizedConnectApps.json", "available_phone_numbers": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers.json", "calls": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls.json", "conferences": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences.json", "connect_apps": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ConnectApps.json", "incoming_phone_numbers": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers.json", "media": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media.json", "messages": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages.json", "notifications": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json", "outgoing_caller_ids": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OutgoingCallerIds.json", "queues": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues.json", "recordings": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json", "sip": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SIP.json", "sms_messages": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SMS/Messages.json", "transcriptions": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions.json", "usage": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage.json" }, "type": "Full", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ], "end": 0, "first_page_uri": "/2010-04-01/Accounts.json?PageSize=1&Page=0", "last_page_uri": "/2010-04-01/Accounts.json?PageSize=1&Page=4", "next_page_uri": null, "num_pages": 5, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "total": 5, "uri": "/2010-04-01/Accounts.json?PageSize=1" } ''' )) actual = self.client.api.v2010.accounts.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "accounts": [], "end": 0, "first_page_uri": "/2010-04-01/Accounts.json?PageSize=1&Page=0", "last_page_uri": "/2010-04-01/Accounts.json?PageSize=1&Page=4", "next_page_uri": null, "num_pages": 5, "page": 0, "page_size": 1, "previous_page_uri": null, "start": 0, "total": 5, "uri": "/2010-04-01/Accounts.json?PageSize=1" } ''' )) actual = self.client.api.v2010.accounts.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "auth_token": "AUTHTOKEN", "date_created": "Sun, 15 Mar 2009 02:08:47 +0000", "date_updated": "Wed, 25 Aug 2010 01:30:09 +0000", "friendly_name": "Test Account", "sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "owner_account_sid": "ACbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "status": "active", "subresource_uris": { "available_phone_numbers": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AvailablePhoneNumbers.json", "calls": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls.json", "conferences": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences.json", "incoming_phone_numbers": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers.json", "notifications": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json", "outgoing_caller_ids": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OutgoingCallerIds.json", "recordings": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json", "sms_messages": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SMS/Messages.json", "transcriptions": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions.json" }, "type": "Full", "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } ''' )) actual = self.client.api.v2010.accounts(sid="ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/chat/000077500000000000000000000000001317472742600207765ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/chat/__init__.py000066400000000000000000000001701317472742600231050ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/chat/v1/000077500000000000000000000000001317472742600213245ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/chat/v1/__init__.py000066400000000000000000000001701317472742600234330ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/chat/v1/service/000077500000000000000000000000001317472742600227645ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/chat/v1/service/__init__.py000066400000000000000000000001701317472742600250730ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/chat/v1/service/channel/000077500000000000000000000000001317472742600243745ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/chat/v1/service/channel/__init__.py000066400000000000000000000001701317472742600265030ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/chat/v1/service/channel/test_invite.py000066400000000000000000000206451317472742600273120ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class InviteTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .invites(sid="INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites/INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "identity": "identity", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites/INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .invites(sid="INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .invites.create(identity="identity") values = {'Identity': "identity",} self.holodeck.assert_has_request(Request( 'post', 'https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "identity": "identity", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites/INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .invites.create(identity="identity") self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .invites.list() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "invites": [], "meta": { "first_page_url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites?PageSize=50&Page=0", "key": "invites", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites?PageSize=50&Page=0" } } ''' )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .invites.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "invites": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "identity": "identity", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites/INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "meta": { "first_page_url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites?PageSize=50&Page=0", "key": "invites", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites?PageSize=50&Page=0" } } ''' )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .invites.list() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .invites(sid="INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites/INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .invites(sid="INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) twilio-python-6.8.2/tests/integration/chat/v1/service/channel/test_member.py000066400000000000000000000273021317472742600272600ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class MemberTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members(sid="MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "jing", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "last_consumed_message_index": null, "last_consumption_timestamp": null, "date_created": "2016-03-24T21:05:50Z", "date_updated": "2016-03-24T21:05:50Z", "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members(sid="MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members.create(identity="identity") values = {'Identity': "identity",} self.holodeck.assert_has_request(Request( 'post', 'https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "jing", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "last_consumed_message_index": null, "last_consumption_timestamp": null, "date_created": "2016-03-24T21:05:50Z", "date_updated": "2016-03-24T21:05:50Z", "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members.create(identity="identity") self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members.list() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members?PageSize=50&Page=0", "next_page_url": null, "key": "members" }, "members": [ { "sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "jing", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "last_consumed_message_index": null, "last_consumption_timestamp": null, "date_created": "2016-03-24T21:05:50Z", "date_updated": "2016-03-24T21:05:50Z", "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members?PageSize=50&Page=0", "next_page_url": null, "key": "members" }, "members": [] } ''' )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members.list() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members(sid="MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members(sid="MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members(sid="MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_role_sid_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "jing", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "last_consumed_message_index": null, "last_consumption_timestamp": null, "date_created": "2016-03-24T21:05:50Z", "date_updated": "2016-03-24T21:05:50Z", "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members(sid="MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) def test_update_last_consumed_message_index_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "jing", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "last_consumed_message_index": 666, "last_consumption_timestamp": null, "date_created": "2016-03-24T21:05:50Z", "date_updated": "2016-03-24T21:05:50Z", "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members(sid="MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/chat/v1/service/channel/test_message.py000066400000000000000000000274451317472742600274450ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class MessageTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "to": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-03-24T20:37:57Z", "date_updated": "2016-03-24T20:37:57Z", "was_edited": false, "from": "system", "attributes": "{}", "body": "Hello", "index": 0, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages.create(body="body") values = {'Body': "body",} self.holodeck.assert_has_request(Request( 'post', 'https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "to": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "attributes": null, "date_created": "2016-03-24T20:37:57Z", "date_updated": "2016-03-24T20:37:57Z", "was_edited": false, "from": "system", "body": "Hello", "index": 0, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages.create(body="body") self.assertIsNotNone(actual) def test_create_with_attributes_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "to": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-03-24T20:37:57Z", "date_updated": "2016-03-24T20:37:57Z", "was_edited": false, "from": "system", "attributes": "{}", "body": "Hello", "index": 0, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages.create(body="body") self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages.list() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages?PageSize=50&Page=0", "next_page_url": null, "key": "messages" }, "messages": [ { "sid": "IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "to": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-03-24T20:37:57Z", "date_updated": "2016-03-24T20:37:57Z", "was_edited": false, "from": "system", "attributes": "{}", "body": "Hello", "index": 0, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages?PageSize=50&Page=0", "next_page_url": null, "key": "messages" }, "messages": [] } ''' )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages.list() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "to": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "attributes": "{\\"test\\": \\"test\\"}", "date_created": "2016-03-24T20:37:57Z", "date_updated": "2016-03-24T20:37:57Z", "was_edited": false, "from": "system", "body": "Hello", "index": 0, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/chat/v1/service/test_channel.py000066400000000000000000000263241317472742600260140ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class ChannelTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "unique_name": "unique_name", "attributes": "{ \\"foo\\": \\"bar\\" }", "type": "public", "date_created": "2015-12-16T22:18:37Z", "date_updated": "2015-12-16T22:18:37Z", "created_by": "system", "members_count": 0, "messages_count": 0, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "members": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members", "messages": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages", "invites": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites", "last_message": null } } ''' )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels.create() self.holodeck.assert_has_request(Request( 'post', 'https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "unique_name": "unique_name", "attributes": "{ \\"foo\\": \\"bar\\" }", "type": "public", "date_created": "2015-12-16T22:18:37Z", "date_updated": "2015-12-16T22:18:37Z", "created_by": "system", "members_count": 0, "messages_count": 0, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "members": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members", "messages": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages", "invites": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites", "last_message": null } } ''' )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels.create() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels.list() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "channels": [ { "sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "unique_name": "unique_name", "attributes": "{ \\"foo\\": \\"bar\\" }", "type": "public", "date_created": "2015-12-16T22:18:37Z", "date_updated": "2015-12-16T22:18:37Z", "created_by": "system", "members_count": 0, "messages_count": 0, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "members": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members", "messages": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages", "invites": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites", "last_message": null } } ], "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0", "next_page_url": null, "key": "channels" } } ''' )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "channels": [], "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0", "next_page_url": null, "key": "channels" } } ''' )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "unique_name": "unique_name", "attributes": "{ \\"foo\\": \\"bar\\" }", "type": "public", "date_created": "2015-12-16T22:18:37Z", "date_updated": "2015-12-16T22:18:37Z", "created_by": "system", "members_count": 0, "messages_count": 0, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "members": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members", "messages": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages", "invites": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites", "last_message": null } } ''' )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/chat/v1/service/test_role.py000066400000000000000000000223351317472742600253430ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class RoleTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles(sid="RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "channel user", "type": "channel", "permissions": [ "sendMessage", "leaveChannel", "editOwnMessage", "deleteOwnMessage" ], "date_created": "2016-03-03T19:47:15Z", "date_updated": "2016-03-03T19:47:15Z", "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles(sid="RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles(sid="RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles(sid="RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles.create(friendly_name="friendly_name", type="channel", permission=['permission']) values = {'FriendlyName': "friendly_name", 'Type': "channel", 'Permission': ['permission'],} self.holodeck.assert_has_request(Request( 'post', 'https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "channel user", "type": "channel", "permissions": [ "sendMessage", "leaveChannel", "editOwnMessage", "deleteOwnMessage" ], "date_created": "2016-03-03T19:47:15Z", "date_updated": "2016-03-03T19:47:15Z", "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles.create(friendly_name="friendly_name", type="channel", permission=['permission']) self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles.list() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles?PageSize=50&Page=0", "next_page_url": null, "key": "roles" }, "roles": [ { "sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "channel user", "type": "channel", "permissions": [ "sendMessage", "leaveChannel", "editOwnMessage", "deleteOwnMessage" ], "date_created": "2016-03-03T19:47:15Z", "date_updated": "2016-03-03T19:47:15Z", "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles?PageSize=50&Page=0", "next_page_url": null, "key": "roles" }, "roles": [] } ''' )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles(sid="RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update(permission=['permission']) values = {'Permission': ['permission'],} self.holodeck.assert_has_request(Request( 'post', 'https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', data=values, )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "channel user", "type": "channel", "permissions": [ "sendMessage", "leaveChannel", "editOwnMessage", "deleteOwnMessage" ], "date_created": "2016-03-03T19:47:15Z", "date_updated": "2016-03-03T19:47:15Z", "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles(sid="RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update(permission=['permission']) self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/chat/v1/service/test_user.py000066400000000000000000000234601317472742600253600ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class UserTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "jing", "attributes": null, "is_online": true, "is_notifiable": null, "friendly_name": null, "joined_channels_count": 0, "date_created": "2016-03-24T21:05:19Z", "date_updated": "2016-03-24T21:05:19Z", "links": { "user_channels": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels" }, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users.create(identity="identity") values = {'Identity': "identity",} self.holodeck.assert_has_request(Request( 'post', 'https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "jing", "attributes": null, "is_online": true, "is_notifiable": null, "friendly_name": null, "joined_channels_count": 0, "date_created": "2016-03-24T21:05:19Z", "date_updated": "2016-03-24T21:05:19Z", "links": { "user_channels": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels" }, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users.create(identity="identity") self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users.list() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users?PageSize=50&Page=0", "next_page_url": null, "key": "users" }, "users": [ { "sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "jing", "attributes": null, "is_online": true, "is_notifiable": null, "friendly_name": null, "date_created": "2016-03-24T21:05:19Z", "date_updated": "2016-03-24T21:05:19Z", "joined_channels_count": 0, "links": { "user_channels": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels" }, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users?PageSize=50&Page=0", "next_page_url": null, "key": "users" }, "users": [] } ''' )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "jing", "attributes": null, "is_online": true, "is_notifiable": null, "friendly_name": null, "joined_channels_count": 0, "date_created": "2016-03-24T21:05:19Z", "date_updated": "2016-03-24T21:05:19Z", "links": { "user_channels": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels" }, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/chat/v1/service/user/000077500000000000000000000000001317472742600237425ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/chat/v1/service/user/__init__.py000066400000000000000000000001701317472742600260510ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/chat/v1/service/user/test_user_channel.py000066400000000000000000000075761317472742600300400ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class UserChannelTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .user_channels.list() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0", "next_page_url": null, "key": "channels" }, "channels": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "member_sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "joined", "last_consumed_message_index": 5, "unread_messages_count": 5, "links": { "channel": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "member": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } } ] } ''' )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .user_channels.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0", "next_page_url": null, "key": "channels" }, "channels": [] } ''' )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .user_channels.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/chat/v1/test_credential.py000066400000000000000000000151641317472742600250560ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class CredentialTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.credentials.list() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v1/Credentials', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "credentials": [ { "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Test slow create", "type": "apn", "sandbox": "False", "date_created": "2015-10-07T17:50:01Z", "date_updated": "2015-10-07T17:50:01Z", "url": "https://chat.twilio.com/v1/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "meta": { "page": 0, "page_size": 1, "first_page_url": "https://chat.twilio.com/v1/Credentials?PageSize=1&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v1/Credentials?PageSize=1&Page=0", "next_page_url": null, "key": "credentials" } } ''' )) actual = self.client.chat.v1.credentials.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "credentials": [], "meta": { "page": 0, "page_size": 1, "first_page_url": "https://chat.twilio.com/v1/Credentials?PageSize=1&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v1/Credentials?PageSize=1&Page=0", "next_page_url": null, "key": "credentials" } } ''' )) actual = self.client.chat.v1.credentials.list() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.credentials.create(type="gcm") values = {'Type': "gcm",} self.holodeck.assert_has_request(Request( 'post', 'https://chat.twilio.com/v1/Credentials', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Test slow create", "type": "apn", "sandbox": "False", "date_created": "2015-10-07T17:50:01Z", "date_updated": "2015-10-07T17:50:01Z", "url": "https://chat.twilio.com/v1/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v1.credentials.create(type="gcm") self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.credentials(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v1/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Test slow create", "type": "apn", "sandbox": "False", "date_created": "2015-10-07T17:50:01Z", "date_updated": "2015-10-07T17:50:01Z", "url": "https://chat.twilio.com/v1/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v1.credentials(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.credentials(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://chat.twilio.com/v1/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Test slow create", "type": "apn", "sandbox": "False", "date_created": "2015-10-07T17:50:01Z", "date_updated": "2015-10-07T17:50:01Z", "url": "https://chat.twilio.com/v1/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v1.credentials(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.credentials(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://chat.twilio.com/v1/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.chat.v1.credentials(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) twilio-python-6.8.2/tests/integration/chat/v1/test_service.py000066400000000000000000000241031317472742600243750ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class ServiceTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "consumption_report_interval": 100, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "default_channel_creator_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_channel_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_service_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "limits": { "actions_per_second": 20, "channel_members": 100, "user_channels": 250 }, "links": {}, "notifications": {}, "post_webhook_url": "post_webhook_url", "pre_webhook_url": "pre_webhook_url", "reachability_enabled": false, "read_status_enabled": false, "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "typing_indicator_timeout": 100, "url": "http://www.example.com", "webhook_filters": [ "webhook_filters" ], "webhook_method": "webhook_method", "webhooks": {} } ''' )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.services.create(friendly_name="friendly_name") values = {'FriendlyName': "friendly_name",} self.holodeck.assert_has_request(Request( 'post', 'https://chat.twilio.com/v1/Services', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "consumption_report_interval": 100, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "default_channel_creator_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_channel_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_service_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "limits": { "actions_per_second": 20, "channel_members": 100, "user_channels": 250 }, "links": {}, "notifications": {}, "post_webhook_url": "post_webhook_url", "pre_webhook_url": "pre_webhook_url", "reachability_enabled": false, "read_status_enabled": false, "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "typing_indicator_timeout": 100, "url": "http://www.example.com", "webhook_filters": [ "webhook_filters" ], "webhook_method": "webhook_method", "webhooks": {} } ''' )) actual = self.client.chat.v1.services.create(friendly_name="friendly_name") self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.services.list() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v1/Services', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://chat.twilio.com/v1/Services?Page=0&PageSize=50", "key": "services", "next_page_url": null, "page": 0, "page_size": 0, "previous_page_url": null, "url": "https://chat.twilio.com/v1/Services" }, "services": [] } ''' )) actual = self.client.chat.v1.services.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://chat.twilio.com/v1/Services?Page=0&PageSize=50", "key": "services", "next_page_url": null, "page": 0, "page_size": 1, "previous_page_url": null, "url": "https://chat.twilio.com/v1/Services" }, "services": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "consumption_report_interval": 100, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "default_channel_creator_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_channel_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_service_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "limits": { "actions_per_second": 20, "channel_members": 100, "user_channels": 250 }, "links": {}, "notifications": {}, "post_webhook_url": "post_webhook_url", "pre_webhook_url": "pre_webhook_url", "reachability_enabled": false, "read_status_enabled": false, "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "typing_indicator_timeout": 100, "url": "http://www.example.com", "webhook_filters": [ "webhook_filters" ], "webhook_method": "webhook_method", "webhooks": {} } ] } ''' )) actual = self.client.chat.v1.services.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "consumption_report_interval": 100, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "default_channel_creator_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_channel_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_service_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "limits": { "actions_per_second": 20, "channel_members": 500, "user_channels": 600 }, "links": {}, "notifications": {}, "post_webhook_url": "post_webhook_url", "pre_webhook_url": "pre_webhook_url", "reachability_enabled": false, "read_status_enabled": false, "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "typing_indicator_timeout": 100, "url": "http://www.example.com", "webhook_filters": [ "webhook_filters" ], "webhook_method": "webhook_method", "webhooks": {} } ''' )) actual = self.client.chat.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/chat/v2/000077500000000000000000000000001317472742600213255ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/chat/v2/__init__.py000066400000000000000000000001701317472742600234340ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/chat/v2/service/000077500000000000000000000000001317472742600227655ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/chat/v2/service/__init__.py000066400000000000000000000001701317472742600250740ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/chat/v2/service/channel/000077500000000000000000000000001317472742600243755ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/chat/v2/service/channel/__init__.py000066400000000000000000000001701317472742600265040ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/chat/v2/service/channel/test_invite.py000066400000000000000000000206451317472742600273130ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class InviteTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .invites(sid="INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites/INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "identity": "identity", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites/INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .invites(sid="INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .invites.create(identity="identity") values = {'Identity': "identity",} self.holodeck.assert_has_request(Request( 'post', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "identity": "identity", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites/INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .invites.create(identity="identity") self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .invites.list() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "invites": [], "meta": { "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites?PageSize=50&Page=0", "key": "invites", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites?PageSize=50&Page=0" } } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .invites.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "invites": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "identity": "identity", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites/INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "meta": { "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites?PageSize=50&Page=0", "key": "invites", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites?PageSize=50&Page=0" } } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .invites.list() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .invites(sid="INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites/INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .invites(sid="INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) twilio-python-6.8.2/tests/integration/chat/v2/service/channel/test_member.py000066400000000000000000000247301317472742600272630ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class MemberTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members(sid="MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "jing", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "last_consumed_message_index": null, "last_consumption_timestamp": null, "date_created": "2016-03-24T21:05:50Z", "date_updated": "2016-03-24T21:05:50Z", "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members(sid="MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members.create(identity="identity") values = {'Identity': "identity",} self.holodeck.assert_has_request(Request( 'post', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "jing", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "last_consumed_message_index": null, "last_consumption_timestamp": null, "date_created": "2016-03-24T21:05:50Z", "date_updated": "2016-03-24T21:05:50Z", "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members.create(identity="identity") self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members.list() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members?PageSize=50&Page=0", "next_page_url": null, "key": "members" }, "members": [ { "sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "jing", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "last_consumed_message_index": null, "last_consumption_timestamp": null, "date_created": "2016-03-24T21:05:50Z", "date_updated": "2016-03-24T21:05:50Z", "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members?PageSize=50&Page=0", "next_page_url": null, "key": "members" }, "members": [] } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members.list() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members(sid="MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members(sid="MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members(sid="MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_role_sid_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "jing", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "last_consumed_message_index": 20, "last_consumption_timestamp": "2016-03-24T21:05:52Z", "date_created": "2016-03-24T21:05:50Z", "date_updated": "2016-03-24T21:05:51Z", "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members(sid="MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/chat/v2/service/channel/test_message.py000066400000000000000000000412301317472742600274320ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class MessageTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "to": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-03-24T20:37:57Z", "date_updated": "2016-03-24T20:37:57Z", "last_updated_by": null, "was_edited": false, "from": "system", "attributes": "{}", "body": "Hello", "index": 0, "type": "text", "media": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_fetch_media_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "to": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-03-24T20:37:57Z", "date_updated": "2016-03-24T20:37:57Z", "last_updated_by": null, "was_edited": false, "from": "system", "attributes": "{}", "body": "Hello", "index": 0, "type": "media", "media": { "sid": "MEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "size": 99999999999999, "content_type": "application/pdf", "filename": "hello.pdf" }, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages.create() self.holodeck.assert_has_request(Request( 'post', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "to": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "attributes": null, "date_created": "2016-03-24T20:37:57Z", "date_updated": "2016-03-24T20:37:57Z", "last_updated_by": "system", "was_edited": false, "from": "system", "body": "Hello", "index": 0, "type": "text", "media": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages.create() self.assertIsNotNone(actual) def test_create_with_all_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "to": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-12-16T22:18:37Z", "date_updated": "2015-12-16T22:18:38Z", "last_updated_by": "username", "was_edited": true, "from": "system", "attributes": "{\\"test\\": \\"test\\"}", "body": "Hello", "index": 0, "type": "text", "media": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages.create() self.assertIsNotNone(actual) def test_create_media_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "to": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "attributes": null, "date_created": "2016-03-24T20:37:57Z", "date_updated": "2016-03-24T20:37:57Z", "last_updated_by": "system", "was_edited": false, "from": "system", "body": "Hello", "index": 0, "type": "text", "media": { "sid": "MEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "size": 99999999999999, "content_type": "application/pdf", "filename": "hello.pdf" }, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages.create() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages.list() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages?PageSize=50&Page=0", "next_page_url": null, "key": "messages" }, "messages": [ { "sid": "IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "to": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-03-24T20:37:57Z", "date_updated": "2016-03-24T20:37:57Z", "last_updated_by": null, "was_edited": false, "from": "system", "attributes": "{}", "body": "Hello", "index": 0, "type": "text", "media": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, { "sid": "IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "to": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-03-24T20:37:57Z", "date_updated": "2016-03-24T20:37:57Z", "last_updated_by": null, "was_edited": false, "from": "system", "attributes": "{}", "body": "Hello", "index": 0, "type": "media", "media": { "sid": "MEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "size": 99999999999999, "content_type": "application/pdf", "filename": "hello.pdf" }, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages?PageSize=50&Page=0", "next_page_url": null, "key": "messages" }, "messages": [] } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages.list() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "to": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "attributes": "{ \\"foo\\": \\"bar\\" }", "date_created": "2015-12-16T22:18:37Z", "date_updated": "2015-12-16T22:18:38Z", "last_updated_by": "username", "was_edited": true, "from": "system", "body": "Hello", "index": 0, "type": "text", "media": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/chat/v2/service/test_binding.py000066400000000000000000000146671317472742600260260ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class BindingTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings.list() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings?PageSize=50&Page=0", "next_page_url": null, "key": "bindings" }, "bindings": [ { "sid": "BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-10-21T11:37:03Z", "date_updated": "2016-10-21T11:37:03Z", "endpoint": "TestUser-endpoint", "identity": "TestUser", "binding_type": "gcm", "credential_sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "message_types": [ "removed_from_channel", "new_message", "added_to_channel", "invited_to_channel" ], "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "user": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/TestUser" } } ] } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings?PageSize=50&Page=0", "next_page_url": null, "key": "bindings" }, "bindings": [] } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings.list() self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings(sid="BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-10-21T11:37:03Z", "date_updated": "2016-10-21T11:37:03Z", "endpoint": "TestUser-endpoint", "identity": "TestUser", "binding_type": "gcm", "credential_sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "message_types": [ "removed_from_channel", "new_message", "added_to_channel", "invited_to_channel" ], "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "user": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/TestUser" } } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings(sid="BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings(sid="BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings(sid="BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) twilio-python-6.8.2/tests/integration/chat/v2/service/test_channel.py000066400000000000000000000263301317472742600260120ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class ChannelTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "unique_name": "unique_name", "attributes": "{ \\"foo\\": \\"bar\\" }", "type": "public", "date_created": "2015-12-16T22:18:37Z", "date_updated": "2015-12-16T22:18:37Z", "created_by": "system", "members_count": 0, "messages_count": 0, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "members": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members", "messages": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages", "invites": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites", "last_message": null } } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels.create() self.holodeck.assert_has_request(Request( 'post', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "unique_name": "unique_name", "attributes": "{ \\"foo\\": \\"bar\\" }", "type": "public", "date_created": "2015-12-16T22:18:37Z", "date_updated": "2015-12-16T22:18:38Z", "created_by": "username", "members_count": 0, "messages_count": 0, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "members": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members", "messages": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages", "invites": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites", "last_message": null } } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels.create() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels.list() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "channels": [ { "sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "unique_name": "unique_name", "attributes": "{ \\"foo\\": \\"bar\\" }", "type": "public", "date_created": "2015-12-16T22:18:37Z", "date_updated": "2015-12-16T22:18:37Z", "created_by": "system", "members_count": 0, "messages_count": 0, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "members": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members", "messages": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages", "invites": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites", "last_message": null } } ], "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0", "next_page_url": null, "key": "channels" } } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "channels": [], "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0", "next_page_url": null, "key": "channels" } } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "unique_name": "unique_name", "attributes": "{ \\"foo\\": \\"bar\\" }", "type": "public", "date_created": "2015-12-16T22:18:37Z", "date_updated": "2015-12-16T22:18:38Z", "created_by": "username", "members_count": 0, "messages_count": 0, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "members": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members", "messages": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages", "invites": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites", "last_message": null } } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/chat/v2/service/test_role.py000066400000000000000000000223351317472742600253440ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class RoleTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles(sid="RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "channel user", "type": "channel", "permissions": [ "sendMessage", "leaveChannel", "editOwnMessage", "deleteOwnMessage" ], "date_created": "2016-03-03T19:47:15Z", "date_updated": "2016-03-03T19:47:15Z", "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles(sid="RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles(sid="RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles(sid="RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles.create(friendly_name="friendly_name", type="channel", permission=['permission']) values = {'FriendlyName': "friendly_name", 'Type': "channel", 'Permission': ['permission'],} self.holodeck.assert_has_request(Request( 'post', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "channel user", "type": "channel", "permissions": [ "sendMessage", "leaveChannel", "editOwnMessage", "deleteOwnMessage" ], "date_created": "2016-03-03T19:47:15Z", "date_updated": "2016-03-03T19:47:15Z", "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles.create(friendly_name="friendly_name", type="channel", permission=['permission']) self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles.list() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles?PageSize=50&Page=0", "next_page_url": null, "key": "roles" }, "roles": [ { "sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "channel user", "type": "channel", "permissions": [ "sendMessage", "leaveChannel", "editOwnMessage", "deleteOwnMessage" ], "date_created": "2016-03-03T19:47:15Z", "date_updated": "2016-03-03T19:47:15Z", "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles?PageSize=50&Page=0", "next_page_url": null, "key": "roles" }, "roles": [] } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles(sid="RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update(permission=['permission']) values = {'Permission': ['permission'],} self.holodeck.assert_has_request(Request( 'post', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', data=values, )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "channel user", "type": "channel", "permissions": [ "sendMessage", "leaveChannel", "editOwnMessage", "deleteOwnMessage" ], "date_created": "2016-03-03T19:47:15Z", "date_updated": "2016-03-03T19:47:15Z", "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles(sid="RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update(permission=['permission']) self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/chat/v2/service/test_user.py000066400000000000000000000246741317472742600253710ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class UserTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "jing", "attributes": null, "is_online": true, "is_notifiable": null, "friendly_name": null, "joined_channels_count": 0, "date_created": "2016-03-24T21:05:19Z", "date_updated": "2016-03-24T21:05:19Z", "links": { "user_channels": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels", "user_bindings": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings" }, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users.create(identity="identity") values = {'Identity': "identity",} self.holodeck.assert_has_request(Request( 'post', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "jing", "attributes": null, "is_online": true, "is_notifiable": null, "friendly_name": null, "joined_channels_count": 0, "date_created": "2016-03-24T21:05:19Z", "date_updated": "2016-03-24T21:05:19Z", "links": { "user_channels": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels", "user_bindings": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings" }, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users.create(identity="identity") self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users.list() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users?PageSize=50&Page=0", "next_page_url": null, "key": "users" }, "users": [ { "sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "jing", "attributes": null, "is_online": true, "is_notifiable": null, "friendly_name": null, "date_created": "2016-03-24T21:05:19Z", "date_updated": "2016-03-24T21:05:19Z", "joined_channels_count": 0, "links": { "user_channels": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels", "user_bindings": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings" }, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users?PageSize=50&Page=0", "next_page_url": null, "key": "users" }, "users": [] } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "jing", "attributes": null, "is_online": true, "is_notifiable": null, "friendly_name": null, "joined_channels_count": 0, "date_created": "2016-03-24T21:05:19Z", "date_updated": "2016-03-24T21:05:19Z", "links": { "user_channels": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels", "user_bindings": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings" }, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/chat/v2/service/user/000077500000000000000000000000001317472742600237435ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/chat/v2/service/user/__init__.py000066400000000000000000000001701317472742600260520ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/chat/v2/service/user/test_user_binding.py000066400000000000000000000163211317472742600300270ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class UserBindingTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .user_bindings.list() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings?PageSize=50&Page=0", "next_page_url": null, "key": "bindings" }, "bindings": [ { "sid": "BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-10-21T11:37:03Z", "date_updated": "2016-10-21T11:37:03Z", "endpoint": "TestUser-endpoint", "identity": "TestUser", "user_sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "binding_type": "gcm", "credential_sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "message_types": [ "removed_from_channel", "new_message", "added_to_channel", "invited_to_channel" ], "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .user_bindings.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings?PageSize=50&Page=0", "next_page_url": null, "key": "bindings" }, "bindings": [] } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .user_bindings.list() self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .user_bindings(sid="BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-10-21T11:37:03Z", "date_updated": "2016-10-21T11:37:03Z", "endpoint": "TestUser-endpoint", "identity": "TestUser", "user_sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "binding_type": "gcm", "credential_sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "message_types": [ "removed_from_channel", "new_message", "added_to_channel", "invited_to_channel" ], "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .user_bindings(sid="BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .user_bindings(sid="BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .user_bindings(sid="BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) twilio-python-6.8.2/tests/integration/chat/v2/service/user/test_user_channel.py000066400000000000000000000075761317472742600300410ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class UserChannelTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .user_channels.list() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0", "next_page_url": null, "key": "channels" }, "channels": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "member_sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "joined", "last_consumed_message_index": 5, "unread_messages_count": 5, "links": { "channel": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "member": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } } ] } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .user_channels.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0", "next_page_url": null, "key": "channels" }, "channels": [] } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .user_channels.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/chat/v2/test_credential.py000066400000000000000000000151641317472742600250570ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class CredentialTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.credentials.list() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v2/Credentials', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "credentials": [ { "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Test slow create", "type": "apn", "sandbox": "False", "date_created": "2015-10-07T17:50:01Z", "date_updated": "2015-10-07T17:50:01Z", "url": "https://chat.twilio.com/v2/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "meta": { "page": 0, "page_size": 1, "first_page_url": "https://chat.twilio.com/v2/Credentials?PageSize=1&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Credentials?PageSize=1&Page=0", "next_page_url": null, "key": "credentials" } } ''' )) actual = self.client.chat.v2.credentials.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "credentials": [], "meta": { "page": 0, "page_size": 1, "first_page_url": "https://chat.twilio.com/v2/Credentials?PageSize=1&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Credentials?PageSize=1&Page=0", "next_page_url": null, "key": "credentials" } } ''' )) actual = self.client.chat.v2.credentials.list() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.credentials.create(type="gcm") values = {'Type': "gcm",} self.holodeck.assert_has_request(Request( 'post', 'https://chat.twilio.com/v2/Credentials', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Test slow create", "type": "apn", "sandbox": "False", "date_created": "2015-10-07T17:50:01Z", "date_updated": "2015-10-07T17:50:01Z", "url": "https://chat.twilio.com/v2/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v2.credentials.create(type="gcm") self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.credentials(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v2/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Test slow create", "type": "apn", "sandbox": "False", "date_created": "2015-10-07T17:50:01Z", "date_updated": "2015-10-07T17:50:01Z", "url": "https://chat.twilio.com/v2/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v2.credentials(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.credentials(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://chat.twilio.com/v2/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Test slow create", "type": "apn", "sandbox": "False", "date_created": "2015-10-07T17:50:01Z", "date_updated": "2015-10-07T17:50:01Z", "url": "https://chat.twilio.com/v2/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.chat.v2.credentials(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.credentials(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://chat.twilio.com/v2/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.chat.v2.credentials(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) twilio-python-6.8.2/tests/integration/chat/v2/test_service.py000066400000000000000000000332521317472742600244030ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class ServiceTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "consumption_report_interval": 100, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "default_channel_creator_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_channel_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_service_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "limits": { "channel_members": 100, "user_channels": 250 }, "links": { "channels": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels", "users": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users", "roles": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles", "bindings": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings" }, "notifications": {}, "post_webhook_url": "post_webhook_url", "pre_webhook_url": "pre_webhook_url", "pre_webhook_retry_count": 2, "post_webhook_retry_count": 3, "reachability_enabled": false, "read_status_enabled": false, "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "typing_indicator_timeout": 100, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "webhook_filters": [ "webhook_filters" ], "webhook_method": "webhook_method", "media": { "size_limit_mb": 150, "compatibility_message": "media compatibility message" } } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services.create(friendly_name="friendly_name") values = {'FriendlyName': "friendly_name",} self.holodeck.assert_has_request(Request( 'post', 'https://chat.twilio.com/v2/Services', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "consumption_report_interval": 100, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "default_channel_creator_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_channel_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_service_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "limits": { "channel_members": 100, "user_channels": 250 }, "links": { "channels": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels", "users": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users", "roles": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles", "bindings": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings" }, "notifications": {}, "post_webhook_url": "post_webhook_url", "pre_webhook_url": "pre_webhook_url", "pre_webhook_retry_count": 2, "post_webhook_retry_count": 3, "reachability_enabled": false, "read_status_enabled": false, "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "typing_indicator_timeout": 100, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "webhook_filters": [ "webhook_filters" ], "webhook_method": "webhook_method", "media": { "size_limit_mb": 150, "compatibility_message": "media compatibility message" } } ''' )) actual = self.client.chat.v2.services.create(friendly_name="friendly_name") self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services.list() self.holodeck.assert_has_request(Request( 'get', 'https://chat.twilio.com/v2/Services', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://chat.twilio.com/v2/Services?PageSize=50&Page=0", "key": "services", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services?PageSize=50&Page=0" }, "services": [] } ''' )) actual = self.client.chat.v2.services.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://chat.twilio.com/v2/Services?PageSize=50&Page=0", "key": "services", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services?PageSize=50&Page=0" }, "services": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "consumption_report_interval": 100, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "default_channel_creator_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_channel_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_service_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "limits": { "channel_members": 100, "user_channels": 250 }, "links": { "channels": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels", "users": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users", "roles": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles", "bindings": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings" }, "notifications": {}, "post_webhook_url": "post_webhook_url", "pre_webhook_url": "pre_webhook_url", "pre_webhook_retry_count": 2, "post_webhook_retry_count": 3, "reachability_enabled": false, "read_status_enabled": false, "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "typing_indicator_timeout": 100, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "webhook_filters": [ "webhook_filters" ], "webhook_method": "webhook_method", "media": { "size_limit_mb": 150, "compatibility_message": "media compatibility message" } } ] } ''' )) actual = self.client.chat.v2.services.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "consumption_report_interval": 100, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "default_channel_creator_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_channel_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_service_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "limits": { "channel_members": 500, "user_channels": 600 }, "links": { "channels": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels", "users": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users", "roles": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles", "bindings": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings" }, "notifications": { "added_to_channel": { "enabled": false, "template": "notifications.added_to_channel.template" }, "invited_to_channel": { "enabled": false, "template": "notifications.invited_to_channel.template" }, "new_message": { "enabled": false, "template": "notifications.new_message.template", "badge_count_enabled": true }, "removed_from_channel": { "enabled": false, "template": "notifications.removed_from_channel.template" } }, "post_webhook_url": "post_webhook_url", "pre_webhook_url": "pre_webhook_url", "pre_webhook_retry_count": 2, "post_webhook_retry_count": 3, "reachability_enabled": false, "read_status_enabled": false, "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "typing_indicator_timeout": 100, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "webhook_filters": [ "webhook_filters" ], "webhook_method": "webhook_method", "media": { "size_limit_mb": 150, "compatibility_message": "new media compatibility message" } } ''' )) actual = self.client.chat.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/fax/000077500000000000000000000000001317472742600206355ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/fax/__init__.py000066400000000000000000000001701317472742600227440ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/fax/v1/000077500000000000000000000000001317472742600211635ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/fax/v1/__init__.py000066400000000000000000000001701317472742600232720ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/fax/v1/fax/000077500000000000000000000000001317472742600217415ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/fax/v1/fax/__init__.py000066400000000000000000000001701317472742600240500ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/fax/v1/fax/test_fax_media.py000066400000000000000000000105211317472742600252660ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class FaxMediaTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.fax.v1.faxes(sid="FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .media(sid="MEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://fax.twilio.com/v1/Faxes/FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media/MEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "content_type": "application/pdf", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "fax_sid": "FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "MEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://fax.twilio.com/v1/Faxes/FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media/MEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.fax.v1.faxes(sid="FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .media(sid="MEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.fax.v1.faxes(sid="FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .media.list() self.holodeck.assert_has_request(Request( 'get', 'https://fax.twilio.com/v1/Faxes/FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media', )) def test_read_response(self): self.holodeck.mock(Response( 200, ''' { "media": [ { "sid": "MEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "fax_sid": "FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "content_type": "application/pdf", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "url": "https://fax.twilio.com/v1/Faxes/FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media/MEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "meta": { "first_page_url": "https://fax.twilio.com/v1/Faxes/FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media?PageSize=50&Page=0", "key": "media", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://fax.twilio.com/v1/Faxes/FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media?PageSize=50&Page=0" } } ''' )) actual = self.client.fax.v1.faxes(sid="FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .media.list() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.fax.v1.faxes(sid="FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .media(sid="MEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://fax.twilio.com/v1/Faxes/FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media/MEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.fax.v1.faxes(sid="FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .media(sid="MEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) twilio-python-6.8.2/tests/integration/fax/v1/test_fax.py000066400000000000000000000210461317472742600233550ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class FaxTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.fax.v1.faxes(sid="FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://fax.twilio.com/v1/Faxes/FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "v1", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "direction": "outbound", "from": "+14155551234", "media_url": "https://www.example.com/fax.pdf", "media_sid": "MEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "num_pages": null, "price": null, "price_unit": null, "quality": null, "sid": "FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "queued", "to": "+14155554321", "duration": null, "links": { "media": "https://fax.twilio.com/v1/Faxes/FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media" }, "url": "https://fax.twilio.com/v1/Faxes/FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.fax.v1.faxes(sid="FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.fax.v1.faxes.list() self.holodeck.assert_has_request(Request( 'get', 'https://fax.twilio.com/v1/Faxes', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "faxes": [], "meta": { "first_page_url": "https://fax.twilio.com/v1/Faxes?PageSize=50&Page=0", "key": "faxes", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://fax.twilio.com/v1/Faxes?PageSize=50&Page=0" } } ''' )) actual = self.client.fax.v1.faxes.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "faxes": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "v1", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "direction": "outbound", "from": "+14155551234", "media_url": "https://www.example.com/fax.pdf", "media_sid": "MEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "num_pages": null, "price": null, "price_unit": null, "quality": null, "sid": "FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "queued", "to": "+14155554321", "duration": null, "links": { "media": "https://fax.twilio.com/v1/Faxes/FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media" }, "url": "https://fax.twilio.com/v1/Faxes/FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "meta": { "first_page_url": "https://fax.twilio.com/v1/Faxes?PageSize=50&Page=0", "key": "faxes", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://fax.twilio.com/v1/Faxes?PageSize=50&Page=0" } } ''' )) actual = self.client.fax.v1.faxes.list() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.fax.v1.faxes.create(to="to", media_url="https://example.com") values = {'To': "to", 'MediaUrl': "https://example.com",} self.holodeck.assert_has_request(Request( 'post', 'https://fax.twilio.com/v1/Faxes', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "v1", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "direction": "outbound", "from": "+14155551234", "media_url": null, "media_sid": null, "num_pages": null, "price": null, "price_unit": null, "quality": "superfine", "sid": "FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "queued", "to": "+14155554321", "duration": null, "links": { "media": "https://fax.twilio.com/v1/Faxes/FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media" }, "url": "https://fax.twilio.com/v1/Faxes/FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.fax.v1.faxes.create(to="to", media_url="https://example.com") self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.fax.v1.faxes(sid="FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://fax.twilio.com/v1/Faxes/FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "api_version": "v1", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "direction": "outbound", "from": "+14155551234", "media_url": null, "media_sid": null, "num_pages": null, "price": null, "price_unit": null, "quality": null, "sid": "FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "canceled", "to": "+14155554321", "duration": null, "links": { "media": "https://fax.twilio.com/v1/Faxes/FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media" }, "url": "https://fax.twilio.com/v1/Faxes/FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.fax.v1.faxes(sid="FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.fax.v1.faxes(sid="FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://fax.twilio.com/v1/Faxes/FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.fax.v1.faxes(sid="FXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) twilio-python-6.8.2/tests/integration/ip_messaging/000077500000000000000000000000001317472742600225245ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/ip_messaging/__init__.py000066400000000000000000000001701317472742600246330ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/ip_messaging/v1/000077500000000000000000000000001317472742600230525ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/ip_messaging/v1/__init__.py000066400000000000000000000001701317472742600251610ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/ip_messaging/v1/service/000077500000000000000000000000001317472742600245125ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/ip_messaging/v1/service/__init__.py000066400000000000000000000001701317472742600266210ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/ip_messaging/v1/service/channel/000077500000000000000000000000001317472742600261225ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/ip_messaging/v1/service/channel/__init__.py000066400000000000000000000001701317472742600302310ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/ip_messaging/v1/service/channel/test_invite.py000066400000000000000000000212351317472742600310340ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class InviteTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .invites(sid="INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites/INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "identity": "identity", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites/INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .invites(sid="INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .invites.create(identity="identity") values = {'Identity': "identity",} self.holodeck.assert_has_request(Request( 'post', 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "identity": "identity", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites/INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .invites.create(identity="identity") self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .invites.list() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "invites": [], "meta": { "first_page_url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites?PageSize=50&Page=0", "key": "invites", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites?PageSize=50&Page=0" } } ''' )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .invites.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "invites": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "identity": "identity", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites/INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "meta": { "first_page_url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites?PageSize=50&Page=0", "key": "invites", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites?PageSize=50&Page=0" } } ''' )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .invites.list() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .invites(sid="INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites/INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .invites(sid="INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) twilio-python-6.8.2/tests/integration/ip_messaging/v1/service/channel/test_member.py000066400000000000000000000300121317472742600307760ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class MemberTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members(sid="MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "jing", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "last_consumed_message_index": null, "last_consumption_timestamp": null, "date_created": "2016-03-24T21:05:50Z", "date_updated": "2016-03-24T21:05:50Z", "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members(sid="MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members.create(identity="identity") values = {'Identity': "identity",} self.holodeck.assert_has_request(Request( 'post', 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "jing", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "last_consumed_message_index": null, "last_consumption_timestamp": null, "date_created": "2016-03-24T21:05:50Z", "date_updated": "2016-03-24T21:05:50Z", "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members.create(identity="identity") self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members.list() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members?PageSize=50&Page=0", "next_page_url": null, "key": "members" }, "members": [ { "sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "jing", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "last_consumed_message_index": null, "last_consumption_timestamp": null, "date_created": "2016-03-24T21:05:50Z", "date_updated": "2016-03-24T21:05:50Z", "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members?PageSize=50&Page=0", "next_page_url": null, "key": "members" }, "members": [] } ''' )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members.list() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members(sid="MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members(sid="MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members(sid="MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_role_sid_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "jing", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "last_consumed_message_index": null, "last_consumption_timestamp": null, "date_created": "2016-03-24T21:05:50Z", "date_updated": "2016-03-24T21:05:50Z", "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members(sid="MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) def test_update_last_consumed_message_index_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "jing", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "last_consumed_message_index": 666, "last_consumption_timestamp": null, "date_created": "2016-03-24T21:05:50Z", "date_updated": "2016-03-24T21:05:50Z", "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members(sid="MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/ip_messaging/v1/service/channel/test_message.py000066400000000000000000000301551317472742600311630ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class MessageTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "to": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-03-24T20:37:57Z", "date_updated": "2016-03-24T20:37:57Z", "was_edited": false, "from": "system", "attributes": "{}", "body": "Hello", "index": 0, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages.create(body="body") values = {'Body': "body",} self.holodeck.assert_has_request(Request( 'post', 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "to": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "attributes": null, "date_created": "2016-03-24T20:37:57Z", "date_updated": "2016-03-24T20:37:57Z", "was_edited": false, "from": "system", "body": "Hello", "index": 0, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages.create(body="body") self.assertIsNotNone(actual) def test_create_with_attributes_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "to": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-03-24T20:37:57Z", "date_updated": "2016-03-24T20:37:57Z", "was_edited": false, "from": "system", "attributes": "{}", "body": "Hello", "index": 0, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages.create(body="body") self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages.list() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages?PageSize=50&Page=0", "next_page_url": null, "key": "messages" }, "messages": [ { "sid": "IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "to": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-03-24T20:37:57Z", "date_updated": "2016-03-24T20:37:57Z", "was_edited": false, "from": "system", "attributes": "{}", "body": "Hello", "index": 0, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages?PageSize=50&Page=0", "next_page_url": null, "key": "messages" }, "messages": [] } ''' )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages.list() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "to": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "attributes": "{\\"test\\": \\"test\\"}", "date_created": "2016-03-24T20:37:57Z", "date_updated": "2016-03-24T20:37:57Z", "was_edited": false, "from": "system", "body": "Hello", "index": 0, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/ip_messaging/v1/service/test_channel.py000066400000000000000000000266541317472742600275500ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class ChannelTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "unique_name": "unique_name", "attributes": "{ \\"foo\\": \\"bar\\" }", "type": "public", "date_created": "2015-12-16T22:18:37Z", "date_updated": "2015-12-16T22:18:37Z", "created_by": "system", "members_count": 0, "messages_count": 0, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "members": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members", "messages": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages", "invites": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites", "last_message": null } } ''' )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels.create() self.holodeck.assert_has_request(Request( 'post', 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "unique_name": "unique_name", "attributes": "{ \\"foo\\": \\"bar\\" }", "type": "public", "date_created": "2015-12-16T22:18:37Z", "date_updated": "2015-12-16T22:18:37Z", "created_by": "system", "members_count": 0, "messages_count": 0, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "members": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members", "messages": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages", "invites": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites", "last_message": null } } ''' )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels.create() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels.list() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "channels": [ { "sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "unique_name": "unique_name", "attributes": "{ \\"foo\\": \\"bar\\" }", "type": "public", "date_created": "2015-12-16T22:18:37Z", "date_updated": "2015-12-16T22:18:37Z", "created_by": "system", "members_count": 0, "messages_count": 0, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "members": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members", "messages": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages", "invites": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites", "last_message": null } } ], "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0", "next_page_url": null, "key": "channels" } } ''' )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "channels": [], "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0", "next_page_url": null, "key": "channels" } } ''' )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "unique_name": "unique_name", "attributes": "{ \\"foo\\": \\"bar\\" }", "type": "public", "date_created": "2015-12-16T22:18:37Z", "date_updated": "2015-12-16T22:18:37Z", "created_by": "system", "members_count": 0, "messages_count": 0, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "members": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members", "messages": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages", "invites": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites", "last_message": null } } ''' )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/ip_messaging/v1/service/test_role.py000066400000000000000000000226651317472742600270770ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class RoleTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles(sid="RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "channel user", "type": "channel", "permissions": [ "sendMessage", "leaveChannel", "editOwnMessage", "deleteOwnMessage" ], "date_created": "2016-03-03T19:47:15Z", "date_updated": "2016-03-03T19:47:15Z", "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles(sid="RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles(sid="RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles(sid="RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles.create(friendly_name="friendly_name", type="channel", permission=['permission']) values = {'FriendlyName': "friendly_name", 'Type': "channel", 'Permission': ['permission'],} self.holodeck.assert_has_request(Request( 'post', 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "channel user", "type": "channel", "permissions": [ "sendMessage", "leaveChannel", "editOwnMessage", "deleteOwnMessage" ], "date_created": "2016-03-03T19:47:15Z", "date_updated": "2016-03-03T19:47:15Z", "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles.create(friendly_name="friendly_name", type="channel", permission=['permission']) self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles.list() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles?PageSize=50&Page=0", "next_page_url": null, "key": "roles" }, "roles": [ { "sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "channel user", "type": "channel", "permissions": [ "sendMessage", "leaveChannel", "editOwnMessage", "deleteOwnMessage" ], "date_created": "2016-03-03T19:47:15Z", "date_updated": "2016-03-03T19:47:15Z", "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles?PageSize=50&Page=0", "next_page_url": null, "key": "roles" }, "roles": [] } ''' )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles(sid="RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update(permission=['permission']) values = {'Permission': ['permission'],} self.holodeck.assert_has_request(Request( 'post', 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', data=values, )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "channel user", "type": "channel", "permissions": [ "sendMessage", "leaveChannel", "editOwnMessage", "deleteOwnMessage" ], "date_created": "2016-03-03T19:47:15Z", "date_updated": "2016-03-03T19:47:15Z", "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles(sid="RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update(permission=['permission']) self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/ip_messaging/v1/service/test_user.py000066400000000000000000000240101317472742600270760ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class UserTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "jing", "attributes": null, "is_online": true, "is_notifiable": null, "friendly_name": null, "joined_channels_count": 0, "date_created": "2016-03-24T21:05:19Z", "date_updated": "2016-03-24T21:05:19Z", "links": { "user_channels": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels" }, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users.create(identity="identity") values = {'Identity': "identity",} self.holodeck.assert_has_request(Request( 'post', 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "jing", "attributes": null, "is_online": true, "is_notifiable": null, "friendly_name": null, "joined_channels_count": 0, "date_created": "2016-03-24T21:05:19Z", "date_updated": "2016-03-24T21:05:19Z", "links": { "user_channels": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels" }, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users.create(identity="identity") self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users.list() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users?PageSize=50&Page=0", "next_page_url": null, "key": "users" }, "users": [ { "sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "jing", "attributes": null, "is_online": true, "is_notifiable": null, "friendly_name": null, "date_created": "2016-03-24T21:05:19Z", "date_updated": "2016-03-24T21:05:19Z", "joined_channels_count": 0, "links": { "user_channels": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels" }, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users?PageSize=50&Page=0", "next_page_url": null, "key": "users" }, "users": [] } ''' )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "jing", "attributes": null, "is_online": true, "is_notifiable": null, "friendly_name": null, "joined_channels_count": 0, "date_created": "2016-03-24T21:05:19Z", "date_updated": "2016-03-24T21:05:19Z", "links": { "user_channels": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels" }, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/ip_messaging/v1/service/user/000077500000000000000000000000001317472742600254705ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/ip_messaging/v1/service/user/__init__.py000066400000000000000000000001701317472742600275770ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/ip_messaging/v1/service/user/test_user_channel.py000066400000000000000000000077161317472742600315620ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class UserChannelTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .user_channels.list() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0", "next_page_url": null, "key": "channels" }, "channels": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "member_sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "joined", "last_consumed_message_index": 5, "unread_messages_count": 5, "links": { "channel": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "member": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } } ] } ''' )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .user_channels.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0", "next_page_url": null, "key": "channels" }, "channels": [] } ''' )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .user_channels.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/ip_messaging/v1/test_credential.py000066400000000000000000000153641317472742600266060ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class CredentialTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.credentials.list() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v1/Credentials', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "credentials": [ { "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Test slow create", "type": "apn", "sandbox": "False", "date_created": "2015-10-07T17:50:01Z", "date_updated": "2015-10-07T17:50:01Z", "url": "https://chat.twilio.com/v1/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "meta": { "page": 0, "page_size": 1, "first_page_url": "https://chat.twilio.com/v1/Credentials?PageSize=1&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v1/Credentials?PageSize=1&Page=0", "next_page_url": null, "key": "credentials" } } ''' )) actual = self.client.ip_messaging.v1.credentials.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "credentials": [], "meta": { "page": 0, "page_size": 1, "first_page_url": "https://chat.twilio.com/v1/Credentials?PageSize=1&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v1/Credentials?PageSize=1&Page=0", "next_page_url": null, "key": "credentials" } } ''' )) actual = self.client.ip_messaging.v1.credentials.list() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.credentials.create(type="gcm") values = {'Type': "gcm",} self.holodeck.assert_has_request(Request( 'post', 'https://ip-messaging.twilio.com/v1/Credentials', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Test slow create", "type": "apn", "sandbox": "False", "date_created": "2015-10-07T17:50:01Z", "date_updated": "2015-10-07T17:50:01Z", "url": "https://chat.twilio.com/v1/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v1.credentials.create(type="gcm") self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.credentials(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v1/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Test slow create", "type": "apn", "sandbox": "False", "date_created": "2015-10-07T17:50:01Z", "date_updated": "2015-10-07T17:50:01Z", "url": "https://chat.twilio.com/v1/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v1.credentials(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.credentials(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://ip-messaging.twilio.com/v1/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Test slow create", "type": "apn", "sandbox": "False", "date_created": "2015-10-07T17:50:01Z", "date_updated": "2015-10-07T17:50:01Z", "url": "https://chat.twilio.com/v1/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v1.credentials(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.credentials(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://ip-messaging.twilio.com/v1/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.ip_messaging.v1.credentials(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) twilio-python-6.8.2/tests/integration/ip_messaging/v1/test_service.py000066400000000000000000000243031317472742600261250ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class ServiceTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "consumption_report_interval": 100, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "default_channel_creator_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_channel_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_service_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "limits": { "actions_per_second": 20, "channel_members": 100, "user_channels": 250 }, "links": {}, "notifications": {}, "post_webhook_url": "post_webhook_url", "pre_webhook_url": "pre_webhook_url", "reachability_enabled": false, "read_status_enabled": false, "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "typing_indicator_timeout": 100, "url": "http://www.example.com", "webhook_filters": [ "webhook_filters" ], "webhook_method": "webhook_method", "webhooks": {} } ''' )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.services.create(friendly_name="friendly_name") values = {'FriendlyName': "friendly_name",} self.holodeck.assert_has_request(Request( 'post', 'https://ip-messaging.twilio.com/v1/Services', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "consumption_report_interval": 100, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "default_channel_creator_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_channel_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_service_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "limits": { "actions_per_second": 20, "channel_members": 100, "user_channels": 250 }, "links": {}, "notifications": {}, "post_webhook_url": "post_webhook_url", "pre_webhook_url": "pre_webhook_url", "reachability_enabled": false, "read_status_enabled": false, "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "typing_indicator_timeout": 100, "url": "http://www.example.com", "webhook_filters": [ "webhook_filters" ], "webhook_method": "webhook_method", "webhooks": {} } ''' )) actual = self.client.ip_messaging.v1.services.create(friendly_name="friendly_name") self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.services.list() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v1/Services', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://chat.twilio.com/v1/Services?Page=0&PageSize=50", "key": "services", "next_page_url": null, "page": 0, "page_size": 0, "previous_page_url": null, "url": "https://chat.twilio.com/v1/Services" }, "services": [] } ''' )) actual = self.client.ip_messaging.v1.services.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://chat.twilio.com/v1/Services?Page=0&PageSize=50", "key": "services", "next_page_url": null, "page": 0, "page_size": 1, "previous_page_url": null, "url": "https://chat.twilio.com/v1/Services" }, "services": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "consumption_report_interval": 100, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "default_channel_creator_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_channel_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_service_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "limits": { "actions_per_second": 20, "channel_members": 100, "user_channels": 250 }, "links": {}, "notifications": {}, "post_webhook_url": "post_webhook_url", "pre_webhook_url": "pre_webhook_url", "reachability_enabled": false, "read_status_enabled": false, "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "typing_indicator_timeout": 100, "url": "http://www.example.com", "webhook_filters": [ "webhook_filters" ], "webhook_method": "webhook_method", "webhooks": {} } ] } ''' )) actual = self.client.ip_messaging.v1.services.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "consumption_report_interval": 100, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "default_channel_creator_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_channel_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_service_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "limits": { "actions_per_second": 20, "channel_members": 500, "user_channels": 600 }, "links": {}, "notifications": {}, "post_webhook_url": "post_webhook_url", "pre_webhook_url": "pre_webhook_url", "reachability_enabled": false, "read_status_enabled": false, "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "typing_indicator_timeout": 100, "url": "http://www.example.com", "webhook_filters": [ "webhook_filters" ], "webhook_method": "webhook_method", "webhooks": {} } ''' )) actual = self.client.ip_messaging.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/ip_messaging/v2/000077500000000000000000000000001317472742600230535ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/ip_messaging/v2/__init__.py000066400000000000000000000001701317472742600251620ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/ip_messaging/v2/service/000077500000000000000000000000001317472742600245135ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/ip_messaging/v2/service/__init__.py000066400000000000000000000001701317472742600266220ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/ip_messaging/v2/service/channel/000077500000000000000000000000001317472742600261235ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/ip_messaging/v2/service/channel/__init__.py000066400000000000000000000001701317472742600302320ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/ip_messaging/v2/service/channel/test_invite.py000066400000000000000000000212351317472742600310350ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class InviteTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .invites(sid="INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites/INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "identity": "identity", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites/INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .invites(sid="INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .invites.create(identity="identity") values = {'Identity': "identity",} self.holodeck.assert_has_request(Request( 'post', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "identity": "identity", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites/INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .invites.create(identity="identity") self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .invites.list() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "invites": [], "meta": { "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites?PageSize=50&Page=0", "key": "invites", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites?PageSize=50&Page=0" } } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .invites.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "invites": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "identity": "identity", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites/INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "meta": { "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites?PageSize=50&Page=0", "key": "invites", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites?PageSize=50&Page=0" } } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .invites.list() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .invites(sid="INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites/INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .invites(sid="INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) twilio-python-6.8.2/tests/integration/ip_messaging/v2/service/channel/test_member.py000066400000000000000000000254101317472742600310050ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class MemberTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members(sid="MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "jing", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "last_consumed_message_index": null, "last_consumption_timestamp": null, "date_created": "2016-03-24T21:05:50Z", "date_updated": "2016-03-24T21:05:50Z", "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members(sid="MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members.create(identity="identity") values = {'Identity': "identity",} self.holodeck.assert_has_request(Request( 'post', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "jing", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "last_consumed_message_index": null, "last_consumption_timestamp": null, "date_created": "2016-03-24T21:05:50Z", "date_updated": "2016-03-24T21:05:50Z", "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members.create(identity="identity") self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members.list() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members?PageSize=50&Page=0", "next_page_url": null, "key": "members" }, "members": [ { "sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "jing", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "last_consumed_message_index": null, "last_consumption_timestamp": null, "date_created": "2016-03-24T21:05:50Z", "date_updated": "2016-03-24T21:05:50Z", "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members?PageSize=50&Page=0", "next_page_url": null, "key": "members" }, "members": [] } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members.list() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members(sid="MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members(sid="MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members(sid="MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_role_sid_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "jing", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "last_consumed_message_index": 20, "last_consumption_timestamp": "2016-03-24T21:05:52Z", "date_created": "2016-03-24T21:05:50Z", "date_updated": "2016-03-24T21:05:51Z", "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .members(sid="MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/ip_messaging/v2/service/channel/test_message.py000066400000000000000000000420201317472742600311560ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class MessageTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "to": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-03-24T20:37:57Z", "date_updated": "2016-03-24T20:37:57Z", "last_updated_by": null, "was_edited": false, "from": "system", "attributes": "{}", "body": "Hello", "index": 0, "type": "text", "media": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_fetch_media_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "to": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-03-24T20:37:57Z", "date_updated": "2016-03-24T20:37:57Z", "last_updated_by": null, "was_edited": false, "from": "system", "attributes": "{}", "body": "Hello", "index": 0, "type": "media", "media": { "sid": "MEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "size": 99999999999999, "content_type": "application/pdf", "filename": "hello.pdf" }, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages.create() self.holodeck.assert_has_request(Request( 'post', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "to": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "attributes": null, "date_created": "2016-03-24T20:37:57Z", "date_updated": "2016-03-24T20:37:57Z", "last_updated_by": "system", "was_edited": false, "from": "system", "body": "Hello", "index": 0, "type": "text", "media": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages.create() self.assertIsNotNone(actual) def test_create_with_all_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "to": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-12-16T22:18:37Z", "date_updated": "2015-12-16T22:18:38Z", "last_updated_by": "username", "was_edited": true, "from": "system", "attributes": "{\\"test\\": \\"test\\"}", "body": "Hello", "index": 0, "type": "text", "media": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages.create() self.assertIsNotNone(actual) def test_create_media_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "to": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "attributes": null, "date_created": "2016-03-24T20:37:57Z", "date_updated": "2016-03-24T20:37:57Z", "last_updated_by": "system", "was_edited": false, "from": "system", "body": "Hello", "index": 0, "type": "text", "media": { "sid": "MEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "size": 99999999999999, "content_type": "application/pdf", "filename": "hello.pdf" }, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages.create() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages.list() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages?PageSize=50&Page=0", "next_page_url": null, "key": "messages" }, "messages": [ { "sid": "IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "to": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-03-24T20:37:57Z", "date_updated": "2016-03-24T20:37:57Z", "last_updated_by": null, "was_edited": false, "from": "system", "attributes": "{}", "body": "Hello", "index": 0, "type": "text", "media": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, { "sid": "IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "to": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-03-24T20:37:57Z", "date_updated": "2016-03-24T20:37:57Z", "last_updated_by": null, "was_edited": false, "from": "system", "attributes": "{}", "body": "Hello", "index": 0, "type": "media", "media": { "sid": "MEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "size": 99999999999999, "content_type": "application/pdf", "filename": "hello.pdf" }, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages?PageSize=50&Page=0", "next_page_url": null, "key": "messages" }, "messages": [] } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages.list() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "to": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "attributes": "{ \\"foo\\": \\"bar\\" }", "date_created": "2015-12-16T22:18:37Z", "date_updated": "2015-12-16T22:18:38Z", "last_updated_by": "username", "was_edited": true, "from": "system", "body": "Hello", "index": 0, "type": "text", "media": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .messages(sid="IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/ip_messaging/v2/service/test_binding.py000066400000000000000000000150771317472742600275500ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class BindingTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings.list() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings?PageSize=50&Page=0", "next_page_url": null, "key": "bindings" }, "bindings": [ { "sid": "BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-10-21T11:37:03Z", "date_updated": "2016-10-21T11:37:03Z", "endpoint": "TestUser-endpoint", "identity": "TestUser", "binding_type": "gcm", "credential_sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "message_types": [ "removed_from_channel", "new_message", "added_to_channel", "invited_to_channel" ], "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "user": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/TestUser" } } ] } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings?PageSize=50&Page=0", "next_page_url": null, "key": "bindings" }, "bindings": [] } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings.list() self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings(sid="BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-10-21T11:37:03Z", "date_updated": "2016-10-21T11:37:03Z", "endpoint": "TestUser-endpoint", "identity": "TestUser", "binding_type": "gcm", "credential_sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "message_types": [ "removed_from_channel", "new_message", "added_to_channel", "invited_to_channel" ], "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "user": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/TestUser" } } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings(sid="BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings(sid="BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings(sid="BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) twilio-python-6.8.2/tests/integration/ip_messaging/v2/service/test_channel.py000066400000000000000000000266601317472742600275460ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class ChannelTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "unique_name": "unique_name", "attributes": "{ \\"foo\\": \\"bar\\" }", "type": "public", "date_created": "2015-12-16T22:18:37Z", "date_updated": "2015-12-16T22:18:37Z", "created_by": "system", "members_count": 0, "messages_count": 0, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "members": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members", "messages": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages", "invites": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites", "last_message": null } } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels.create() self.holodeck.assert_has_request(Request( 'post', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "unique_name": "unique_name", "attributes": "{ \\"foo\\": \\"bar\\" }", "type": "public", "date_created": "2015-12-16T22:18:37Z", "date_updated": "2015-12-16T22:18:38Z", "created_by": "username", "members_count": 0, "messages_count": 0, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "members": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members", "messages": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages", "invites": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites", "last_message": null } } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels.create() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels.list() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "channels": [ { "sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "unique_name": "unique_name", "attributes": "{ \\"foo\\": \\"bar\\" }", "type": "public", "date_created": "2015-12-16T22:18:37Z", "date_updated": "2015-12-16T22:18:37Z", "created_by": "system", "members_count": 0, "messages_count": 0, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "members": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members", "messages": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages", "invites": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites", "last_message": null } } ], "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0", "next_page_url": null, "key": "channels" } } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "channels": [], "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0", "next_page_url": null, "key": "channels" } } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "unique_name": "unique_name", "attributes": "{ \\"foo\\": \\"bar\\" }", "type": "public", "date_created": "2015-12-16T22:18:37Z", "date_updated": "2015-12-16T22:18:38Z", "created_by": "username", "members_count": 0, "messages_count": 0, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "members": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members", "messages": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages", "invites": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites", "last_message": null } } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .channels(sid="CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/ip_messaging/v2/service/test_role.py000066400000000000000000000226651317472742600271000ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class RoleTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles(sid="RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "channel user", "type": "channel", "permissions": [ "sendMessage", "leaveChannel", "editOwnMessage", "deleteOwnMessage" ], "date_created": "2016-03-03T19:47:15Z", "date_updated": "2016-03-03T19:47:15Z", "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles(sid="RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles(sid="RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles(sid="RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles.create(friendly_name="friendly_name", type="channel", permission=['permission']) values = {'FriendlyName': "friendly_name", 'Type': "channel", 'Permission': ['permission'],} self.holodeck.assert_has_request(Request( 'post', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "channel user", "type": "channel", "permissions": [ "sendMessage", "leaveChannel", "editOwnMessage", "deleteOwnMessage" ], "date_created": "2016-03-03T19:47:15Z", "date_updated": "2016-03-03T19:47:15Z", "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles.create(friendly_name="friendly_name", type="channel", permission=['permission']) self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles.list() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles?PageSize=50&Page=0", "next_page_url": null, "key": "roles" }, "roles": [ { "sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "channel user", "type": "channel", "permissions": [ "sendMessage", "leaveChannel", "editOwnMessage", "deleteOwnMessage" ], "date_created": "2016-03-03T19:47:15Z", "date_updated": "2016-03-03T19:47:15Z", "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles?PageSize=50&Page=0", "next_page_url": null, "key": "roles" }, "roles": [] } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles(sid="RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update(permission=['permission']) values = {'Permission': ['permission'],} self.holodeck.assert_has_request(Request( 'post', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', data=values, )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "channel user", "type": "channel", "permissions": [ "sendMessage", "leaveChannel", "editOwnMessage", "deleteOwnMessage" ], "date_created": "2016-03-03T19:47:15Z", "date_updated": "2016-03-03T19:47:15Z", "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .roles(sid="RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update(permission=['permission']) self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/ip_messaging/v2/service/test_user.py000066400000000000000000000252241317472742600271070ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class UserTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "jing", "attributes": null, "is_online": true, "is_notifiable": null, "friendly_name": null, "joined_channels_count": 0, "date_created": "2016-03-24T21:05:19Z", "date_updated": "2016-03-24T21:05:19Z", "links": { "user_channels": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels", "user_bindings": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings" }, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users.create(identity="identity") values = {'Identity': "identity",} self.holodeck.assert_has_request(Request( 'post', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "jing", "attributes": null, "is_online": true, "is_notifiable": null, "friendly_name": null, "joined_channels_count": 0, "date_created": "2016-03-24T21:05:19Z", "date_updated": "2016-03-24T21:05:19Z", "links": { "user_channels": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels", "user_bindings": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings" }, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users.create(identity="identity") self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users.list() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users?PageSize=50&Page=0", "next_page_url": null, "key": "users" }, "users": [ { "sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "jing", "attributes": null, "is_online": true, "is_notifiable": null, "friendly_name": null, "date_created": "2016-03-24T21:05:19Z", "date_updated": "2016-03-24T21:05:19Z", "joined_channels_count": 0, "links": { "user_channels": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels", "user_bindings": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings" }, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users?PageSize=50&Page=0", "next_page_url": null, "key": "users" }, "users": [] } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "jing", "attributes": null, "is_online": true, "is_notifiable": null, "friendly_name": null, "joined_channels_count": 0, "date_created": "2016-03-24T21:05:19Z", "date_updated": "2016-03-24T21:05:19Z", "links": { "user_channels": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels", "user_bindings": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings" }, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/ip_messaging/v2/service/user/000077500000000000000000000000001317472742600254715ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/ip_messaging/v2/service/user/__init__.py000066400000000000000000000001701317472742600276000ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/ip_messaging/v2/service/user/test_user_binding.py000066400000000000000000000166211317472742600315600ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class UserBindingTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .user_bindings.list() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings?PageSize=50&Page=0", "next_page_url": null, "key": "bindings" }, "bindings": [ { "sid": "BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-10-21T11:37:03Z", "date_updated": "2016-10-21T11:37:03Z", "endpoint": "TestUser-endpoint", "identity": "TestUser", "user_sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "binding_type": "gcm", "credential_sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "message_types": [ "removed_from_channel", "new_message", "added_to_channel", "invited_to_channel" ], "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .user_bindings.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings?PageSize=50&Page=0", "next_page_url": null, "key": "bindings" }, "bindings": [] } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .user_bindings.list() self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .user_bindings(sid="BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-10-21T11:37:03Z", "date_updated": "2016-10-21T11:37:03Z", "endpoint": "TestUser-endpoint", "identity": "TestUser", "user_sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "binding_type": "gcm", "credential_sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "message_types": [ "removed_from_channel", "new_message", "added_to_channel", "invited_to_channel" ], "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .user_bindings(sid="BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .user_bindings(sid="BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .user_bindings(sid="BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) twilio-python-6.8.2/tests/integration/ip_messaging/v2/service/user/test_user_channel.py000066400000000000000000000077161317472742600315630ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class UserChannelTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .user_channels.list() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0", "next_page_url": null, "key": "channels" }, "channels": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "member_sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "joined", "last_consumed_message_index": 5, "unread_messages_count": 5, "links": { "channel": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "member": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } } ] } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .user_channels.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0", "next_page_url": null, "key": "channels" }, "channels": [] } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(sid="USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .user_channels.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/ip_messaging/v2/test_credential.py000066400000000000000000000153641317472742600266070ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class CredentialTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.credentials.list() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v2/Credentials', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "credentials": [ { "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Test slow create", "type": "apn", "sandbox": "False", "date_created": "2015-10-07T17:50:01Z", "date_updated": "2015-10-07T17:50:01Z", "url": "https://chat.twilio.com/v2/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "meta": { "page": 0, "page_size": 1, "first_page_url": "https://chat.twilio.com/v2/Credentials?PageSize=1&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Credentials?PageSize=1&Page=0", "next_page_url": null, "key": "credentials" } } ''' )) actual = self.client.ip_messaging.v2.credentials.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "credentials": [], "meta": { "page": 0, "page_size": 1, "first_page_url": "https://chat.twilio.com/v2/Credentials?PageSize=1&Page=0", "previous_page_url": null, "url": "https://chat.twilio.com/v2/Credentials?PageSize=1&Page=0", "next_page_url": null, "key": "credentials" } } ''' )) actual = self.client.ip_messaging.v2.credentials.list() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.credentials.create(type="gcm") values = {'Type': "gcm",} self.holodeck.assert_has_request(Request( 'post', 'https://ip-messaging.twilio.com/v2/Credentials', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Test slow create", "type": "apn", "sandbox": "False", "date_created": "2015-10-07T17:50:01Z", "date_updated": "2015-10-07T17:50:01Z", "url": "https://chat.twilio.com/v2/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v2.credentials.create(type="gcm") self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.credentials(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v2/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Test slow create", "type": "apn", "sandbox": "False", "date_created": "2015-10-07T17:50:01Z", "date_updated": "2015-10-07T17:50:01Z", "url": "https://chat.twilio.com/v2/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v2.credentials(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.credentials(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://ip-messaging.twilio.com/v2/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Test slow create", "type": "apn", "sandbox": "False", "date_created": "2015-10-07T17:50:01Z", "date_updated": "2015-10-07T17:50:01Z", "url": "https://chat.twilio.com/v2/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.ip_messaging.v2.credentials(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.credentials(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://ip-messaging.twilio.com/v2/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.ip_messaging.v2.credentials(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) twilio-python-6.8.2/tests/integration/ip_messaging/v2/test_service.py000066400000000000000000000334521317472742600261330ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class ServiceTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "consumption_report_interval": 100, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "default_channel_creator_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_channel_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_service_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "limits": { "channel_members": 100, "user_channels": 250 }, "links": { "channels": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels", "users": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users", "roles": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles", "bindings": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings" }, "notifications": {}, "post_webhook_url": "post_webhook_url", "pre_webhook_url": "pre_webhook_url", "pre_webhook_retry_count": 2, "post_webhook_retry_count": 3, "reachability_enabled": false, "read_status_enabled": false, "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "typing_indicator_timeout": 100, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "webhook_filters": [ "webhook_filters" ], "webhook_method": "webhook_method", "media": { "size_limit_mb": 150, "compatibility_message": "media compatibility message" } } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services.create(friendly_name="friendly_name") values = {'FriendlyName': "friendly_name",} self.holodeck.assert_has_request(Request( 'post', 'https://ip-messaging.twilio.com/v2/Services', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "consumption_report_interval": 100, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "default_channel_creator_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_channel_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_service_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "limits": { "channel_members": 100, "user_channels": 250 }, "links": { "channels": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels", "users": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users", "roles": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles", "bindings": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings" }, "notifications": {}, "post_webhook_url": "post_webhook_url", "pre_webhook_url": "pre_webhook_url", "pre_webhook_retry_count": 2, "post_webhook_retry_count": 3, "reachability_enabled": false, "read_status_enabled": false, "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "typing_indicator_timeout": 100, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "webhook_filters": [ "webhook_filters" ], "webhook_method": "webhook_method", "media": { "size_limit_mb": 150, "compatibility_message": "media compatibility message" } } ''' )) actual = self.client.ip_messaging.v2.services.create(friendly_name="friendly_name") self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services.list() self.holodeck.assert_has_request(Request( 'get', 'https://ip-messaging.twilio.com/v2/Services', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://chat.twilio.com/v2/Services?PageSize=50&Page=0", "key": "services", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services?PageSize=50&Page=0" }, "services": [] } ''' )) actual = self.client.ip_messaging.v2.services.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://chat.twilio.com/v2/Services?PageSize=50&Page=0", "key": "services", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://chat.twilio.com/v2/Services?PageSize=50&Page=0" }, "services": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "consumption_report_interval": 100, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "default_channel_creator_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_channel_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_service_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "limits": { "channel_members": 100, "user_channels": 250 }, "links": { "channels": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels", "users": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users", "roles": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles", "bindings": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings" }, "notifications": {}, "post_webhook_url": "post_webhook_url", "pre_webhook_url": "pre_webhook_url", "pre_webhook_retry_count": 2, "post_webhook_retry_count": 3, "reachability_enabled": false, "read_status_enabled": false, "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "typing_indicator_timeout": 100, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "webhook_filters": [ "webhook_filters" ], "webhook_method": "webhook_method", "media": { "size_limit_mb": 150, "compatibility_message": "media compatibility message" } } ] } ''' )) actual = self.client.ip_messaging.v2.services.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://ip-messaging.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "consumption_report_interval": 100, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "default_channel_creator_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_channel_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_service_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "limits": { "channel_members": 500, "user_channels": 600 }, "links": { "channels": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels", "users": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users", "roles": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles", "bindings": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings" }, "notifications": { "added_to_channel": { "enabled": false, "template": "notifications.added_to_channel.template" }, "invited_to_channel": { "enabled": false, "template": "notifications.invited_to_channel.template" }, "new_message": { "enabled": false, "template": "notifications.new_message.template", "badge_count_enabled": true }, "removed_from_channel": { "enabled": false, "template": "notifications.removed_from_channel.template" } }, "post_webhook_url": "post_webhook_url", "pre_webhook_url": "pre_webhook_url", "pre_webhook_retry_count": 2, "post_webhook_retry_count": 3, "reachability_enabled": false, "read_status_enabled": false, "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "typing_indicator_timeout": 100, "url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "webhook_filters": [ "webhook_filters" ], "webhook_method": "webhook_method", "media": { "size_limit_mb": 150, "compatibility_message": "new media compatibility message" } } ''' )) actual = self.client.ip_messaging.v2.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/lookups/000077500000000000000000000000001317472742600215535ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/lookups/__init__.py000066400000000000000000000001701317472742600236620ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/lookups/v1/000077500000000000000000000000001317472742600221015ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/lookups/v1/__init__.py000066400000000000000000000001701317472742600242100ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/lookups/v1/test_phone_number.py000066400000000000000000000035151317472742600261770ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class PhoneNumberTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.lookups.v1.phone_numbers(phone_number="+987654321").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://lookups.twilio.com/v1/PhoneNumbers/+987654321', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "caller_name": { "caller_name": "Delicious Cheese Cake", "caller_type": "CONSUMER", "error_code": null }, "carrier": { "error_code": null, "mobile_country_code": "310", "mobile_network_code": "456", "name": "verizon", "type": "mobile" }, "country_code": "US", "national_format": "(510) 867-5309", "phone_number": "+15108675309", "add_ons": { "status": "successful", "message": null, "code": null, "results": {} }, "url": "https://lookups.twilio.com/v1/PhoneNumbers/phone_number" } ''' )) actual = self.client.lookups.v1.phone_numbers(phone_number="+987654321").fetch() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/messaging/000077500000000000000000000000001317472742600220345ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/messaging/__init__.py000066400000000000000000000001701317472742600241430ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/messaging/v1/000077500000000000000000000000001317472742600223625ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/messaging/v1/__init__.py000066400000000000000000000001701317472742600244710ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/messaging/v1/service/000077500000000000000000000000001317472742600240225ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/messaging/v1/service/__init__.py000066400000000000000000000001701317472742600261310ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/messaging/v1/service/test_alpha_sender.py000066400000000000000000000142021317472742600300570ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class AlphaSenderTestCase(IntegrationTestCase): def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.messaging.v1.services(sid="MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .alpha_senders.create(alpha_sender="alpha_sender") values = {'AlphaSender': "alpha_sender",} self.holodeck.assert_has_request(Request( 'post', 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AlphaSenders', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "AIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:12:31Z", "date_updated": "2015-07-30T20:12:33Z", "alpha_sender": "Twilio", "capabilities": [], "url": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AlphaSenders/AIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.messaging.v1.services(sid="MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .alpha_senders.create(alpha_sender="alpha_sender") self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.messaging.v1.services(sid="MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .alpha_senders.list() self.holodeck.assert_has_request(Request( 'get', 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AlphaSenders', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AlphaSenders?PageSize=50&Page=0", "previous_page_url": null, "next_page_url": null, "key": "alpha_senders", "url": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AlphaSenders?PageSize=50&Page=0" }, "alpha_senders": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "AIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:12:31Z", "date_updated": "2015-07-30T20:12:33Z", "alpha_sender": "Twilio", "capabilities": [], "url": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AlphaSenders/AIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.messaging.v1.services(sid="MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .alpha_senders.list() self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.messaging.v1.services(sid="MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .alpha_senders(sid="AIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AlphaSenders/AIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "AIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:12:31Z", "date_updated": "2015-07-30T20:12:33Z", "alpha_sender": "Twilio", "capabilities": [], "url": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AlphaSenders/AIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.messaging.v1.services(sid="MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .alpha_senders(sid="AIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.messaging.v1.services(sid="MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .alpha_senders(sid="AIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AlphaSenders/AIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.messaging.v1.services(sid="MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .alpha_senders(sid="AIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) twilio-python-6.8.2/tests/integration/messaging/v1/service/test_phone_number.py000066400000000000000000000166471317472742600301320ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class PhoneNumberTestCase(IntegrationTestCase): def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.messaging.v1.services(sid="MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .phone_numbers.create(phone_number_sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") values = {'PhoneNumberSid': "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",} self.holodeck.assert_has_request(Request( 'post', 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:12:31Z", "date_updated": "2015-07-30T20:12:33Z", "phone_number": "+987654321", "country_code": "US", "capabilities": [], "url": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.messaging.v1.services(sid="MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .phone_numbers.create(phone_number_sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") self.assertIsNotNone(actual) def test_create_with_capabilities_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:12:31Z", "date_updated": "2015-07-30T20:12:33Z", "phone_number": "+987654321", "country_code": "US", "capabilities": [ "MMS", "SMS", "Voice" ], "url": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.messaging.v1.services(sid="MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .phone_numbers.create(phone_number_sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.messaging.v1.services(sid="MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .phone_numbers(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.messaging.v1.services(sid="MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .phone_numbers(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.messaging.v1.services(sid="MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .phone_numbers.list() self.holodeck.assert_has_request(Request( 'get', 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers?PageSize=50&Page=0", "previous_page_url": null, "next_page_url": null, "key": "phone_numbers", "url": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers?PageSize=50&Page=0" }, "phone_numbers": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:12:31Z", "date_updated": "2015-07-30T20:12:33Z", "phone_number": "+987654321", "country_code": "US", "capabilities": [], "url": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.messaging.v1.services(sid="MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .phone_numbers.list() self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.messaging.v1.services(sid="MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .phone_numbers(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:12:31Z", "date_updated": "2015-07-30T20:12:33Z", "phone_number": "12345", "country_code": "US", "capabilities": [], "url": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.messaging.v1.services(sid="MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .phone_numbers(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/messaging/v1/service/test_short_code.py000066400000000000000000000144221317472742600275670ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class ShortCodeTestCase(IntegrationTestCase): def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.messaging.v1.services(sid="MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .short_codes.create(short_code_sid="SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") values = {'ShortCodeSid': "SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",} self.holodeck.assert_has_request(Request( 'post', 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:12:31Z", "date_updated": "2015-07-30T20:12:33Z", "short_code": "12345", "country_code": "US", "capabilities": [], "url": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes/SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.messaging.v1.services(sid="MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .short_codes.create(short_code_sid="SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.messaging.v1.services(sid="MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .short_codes(sid="SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes/SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.messaging.v1.services(sid="MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .short_codes(sid="SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.messaging.v1.services(sid="MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .short_codes.list() self.holodeck.assert_has_request(Request( 'get', 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes?PageSize=50&Page=0", "previous_page_url": null, "next_page_url": null, "key": "short_codes", "url": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes?PageSize=50&Page=0" }, "short_codes": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:12:31Z", "date_updated": "2015-07-30T20:12:33Z", "short_code": "12345", "country_code": "US", "capabilities": [], "url": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes/SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.messaging.v1.services(sid="MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .short_codes.list() self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.messaging.v1.services(sid="MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .short_codes(sid="SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes/SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:12:31Z", "date_updated": "2015-07-30T20:12:33Z", "short_code": "12345", "country_code": "US", "capabilities": [], "url": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes/SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.messaging.v1.services(sid="MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .short_codes(sid="SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/messaging/v1/test_service.py000066400000000000000000000236051317472742600254410ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class ServiceTestCase(IntegrationTestCase): def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.messaging.v1.services.create(friendly_name="friendly_name") values = {'FriendlyName': "friendly_name",} self.holodeck.assert_has_request(Request( 'post', 'https://messaging.twilio.com/v1/Services', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:12:31Z", "date_updated": "2015-07-30T20:12:33Z", "friendly_name": "My Service!", "inbound_request_url": "https://www.example.com/", "inbound_method": "POST", "fallback_url": "https://www.example.com", "fallback_method": "GET", "status_callback": "https://www.example.com", "sticky_sender": true, "smart_encoding": false, "mms_converter": true, "fallback_to_long_code": true, "scan_message_content": "inherit", "area_code_geomatch": true, "validity_period": 600, "synchronous_validation": true, "links": { "phone_numbers": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers", "short_codes": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes", "alpha_senders": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AlphaSenders" }, "url": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.messaging.v1.services.create(friendly_name="friendly_name") self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.messaging.v1.services(sid="MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "My Service!", "sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:12:31Z", "date_updated": "2015-07-30T20:12:33Z", "sticky_sender": false, "mms_converter": true, "smart_encoding": false, "fallback_to_long_code": true, "scan_message_content": "inherit", "synchronous_validation": true, "area_code_geomatch": true, "validity_period": 600, "inbound_request_url": "https://www.example.com", "inbound_method": "POST", "fallback_url": null, "fallback_method": "POST", "status_callback": "https://www.example.com", "links": { "phone_numbers": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers", "short_codes": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes", "alpha_senders": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AlphaSenders" }, "url": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.messaging.v1.services(sid="MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.messaging.v1.services.list() self.holodeck.assert_has_request(Request( 'get', 'https://messaging.twilio.com/v1/Services', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://messaging.twilio.com/v1/Services?PageSize=50&Page=0", "previous_page_url": null, "next_page_url": null, "key": "services", "url": "https://messaging.twilio.com/v1/Services?PageSize=50&Page=0" }, "services": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "My Service!", "sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:12:31Z", "date_updated": "2015-07-30T20:12:33Z", "sticky_sender": true, "mms_converter": true, "smart_encoding": false, "fallback_to_long_code": true, "area_code_geomatch": true, "validity_period": 600, "scan_message_content": "inherit", "synchronous_validation": true, "inbound_request_url": "https://www.example.com/", "inbound_method": "POST", "fallback_url": null, "fallback_method": "POST", "status_callback": "https://www.example.com", "links": { "phone_numbers": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers", "short_codes": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes", "alpha_senders": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AlphaSenders" }, "url": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.messaging.v1.services.list() self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.messaging.v1.services(sid="MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:12:31Z", "date_updated": "2015-07-30T20:12:33Z", "friendly_name": "My Service!", "inbound_request_url": "https://www.example.com/", "inbound_method": "POST", "fallback_url": null, "fallback_method": "POST", "status_callback": "https://www.example.com", "sticky_sender": true, "mms_converter": true, "smart_encoding": false, "fallback_to_long_code": true, "area_code_geomatch": true, "validity_period": 600, "scan_message_content": "inherit", "synchronous_validation": true, "links": { "phone_numbers": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers", "short_codes": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes", "alpha_senders": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AlphaSenders" }, "url": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.messaging.v1.services(sid="MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.messaging.v1.services(sid="MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.messaging.v1.services(sid="MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) twilio-python-6.8.2/tests/integration/monitor/000077500000000000000000000000001317472742600215465ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/monitor/__init__.py000066400000000000000000000001701317472742600236550ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/monitor/v1/000077500000000000000000000000001317472742600220745ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/monitor/v1/__init__.py000066400000000000000000000001701317472742600242030ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/monitor/v1/test_alert.py000066400000000000000000000120441317472742600246150ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class AlertTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.monitor.v1.alerts(sid="NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://monitor.twilio.com/v1/Alerts/NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "alert_text": "alert_text", "api_version": "2010-04-01", "date_created": "2015-07-30T20:00:00Z", "date_generated": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "error_code": "error_code", "log_level": "log_level", "more_info": "more_info", "request_method": "GET", "request_url": "http://www.example.com", "request_variables": "request_variables", "resource_sid": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "response_body": "response_body", "response_headers": "response_headers", "sid": "NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "http://www.example.com" } ''' )) actual = self.client.monitor.v1.alerts(sid="NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.monitor.v1.alerts(sid="NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://monitor.twilio.com/v1/Alerts/NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.monitor.v1.alerts(sid="NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.monitor.v1.alerts.list() self.holodeck.assert_has_request(Request( 'get', 'https://monitor.twilio.com/v1/Alerts', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "alerts": [], "meta": { "first_page_url": "https://monitor.twilio.com/v1/Alerts?Page=0&PageSize=50", "key": "alerts", "next_page_url": null, "page": 0, "page_size": 0, "previous_page_url": null, "url": "https://monitor.twilio.com/v1/Alerts" } } ''' )) actual = self.client.monitor.v1.alerts.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "alerts": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "alert_text": "alert_text", "api_version": "2010-04-01", "date_created": "2015-07-30T20:00:00Z", "date_generated": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "error_code": "error_code", "log_level": "log_level", "more_info": "more_info", "request_method": "GET", "request_url": "http://www.example.com", "resource_sid": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "http://www.example.com" } ], "meta": { "first_page_url": "https://monitor.twilio.com/v1/Alerts?Page=0&PageSize=50", "key": "alerts", "next_page_url": null, "page": 0, "page_size": 1, "previous_page_url": null, "url": "https://monitor.twilio.com/v1/Alerts" } } ''' )) actual = self.client.monitor.v1.alerts.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/monitor/v1/test_event.py000066400000000000000000000123541317472742600246330ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class EventTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.monitor.v1.events(sid="AEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://monitor.twilio.com/v1/Events/AEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "actor_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "actor_type": "account", "description": null, "event_data": { "friendly_name": { "previous": "SubAccount Created at 2014-10-03 09:48 am", "updated": "Mr. Friendly" } }, "event_date": "2014-10-03T16:48:25Z", "event_type": "account.updated", "links": { "actor": "https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "resource": "https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, "resource_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "resource_type": "account", "sid": "AEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "source": "api", "source_ip_address": "10.86.6.250", "url": "https://monitor.twilio.com/v1/Events/AEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.monitor.v1.events(sid="AEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.monitor.v1.events.list() self.holodeck.assert_has_request(Request( 'get', 'https://monitor.twilio.com/v1/Events', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "events": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "actor_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "actor_type": "account", "description": null, "event_data": { "friendly_name": { "previous": "SubAccount Created at 2014-10-03 09:48 am", "updated": "Mr. Friendly" } }, "event_date": "2014-10-03T16:48:25Z", "event_type": "account.updated", "links": { "actor": "https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "resource": "https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, "resource_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "resource_type": "account", "sid": "AEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "source": "api", "source_ip_address": "10.86.6.250", "url": "https://monitor.twilio.com/v1/Events/AEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "meta": { "first_page_url": "https://monitor.twilio.com/v1/Events?PageSize=50&Page=0", "key": "events", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://monitor.twilio.com/v1/Events?PageSize=50&Page=0" } } ''' )) actual = self.client.monitor.v1.events.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "events": [], "meta": { "first_page_url": "https://monitor.twilio.com/v1/Events?PageSize=50&Page=0", "key": "events", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://monitor.twilio.com/v1/Events?PageSize=50&Page=0" } } ''' )) actual = self.client.monitor.v1.events.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/notify/000077500000000000000000000000001317472742600213675ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/notify/__init__.py000066400000000000000000000001701317472742600234760ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/notify/v1/000077500000000000000000000000001317472742600217155ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/notify/v1/__init__.py000066400000000000000000000001701317472742600240240ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/notify/v1/service/000077500000000000000000000000001317472742600233555ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/notify/v1/service/__init__.py000066400000000000000000000001701317472742600254640ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/notify/v1/service/test_binding.py000066400000000000000000000206231317472742600264030ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class BindingTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings(sid="BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "address": "a7c658f4111ec4ff5a1a647f9d0edd819025b9f20522d2fae897049f32873e73", "binding_type": "apn", "credential_sid": null, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "endpoint": "26607274", "identity": "24987039", "notification_protocol_version": "3", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "tags": [ "26607274" ], "links": { "user": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/24987039" }, "url": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings(sid="BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings(sid="BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings(sid="BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings.create(identity="identity", binding_type="apn", address="address") values = {'Identity': "identity", 'BindingType': "apn", 'Address': "address",} self.holodeck.assert_has_request(Request( 'post', 'https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "address": "a7c658f4111ec4ff5a1a647f9d0edd819025b9f20522d2fae897049f32873e73", "binding_type": "apn", "credential_sid": null, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "endpoint": "26607274", "identity": "24987039", "notification_protocol_version": "3", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "tags": [ "26607274" ], "links": { "user": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/24987039" }, "url": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings.create(identity="identity", binding_type="apn", address="address") self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings.list() self.holodeck.assert_has_request(Request( 'get', 'https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "bindings": [], "meta": { "first_page_url": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings?PageSize=50&Page=0", "key": "bindings", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings?PageSize=50&Page=0" } } ''' )) actual = self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "bindings": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "address": "a7c658f4111ec4ff5a1a647f9d0edd819025b9f20522d2fae897049f32873e73", "binding_type": "apn", "credential_sid": null, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "endpoint": "26607274", "identity": "24987039", "notification_protocol_version": "3", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "tags": [ "26607274" ], "links": { "user": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/24987039" }, "url": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "meta": { "first_page_url": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings?PageSize=50&Page=0", "key": "bindings", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings?PageSize=50&Page=0" } } ''' )) actual = self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/notify/v1/service/test_notification.py000066400000000000000000000060331317472742600274560ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class NotificationTestCase(IntegrationTestCase): def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .notifications.create() self.holodeck.assert_has_request(Request( 'post', 'https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "NOb8021351170b4e1286adaac3fdd6d082", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "IS699b53e02da45a1ba9d13b7d7d2766af", "date_created": "2016-03-24T23:42:28Z", "identities": [ "jing" ], "tags": [], "segments": [], "priority": "high", "ttl": 2419200, "title": "test", "body": "body", "sound": null, "action": null, "data": null, "apn": null, "fcm": null, "gcm": null, "sms": null, "facebook_messenger": null, "alexa": null } ''' )) actual = self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .notifications.create() self.assertIsNotNone(actual) def test_create_direct_notification_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "NOb8021351170b4e1286adaac3fdd6d082", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "IS699b53e02da45a1ba9d13b7d7d2766af", "date_created": "2016-03-24T23:42:28Z", "identities": [], "tags": [], "segments": [], "priority": "high", "ttl": 2419200, "title": null, "body": "body", "sound": null, "action": null, "data": null, "apn": null, "fcm": null, "gcm": null, "sms": null, "facebook_messenger": null, "alexa": null } ''' )) actual = self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .notifications.create() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/notify/v1/service/test_segment.py000066400000000000000000000057271317472742600264430ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class SegmentTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .segments.list() self.holodeck.assert_has_request(Request( 'get', 'https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Segments', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Segments?PageSize=50&Page=0", "key": "segments", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Segments?PageSize=50&Page=0" }, "segments": [] } ''' )) actual = self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .segments.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "segments": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2017-02-14T14:36:41Z", "date_updated": "2017-02-14T14:36:41Z", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "GSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "segment" } ], "meta": { "first_page_url": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Segments?PageSize=50&Page=0", "key": "segments", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Segments?PageSize=50&Page=0" } } ''' )) actual = self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .segments.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/notify/v1/service/test_user.py000066400000000000000000000175161317472742600257560ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class UserTestCase(IntegrationTestCase): def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users.create(identity="identity") values = {'Identity': "identity",} self.holodeck.assert_has_request(Request( 'post', 'https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2017-02-17T07:17:02Z", "date_updated": "2017-02-17T07:17:02Z", "identity": "identity", "links": { "bindings": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/identity/Bindings", "segment_memberships": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/identity/SegmentMemberships" }, "segments": [ "segment1" ], "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/identity" } ''' )) actual = self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users.create(identity="identity") self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(identity="NUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/NUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(identity="NUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(identity="NUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/NUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2017-02-17T07:17:02Z", "date_updated": "2017-02-17T07:17:02Z", "identity": "identity", "links": { "bindings": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/identity/Bindings", "segment_memberships": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/identity/SegmentMemberships" }, "segments": [ "segment1" ], "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/identity" } ''' )) actual = self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(identity="NUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users.list() self.holodeck.assert_has_request(Request( 'get', 'https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "users": [], "meta": { "first_page_url": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users?PageSize=50&Page=0", "key": "users", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users?PageSize=50&Page=0" } } ''' )) actual = self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "users": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2017-02-17T07:17:02Z", "date_updated": "2017-02-17T07:17:02Z", "identity": "identity", "links": { "bindings": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/identity/Bindings", "segment_memberships": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/identity/SegmentMemberships" }, "segments": [ "segment1" ], "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/identity" } ], "meta": { "first_page_url": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users?PageSize=50&Page=0", "key": "users", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users?PageSize=50&Page=0" } } ''' )) actual = self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/notify/v1/service/user/000077500000000000000000000000001317472742600243335ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/notify/v1/service/user/__init__.py000066400000000000000000000001701317472742600264420ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/notify/v1/service/user/test_segment_memberships.py000066400000000000000000000104151317472742600320050ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class SegmentMembershipTestCase(IntegrationTestCase): def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(identity="NUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .segment_memberships.create(segment="segment") values = {'Segment': "segment",} self.holodeck.assert_has_request(Request( 'post', 'https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/NUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SegmentMemberships', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "identity", "segment": "segment", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/identity/SegmentMemberships/segment" } ''' )) actual = self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(identity="NUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .segment_memberships.create(segment="segment") self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(identity="NUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .segment_memberships(segment="segment").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/NUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SegmentMemberships/segment', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(identity="NUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .segment_memberships(segment="segment").delete() self.assertTrue(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(identity="NUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .segment_memberships(segment="segment").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/NUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SegmentMemberships/segment', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "identity", "segment": "segment", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/identity/SegmentMemberships/segment" } ''' )) actual = self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(identity="NUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .segment_memberships(segment="segment").fetch() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/notify/v1/service/user/test_user_binding.py000066400000000000000000000256271317472742600304300ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class UserBindingTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(identity="NUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings(sid="BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/NUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "address": "address", "binding_type": "binding_type", "credential_sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "endpoint": "endpoint", "links": { "user": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/identity" }, "identity": "identity", "notification_protocol_version": "notification_protocol_version", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "tags": [ "tag" ], "url": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/identity/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(identity="NUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings(sid="BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(identity="NUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings(sid="BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/NUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(identity="NUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings(sid="BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(identity="NUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings.create(binding_type="apn", address="address") values = {'BindingType': "apn", 'Address': "address",} self.holodeck.assert_has_request(Request( 'post', 'https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/NUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "address": "address", "binding_type": "binding_type", "credential_sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "endpoint": "endpoint", "identity": "identity", "links": { "user": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/identity" }, "notification_protocol_version": "notification_protocol_version", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "tags": [ "tag" ], "url": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/identity/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(identity="NUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings.create(binding_type="apn", address="address") self.assertIsNotNone(actual) def test_create_alexa_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "address": "address", "binding_type": "binding_type", "credential_sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "endpoint": "endpoint", "identity": "identity", "links": { "user": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/identity" }, "notification_protocol_version": "notification_protocol_version", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "tags": [ "tag" ], "url": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/identity/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(identity="NUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings.create(binding_type="apn", address="address") self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(identity="NUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings.list() self.holodeck.assert_has_request(Request( 'get', 'https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/NUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "bindings": [], "meta": { "first_page_url": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/identity/Bindings?PageSize=50&Page=0", "key": "bindings", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/identity/Bindings?PageSize=50&Page=0" } } ''' )) actual = self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(identity="NUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "bindings": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "address": "address", "binding_type": "binding_type", "credential_sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "endpoint": "endpoint", "identity": "identity", "links": { "user": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/identity" }, "notification_protocol_version": "notification_protocol_version", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "tags": [ "tag" ], "url": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/identity/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "meta": { "first_page_url": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/identity/Bindings?PageSize=50&Page=0", "key": "bindings", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/identity/Bindings?PageSize=50&Page=0" } } ''' )) actual = self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .users(identity="NUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .bindings.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/notify/v1/test_credential.py000066400000000000000000000152441317472742600254460ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class CredentialTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.notify.v1.credentials.list() self.holodeck.assert_has_request(Request( 'get', 'https://notify.twilio.com/v1/Credentials', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "credentials": [ { "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Test slow create", "type": "apn", "sandbox": "False", "date_created": "2015-10-07T17:50:01Z", "date_updated": "2015-10-07T17:50:01Z", "url": "https://notify.twilio.com/v1/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "meta": { "page": 0, "page_size": 1, "first_page_url": "https://notify.twilio.com/v1/Credentials?PageSize=1&Page=0", "previous_page_url": null, "url": "https://notify.twilio.com/v1/Credentials?PageSize=1&Page=0", "next_page_url": null, "key": "credentials" } } ''' )) actual = self.client.notify.v1.credentials.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "credentials": [], "meta": { "page": 0, "page_size": 1, "first_page_url": "https://notify.twilio.com/v1/Credentials?PageSize=1&Page=0", "previous_page_url": null, "url": "https://notify.twilio.com/v1/Credentials?PageSize=1&Page=0", "next_page_url": null, "key": "credentials" } } ''' )) actual = self.client.notify.v1.credentials.list() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.notify.v1.credentials.create(type="gcm") values = {'Type': "gcm",} self.holodeck.assert_has_request(Request( 'post', 'https://notify.twilio.com/v1/Credentials', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Test slow create", "type": "apn", "sandbox": "False", "date_created": "2015-10-07T17:50:01Z", "date_updated": "2015-10-07T17:50:01Z", "url": "https://notify.twilio.com/v1/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.notify.v1.credentials.create(type="gcm") self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.notify.v1.credentials(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://notify.twilio.com/v1/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Test slow create", "type": "apn", "sandbox": "False", "date_created": "2015-10-07T17:50:01Z", "date_updated": "2015-10-07T17:50:01Z", "url": "https://notify.twilio.com/v1/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.notify.v1.credentials(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.notify.v1.credentials(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://notify.twilio.com/v1/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Test slow create", "type": "apn", "sandbox": "False", "date_created": "2015-10-07T17:50:01Z", "date_updated": "2015-10-07T17:50:01Z", "url": "https://notify.twilio.com/v1/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.notify.v1.credentials(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.notify.v1.credentials(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://notify.twilio.com/v1/Credentials/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.notify.v1.credentials(sid="CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) twilio-python-6.8.2/tests/integration/notify/v1/test_service.py000066400000000000000000000253071317472742600247750ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class ServiceTestCase(IntegrationTestCase): def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.notify.v1.services.create() self.holodeck.assert_has_request(Request( 'post', 'https://notify.twilio.com/v1/Services', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "733c7f0f-6541-42ec-84ce-e2ae1cac588c", "date_created": "2016-03-09T20:22:31Z", "date_updated": "2016-03-09T20:22:31Z", "apn_credential_sid": null, "gcm_credential_sid": null, "fcm_credential_sid": null, "messaging_service_sid": null, "facebook_messenger_page_id": "4", "alexa_skill_id": null, "default_apn_notification_protocol_version": "3", "default_gcm_notification_protocol_version": "3", "default_fcm_notification_protocol_version": "3", "default_alexa_notification_protocol_version": "3", "log_enabled": true, "url": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "bindings": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings", "notifications": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications", "segments": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Segments", "users": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users" } } ''' )) actual = self.client.notify.v1.services.create() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "733c7f0f-6541-42ec-84ce-e2ae1cac588c", "date_created": "2016-03-09T20:22:31Z", "date_updated": "2016-03-09T20:22:31Z", "apn_credential_sid": null, "gcm_credential_sid": null, "fcm_credential_sid": null, "messaging_service_sid": null, "facebook_messenger_page_id": "4", "alexa_skill_id": null, "default_apn_notification_protocol_version": "3", "default_gcm_notification_protocol_version": "3", "default_fcm_notification_protocol_version": "3", "default_alexa_notification_protocol_version": "3", "log_enabled": true, "url": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "bindings": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings", "notifications": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications", "segments": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Segments", "users": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users" } } ''' )) actual = self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.notify.v1.services.list() self.holodeck.assert_has_request(Request( 'get', 'https://notify.twilio.com/v1/Services', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://notify.twilio.com/v1/Services?PageSize=50&Page=0", "previous_page_url": null, "url": "https://notify.twilio.com/v1/Services?PageSize=50&Page=0", "next_page_url": null, "key": "services" }, "services": [ { "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "733c7f0f-6541-42ec-84ce-e2ae1cac588c", "date_created": "2016-03-09T20:22:31Z", "date_updated": "2016-03-09T20:22:31Z", "apn_credential_sid": null, "gcm_credential_sid": null, "fcm_credential_sid": null, "messaging_service_sid": null, "facebook_messenger_page_id": "4", "alexa_skill_id": null, "default_apn_notification_protocol_version": "3", "default_gcm_notification_protocol_version": "3", "default_fcm_notification_protocol_version": "3", "default_alexa_notification_protocol_version": "3", "log_enabled": true, "url": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "bindings": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings", "notifications": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications", "segments": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Segments", "users": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users" } } ] } ''' )) actual = self.client.notify.v1.services.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://notify.twilio.com/v1/Services?PageSize=50&Page=0", "previous_page_url": null, "url": "https://notify.twilio.com/v1/Services?PageSize=50&Page=0", "next_page_url": null, "key": "services" }, "services": [] } ''' )) actual = self.client.notify.v1.services.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "733c7f0f-6541-42ec-84ce-e2ae1cac588c", "date_created": "2016-03-09T20:22:31Z", "date_updated": "2016-03-09T20:22:31Z", "apn_credential_sid": null, "gcm_credential_sid": null, "fcm_credential_sid": null, "default_apn_notification_protocol_version": "3", "default_gcm_notification_protocol_version": "3", "default_fcm_notification_protocol_version": "3", "default_alexa_notification_protocol_version": "3", "messaging_service_sid": null, "alexa_skill_id": null, "facebook_messenger_page_id": "4", "log_enabled": true, "url": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "bindings": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings", "notifications": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications", "segments": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Segments", "users": "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users" } } ''' )) actual = self.client.notify.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/preview/000077500000000000000000000000001317472742600215405ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/preview/__init__.py000066400000000000000000000001701317472742600236470ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/preview/acc_security/000077500000000000000000000000001317472742600242155ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/preview/acc_security/__init__.py000066400000000000000000000001701317472742600263240ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/preview/acc_security/service/000077500000000000000000000000001317472742600256555ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/preview/acc_security/service/__init__.py000066400000000000000000000001701317472742600277640ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/preview/acc_security/service/test_verification.py000066400000000000000000000034111317472742600317470ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class VerificationTestCase(IntegrationTestCase): def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.acc_security.services(sid="VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .verifications.create(to="to", channel="channel") values = {'To': "to", 'Channel': "channel",} self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/Verification/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Verifications', data=values, )) def test_create_verification_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "VEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "to": "+14159373912", "channel": "sms", "status": "pending", "valid": null, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z" } ''' )) actual = self.client.preview.acc_security.services(sid="VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .verifications.create(to="to", channel="channel") self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/preview/acc_security/service/test_verification_check.py000066400000000000000000000033601317472742600331070ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class VerificationCheckTestCase(IntegrationTestCase): def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.acc_security.services(sid="VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .verification_checks.create(code="code") values = {'Code': "code",} self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/Verification/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/VerificationCheck', data=values, )) def test_verification_checks_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "VEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "to": "+14159373912", "channel": "sms", "status": "approved", "valid": false, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z" } ''' )) actual = self.client.preview.acc_security.services(sid="VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .verification_checks.create(code="code") self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/preview/acc_security/test_service.py000066400000000000000000000151041317472742600272670ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class ServiceTestCase(IntegrationTestCase): def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.acc_security.services.create(name="name") values = {'Name': "name",} self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/Verification/Services', data=values, )) def test_create_record_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "name": "name", "code_length": 4, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "url": "https://preview.twilio.com/Verification/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "verification_checks": "https://preview.twilio.com/Verification/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/VerificationCheck", "verifications": "https://preview.twilio.com/Verification/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Verifications" } } ''' )) actual = self.client.preview.acc_security.services.create(name="name") self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.acc_security.services(sid="VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/Verification/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_record_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "name": "name", "code_length": 4, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "url": "https://preview.twilio.com/Verification/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "verification_checks": "https://preview.twilio.com/Verification/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/VerificationCheck", "verifications": "https://preview.twilio.com/Verification/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Verifications" } } ''' )) actual = self.client.preview.acc_security.services(sid="VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.acc_security.services.list() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/Verification/Services', )) def test_read_all_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://preview.twilio.com/Verification/Services?PageSize=50&Page=0", "previous_page_url": null, "next_page_url": null, "key": "services", "url": "https://preview.twilio.com/Verification/Services?PageSize=50&Page=0" }, "services": [ { "sid": "VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "name": "name", "code_length": 4, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "url": "https://preview.twilio.com/Verification/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "verification_checks": "https://preview.twilio.com/Verification/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/VerificationCheck", "verifications": "https://preview.twilio.com/Verification/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Verifications" } } ] } ''' )) actual = self.client.preview.acc_security.services.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.acc_security.services(sid="VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/Verification/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_record_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "name": "name", "code_length": 4, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "url": "https://preview.twilio.com/Verification/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "verification_checks": "https://preview.twilio.com/Verification/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/VerificationCheck", "verifications": "https://preview.twilio.com/Verification/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Verifications" } } ''' )) actual = self.client.preview.acc_security.services(sid="VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/preview/bulk_exports/000077500000000000000000000000001317472742600242615ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/preview/bulk_exports/__init__.py000066400000000000000000000001701317472742600263700ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/preview/bulk_exports/export/000077500000000000000000000000001317472742600256025ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/preview/bulk_exports/export/__init__.py000066400000000000000000000001701317472742600277110ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/preview/bulk_exports/export/test_day.py000066400000000000000000000034051317472742600277720ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class DayTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.bulk_exports.exports(resource_type="resource_type") \ .days.list() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/BulkExports/Exports/resource_type/Days', )) def test_read_response(self): self.holodeck.mock(Response( 200, ''' { "days": [ { "day": "2017-05-01", "size": 1234, "resource_type": "Calls" } ], "meta": { "key": "days", "page_size": 50, "url": "https://preview.twilio.com/BulkExports/Exports/Calls/Days?PageSize=50&Page=0", "page": 0, "first_page_url": "https://preview.twilio.com/BulkExports/Exports/Calls/Days?PageSize=50&Page=0", "previous_page_url": null, "next_page_url": null } } ''' )) actual = self.client.preview.bulk_exports.exports(resource_type="resource_type") \ .days.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/preview/bulk_exports/test_export.py000066400000000000000000000023561317472742600272210ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class ExportTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.bulk_exports.exports(resource_type="resource_type").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/BulkExports/Exports/resource_type', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "resource_type": "Calls", "url": "https://preview.twilio.com/BulkExports/Exports/Calls", "links": { "days": "https://preview.twilio.com/BulkExports/Exports/Calls/Days" } } ''' )) actual = self.client.preview.bulk_exports.exports(resource_type="resource_type").fetch() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/preview/bulk_exports/test_export_configuration.py000066400000000000000000000043271317472742600321500ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class ExportConfigurationTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.bulk_exports.export_configuration(resource_type="resource_type").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/BulkExports/Exports/resource_type/Configuration', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "url": "https://preview.twilio.com/BulkExports/Exports/Calls/Configuration", "enabled": true, "webhook_url": "", "webhook_method": "", "resource_type": "Calls" } ''' )) actual = self.client.preview.bulk_exports.export_configuration(resource_type="resource_type").fetch() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.bulk_exports.export_configuration(resource_type="resource_type").update() self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/BulkExports/Exports/resource_type/Configuration', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "url": "https://preview.twilio.com/BulkExports/Exports/Calls/Configuration", "enabled": true, "webhook_url": "", "resource_type": "Calls", "webhook_method": "" } ''' )) actual = self.client.preview.bulk_exports.export_configuration(resource_type="resource_type").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/preview/deployed_devices/000077500000000000000000000000001317472742600250475ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/preview/deployed_devices/__init__.py000066400000000000000000000001701317472742600271560ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/preview/deployed_devices/fleet/000077500000000000000000000000001317472742600261465ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/preview/deployed_devices/fleet/__init__.py000066400000000000000000000001701317472742600302550ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/preview/deployed_devices/fleet/test_certificate.py000066400000000000000000000221761317472742600320510ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class CertificateTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .certificates(sid="CYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Certificates/CYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "CYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "fleet_sid": "FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "device_sid": "THaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "thumbprint": "1234567890", "date_created": "2016-07-30T20:00:00Z", "date_updated": null, "url": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Certificates/CYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .certificates(sid="CYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .certificates(sid="CYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Certificates/CYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .certificates(sid="CYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .certificates.create(certificate_data="certificate_data") values = {'CertificateData': "certificate_data",} self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Certificates', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "CYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "fleet_sid": "FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "device_sid": "THaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "thumbprint": "1234567890", "date_created": "2016-07-30T20:00:00Z", "date_updated": null, "url": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Certificates/CYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .certificates.create(certificate_data="certificate_data") self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .certificates.list() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Certificates', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "certificates": [], "meta": { "first_page_url": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Certificates?PageSize=50&Page=0", "key": "certificates", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Certificates?PageSize=50&Page=0" } } ''' )) actual = self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .certificates.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "certificates": [ { "sid": "CYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "fleet_sid": "FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "device_sid": "THaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "thumbprint": "1234567890", "date_created": "2016-07-30T20:00:00Z", "date_updated": null, "url": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Certificates/CYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "meta": { "first_page_url": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Certificates?PageSize=50&Page=0", "key": "certificates", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Certificates?PageSize=50&Page=0" } } ''' )) actual = self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .certificates.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .certificates(sid="CYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Certificates/CYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "CYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "fleet_sid": "FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "device_sid": "THaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "thumbprint": "1234567890", "date_created": "2016-07-30T20:00:00Z", "date_updated": "2016-07-30T20:00:00Z", "url": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Certificates/CYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .certificates(sid="CYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/preview/deployed_devices/fleet/test_deployment.py000066400000000000000000000215351317472742600317450ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class DeploymentTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .deployments(sid="DLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Deployments/DLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "DLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "fleet_sid": "FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sync_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-07-30T20:00:00Z", "date_updated": "2016-07-30T20:00:00Z", "url": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Deployments/DLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .deployments(sid="DLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .deployments(sid="DLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Deployments/DLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .deployments(sid="DLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .deployments.create() self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Deployments', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "DLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "fleet_sid": "FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sync_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-07-30T20:00:00Z", "date_updated": "2016-07-30T20:00:00Z", "url": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Deployments/DLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .deployments.create() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .deployments.list() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Deployments', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "deployments": [], "meta": { "first_page_url": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Deployments?PageSize=50&Page=0", "key": "deployments", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Deployments?PageSize=50&Page=0" } } ''' )) actual = self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .deployments.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "deployments": [ { "sid": "DLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "fleet_sid": "FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sync_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-07-30T20:00:00Z", "date_updated": "2016-07-30T20:00:00Z", "url": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Deployments/DLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "meta": { "first_page_url": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Deployments?PageSize=50&Page=0", "key": "deployments", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Deployments?PageSize=50&Page=0" } } ''' )) actual = self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .deployments.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .deployments(sid="DLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Deployments/DLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "DLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "fleet_sid": "FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sync_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-07-30T20:00:00Z", "date_updated": "2016-07-30T20:00:00Z", "url": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Deployments/DLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .deployments(sid="DLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/preview/deployed_devices/fleet/test_device.py000066400000000000000000000226451317472742600310270ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class DeviceTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .devices(sid="THaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Devices/THaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "THaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "friendly_name": "friendly_name", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "fleet_sid": "FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "enabled": true, "deployment_sid": "DLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "bob@twilio.com", "date_created": "2016-07-30T20:00:00Z", "date_updated": "2016-07-30T20:00:00Z", "date_authenticated": null, "url": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Devices/THaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .devices(sid="THaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .devices(sid="THaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Devices/THaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .devices(sid="THaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .devices.create() self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Devices', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "THaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "friendly_name": "friendly_name", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "fleet_sid": "FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "enabled": true, "deployment_sid": "DLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "bob@twilio.com", "date_created": "2016-07-30T20:00:00Z", "date_updated": "2016-07-30T20:00:00Z", "date_authenticated": null, "url": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Devices/THaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .devices.create() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .devices.list() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Devices', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "devices": [], "meta": { "first_page_url": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Devices?PageSize=50&Page=0", "key": "devices", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Devices?PageSize=50&Page=0" } } ''' )) actual = self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .devices.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "devices": [ { "sid": "THaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "friendly_name": "friendly_name", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "enabled": true, "fleet_sid": "FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "deployment_sid": "DLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "bob@twilio.com", "date_created": "2016-07-30T20:00:00Z", "date_updated": "2016-07-30T20:00:00Z", "date_authenticated": null, "url": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Devices/THaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "meta": { "first_page_url": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Devices?PageSize=50&Page=0", "key": "devices", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Devices?PageSize=50&Page=0" } } ''' )) actual = self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .devices.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .devices(sid="THaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Devices/THaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "THaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "friendly_name": "friendly_name", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "fleet_sid": "FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "enabled": true, "deployment_sid": "DLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "bob@twilio.com", "date_created": "2016-07-30T20:00:00Z", "date_updated": "2016-07-30T20:00:00Z", "date_authenticated": null, "url": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Devices/THaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .devices(sid="THaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/preview/deployed_devices/fleet/test_key.py000066400000000000000000000213361317472742600303540ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class KeyTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .keys(sid="KYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Keys/KYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "KYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "fleet_sid": "FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "device_sid": "THaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "secret": null, "date_created": "2016-07-30T20:00:00Z", "date_updated": null, "url": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Keys/KYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .keys(sid="KYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .keys(sid="KYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Keys/KYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .keys(sid="KYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .keys.create() self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Keys', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "KYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "fleet_sid": "FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "device_sid": "THaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "secret": null, "date_created": "2016-07-30T20:00:00Z", "date_updated": null, "url": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Keys/KYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .keys.create() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .keys.list() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Keys', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "keys": [], "meta": { "first_page_url": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Keys?PageSize=50&Page=0", "key": "keys", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Keys?PageSize=50&Page=0" } } ''' )) actual = self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .keys.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "keys": [ { "sid": "KYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "fleet_sid": "FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "device_sid": "THaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "secret": null, "date_created": "2016-07-30T20:00:00Z", "date_updated": "2016-07-30T20:00:00Z", "url": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Keys/KYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "meta": { "first_page_url": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Keys?PageSize=50&Page=0", "key": "keys", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Keys?PageSize=50&Page=0" } } ''' )) actual = self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .keys.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .keys(sid="KYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Keys/KYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "KYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "fleet_sid": "FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "device_sid": "THaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "secret": null, "date_created": "2016-07-30T20:00:00Z", "date_updated": "2016-07-30T20:00:00Z", "url": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Keys/KYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .keys(sid="KYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/preview/deployed_devices/test_fleet.py000066400000000000000000000223441317472742600275640ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class FleetTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "friendly_name": "friendly_name", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_deployment_sid": "DLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-07-30T20:00:00Z", "date_updated": "2016-07-30T20:00:00Z", "url": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "devices": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Devices", "deployments": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Deployments", "certificates": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Certificates", "keys": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Keys" } } ''' )) actual = self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.deployed_devices.fleets.create() self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/DeployedDevices/Fleets', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "friendly_name": "friendly_name", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_deployment_sid": "DLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-07-30T20:00:00Z", "date_updated": null, "url": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "devices": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Devices", "deployments": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Deployments", "certificates": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Certificates", "keys": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Keys" } } ''' )) actual = self.client.preview.deployed_devices.fleets.create() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.deployed_devices.fleets.list() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/DeployedDevices/Fleets', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "fleets": [], "meta": { "first_page_url": "https://preview.twilio.com/DeployedDevices/Fleets?PageSize=50&Page=0", "key": "fleets", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/DeployedDevices/Fleets?PageSize=50&Page=0" } } ''' )) actual = self.client.preview.deployed_devices.fleets.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "fleets": [ { "sid": "FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "friendly_name": "friendly_name", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_deployment_sid": "DLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-07-30T20:00:00Z", "date_updated": null, "url": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "devices": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Devices", "deployments": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Deployments", "certificates": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Certificates", "keys": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Keys" } } ], "meta": { "first_page_url": "https://preview.twilio.com/DeployedDevices/Fleets?PageSize=50&Page=0", "key": "fleets", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/DeployedDevices/Fleets?PageSize=50&Page=0" } } ''' )) actual = self.client.preview.deployed_devices.fleets.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "friendly_name": "friendly_name", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "default_deployment_sid": "DLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-07-30T20:00:00Z", "date_updated": "2016-07-30T20:00:00Z", "url": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "devices": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Devices", "deployments": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Deployments", "certificates": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Certificates", "keys": "https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Keys" } } ''' )) actual = self.client.preview.deployed_devices.fleets(sid="FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/preview/hosted_numbers/000077500000000000000000000000001317472742600245615ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/preview/hosted_numbers/__init__.py000066400000000000000000000001701317472742600266700ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/preview/hosted_numbers/test_authorization_document.py000066400000000000000000000164031317472742600327740ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class AuthorizationDocumentTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.hosted_numbers.authorization_documents(sid="PXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/HostedNumbers/AuthorizationDocuments/PXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "address_sid": "AD11111111111111111111111111111111", "cc_emails": [ "aaa@twilio.com", "bbb@twilio.com" ], "date_created": "2017-03-28T20:06:39Z", "date_updated": "2017-03-28T20:06:39Z", "email": "test@twilio.com", "sid": "PXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "signing", "url": "https://preview.twilio.com/HostedNumbers/AuthorizationDocuments/PXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.hosted_numbers.authorization_documents(sid="PXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.hosted_numbers.authorization_documents(sid="PXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/HostedNumbers/AuthorizationDocuments/PXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "address_sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "cc_emails": [ "test1@twilio.com", "test2@twilio.com" ], "date_created": "2017-03-28T20:06:39Z", "date_updated": "2017-03-28T20:06:39Z", "email": "test+hosted@twilio.com", "sid": "PXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "signing", "url": "https://preview.twilio.com/HostedNumbers/AuthorizationDocuments/PXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.hosted_numbers.authorization_documents(sid="PXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.hosted_numbers.authorization_documents.list() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/HostedNumbers/AuthorizationDocuments', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://preview.twilio.com/HostedNumbers/AuthorizationDocuments?PageSize=50&Page=0", "key": "items", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/HostedNumbers/AuthorizationDocuments?PageSize=50&Page=0" }, "items": [] } ''' )) actual = self.client.preview.hosted_numbers.authorization_documents.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://preview.twilio.com/HostedNumbers/AuthorizationDocuments?PageSize=50&Page=0", "key": "items", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/HostedNumbers/AuthorizationDocuments?PageSize=50&Page=0" }, "items": [ { "address_sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "cc_emails": [ "test1@twilio.com", "test2@twilio.com" ], "date_created": "2017-03-28T20:06:39Z", "date_updated": "2017-03-28T20:06:39Z", "email": "test+hosted@twilio.com", "sid": "PXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "signing", "url": "https://preview.twilio.com/HostedNumbers/AuthorizationDocuments/PXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.preview.hosted_numbers.authorization_documents.list() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.hosted_numbers.authorization_documents.create(hosted_number_order_sids=['hosted_number_order_sids'], address_sid="ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", email="email") values = { 'HostedNumberOrderSids': ['hosted_number_order_sids'], 'AddressSid': "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 'Email': "email", } self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/HostedNumbers/AuthorizationDocuments', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "address_sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "cc_emails": [ "test1@twilio.com", "test2@twilio.com" ], "date_created": "2017-03-28T20:06:39Z", "date_updated": "2017-03-28T20:06:39Z", "email": "test+hosted@twilio.com", "sid": "PXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "signing", "url": "https://preview.twilio.com/HostedNumbers/AuthorizationDocuments/PXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.hosted_numbers.authorization_documents.create(hosted_number_order_sids=['hosted_number_order_sids'], address_sid="ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", email="email") self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/preview/hosted_numbers/test_hosted_number_order.py000066400000000000000000000260151317472742600322270ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class HostedNumberOrderTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.hosted_numbers.hosted_number_orders(sid="HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/HostedNumbers/HostedNumberOrders/HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "address_sid": "AD11111111111111111111111111111111", "capabilities": { "sms": true, "voice": false }, "cc_emails": [ "aaa@twilio.com", "bbb@twilio.com" ], "date_created": "2017-03-28T20:06:39Z", "date_updated": "2017-03-28T20:06:39Z", "email": "test@twilio.com", "friendly_name": "friendly_name", "incoming_phone_number_sid": "PN11111111111111111111111111111111", "phone_number": "+14153608311", "sid": "HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "signing_document_sid": "PX11111111111111111111111111111111", "status": "received", "unique_name": "foobar", "url": "https://preview.twilio.com/HostedNumbers/HostedNumberOrders/HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "verification_attempts": 0 } ''' )) actual = self.client.preview.hosted_numbers.hosted_number_orders(sid="HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.hosted_numbers.hosted_number_orders(sid="HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://preview.twilio.com/HostedNumbers/HostedNumberOrders/HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.preview.hosted_numbers.hosted_number_orders(sid="HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.hosted_numbers.hosted_number_orders(sid="HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/HostedNumbers/HostedNumberOrders/HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "address_sid": "AD11111111111111111111111111111111", "capabilities": { "sms": true, "voice": false }, "cc_emails": [ "test1@twilio.com", "test2@twilio.com" ], "date_created": "2017-03-28T20:06:39Z", "date_updated": "2017-03-28T20:06:39Z", "email": "test+hosted@twilio.com", "friendly_name": "new friendly name", "incoming_phone_number_sid": "PN11111111111111111111111111111111", "phone_number": "+14153608311", "sid": "HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "signing_document_sid": "PX11111111111111111111111111111111", "status": "pending-loa", "unique_name": "new unique name", "url": "https://preview.twilio.com/HostedNumbers/HostedNumberOrders/HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "verification_attempts": 1 } ''' )) actual = self.client.preview.hosted_numbers.hosted_number_orders(sid="HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.hosted_numbers.hosted_number_orders.list() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/HostedNumbers/HostedNumberOrders', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://preview.twilio.com/HostedNumbers/HostedNumberOrders?PageSize=50&Page=0", "key": "items", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/HostedNumbers/HostedNumberOrders?PageSize=50&Page=0" }, "items": [] } ''' )) actual = self.client.preview.hosted_numbers.hosted_number_orders.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://preview.twilio.com/HostedNumbers/HostedNumberOrders?PageSize=50&Page=0", "key": "items", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/HostedNumbers/HostedNumberOrders?PageSize=50&Page=0" }, "items": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "address_sid": "AD11111111111111111111111111111111", "capabilities": { "sms": true, "voice": false }, "cc_emails": [ "aaa@twilio.com", "bbb@twilio.com" ], "date_created": "2017-03-28T20:06:39Z", "date_updated": "2017-03-28T20:06:39Z", "email": "test@twilio.com", "friendly_name": "friendly_name", "incoming_phone_number_sid": "PN11111111111111111111111111111111", "phone_number": "+14153608311", "sid": "HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "signing_document_sid": "PX11111111111111111111111111111111", "status": "received", "unique_name": "foobar", "url": "https://preview.twilio.com/HostedNumbers/HostedNumberOrders/HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "verification_attempts": 0 } ] } ''' )) actual = self.client.preview.hosted_numbers.hosted_number_orders.list() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.hosted_numbers.hosted_number_orders.create(phone_number="+987654321", iso_country="iso_country", sms_capability=True) values = {'PhoneNumber': "+987654321", 'IsoCountry': "iso_country", 'SmsCapability': True,} self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/HostedNumbers/HostedNumberOrders', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "address_sid": "AD11111111111111111111111111111111", "capabilities": { "sms": true, "voice": false }, "cc_emails": [], "date_created": "2017-03-28T20:06:39Z", "date_updated": "2017-03-28T20:06:39Z", "email": "test@twilio.com", "friendly_name": null, "incoming_phone_number_sid": "PN11111111111111111111111111111111", "phone_number": "+14153608311", "sid": "HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "signing_document_sid": null, "status": "received", "unique_name": null, "url": "https://preview.twilio.com/HostedNumbers/HostedNumberOrders/HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "verification_attempts": 0 } ''' )) actual = self.client.preview.hosted_numbers.hosted_number_orders.create(phone_number="+987654321", iso_country="iso_country", sms_capability=True) self.assertIsNotNone(actual) def test_create_without_optional_loa_fields_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "address_sid": null, "capabilities": { "sms": true, "voice": false }, "cc_emails": [], "date_created": "2017-03-28T20:06:39Z", "date_updated": "2017-03-28T20:06:39Z", "email": null, "friendly_name": null, "incoming_phone_number_sid": "PN11111111111111111111111111111111", "phone_number": "+14153608311", "sid": "HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "signing_document_sid": null, "status": "received", "unique_name": null, "url": "https://preview.twilio.com/HostedNumbers/HostedNumberOrders/HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "verification_attempts": 0 } ''' )) actual = self.client.preview.hosted_numbers.hosted_number_orders.create(phone_number="+987654321", iso_country="iso_country", sms_capability=True) self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/preview/marketplace/000077500000000000000000000000001317472742600240305ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/preview/marketplace/__init__.py000066400000000000000000000001701317472742600261370ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/preview/marketplace/available_add_on/000077500000000000000000000000001317472742600272545ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/preview/marketplace/available_add_on/__init__.py000066400000000000000000000001701317472742600313630ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ test_available_add_on_extension.py000066400000000000000000000113041317472742600361250ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/preview/marketplace/available_add_on# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class AvailableAddOnExtensionTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.marketplace.available_add_ons(sid="XBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .extensions(sid="XFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/marketplace/AvailableAddOns/XBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Extensions/XFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "XFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "available_add_on_sid": "XBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Incoming Voice Call", "product_name": "Programmable Voice", "unique_name": "voice-incoming", "url": "https://preview.twilio.com/marketplace/AvailableAddOns/XBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Extensions/XFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.marketplace.available_add_ons(sid="XBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .extensions(sid="XFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.marketplace.available_add_ons(sid="XBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .extensions.list() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/marketplace/AvailableAddOns/XBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Extensions', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "extensions": [ { "sid": "XFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "available_add_on_sid": "XBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Incoming Voice Call", "product_name": "Programmable Voice", "unique_name": "voice-incoming", "url": "https://preview.twilio.com/marketplace/AvailableAddOns/XBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Extensions/XFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "meta": { "page": 0, "page_size": 50, "first_page_url": "https://preview.twilio.com/marketplace/AvailableAddOns/XBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Extensions?PageSize=50&Page=0", "previous_page_url": null, "url": "https://preview.twilio.com/marketplace/AvailableAddOns/XBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Extensions?PageSize=50&Page=0", "next_page_url": null, "key": "extensions" } } ''' )) actual = self.client.preview.marketplace.available_add_ons(sid="XBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .extensions.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "extensions": [], "meta": { "page": 0, "page_size": 50, "first_page_url": "https://preview.twilio.com/marketplace/AvailableAddOns/XBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Extensions?PageSize=50&Page=0", "previous_page_url": null, "url": "https://preview.twilio.com/marketplace/AvailableAddOns/XBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Extensions?PageSize=50&Page=0", "next_page_url": null, "key": "extensions" } } ''' )) actual = self.client.preview.marketplace.available_add_ons(sid="XBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .extensions.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/preview/marketplace/installed_add_on/000077500000000000000000000000001317472742600273135ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/preview/marketplace/installed_add_on/__init__.py000066400000000000000000000001701317472742600314220ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ test_installed_add_on_extension.py000066400000000000000000000144711317472742600362330ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/preview/marketplace/installed_add_on# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class InstalledAddOnExtensionTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.marketplace.installed_add_ons(sid="XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .extensions(sid="XFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/marketplace/InstalledAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Extensions/XFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "XFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "installed_add_on_sid": "XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Incoming Voice Call", "product_name": "Programmable Voice", "unique_name": "voice-incoming", "enabled": true, "url": "https://preview.twilio.com/marketplace/InstalledAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Extensions/XFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.marketplace.installed_add_ons(sid="XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .extensions(sid="XFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.marketplace.installed_add_ons(sid="XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .extensions(sid="XFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update(enabled=True) values = {'Enabled': True,} self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/marketplace/InstalledAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Extensions/XFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', data=values, )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "XFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "installed_add_on_sid": "XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Incoming Voice Call", "product_name": "Programmable Voice", "unique_name": "voice-incoming", "enabled": false, "url": "https://preview.twilio.com/marketplace/InstalledAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Extensions/XFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.marketplace.installed_add_ons(sid="XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .extensions(sid="XFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update(enabled=True) self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.marketplace.installed_add_ons(sid="XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .extensions.list() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/marketplace/InstalledAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Extensions', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "extensions": [ { "sid": "XFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "installed_add_on_sid": "XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Incoming Voice Call", "product_name": "Programmable Voice", "unique_name": "voice-incoming", "enabled": true, "url": "https://preview.twilio.com/marketplace/InstalledAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Extensions/XFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "meta": { "page": 0, "page_size": 50, "first_page_url": "https://preview.twilio.com/marketplace/InstalledAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Extensions?PageSize=50&Page=0", "previous_page_url": null, "url": "https://preview.twilio.com/marketplace/InstalledAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Extensions?PageSize=50&Page=0", "next_page_url": null, "key": "extensions" } } ''' )) actual = self.client.preview.marketplace.installed_add_ons(sid="XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .extensions.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "extensions": [], "meta": { "page": 0, "page_size": 50, "first_page_url": "https://preview.twilio.com/marketplace/InstalledAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Extensions?PageSize=50&Page=0", "previous_page_url": null, "url": "https://preview.twilio.com/marketplace/InstalledAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Extensions?PageSize=50&Page=0", "next_page_url": null, "key": "extensions" } } ''' )) actual = self.client.preview.marketplace.installed_add_ons(sid="XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .extensions.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/preview/marketplace/test_available_add_on.py000066400000000000000000000117111317472742600306660ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class AvailableAddOnTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.marketplace.available_add_ons(sid="XBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/marketplace/AvailableAddOns/XBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "XBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "VoiceBase High Accuracy Transcription", "description": "Automatic Transcription and Keyword Extract...", "pricing_type": "per minute", "configuration_schema": { "type": "object", "properties": { "bad_words": { "type": "boolean" } }, "required": [ "bad_words" ] }, "url": "https://preview.twilio.com/marketplace/AvailableAddOns/XBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "extensions": "https://preview.twilio.com/marketplace/AvailableAddOns/XBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Extensions" } } ''' )) actual = self.client.preview.marketplace.available_add_ons(sid="XBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.marketplace.available_add_ons.list() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/marketplace/AvailableAddOns', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "available_add_ons": [ { "sid": "XBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "VoiceBase High Accuracy Transcription", "description": "Automatic Transcription and Keyword Extract...", "pricing_type": "per minute", "configuration_schema": { "type": "object", "properties": { "bad_words": { "type": "boolean" } }, "required": [ "bad_words" ] }, "url": "https://preview.twilio.com/marketplace/AvailableAddOns/XBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "extensions": "https://preview.twilio.com/marketplace/AvailableAddOns/XBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Extensions" } } ], "meta": { "page": 0, "page_size": 50, "first_page_url": "https://preview.twilio.com/marketplace/AvailableAddOns?PageSize=50&Page=0", "previous_page_url": null, "url": "https://preview.twilio.com/marketplace/AvailableAddOns?PageSize=50&Page=0", "next_page_url": null, "key": "available_add_ons" } } ''' )) actual = self.client.preview.marketplace.available_add_ons.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "available_add_ons": [], "meta": { "page": 0, "page_size": 50, "first_page_url": "https://preview.twilio.com/marketplace/AvailableAddOns?PageSize=50&Page=0", "previous_page_url": null, "url": "https://preview.twilio.com/marketplace/AvailableAddOns?PageSize=50&Page=0", "next_page_url": null, "key": "available_add_ons" } } ''' )) actual = self.client.preview.marketplace.available_add_ons.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/preview/marketplace/test_installed_add_on.py000066400000000000000000000225301317472742600307260ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class InstalledAddOnTestCase(IntegrationTestCase): def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.marketplace.installed_add_ons.create(available_add_on_sid="XBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", accept_terms_of_service=True) values = {'AvailableAddOnSid': "XBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 'AcceptTermsOfService': True,} self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/marketplace/InstalledAddOns', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "VoiceBase High Accuracy Transcription", "description": "Automatic Transcription and Keyword Extract...", "configuration": { "bad_words": true }, "unique_name": "voicebase_high_accuracy_transcription_1", "date_created": "2016-04-07T23:52:28Z", "date_updated": "2016-04-07T23:52:28Z", "url": "https://preview.twilio.com/marketplace/InstalledAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "extensions": "https://preview.twilio.com/marketplace/InstalledAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Extensions", "available_add_on": "https://preview.twilio.com/marketplace/AvailableAddOns/XBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } } ''' )) actual = self.client.preview.marketplace.installed_add_ons.create(available_add_on_sid="XBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", accept_terms_of_service=True) self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.marketplace.installed_add_ons(sid="XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://preview.twilio.com/marketplace/InstalledAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.preview.marketplace.installed_add_ons(sid="XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.marketplace.installed_add_ons(sid="XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/marketplace/InstalledAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "VoiceBase High Accuracy Transcription", "description": "Automatic Transcription and Keyword Extract...", "configuration": { "bad_words": true }, "unique_name": "voicebase_high_accuracy_transcription", "date_created": "2016-04-07T23:52:28Z", "date_updated": "2016-04-07T23:52:28Z", "url": "https://preview.twilio.com/marketplace/InstalledAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "extensions": "https://preview.twilio.com/marketplace/InstalledAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Extensions", "available_add_on": "https://preview.twilio.com/marketplace/AvailableAddOns/XBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } } ''' )) actual = self.client.preview.marketplace.installed_add_ons(sid="XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.marketplace.installed_add_ons(sid="XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/marketplace/InstalledAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "VoiceBase High Accuracy Transcription", "description": "Automatic Transcription and Keyword Extract...", "configuration": { "bad_words": true }, "unique_name": "voicebase_high_accuracy_transcription_2", "date_created": "2016-04-07T23:52:28Z", "date_updated": "2016-04-07T23:52:28Z", "url": "https://preview.twilio.com/marketplace/InstalledAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "extensions": "https://preview.twilio.com/marketplace/InstalledAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Extensions", "available_add_on": "https://preview.twilio.com/marketplace/AvailableAddOns/XBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } } ''' )) actual = self.client.preview.marketplace.installed_add_ons(sid="XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.marketplace.installed_add_ons.list() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/marketplace/InstalledAddOns', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "installed_add_ons": [ { "sid": "XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "VoiceBase High Accuracy Transcription", "description": "Automatic Transcription and Keyword Extract...", "configuration": { "bad_words": true }, "unique_name": "voicebase_high_accuracy_transcription", "date_created": "2016-04-07T23:52:28Z", "date_updated": "2016-04-07T23:52:28Z", "url": "https://preview.twilio.com/marketplace/InstalledAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "extensions": "https://preview.twilio.com/marketplace/InstalledAddOns/XEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Extensions", "available_add_on": "https://preview.twilio.com/marketplace/AvailableAddOns/XBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } } ], "meta": { "page": 0, "page_size": 50, "first_page_url": "https://preview.twilio.com/marketplace/InstalledAddOns?PageSize=50&Page=0", "previous_page_url": null, "url": "https://preview.twilio.com/marketplace/InstalledAddOns?PageSize=50&Page=0", "next_page_url": null, "key": "installed_add_ons" } } ''' )) actual = self.client.preview.marketplace.installed_add_ons.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "installed_add_ons": [], "meta": { "page": 0, "page_size": 50, "first_page_url": "https://preview.twilio.com/marketplace/InstalledAddOns?PageSize=50&Page=0", "previous_page_url": null, "url": "https://preview.twilio.com/marketplace/InstalledAddOns?PageSize=50&Page=0", "next_page_url": null, "key": "installed_add_ons" } } ''' )) actual = self.client.preview.marketplace.installed_add_ons.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/preview/proxy/000077500000000000000000000000001317472742600227215ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/preview/proxy/__init__.py000066400000000000000000000001701317472742600250300ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/preview/proxy/service/000077500000000000000000000000001317472742600243615ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/preview/proxy/service/__init__.py000066400000000000000000000001701317472742600264700ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/preview/proxy/service/session/000077500000000000000000000000001317472742600260445ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/preview/proxy/service/session/__init__.py000066400000000000000000000001701317472742600301530ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/preview/proxy/service/session/participant/000077500000000000000000000000001317472742600303625ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/preview/proxy/service/session/participant/__init__.py000066400000000000000000000001701317472742600324710ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ test_message_interaction.py000066400000000000000000000172561317472742600357520ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/preview/proxy/service/session/participant# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class MessageInteractionTestCase(IntegrationTestCase): def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants(sid="KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .message_interactions.create() self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/MessageInteractions', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "service_sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "data": "body", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "participant_sid": "KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "inbound_participant_sid": null, "inbound_resource_sid": null, "inbound_resource_status": null, "inbound_resource_type": null, "inbound_resource_url": null, "outbound_participant_sid": "KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "outbound_resource_sid": "SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "outbound_resource_status": "sent", "outbound_resource_type": "Message", "outbound_resource_url": null, "sid": "KIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "completed", "url": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/MessageInteractions/KIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "session_sid": "KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants(sid="KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .message_interactions.create() self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants(sid="KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .message_interactions(sid="KIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/MessageInteractions/KIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "service_sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "data": "data", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "participant_sid": "KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "inbound_participant_sid": null, "inbound_resource_sid": null, "inbound_resource_status": null, "inbound_resource_type": null, "inbound_resource_url": null, "outbound_participant_sid": "KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "outbound_resource_sid": "SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "outbound_resource_status": "sent", "outbound_resource_type": "Message", "outbound_resource_url": null, "sid": "KIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "completed", "url": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/MessageInteractions/KIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "session_sid": "KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants(sid="KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .message_interactions(sid="KIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants(sid="KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .message_interactions.list() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/MessageInteractions', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "interactions": [], "meta": { "previous_page_url": null, "next_page_url": null, "url": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/MessageInteractions?PageSize=50&Page=0", "page": 0, "first_page_url": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/MessageInteractions?PageSize=50&Page=0", "page_size": 50, "key": "interactions" } } ''' )) actual = self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants(sid="KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .message_interactions.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/preview/proxy/service/session/test_interaction.py000066400000000000000000000106201317472742600317730ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class InteractionTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .interactions(sid="KIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Interactions/KIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "service_sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "data": "data", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "inbound_participant_sid": "KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "inbound_resource_sid": "SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "inbound_resource_status": "sent", "inbound_resource_type": "Message", "inbound_resource_url": null, "outbound_participant_sid": "KPbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "outbound_resource_sid": "SMbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "outbound_resource_status": "sent", "outbound_resource_type": "Message", "outbound_resource_url": null, "sid": "KIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "completed", "url": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Interactions/KIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "session_sid": "KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .interactions(sid="KIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .interactions.list() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Interactions', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "interactions": [], "meta": { "previous_page_url": null, "next_page_url": null, "url": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Interactions?PageSize=50&Page=0", "page": 0, "first_page_url": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Interactions?PageSize=50&Page=0", "page_size": 50, "key": "interactions" } } ''' )) actual = self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .interactions.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/preview/proxy/service/session/test_participant.py000066400000000000000000000232231317472742600317750ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class ParticipantTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants(sid="KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "service_sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "participant_type": "sms", "identifier": "identifier", "date_updated": "2015-07-30T20:00:00Z", "proxy_identifier": "proxy_identifier", "friendly_name": "friendly_name", "date_created": "2015-07-30T20:00:00Z", "url": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "message_interactions": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/MessageInteractions" }, "sid": "KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "session_sid": "KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants(sid="KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants.list() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "previous_page_url": null, "next_page_url": null, "url": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants?PageSize=50&Page=0", "page": 0, "first_page_url": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants?PageSize=50&Page=0", "page_size": 50, "key": "participants" }, "participants": [] } ''' )) actual = self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants.list() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants.create(identifier="identifier") values = {'Identifier': "identifier",} self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "service_sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "participant_type": "sms", "identifier": "identifier", "date_updated": "2015-07-30T20:00:00Z", "proxy_identifier": "proxy_identifier", "friendly_name": "friendly_name", "date_created": "2015-07-30T20:00:00Z", "url": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "message_interactions": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/MessageInteractions" }, "sid": "KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "session_sid": "KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants.create(identifier="identifier") self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants(sid="KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants(sid="KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants(sid="KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "service_sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "participant_type": "sms", "identifier": "identifier", "date_updated": "2015-07-30T20:00:00Z", "proxy_identifier": "proxy_identifier", "friendly_name": "friendly_name", "date_created": "2015-07-30T20:00:00Z", "url": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "message_interactions": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/MessageInteractions" }, "sid": "KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "session_sid": "KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants(sid="KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/preview/proxy/service/test_phone_number.py000066400000000000000000000145041317472742600304570ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class PhoneNumberTestCase(IntegrationTestCase): def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .phone_numbers.create(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") values = {'Sid': "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",} self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "phone_number": "+987654321", "country_code": "US", "capabilities": [], "url": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .phone_numbers.create(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .phone_numbers(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .phone_numbers(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .phone_numbers.list() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers?PageSize=50&Page=0", "previous_page_url": null, "next_page_url": null, "key": "phone_numbers", "url": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers?PageSize=50&Page=0" }, "phone_numbers": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "phone_number": "+987654321", "country_code": "US", "capabilities": [], "url": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .phone_numbers.list() self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .phone_numbers(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "phone_number": "12345", "country_code": "US", "capabilities": [], "url": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .phone_numbers(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/preview/proxy/service/test_session.py000066400000000000000000000204551317472742600274630ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class SessionTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "service_sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "in-progess", "unique_name": "unique_name", "start_time": "2015-07-30T20:00:00Z", "links": { "interactions": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Interactions", "participants": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants" }, "ttl": 100, "date_updated": "2015-07-30T20:00:00Z", "date_created": "2015-07-30T20:00:00Z", "end_time": "2015-07-30T20:00:00Z", "url": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions.list() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "sessions": [], "meta": { "previous_page_url": null, "next_page_url": null, "url": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions?PageSize=50&Page=0", "page": 0, "first_page_url": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions?PageSize=50&Page=0", "page_size": 50, "key": "sessions" } } ''' )) actual = self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions.list() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions.create() self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "service_sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "in-progess", "unique_name": "unique_name", "start_time": "2015-07-30T20:00:00Z", "links": { "interactions": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Interactions", "participants": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants" }, "ttl": 100, "date_updated": "2015-07-30T20:00:00Z", "date_created": "2015-07-30T20:00:00Z", "end_time": "2015-07-30T20:00:00Z", "url": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions.create() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "service_sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "in-progess", "unique_name": "unique_name", "start_time": "2015-07-30T20:00:00Z", "links": { "interactions": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Interactions", "participants": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants" }, "ttl": 100, "date_updated": "2015-07-30T20:00:00Z", "date_created": "2015-07-30T20:00:00Z", "end_time": "2015-07-30T20:00:00Z", "url": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/preview/proxy/service/test_short_code.py000066400000000000000000000144141317472742600301270ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class ShortCodeTestCase(IntegrationTestCase): def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .short_codes.create(sid="SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") values = {'Sid': "SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",} self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "short_code": "12345", "country_code": "US", "capabilities": [], "url": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes/SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .short_codes.create(sid="SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .short_codes(sid="SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes/SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .short_codes(sid="SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .short_codes.list() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes?PageSize=50&Page=0", "previous_page_url": null, "next_page_url": null, "key": "short_codes", "url": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes?PageSize=50&Page=0" }, "short_codes": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "short_code": "12345", "country_code": "US", "capabilities": [], "url": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes/SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .short_codes.list() self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .short_codes(sid="SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes/SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "short_code": "12345", "country_code": "US", "capabilities": [], "url": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes/SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .short_codes(sid="SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/preview/proxy/test_service.py000066400000000000000000000151761317472742600260040ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class ServiceTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "friendly_name": "friendly_name", "date_created": "2015-07-30T20:00:00Z", "url": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_updated": "2015-07-30T20:00:00Z", "sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "sessions": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions", "phone_numbers": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers", "short_codes": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes" }, "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "callback_url": "http://www.example.com", "auto_create": false } ''' )) actual = self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.proxy.services.list() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/Proxy/Services', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "previous_page_url": null, "next_page_url": null, "url": "https://preview.twilio.com/Proxy/Services?PageSize=50&Page=0", "page": 0, "first_page_url": "https://preview.twilio.com/Proxy/Services?PageSize=50&Page=0", "page_size": 50, "key": "services" }, "services": [] } ''' )) actual = self.client.preview.proxy.services.list() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.proxy.services.create() self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/Proxy/Services', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "friendly_name": "friendly_name", "date_created": "2015-07-30T20:00:00Z", "url": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_updated": "2015-07-30T20:00:00Z", "sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "sessions": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions", "phone_numbers": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers", "short_codes": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes" }, "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "callback_url": "http://www.example.com", "auto_create": false } ''' )) actual = self.client.preview.proxy.services.create() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "friendly_name": "friendly_name", "date_created": "2015-07-30T20:00:00Z", "url": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_updated": "2015-07-30T20:00:00Z", "sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "sessions": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions", "phone_numbers": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers", "short_codes": "https://preview.twilio.com/Proxy/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes" }, "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "callback_url": "http://www.example.com", "auto_create": false } ''' )) actual = self.client.preview.proxy.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/preview/sync/000077500000000000000000000000001317472742600225145ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/preview/sync/__init__.py000066400000000000000000000001701317472742600246230ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/preview/sync/service/000077500000000000000000000000001317472742600241545ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/preview/sync/service/__init__.py000066400000000000000000000001701317472742600262630ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/preview/sync/service/document/000077500000000000000000000000001317472742600257725ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/preview/sync/service/document/__init__.py000066400000000000000000000001701317472742600301010ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/preview/sync/service/document/test_document_permission.py000066400000000000000000000200611317472742600334700ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class DocumentPermissionTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents(sid="ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .document_permissions(identity="identity").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions/identity', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "document_sid": "ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "identity", "read": true, "write": true, "manage": true, "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions/identity" } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents(sid="ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .document_permissions(identity="identity").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents(sid="ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .document_permissions(identity="identity").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions/identity', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents(sid="ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .document_permissions(identity="identity").delete() self.assertTrue(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents(sid="ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .document_permissions.list() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "permissions": [], "meta": { "first_page_url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/sidOrUniqueName/Permissions?PageSize=50&Page=0", "key": "permissions", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/sidOrUniqueName/Permissions?PageSize=50&Page=0" } } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents(sid="ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .document_permissions.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "permissions": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "document_sid": "ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "identity", "read": true, "write": true, "manage": true, "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions/identity" } ], "meta": { "first_page_url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/sidOrUniqueName/Permissions?PageSize=50&Page=0", "key": "permissions", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/sidOrUniqueName/Permissions?PageSize=50&Page=0" } } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents(sid="ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .document_permissions.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents(sid="ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .document_permissions(identity="identity").update(read=True, write=True, manage=True) values = {'Read': True, 'Write': True, 'Manage': True,} self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions/identity', data=values, )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "document_sid": "ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "identity", "read": true, "write": true, "manage": true, "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions/identity" } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents(sid="ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .document_permissions(identity="identity").update(read=True, write=True, manage=True) self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/preview/sync/service/sync_list/000077500000000000000000000000001317472742600261635ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/preview/sync/service/sync_list/__init__.py000066400000000000000000000001701317472742600302720ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/preview/sync/service/sync_list/test_sync_list_item.py000066400000000000000000000236241317472742600326300ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base import serialize from twilio.base.exceptions import TwilioException from twilio.http.response import Response class SyncListItemTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_items(index=1).fetch() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items/1', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "data": {}, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "index": 100, "list_sid": "ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "revision": "revision", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items/100" } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_items(index=1).fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_items(index=1).delete() self.holodeck.assert_has_request(Request( 'delete', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items/1', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_items(index=1).delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_items.create(data="{}") values = {'Data': serialize.object("{}"),} self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "data": {}, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "index": 100, "list_sid": "ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "revision": "revision", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items/100" } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_items.create(data="{}") self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_items.list() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "items": [], "meta": { "first_page_url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items?PageSize=50&Page=0", "key": "items", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items?PageSize=50&Page=0" } } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_items.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "items": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "data": {}, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "index": 100, "list_sid": "ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "revision": "revision", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items/100" } ], "meta": { "first_page_url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items?PageSize=50&Page=0", "key": "items", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items?PageSize=50&Page=0" } } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_items.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_items(index=1).update(data="{}") values = {'Data': serialize.object("{}"),} self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items/1', data=values, )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "data": {}, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "index": 100, "list_sid": "ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "revision": "revision", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items/100" } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_items(index=1).update(data="{}") self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/preview/sync/service/sync_list/test_sync_list_permission.py000066400000000000000000000200131317472742600340470ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class SyncListPermissionTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_permissions(identity="identity").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions/identity', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "list_sid": "ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "identity", "read": true, "write": true, "manage": true, "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions/identity" } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_permissions(identity="identity").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_permissions(identity="identity").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions/identity', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_permissions(identity="identity").delete() self.assertTrue(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_permissions.list() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "permissions": [], "meta": { "first_page_url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/sidOrUniqueName/Permissions?PageSize=50&Page=0", "key": "permissions", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/sidOrUniqueName/Permissions?PageSize=50&Page=0" } } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_permissions.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "permissions": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "list_sid": "ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "identity", "read": true, "write": true, "manage": true, "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions/identity" } ], "meta": { "first_page_url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/sidOrUniqueName/Permissions?PageSize=50&Page=0", "key": "permissions", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/sidOrUniqueName/Permissions?PageSize=50&Page=0" } } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_permissions.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_permissions(identity="identity").update(read=True, write=True, manage=True) values = {'Read': True, 'Write': True, 'Manage': True,} self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions/identity', data=values, )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "list_sid": "ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "identity", "read": true, "write": true, "manage": true, "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions/identity" } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_permissions(identity="identity").update(read=True, write=True, manage=True) self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/preview/sync/service/sync_map/000077500000000000000000000000001317472742600257655ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/preview/sync/service/sync_map/__init__.py000066400000000000000000000001701317472742600300740ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/preview/sync/service/sync_map/test_sync_map_item.py000066400000000000000000000236421317472742600322340ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base import serialize from twilio.base.exceptions import TwilioException from twilio.http.response import Response class SyncMapItemTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_items(key="key").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items/key', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "data": {}, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "key": "key", "map_sid": "MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "revision": "revision", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items/key" } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_items(key="key").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_items(key="key").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items/key', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_items(key="key").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_items.create(key="key", data="{}") values = {'Key': "key", 'Data': serialize.object("{}"),} self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "data": {}, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "key": "key", "map_sid": "MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "revision": "revision", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items/key" } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_items.create(key="key", data="{}") self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_items.list() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "items": [], "meta": { "first_page_url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items?PageSize=50&Page=0", "key": "items", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items?PageSize=50&Page=0" } } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_items.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "items": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "data": {}, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "key": "key", "map_sid": "MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "revision": "revision", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items/key" } ], "meta": { "first_page_url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items?PageSize=50&Page=0", "key": "items", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items?PageSize=50&Page=0" } } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_items.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_items(key="key").update(data="{}") values = {'Data': serialize.object("{}"),} self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items/key', data=values, )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "data": {}, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "key": "key", "map_sid": "MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "revision": "revision", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items/key" } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_items(key="key").update(data="{}") self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/preview/sync/service/sync_map/test_sync_map_permission.py000066400000000000000000000177521317472742600334730ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class SyncMapPermissionTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_permissions(identity="identity").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions/identity', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "map_sid": "MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "identity", "read": true, "write": true, "manage": true, "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions/identity" } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_permissions(identity="identity").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_permissions(identity="identity").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions/identity', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_permissions(identity="identity").delete() self.assertTrue(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_permissions.list() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "permissions": [], "meta": { "first_page_url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/sidOrUniqueName/Permissions?PageSize=50&Page=0", "key": "permissions", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/sidOrUniqueName/Permissions?PageSize=50&Page=0" } } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_permissions.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "permissions": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "map_sid": "MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "identity", "read": true, "write": true, "manage": true, "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions/identity" } ], "meta": { "first_page_url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/sidOrUniqueName/Permissions?PageSize=50&Page=0", "key": "permissions", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/sidOrUniqueName/Permissions?PageSize=50&Page=0" } } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_permissions.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_permissions(identity="identity").update(read=True, write=True, manage=True) values = {'Read': True, 'Write': True, 'Manage': True,} self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions/identity', data=values, )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "map_sid": "MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "identity", "read": true, "write": true, "manage": true, "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions/identity" } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_permissions(identity="identity").update(read=True, write=True, manage=True) self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/preview/sync/service/test_document.py000066400000000000000000000231251317472742600274060ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base import serialize from twilio.base.exceptions import TwilioException from twilio.http.response import Response class DocumentTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents(sid="ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "data": {}, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "revision": "revision", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "permissions": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions" } } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents(sid="ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents(sid="ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents(sid="ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents.create() self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "data": {}, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "revision": "revision", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "permissions": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions" } } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents.create() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents.list() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "documents": [], "meta": { "first_page_url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents?PageSize=50&Page=0", "key": "documents", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents?PageSize=50&Page=0" } } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "documents": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "data": {}, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "revision": "revision", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "permissions": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions" } } ], "meta": { "first_page_url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents?PageSize=50&Page=0", "key": "documents", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents?PageSize=50&Page=0" } } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents(sid="ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update(data="{}") values = {'Data': serialize.object("{}"),} self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', data=values, )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "data": {}, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "revision": "revision", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "permissions": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions" } } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents(sid="ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update(data="{}") self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/preview/sync/service/test_sync_list.py000066400000000000000000000200521317472742600275730ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class SyncListTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "links": { "items": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items", "permissions": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions" }, "revision": "revision", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists.create() self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "links": { "items": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items", "permissions": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions" }, "revision": "revision", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists.create() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists.list() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "lists": [], "meta": { "first_page_url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists?PageSize=50&Page=0", "key": "lists", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists?PageSize=50&Page=0" } } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "lists": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "links": { "items": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items", "permissions": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions" }, "revision": "revision", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "meta": { "first_page_url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists?PageSize=50&Page=0", "key": "lists", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists?PageSize=50&Page=0" } } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/preview/sync/service/test_sync_map.py000066400000000000000000000200131317472742600273720ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class SyncMapTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "links": { "items": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items", "permissions": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions" }, "revision": "revision", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps.create() self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "links": { "items": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items", "permissions": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions" }, "revision": "revision", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps.create() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps.list() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "maps": [], "meta": { "first_page_url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps?PageSize=50&Page=0", "key": "maps", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps?PageSize=50&Page=0" } } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "maps": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "links": { "items": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items", "permissions": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions" }, "revision": "revision", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "meta": { "first_page_url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps?PageSize=50&Page=0", "key": "maps", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps?PageSize=50&Page=0" } } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/preview/sync/test_service.py000066400000000000000000000207411317472742600255710ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class ServiceTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "friendly_name": "friendly_name", "links": { "documents": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents", "lists": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists", "maps": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps" }, "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "webhook_url": "http://www.example.com", "reachability_webhooks_enabled": false, "acl_enabled": false } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services.create() self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/Sync/Services', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "friendly_name": "friendly_name", "links": { "documents": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents", "lists": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists", "maps": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps" }, "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "webhook_url": "http://www.example.com", "reachability_webhooks_enabled": false, "acl_enabled": true } ''' )) actual = self.client.preview.sync.services.create() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services.list() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/Sync/Services', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://preview.twilio.com/Sync/Services?PageSize=50&Page=0", "key": "services", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/Sync/Services?PageSize=50&Page=0" }, "services": [] } ''' )) actual = self.client.preview.sync.services.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://preview.twilio.com/Sync/Services?PageSize=50&Page=0", "key": "services", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/Sync/Services?PageSize=50&Page=0" }, "services": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "friendly_name": "friendly_name", "links": { "documents": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents", "lists": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists", "maps": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps" }, "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "webhook_url": "http://www.example.com", "reachability_webhooks_enabled": false, "acl_enabled": false } ] } ''' )) actual = self.client.preview.sync.services.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "friendly_name": "friendly_name", "links": { "documents": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents", "lists": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists", "maps": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps" }, "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://preview.twilio.com/Sync/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "webhook_url": "http://www.example.com", "reachability_webhooks_enabled": false, "acl_enabled": true } ''' )) actual = self.client.preview.sync.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/preview/wireless/000077500000000000000000000000001317472742600233755ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/preview/wireless/__init__.py000066400000000000000000000001701317472742600255040ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/preview/wireless/sim/000077500000000000000000000000001317472742600241655ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/preview/wireless/sim/__init__.py000066400000000000000000000001701317472742600262740ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/preview/wireless/sim/test_usage.py000066400000000000000000000031141317472742600267010ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class UsageTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.wireless.sims(sid="DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage().fetch() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/wireless/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "commands_costs": {}, "commands_usage": {}, "data_costs": {}, "data_usage": {}, "sim_unique_name": "sim_unique_name", "sim_sid": "DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "period": {}, "url": "https://preview.twilio.com/wireless/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage" } ''' )) actual = self.client.preview.wireless.sims(sid="DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage().fetch() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/preview/wireless/test_command.py000066400000000000000000000127731317472742600264360ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class CommandTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.wireless.commands(sid="DCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/wireless/Commands/DCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "command": "command", "command_mode": "command_mode", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "device_sid": "DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sim_sid": "DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "direction": "direction", "sid": "DCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "status", "url": "https://preview.twilio.com/wireless/Commands/DCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.wireless.commands(sid="DCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.wireless.commands.list() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/wireless/Commands', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "commands": [], "meta": { "first_page_url": "https://preview.twilio.com/wireless/Commands?PageSize=50&Page=0", "key": "commands", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/wireless/Commands?PageSize=50&Page=0" } } ''' )) actual = self.client.preview.wireless.commands.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "commands": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "command": "command", "command_mode": "command_mode", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "device_sid": "DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sim_sid": "DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "direction": "direction", "sid": "DCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "status", "url": "https://preview.twilio.com/wireless/Commands/DCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "meta": { "first_page_url": "https://preview.twilio.com/wireless/Commands?PageSize=50&Page=0", "key": "commands", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/wireless/Commands?PageSize=50&Page=0" } } ''' )) actual = self.client.preview.wireless.commands.list() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.wireless.commands.create(command="command") values = {'Command': "command",} self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/wireless/Commands', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "command": "command", "command_mode": "command_mode", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "device_sid": "DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sim_sid": "DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "direction": "direction", "sid": "DCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "status", "url": "https://preview.twilio.com/wireless/Commands/DCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.wireless.commands.create(command="command") self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/preview/wireless/test_rate_plan.py000066400000000000000000000204071317472742600267560ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class RatePlanTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.wireless.rate_plans.list() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/wireless/RatePlans', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://preview.twilio.com/wireless/RatePlans?PageSize=50&Page=0", "key": "rate_plans", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/wireless/RatePlans?PageSize=50&Page=0" }, "rate_plans": [] } ''' )) actual = self.client.preview.wireless.rate_plans.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://preview.twilio.com/wireless/RatePlans?PageSize=50&Page=0", "key": "rate_plans", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/wireless/RatePlans?PageSize=50&Page=0" }, "rate_plans": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "data_enabled": true, "data_limit": 1000, "data_metering": "pooled", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "friendly_name": "friendly_name", "messaging_enabled": true, "voice_enabled": true, "national_roaming_enabled": true, "international_roaming": [ "data", "messaging", "voice" ], "sid": "WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://preview.twilio.com/wireless/RatePlans/WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.preview.wireless.rate_plans.list() self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.wireless.rate_plans(sid="WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/wireless/RatePlans/WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "data_enabled": true, "data_limit": 1000, "data_metering": "pooled", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "friendly_name": "friendly_name", "messaging_enabled": true, "voice_enabled": true, "national_roaming_enabled": true, "international_roaming": [ "data", "messaging", "voice" ], "sid": "WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://preview.twilio.com/wireless/RatePlans/WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.wireless.rate_plans(sid="WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.wireless.rate_plans.create() self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/wireless/RatePlans', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "data_enabled": true, "data_limit": 1000, "data_metering": "pooled", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "friendly_name": "friendly_name", "messaging_enabled": true, "voice_enabled": true, "national_roaming_enabled": true, "international_roaming": [ "data", "messaging", "voice" ], "sid": "WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://preview.twilio.com/wireless/RatePlans/WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.wireless.rate_plans.create() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.wireless.rate_plans(sid="WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/wireless/RatePlans/WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "data_enabled": true, "data_limit": 1000, "data_metering": "pooled", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "friendly_name": "friendly_name", "messaging_enabled": true, "voice_enabled": true, "national_roaming_enabled": true, "international_roaming": [ "data", "messaging", "voice" ], "sid": "WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://preview.twilio.com/wireless/RatePlans/WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.wireless.rate_plans(sid="WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.wireless.rate_plans(sid="WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://preview.twilio.com/wireless/RatePlans/WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.preview.wireless.rate_plans(sid="WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) twilio-python-6.8.2/tests/integration/preview/wireless/test_sim.py000066400000000000000000000176431317472742600256110ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class SimTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.wireless.sims(sid="DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/wireless/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "commands_callback_method": "http_method", "commands_callback_url": "http://www.example.com", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "friendly_name": "friendly_name", "sms_fallback_method": "http_method", "sms_fallback_url": "http://www.example.com", "sms_method": "http_method", "sms_url": "http://www.example.com", "voice_fallback_method": "http_method", "voice_fallback_url": "http://www.example.com", "voice_method": "http_method", "voice_url": "http://www.example.com", "links": { "usage": "https://preview.twilio.com/wireless/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage", "rate_plan": "https://preview.twilio.com/wireless/RatePlans/WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, "rate_plan_sid": "WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "iccid": "iccid", "e_id": "e_id", "status": "status", "url": "https://preview.twilio.com/wireless/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.wireless.sims(sid="DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.wireless.sims.list() self.holodeck.assert_has_request(Request( 'get', 'https://preview.twilio.com/wireless/Sims', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "sims": [], "meta": { "first_page_url": "https://preview.twilio.com/wireless/Sims?PageSize=50&Page=0", "key": "sims", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/wireless/Sims?PageSize=50&Page=0" } } ''' )) actual = self.client.preview.wireless.sims.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "sims": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "commands_callback_method": "http_method", "commands_callback_url": "http://www.example.com", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "friendly_name": "friendly_name", "links": { "usage": "https://preview.twilio.com/wireless/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage", "rate_plan": "https://preview.twilio.com/wireless/RatePlans/WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, "rate_plan_sid": "WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "iccid": "iccid", "e_id": "e_id", "status": "status", "sms_fallback_method": "http_method", "sms_fallback_url": "http://www.example.com", "sms_method": "http_method", "sms_url": "http://www.example.com", "voice_fallback_method": "http_method", "voice_fallback_url": "http://www.example.com", "voice_method": "http_method", "voice_url": "http://www.example.com", "url": "https://preview.twilio.com/wireless/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "meta": { "first_page_url": "https://preview.twilio.com/wireless/Sims?PageSize=50&Page=0", "key": "sims", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://preview.twilio.com/wireless/Sims?PageSize=50&Page=0" } } ''' )) actual = self.client.preview.wireless.sims.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.preview.wireless.sims(sid="DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://preview.twilio.com/wireless/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "commands_callback_method": "http_method", "commands_callback_url": "http://www.example.com", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "friendly_name": "friendly_name", "links": { "usage": "https://preview.twilio.com/wireless/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Usage", "rate_plan": "https://preview.twilio.com/wireless/RatePlans/WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, "rate_plan_sid": "WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "iccid": "iccid", "e_id": "e_id", "status": "status", "sms_fallback_method": "http_method", "sms_fallback_url": "http://www.example.com", "sms_method": "http_method", "sms_url": "http://www.example.com", "voice_fallback_method": "http_method", "voice_fallback_url": "http://www.example.com", "voice_method": "http_method", "voice_url": "http://www.example.com", "url": "https://preview.twilio.com/wireless/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.preview.wireless.sims(sid="DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/pricing/000077500000000000000000000000001317472742600215125ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/pricing/__init__.py000066400000000000000000000001701317472742600236210ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/pricing/v1/000077500000000000000000000000001317472742600220405ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/pricing/v1/__init__.py000066400000000000000000000001701317472742600241470ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/pricing/v1/messaging/000077500000000000000000000000001317472742600240155ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/pricing/v1/messaging/__init__.py000066400000000000000000000001701317472742600261240ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/pricing/v1/messaging/test_country.py000066400000000000000000000100071317472742600271270ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class CountryTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.pricing.v1.messaging \ .countries.list() self.holodeck.assert_has_request(Request( 'get', 'https://pricing.twilio.com/v1/Messaging/Countries', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "countries": [], "meta": { "first_page_url": "https://pricing.twilio.com/v1/Messaging/Countries?Page=0&PageSize=50", "key": "countries", "next_page_url": null, "page": 0, "page_size": 0, "previous_page_url": null, "url": "https://pricing.twilio.com/v1/Messaging/Countries" } } ''' )) actual = self.client.pricing.v1.messaging \ .countries.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "countries": [ { "country": "country", "iso_country": "US", "url": "http://www.example.com" } ], "meta": { "first_page_url": "https://pricing.twilio.com/v1/Messaging/Countries?Page=0&PageSize=50", "key": "countries", "next_page_url": null, "page": 0, "page_size": 1, "previous_page_url": null, "url": "https://pricing.twilio.com/v1/Messaging/Countries" } } ''' )) actual = self.client.pricing.v1.messaging \ .countries.list() self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.pricing.v1.messaging \ .countries(iso_country="US").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://pricing.twilio.com/v1/Messaging/Countries/US', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "country": "country", "inbound_sms_prices": [ { "base_price": 0.05, "current_price": 0.05, "number_type": "mobile" } ], "iso_country": "US", "outbound_sms_prices": [ { "carrier": "att", "mcc": "foo", "mnc": "bar", "prices": [ { "base_price": 0.05, "current_price": 0.05, "number_type": "mobile" } ] } ], "price_unit": "USD", "url": "http://www.example.com" } ''' )) actual = self.client.pricing.v1.messaging \ .countries(iso_country="US").fetch() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/pricing/v1/phone_number/000077500000000000000000000000001317472742600245215ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/pricing/v1/phone_number/__init__.py000066400000000000000000000001701317472742600266300ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/pricing/v1/phone_number/test_country.py000066400000000000000000000074771317472742600276540ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class CountryTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.pricing.v1.phone_numbers \ .countries.list() self.holodeck.assert_has_request(Request( 'get', 'https://pricing.twilio.com/v1/PhoneNumbers/Countries', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "countries": [ { "country": "Austria", "iso_country": "AT", "url": "https://pricing.twilio.com/v1/PhoneNumbers/Countries/AT" } ], "meta": { "first_page_url": "https://pricing.twilio.com/v1/PhoneNumbers/Countries?PageSize=1&Page=0", "key": "countries", "next_page_url": null, "page": 0, "page_size": 1, "previous_page_url": null, "url": "https://pricing.twilio.com/v1/PhoneNumbers/Countries?PageSize=1&Page=0" } } ''' )) actual = self.client.pricing.v1.phone_numbers \ .countries.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "countries": [], "meta": { "first_page_url": "https://pricing.twilio.com/v1/PhoneNumbers/Countries?PageSize=1&Page=0", "key": "countries", "next_page_url": null, "page": 0, "page_size": 1, "previous_page_url": null, "url": "https://pricing.twilio.com/v1/PhoneNumbers/Countries?PageSize=1&Page=0" } } ''' )) actual = self.client.pricing.v1.phone_numbers \ .countries.list() self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.pricing.v1.phone_numbers \ .countries(iso_country="US").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://pricing.twilio.com/v1/PhoneNumbers/Countries/US', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "country": "Estonia", "iso_country": "EE", "phone_number_prices": [ { "base_price": 3.0, "current_price": 3.0, "type": "mobile" }, { "base_price": 1.0, "current_price": 1.0, "type": "national" } ], "price_unit": "usd", "url": "https://pricing.twilio.com/v1/PhoneNumbers/Countries/US" } ''' )) actual = self.client.pricing.v1.phone_numbers \ .countries(iso_country="US").fetch() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/pricing/v1/test_messaging.py000066400000000000000000000005271317472742600254320ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class MessagingTestCase(IntegrationTestCase): pass twilio-python-6.8.2/tests/integration/pricing/v1/test_phone_number.py000066400000000000000000000005311317472742600261310ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class PhoneNumberTestCase(IntegrationTestCase): pass twilio-python-6.8.2/tests/integration/pricing/v1/test_voice.py000066400000000000000000000005231317472742600245560ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class VoiceTestCase(IntegrationTestCase): pass twilio-python-6.8.2/tests/integration/pricing/v1/voice/000077500000000000000000000000001317472742600231455ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/pricing/v1/voice/__init__.py000066400000000000000000000001701317472742600252540ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/pricing/v1/voice/test_country.py000066400000000000000000000216301317472742600262630ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class CountryTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.pricing.v1.voice \ .countries.list() self.holodeck.assert_has_request(Request( 'get', 'https://pricing.twilio.com/v1/Voice/Countries', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "countries": [ { "country": "Andorra", "iso_country": "AD", "url": "https://pricing.twilio.com/v1/Voice/Countries/AD" } ], "meta": { "first_page_url": "https://pricing.twilio.com/v1/Voice/Countries?PageSize=1&Page=0", "key": "countries", "next_page_url": null, "page": 0, "page_size": 1, "previous_page_url": null, "url": "https://pricing.twilio.com/v1/Voice/Countries?PageSize=1&Page=0" } } ''' )) actual = self.client.pricing.v1.voice \ .countries.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "countries": [], "meta": { "first_page_url": "https://pricing.twilio.com/v1/Voice/Countries?PageSize=1&Page=0", "key": "countries", "next_page_url": null, "page": 0, "page_size": 1, "previous_page_url": null, "url": "https://pricing.twilio.com/v1/Voice/Countries?PageSize=1&Page=0" } } ''' )) actual = self.client.pricing.v1.voice \ .countries.list() self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.pricing.v1.voice \ .countries(iso_country="US").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://pricing.twilio.com/v1/Voice/Countries/US', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "country": "Australia", "inbound_call_prices": [ { "base_price": "0.0075", "current_price": "0.0075", "number_type": "local" } ], "iso_country": "AU", "outbound_prefix_prices": [ { "base_price": "0.024", "current_price": "0.024", "friendly_name": "Programmable Outbound Minute - Australia - Major Cities", "prefixes": [ "6128", "6129", "6138", "6139", "6173", "61261", "61262", "61861", "61862", "61863", "61864", "61865", "61870", "61881", "61882", "61883", "61884", "61892", "61893", "61894" ] }, { "base_price": "0.035", "current_price": "0.035", "friendly_name": "Programmable Outbound Minute - Australia", "prefixes": [ "61" ] }, { "base_price": "0.095", "current_price": "0.095", "friendly_name": "Programmable Outbound Minute - Australia - Shared Cost Service", "prefixes": [ "6113" ] }, { "base_price": "0.095", "current_price": "0.095", "friendly_name": "Programmable Outbound Minute - Australia - Mobile", "prefixes": [ "614", "6116", "61400", "61401", "61402", "61403", "61404", "61405", "61406", "61407", "61408", "61409", "61410", "61411", "61412", "61413", "61414", "61415", "61416", "61417", "61418", "61419", "61421", "61422", "61423", "61424", "61425", "61426", "61427", "61428", "61429", "61430", "61431", "61432", "61433", "61434", "61435", "61437", "61438", "61439", "61447", "61448", "61449", "61450", "61451", "61452", "61453", "61455", "61456", "61457", "61458", "61459", "61466", "61467", "61474", "61477", "61478", "61481", "61482", "61487", "61490", "61497", "61498", "61499", "614202", "614203", "614204", "614205", "614206", "614207", "614208", "614209", "614444", "614683", "614684", "614685", "614686", "614687", "614688", "614689", "614790", "614791", "614880", "614881", "614882", "614883", "614884", "614885", "614886", "614887", "614889" ] } ], "price_unit": "USD", "url": "https://pricing.twilio.com/v1/Voice/Countries/US" } ''' )) actual = self.client.pricing.v1.voice \ .countries(iso_country="US").fetch() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/pricing/v1/voice/test_number.py000066400000000000000000000031251317472742600260470ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class NumberTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.pricing.v1.voice \ .numbers(number="+987654321").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://pricing.twilio.com/v1/Voice/Numbers/+987654321', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "country": "United States", "inbound_call_price": { "base_price": null, "current_price": null, "number_type": null }, "iso_country": "US", "number": "+987654321", "outbound_call_price": { "base_price": "0.015", "current_price": "0.015" }, "price_unit": "USD", "url": "https://pricing.twilio.com/v1/Voice/Numbers/+987654321" } ''' )) actual = self.client.pricing.v1.voice \ .numbers(number="+987654321").fetch() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/proxy/000077500000000000000000000000001317472742600212405ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/proxy/__init__.py000066400000000000000000000001701317472742600233470ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/proxy/v1/000077500000000000000000000000001317472742600215665ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/proxy/v1/__init__.py000066400000000000000000000001701317472742600236750ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/proxy/v1/service/000077500000000000000000000000001317472742600232265ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/proxy/v1/service/__init__.py000066400000000000000000000001701317472742600253350ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/proxy/v1/service/session/000077500000000000000000000000001317472742600247115ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/proxy/v1/service/session/__init__.py000066400000000000000000000001701317472742600270200ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/proxy/v1/service/session/participant/000077500000000000000000000000001317472742600272275ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/proxy/v1/service/session/participant/__init__.py000066400000000000000000000001701317472742600313360ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ test_message_interaction.py000066400000000000000000000170131317472742600346060ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/proxy/v1/service/session/participant# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class MessageInteractionTestCase(IntegrationTestCase): def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants(sid="KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .message_interactions.create() self.holodeck.assert_has_request(Request( 'post', 'https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/MessageInteractions', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "service_sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "data": "body", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "participant_sid": "KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "inbound_participant_sid": null, "inbound_resource_sid": null, "inbound_resource_status": null, "inbound_resource_type": null, "inbound_resource_url": null, "outbound_participant_sid": "KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "outbound_resource_sid": "SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "outbound_resource_status": "sent", "outbound_resource_type": "Message", "outbound_resource_url": null, "sid": "KIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "type": "message", "url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/MessageInteractions/KIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "session_sid": "KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants(sid="KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .message_interactions.create() self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants(sid="KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .message_interactions(sid="KIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/MessageInteractions/KIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "service_sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "data": "data", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "participant_sid": "KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "inbound_participant_sid": null, "inbound_resource_sid": null, "inbound_resource_status": null, "inbound_resource_type": null, "inbound_resource_url": null, "outbound_participant_sid": "KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "outbound_resource_sid": "SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "outbound_resource_status": "sent", "outbound_resource_type": "Message", "outbound_resource_url": null, "sid": "KIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "type": "message", "url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/MessageInteractions/KIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "session_sid": "KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants(sid="KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .message_interactions(sid="KIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants(sid="KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .message_interactions.list() self.holodeck.assert_has_request(Request( 'get', 'https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/MessageInteractions', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "interactions": [], "meta": { "previous_page_url": null, "next_page_url": null, "url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/MessageInteractions?PageSize=50&Page=0", "page": 0, "first_page_url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/MessageInteractions?PageSize=50&Page=0", "page_size": 50, "key": "interactions" } } ''' )) actual = self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants(sid="KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .message_interactions.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/proxy/v1/service/session/test_interaction.py000066400000000000000000000104671317472742600306510ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class InteractionTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .interactions(sid="KIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Interactions/KIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "service_sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "data": "data", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "inbound_participant_sid": "KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "inbound_resource_sid": "SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "inbound_resource_status": "sent", "inbound_resource_type": "Message", "inbound_resource_url": null, "outbound_participant_sid": "KPbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "outbound_resource_sid": "SMbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "outbound_resource_status": "sent", "outbound_resource_type": "Message", "outbound_resource_url": null, "sid": "KIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "type": "message", "url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Interactions/KIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "session_sid": "KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .interactions(sid="KIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .interactions.list() self.holodeck.assert_has_request(Request( 'get', 'https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Interactions', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "interactions": [], "meta": { "previous_page_url": null, "next_page_url": null, "url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Interactions?PageSize=50&Page=0", "page": 0, "first_page_url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Interactions?PageSize=50&Page=0", "page_size": 50, "key": "interactions" } } ''' )) actual = self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .interactions.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/proxy/v1/service/session/test_participant.py000066400000000000000000000235511317472742600306460ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class ParticipantTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants(sid="KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "session_sid": "KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "participant_type": "message-only", "identifier": "identifier", "proxy_identifier": "proxy_identifier", "proxy_identifier_sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "date_deleted": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "date_created": "2015-07-30T20:00:00Z", "url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "message_interactions": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/MessageInteractions" } } ''' )) actual = self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants(sid="KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants.list() self.holodeck.assert_has_request(Request( 'get', 'https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "previous_page_url": null, "next_page_url": null, "url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants?PageSize=50&Page=0", "page": 0, "first_page_url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants?PageSize=50&Page=0", "page_size": 50, "key": "participants" }, "participants": [] } ''' )) actual = self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants.list() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants.create(identifier="identifier") values = {'Identifier': "identifier",} self.holodeck.assert_has_request(Request( 'post', 'https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "session_sid": "KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "participant_type": "message-only", "identifier": "identifier", "proxy_identifier": "proxy_identifier", "proxy_identifier_sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "date_deleted": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "date_created": "2015-07-30T20:00:00Z", "url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "message_interactions": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/MessageInteractions" } } ''' )) actual = self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants.create(identifier="identifier") self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants(sid="KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants(sid="KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants(sid="KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "session_sid": "KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "participant_type": "message-only", "identifier": "identifier", "proxy_identifier": "proxy_identifier", "proxy_identifier_sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "date_deleted": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "date_created": "2015-07-30T20:00:00Z", "url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "message_interactions": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/MessageInteractions" } } ''' )) actual = self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .participants(sid="KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/proxy/v1/service/test_phone_number.py000066400000000000000000000145421317472742600273260ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class PhoneNumberTestCase(IntegrationTestCase): def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .phone_numbers.create(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") values = {'Sid': "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",} self.holodeck.assert_has_request(Request( 'post', 'https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "phone_number": "+987654321", "friendly_name": "Friendly Name", "iso_country": "US", "capabilities": [], "url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .phone_numbers.create(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .phone_numbers(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .phone_numbers(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .phone_numbers.list() self.holodeck.assert_has_request(Request( 'get', 'https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers?PageSize=50&Page=0", "previous_page_url": null, "next_page_url": null, "key": "phone_numbers", "url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers?PageSize=50&Page=0" }, "phone_numbers": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "phone_number": "+987654321", "friendly_name": "Friendly Name", "iso_country": "US", "capabilities": [], "url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .phone_numbers.list() self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .phone_numbers(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "phone_number": "12345", "friendly_name": "Friendly Name", "iso_country": "US", "capabilities": [], "url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .phone_numbers(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/proxy/v1/service/test_session.py000066400000000000000000000211371317472742600263260ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class SessionTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "service_sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "in-progess", "unique_name": "unique_name", "date_started": "2015-07-30T20:00:00Z", "date_ended": "2015-07-30T20:00:00Z", "date_last_interaction": "2015-07-30T20:00:00Z", "date_expiry": "2015-07-30T20:00:00Z", "ttl": 3600, "closed_reason": "", "sid": "KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_updated": "2015-07-30T20:00:00Z", "date_created": "2015-07-30T20:00:00Z", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "interactions": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Interactions", "participants": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants" } } ''' )) actual = self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions.list() self.holodeck.assert_has_request(Request( 'get', 'https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "sessions": [], "meta": { "previous_page_url": null, "next_page_url": null, "url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions?PageSize=50&Page=0", "page": 0, "first_page_url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions?PageSize=50&Page=0", "page_size": 50, "key": "sessions" } } ''' )) actual = self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions.list() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions.create() self.holodeck.assert_has_request(Request( 'post', 'https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "service_sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "in-progess", "unique_name": "unique_name", "date_started": "2015-07-30T20:00:00Z", "date_ended": "2015-07-30T20:00:00Z", "date_last_interaction": "2015-07-30T20:00:00Z", "date_expiry": "2015-07-30T20:00:00Z", "ttl": 3600, "closed_reason": "", "sid": "KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_updated": "2015-07-30T20:00:00Z", "date_created": "2015-07-30T20:00:00Z", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "interactions": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Interactions", "participants": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants" } } ''' )) actual = self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions.create() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "service_sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "in-progess", "unique_name": "unique_name", "date_started": "2015-07-30T20:00:00Z", "date_ended": "2015-07-30T20:00:00Z", "date_last_interaction": "2015-07-30T20:00:00Z", "date_expiry": "2015-07-30T20:00:00Z", "ttl": 3600, "closed_reason": "", "sid": "KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_updated": "2015-07-30T20:00:00Z", "date_created": "2015-07-30T20:00:00Z", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "interactions": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Interactions", "participants": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants" } } ''' )) actual = self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sessions(sid="KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/proxy/v1/service/test_short_code.py000066400000000000000000000142141317472742600267720ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class ShortCodeTestCase(IntegrationTestCase): def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .short_codes.create(sid="SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") values = {'Sid': "SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",} self.holodeck.assert_has_request(Request( 'post', 'https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "short_code": "12345", "iso_country": "US", "capabilities": [], "url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes/SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .short_codes.create(sid="SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .short_codes(sid="SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes/SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .short_codes(sid="SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .short_codes.list() self.holodeck.assert_has_request(Request( 'get', 'https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes?PageSize=50&Page=0", "previous_page_url": null, "next_page_url": null, "key": "short_codes", "url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes?PageSize=50&Page=0" }, "short_codes": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "short_code": "12345", "iso_country": "US", "capabilities": [], "url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes/SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .short_codes.list() self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .short_codes(sid="SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes/SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "short_code": "12345", "iso_country": "US", "capabilities": [], "url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes/SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .short_codes(sid="SCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/proxy/v1/test_service.py000066400000000000000000000147521317472742600246500ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class ServiceTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "default_ttl": 3600, "callback_url": "http://www.example.com", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "sessions": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions", "phone_numbers": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers", "short_codes": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes" } } ''' )) actual = self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.proxy.v1.services.list() self.holodeck.assert_has_request(Request( 'get', 'https://proxy.twilio.com/v1/Services', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "services": [], "meta": { "first_page_url": "https://proxy.twilio.com/v1/Services?PageSize=50&Page=0", "key": "services", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://proxy.twilio.com/v1/Services?PageSize=50&Page=0" } } ''' )) actual = self.client.proxy.v1.services.list() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.proxy.v1.services.create() self.holodeck.assert_has_request(Request( 'post', 'https://proxy.twilio.com/v1/Services', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "default_ttl": 3600, "callback_url": "http://www.example.com", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "sessions": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions", "phone_numbers": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers", "short_codes": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes" } } ''' )) actual = self.client.proxy.v1.services.create() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "friendly_name", "default_ttl": 3600, "callback_url": "http://www.example.com", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "sessions": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions", "phone_numbers": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers", "short_codes": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes" } } ''' )) actual = self.client.proxy.v1.services(sid="KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/sync/000077500000000000000000000000001317472742600210335ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/sync/__init__.py000066400000000000000000000001701317472742600231420ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/sync/v1/000077500000000000000000000000001317472742600213615ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/sync/v1/__init__.py000066400000000000000000000001701317472742600234700ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/sync/v1/service/000077500000000000000000000000001317472742600230215ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/sync/v1/service/__init__.py000066400000000000000000000001701317472742600251300ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/sync/v1/service/document/000077500000000000000000000000001317472742600246375ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/sync/v1/service/document/__init__.py000066400000000000000000000001701317472742600267460ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/sync/v1/service/document/test_document_permission.py000066400000000000000000000175631317472742600323520ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class DocumentPermissionTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents(sid="ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .document_permissions(identity="identity").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions/identity', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "document_sid": "ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "identity", "read": true, "write": true, "manage": true, "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions/identity" } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents(sid="ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .document_permissions(identity="identity").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents(sid="ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .document_permissions(identity="identity").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions/identity', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents(sid="ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .document_permissions(identity="identity").delete() self.assertTrue(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents(sid="ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .document_permissions.list() self.holodeck.assert_has_request(Request( 'get', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "permissions": [], "meta": { "first_page_url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/sidOrUniqueName/Permissions?PageSize=50&Page=0", "key": "permissions", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/sidOrUniqueName/Permissions?PageSize=50&Page=0" } } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents(sid="ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .document_permissions.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "permissions": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "document_sid": "ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "identity", "read": true, "write": true, "manage": true, "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions/identity" } ], "meta": { "first_page_url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/sidOrUniqueName/Permissions?PageSize=50&Page=0", "key": "permissions", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/sidOrUniqueName/Permissions?PageSize=50&Page=0" } } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents(sid="ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .document_permissions.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents(sid="ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .document_permissions(identity="identity").update(read=True, write=True, manage=True) values = {'Read': True, 'Write': True, 'Manage': True,} self.holodeck.assert_has_request(Request( 'post', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions/identity', data=values, )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "document_sid": "ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "identity", "read": true, "write": true, "manage": true, "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions/identity" } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents(sid="ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .document_permissions(identity="identity").update(read=True, write=True, manage=True) self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/sync/v1/service/sync_list/000077500000000000000000000000001317472742600250305ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/sync/v1/service/sync_list/__init__.py000066400000000000000000000001701317472742600271370ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/sync/v1/service/sync_list/test_sync_list_item.py000066400000000000000000000232561317472742600314760ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base import serialize from twilio.base.exceptions import TwilioException from twilio.http.response import Response class SyncListItemTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_items(index=1).fetch() self.holodeck.assert_has_request(Request( 'get', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items/1', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "data": {}, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "index": 100, "list_sid": "ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "revision": "revision", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items/100" } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_items(index=1).fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_items(index=1).delete() self.holodeck.assert_has_request(Request( 'delete', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items/1', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_items(index=1).delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_items.create(data="{}") values = {'Data': serialize.object("{}"),} self.holodeck.assert_has_request(Request( 'post', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "data": {}, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "index": 100, "list_sid": "ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "revision": "revision", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items/100" } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_items.create(data="{}") self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_items.list() self.holodeck.assert_has_request(Request( 'get', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "items": [], "meta": { "first_page_url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items?PageSize=50&Page=0", "key": "items", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items?PageSize=50&Page=0" } } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_items.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "items": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "data": {}, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "index": 100, "list_sid": "ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "revision": "revision", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items/100" } ], "meta": { "first_page_url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items?PageSize=50&Page=0", "key": "items", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items?PageSize=50&Page=0" } } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_items.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_items(index=1).update(data="{}") values = {'Data': serialize.object("{}"),} self.holodeck.assert_has_request(Request( 'post', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items/1', data=values, )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "data": {}, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "index": 100, "list_sid": "ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "revision": "revision", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items/100" } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_items(index=1).update(data="{}") self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/sync/v1/service/sync_list/test_sync_list_permission.py000066400000000000000000000175151317472742600327310ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class SyncListPermissionTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_permissions(identity="identity").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions/identity', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "list_sid": "ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "identity", "read": true, "write": true, "manage": true, "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions/identity" } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_permissions(identity="identity").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_permissions(identity="identity").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions/identity', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_permissions(identity="identity").delete() self.assertTrue(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_permissions.list() self.holodeck.assert_has_request(Request( 'get', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "permissions": [], "meta": { "first_page_url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/sidOrUniqueName/Permissions?PageSize=50&Page=0", "key": "permissions", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/sidOrUniqueName/Permissions?PageSize=50&Page=0" } } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_permissions.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "permissions": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "list_sid": "ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "identity", "read": true, "write": true, "manage": true, "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions/identity" } ], "meta": { "first_page_url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/sidOrUniqueName/Permissions?PageSize=50&Page=0", "key": "permissions", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/sidOrUniqueName/Permissions?PageSize=50&Page=0" } } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_permissions.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_permissions(identity="identity").update(read=True, write=True, manage=True) values = {'Read': True, 'Write': True, 'Manage': True,} self.holodeck.assert_has_request(Request( 'post', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions/identity', data=values, )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "list_sid": "ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "identity", "read": true, "write": true, "manage": true, "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions/identity" } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_list_permissions(identity="identity").update(read=True, write=True, manage=True) self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/sync/v1/service/sync_map/000077500000000000000000000000001317472742600246325ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/sync/v1/service/sync_map/__init__.py000066400000000000000000000001701317472742600267410ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/sync/v1/service/sync_map/test_sync_map_item.py000066400000000000000000000232741317472742600311020ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base import serialize from twilio.base.exceptions import TwilioException from twilio.http.response import Response class SyncMapItemTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_items(key="key").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items/key', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "data": {}, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "key": "key", "map_sid": "MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "revision": "revision", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items/key" } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_items(key="key").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_items(key="key").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items/key', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_items(key="key").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_items.create(key="key", data="{}") values = {'Key': "key", 'Data': serialize.object("{}"),} self.holodeck.assert_has_request(Request( 'post', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "data": {}, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "key": "key", "map_sid": "MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "revision": "revision", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items/key" } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_items.create(key="key", data="{}") self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_items.list() self.holodeck.assert_has_request(Request( 'get', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "items": [], "meta": { "first_page_url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items?PageSize=50&Page=0", "key": "items", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items?PageSize=50&Page=0" } } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_items.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "items": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "data": {}, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "key": "key", "map_sid": "MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "revision": "revision", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items/key" } ], "meta": { "first_page_url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items?PageSize=50&Page=0", "key": "items", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items?PageSize=50&Page=0" } } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_items.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_items(key="key").update(data="{}") values = {'Data': serialize.object("{}"),} self.holodeck.assert_has_request(Request( 'post', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items/key', data=values, )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "data": {}, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "key": "key", "map_sid": "MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "revision": "revision", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items/key" } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_items(key="key").update(data="{}") self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/sync/v1/service/sync_map/test_sync_map_permission.py000066400000000000000000000174541317472742600323370ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class SyncMapPermissionTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_permissions(identity="identity").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions/identity', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "map_sid": "MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "identity", "read": true, "write": true, "manage": true, "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions/identity" } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_permissions(identity="identity").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_permissions(identity="identity").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions/identity', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_permissions(identity="identity").delete() self.assertTrue(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_permissions.list() self.holodeck.assert_has_request(Request( 'get', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "permissions": [], "meta": { "first_page_url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/sidOrUniqueName/Permissions?PageSize=50&Page=0", "key": "permissions", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/sidOrUniqueName/Permissions?PageSize=50&Page=0" } } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_permissions.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "permissions": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "map_sid": "MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "identity", "read": true, "write": true, "manage": true, "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions/identity" } ], "meta": { "first_page_url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/sidOrUniqueName/Permissions?PageSize=50&Page=0", "key": "permissions", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/sidOrUniqueName/Permissions?PageSize=50&Page=0" } } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_permissions.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_permissions(identity="identity").update(read=True, write=True, manage=True) values = {'Read': True, 'Write': True, 'Manage': True,} self.holodeck.assert_has_request(Request( 'post', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions/identity', data=values, )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "map_sid": "MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "identity": "identity", "read": true, "write": true, "manage": true, "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions/identity" } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_map_permissions(identity="identity").update(read=True, write=True, manage=True) self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/sync/v1/service/sync_stream/000077500000000000000000000000001317472742600253505ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/sync/v1/service/sync_stream/__init__.py000066400000000000000000000001701317472742600274570ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/sync/v1/service/sync_stream/test_stream_message.py000066400000000000000000000030611317472742600317600ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base import serialize from twilio.base.exceptions import TwilioException from twilio.http.response import Response class StreamMessageTestCase(IntegrationTestCase): def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_streams(sid="TOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .stream_messages.create(data="{}") values = {'Data': serialize.object("{}"),} self.holodeck.assert_has_request(Request( 'post', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams/TOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "TZaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "data": {} } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_streams(sid="TOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .stream_messages.create(data="{}") self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/sync/v1/service/test_document.py000066400000000000000000000226221317472742600262540ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base import serialize from twilio.base.exceptions import TwilioException from twilio.http.response import Response class DocumentTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents(sid="ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "data": {}, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "revision": "revision", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "permissions": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions" } } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents(sid="ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents(sid="ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents(sid="ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents.create() self.holodeck.assert_has_request(Request( 'post', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "data": {}, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "revision": "revision", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "permissions": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions" } } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents.create() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents.list() self.holodeck.assert_has_request(Request( 'get', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "documents": [], "meta": { "first_page_url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents?PageSize=50&Page=0", "key": "documents", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents?PageSize=50&Page=0" } } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "documents": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "data": {}, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "revision": "revision", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "permissions": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions" } } ], "meta": { "first_page_url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents?PageSize=50&Page=0", "key": "documents", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents?PageSize=50&Page=0" } } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents(sid="ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update(data="{}") values = {'Data': serialize.object("{}"),} self.holodeck.assert_has_request(Request( 'post', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', data=values, )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "data": {}, "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "revision": "revision", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "permissions": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents/ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions" } } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .documents(sid="ETaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update(data="{}") self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/sync/v1/service/test_sync_list.py000066400000000000000000000175731317472742600264560ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class SyncListTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "links": { "items": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items", "permissions": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions" }, "revision": "revision", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists(sid="ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists.create() self.holodeck.assert_has_request(Request( 'post', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "links": { "items": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items", "permissions": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions" }, "revision": "revision", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists.create() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists.list() self.holodeck.assert_has_request(Request( 'get', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "lists": [], "meta": { "first_page_url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists?PageSize=50&Page=0", "key": "lists", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists?PageSize=50&Page=0" } } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "lists": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "links": { "items": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items", "permissions": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions" }, "revision": "revision", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists/ESaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "meta": { "first_page_url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists?PageSize=50&Page=0", "key": "lists", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists?PageSize=50&Page=0" } } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_lists.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/sync/v1/service/test_sync_map.py000066400000000000000000000175341317472742600262550ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class SyncMapTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "links": { "items": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items", "permissions": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions" }, "revision": "revision", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps(sid="MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps.create() self.holodeck.assert_has_request(Request( 'post', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "links": { "items": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items", "permissions": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions" }, "revision": "revision", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps.create() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps.list() self.holodeck.assert_has_request(Request( 'get', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "maps": [], "meta": { "first_page_url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps?PageSize=50&Page=0", "key": "maps", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps?PageSize=50&Page=0" } } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "maps": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "links": { "items": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Items", "permissions": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Permissions" }, "revision": "revision", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps/MPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "meta": { "first_page_url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps?PageSize=50&Page=0", "key": "maps", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps?PageSize=50&Page=0" } } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_maps.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/sync/v1/service/test_sync_stream.py000066400000000000000000000165271317472742600267740ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class SyncStreamTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_streams(sid="TOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams/TOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "links": { "messages": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams/TOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages" }, "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "TOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams/TOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_streams(sid="TOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_streams(sid="TOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams/TOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_streams(sid="TOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_streams.create() self.holodeck.assert_has_request(Request( 'post', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "links": { "messages": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams/TOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages" }, "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "TOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams/TOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_streams.create() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_streams.list() self.holodeck.assert_has_request(Request( 'get', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "streams": [], "meta": { "first_page_url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams?PageSize=50&Page=0", "key": "streams", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams?PageSize=50&Page=0" } } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_streams.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "streams": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "created_by": "created_by", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "links": { "messages": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams/TOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages" }, "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "TOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams/TOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "meta": { "first_page_url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams?PageSize=50&Page=0", "key": "streams", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams?PageSize=50&Page=0" } } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .sync_streams.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/sync/v1/test_service.py000066400000000000000000000216711317472742600244410ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class ServiceTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "friendly_name": "friendly_name", "links": { "documents": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents", "lists": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists", "maps": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps", "streams": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams" }, "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "webhook_url": "http://www.example.com", "reachability_webhooks_enabled": false, "acl_enabled": false } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services.create() self.holodeck.assert_has_request(Request( 'post', 'https://sync.twilio.com/v1/Services', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "friendly_name": "friendly_name", "links": { "documents": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents", "lists": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists", "maps": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps", "streams": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams" }, "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "webhook_url": "http://www.example.com", "reachability_webhooks_enabled": false, "acl_enabled": true } ''' )) actual = self.client.sync.v1.services.create() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services.list() self.holodeck.assert_has_request(Request( 'get', 'https://sync.twilio.com/v1/Services', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://sync.twilio.com/v1/Services?PageSize=50&Page=0", "key": "services", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://sync.twilio.com/v1/Services?PageSize=50&Page=0" }, "services": [] } ''' )) actual = self.client.sync.v1.services.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://sync.twilio.com/v1/Services?PageSize=50&Page=0", "key": "services", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://sync.twilio.com/v1/Services?PageSize=50&Page=0" }, "services": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "friendly_name": "friendly_name", "links": { "documents": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents", "lists": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists", "maps": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps", "streams": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams" }, "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "webhook_url": "http://www.example.com", "reachability_webhooks_enabled": false, "acl_enabled": false } ] } ''' )) actual = self.client.sync.v1.services.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "friendly_name": "friendly_name", "links": { "documents": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Documents", "lists": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Lists", "maps": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Maps", "streams": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams" }, "sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "url": "https://sync.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "webhook_url": "http://www.example.com", "reachability_webhooks_enabled": false, "acl_enabled": true } ''' )) actual = self.client.sync.v1.services(sid="ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/taskrouter/000077500000000000000000000000001317472742600222625ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/taskrouter/__init__.py000066400000000000000000000001701317472742600243710ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/taskrouter/v1/000077500000000000000000000000001317472742600226105ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/taskrouter/v1/__init__.py000066400000000000000000000001701317472742600247170ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/taskrouter/v1/test_workspace.py000066400000000000000000000330351317472742600262230ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class WorkspaceTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-08-01T22:10:40Z", "date_updated": "2016-08-01T22:10:40Z", "default_activity_name": "Offline", "default_activity_sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "event_callback_url": "", "events_filter": null, "friendly_name": "new", "links": { "activities": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities", "statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics", "real_time_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics", "cumulative_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics", "task_queues": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues", "tasks": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks", "workers": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers", "workflows": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows", "task_channels": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskChannels", "events": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Events" }, "multi_task_enabled": false, "prioritize_queue_order": "FIFO", "sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "timeout_activity_name": "Offline", "timeout_activity_sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-08-01T22:10:40Z", "date_updated": "2016-08-01T22:10:40Z", "default_activity_name": "Offline", "default_activity_sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "event_callback_url": "", "events_filter": null, "friendly_name": "new", "links": { "activities": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities", "statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics", "real_time_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics", "cumulative_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics", "task_queues": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues", "tasks": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks", "workers": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers", "workflows": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows", "task_channels": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskChannels", "events": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Events" }, "multi_task_enabled": false, "prioritize_queue_order": "FIFO", "sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "timeout_activity_name": "Offline", "timeout_activity_sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces.list() self.holodeck.assert_has_request(Request( 'get', 'https://taskrouter.twilio.com/v1/Workspaces', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://taskrouter.twilio.com/v1/Workspaces?PageSize=50&Page=0", "key": "workspaces", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://taskrouter.twilio.com/v1/Workspaces?PageSize=50&Page=0" }, "workspaces": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-08-01T22:10:40Z", "date_updated": "2016-08-01T22:10:40Z", "default_activity_name": "Offline", "default_activity_sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "event_callback_url": "", "events_filter": null, "friendly_name": "new", "links": { "activities": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities", "statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics", "real_time_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics", "cumulative_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics", "task_queues": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues", "tasks": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks", "workers": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers", "workflows": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows", "task_channels": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskChannels", "events": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Events" }, "multi_task_enabled": false, "prioritize_queue_order": "FIFO", "sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "timeout_activity_name": "Offline", "timeout_activity_sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.taskrouter.v1.workspaces.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://taskrouter.twilio.com/v1/Workspaces?PageSize=50&Page=0", "key": "workspaces", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://taskrouter.twilio.com/v1/Workspaces?PageSize=50&Page=0" }, "workspaces": [] } ''' )) actual = self.client.taskrouter.v1.workspaces.list() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces.create(friendly_name="friendly_name") values = {'FriendlyName': "friendly_name",} self.holodeck.assert_has_request(Request( 'post', 'https://taskrouter.twilio.com/v1/Workspaces', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2016-08-01T22:10:40Z", "date_updated": "2016-08-01T22:10:40Z", "default_activity_name": "Offline", "default_activity_sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "event_callback_url": "", "events_filter": null, "friendly_name": "new", "links": { "activities": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities", "statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics", "real_time_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics", "cumulative_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics", "task_queues": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues", "tasks": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks", "workers": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers", "workflows": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows", "task_channels": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskChannels", "events": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Events" }, "multi_task_enabled": false, "prioritize_queue_order": "FIFO", "sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "timeout_activity_name": "Offline", "timeout_activity_sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.taskrouter.v1.workspaces.create(friendly_name="friendly_name") self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) twilio-python-6.8.2/tests/integration/taskrouter/v1/workspace/000077500000000000000000000000001317472742600246065ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/taskrouter/v1/workspace/__init__.py000066400000000000000000000001701317472742600267150ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/taskrouter/v1/workspace/task/000077500000000000000000000000001317472742600255505ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/taskrouter/v1/workspace/task/__init__.py000066400000000000000000000001701317472742600276570ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/taskrouter/v1/workspace/task/test_reservation.py000066400000000000000000000221001317472742600315150ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class ReservationTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .tasks(sid="WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .reservations.list() self.holodeck.assert_has_request(Request( 'get', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations?PageSize=50&Page=0", "key": "reservations", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations?PageSize=50&Page=0" }, "reservations": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2014-05-14T10:50:02Z", "date_updated": "2014-05-15T16:03:42Z", "links": { "task": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "worker": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, "reservation_status": "accepted", "sid": "WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "task_sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "worker_name": "Doug", "worker_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .tasks(sid="WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .reservations.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations?PageSize=50&Page=0", "key": "reservations", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations?PageSize=50&Page=0" }, "reservations": [] } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .tasks(sid="WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .reservations.list() self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .tasks(sid="WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .reservations(sid="WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2014-05-14T10:50:02Z", "date_updated": "2014-05-15T16:03:42Z", "links": { "task": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "worker": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, "reservation_status": "accepted", "sid": "WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "task_sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "worker_name": "Doug", "worker_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .tasks(sid="WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .reservations(sid="WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .tasks(sid="WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .reservations(sid="WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2014-05-14T10:50:02Z", "date_updated": "2014-05-15T16:03:42Z", "links": { "task": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "worker": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, "reservation_status": "accepted", "sid": "WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "task_sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "worker_name": "Doug", "worker_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .tasks(sid="WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .reservations(sid="WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/taskrouter/v1/workspace/task_queue/000077500000000000000000000000001317472742600267545ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/taskrouter/v1/workspace/task_queue/__init__.py000066400000000000000000000001701317472742600310630ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ test_task_queue_cumulative_statistics.py000066400000000000000000000071171317472742600371720ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/taskrouter/v1/workspace/task_queue# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class TaskQueueCumulativeStatisticsTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .task_queues(sid="WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .cumulative_statistics().fetch() self.holodeck.assert_has_request(Request( 'get', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "reservations_created": 100, "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "reservations_rejected": 100, "tasks_completed": 100, "end_time": "2015-07-30T20:00:00Z", "tasks_entered": 100, "tasks_canceled": 100, "reservations_accepted": 100, "task_queue_sid": "WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "reservations_timed_out": 100, "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics", "wait_duration_until_canceled": { "avg": 0, "min": 0, "max": 0, "total": 0 }, "wait_duration_until_accepted": { "avg": 0, "min": 0, "max": 0, "total": 0 }, "split_by_wait_time": { "5": { "above": { "tasks_canceled": 0, "reservations_accepted": 0 }, "below": { "tasks_canceled": 0, "reservations_accepted": 0 } }, "10": { "above": { "tasks_canceled": 0, "reservations_accepted": 0 }, "below": { "tasks_canceled": 0, "reservations_accepted": 0 } } }, "start_time": "2015-07-30T20:00:00Z", "tasks_moved": 100, "reservations_canceled": 100, "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "tasks_deleted": 100, "reservations_rescinded": 100, "avg_task_acceptance_time": 100 } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .task_queues(sid="WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .cumulative_statistics().fetch() self.assertIsNotNone(actual) test_task_queue_real_time_statistics.py000066400000000000000000000060501317472742600367500ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/taskrouter/v1/workspace/task_queue# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class TaskQueueRealTimeStatisticsTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .task_queues(sid="WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .real_time_statistics().fetch() self.holodeck.assert_has_request(Request( 'get', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "longest_task_waiting_age": 100, "task_queue_sid": "WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "tasks_by_status": { "reserved": 0, "pending": 0, "assigned": 0, "wrapping": 0 }, "total_eligible_workers": 100, "activity_statistics": [ { "friendly_name": "Idle", "workers": 0, "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, { "friendly_name": "Busy", "workers": 9, "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, { "friendly_name": "Offline", "workers": 6, "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, { "friendly_name": "Reserved", "workers": 0, "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "tasks_by_priority": {}, "total_tasks": 100, "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "total_available_workers": 100, "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics" } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .task_queues(sid="WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .real_time_statistics().fetch() self.assertIsNotNone(actual) test_task_queue_statistics.py000066400000000000000000000105021317472742600347240ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/taskrouter/v1/workspace/task_queue# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class TaskQueueStatisticsTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .task_queues(sid="WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .statistics().fetch() self.holodeck.assert_has_request(Request( 'get', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics", "cumulative": { "avg_task_acceptance_time": 0.0, "end_time": "2015-08-18T08:42:34Z", "reservations_accepted": 0, "reservations_canceled": 0, "reservations_created": 0, "reservations_rejected": 0, "reservations_rescinded": 0, "reservations_timed_out": 0, "start_time": "2015-08-18T08:27:34Z", "tasks_canceled": 0, "tasks_deleted": 0, "tasks_entered": 0, "tasks_moved": 0 }, "realtime": { "activity_statistics": [ { "friendly_name": "Offline", "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workers": 0 }, { "friendly_name": "Idle", "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workers": 0 }, { "friendly_name": "80fa2beb-3a05-11e5-8fc8-98e0d9a1eb73", "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workers": 0 }, { "friendly_name": "Reserved", "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workers": 0 }, { "friendly_name": "Busy", "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workers": 0 }, { "friendly_name": "817ca1c5-3a05-11e5-9292-98e0d9a1eb73", "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workers": 0 } ], "longest_task_waiting_age": 0, "longest_task_waiting_sid": null, "tasks_by_status": { "assigned": 0, "pending": 0, "reserved": 0, "wrapping": 0 }, "total_available_workers": 0, "total_eligible_workers": 0, "total_tasks": 0 }, "task_queue_sid": "WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .task_queues(sid="WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .statistics().fetch() self.assertIsNotNone(actual) test_task_queues_statistics.py000066400000000000000000000143071317472742600351160ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/taskrouter/v1/workspace/task_queue# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class TaskQueuesStatisticsTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .task_queues \ .statistics.list() self.holodeck.assert_has_request(Request( 'get', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/Statistics', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/Statistics?PageSize=50&Page=0", "key": "task_queues_statistics", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/Statistics?PageSize=50&Page=0" }, "task_queues_statistics": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "cumulative": { "avg_task_acceptance_time": 0.0, "end_time": "2015-08-18T08:46:15Z", "reservations_accepted": 0, "reservations_canceled": 0, "reservations_created": 0, "reservations_rejected": 0, "reservations_rescinded": 0, "reservations_timed_out": 0, "start_time": "2015-08-18T08:31:15Z", "tasks_canceled": 0, "tasks_deleted": 0, "tasks_entered": 0, "tasks_moved": 0 }, "realtime": { "activity_statistics": [ { "friendly_name": "Offline", "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workers": 0 }, { "friendly_name": "Idle", "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workers": 0 }, { "friendly_name": "80fa2beb-3a05-11e5-8fc8-98e0d9a1eb73", "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workers": 0 }, { "friendly_name": "Reserved", "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workers": 0 }, { "friendly_name": "Busy", "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workers": 0 }, { "friendly_name": "817ca1c5-3a05-11e5-9292-98e0d9a1eb73", "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workers": 0 } ], "longest_task_waiting_age": 0, "longest_task_waiting_sid": null, "tasks_by_status": { "assigned": 0, "pending": 0, "reserved": 0, "wrapping": 0 }, "total_available_workers": 0, "total_eligible_workers": 0, "total_tasks": 0 }, "task_queue_sid": "WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .task_queues \ .statistics.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/Statistics?PageSize=50&Page=0", "key": "task_queues_statistics", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/Statistics?PageSize=50&Page=0" }, "task_queues_statistics": [] } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .task_queues \ .statistics.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/taskrouter/v1/workspace/test_activity.py000066400000000000000000000215151317472742600300570ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class ActivityTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .activities(sid="WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities/WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "available": true, "date_created": "2014-05-14T10:50:02Z", "date_updated": "2014-05-14T23:26:06Z", "friendly_name": "New Activity", "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities/WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .activities(sid="WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .activities(sid="WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities/WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "available": true, "date_created": "2014-05-14T10:50:02Z", "date_updated": "2014-05-14T23:26:06Z", "friendly_name": "New Activity", "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities/WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .activities(sid="WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .activities(sid="WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities/WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .activities(sid="WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .activities.list() self.holodeck.assert_has_request(Request( 'get', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "activities": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "available": true, "date_created": "2014-05-14T10:50:02Z", "date_updated": "2014-05-14T23:26:06Z", "friendly_name": "New Activity", "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities/WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "meta": { "first_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities?PageSize=50&Page=0", "key": "activities", "last_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities?PageSize=50&Page=0", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities?PageSize=50&Page=0" } } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .activities.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "activities": [], "meta": { "first_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities?PageSize=50&Page=0", "key": "activities", "last_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities?PageSize=50&Page=0", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities?PageSize=50&Page=0" } } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .activities.list() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .activities.create(friendly_name="friendly_name") values = {'FriendlyName': "friendly_name",} self.holodeck.assert_has_request(Request( 'post', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "available": true, "date_created": "2014-05-14T10:50:02Z", "date_updated": "2014-05-14T23:26:06Z", "friendly_name": "New Activity", "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities/WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .activities.create(friendly_name="friendly_name") self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/taskrouter/v1/workspace/test_event.py000066400000000000000000000154511317472742600273460ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class EventTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .events(sid="EVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Events/EVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "actor_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "actor_type": "workspace", "actor_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "description": "Worker JustinWorker updated to Idle Activity", "event_data": { "worker_activity_name": "Offline", "worker_activity_sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "worker_attributes": "{}", "worker_name": "JustinWorker", "worker_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "worker_time_in_previous_activity": "26", "workspace_name": "WorkspaceName", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, "event_date": "2015-02-07T00:32:41Z", "event_type": "worker.activity", "resource_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "resource_type": "worker", "resource_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "EVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "source": "twilio", "source_ip_address": "1.2.3.4", "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Events/EVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .events(sid="EVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .events.list() self.holodeck.assert_has_request(Request( 'get', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Events', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "events": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "actor_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "actor_type": "workspace", "actor_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "description": "Worker JustinWorker updated to Idle Activity", "event_data": { "worker_activity_name": "Offline", "worker_activity_sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "worker_attributes": "{}", "worker_name": "JustinWorker", "worker_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "worker_time_in_previous_activity": "26", "workspace_name": "WorkspaceName", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, "event_date": "2015-02-07T00:32:41Z", "event_type": "worker.activity", "resource_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "resource_type": "worker", "resource_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "EVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "source": "twilio", "source_ip_address": "1.2.3.4", "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Events/EVaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "meta": { "first_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Events?PageSize=50&Page=0", "key": "events", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Events?PageSize=50&Page=0" } } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .events.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "events": [], "meta": { "first_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Events?PageSize=50&Page=0", "key": "events", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Events?PageSize=50&Page=0" } } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .events.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/taskrouter/v1/workspace/test_task.py000066400000000000000000000342021317472742600271620ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class TaskTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .tasks(sid="WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "age": 25200, "assignment_status": "pending", "attributes": "{\\"body\\": \\"hello\\"}", "date_created": "2014-05-14T18:50:02Z", "date_updated": "2014-05-15T07:26:06Z", "priority": 0, "reason": "Test Reason", "sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "task_queue_sid": "WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "task_channel_sid": "TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "task_channel_unique_name": "task-channel", "timeout": 60, "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workflow_sid": "WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workflow_friendly_name": "Test Workflow", "task_queue_friendly_name": "Test Queue", "addons": "{}", "links": { "task_queue": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workflow": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "reservations": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations" } } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .tasks(sid="WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .tasks(sid="WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "age": 25200, "assignment_status": "pending", "attributes": "{\\"body\\": \\"hello\\"}", "date_created": "2014-05-14T18:50:02Z", "date_updated": "2014-05-15T07:26:06Z", "priority": 0, "reason": "Test Reason", "sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "task_queue_sid": "WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "task_channel_sid": "TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "task_channel_unique_name": "task-channel", "timeout": 60, "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workflow_sid": "WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workflow_friendly_name": "Test Workflow", "task_queue_friendly_name": "Test Queue", "addons": "{}", "links": { "task_queue": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workflow": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "reservations": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations" } } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .tasks(sid="WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .tasks(sid="WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .tasks(sid="WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .tasks.list() self.holodeck.assert_has_request(Request( 'get', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks?PageSize=50&Page=0", "key": "tasks", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks?PageSize=50&Page=0" }, "tasks": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "age": 25200, "assignment_status": "pending", "attributes": "{\\"body\\": \\"hello\\"}", "date_created": "2014-05-14T14:26:54Z", "date_updated": "2014-05-15T16:03:42Z", "priority": 0, "reason": "Test Reason", "sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "task_queue_sid": "WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "task_channel_sid": "TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "task_channel_unique_name": "task-channel", "timeout": 60, "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workflow_sid": "WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workflow_friendly_name": "Test Workflow", "task_queue_friendly_name": "Test Queue", "addons": "{}", "links": { "task_queue": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workflow": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "reservations": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations" } } ] } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .tasks.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks?PageSize=50&Page=0", "key": "tasks", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks?PageSize=50&Page=0" }, "tasks": [] } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .tasks.list() self.assertIsNotNone(actual) def test_read_assignment_status_multiple_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks?PageSize=50&Page=0", "key": "tasks", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks?PageSize=50&Page=0" }, "tasks": [] } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .tasks.list() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .tasks.create() self.holodeck.assert_has_request(Request( 'post', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "age": 25200, "assignment_status": "pending", "attributes": "{\\"body\\": \\"attributes\\"}", "date_created": "2014-05-14T18:50:02Z", "date_updated": "2014-05-15T07:26:06Z", "priority": 1, "reason": "Test Reason", "sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "task_queue_sid": "WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "task_channel_sid": "TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "task_channel_unique_name": "unique", "timeout": 60, "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workflow_sid": "WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workflow_friendly_name": "Example Workflow", "task_queue_friendly_name": "Example Task Queue", "addons": "{}", "links": { "task_queue": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workflow": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "reservations": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations" } } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .tasks.create() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/taskrouter/v1/workspace/test_task_channel.py000066400000000000000000000120371317472742600306540ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class TaskChannelTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .task_channels(sid="TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskChannels/TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2014-05-14T10:50:02Z", "date_updated": "2014-05-14T23:26:06Z", "friendly_name": "Default", "sid": "TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "default", "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskChannels/TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .task_channels(sid="TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .task_channels.list() self.holodeck.assert_has_request(Request( 'get', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskChannels', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "channels": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2014-05-14T10:50:02Z", "date_updated": "2014-05-14T23:26:06Z", "friendly_name": "Default", "sid": "TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "default", "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskChannels/TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "meta": { "first_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskChannels?PageSize=50&Page=0", "key": "channels", "last_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskChannels?PageSize=50&Page=0", "next_page_url": null, "page": 0, "page_size": 1, "previous_page_url": null, "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskChannels?PageSize=50&Page=0" } } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .task_channels.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "channels": [], "meta": { "first_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskChannels?PageSize=50&Page=0", "key": "channels", "last_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskChannels?PageSize=50&Page=0", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskChannels?PageSize=50&Page=0" } } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .task_channels.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/taskrouter/v1/workspace/test_task_queue.py000066400000000000000000000370121317472742600303700ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class TaskQueueTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .task_queues(sid="WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "assignment_activity_name": "817ca1c5-3a05-11e5-9292-98e0d9a1eb73", "assignment_activity_sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-08-04T01:31:41Z", "date_updated": "2015-08-04T01:31:41Z", "friendly_name": "81f96435-3a05-11e5-9f81-98e0d9a1eb73", "max_reserved_workers": 1, "links": { "assignment_activity": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities/WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "reservation_activity": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities/WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics", "real_time_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics", "cumulative_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics", "list_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/Statistics" }, "reservation_activity_name": "80fa2beb-3a05-11e5-8fc8-98e0d9a1eb73", "reservation_activity_sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "target_workers": null, "task_order": "FIFO", "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .task_queues(sid="WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .task_queues(sid="WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "assignment_activity_name": "817ca1c5-3a05-11e5-9292-98e0d9a1eb73", "assignment_activity_sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-08-04T01:31:41Z", "date_updated": "2015-08-04T01:31:41Z", "friendly_name": "81f96435-3a05-11e5-9f81-98e0d9a1eb73", "max_reserved_workers": 1, "links": { "assignment_activity": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities/WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "reservation_activity": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities/WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics", "real_time_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics", "cumulative_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics", "list_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/Statistics" }, "reservation_activity_name": "80fa2beb-3a05-11e5-8fc8-98e0d9a1eb73", "reservation_activity_sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "target_workers": null, "task_order": "FIFO", "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .task_queues(sid="WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .task_queues.list() self.holodeck.assert_has_request(Request( 'get', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues?PageSize=50&Page=0", "key": "task_queues", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues?PageSize=50&Page=0" }, "task_queues": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "assignment_activity_name": "817ca1c5-3a05-11e5-9292-98e0d9a1eb73", "assignment_activity_sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-08-04T01:31:41Z", "date_updated": "2015-08-04T01:31:41Z", "friendly_name": "81f96435-3a05-11e5-9f81-98e0d9a1eb73", "max_reserved_workers": 1, "links": { "assignment_activity": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities/WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "reservation_activity": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities/WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics", "real_time_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics", "cumulative_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics", "list_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/Statistics" }, "reservation_activity_name": "80fa2beb-3a05-11e5-8fc8-98e0d9a1eb73", "reservation_activity_sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "target_workers": null, "task_order": "FIFO", "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .task_queues.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues?PageSize=50&Page=0", "key": "task_queues", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues?PageSize=50&Page=0" }, "task_queues": [] } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .task_queues.list() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .task_queues.create(friendly_name="friendly_name", reservation_activity_sid="WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", assignment_activity_sid="WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") values = { 'FriendlyName': "friendly_name", 'ReservationActivitySid': "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 'AssignmentActivitySid': "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", } self.holodeck.assert_has_request(Request( 'post', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "assignment_activity_name": "817ca1c5-3a05-11e5-9292-98e0d9a1eb73", "assignment_activity_sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-08-04T01:31:41Z", "date_updated": "2015-08-04T01:31:41Z", "friendly_name": "81f96435-3a05-11e5-9f81-98e0d9a1eb73", "max_reserved_workers": 1, "links": { "assignment_activity": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities/WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "reservation_activity": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities/WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics", "real_time_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics", "cumulative_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics", "list_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/Statistics" }, "reservation_activity_name": "80fa2beb-3a05-11e5-8fc8-98e0d9a1eb73", "reservation_activity_sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "target_workers": null, "task_order": "FIFO", "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .task_queues.create(friendly_name="friendly_name", reservation_activity_sid="WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", assignment_activity_sid="WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .task_queues(sid="WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues/WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .task_queues(sid="WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) twilio-python-6.8.2/tests/integration/taskrouter/v1/workspace/test_worker.py000066400000000000000000000361101317472742600275310ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class WorkerTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workers.list() self.holodeck.assert_has_request(Request( 'get', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "page": 0, "page_size": 50, "first_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers?PageSize=50&Page=0", "previous_page_url": null, "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers?PageSize=50&Page=0", "next_page_url": null, "key": "workers" }, "workers": [ { "sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "testWorker", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "activity_sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "activity_name": "Offline", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "attributes": "{}", "available": false, "date_created": "2017-05-30T23:05:29Z", "date_updated": "2017-05-30T23:05:29Z", "date_status_changed": "2017-05-30T23:05:29Z", "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "channels": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels", "activity": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities/WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/Statistics", "real_time_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/RealTimeStatistics", "cumulative_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/CumulativeStatistics", "worker_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics", "worker_channels": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels", "reservations": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations" } } ] } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workers.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers?PageSize=50&Page=0", "key": "workers", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers?PageSize=50&Page=0" }, "workers": [] } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workers.list() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workers.create(friendly_name="friendly_name") values = {'FriendlyName': "friendly_name",} self.holodeck.assert_has_request(Request( 'post', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "NewWorker", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "activity_sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "activity_name": "Offline", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "attributes": "{}", "available": false, "date_created": "2017-05-30T23:19:38Z", "date_updated": "2017-05-30T23:19:38Z", "date_status_changed": "2017-05-30T23:19:38Z", "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "channels": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels", "activity": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities/WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/Statistics", "real_time_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/RealTimeStatistics", "cumulative_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/CumulativeStatistics", "worker_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics", "worker_channels": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels", "reservations": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations" } } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workers.create(friendly_name="friendly_name") self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workers(sid="WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "activity_name": "available", "activity_sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "attributes": "{}", "available": false, "date_created": "2017-05-30T23:32:39Z", "date_status_changed": "2017-05-30T23:32:39Z", "date_updated": "2017-05-30T23:32:39Z", "friendly_name": "NewWorker3", "sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "channels": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels", "activity": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities/WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/Statistics", "real_time_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/RealTimeStatistics", "cumulative_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/CumulativeStatistics", "worker_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics", "worker_channels": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels", "reservations": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations" } } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workers(sid="WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workers(sid="WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "blah", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "activity_sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "activity_name": "Offline", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "attributes": "{}", "available": false, "date_created": "2017-05-30T23:32:22Z", "date_updated": "2017-05-31T00:05:57Z", "date_status_changed": "2017-05-30T23:32:22Z", "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "channels": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels", "activity": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities/WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/Statistics", "real_time_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/RealTimeStatistics", "cumulative_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/CumulativeStatistics", "worker_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics", "worker_channels": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels", "reservations": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations" } } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workers(sid="WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workers(sid="WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workers(sid="WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) twilio-python-6.8.2/tests/integration/taskrouter/v1/workspace/test_workflow.py000066400000000000000000000314671317472742600301040ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class WorkflowTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workflows(sid="WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "assignment_callback_url": "http://example.com", "configuration": "task-routing:\\n - filter: \\n - 1 == 1\\n target:\\n - queue: WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\n set-priority: 0\\n", "date_created": "2014-05-14T10:50:02Z", "date_updated": "2014-05-14T23:26:06Z", "document_content_type": "application/json", "fallback_assignment_callback_url": null, "friendly_name": "Default Fifo Workflow", "sid": "WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "task_reservation_timeout": 120, "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics", "real_time_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics", "cumulative_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics" } } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workflows(sid="WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workflows(sid="WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "assignment_callback_url": "http://example.com", "configuration": "task-routing:\\n - filter: \\n - 1 == 1\\n target:\\n - queue: WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\n set-priority: 0\\n", "date_created": "2014-05-14T10:50:02Z", "date_updated": "2014-05-14T23:26:06Z", "document_content_type": "application/json", "fallback_assignment_callback_url": null, "friendly_name": "Default Fifo Workflow", "sid": "WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "task_reservation_timeout": 120, "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics", "real_time_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics", "cumulative_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics" }, "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workflows(sid="WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workflows(sid="WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workflows(sid="WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workflows.list() self.holodeck.assert_has_request(Request( 'get', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows?PageSize=50&Page=0", "key": "workflows", "last_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows?PageSize=50&Page=0", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows?PageSize=50&Page=0" }, "workflows": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "assignment_callback_url": "http://example.com", "configuration": "task-routing:\\n - filter: \\n - 1 == 1\\n target:\\n - queue: WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\n set-priority: 0\\n", "date_created": "2014-05-14T10:50:02Z", "date_updated": "2014-05-15T16:47:51Z", "document_content_type": "application/json", "fallback_assignment_callback_url": null, "friendly_name": "Default Fifo Workflow", "sid": "WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "task_reservation_timeout": 120, "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics", "real_time_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics", "cumulative_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics" }, "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workflows.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows?PageSize=50&Page=0", "key": "workflows", "last_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows?PageSize=50&Page=0", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows?PageSize=50&Page=0" }, "workflows": [] } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workflows.list() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workflows.create(friendly_name="friendly_name", configuration="configuration") values = {'FriendlyName': "friendly_name", 'Configuration': "configuration",} self.holodeck.assert_has_request(Request( 'post', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "assignment_callback_url": "http://example.com", "configuration": "task-routing:\\n - filter: \\n - 1 == 1\\n target:\\n - queue: WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\n set-priority: 0\\n", "date_created": "2014-05-14T10:50:02Z", "date_updated": "2014-05-14T23:26:06Z", "document_content_type": "application/json", "fallback_assignment_callback_url": null, "friendly_name": "Default Fifo Workflow", "sid": "WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "task_reservation_timeout": 120, "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics", "real_time_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics", "cumulative_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics" } } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workflows.create(friendly_name="friendly_name", configuration="configuration") self.assertIsNotNone(actual) test_workspace_cumulative_statistics.py000066400000000000000000000064361317472742600346570ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/taskrouter/v1/workspace# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class WorkspaceCumulativeStatisticsTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .cumulative_statistics().fetch() self.holodeck.assert_has_request(Request( 'get', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "reservations_accepted": 100, "tasks_completed": 100, "start_time": "2015-07-30T20:00:00Z", "reservations_rescinded": 100, "tasks_timed_out_in_workflow": 100, "end_time": "2015-07-30T20:00:00Z", "avg_task_acceptance_time": 100, "tasks_canceled": 100, "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics", "tasks_moved": 100, "tasks_deleted": 100, "tasks_created": 100, "reservations_canceled": 100, "reservations_timed_out": 100, "wait_duration_until_canceled": { "avg": 0, "min": 0, "max": 0, "total": 0 }, "wait_duration_until_accepted": { "avg": 0, "min": 0, "max": 0, "total": 0 }, "split_by_wait_time": { "5": { "above": { "tasks_canceled": 0, "reservations_accepted": 0 }, "below": { "tasks_canceled": 0, "reservations_accepted": 0 } }, "10": { "above": { "tasks_canceled": 0, "reservations_accepted": 0 }, "below": { "tasks_canceled": 0, "reservations_accepted": 0 } } }, "reservations_created": 100, "reservations_rejected": 100, "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .cumulative_statistics().fetch() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/taskrouter/v1/workspace/test_workspace_real_time_statistics.py000066400000000000000000000047571317472742600345250ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class WorkspaceRealTimeStatisticsTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .real_time_statistics().fetch() self.holodeck.assert_has_request(Request( 'get', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics", "tasks_by_priority": {}, "activity_statistics": [ { "friendly_name": "Idle", "workers": 0, "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, { "friendly_name": "Busy", "workers": 9, "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, { "friendly_name": "Offline", "workers": 6, "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, { "friendly_name": "Reserved", "workers": 0, "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "longest_task_waiting_age": 100, "total_workers": 100, "total_tasks": 100, "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "tasks_by_status": {} } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .real_time_statistics().fetch() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/taskrouter/v1/workspace/test_workspace_statistics.py000066400000000000000000000077301317472742600324760ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class WorkspaceStatisticsTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .statistics().fetch() self.holodeck.assert_has_request(Request( 'get', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics", "cumulative": { "avg_task_acceptance_time": 0.0, "start_time": "2008-01-02T00:00:00Z", "reservations_accepted": 0, "reservations_canceled": 0, "reservations_created": 0, "reservations_rejected": 0, "reservations_rescinded": 0, "reservations_timed_out": 0, "end_time": "2008-01-02T00:00:00Z", "tasks_canceled": 0, "tasks_created": 0, "tasks_deleted": 0, "tasks_moved": 0, "tasks_timed_out_in_workflow": 0 }, "realtime": { "activity_statistics": [ { "friendly_name": "Offline", "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workers": 1 }, { "friendly_name": "Idle", "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workers": 0 }, { "friendly_name": "80fa2beb-3a05-11e5-8fc8-98e0d9a1eb73", "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workers": 0 }, { "friendly_name": "Reserved", "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workers": 0 }, { "friendly_name": "Busy", "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workers": 0 }, { "friendly_name": "817ca1c5-3a05-11e5-9292-98e0d9a1eb73", "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workers": 0 } ], "longest_task_waiting_age": 0, "longest_task_waiting_sid": null, "tasks_by_status": { "assigned": 0, "pending": 0, "reserved": 0, "wrapping": 0 }, "total_tasks": 0, "total_workers": 1 }, "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .statistics().fetch() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/taskrouter/v1/workspace/worker/000077500000000000000000000000001317472742600261175ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/taskrouter/v1/workspace/worker/__init__.py000066400000000000000000000001701317472742600302260ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/taskrouter/v1/workspace/worker/test_reservation.py000066400000000000000000000221421317472742600320720ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class ReservationTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workers(sid="WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .reservations.list() self.holodeck.assert_has_request(Request( 'get', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations?PageSize=50&Page=0", "key": "reservations", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations?PageSize=50&Page=0" }, "reservations": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2014-05-14T10:50:02Z", "date_updated": "2014-05-15T16:03:42Z", "links": { "task": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "worker": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, "reservation_status": "accepted", "sid": "WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "task_sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "worker_name": "Doug", "worker_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workers(sid="WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .reservations.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations?PageSize=50&Page=0", "key": "reservations", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations?PageSize=50&Page=0" }, "reservations": [] } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workers(sid="WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .reservations.list() self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workers(sid="WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .reservations(sid="WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2014-05-14T10:50:02Z", "date_updated": "2014-05-15T16:03:42Z", "links": { "task": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "worker": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, "reservation_status": "accepted", "sid": "WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "task_sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "worker_name": "Doug", "worker_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workers(sid="WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .reservations(sid="WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workers(sid="WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .reservations(sid="WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2014-05-14T10:50:02Z", "date_updated": "2014-05-15T16:03:42Z", "links": { "task": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "worker": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, "reservation_status": "accepted", "sid": "WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "task_sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "worker_name": "Doug", "worker_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workers(sid="WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .reservations(sid="WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/taskrouter/v1/workspace/worker/test_worker_channel.py000066400000000000000000000230051317472742600325310ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class WorkerChannelTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workers(sid="WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .worker_channels.list() self.holodeck.assert_has_request(Request( 'get', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0", "key": "channels", "next_page_url": null, "page": 0, "page_size": 1, "previous_page_url": null, "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels" }, "channels": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "assigned_tasks": 0, "available": true, "available_capacity_percentage": 100, "configured_capacity": 1, "date_created": "2014-05-14T10:50:02Z", "date_updated": "2014-05-15T16:03:42Z", "links": { "taskchannel": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskChannels/TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "worker": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, "sid": "WCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "task_channel_sid": "TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "task_channel_unique_name": "default", "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "worker_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workers(sid="WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .worker_channels.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels?PageSize=50&Page=0", "key": "channels", "next_page_url": null, "page": 0, "page_size": 1, "previous_page_url": null, "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels" }, "channels": [] } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workers(sid="WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .worker_channels.list() self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workers(sid="WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .worker_channels(sid="WCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/WCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "assigned_tasks": 0, "available": true, "available_capacity_percentage": 100, "configured_capacity": 1, "date_created": "2014-05-14T10:50:02Z", "date_updated": "2014-05-15T16:03:42Z", "links": { "taskchannel": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskChannels/TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "worker": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, "sid": "WCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "task_channel_sid": "TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "task_channel_unique_name": "default", "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "worker_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workers(sid="WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .worker_channels(sid="WCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workers(sid="WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .worker_channels(sid="WCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/WCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "assigned_tasks": 0, "available": true, "available_capacity_percentage": 100, "configured_capacity": 3, "date_created": "2014-05-14T10:50:02Z", "date_updated": "2014-05-15T16:03:42Z", "links": { "taskchannel": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskChannels/TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "worker": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, "sid": "WCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "task_channel_sid": "TCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "task_channel_unique_name": "default", "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "worker_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workers(sid="WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .worker_channels(sid="WCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/taskrouter/v1/workspace/worker/test_worker_statistics.py000066400000000000000000000071001317472742600333110ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class WorkerStatisticsTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workers(sid="WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .statistics().fetch() self.holodeck.assert_has_request(Request( 'get', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "cumulative": { "reservations_created": 100, "reservations_accepted": 100, "reservations_rejected": 100, "reservations_timed_out": 100, "reservations_canceled": 100, "reservations_rescinded": 100, "activity_durations": [ { "max": 0, "min": 900, "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Offline", "avg": 1080, "total": 5400 }, { "max": 0, "min": 900, "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Busy", "avg": 1012, "total": 8100 }, { "max": 0, "min": 0, "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Idle", "avg": 0, "total": 0 }, { "max": 0, "min": 0, "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Reserved", "avg": 0, "total": 0 } ], "start_time": "2008-01-02T00:00:00Z", "end_time": "2008-01-02T00:00:00Z" }, "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "worker_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics" } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workers(sid="WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .statistics().fetch() self.assertIsNotNone(actual) test_workers_cumulative_statistics.py000066400000000000000000000064211317472742600356600ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/taskrouter/v1/workspace/worker# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class WorkersCumulativeStatisticsTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workers(sid="WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .cumulative_statistics().fetch() self.holodeck.assert_has_request(Request( 'get', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/CumulativeStatistics', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/CumulativeStatistics", "reservations_created": 100, "reservations_accepted": 100, "reservations_rejected": 100, "reservations_timed_out": 100, "reservations_canceled": 100, "reservations_rescinded": 100, "activity_durations": [ { "max": 0, "min": 900, "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Offline", "avg": 1080, "total": 5400 }, { "max": 0, "min": 900, "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Busy", "avg": 1012, "total": 8100 }, { "max": 0, "min": 0, "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Idle", "avg": 0, "total": 0 }, { "max": 0, "min": 0, "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Reserved", "avg": 0, "total": 0 } ], "start_time": "2015-07-30T20:00:00Z", "end_time": "2015-07-30T20:00:00Z" } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workers(sid="WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .cumulative_statistics().fetch() self.assertIsNotNone(actual) test_workers_real_time_statistics.py000066400000000000000000000050201317472742600354350ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/taskrouter/v1/workspace/worker# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class WorkersRealTimeStatisticsTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workers(sid="WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .real_time_statistics().fetch() self.holodeck.assert_has_request(Request( 'get', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/RealTimeStatistics', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/RealTimeStatistics", "total_workers": 15, "activity_statistics": [ { "friendly_name": "Idle", "workers": 0, "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, { "friendly_name": "Busy", "workers": 9, "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, { "friendly_name": "Offline", "workers": 6, "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, { "friendly_name": "Reserved", "workers": 0, "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workers(sid="WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .real_time_statistics().fetch() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/taskrouter/v1/workspace/worker/test_workers_statistics.py000066400000000000000000000105521317472742600335010ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class WorkersStatisticsTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workers \ .statistics().fetch() self.holodeck.assert_has_request(Request( 'get', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/Statistics', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "cumulative": { "reservations_created": 0, "reservations_accepted": 0, "reservations_rejected": 0, "reservations_timed_out": 0, "reservations_canceled": 0, "reservations_rescinded": 0, "activity_durations": [ { "max": 0, "min": 900, "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Offline", "avg": 1080, "total": 5400 }, { "max": 0, "min": 900, "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Busy", "avg": 1012, "total": 8100 }, { "max": 0, "min": 0, "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Idle", "avg": 0, "total": 0 }, { "max": 0, "min": 0, "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "Reserved", "avg": 0, "total": 0 } ], "start_time": "2008-01-02T00:00:00Z", "end_time": "2008-01-02T00:00:00Z" }, "realtime": { "total_workers": 15, "activity_statistics": [ { "friendly_name": "Idle", "workers": 0, "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, { "friendly_name": "Busy", "workers": 9, "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, { "friendly_name": "Offline", "workers": 6, "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, { "friendly_name": "Reserved", "workers": 0, "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] }, "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/Statistics" } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workers \ .statistics().fetch() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/taskrouter/v1/workspace/workflow/000077500000000000000000000000001317472742600264605ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/taskrouter/v1/workspace/workflow/__init__.py000066400000000000000000000001701317472742600305670ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ test_workflow_cumulative_statistics.py000066400000000000000000000071721317472742600364030ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/taskrouter/v1/workspace/workflow# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class WorkflowCumulativeStatisticsTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workflows(sid="WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .cumulative_statistics().fetch() self.holodeck.assert_has_request(Request( 'get', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "avg_task_acceptance_time": 100, "tasks_canceled": 100, "start_time": "2015-07-30T20:00:00Z", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "tasks_moved": 100, "tasks_entered": 100, "wait_duration_until_canceled": { "avg": 0, "min": 0, "max": 0, "total": 0 }, "wait_duration_until_accepted": { "avg": 0, "min": 0, "max": 0, "total": 0 }, "split_by_wait_time": { "5": { "above": { "tasks_canceled": 0, "reservations_accepted": 0 }, "below": { "tasks_canceled": 0, "reservations_accepted": 0 } }, "10": { "above": { "tasks_canceled": 0, "reservations_accepted": 0 }, "below": { "tasks_canceled": 0, "reservations_accepted": 0 } } }, "reservations_canceled": 100, "end_time": "2015-07-30T20:00:00Z", "workflow_sid": "WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "reservations_created": 100, "reservations_accepted": 100, "reservations_rescinded": 100, "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "reservations_rejected": 100, "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics", "tasks_deleted": 100, "tasks_timed_out_in_workflow": 100, "tasks_completed": 100, "reservations_timed_out": 100 } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workflows(sid="WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .cumulative_statistics().fetch() self.assertIsNotNone(actual) test_workflow_real_time_statistics.py000066400000000000000000000041361317472742600361630ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/taskrouter/v1/workspace/workflow# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class WorkflowRealTimeStatisticsTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workflows(sid="WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .real_time_statistics().fetch() self.holodeck.assert_has_request(Request( 'get', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "longest_task_waiting_age": 100, "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics", "tasks_by_priority": {}, "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "tasks_by_status": { "reserved": 0, "pending": 0, "assigned": 0, "wrapping": 0 }, "workflow_sid": "WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "total_tasks": 100, "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workflows(sid="WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .real_time_statistics().fetch() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/taskrouter/v1/workspace/workflow/test_workflow_statistics.py000066400000000000000000000052421317472742600342200ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class WorkflowStatisticsTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workflows(sid="WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .statistics().fetch() self.holodeck.assert_has_request(Request( 'get', 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics", "cumulative": { "avg_task_acceptance_time": 0.0, "end_time": "2008-01-02T00:00:00Z", "reservations_accepted": 0, "reservations_rejected": 0, "reservations_timed_out": 0, "start_time": "2008-01-02T00:00:00Z", "tasks_canceled": 0, "tasks_entered": 0, "tasks_moved": 0, "tasks_timed_out_in_workflow": 0 }, "realtime": { "longest_task_waiting_age": 0, "longest_task_waiting_sid": null, "tasks_by_status": { "assigned": 1, "pending": 0, "reserved": 0, "wrapping": 0 }, "total_tasks": 1 }, "workflow_sid": "WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.taskrouter.v1.workspaces(sid="WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .workflows(sid="WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .statistics().fetch() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/trunking/000077500000000000000000000000001317472742600217205ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/trunking/__init__.py000066400000000000000000000001701317472742600240270ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/trunking/v1/000077500000000000000000000000001317472742600222465ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/trunking/v1/__init__.py000066400000000000000000000001701317472742600243550ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/trunking/v1/test_trunk.py000066400000000000000000000243171317472742600250310ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class TrunkTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "domain_name": "test.pstn.twilio.com", "disaster_recovery_method": "POST", "disaster_recovery_url": "http://disaster-recovery.com", "friendly_name": "friendly_name", "secure": false, "recording": { "mode": "do-not-record", "trim": "do-not-trim" }, "auth_type": "", "auth_type_set": [], "date_created": "2015-01-02T11:23:45Z", "date_updated": "2015-01-02T11:23:45Z", "url": "http://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "origination_urls": "http://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls", "credential_lists": "http://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialLists", "ip_access_control_lists": "http://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlLists", "phone_numbers": "http://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers" } } ''' )) actual = self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.trunking.v1.trunks.create() self.holodeck.assert_has_request(Request( 'post', 'https://trunking.twilio.com/v1/Trunks', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "domain_name": "test.pstn.twilio.com", "disaster_recovery_method": "POST", "disaster_recovery_url": "http://disaster-recovery.com", "friendly_name": "friendly_name", "secure": false, "recording": { "mode": "do-not-record", "trim": "do-not-trim" }, "auth_type": "", "auth_type_set": [], "date_created": "2015-01-02T11:23:45Z", "date_updated": "2015-01-02T11:23:45Z", "url": "http://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "origination_urls": "http://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls", "credential_lists": "http://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialLists", "ip_access_control_lists": "http://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlLists", "phone_numbers": "http://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers" } } ''' )) actual = self.client.trunking.v1.trunks.create() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.trunking.v1.trunks.list() self.holodeck.assert_has_request(Request( 'get', 'https://trunking.twilio.com/v1/Trunks', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://trunking.twilio.com/v1/Trunks?PageSize=1&Page=0", "key": "trunks", "next_page_url": null, "page": 0, "page_size": 1, "previous_page_url": null, "url": "https://trunking.twilio.com/v1/Trunks?PageSize=1&Page=0" }, "trunks": [ { "sid": "TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "domain_name": "test.pstn.twilio.com", "disaster_recovery_method": "POST", "disaster_recovery_url": "http://disaster-recovery.com", "friendly_name": "friendly_name", "secure": false, "recording": { "mode": "do-not-record", "trim": "do-not-trim" }, "auth_type": "", "auth_type_set": [], "date_created": "2015-01-02T11:23:45Z", "date_updated": "2015-01-02T11:23:45Z", "url": "http://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "origination_urls": "http://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls", "credential_lists": "http://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialLists", "ip_access_control_lists": "http://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlLists", "phone_numbers": "http://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers" } } ] } ''' )) actual = self.client.trunking.v1.trunks.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://trunking.twilio.com/v1/Trunks?PageSize=1&Page=0", "key": "trunks", "next_page_url": null, "page": 0, "page_size": 1, "previous_page_url": null, "url": "https://trunking.twilio.com/v1/Trunks?PageSize=1&Page=0" }, "trunks": [] } ''' )) actual = self.client.trunking.v1.trunks.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "domain_name": "test.pstn.twilio.com", "disaster_recovery_method": "GET", "disaster_recovery_url": "http://updated-recovery.com", "friendly_name": "updated_name", "secure": true, "recording": { "mode": "do-not-record", "trim": "do-not-trim" }, "auth_type": "", "auth_type_set": [], "date_created": "2015-01-02T11:23:45Z", "date_updated": "2015-01-02T11:23:45Z", "url": "http://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "origination_urls": "http://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls", "credential_lists": "http://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialLists", "ip_access_control_lists": "http://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlLists", "phone_numbers": "http://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers" } } ''' )) actual = self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/trunking/v1/trunk/000077500000000000000000000000001317472742600234115ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/trunking/v1/trunk/__init__.py000066400000000000000000000001701317472742600255200ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/trunking/v1/trunk/test_credential_list.py000066400000000000000000000161371317472742600301770ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class CredentialListTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .credentials_lists(sid="CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "trunk_sid": "TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Wed, 11 Sep 2013 17:51:38 -0000", "date_updated": "Wed, 11 Sep 2013 17:51:38 -0000", "friendly_name": "Low Rises", "sid": "CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .credentials_lists(sid="CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .credentials_lists(sid="CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .credentials_lists(sid="CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .credentials_lists.create(credential_list_sid="CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") values = {'CredentialListSid': "CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",} self.holodeck.assert_has_request(Request( 'post', 'https://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialLists', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "trunk_sid": "TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Wed, 11 Sep 2013 17:51:38 -0000", "date_updated": "Wed, 11 Sep 2013 17:51:38 -0000", "friendly_name": "Low Rises", "sid": "CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .credentials_lists.create(credential_list_sid="CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .credentials_lists.list() self.holodeck.assert_has_request(Request( 'get', 'https://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialLists', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "credential_lists": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "trunk_sid": "TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "Wed, 11 Sep 2013 17:51:38 -0000", "date_updated": "Wed, 11 Sep 2013 17:51:38 -0000", "friendly_name": "Low Rises", "sid": "CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialLists/CLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "meta": { "page": 0, "page_size": 50, "first_page_url": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialLists?PageSize=50&Page=0", "previous_page_url": null, "url": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialLists?PageSize=50&Page=0", "next_page_url": null, "key": "credential_lists" } } ''' )) actual = self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .credentials_lists.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "credential_lists": [], "meta": { "page": 0, "page_size": 50, "first_page_url": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialLists?PageSize=50&Page=0", "previous_page_url": null, "url": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialLists?PageSize=50&Page=0", "next_page_url": null, "key": "credential_lists" } } ''' )) actual = self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .credentials_lists.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/trunking/v1/trunk/test_ip_access_control_list.py000066400000000000000000000155441317472742600315570ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class IpAccessControlListTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .ip_access_control_lists(sid="ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlLists/ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "friendly_name": "friendly_name", "sid": "ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "trunk_sid": "TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "http://www.example.com" } ''' )) actual = self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .ip_access_control_lists(sid="ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .ip_access_control_lists(sid="ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlLists/ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .ip_access_control_lists(sid="ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .ip_access_control_lists.create(ip_access_control_list_sid="ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") values = {'IpAccessControlListSid': "ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",} self.holodeck.assert_has_request(Request( 'post', 'https://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlLists', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "friendly_name": "friendly_name", "sid": "ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "trunk_sid": "TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "http://www.example.com" } ''' )) actual = self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .ip_access_control_lists.create(ip_access_control_list_sid="ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .ip_access_control_lists.list() self.holodeck.assert_has_request(Request( 'get', 'https://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlLists', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "ip_access_control_lists": [], "meta": { "first_page_url": "https://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlLists?Page=0&PageSize=50", "key": "ip_access_control_lists", "next_page_url": null, "page": 0, "page_size": 0, "previous_page_url": null, "url": "https://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlLists" } } ''' )) actual = self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .ip_access_control_lists.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "ip_access_control_lists": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "friendly_name": "friendly_name", "sid": "ALaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "trunk_sid": "TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "http://www.example.com" } ], "meta": { "first_page_url": "https://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlLists?Page=0&PageSize=50", "key": "ip_access_control_lists", "next_page_url": null, "page": 0, "page_size": 1, "previous_page_url": null, "url": "https://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlLists" } } ''' )) actual = self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .ip_access_control_lists.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/trunking/v1/trunk/test_origination_url.py000066400000000000000000000223761317472742600302400ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class OriginationUrlTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .origination_urls(sid="OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls/OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "weight": 1, "date_updated": "2015-01-02T11:23:45Z", "enabled": true, "friendly_name": "friendly_name", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "priority": 1, "sip_url": "sip://sip-box.com:1234", "sid": "OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-01-02T11:23:45Z", "trunk_sid": "TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls/OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .origination_urls(sid="OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .origination_urls(sid="OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls/OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .origination_urls(sid="OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .origination_urls.create(weight=1, priority=1, enabled=True, friendly_name="friendly_name", sip_url="https://example.com") values = { 'Weight': 1, 'Priority': 1, 'Enabled': True, 'FriendlyName': "friendly_name", 'SipUrl': "https://example.com", } self.holodeck.assert_has_request(Request( 'post', 'https://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "weight": 1, "date_updated": "2015-01-02T11:23:45Z", "enabled": true, "friendly_name": "friendly_name", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "priority": 1, "sip_url": "sip://sip-box.com:1234", "sid": "OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-01-02T11:23:45Z", "trunk_sid": "TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls/OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .origination_urls.create(weight=1, priority=1, enabled=True, friendly_name="friendly_name", sip_url="https://example.com") self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .origination_urls.list() self.holodeck.assert_has_request(Request( 'get', 'https://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls?PageSize=1&Page=0", "key": "origination_urls", "next_page_url": null, "page": 0, "page_size": 1, "previous_page_url": null, "url": "https://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls?PageSize=1&Page=0" }, "origination_urls": [ { "weight": 1, "date_updated": "2015-01-02T11:23:45Z", "enabled": true, "friendly_name": "friendly_name", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "priority": 1, "sip_url": "sip://sip-box.com:1234", "sid": "OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-01-02T11:23:45Z", "trunk_sid": "TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls/OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .origination_urls.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls?PageSize=1&Page=0", "key": "origination_urls", "next_page_url": null, "page": 0, "page_size": 1, "previous_page_url": null, "url": "https://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls?PageSize=1&Page=0" }, "origination_urls": [] } ''' )) actual = self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .origination_urls.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .origination_urls(sid="OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls/OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "weight": 2, "date_updated": "2015-01-02T11:23:45Z", "enabled": false, "friendly_name": "updated_name", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "priority": 2, "sip_url": "sip://sip-updated.com:4321", "sid": "OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-01-02T11:23:45Z", "trunk_sid": "TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls/OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .origination_urls(sid="OUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/trunking/v1/trunk/test_phone_number.py000066400000000000000000000245461317472742600275160ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class PhoneNumberTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .phone_numbers(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2010-12-10T17:27:34Z", "date_updated": "2015-10-09T11:36:32Z", "friendly_name": "(415) 867-5309", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "phone_number": "+14158675309", "api_version": "2010-04-01", "voice_caller_id_lookup": null, "voice_url": "", "voice_method": "POST", "voice_fallback_url": null, "voice_fallback_method": null, "status_callback": "", "status_callback_method": "POST", "voice_application_sid": null, "trunk_sid": "TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sms_url": "", "sms_method": "POST", "sms_fallback_url": "", "sms_fallback_method": "POST", "sms_application_sid": "", "address_requirements": "none", "beta": false, "url": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "capabilities": { "voice": true, "sms": true, "mms": true }, "links": { "phone_number": "https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } } ''' )) actual = self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .phone_numbers(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .phone_numbers(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .phone_numbers(sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .phone_numbers.create(phone_number_sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") values = {'PhoneNumberSid': "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",} self.holodeck.assert_has_request(Request( 'post', 'https://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2010-12-10T17:27:34Z", "date_updated": "2015-10-09T11:36:32Z", "friendly_name": "(415) 867-5309", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "phone_number": "+14158675309", "api_version": "2010-04-01", "voice_caller_id_lookup": null, "voice_url": "", "voice_method": "POST", "voice_fallback_url": null, "voice_fallback_method": null, "status_callback": "", "status_callback_method": "POST", "voice_application_sid": null, "trunk_sid": "TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sms_url": "", "sms_method": "POST", "sms_fallback_url": "", "sms_fallback_method": "POST", "sms_application_sid": "", "address_requirements": "none", "beta": false, "url": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "capabilities": { "voice": true, "sms": true, "mms": true }, "links": { "phone_number": "https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } } ''' )) actual = self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .phone_numbers.create(phone_number_sid="PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .phone_numbers.list() self.holodeck.assert_has_request(Request( 'get', 'https://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers', )) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers?PageSize=1&Page=0", "key": "phone_numbers", "next_page_url": null, "page": 0, "page_size": 1, "previous_page_url": null, "url": "https://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers?PageSize=1&Page=0" }, "phone_numbers": [ { "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2010-12-10T17:27:34Z", "date_updated": "2015-10-09T11:36:32Z", "friendly_name": "(415) 867-5309", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "phone_number": "+14158675309", "api_version": "2010-04-01", "voice_caller_id_lookup": null, "voice_url": "", "voice_method": "POST", "voice_fallback_url": null, "voice_fallback_method": null, "status_callback": "", "status_callback_method": "POST", "voice_application_sid": null, "trunk_sid": "TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sms_url": "", "sms_method": "POST", "sms_fallback_url": "", "sms_fallback_method": "POST", "sms_application_sid": "", "address_requirements": "none", "beta": false, "url": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "capabilities": { "voice": true, "sms": true, "mms": true }, "links": { "phone_number": "https://api.twilio.com/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json" } } ] } ''' )) actual = self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .phone_numbers.list() self.assertIsNotNone(actual) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers?PageSize=1&Page=0", "key": "phone_numbers", "next_page_url": null, "page": 0, "page_size": 1, "previous_page_url": null, "url": "https://trunking.twilio.com/v1/Trunks/TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers?PageSize=1&Page=0" }, "phone_numbers": [] } ''' )) actual = self.client.trunking.v1.trunks(sid="TRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .phone_numbers.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/video/000077500000000000000000000000001317472742600211655ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/video/__init__.py000066400000000000000000000001701317472742600232740ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/video/v1/000077500000000000000000000000001317472742600215135ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/video/v1/__init__.py000066400000000000000000000001701317472742600236220ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/video/v1/room/000077500000000000000000000000001317472742600224675ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/video/v1/room/__init__.py000066400000000000000000000001701317472742600245760ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/video/v1/room/test_recording.py000066400000000000000000000131551317472742600260610ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class RoomRecordingTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.video.v1.rooms(sid="RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings(sid="RTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/RTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "processing", "date_created": "2015-07-30T20:00:00Z", "sid": "RTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "source_sid": "MTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "size": 0, "type": "audio", "duration": 0, "container_format": "mka", "codec": "OPUS", "grouping_sids": { "room_sid": "RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, "room_sid": "RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/RTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "media": "https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/RTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media" } } ''' )) actual = self.client.video.v1.rooms(sid="RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings(sid="RTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.video.v1.rooms(sid="RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings.list() self.holodeck.assert_has_request(Request( 'get', 'https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "recordings": [], "meta": { "page": 0, "page_size": 50, "first_page_url": "https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings?PageSize=50&Page=0", "previous_page_url": null, "url": "https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings?PageSize=50&Page=0", "next_page_url": null, "key": "recordings" } } ''' )) actual = self.client.video.v1.rooms(sid="RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings.list() self.assertIsNotNone(actual) def test_read_results_response(self): self.holodeck.mock(Response( 200, ''' { "recordings": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "completed", "date_created": "2015-07-30T20:00:00Z", "sid": "RTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "source_sid": "MTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "size": 23, "type": "audio", "duration": 10, "container_format": "mka", "codec": "OPUS", "grouping_sids": { "room_sid": "RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "participant_sid": "PAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, "room_sid": "RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/RTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "media": "https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings/RTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media" } } ], "meta": { "page": 0, "page_size": 50, "first_page_url": "https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings?PageSize=50&Page=0", "previous_page_url": null, "url": "https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings?PageSize=50&Page=0", "next_page_url": null, "key": "recordings" } } ''' )) actual = self.client.video.v1.rooms(sid="RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .recordings.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/video/v1/test_recording.py000066400000000000000000000124431317472742600251040ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class RecordingTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.video.v1.recordings(sid="RTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://video.twilio.com/v1/Recordings/RTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "processing", "date_created": "2015-07-30T20:00:00Z", "sid": "RTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "source_sid": "MTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "size": 0, "url": "https://video.twilio.com/v1/Recordings/RTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "type": "audio", "duration": 0, "container_format": "mka", "codec": "OPUS", "grouping_sids": { "room_sid": "RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, "links": { "media": "https://video.twilio.com/v1/Recordings/RTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media" } } ''' )) actual = self.client.video.v1.recordings(sid="RTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.video.v1.recordings.list() self.holodeck.assert_has_request(Request( 'get', 'https://video.twilio.com/v1/Recordings', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "recordings": [], "meta": { "page": 0, "page_size": 50, "first_page_url": "https://video.twilio.com/v1/Recordings?PageSize=50&Page=0", "previous_page_url": null, "url": "https://video.twilio.com/v1/Recordings?PageSize=50&Page=0", "next_page_url": null, "key": "recordings" } } ''' )) actual = self.client.video.v1.recordings.list() self.assertIsNotNone(actual) def test_read_results_response(self): self.holodeck.mock(Response( 200, ''' { "recordings": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "completed", "date_created": "2015-07-30T20:00:00Z", "sid": "RTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "source_sid": "MTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "size": 23, "type": "audio", "duration": 10, "container_format": "mka", "codec": "OPUS", "grouping_sids": { "room_sid": "RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "participant_sid": "PAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, "url": "https://video.twilio.com/v1/Recordings/RTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "media": "https://video.twilio.com/v1/Recordings/RTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media" } } ], "meta": { "page": 0, "page_size": 50, "first_page_url": "https://video.twilio.com/v1/Recordings?PageSize=50&Page=0", "previous_page_url": null, "url": "https://video.twilio.com/v1/Recordings?PageSize=50&Page=0", "next_page_url": null, "key": "recordings" } } ''' )) actual = self.client.video.v1.recordings.list() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.video.v1.recordings(sid="RTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://video.twilio.com/v1/Recordings/RTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.video.v1.recordings(sid="RTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) twilio-python-6.8.2/tests/integration/video/v1/test_room.py000066400000000000000000000203071317472742600241020ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class RoomTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.video.v1.rooms(sid="RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "status": "in-progress", "type": "peer-to-peer", "sid": "RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "enable_turn": true, "unique_name": "unique_name", "max_participants": 10, "duration": 0, "status_callback_method": "POST", "status_callback": "", "record_participants_on_connect": false, "video_codecs": [ "VP8" ], "end_time": "2015-07-30T20:00:00Z", "url": "https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "recordings": "https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings" } } ''' )) actual = self.client.video.v1.rooms(sid="RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.video.v1.rooms.create() self.holodeck.assert_has_request(Request( 'post', 'https://video.twilio.com/v1/Rooms', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "status": "in-progress", "type": "peer-to-peer", "sid": "RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "enable_turn": true, "unique_name": "RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "max_participants": 10, "duration": 0, "status_callback_method": "POST", "status_callback": "", "record_participants_on_connect": false, "video_codecs": [ "VP8" ], "end_time": "2015-07-30T20:00:00Z", "url": "https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "recordings": "https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings" } } ''' )) actual = self.client.video.v1.rooms.create() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.video.v1.rooms.list() self.holodeck.assert_has_request(Request( 'get', 'https://video.twilio.com/v1/Rooms', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "rooms": [], "meta": { "page": 0, "page_size": 50, "first_page_url": "https://video.twilio.com/v1/Rooms?PageSize=50&Page=0", "previous_page_url": null, "url": "https://video.twilio.com/v1/Rooms?PageSize=50&Page=0", "next_page_url": null, "key": "rooms" } } ''' )) actual = self.client.video.v1.rooms.list() self.assertIsNotNone(actual) def test_read_with_status_response(self): self.holodeck.mock(Response( 200, ''' { "rooms": [ { "sid": "RM4070b618362c1682b2385b1f9982833c", "status": "completed", "date_created": "2017-04-03T22:21:49Z", "date_updated": "2017-04-03T22:21:51Z", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "type": "peer-to-peer", "enable_turn": true, "unique_name": "RM4070b618362c1682b2385b1f9982833c", "status_callback": null, "status_callback_method": "POST", "end_time": "2017-04-03T22:21:51Z", "duration": 2, "max_participants": 10, "record_participants_on_connect": false, "video_codecs": [ "VP8" ], "url": "https://video.twilio.com/v1/Rooms/RM4070b618362c1682b2385b1f9982833c", "links": { "recordings": "https://video.twilio.com/v1/Rooms/RM4070b618362c1682b2385b1f9982833c/Recordings" } } ], "meta": { "page": 0, "page_size": 50, "first_page_url": "https://video.twilio.com/v1/Rooms?PageSize=50&Page=0", "previous_page_url": null, "url": "https://video.twilio.com/v1/Rooms?PageSize=50&Page=0", "next_page_url": null, "key": "rooms" } } ''' )) actual = self.client.video.v1.rooms.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.video.v1.rooms(sid="RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update(status="in-progress") values = {'Status': "in-progress",} self.holodeck.assert_has_request(Request( 'post', 'https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', data=values, )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "status": "completed", "type": "peer-to-peer", "sid": "RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "enable_turn": true, "unique_name": "unique_name", "max_participants": 10, "status_callback_method": "POST", "status_callback": "", "record_participants_on_connect": false, "video_codecs": [ "VP8" ], "end_time": "2015-07-30T20:00:00Z", "duration": 10, "url": "https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "links": { "recordings": "https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings" } } ''' )) actual = self.client.video.v1.rooms(sid="RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update(status="in-progress") self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/wireless/000077500000000000000000000000001317472742600217145ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/wireless/__init__.py000066400000000000000000000001701317472742600240230ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/wireless/v1/000077500000000000000000000000001317472742600222425ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/wireless/v1/__init__.py000066400000000000000000000001701317472742600243510ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/wireless/v1/sim/000077500000000000000000000000001317472742600230325ustar00rootroot00000000000000twilio-python-6.8.2/tests/integration/wireless/v1/sim/__init__.py000066400000000000000000000001701317472742600251410ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ twilio-python-6.8.2/tests/integration/wireless/v1/sim/test_data_session.py000066400000000000000000000065101317472742600271210ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class DataSessionTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.wireless.v1.sims(sid="DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .data_sessions.list() self.holodeck.assert_has_request(Request( 'get', 'https://wireless.twilio.com/v1/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/DataSessions', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "data_sessions": [ { "sid": "WNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sim_sid": "DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "radio_link": "LTE", "operator_mcc": 0, "operator_mnc": 0, "operator_country": "", "operator_name": "", "cell_id": "", "cell_location_estimate": {}, "packets_uploaded": 0, "packets_downloaded": 0, "last_updated": "2015-07-30T20:00:00Z", "start": "2015-07-30T20:00:00Z", "end": null }, { "sid": "WNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sim_sid": "DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "radio_link": "3G", "operator_mcc": 0, "operator_mnc": 0, "operator_country": "", "operator_name": "", "cell_id": "", "cell_location_estimate": {}, "packets_uploaded": 0, "packets_downloaded": 0, "last_updated": "2015-07-30T20:00:00Z", "start": "2015-07-30T20:00:00Z", "end": "2015-07-30T20:00:00Z" } ], "meta": { "first_page_url": "https://wireless.twilio.com/v1/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/DataSessions?PageSize=50&Page=0", "key": "data_sessions", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://wireless.twilio.com/v1/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/DataSessions?PageSize=50&Page=0" } } ''' )) actual = self.client.wireless.v1.sims(sid="DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .data_sessions.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/wireless/v1/sim/test_usage_record.py000066400000000000000000000044331317472742600271110ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class UsageRecordTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.wireless.v1.sims(sid="DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage_records.list() self.holodeck.assert_has_request(Request( 'get', 'https://wireless.twilio.com/v1/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/UsageRecords', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "usage_records": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "commands": {}, "data": {}, "sim_sid": "DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "period": {} }, { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "commands": {}, "data": {}, "sim_sid": "DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "period": {} } ], "meta": { "first_page_url": "https://wireless.twilio.com/v1/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/UsageRecords?PageSize=50&Page=0", "key": "usage_records", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://wireless.twilio.com/v1/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/UsageRecords?PageSize=50&Page=0" } } ''' )) actual = self.client.wireless.v1.sims(sid="DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \ .usage_records.list() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/wireless/v1/test_command.py000066400000000000000000000122671317472742600253010ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class CommandTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.wireless.v1.commands(sid="DCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://wireless.twilio.com/v1/Commands/DCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "command": "command", "command_mode": "text", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "sim_sid": "DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "direction": "from_sim", "sid": "DCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "queued", "url": "https://wireless.twilio.com/v1/Commands/DCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.wireless.v1.commands(sid="DCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.wireless.v1.commands.list() self.holodeck.assert_has_request(Request( 'get', 'https://wireless.twilio.com/v1/Commands', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "commands": [], "meta": { "first_page_url": "https://wireless.twilio.com/v1/Commands?PageSize=50&Page=0", "key": "commands", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://wireless.twilio.com/v1/Commands?PageSize=50&Page=0" } } ''' )) actual = self.client.wireless.v1.commands.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "commands": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "command": "command", "command_mode": "text", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "sim_sid": "DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "direction": "from_sim", "sid": "DCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "queued", "url": "https://wireless.twilio.com/v1/Commands/DCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "meta": { "first_page_url": "https://wireless.twilio.com/v1/Commands?PageSize=50&Page=0", "key": "commands", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://wireless.twilio.com/v1/Commands?PageSize=50&Page=0" } } ''' )) actual = self.client.wireless.v1.commands.list() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.wireless.v1.commands.create(command="command") values = {'Command': "command",} self.holodeck.assert_has_request(Request( 'post', 'https://wireless.twilio.com/v1/Commands', data=values, )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "command": "command", "command_mode": "text", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "sim_sid": "DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "direction": "from_sim", "sid": "DCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "queued", "url": "https://wireless.twilio.com/v1/Commands/DCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.wireless.v1.commands.create(command="command") self.assertIsNotNone(actual) twilio-python-6.8.2/tests/integration/wireless/v1/test_rate_plan.py000066400000000000000000000211331317472742600256200ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class RatePlanTestCase(IntegrationTestCase): def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.wireless.v1.rate_plans.list() self.holodeck.assert_has_request(Request( 'get', 'https://wireless.twilio.com/v1/RatePlans', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://wireless.twilio.com/v1/RatePlans?PageSize=50&Page=0", "key": "rate_plans", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://wireless.twilio.com/v1/RatePlans?PageSize=50&Page=0" }, "rate_plans": [] } ''' )) actual = self.client.wireless.v1.rate_plans.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "first_page_url": "https://wireless.twilio.com/v1/RatePlans?PageSize=50&Page=0", "key": "rate_plans", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://wireless.twilio.com/v1/RatePlans?PageSize=50&Page=0" }, "rate_plans": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "data_enabled": true, "data_limit": 1000, "data_metering": "pooled", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "friendly_name": "friendly_name", "messaging_enabled": true, "voice_enabled": true, "national_roaming_enabled": true, "national_roaming_data_limit": 1000, "international_roaming": [ "data", "messaging", "voice" ], "international_roaming_data_limit": 1000, "sid": "WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://wireless.twilio.com/v1/RatePlans/WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] } ''' )) actual = self.client.wireless.v1.rate_plans.list() self.assertIsNotNone(actual) def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.wireless.v1.rate_plans(sid="WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://wireless.twilio.com/v1/RatePlans/WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "data_enabled": true, "data_limit": 1000, "data_metering": "pooled", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "friendly_name": "friendly_name", "messaging_enabled": true, "voice_enabled": true, "national_roaming_enabled": true, "national_roaming_data_limit": 1000, "international_roaming": [ "data", "messaging", "voice" ], "international_roaming_data_limit": 1000, "sid": "WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://wireless.twilio.com/v1/RatePlans/WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.wireless.v1.rate_plans(sid="WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_create_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.wireless.v1.rate_plans.create() self.holodeck.assert_has_request(Request( 'post', 'https://wireless.twilio.com/v1/RatePlans', )) def test_create_response(self): self.holodeck.mock(Response( 201, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "data_enabled": true, "data_limit": 1000, "data_metering": "pooled", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "friendly_name": "friendly_name", "messaging_enabled": true, "voice_enabled": true, "national_roaming_enabled": true, "national_roaming_data_limit": 1000, "international_roaming": [ "data", "messaging", "voice" ], "international_roaming_data_limit": 1000, "sid": "WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://wireless.twilio.com/v1/RatePlans/WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.wireless.v1.rate_plans.create() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.wireless.v1.rate_plans(sid="WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://wireless.twilio.com/v1/RatePlans/WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "data_enabled": true, "data_limit": 1000, "data_metering": "pooled", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "friendly_name": "friendly_name", "messaging_enabled": true, "voice_enabled": true, "national_roaming_enabled": true, "national_roaming_data_limit": 1000, "international_roaming": [ "data", "messaging", "voice" ], "international_roaming_data_limit": 1000, "sid": "WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://wireless.twilio.com/v1/RatePlans/WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ''' )) actual = self.client.wireless.v1.rate_plans(sid="WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) def test_delete_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.wireless.v1.rate_plans(sid="WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.holodeck.assert_has_request(Request( 'delete', 'https://wireless.twilio.com/v1/RatePlans/WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_delete_response(self): self.holodeck.mock(Response( 204, None, )) actual = self.client.wireless.v1.rate_plans(sid="WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").delete() self.assertTrue(actual) twilio-python-6.8.2/tests/integration/wireless/v1/test_sim.py000066400000000000000000000205411317472742600244450ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.base.exceptions import TwilioException from twilio.http.response import Response class SimTestCase(IntegrationTestCase): def test_fetch_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.wireless.v1.sims(sid="DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.holodeck.assert_has_request(Request( 'get', 'https://wireless.twilio.com/v1/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_fetch_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "commands_callback_method": "http_method", "commands_callback_url": "http://www.example.com", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "friendly_name": "friendly_name", "sms_fallback_method": "http_method", "sms_fallback_url": "http://www.example.com", "sms_method": "http_method", "sms_url": "http://www.example.com", "voice_fallback_method": "http_method", "voice_fallback_url": "http://www.example.com", "voice_method": "http_method", "voice_url": "http://www.example.com", "links": { "data_sessions": "https://wireless.twilio.com/v1/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/DataSessions", "rate_plan": "https://wireless.twilio.com/v1/RatePlans/WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "usage_records": "https://wireless.twilio.com/v1/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/UsageRecords" }, "rate_plan_sid": "WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "iccid": "iccid", "e_id": "e_id", "status": "new", "url": "https://wireless.twilio.com/v1/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "ip_address": "192.168.1.1" } ''' )) actual = self.client.wireless.v1.sims(sid="DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch() self.assertIsNotNone(actual) def test_list_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.wireless.v1.sims.list() self.holodeck.assert_has_request(Request( 'get', 'https://wireless.twilio.com/v1/Sims', )) def test_read_empty_response(self): self.holodeck.mock(Response( 200, ''' { "sims": [], "meta": { "first_page_url": "https://wireless.twilio.com/v1/Sims?PageSize=50&Page=0", "key": "sims", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://wireless.twilio.com/v1/Sims?PageSize=50&Page=0" } } ''' )) actual = self.client.wireless.v1.sims.list() self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "sims": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "commands_callback_method": "http_method", "commands_callback_url": "http://www.example.com", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "friendly_name": "friendly_name", "links": { "data_sessions": "https://wireless.twilio.com/v1/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/DataSessions", "rate_plan": "https://wireless.twilio.com/v1/RatePlans/WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "usage_records": "https://wireless.twilio.com/v1/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/UsageRecords" }, "rate_plan_sid": "WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "iccid": "iccid", "e_id": "e_id", "status": "new", "sms_fallback_method": "http_method", "sms_fallback_url": "http://www.example.com", "sms_method": "http_method", "sms_url": "http://www.example.com", "voice_fallback_method": "http_method", "voice_fallback_url": "http://www.example.com", "voice_method": "http_method", "voice_url": "http://www.example.com", "url": "https://wireless.twilio.com/v1/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "ip_address": "192.168.1.30" } ], "meta": { "first_page_url": "https://wireless.twilio.com/v1/Sims?PageSize=50&Page=0", "key": "sims", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://wireless.twilio.com/v1/Sims?PageSize=50&Page=0" } } ''' )) actual = self.client.wireless.v1.sims.list() self.assertIsNotNone(actual) def test_update_request(self): self.holodeck.mock(Response(500, '')) with self.assertRaises(TwilioException): self.client.wireless.v1.sims(sid="DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.holodeck.assert_has_request(Request( 'post', 'https://wireless.twilio.com/v1/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', )) def test_update_response(self): self.holodeck.mock(Response( 200, ''' { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "unique_name": "unique_name", "commands_callback_method": "http_method", "commands_callback_url": "http://www.example.com", "date_created": "2015-07-30T20:00:00Z", "date_updated": "2015-07-30T20:00:00Z", "friendly_name": "friendly_name", "links": { "data_sessions": "https://wireless.twilio.com/v1/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/DataSessions", "rate_plan": "https://wireless.twilio.com/v1/RatePlans/WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "usage_records": "https://wireless.twilio.com/v1/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/UsageRecords" }, "rate_plan_sid": "WPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sid": "DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "iccid": "iccid", "e_id": "e_id", "status": "new", "sms_fallback_method": "http_method", "sms_fallback_url": "http://www.example.com", "sms_method": "http_method", "sms_url": "http://www.example.com", "voice_fallback_method": "http_method", "voice_fallback_url": "http://www.example.com", "voice_method": "http_method", "voice_url": "http://www.example.com", "url": "https://wireless.twilio.com/v1/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "ip_address": "192.168.1.30" } ''' )) actual = self.client.wireless.v1.sims(sid="DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update() self.assertIsNotNone(actual) twilio-python-6.8.2/tests/requirements.txt000066400000000000000000000001331317472742600210150ustar00rootroot00000000000000sphinx mock==0.8.0 nose coverage nosexcover flake8 mccabe wheel>=0.22.0 cryptography twine twilio-python-6.8.2/tests/unit/000077500000000000000000000000001317472742600165135ustar00rootroot00000000000000twilio-python-6.8.2/tests/unit/__init__.py000066400000000000000000000000011317472742600206130ustar00rootroot00000000000000 twilio-python-6.8.2/tests/unit/base/000077500000000000000000000000001317472742600174255ustar00rootroot00000000000000twilio-python-6.8.2/tests/unit/base/__init__.py000066400000000000000000000000011317472742600215250ustar00rootroot00000000000000 twilio-python-6.8.2/tests/unit/base/test_deserialize.py000066400000000000000000000046011317472742600233370ustar00rootroot00000000000000import datetime import unittest from decimal import Decimal import pytz from twilio.base import deserialize class Iso8601DateTestCase(unittest.TestCase): def test_parsable(self): actual = deserialize.iso8601_date('2015-01-02') expected = datetime.date(2015, 1, 2) self.assertEqual(expected, actual) def test_not_parsable(self): actual = deserialize.iso8601_date('not-a-date') self.assertEqual('not-a-date', actual) 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) self.assertEqual(expected, actual) def test_not_parsable(self): actual = deserialize.iso8601_datetime('not-a-datetime') self.assertEqual('not-a-datetime', actual) class DecimalTestCase(unittest.TestCase): def test_none(self): self.assertEqual(None, deserialize.decimal(None)) def test_empty_string(self): self.assertEqual('', deserialize.decimal('')) def test_zero_string(self): self.assertEqual(Decimal('0.0000'), deserialize.decimal('0.0000')) def test_negative_string(self): self.assertEqual(Decimal('-0.0123'), deserialize.decimal('-0.0123')) def test_positive_string(self): self.assertEqual(Decimal('0.0123'), deserialize.decimal('0.0123')) def test_zero(self): self.assertEqual(0, deserialize.decimal(0)) def test_negative(self): self.assertEqual(-0.0123, deserialize.decimal(-0.0123)) def test_positive(self): self.assertEqual(0.0123, deserialize.decimal(0.0123)) class IntegerTestCase(unittest.TestCase): def test_none(self): self.assertEqual(None, deserialize.integer(None)) def test_empty_string(self): self.assertEqual('', deserialize.integer('')) def test_zero_string(self): self.assertEqual(0, deserialize.integer('0')) def test_negative_string(self): self.assertEqual(-1, deserialize.integer('-1')) def test_positive_string(self): self.assertEqual(1, deserialize.integer('1')) def test_zero(self): self.assertEqual(0, deserialize.integer(0)) def test_negative(self): self.assertEqual(-1, deserialize.integer(-1)) def test_positive(self): self.assertEqual(1, deserialize.integer(1)) twilio-python-6.8.2/tests/unit/base/test_serialize.py000066400000000000000000000071471317472742600230360ustar00rootroot00000000000000import datetime import unittest from twilio.base import serialize, values class Iso8601DateTestCase(unittest.TestCase): def test_unset(self): value = values.unset actual = serialize.iso8601_date(value) self.assertEqual(values.unset, actual) def test_datetime(self): value = datetime.datetime(2015, 1, 2, 12, 0, 0, 0) actual = serialize.iso8601_date(value) self.assertEqual('2015-01-02', actual) def test_datetime_without_time(self): value = datetime.datetime(2015, 1, 2) actual = serialize.iso8601_date(value) self.assertEqual('2015-01-02', actual) def test_date(self): value = datetime.date(2015, 1, 2) actual = serialize.iso8601_date(value) self.assertEqual('2015-01-02', actual) def test_str(self): actual = serialize.iso8601_date('2015-01-02') self.assertEqual('2015-01-02', actual) class Iso8601DateTimeTestCase(unittest.TestCase): def test_unset(self): value = values.unset actual = serialize.iso8601_datetime(value) self.assertEqual(values.unset, actual) def test_datetime(self): value = datetime.datetime(2015, 1, 2, 3, 4, 5, 6) actual = serialize.iso8601_datetime(value) self.assertEqual('2015-01-02T03:04:05Z', actual) def test_datetime_without_time(self): value = datetime.datetime(2015, 1, 2) actual = serialize.iso8601_datetime(value) self.assertEqual('2015-01-02T00:00:00Z', actual) def test_date(self): value = datetime.date(2015, 1, 2) actual = serialize.iso8601_datetime(value) self.assertEqual('2015-01-02T00:00:00Z', actual) def test_str(self): actual = serialize.iso8601_datetime('2015-01-02T03:04:05Z') self.assertEqual('2015-01-02T03:04:05Z', actual) class PrefixedCollapsibleMapTestCase(unittest.TestCase): def test_unset(self): value = values.unset actual = serialize.prefixed_collapsible_map(value, 'Prefix') self.assertEqual({}, actual) def test_single_key(self): value = { 'foo': 'bar' } actual = serialize.prefixed_collapsible_map(value, 'Prefix') self.assertEqual({ 'Prefix.foo': 'bar' }, actual) def test_nested_key(self): value = { 'foo': { 'bar': 'baz' } } actual = serialize.prefixed_collapsible_map(value, 'Prefix') self.assertEqual({ 'Prefix.foo.bar': 'baz' }, actual) def test_multiple_keys(self): value = { 'watson': { 'language': 'en', 'alice': 'bob' }, 'foo': 'bar' } actual = serialize.prefixed_collapsible_map(value, 'Prefix') self.assertEqual({ 'Prefix.watson.language': 'en', 'Prefix.watson.alice': 'bob', 'Prefix.foo': 'bar' }, actual) def test_list(self): value = [ 'foo', 'bar' ] actual = serialize.prefixed_collapsible_map(value, 'Prefix') self.assertEqual({}, actual) class ObjectTestCase(unittest.TestCase): def test_object(self): actual = serialize.object({'twilio': 'rocks'}) self.assertEqual('{"twilio": "rocks"}', actual) def test_list(self): actual = serialize.object(['twilio', 'rocks']) self.assertEqual('["twilio", "rocks"]', actual) def test_does_not_change_other_types(self): actual = serialize.object('{"attribute":"value"}') self.assertEqual('{"attribute":"value"}', actual) twilio-python-6.8.2/tests/unit/http/000077500000000000000000000000001317472742600174725ustar00rootroot00000000000000twilio-python-6.8.2/tests/unit/http/__init__.py000066400000000000000000000000001317472742600215710ustar00rootroot00000000000000twilio-python-6.8.2/tests/unit/http/test_http_client.py000066400000000000000000000116611317472742600234250ustar00rootroot00000000000000# -*- coding: utf-8 -*- import six import unittest import mock from mock import patch, Mock from requests import Request from requests import Session from twilio.http.http_client import TwilioHttpClient from twilio.http.response import Response class TestHttpClientRequest(unittest.TestCase): def setUp(self): self.session_patcher = patch('twilio.http.http_client.Session') self.session_mock = Mock(wraps=Session()) self.request_mock = Mock() self.session_mock.prepare_request.return_value = self.request_mock self.session_mock.send.return_value = Response(200, 'testing-unicode: Ω≈ç√, 💩') self.request_mock.headers = {} session_constructor_mock = self.session_patcher.start() session_constructor_mock.return_value = self.session_mock self.client = TwilioHttpClient() def tearDown(self): self.session_patcher.stop() def test_request_sets_host_header_if_missing(self): self.request_mock.url = 'https://api.twilio.com/' self.request_mock.headers = {'Host': 'other.twilio.com'} self.client.request('doesnt matter', 'doesnt matter') self.assertEqual('other.twilio.com', self.request_mock.headers['Host']) self.assertIsNotNone(self.client.last_request) self.assertIsNotNone(self.client.last_response) def test_request_with_unicode_response(self): self.request_mock.url = 'https://api.twilio.com/' self.request_mock.headers = {'Host': 'other.twilio.com'} response = self.client.request('doesnt matter', 'doesnt matter') self.assertEqual('other.twilio.com', self.request_mock.headers['Host']) self.assertEqual(200, response.status_code) self.assertEqual('testing-unicode: Ω≈ç√, 💩', response.content) def test_last_request_last_response_exist(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'}, {'data-value': 'data-key'}, {'headers-value': 'headers-key'}, ['a', 'b']) self.assertIsNotNone(self.client.last_request) self.assertEqual('doesnt-matter-url', self.client.last_request.url) self.assertEqual('DOESNT-MATTER-METHOD', self.client.last_request.method) self.assertEqual({'params-value': 'params-key'}, self.client.last_request.params) self.assertEqual({'data-value': 'data-key'}, self.client.last_request.data) self.assertEqual({'headers-value': 'headers-key'}, self.client.last_request.headers) self.assertEqual(['a', 'b'], self.client.last_request.auth) self.assertIsNotNone(self.client.last_response) self.assertEqual(200, self.client.last_response.status_code) self.assertEqual('testing-unicode: Ω≈ç√, 💩', self.client.last_response.text) def test_last_response_empty_on_error(self): self.session_mock.send.side_effect = Exception('voltron') with self.assertRaises(Exception): self.client.request('doesnt-matter', 'doesnt-matter') self.assertIsNotNone(self.client.last_request) self.assertIsNone(self.client.last_response) class TestHttpClientSession(unittest.TestCase): def setUp(self): self.session_patcher = patch('twilio.http.http_client.Session') self.session_constructor_mock = self.session_patcher.start() def tearDown(self): self.session_patcher.stop() def _setup_session_response(self, value): session_mock = Mock(wraps=Session()) request_mock = Mock() session_mock.prepare_request.return_value = request_mock session_mock.send.return_value = Response(200, value) self.session_constructor_mock.return_value = session_mock def test_session_preserved(self): self._setup_session_response('response_1') client = TwilioHttpClient() response_1 = client.request('GET', 'https://api.twilio.com') self._setup_session_response('response_2') response_2 = client.request('GET', 'https://api.twilio.com') # Used same session, response should be the same self.assertEqual(response_1.content, 'response_1') self.assertEqual(response_2.content, 'response_1') def test_session_not_preserved(self): self._setup_session_response('response_1') client = TwilioHttpClient(pool_connections=False) response_1 = client.request('GET', 'https://api.twilio.com') self._setup_session_response('response_2') response_2 = client.request('GET', 'https://api.twilio.com') # Used different session, responses should be different self.assertEqual(response_1.content, 'response_1') self.assertEqual(response_2.content, 'response_2') twilio-python-6.8.2/tests/unit/http/test_validation_client.py000066400000000000000000000123511317472742600245750ustar00rootroot00000000000000# -*- coding: utf-8 -*- import unittest import mock from mock import patch, Mock from requests import Request from requests import Session from twilio.http.validation_client import ValidationClient from twilio.http.response import Response class TestValidationClientHelpers(unittest.TestCase): def setUp(self): self.request = Request( 'GET', 'https://api.twilio.com/2010-04-01/Accounts/AC123/Messages', auth=('Username', 'Password'), ) self.request = self.request.prepare() self.client = ValidationClient('AC123', 'SK123', 'CR123', 'private_key') def test_build_validation_payload_basic(self): validation_payload = self.client._build_validation_payload(self.request) self.assertEqual('GET', validation_payload.method) self.assertEqual('/2010-04-01/Accounts/AC123/Messages', validation_payload.path) self.assertEqual('', validation_payload.query_string) self.assertEqual(['authorization', 'host'], validation_payload.signed_headers) self.assertEqual('', validation_payload.body) def test_build_validation_payload_query_string_parsed(self): self.request.url = self.request.url + '?QueryParam=1&Other=true' validation_payload = self.client._build_validation_payload(self.request) self.assertEqual('GET', validation_payload.method) self.assertEqual('/2010-04-01/Accounts/AC123/Messages', validation_payload.path) self.assertEqual('QueryParam=1&Other=true', validation_payload.query_string) self.assertEqual(['authorization', 'host'], validation_payload.signed_headers) self.assertEqual('', validation_payload.body) def test_build_validation_payload_body_parsed(self): self.request.body = 'foobar' validation_payload = self.client._build_validation_payload(self.request) self.assertEqual('GET', validation_payload.method) self.assertEqual('/2010-04-01/Accounts/AC123/Messages', validation_payload.path) self.assertEqual('', validation_payload.query_string) self.assertEqual(['authorization', 'host'], validation_payload.signed_headers) self.assertEqual('foobar', validation_payload.body) def test_build_validation_payload_complex(self): self.request.body = 'foobar' self.request.url = self.request.url + '?QueryParam=Value&OtherQueryParam=OtherValue' validation_payload = self.client._build_validation_payload(self.request) self.assertEqual('GET', validation_payload.method) self.assertEqual('/2010-04-01/Accounts/AC123/Messages', validation_payload.path) self.assertEqual(['authorization', 'host'], validation_payload.signed_headers) self.assertEqual('foobar', validation_payload.body) self.assertEqual('QueryParam=Value&OtherQueryParam=OtherValue', validation_payload.query_string) def test_get_host(self): self.assertEqual('api.twilio.com', self.client._get_host(self.request)) class TestValidationClientRequest(unittest.TestCase): def setUp(self): self.session_patcher = patch('twilio.http.validation_client.Session') self.jwt_patcher = patch('twilio.http.validation_client.ClientValidationJwt') self.session_mock = Mock(wraps=Session()) self.validation_token = self.jwt_patcher.start() self.request_mock = Mock() self.session_mock.prepare_request.return_value = self.request_mock self.session_mock.send.return_value = Response(200, 'test, omega: Ω, pile of poop: 💩') self.validation_token.return_value.to_jwt.return_value = 'test-token' self.request_mock.headers = {} session_constructor_mock = self.session_patcher.start() session_constructor_mock.return_value = self.session_mock self.client = ValidationClient('AC123', 'SK123', 'CR123', 'private_key') def tearDown(self): self.session_patcher.stop() self.jwt_patcher.stop() def test_request_does_not_overwrite_host_header(self): self.request_mock.url = 'https://api.twilio.com/' self.client.request('doesnt matter', 'doesnt matter') self.assertEqual('api.twilio.com', self.request_mock.headers['Host']) self.assertEqual('test-token', self.request_mock.headers['Twilio-Client-Validation']) def test_request_sets_host_header_if_missing(self): self.request_mock.url = 'https://api.twilio.com/' self.request_mock.headers = {'Host': 'other.twilio.com'} self.client.request('doesnt matter', 'doesnt matter') self.assertEqual('other.twilio.com', self.request_mock.headers['Host']) self.assertEqual('test-token', self.request_mock.headers['Twilio-Client-Validation']) def test_request_with_unicode_response(self): self.request_mock.url = 'https://api.twilio.com/' self.request_mock.headers = {'Host': 'other.twilio.com'} response = self.client.request('doesnt matter', 'doesnt matter') self.assertEqual('other.twilio.com', self.request_mock.headers['Host']) self.assertEqual('test-token', self.request_mock.headers['Twilio-Client-Validation']) self.assertEqual(200, response.status_code) self.assertEqual('test, omega: Ω, pile of poop: 💩', response.content) twilio-python-6.8.2/tests/unit/jwt/000077500000000000000000000000001317472742600173175ustar00rootroot00000000000000twilio-python-6.8.2/tests/unit/jwt/__init__.py000066400000000000000000000000011317472742600214170ustar00rootroot00000000000000 twilio-python-6.8.2/tests/unit/jwt/test_access_token.py000066400000000000000000000206101317472742600233700ustar00rootroot00000000000000import time import unittest from datetime import datetime from nose.tools import assert_equal from twilio.jwt.access_token import AccessToken from twilio.jwt.access_token.grants import ( IpMessagingGrant, SyncGrant, VoiceGrant, VideoGrant, ConversationsGrant, TaskRouterGrant, ChatGrant ) ACCOUNT_SID = 'AC123' SIGNING_KEY_SID = 'SK123' # python2.6 support def assert_is_not_none(obj): assert obj is not None, '%r is None' % obj def assert_in(obj1, obj2): assert obj1 in obj2, '%r is not in %r' % (obj1, obj2) def assert_greater_equal(obj1, obj2): assert obj1 > obj2, '%r is not greater than or equal to %r' % (obj1, obj2) class AccessTokenTest(unittest.TestCase): def _validate_claims(self, payload): assert_equal(SIGNING_KEY_SID, payload['iss']) assert_equal(ACCOUNT_SID, payload['sub']) assert_is_not_none(payload['exp']) assert_is_not_none(payload['jti']) assert_is_not_none(payload['grants']) assert_greater_equal(payload['exp'], int(time.time())) assert_in(payload['iss'], payload['jti']) def test_empty_grants(self): scat = AccessToken(ACCOUNT_SID, SIGNING_KEY_SID, 'secret') token = scat.to_jwt() assert_is_not_none(token) decoded_token = AccessToken.from_jwt(token, 'secret') self._validate_claims(decoded_token.payload) assert_equal({}, decoded_token.payload['grants']) def test_nbf(self): now = int(time.mktime(datetime.now().timetuple())) scat = AccessToken(ACCOUNT_SID, SIGNING_KEY_SID, 'secret', nbf=now) token = scat.to_jwt() assert_is_not_none(token) decoded_token = AccessToken.from_jwt(token, 'secret') self._validate_claims(decoded_token.payload) assert_equal(now, decoded_token.nbf) def test_headers(self): scat = AccessToken(ACCOUNT_SID, SIGNING_KEY_SID, 'secret') token = scat.to_jwt() assert_is_not_none(token) decoded_token = AccessToken.from_jwt(token, 'secret') self.assertEqual(decoded_token.headers['cty'], 'twilio-fpa;v=1') def test_identity(self): scat = AccessToken(ACCOUNT_SID, SIGNING_KEY_SID, 'secret', identity='test@twilio.com') token = scat.to_jwt() assert_is_not_none(token) decoded_token = AccessToken.from_jwt(token, 'secret') self._validate_claims(decoded_token.payload) assert_equal({ 'identity': 'test@twilio.com' }, decoded_token.payload['grants']) def test_conversations_grant(self): scat = AccessToken(ACCOUNT_SID, SIGNING_KEY_SID, 'secret') scat.add_grant(ConversationsGrant(configuration_profile_sid='CP123')) token = scat.to_jwt() assert_is_not_none(token) decoded_token = AccessToken.from_jwt(token, 'secret') self._validate_claims(decoded_token.payload) assert_equal(1, len(decoded_token.payload['grants'])) assert_equal({ 'configuration_profile_sid': 'CP123' }, decoded_token.payload['grants']['rtc']) def test_video_grant(self): scat = AccessToken(ACCOUNT_SID, SIGNING_KEY_SID, 'secret') scat.add_grant(VideoGrant(room='RM123')) token = scat.to_jwt() assert_is_not_none(token) decoded_token = AccessToken.from_jwt(token, 'secret') self._validate_claims(decoded_token.payload) assert_equal(1, len(decoded_token.payload['grants'])) assert_equal({ 'room': 'RM123' }, decoded_token.payload['grants']['video']) def test_ip_messaging_grant(self): scat = AccessToken(ACCOUNT_SID, SIGNING_KEY_SID, 'secret') scat.add_grant(IpMessagingGrant(service_sid='IS123', push_credential_sid='CR123')) token = scat.to_jwt() assert_is_not_none(token) decoded_token = AccessToken.from_jwt(token, 'secret') self._validate_claims(decoded_token.payload) assert_equal(1, len(decoded_token.payload['grants'])) assert_equal({ 'service_sid': 'IS123', 'push_credential_sid': 'CR123' }, decoded_token.payload['grants']['ip_messaging']) def test_chat_grant(self): scat = AccessToken(ACCOUNT_SID, SIGNING_KEY_SID, 'secret') scat.add_grant(ChatGrant(service_sid='IS123', push_credential_sid='CR123')) token = scat.to_jwt() assert_is_not_none(token) decoded_token = AccessToken.from_jwt(token, 'secret') self._validate_claims(decoded_token.payload) assert_equal(1, len(decoded_token.payload['grants'])) assert_equal({ 'service_sid': 'IS123', 'push_credential_sid': 'CR123' }, decoded_token.payload['grants']['chat']) def test_sync_grant(self): scat = AccessToken(ACCOUNT_SID, SIGNING_KEY_SID, 'secret') scat.identity = "bender" scat.add_grant(SyncGrant(service_sid='IS123', endpoint_id='blahblahendpoint')) token = scat.to_jwt() assert_is_not_none(token) decoded_token = AccessToken.from_jwt(token, 'secret') self._validate_claims(decoded_token.payload) assert_equal(2, len(decoded_token.payload['grants'])) assert_equal("bender", decoded_token.payload['grants']['identity']) assert_equal({ 'service_sid': 'IS123', 'endpoint_id': 'blahblahendpoint' }, decoded_token.payload['grants']['data_sync']) def test_grants(self): scat = AccessToken(ACCOUNT_SID, SIGNING_KEY_SID, 'secret') scat.add_grant(VideoGrant()) scat.add_grant(IpMessagingGrant()) token = scat.to_jwt() assert_is_not_none(token) decoded_token = AccessToken.from_jwt(token, 'secret') self._validate_claims(decoded_token.payload) assert_equal(2, len(decoded_token.payload['grants'])) assert_equal({}, decoded_token.payload['grants']['video']) assert_equal({}, decoded_token.payload['grants']['ip_messaging']) def test_programmable_voice_grant(self): grant = VoiceGrant( outgoing_application_sid='AP123', outgoing_application_params={ 'foo': 'bar' } ) scat = AccessToken(ACCOUNT_SID, SIGNING_KEY_SID, 'secret') scat.add_grant(grant) token = scat.to_jwt() assert_is_not_none(token) decoded_token = AccessToken.from_jwt(token, 'secret') self._validate_claims(decoded_token.payload) assert_equal(1, len(decoded_token.payload['grants'])) assert_equal({ 'outgoing': { 'application_sid': 'AP123', 'params': { 'foo': 'bar' } } }, decoded_token.payload['grants']['voice']) def test_task_router_grant(self): grant = TaskRouterGrant( workspace_sid='WS123', worker_sid='WK123', role='worker' ) scat = AccessToken(ACCOUNT_SID, SIGNING_KEY_SID, 'secret') scat.add_grant(grant) token = scat.to_jwt() assert_is_not_none(token) decoded_token = AccessToken.from_jwt(token, 'secret') self._validate_claims(decoded_token.payload) assert_equal(1, len(decoded_token.payload['grants'])) assert_equal({ 'workspace_sid': 'WS123', 'worker_sid': 'WK123', 'role': 'worker' }, decoded_token.payload['grants']['task_router']) def test_pass_grants_in_constructor(self): grants = [ VideoGrant(), IpMessagingGrant() ] scat = AccessToken(ACCOUNT_SID, SIGNING_KEY_SID, 'secret', grants=grants) token = scat.to_jwt() assert_is_not_none(token) decoded_token = AccessToken.from_jwt(token, 'secret') self._validate_claims(decoded_token.payload) assert_equal(2, len(decoded_token.payload['grants'])) assert_equal({}, decoded_token.payload['grants']['video']) assert_equal({}, decoded_token.payload['grants']['ip_messaging']) def test_constructor_validates_grants(self): grants = [VideoGrant, 'GrantMeAccessToEverything'] self.assertRaises(ValueError, AccessToken, ACCOUNT_SID, SIGNING_KEY_SID, 'secret', grants=grants) def test_add_grant_validates_grant(self): scat = AccessToken(ACCOUNT_SID, SIGNING_KEY_SID, 'secret') scat.add_grant(VideoGrant()) self.assertRaises(ValueError, scat.add_grant, 'GrantRootAccess') twilio-python-6.8.2/tests/unit/jwt/test_client.py000066400000000000000000000104751317472742600222150ustar00rootroot00000000000000import unittest import time from nose.tools import assert_true, assert_equal from twilio.jwt import Jwt from twilio.jwt.client import ClientCapabilityToken, ScopeURI class ClientCapabilityTokenTest(unittest.TestCase): def assertIn(self, foo, bar, msg=None): """backport for 2.6""" return assert_true(foo in bar, msg=(msg or "%s not found in %s" % (foo, bar))) def now(self): return int(time.time()) def test_no_permissions(self): token = ClientCapabilityToken("AC123", "XXXXX") assert_equal(len(token._generate_payload()), 1) assert_equal(token._generate_payload()["scope"], '') def test_inbound_permissions(self): token = ClientCapabilityToken("AC123", "XXXXX") token.allow_client_incoming("andy") eurl = "scope:client:incoming?clientName=andy" assert_equal(len(token._generate_payload()), 1) assert_equal(token._generate_payload()['scope'], eurl) def test_outbound_permissions(self): token = ClientCapabilityToken("AC123", "XXXXX") token.allow_client_outgoing("AP123") eurl = "scope:client:outgoing?appSid=AP123" assert_equal(len(token._generate_payload()), 1) self.assertIn(eurl, token._generate_payload()['scope']) def test_outbound_permissions_params(self): token = ClientCapabilityToken("AC123", "XXXXX") token.allow_client_outgoing("AP123", foobar=3) eurl = "scope:client:outgoing?appParams=foobar%3D3&appSid=AP123" assert_equal(token.payload["scope"], eurl) def test_events(self): token = ClientCapabilityToken("AC123", "XXXXX") token.allow_event_stream() event_uri = "scope:stream:subscribe?path=%2F2010-04-01%2FEvents" assert_equal(token.payload["scope"], event_uri) def test_events_with_filters(self): token = ClientCapabilityToken("AC123", "XXXXX") token.allow_event_stream(foobar="hey") event_uri = "scope:stream:subscribe?params=foobar%3Dhey&path=%2F2010-04-01%2FEvents" assert_equal(token.payload["scope"], event_uri) def test_decode(self): token = ClientCapabilityToken("AC123", "XXXXX") token.allow_client_outgoing("AP123", foobar=3) token.allow_client_incoming("andy") token.allow_event_stream() outgoing_uri = "scope:client:outgoing?appParams=foobar%3D3&appSid=AP123&clientName=andy" incoming_uri = "scope:client:incoming?clientName=andy" event_uri = "scope:stream:subscribe?path=%2F2010-04-01%2FEvents" result = Jwt.from_jwt(token.to_jwt(), "XXXXX") scope = result.payload["scope"].split(" ") self.assertIn(outgoing_uri, scope) self.assertIn(incoming_uri, scope) self.assertIn(event_uri, scope) def test_encode_full_payload(self): token = ClientCapabilityToken("AC123", "XXXXX") token.allow_event_stream(foobar="hey") token.allow_client_incoming("andy") event_uri = "scope:stream:subscribe?params=foobar%3Dhey&path=%2F2010-04-01%2FEvents" incoming_uri = "scope:client:incoming?clientName=andy" self.assertIn(event_uri, token.payload["scope"]) self.assertIn(incoming_uri, token.payload["scope"]) self.assertEqual(token.payload['iss'], 'AC123') self.assertGreaterEqual(token.payload['exp'], self.now()) def test_pass_scopes_in_constructor(self): token = ClientCapabilityToken('AC123', 'XXXXX', allow_client_outgoing={ 'application_sid': 'AP123', 'param1': 'val1' }) outgoing_uri = "scope:client:outgoing?appParams=param1%3Dval1&appSid=AP123" result = Jwt.from_jwt(token.to_jwt(), "XXXXX") self.assertEqual(outgoing_uri, result.payload["scope"]) class ScopeURITest(unittest.TestCase): def test_to_payload_no_params(self): scope_uri = ScopeURI('service', 'godmode') self.assertEqual('scope:service:godmode', scope_uri.to_payload()) def test_to_payload_with_params(self): scope_uri = ScopeURI('service', 'godmode', {'key': 'val'}) self.assertEqual('scope:service:godmode?key=val', scope_uri.to_payload()) def test_to_payload_with_params_encoded(self): scope_uri = ScopeURI('service', 'godmode', {'key with space': 'val'}) self.assertEqual('scope:service:godmode?key+with+space=val', scope_uri.to_payload()) twilio-python-6.8.2/tests/unit/jwt/test_client_validation.py000066400000000000000000000241371317472742600244270ustar00rootroot00000000000000import unittest import time from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives.asymmetric import rsa from cryptography.hazmat.primitives.serialization import ( Encoding, PublicFormat, PrivateFormat, NoEncryption ) from twilio.http.validation_client import ValidationPayload from twilio.jwt import Jwt from twilio.jwt.validation import ClientValidationJwt class ClientValidationJwtTest(unittest.TestCase): def test_generate_payload_basic(self): vp = ValidationPayload( method='GET', path='https://api.twilio.com/', query_string='q1=v1', signed_headers=['headerb', 'headera'], all_headers={'head': 'toe', 'headera': 'vala', 'headerb': 'valb'}, body='me=letop&you=leworst' ) expected_payload = '\n'.join([ 'GET', 'https://api.twilio.com/', 'q1=v1', 'headera:vala', 'headerb:valb', '', 'headera;headerb', '{}'.format(ClientValidationJwt._hash('me=letop&you=leworst')) ]) expected_payload = ClientValidationJwt._hash(expected_payload) jwt = ClientValidationJwt('AC123', 'SK123', 'CR123', 'secret', vp) actual_payload = jwt._generate_payload() self.assertEqual('headera;headerb', actual_payload['hrh']) self.assertEqual(expected_payload, actual_payload['rqh']) def test_generate_payload_complex(self): vp = ValidationPayload( method='GET', path='https://api.twilio.com/', query_string='q1=v1&q2=v2&a=b', signed_headers=['headerb', 'headera'], all_headers={'head': 'toe', 'Headerb': 'valb', 'yeezy': 'weezy'}, body='me=letop&you=leworst' ) expected_payload = '\n'.join([ 'GET', 'https://api.twilio.com/', 'a=b&q1=v1&q2=v2', 'headerb:valb', '', 'headera;headerb', '{}'.format(ClientValidationJwt._hash('me=letop&you=leworst')) ]) expected_payload = ClientValidationJwt._hash(expected_payload) jwt = ClientValidationJwt('AC123', 'SK123', 'CR123', 'secret', vp) actual_payload = jwt._generate_payload() self.assertEqual('headera;headerb', actual_payload['hrh']) self.assertEqual(expected_payload, actual_payload['rqh']) def test_generate_payload_no_query_string(self): vp = ValidationPayload( method='GET', path='https://api.twilio.com/', query_string='', signed_headers=['headerb', 'headera'], all_headers={'head': 'toe', 'Headerb': 'valb', 'yeezy': 'weezy'}, body='me=letop&you=leworst' ) expected_payload = '\n'.join([ 'GET', 'https://api.twilio.com/', '', 'headerb:valb', '', 'headera;headerb', '{}'.format(ClientValidationJwt._hash('me=letop&you=leworst')) ]) expected_payload = ClientValidationJwt._hash(expected_payload) jwt = ClientValidationJwt('AC123', 'SK123', 'CR123', 'secret', vp) actual_payload = jwt._generate_payload() self.assertEqual('headera;headerb', actual_payload['hrh']) self.assertEqual(expected_payload, actual_payload['rqh']) def test_generate_payload_no_req_body(self): vp = ValidationPayload( method='GET', path='https://api.twilio.com/', query_string='q1=v1', signed_headers=['headerb', 'headera'], all_headers={'head': 'toe', 'headera': 'vala', 'headerb': 'valb'}, body='' ) expected_payload = '\n'.join([ 'GET', 'https://api.twilio.com/', 'q1=v1', 'headera:vala', 'headerb:valb', '', 'headera;headerb', '' ]) expected_payload = ClientValidationJwt._hash(expected_payload) jwt = ClientValidationJwt('AC123', 'SK123', 'CR123', 'secret', vp) actual_payload = jwt._generate_payload() self.assertEqual('headera;headerb', actual_payload['hrh']) self.assertEqual(expected_payload, actual_payload['rqh']) def test_generate_payload_header_keys_lowercased(self): vp = ValidationPayload( method='GET', path='https://api.twilio.com/', query_string='q1=v1', signed_headers=['headerb', 'headera'], all_headers={'head': 'toe', 'Headera': 'vala', 'Headerb': 'valb'}, body='me=letop&you=leworst' ) expected_payload = '\n'.join([ 'GET', 'https://api.twilio.com/', 'q1=v1', 'headera:vala', 'headerb:valb', '', 'headera;headerb', '{}'.format(ClientValidationJwt._hash('me=letop&you=leworst')) ]) expected_payload = ClientValidationJwt._hash(expected_payload) jwt = ClientValidationJwt('AC123', 'SK123', 'CR123', 'secret', vp) actual_payload = jwt._generate_payload() self.assertEqual('headera;headerb', actual_payload['hrh']) self.assertEqual(expected_payload, actual_payload['rqh']) def test_generate_payload_no_headers(self): vp = ValidationPayload( method='GET', path='https://api.twilio.com/', query_string='q1=v1', signed_headers=['headerb', 'headera'], all_headers={}, body='me=letop&you=leworst' ) expected_payload = '\n'.join([ 'GET', 'https://api.twilio.com/', 'q1=v1', '', 'headera;headerb', '{}'.format(ClientValidationJwt._hash('me=letop&you=leworst')) ]) expected_payload = ClientValidationJwt._hash(expected_payload) jwt = ClientValidationJwt('AC123', 'SK123', 'CR123', 'secret', vp) actual_payload = jwt._generate_payload() self.assertEqual('headera;headerb', actual_payload['hrh']) self.assertEqual(expected_payload, actual_payload['rqh']) def test_generate_payload_schema_correct_1(self): """Test against a known good rqh payload hash""" vp = ValidationPayload( method='GET', path='/Messages', query_string='PageSize=5&Limit=10', signed_headers=['authorization', 'host'], all_headers={'authorization': 'foobar', 'host': 'api.twilio.com'}, body='foobar' ) expected_hash = '4dc9b67bed579647914587b0e22a1c65c1641d8674797cd82de65e766cce5f80' jwt = ClientValidationJwt('AC123', 'SK123', 'CR123', 'secret', vp) actual_payload = jwt._generate_payload() self.assertEqual('authorization;host', actual_payload['hrh']) self.assertEqual(expected_hash, actual_payload['rqh']) def test_generate_payload_schema_correct_2(self): """Test against a known good rqh payload hash""" vp = ValidationPayload( method='POST', path='/Messages', query_string='', signed_headers=['authorization', 'host'], all_headers={'authorization': 'foobar', 'host': 'api.twilio.com'}, body='testbody' ) expected_hash = 'bd792c967c20d546c738b94068f5f72758a10d26c12979677501e1eefe58c65a' jwt = ClientValidationJwt('AC123', 'SK123', 'CR123', 'secret', vp) actual_payload = jwt._generate_payload() self.assertEqual('authorization;host', actual_payload['hrh']) self.assertEqual(expected_hash, actual_payload['rqh']) def test_jwt_payload(self): vp = ValidationPayload( method='GET', path='/Messages', query_string='PageSize=5&Limit=10', signed_headers=['authorization', 'host'], all_headers={'authorization': 'foobar', 'host': 'api.twilio.com'}, body='foobar' ) expected_hash = '4dc9b67bed579647914587b0e22a1c65c1641d8674797cd82de65e766cce5f80' jwt = ClientValidationJwt('AC123', 'SK123', 'CR123', 'secret', vp) self.assertDictContainsSubset({ 'hrh': 'authorization;host', 'rqh': expected_hash, 'iss': 'SK123', 'sub': 'AC123', }, jwt.payload) self.assertGreaterEqual(jwt.payload['exp'], time.time(), 'JWT exp is before now') self.assertLessEqual(jwt.payload['exp'], time.time() + 301, 'JWT exp is after now + 5mins') self.assertDictEqual({ 'alg': 'RS256', 'typ': 'JWT', 'cty': 'twilio-pkrv;v=1', 'kid': 'CR123' }, jwt.headers) def test_jwt_signing(self): vp = ValidationPayload( method='GET', path='/Messages', query_string='PageSize=5&Limit=10', signed_headers=['authorization', 'host'], all_headers={'authorization': 'foobar', 'host': 'api.twilio.com'}, body='foobar' ) expected_hash = '4dc9b67bed579647914587b0e22a1c65c1641d8674797cd82de65e766cce5f80' private_key = rsa.generate_private_key( public_exponent=65537, key_size=2048, backend=default_backend() ) public_key = private_key.public_key().public_bytes(Encoding.PEM, PublicFormat.PKCS1) private_key = private_key.private_bytes(Encoding.PEM, PrivateFormat.PKCS8, NoEncryption()) jwt = ClientValidationJwt('AC123', 'SK123', 'CR123', private_key, vp) decoded = Jwt.from_jwt(jwt.to_jwt(), public_key) self.assertDictContainsSubset({ 'hrh': 'authorization;host', 'rqh': expected_hash, 'iss': 'SK123', 'sub': 'AC123', }, decoded.payload) self.assertGreaterEqual(decoded.payload['exp'], time.time(), 'JWT exp is before now') self.assertLessEqual(decoded.payload['exp'], time.time() + 501, 'JWT exp is after now + 5m') self.assertDictEqual({ 'alg': 'RS256', 'typ': 'JWT', 'cty': 'twilio-pkrv;v=1', 'kid': 'CR123' }, decoded.headers) twilio-python-6.8.2/tests/unit/jwt/test_jwt.py000066400000000000000000000240001317472742600215300ustar00rootroot00000000000000import unittest import jwt as jwt_lib import time as real_time from nose.tools import assert_true from mock import patch from twilio.jwt import Jwt, JwtDecodeError class DummyJwt(Jwt): """Jwt implementation that allows setting arbitrary payload and headers for testing.""" def __init__(self, secret_key, issuer, subject=None, algorithm='HS256', nbf=Jwt.GENERATE, ttl=3600, valid_until=None, headers=None, payload=None): super(DummyJwt, self).__init__( secret_key=secret_key, issuer=issuer, subject=subject, algorithm=algorithm, nbf=nbf, ttl=ttl, valid_until=valid_until ) self._payload = payload or {} self._headers = headers or {} def _generate_payload(self): return self._payload def _generate_headers(self): return self._headers class JwtTest(unittest.TestCase): def assertIn(self, foo, bar, msg=None): """backport for 2.6""" return assert_true(foo in bar, msg=(msg or "%s not found in %s" % (foo, bar))) def now(self): return int(real_time.time()) def assertJwtsEqual(self, jwt, key, expected_payload=None, expected_headers=None): expected_headers = expected_headers or {} expected_payload = expected_payload or {} decoded_payload = jwt_lib.decode(jwt, key, verify=False) decoded_headers = jwt_lib.get_unverified_header(jwt) self.assertEqual(expected_headers, decoded_headers) self.assertEqual(expected_payload, decoded_payload) @patch('time.time') def test_basic_encode(self, time_mock): time_mock.return_value = 0.0 jwt = DummyJwt('secret_key', 'issuer', headers={}, payload={}) self.assertJwtsEqual( jwt.to_jwt(), 'secret_key', expected_headers={'typ': 'JWT', 'alg': 'HS256'}, expected_payload={'iss': 'issuer', 'exp': 3600, 'nbf': 0}, ) @patch('time.time') def test_encode_with_subject(self, time_mock): time_mock.return_value = 0.0 jwt = DummyJwt('secret_key', 'issuer', subject='subject', headers={}, payload={}) self.assertJwtsEqual( jwt.to_jwt(), 'secret_key', expected_headers={'typ': 'JWT', 'alg': 'HS256'}, expected_payload={'iss': 'issuer', 'exp': 3600, 'nbf': 0, 'sub': 'subject'}, ) @patch('time.time') def test_encode_without_nbf(self, time_mock): time_mock.return_value = 0.0 jwt = DummyJwt('secret_key', 'issuer', subject='subject', headers={}, payload={}, nbf=None) self.assertJwtsEqual( jwt.to_jwt(), 'secret_key', expected_headers={'typ': 'JWT', 'alg': 'HS256'}, expected_payload={'iss': 'issuer', 'exp': 3600, 'sub': 'subject'}, ) @patch('time.time') def test_encode_custom_ttl(self, time_mock): time_mock.return_value = 0.0 jwt = DummyJwt('secret_key', 'issuer', ttl=10, headers={}, payload={}) self.assertJwtsEqual( jwt.to_jwt(), 'secret_key', expected_headers={'typ': 'JWT', 'alg': 'HS256'}, expected_payload={'iss': 'issuer', 'exp': 10, 'nbf': 0}, ) @patch('time.time') def test_encode_ttl_added_to_current_time(self, time_mock): time_mock.return_value = 50.0 jwt = DummyJwt('secret_key', 'issuer', ttl=10, headers={}, payload={}) self.assertJwtsEqual( jwt.to_jwt(), 'secret_key', expected_headers={'typ': 'JWT', 'alg': 'HS256'}, expected_payload={'iss': 'issuer', 'exp': 60, 'nbf': 50}, ) @patch('time.time') def test_encode_override_ttl(self, time_mock): time_mock.return_value = 0.0 jwt = DummyJwt('secret_key', 'issuer', ttl=10, headers={}, payload={}) self.assertJwtsEqual( jwt.to_jwt(ttl=20), 'secret_key', expected_headers={'typ': 'JWT', 'alg': 'HS256'}, expected_payload={'iss': 'issuer', 'exp': 20, 'nbf': 0}, ) @patch('time.time') def test_encode_valid_until_overrides_ttl(self, time_mock): time_mock.return_value = 0.0 jwt = DummyJwt('secret_key', 'issuer', ttl=10, valid_until=70, headers={}, payload={}) self.assertJwtsEqual( jwt.to_jwt(), 'secret_key', expected_headers={'typ': 'JWT', 'alg': 'HS256'}, expected_payload={'iss': 'issuer', 'exp': 70, 'nbf': 0}, ) @patch('time.time') def test_encode_custom_nbf(self, time_mock): time_mock.return_value = 0.0 jwt = DummyJwt('secret_key', 'issuer', ttl=10, nbf=5, headers={}, payload={}) self.assertJwtsEqual( jwt.to_jwt(), 'secret_key', expected_headers={'typ': 'JWT', 'alg': 'HS256'}, expected_payload={'iss': 'issuer', 'exp': 10, 'nbf': 5}, ) @patch('time.time') def test_encode_custom_algorithm(self, time_mock): time_mock.return_value = 0.0 jwt = DummyJwt('secret_key', 'issuer', algorithm='HS512', headers={}, payload={}) self.assertJwtsEqual( jwt.to_jwt(), 'secret_key', expected_headers={'typ': 'JWT', 'alg': 'HS512'}, expected_payload={'iss': 'issuer', 'exp': 3600, 'nbf': 0}, ) @patch('time.time') def test_encode_override_algorithm(self, time_mock): time_mock.return_value = 0.0 jwt = DummyJwt('secret_key', 'issuer', algorithm='HS256', headers={}, payload={}) self.assertJwtsEqual( jwt.to_jwt(algorithm='HS512'), 'secret_key', expected_headers={'typ': 'JWT', 'alg': 'HS512'}, expected_payload={'iss': 'issuer', 'exp': 3600, 'nbf': 0}, ) @patch('time.time') def test_encode_with_headers(self, time_mock): time_mock.return_value = 0.0 jwt = DummyJwt('secret_key', 'issuer', algorithm='HS256', headers={'sooper': 'secret'}, payload={}) self.assertJwtsEqual( jwt.to_jwt(), 'secret_key', expected_headers={'typ': 'JWT', 'alg': 'HS256', 'sooper': 'secret'}, expected_payload={'iss': 'issuer', 'exp': 3600, 'nbf': 0}, ) @patch('time.time') def test_encode_with_payload(self, time_mock): time_mock.return_value = 0.0 jwt = DummyJwt('secret_key', 'issuer', algorithm='HS256', payload={'root': 'true'}) self.assertJwtsEqual( jwt.to_jwt(), 'secret_key', expected_headers={'typ': 'JWT', 'alg': 'HS256'}, expected_payload={'iss': 'issuer', 'exp': 3600, 'nbf': 0, 'root': 'true'}, ) @patch('time.time') def test_encode_with_payload_and_headers(self, time_mock): time_mock.return_value = 0.0 jwt = DummyJwt('secret_key', 'issuer', headers={'yes': 'oui'}, payload={'pay': 'me'}) self.assertJwtsEqual( jwt.to_jwt(), 'secret_key', expected_headers={'typ': 'JWT', 'alg': 'HS256', 'yes': 'oui'}, expected_payload={'iss': 'issuer', 'exp': 3600, 'nbf': 0, 'pay': 'me'}, ) def test_encode_invalid_crypto_alg_fails(self): jwt = DummyJwt('secret_key', 'issuer', algorithm='PlzDontTouchAlgorithm') self.assertRaises(NotImplementedError, jwt.to_jwt) def test_encode_no_key_fails(self): jwt = DummyJwt(None, 'issuer') self.assertRaises(ValueError, jwt.to_jwt) def test_encode_decode(self): test_start = self.now() jwt = DummyJwt('secret_key', 'issuer', subject='hey', payload={'sick': 'sick'}) decoded_jwt = Jwt.from_jwt(jwt.to_jwt(), 'secret_key') self.assertGreaterEqual(decoded_jwt.valid_until, self.now() + 3600) self.assertGreaterEqual(decoded_jwt.nbf, test_start) self.assertEqual(decoded_jwt.issuer, 'issuer') self.assertEqual(decoded_jwt.secret_key, 'secret_key') self.assertEqual(decoded_jwt.algorithm, 'HS256') self.assertEqual(decoded_jwt.subject, 'hey') self.assertEqual(decoded_jwt.headers, {'typ': 'JWT', 'alg': 'HS256'}) self.assertDictContainsSubset({ 'iss': 'issuer', 'sub': 'hey', 'sick': 'sick', }, decoded_jwt.payload) def test_decode_bad_secret(self): jwt = DummyJwt('secret_key', 'issuer') self.assertRaises(JwtDecodeError, Jwt.from_jwt, jwt.to_jwt(), 'letmeinplz') def test_decode_modified_jwt_fails(self): jwt = DummyJwt('secret_key', 'issuer') example_jwt = jwt.to_jwt().decode('utf-8') example_jwt = 'ABC' + example_jwt[3:] example_jwt = example_jwt.encode('utf-8') self.assertRaises(JwtDecodeError, Jwt.from_jwt, example_jwt, 'secret_key') def test_decode_validates_expiration(self): expired_jwt = DummyJwt('secret_key', 'issuer', valid_until=self.now()) real_time.sleep(1) self.assertRaises(JwtDecodeError, Jwt.from_jwt, expired_jwt.to_jwt(), 'secret_key') def test_decode_validates_nbf(self): expired_jwt = DummyJwt('secret_key', 'issuer', nbf=self.now() + 3600) # valid 1hr from now self.assertRaises(JwtDecodeError, Jwt.from_jwt, expired_jwt.to_jwt(), 'secret_key') def test_decodes_valid_jwt(self): expiry_time = self.now() + 1000 example_jwt = jwt_lib.encode( {'hello': 'world', 'iss': 'me', 'sub': 'being awesome', 'exp': expiry_time}, 'secret' ) decoded_jwt = Jwt.from_jwt(example_jwt, 'secret') self.assertEqual(decoded_jwt.issuer, 'me') self.assertEqual(decoded_jwt.subject, 'being awesome') self.assertEqual(decoded_jwt.valid_until, expiry_time) self.assertIn('hello', decoded_jwt.payload) self.assertEqual(decoded_jwt.payload['hello'], 'world') def test_decode_allows_skip_verification(self): jwt = DummyJwt('secret', 'issuer', payload={'get': 'rekt'}) decoded_jwt = Jwt.from_jwt(jwt.to_jwt(), key=None) self.assertEqual(decoded_jwt.issuer, 'issuer') self.assertEqual(decoded_jwt.payload['get'], 'rekt') self.assertIsNone(decoded_jwt.secret_key) twilio-python-6.8.2/tests/unit/jwt/test_task_router.py000066400000000000000000000425541317472742600233040ustar00rootroot00000000000000import unittest import time from twilio.jwt.taskrouter.capabilities import ( WorkerCapabilityToken, TaskQueueCapabilityToken, WorkspaceCapabilityToken, ) class TaskQueueCapabilityTokenTest(unittest.TestCase): def setUp(self): self.account_sid = "AC123" self.auth_token = "foobar" self.workspace_sid = "WS456" self.taskqueue_sid = "WQ789" self.capability = TaskQueueCapabilityToken(self.account_sid, self.auth_token, self.workspace_sid, self.taskqueue_sid) def test_generate_token(self): token = self.capability.to_jwt() self.assertNotEqual(None, token) decoded = TaskQueueCapabilityToken.from_jwt(token, self.auth_token) self.assertNotEqual(None, decoded) self.assertEqual(decoded.payload["iss"], self.account_sid) self.assertEqual(decoded.payload["account_sid"], self.account_sid) self.assertEqual(decoded.payload["workspace_sid"], self.workspace_sid) self.assertEqual(decoded.payload["taskqueue_sid"], self.taskqueue_sid) self.assertEqual(decoded.payload["channel"], self.taskqueue_sid) self.assertEqual(decoded.payload["version"], "v1") self.assertEqual(decoded.payload["friendly_name"], self.taskqueue_sid) def test_generate_token_with_default_ttl(self): token = self.capability.to_jwt() self.assertNotEqual(None, token) decoded = TaskQueueCapabilityToken.from_jwt(token, self.auth_token) self.assertNotEqual(None, decoded) self.assertAlmostEqual(int(time.time()) + 3600, decoded.valid_until, delta=5) def test_generate_token_with_custom_ttl(self): ttl = 10000 token = self.capability.to_jwt(ttl=ttl) self.assertNotEqual(None, token) decoded = TaskQueueCapabilityToken.from_jwt(token, self.auth_token) self.assertNotEqual(None, decoded) self.assertAlmostEqual(int(time.time()) + 10000, decoded.valid_until, delta=5) def test_default(self): token = self.capability.to_jwt() self.assertNotEqual(None, token) decoded = TaskQueueCapabilityToken.from_jwt(token, self.auth_token) self.assertNotEqual(None, decoded) policies = decoded.payload['policies'] self.assertEqual(len(policies), 3) # websocket GET get_policy = policies[0] self.assertEqual("https://event-bridge.twilio.com/v1/wschannels/AC123/WQ789", get_policy['url']) self.assertEqual("GET", get_policy['method']) self.assertTrue(get_policy['allow']) self.assertEqual({}, get_policy['query_filter']) self.assertEqual({}, get_policy['post_filter']) # websocket POST post_policy = policies[1] self.assertEqual("https://event-bridge.twilio.com/v1/wschannels/AC123/WQ789", post_policy['url']) self.assertEqual("POST", post_policy['method']) self.assertTrue(post_policy['allow']) self.assertEqual({}, post_policy['query_filter']) self.assertEqual({}, post_policy['post_filter']) # fetch GET fetch_policy = policies[2] self.assertEqual("https://taskrouter.twilio.com/v1/Workspaces/WS456/TaskQueues/WQ789", fetch_policy['url']) self.assertEqual("GET", fetch_policy['method']) self.assertTrue(fetch_policy['allow']) self.assertEqual({}, fetch_policy['query_filter']) self.assertEqual({}, fetch_policy['post_filter']) def test_allow_fetch_subresources(self): self.capability.allow_fetch_subresources() token = self.capability.to_jwt() self.assertNotEqual(None, token) decoded = TaskQueueCapabilityToken.from_jwt(token, self.auth_token) self.assertNotEqual(None, decoded) policies = decoded.payload['policies'] self.assertEqual(len(policies), 4) # confirm the additional policy generated with allow_fetch_subresources() policy = policies[3] self.assertEqual(policy['url'], "https://taskrouter.twilio.com/v1/Workspaces/WS456/TaskQueues/WQ789/**") self.assertEqual(policy['method'], "GET") self.assertTrue(policy['allow']) self.assertEqual({}, policy['query_filter']) self.assertEqual({}, policy['post_filter']) def test_allow_updates_subresources(self): self.capability.allow_update_subresources() token = self.capability.to_jwt() self.assertNotEqual(None, token) decoded = TaskQueueCapabilityToken.from_jwt(token, self.auth_token) self.assertNotEqual(None, decoded) policies = decoded.payload['policies'] self.assertEqual(len(policies), 4) # confirm the additional policy generated with allow_updates_subresources() policy = policies[3] self.assertEqual(policy['url'], "https://taskrouter.twilio.com/v1/Workspaces/WS456/TaskQueues/WQ789/**") self.assertEqual(policy['method'], "POST") self.assertTrue(policy['allow']) self.assertEqual({}, policy['query_filter']) self.assertEqual({}, policy['post_filter']) def test_pass_policy_in_constructor(self): self.capability = TaskQueueCapabilityToken(self.account_sid, self.auth_token, self.workspace_sid, self.taskqueue_sid, allow_update_subresources=True) token = self.capability.to_jwt() self.assertNotEqual(None, token) decoded = TaskQueueCapabilityToken.from_jwt(token, self.auth_token) self.assertNotEqual(None, decoded) policies = decoded.payload['policies'] self.assertEqual(len(policies), 4) # confirm the additional policy generated with allow_updates_subresources() policy = policies[3] self.assertEqual(policy['url'], "https://taskrouter.twilio.com/v1/Workspaces/WS456/TaskQueues/WQ789/**") self.assertEqual(policy['method'], "POST") self.assertTrue(policy['allow']) self.assertEqual({}, policy['query_filter']) self.assertEqual({}, policy['post_filter']) class WorkerCapabilityTokenTest(unittest.TestCase): def check_policy(self, method, url, policy): self.assertEqual(url, policy['url']) self.assertEqual(method, policy['method']) self.assertTrue(policy['allow']) self.assertEqual({}, policy['query_filter']) self.assertEqual({}, policy['post_filter']) def check_decoded(self, decoded, account_sid, workspace_sid, channel_id, channel_sid=None): self.assertEqual(decoded["iss"], account_sid) self.assertEqual(decoded["account_sid"], account_sid) self.assertEqual(decoded["workspace_sid"], workspace_sid) self.assertEqual(decoded["channel"], channel_id) self.assertEqual(decoded["version"], "v1") self.assertEqual(decoded["friendly_name"], channel_id) if 'worker_sid' in decoded.keys(): self.assertEqual(decoded['worker_sid'], channel_sid) if 'taskqueue_sid' in decoded.keys(): self.assertEqual(decoded['taskqueue_sid'], channel_sid) def setUp(self): self.account_sid = "AC123" self.auth_token = "foobar" self.workspace_sid = "WS456" self.worker_sid = "WK789" self.capability = WorkerCapabilityToken(self.account_sid, self.auth_token, self.workspace_sid, self.worker_sid) def test_generate_token(self): token = self.capability.to_jwt() self.assertNotEqual(None, token) decoded = WorkerCapabilityToken.from_jwt(token, self.auth_token) self.assertNotEqual(None, decoded) self.check_decoded(decoded.payload, self.account_sid, self.workspace_sid, self.worker_sid, self.worker_sid) def test_generate_token_with_default_ttl(self): token = self.capability.to_jwt() self.assertNotEqual(None, token) decoded = WorkerCapabilityToken.from_jwt(token, self.auth_token) self.assertNotEqual(None, decoded) self.assertAlmostEqual(int(time.time()) + 3600, decoded.valid_until, delta=5) def test_generate_token_with_custom_ttl(self): ttl = 10000 token = self.capability.to_jwt(ttl=ttl) self.assertNotEqual(None, token) decoded = WorkerCapabilityToken.from_jwt(token, self.auth_token) self.assertNotEqual(None, decoded) self.assertAlmostEqual(int(time.time()) + 10000, decoded.valid_until, delta=5) def test_defaults(self): token = self.capability.to_jwt() self.assertNotEqual(None, token) decoded = WorkerCapabilityToken.decode(token, self.auth_token) self.assertNotEqual(None, decoded) websocket_url = 'https://event-bridge.twilio.com/v1/wschannels/{0}/{1}'.format( self.account_sid, self.worker_sid ) # expect 6 policies policies = decoded.payload['policies'] self.assertEqual(len(policies), 6) # should expect 6 policies for method, url, policy in [ ('GET', websocket_url, policies[0]), ('POST', websocket_url, policies[1]), ('GET', "https://taskrouter.twilio.com/v1/Workspaces/WS456/Workers/WK789", policies[2]), ('GET', "https://taskrouter.twilio.com/v1/Workspaces/WS456/Activities", policies[3]), ('GET', "https://taskrouter.twilio.com/v1/Workspaces/WS456/Tasks/**", policies[4]), ('GET', "https://taskrouter.twilio.com/v1/Workspaces/WS456/Workers/WK789/Reservations/**", policies[5]) ]: yield self.check_policy, method, url, policy def test_allow_activity_updates(self): # allow activity updates to the worker self.capability.allow_update_activities() token = self.capability.to_jwt() self.assertNotEqual(None, token) decoded = WorkerCapabilityToken.from_jwt(token, self.auth_token) self.assertNotEqual(None, decoded) policies = decoded.payload['policies'] self.assertEqual(len(policies), 7) policy = policies[6] url = "https://taskrouter.twilio.com/v1/Workspaces/{0}/Workers/{1}".format( self.workspace_sid, self.worker_sid ) self.assertEqual(url, policy["url"]) self.assertEqual("POST", policy["method"]) self.assertTrue(policy["allow"]) self.assertNotEqual(None, policy['post_filter']) self.assertEqual({}, policy['query_filter']) self.assertTrue(policy['post_filter']['ActivitySid']) def test_allow_reservation_updates(self): # allow reservation updates self.capability.allow_update_reservations() token = self.capability.to_jwt() self.assertNotEqual(None, token) decoded = WorkerCapabilityToken.from_jwt(token, self.auth_token) self.assertNotEqual(None, decoded) policies = decoded.payload['policies'] self.assertEqual(len(policies), 8) taskPolicy = policies[6] tasksUrl = "https://taskrouter.twilio.com/v1/Workspaces/{0}/Tasks/**".format(self.workspace_sid) self.check_policy('POST', tasksUrl, taskPolicy) workerReservationsPolicy = policies[7] reservationsUrl = "https://taskrouter.twilio.com/v1/Workspaces/{0}/Workers/{1}/Reservations/**".format(self.workspace_sid, self.worker_sid) self.check_policy('POST', reservationsUrl, workerReservationsPolicy) def test_pass_policies_in_constructor(self): # allow reservation updates self.capability = WorkerCapabilityToken(self.account_sid, self.auth_token, self.workspace_sid, self.worker_sid, allow_update_reservations=True) token = self.capability.to_jwt() self.assertNotEqual(None, token) decoded = WorkerCapabilityToken.from_jwt(token, self.auth_token) self.assertNotEqual(None, decoded) policies = decoded.payload['policies'] self.assertEqual(len(policies), 8) taskPolicy = policies[6] tasksUrl = "https://taskrouter.twilio.com/v1/Workspaces/{0}/Tasks/**".format(self.workspace_sid) self.check_policy('POST', tasksUrl, taskPolicy) workerReservationsPolicy = policies[7] reservationsUrl = "https://taskrouter.twilio.com/v1/Workspaces/{0}/Workers/{1}/Reservations/**".format(self.workspace_sid, self.worker_sid) self.check_policy('POST', reservationsUrl, workerReservationsPolicy) class WorkspaceCapabilityTokenTest(unittest.TestCase): def check_policy(self, method, url, policy): self.assertEqual(url, policy['url']) self.assertEqual(method, policy['method']) self.assertTrue(policy['allow']) self.assertEqual({}, policy['query_filter']) self.assertEqual({}, policy['post_filter']) def check_decoded(self, decoded, account_sid, workspace_sid, channel_id, channel_sid=None): self.assertEqual(decoded["iss"], account_sid) self.assertEqual(decoded["account_sid"], account_sid) self.assertEqual(decoded["workspace_sid"], workspace_sid) self.assertEqual(decoded["channel"], channel_id) self.assertEqual(decoded["version"], "v1") self.assertEqual(decoded["friendly_name"], channel_id) if 'worker_sid' in decoded.keys(): self.assertEqual(decoded['worker_sid'], channel_sid) if 'taskqueue_sid' in decoded.keys(): self.assertEqual(decoded['taskqueue_sid'], channel_sid) def setUp(self): self.account_sid = "AC123" self.auth_token = "foobar" self.workspace_sid = "WS456" self.capability = WorkspaceCapabilityToken(self.account_sid, self.auth_token, self.workspace_sid) def test_generate_token(self): token = self.capability.to_jwt() self.assertNotEqual(None, token) decoded = WorkspaceCapabilityToken.from_jwt(token, self.auth_token) self.assertNotEqual(None, decoded) self.check_decoded(decoded.payload, self.account_sid, self.workspace_sid, self.workspace_sid) def test_generate_token_with_default_ttl(self): token = self.capability.to_jwt() self.assertNotEqual(None, token) decoded = WorkspaceCapabilityToken.from_jwt(token, self.auth_token) self.assertNotEqual(None, decoded) self.assertAlmostEqual(int(time.time()) + 3600, decoded.valid_until, delta=5) def test_generate_token_with_custom_ttl(self): ttl = 10000 token = self.capability.to_jwt(ttl=ttl) self.assertNotEqual(None, token) decoded = WorkspaceCapabilityToken.from_jwt(token, self.auth_token) self.assertNotEqual(None, decoded) self.assertAlmostEqual(int(time.time()) + 10000, decoded.valid_until, delta=5) def test_default(self): token = self.capability.to_jwt() self.assertNotEqual(None, token) decoded = WorkspaceCapabilityToken.from_jwt(token, self.auth_token) self.assertNotEqual(None, decoded) policies = decoded.payload['policies'] self.assertEqual(len(policies), 3) for method, url, policy in [ ('GET', "https://event-bridge.twilio.com/v1/wschannels/AC123/WS456", policies[0]), ('POST', "https://event-bridge.twilio.com/v1/wschannels/AC123/WS456", policies[1]), ('GET', "https://taskrouter.twilio.com/v1/Workspaces/WS456", policies[2]) ]: yield self.check_policy, method, url, policy def test_allow_fetch_subresources(self): self.capability.allow_fetch_subresources() token = self.capability.to_jwt() self.assertNotEqual(None, token) decoded = WorkspaceCapabilityToken.from_jwt(token, self.auth_token) self.assertNotEqual(None, decoded) policies = decoded.payload['policies'] self.assertEqual(len(policies), 4) # confirm the additional policy generated with allow_fetch_subresources() policy = policies[3] self.check_policy('GET', "https://taskrouter.twilio.com/v1/Workspaces/WS456/**", policy) def test_allow_updates_subresources(self): self.capability.allow_update_subresources() token = self.capability.to_jwt() self.assertNotEqual(None, token) decoded = WorkspaceCapabilityToken.from_jwt(token, self.auth_token) self.assertNotEqual(None, decoded) policies = decoded.payload['policies'] self.assertEqual(len(policies), 4) # confirm the additional policy generated with allow_update_subresources() policy = policies[3] self.check_policy('POST', "https://taskrouter.twilio.com/v1/Workspaces/WS456/**", policy) def test_pass_policy_in_constructor(self): self.capability = WorkspaceCapabilityToken(self.account_sid, self.auth_token, self.workspace_sid, allow_update_subresources=True) token = self.capability.to_jwt() self.assertNotEqual(None, token) decoded = WorkspaceCapabilityToken.from_jwt(token, self.auth_token) self.assertNotEqual(None, decoded) policies = decoded.payload['policies'] self.assertEqual(len(policies), 4) # confirm the additional policy generated with allow_update_subresources() policy = policies[3] self.check_policy('POST', "https://taskrouter.twilio.com/v1/Workspaces/WS456/**", policy) if __name__ == "__main__": unittest.main() twilio-python-6.8.2/tests/unit/rest/000077500000000000000000000000001317472742600174705ustar00rootroot00000000000000twilio-python-6.8.2/tests/unit/rest/test_client.py000066400000000000000000000034651317472742600223670ustar00rootroot00000000000000import unittest from twilio.rest import ( TwilioClient, TwilioRestClient, TwilioIpMessagingClient, TwilioLookupsClient, TwilioMonitorClient, TwilioPricingClient, TwilioTaskRouterClient, TwilioTrunkingClient, ) from twilio.base.obsolete import ObsoleteException class TestDummyClients(unittest.TestCase): def test_obsolete_exception_twilioclient(self): self.assertRaises(ObsoleteException, TwilioClient, "Expected raised ObsoleteException") def test_obsolete_exception_twiliorestclient(self): self.assertRaises(ObsoleteException, TwilioRestClient, "Expected raised ObsoleteException") def test_obsolete_exception_twilioipmessagingclient(self): self.assertRaises(ObsoleteException, TwilioIpMessagingClient, "Expected raised ObsoleteException") def test_obsolete_exception_twiliolookupsclient(self): self.assertRaises(ObsoleteException, TwilioLookupsClient, "Expected raised ObsoleteException") def test_obsolete_exception_twiliomonitorclient(self): self.assertRaises(ObsoleteException, TwilioMonitorClient, "Expected raised ObsoleteException") def test_obsolete_exception_twiliopricingclient(self): self.assertRaises(ObsoleteException, TwilioPricingClient, "Expected raised ObsoleteException") def test_obsolete_exception_twiliotaskrouterclient(self): self.assertRaises(ObsoleteException, TwilioTaskRouterClient, "Expected raised ObsoleteException") def test_obsolete_exception_twiliotrunkingclient(self): self.assertRaises(ObsoleteException, TwilioTrunkingClient, "Expected raised ObsoleteException") twilio-python-6.8.2/tests/unit/test_request_validator.py000066400000000000000000000046441317472742600236710ustar00rootroot00000000000000# -*- coding: utf-8 -*- import unittest from nose.tools import assert_equal, assert_true from six import b, u from twilio.request_validator import RequestValidator class ValidationTest(unittest.TestCase): def setUp(self): token = "1c892n40nd03kdnc0112slzkl3091j20" self.validator = RequestValidator(token) self.uri = "http://www.postbin.org/1ed898x" self.params = { "AccountSid": "AC9a9f9392lad99kla0sklakjs90j092j3", "ApiVersion": "2010-04-01", "CallSid": "CAd800bb12c0426a7ea4230e492fef2a4f", "CallStatus": "ringing", "Called": "+15306384866", "CalledCity": "OAKLAND", "CalledCountry": "US", "CalledState": "CA", "CalledZip": "94612", "Caller": "+15306666666", "CallerCity": "SOUTH LAKE TAHOE", "CallerCountry": "US", "CallerName": "CA Wireless Call", "CallerState": "CA", "CallerZip": "89449", "Direction": "inbound", "From": "+15306666666", "FromCity": "SOUTH LAKE TAHOE", "FromCountry": "US", "FromState": "CA", "FromZip": "89449", "To": "+15306384866", "ToCity": "OAKLAND", "ToCountry": "US", "ToState": "CA", "ToZip": "94612", } def test_compute_signature_bytecode(self): expected = b("fF+xx6dTinOaCdZ0aIeNkHr/ZAA=") signature = self.validator.compute_signature(self.uri, self.params, utf=False) assert_equal(signature, expected) def test_compute_signature_unicode(self): expected = u("fF+xx6dTinOaCdZ0aIeNkHr/ZAA=") signature = self.validator.compute_signature(self.uri, self.params, utf=True) assert_equal(signature, expected) def test_validation(self): expected = "fF+xx6dTinOaCdZ0aIeNkHr/ZAA=" assert_true(self.validator.validate(self.uri, self.params, expected)) def test_validation_removes_port_on_https(self): self.uri = "https://www.postbin.org:1234/1ed898x" expected = "Y7MeICc5ECftd1G11Fc8qoxAn0A=" assert_true(self.validator.validate(self.uri, self.params, expected)) twilio-python-6.8.2/tests/unit/twiml/000077500000000000000000000000001317472742600176475ustar00rootroot00000000000000twilio-python-6.8.2/tests/unit/twiml/__init__.py000066400000000000000000000015171317472742600217640ustar00rootroot00000000000000import unittest from nose.tools import raises from six import text_type from twilio.twiml import format_language, TwiMLException, TwiML class TwilioTest(unittest.TestCase): def strip(self, xml): return text_type(xml) @raises(TwiMLException) def test_append_fail(self): t = TwiML() t.append('foobar') def test_format_language_none(self): language = None self.assertEqual(language, format_language(language)) def test_format_language_valid(self): language = 'en-US' self.assertEqual(language, format_language(language)) def test_format_language_coerced(self): language = 'EN_us' self.assertEqual('en-US', format_language(language)) @raises(TwiMLException) def test_format_language_fail(self): format_language('this is invalid') twilio-python-6.8.2/tests/unit/twiml/test_messaging_response.py000066400000000000000000000050161317472742600251550ustar00rootroot00000000000000from nose.tools import assert_equal from tests.unit.twiml import TwilioTest from twilio.twiml.messaging_response import MessagingResponse, Body, Media class TestResponse(TwilioTest): def test_empty_response(self): r = MessagingResponse() assert_equal( self.strip(r), '' ) def test_response(self): r = MessagingResponse() r.message('Hello') r.redirect(url='example.com') assert_equal( self.strip(r), 'Helloexample.com' ) def test_response_chain(self): with MessagingResponse() as r: r.message('Hello') r.redirect(url='example.com') assert_equal( self.strip(r), 'Helloexample.com' ) def test_nested_verbs(self): with MessagingResponse() as r: with r.message('Hello') as m: m.media('example.com') assert_equal( self.strip(r), 'Helloexample.com' ) class TestMessage(TwilioTest): def test_body(self): r = MessagingResponse() r.message('Hello') assert_equal( self.strip(r), 'Hello' ) def test_nested_body(self): b = Body('Hello World') r = MessagingResponse() r.append(b) assert_equal( self.strip(r), 'Hello World' ) def test_nested_body_media(self): b = Body('Hello World') m = Media('hey.jpg') r = MessagingResponse() r.append(b) r.append(m) assert_equal( self.strip(r), 'Hello Worldhey.jpg' ) class TestRedirect(TwilioTest): def test_redirect(self): r = MessagingResponse() r.redirect(url='example.com') assert_equal( self.strip(r), 'example.com' ) twilio-python-6.8.2/tests/unit/twiml/test_voice_response.py000066400000000000000000000425111317472742600243060ustar00rootroot00000000000000# -*- coding: utf-8 -*- from nose.tools import assert_equal from six import u from tests.unit.twiml import TwilioTest from twilio.twiml.voice_response import VoiceResponse, Dial, Enqueue, Gather class TestResponse(TwilioTest): def test_empty_response(self): r = VoiceResponse() assert_equal( self.strip(r), '' ) def test_response(self): r = VoiceResponse() r.hangup() r.leave() r.sms( 'twilio sms', to='+11234567890', from_='+10987654321' ) assert_equal( self.strip(r), 'twilio sms' ) def test_response_chain(self): with VoiceResponse() as r: r.hangup() r.leave() r.sms( 'twilio sms', to='+11234567890', from_='+10987654321' ) assert_equal( self.strip(r), 'twilio sms' ) def test_nested_verbs(self): with VoiceResponse() as r: with r.gather() as g: g.say('Hello', voice='man') assert_equal( self.strip(r), 'Hello' ) class TestSay(TwilioTest): def test_empty_say(self): """ should be a say with no text """ r = VoiceResponse() r.say('') assert_equal( self.strip(r), '' ) def test_say_hello_world(self): """ should say hello world """ r = VoiceResponse() r.say('Hello World') assert_equal( self.strip(r), 'Hello World' ) def test_say_french(self): """ should say hello monkey """ r = VoiceResponse() r.say(u('n\xe9cessaire et d\'autres')) assert_equal( self.strip(r), 'nécessaire et d\'autres' ) def test_say_loop(self): """ should say hello monkey and loop 3 times """ r = VoiceResponse() r.say('Hello Monkey', loop=3) assert_equal( self.strip(r), 'Hello Monkey' ) def test_say_loop_gb(self): """ should say have a woman say hello monkey and loop 3 times """ r = VoiceResponse() r.say('Hello Monkey', language='en-gb') assert_equal( self.strip(r), 'Hello Monkey' ) def test_say_loop_woman(self): """ should say have a woman say hello monkey and loop 3 times """ r = VoiceResponse() r.say('Hello Monkey', loop=3, voice='woman') assert_equal( self.strip(r), 'Hello Monkey' ) def test_say_all(self): """ convenience method: should say have a woman say hello monkey and loop 3 times and be in french """ r = VoiceResponse() r.say('Hello Monkey', loop=3, voice='man', language='fr') assert_equal( self.strip(r), 'Hello Monkey' ) class TestPlay(TwilioTest): def test_empty_play(self): """ should play hello monkey """ r = VoiceResponse() r.play() assert_equal( self.strip(r), '' ) def test_play_hello(self): """ should play hello monkey """ r = VoiceResponse() r.play(url='http://hellomonkey.mp3') assert_equal( self.strip(r), 'http://hellomonkey.mp3' ) def test_play_hello_loop(self): """ should play hello monkey loop """ r = VoiceResponse() r.play(url='http://hellomonkey.mp3', loop=3) assert_equal( self.strip(r), 'http://hellomonkey.mp3' ) def test_play_digits(self): """ should play digits """ r = VoiceResponse() r.play(digits='w123') assert_equal( self.strip(r), '' ) class TestRecord(TwilioTest): def test_record_empty(self): """ should record """ r = VoiceResponse() r.record() assert_equal( self.strip(r), '' ) def test_record_action_method(self): """ should record with an action and a get method """ r = VoiceResponse() r.record(action='example.com', method='GET') assert_equal( self.strip(r), '' ) def test_record_max_length_finish_timeout(self): """ should record with an maxLength, finishOnKey, and timeout """ r = VoiceResponse() r.record(timeout=4, finish_on_key='#', max_length=30) assert_equal( self.strip(r), '' ) def test_record_transcribe(self): """ should record with a transcribe and transcribeCallback """ r = VoiceResponse() r.record(transcribe_callback='example.com') assert_equal( self.strip(r), '' ) class TestRedirect(TwilioTest): def test_redirect_empty(self): r = VoiceResponse() r.redirect('') assert_equal( self.strip(r), '' ) def test_redirect_method(self): r = VoiceResponse() r.redirect('example.com', method='POST') assert_equal( self.strip(r), 'example.com' ) def test_redirect_method_params(self): r = VoiceResponse() r.redirect('example.com?id=34&action=hey', method='POST') assert_equal( self.strip(r), 'example.com?id=34&action=hey' ) class TestHangup(TwilioTest): def test_hangup(self): """ convenience: should Hangup to a url via POST """ r = VoiceResponse() r.hangup() assert_equal( self.strip(r), '' ) class TestLeave(TwilioTest): def test_leave(self): """ convenience: should Hangup to a url via POST """ r = VoiceResponse() r.leave() assert_equal( self.strip(r), '' ) class TestReject(TwilioTest): def test_reject(self): """ should be a Reject with default reason """ r = VoiceResponse() r.reject() assert_equal( self.strip(r), '' ) class TestSms(TwilioTest): def test_empty(self): """ Test empty sms verb """ r = VoiceResponse() r.sms('') assert_equal( self.strip(r), '' ) def test_body(self): """ Test hello world """ r = VoiceResponse() r.sms('Hello, World') assert_equal( self.strip(r), 'Hello, World' ) def test_to_from_action(self): """ Test the to, from, and status callback """ r = VoiceResponse() r.sms('Hello, World', to=1231231234, from_=3453453456, status_callback='example.com?id=34&action=hey') assert_equal( self.strip(r), 'Hello, World' ) def test_action_method(self): """ Test the action and method parameters on Sms """ r = VoiceResponse() r.sms('Hello', method='POST', action='example.com?id=34&action=hey') assert_equal( self.strip(r), 'Hello' ) class TestConference(TwilioTest): def test_conference(self): d = Dial() d.conference( 'TestConferenceAttributes', beep=False, wait_url='', start_conference_on_enter=True, end_conference_on_exit=True ) r = VoiceResponse() r.append(d) assert_equal( self.strip(r), 'TestConferenceAttributes' ) def test_muted_conference(self): d = Dial() d.conference( 'TestConferenceMutedAttribute', beep=False, muted=True, wait_url='', start_conference_on_enter=True, end_conference_on_exit=True ) r = VoiceResponse() r.append(d) assert_equal( self.strip(r), 'TestConferenceMutedAttribute' ) class TestQueue(TwilioTest): def test_queue(self): d = Dial() d.queue('TestQueueAttribute', url='', method='GET') r = VoiceResponse() r.append(d) assert_equal( self.strip(r), 'TestQueueAttribute' ) class TestEcho(TwilioTest): def test_echo(self): r = VoiceResponse() r.echo() assert_equal( self.strip(r), '' ) class TestEnqueue(TwilioTest): def test_enqueue(self): r = VoiceResponse() r.enqueue( 'TestEnqueueAttribute', action='act', method='GET', wait_url='wait', wait_url_method='POST' ) assert_equal( self.strip(r), 'TestEnqueueAttribute' ) def test_task_string(self): e = Enqueue(None, workflowSid='123123123') e.task('{"account_sid": "AC123123123"}') r = VoiceResponse() r.append(e) assert_equal( self.strip(r), '{"account_sid": "AC123123123"}' ) def test_task_dict(self): e = Enqueue(None, workflowSid='123123123') e.task({"account_sid": "AC123123123"}) r = VoiceResponse() r.append(e) assert_equal( self.strip(r), '{"account_sid": "AC123123123"}' ) class TestDial(TwilioTest): def test_dial(self): """ should redirect the call """ r = VoiceResponse() r.dial("1231231234") assert_equal( self.strip(r), '1231231234' ) def test_sim(self): d = Dial() d.sim('123123123') r = VoiceResponse() r.append(d) assert_equal( self.strip(r), '123123123' ) def test_sip(self): """ should redirect the call """ d = Dial() d.sip('foo@example.com') r = VoiceResponse() r.append(d) assert_equal( self.strip(r), 'foo@example.com' ) def test_sip_username_password(self): """ should redirect the call """ d = Dial() d.sip('foo@example.com', username='foo', password='bar') r = VoiceResponse() r.append(d) assert_equal( self.strip(r), 'foo@example.com' ) def test_add_number(self): """ add a number to a dial """ d = Dial() d.number('1231231234') r = VoiceResponse() r.append(d) assert_equal( self.strip(r), '1231231234' ) def test_add_number_status_callback_event(self): """ add a number to a dial with status callback events""" d = Dial() d.number('1231231234', status_callback='http://example.com', status_callback_event='initiated completed') r = VoiceResponse() r.append(d) assert_equal( self.strip(r), '1231231234' ) def test_add_conference(self): """ add a conference to a dial """ d = Dial() d.conference('My Room') r = VoiceResponse() r.append(d) assert_equal( self.strip(r), 'My Room' ) def test_add_queue(self): """ add a queue to a dial """ d = Dial() d.queue('The Cute Queue') r = VoiceResponse() r.append(d) assert_equal( self.strip(r), 'The Cute Queue' ) def test_add_empty_client(self): """ add an empty client to a dial """ d = Dial() d.client('') r = VoiceResponse() r.append(d) assert_equal( self.strip(r), '' ) def test_add_client(self): """ add a client to a dial """ d = Dial() d.client('alice') r = VoiceResponse() r.append(d) assert_equal( self.strip(r), 'alice' ) class TestGather(TwilioTest): def test_empty(self): """ a gather with nothing inside """ r = VoiceResponse() r.gather() assert_equal( self.strip(r), '' ) def test_gather_say(self): g = Gather() g.say('Hello') r = VoiceResponse() r.append(g) assert_equal( self.strip(r), 'Hello' ) def test_nested_say_play_pause(self): """ a gather with a say, play, and pause """ g = Gather() g.say('Hey') g.play(url='hey.mp3') g.pause() r = VoiceResponse() r.append(g) assert_equal( self.strip(r), 'Heyhey.mp3' ) twilio-python-6.8.2/tox.ini000066400000000000000000000002101317472742600156760ustar00rootroot00000000000000[tox] envlist = py27, py33, py34, py35, py36, pypy [testenv] deps= -r{toxinidir}/tests/requirements.txt commands= nosetests \ [] twilio-python-6.8.2/twilio/000077500000000000000000000000001317472742600157015ustar00rootroot00000000000000twilio-python-6.8.2/twilio/__init__.py000066400000000000000000000001151317472742600200070ustar00rootroot00000000000000 __version_info__ = ('6', '8', '2') __version__ = '.'.join(__version_info__) twilio-python-6.8.2/twilio/base/000077500000000000000000000000001317472742600166135ustar00rootroot00000000000000twilio-python-6.8.2/twilio/base/__init__.py000066400000000000000000000000001317472742600207120ustar00rootroot00000000000000twilio-python-6.8.2/twilio/base/deserialize.py000066400000000000000000000033201317472742600214630ustar00rootroot00000000000000import datetime from decimal import Decimal, BasicContext from email.utils import parsedate import pytz ISO8601_DATE_FORMAT = '%Y-%m-%d' ISO8601_DATETIME_FORMAT = '%Y-%m-%dT%H:%M:%SZ' def iso8601_date(s): """ Parses an ISO 8601 date string and returns a UTC date object or the string if the parsing failed. :param s: ISO 8601-formatted date string (2015-01-25) :return: """ try: return datetime.datetime.strptime(s, ISO8601_DATE_FORMAT).replace(tzinfo=pytz.utc).date() except (TypeError, ValueError): return s def iso8601_datetime(s): """ Parses an ISO 8601 datetime string and returns a UTC datetime object, or the string if parsing failed. :param s: ISO 8601-formatted datetime string (2015-01-25T12:34:56Z) :return: datetime or str """ try: return datetime.datetime.strptime(s, ISO8601_DATETIME_FORMAT).replace(tzinfo=pytz.utc) except (TypeError, ValueError): return s def rfc2822_datetime(s): """ Parses an RFC 2822 date string and returns a UTC datetime object, or the string if parsing failed. :param s: RFC 2822-formatted string date :return: datetime or str """ date_tuple = parsedate(s) if date_tuple is None: return None return datetime.datetime(*date_tuple[:6]).replace(tzinfo=pytz.utc) def decimal(d): """ Parses a decimal string into a Decimal :param d: decimal string :return: Decimal """ if not d: return d return Decimal(d, BasicContext) def integer(i): """ Parses an integer string into an int :param i: integer string :return: int """ try: return int(i) except (TypeError, ValueError): return i twilio-python-6.8.2/twilio/base/domain.py000066400000000000000000000030071317472742600204340ustar00rootroot00000000000000class Domain(object): """ This represents at Twilio API subdomain. Like, `api.twilio.com` or `lookups.twilio.com'. """ def __init__(self, twilio): """ :param Twilio twilio: :return: """ self.twilio = twilio self.base_url = None def absolute_url(self, uri): """ Converts a relative `uri` to an absolute url. :param string uri: The relative uri to make absolute. :return: An absolute url (based off this domain) """ return '{}/{}'.format(self.base_url.strip('/'), uri.strip('/')) def request(self, method, uri, params=None, data=None, headers=None, auth=None, timeout=None, allow_redirects=False): """ Makes an HTTP request to this domain. :param string method: The HTTP method. :param string uri: The HTTP uri. :param dict params: Query parameters. :param object data: The request body. :param dict headers: The HTTP headers. :param tuple auth: Basic auth tuple of (username, password) :param int timeout: The request timeout. :param bool allow_redirects: True if the client should follow HTTP redirects. """ url = self.absolute_url(uri) return self.twilio.request( method, url, params=params, data=data, headers=headers, auth=auth, timeout=timeout, allow_redirects=allow_redirects ) twilio-python-6.8.2/twilio/base/exceptions.py000066400000000000000000000046461317472742600213600ustar00rootroot00000000000000# -*- coding: utf-8 -*- import sys from six import u class TwilioException(Exception): pass class TwilioRestException(TwilioException): """ A generic 400 or 500 level exception from the Twilio API :param int status: the HTTP status that was returned for the exception :param str uri: The URI that caused the exception :param str msg: A human-readable message for the error :param str method: The HTTP method used to make the request :param int|None code: A Twilio-specific error code for the error. This is not available for all errors. """ def __init__(self, status, uri, msg="", code=None, method='GET'): self.uri = uri self.status = status self.msg = msg self.code = code self.method = method def __str__(self): """ Try to pretty-print the exception, if this is going on screen. """ def red(words): return u("\033[31m\033[49m%s\033[0m") % words def white(words): return u("\033[37m\033[49m%s\033[0m") % words def blue(words): return u("\033[34m\033[49m%s\033[0m") % words def teal(words): return u("\033[36m\033[49m%s\033[0m") % words def get_uri(code): return "https://www.twilio.com/docs/errors/{0}".format(code) # If it makes sense to print a human readable error message, try to # do it. The one problem is that someone might catch this error and # try to display the message from it to an end user. if hasattr(sys.stderr, 'isatty') and sys.stderr.isatty(): msg = ( "\n{red_error} {request_was}\n\n{http_line}" "\n\n{twilio_returned}\n\n{message}\n".format( red_error=red("HTTP Error"), request_was=white("Your request was:"), http_line=teal("%s %s" % (self.method, self.uri)), twilio_returned=white( "Twilio returned the following information:"), message=blue(str(self.msg)) )) if self.code: msg = "".join([msg, "\n{more_info}\n\n{uri}\n\n".format( more_info=white("More information may be available here:"), uri=blue(get_uri(self.code))), ]) return msg else: return "HTTP {0} error: {1}".format(self.status, self.msg) twilio-python-6.8.2/twilio/base/instance_context.py000066400000000000000000000002701317472742600225340ustar00rootroot00000000000000class InstanceContext(object): def __init__(self, version): """ :param Version version: """ self._version = version """ :type: Version """ twilio-python-6.8.2/twilio/base/instance_resource.py000066400000000000000000000002711317472742600227000ustar00rootroot00000000000000class InstanceResource(object): def __init__(self, version): """ :param Version version: """ self._version = version """ :type: Version """ twilio-python-6.8.2/twilio/base/list_resource.py000066400000000000000000000002641317472742600220510ustar00rootroot00000000000000class ListResource(object): def __init__(self, version): """ :param Version version: """ self._version = version """ :type: Version """ twilio-python-6.8.2/twilio/base/obsolete.py000066400000000000000000000011741317472742600210040ustar00rootroot00000000000000import warnings import functools class ObsoleteException(BaseException): """ Base class for warnings about obsolete features. """ pass def obsolete_client(func): """This is a decorator which can be used to mark Client classes as obsolete. It will result in an error being emitted when the class is instantiated.""" @functools.wraps(func) def new_func(*args, **kwargs): raise ObsoleteException( "{} has been removed from this version of the library. " "Please refer to current documentation for guidance." .format(func.__name__) ) return new_func twilio-python-6.8.2/twilio/base/page.py000066400000000000000000000077101317472742600201060ustar00rootroot00000000000000import json from twilio.base.exceptions import TwilioException class Page(object): """ Represents a page of records in a collection. A `Page` lets you iterate over its records and fetch the next and previous pages in the collection. """ META_KEYS = { 'end', 'first_page_uri', 'next_page_uri', 'last_page_uri', 'page', 'page_size', 'previous_page_uri', 'total', 'num_pages', 'start', 'uri' } def __init__(self, version, response): payload = self.process_response(response) self._version = version self._payload = payload self._solution = {} self._records = iter(self.load_page(payload)) def __iter__(self): """ A `Page` is a valid iterator. """ return self def __next__(self): return self.next() def next(self): """ Returns the next record in the `Page`. """ return self.get_instance(next(self._records)) @classmethod def process_response(self, response): """ Load a JSON response. :param Response response: The HTTP response. :return dict: The JSON-loaded content. """ if response.status_code != 200: raise TwilioException('Unable to fetch page', response) return json.loads(response.text) def load_page(self, payload): """ Parses the collection of records out of a list payload. :param dict payload: The JSON-loaded content. :return list: The list of records. """ if 'meta' in payload and 'key' in payload['meta']: return payload[payload['meta']['key']] else: keys = set(payload.keys()) key = keys - self.META_KEYS if len(key) == 1: return payload[key.pop()] raise TwilioException('Page Records can not be deserialized') @property def previous_page_url(self): """ :return str: Returns a link to the previous_page_url or None if doesn't exist. """ if 'meta' in self._payload and 'previous_page_url' in self._payload['meta']: return self._payload['meta']['previous_page_url'] elif 'previous_page_uri' in self._payload and self._payload['previous_page_uri']: return self._version.domain.absolute_url(self._payload['previous_page_uri']) return None @property def next_page_url(self): """ :return str: Returns a link to the next_page_url or None if doesn't exist. """ if 'meta' in self._payload and 'next_page_url' in self._payload['meta']: return self._payload['meta']['next_page_url'] elif 'next_page_uri' in self._payload and self._payload['next_page_uri']: return self._version.domain.absolute_url(self._payload['next_page_uri']) return None def get_instance(self, payload): """ :param dict payload: A JSON-loaded representation of an instance record. :return: A rich, resource-dependent object. """ raise TwilioException('Page.get_instance() must be implemented in the derived class') def next_page(self): """ Return the `Page` after this one. :return Page: The next page. """ if not self.next_page_url: return None response = self._version.domain.twilio.request('GET', self.next_page_url) cls = type(self) return cls(self._version, response, self._solution) def previous_page(self): """ Return the `Page` before this one. :return Page: The previous page. """ if not self.previous_page_url: return None response = self._version.domain.twilio.request('GET', self.previous_page_url) cls = type(self) return cls(self._version, response, self._solution) def __repr__(self): return '' twilio-python-6.8.2/twilio/base/serialize.py000066400000000000000000000033031317472742600211530ustar00rootroot00000000000000import datetime import json from twilio.base import values def iso8601_date(d): """ Return a string representation of a date that the Twilio API understands Format is YYYY-MM-DD. Returns None if d is not a string, datetime, or date """ if d == values.unset: return d elif isinstance(d, datetime.datetime): return str(d.date()) elif isinstance(d, datetime.date): return str(d) elif isinstance(d, str): return d def iso8601_datetime(d): """ Return a string representation of a date that the Twilio API understands Format is YYYY-MM-DD. Returns None if d is not a string, datetime, or date """ if d == values.unset: return d elif isinstance(d, datetime.datetime) or isinstance(d, datetime.date): return d.strftime('%Y-%m-%dT%H:%M:%SZ') elif isinstance(d, str): return d def prefixed_collapsible_map(m, prefix): """ Return a dict of params corresponding to those in m with the added prefix """ if m == values.unset: return {} def flatten_dict(d, result={}, prv_keys=[]): for k, v in d.items(): if isinstance(v, dict): flatten_dict(v, result, prv_keys + [k]) else: result['.'.join(prv_keys + [k])] = v return result if isinstance(m, dict): flattened = flatten_dict(m) return {'{}.{}'.format(prefix, k): v for k, v in flattened.items()} return {} def object(obj): """ Return a jsonified string represenation of obj if obj is jsonifiable else return obj untouched """ if isinstance(obj, dict) or isinstance(obj, list): return json.dumps(obj) return obj twilio-python-6.8.2/twilio/base/values.py000066400000000000000000000003771317472742600204730ustar00rootroot00000000000000from six import iteritems unset = object() def of(d): """ Remove unset values from a dict. :param dict d: A dict to strip. :return dict: A dict with unset values removed. """ return {k: v for k, v in iteritems(d) if v != unset} twilio-python-6.8.2/twilio/base/version.py000066400000000000000000000144551317472742600206630ustar00rootroot00000000000000import json from math import ceil from twilio.base import values from twilio.base.exceptions import TwilioRestException class Version(object): """ Represents an API version. """ def __init__(self, domain): """ :param Domain domain: :return: """ self.domain = domain self.version = None def absolute_url(self, uri): """ Turns a relative uri into an absolute url. """ return self.domain.absolute_url(self.relative_uri(uri)) def relative_uri(self, uri): """ Turns a relative uri into a versioned relative uri. """ return '{}/{}'.format(self.version.strip('/'), uri.strip('/')) def request(self, method, uri, params=None, data=None, headers=None, auth=None, timeout=None, allow_redirects=False): """ Make an HTTP request. """ url = self.relative_uri(uri) return self.domain.request( method, url, params=params, data=data, headers=headers, auth=auth, timeout=timeout, allow_redirects=allow_redirects ) @classmethod def exception(cls, method, uri, response, message): """ Wraps an exceptional response in a `TwilioRestException`. """ # noinspection PyBroadException try: error_payload = json.loads(response.text) if 'message' in error_payload: message = '{}: {}'.format(message, error_payload['message']) code = error_payload.get('code', response.status_code) return TwilioRestException(response.status_code, uri, message, code, method) except Exception: return TwilioRestException(response.status_code, uri, message, response.status_code, method) def fetch(self, method, uri, params=None, data=None, headers=None, auth=None, timeout=None, allow_redirects=False): """ Fetch a resource instance. """ response = self.request( method, uri, params=params, data=data, headers=headers, auth=auth, timeout=timeout, allow_redirects=allow_redirects, ) if response.status_code < 200 or response.status_code >= 300: raise self.exception(method, uri, response, 'Unable to fetch record') return json.loads(response.text) def update(self, method, uri, params=None, data=None, headers=None, auth=None, timeout=None, allow_redirects=False): """ Update a resource instance. """ response = self.request( method, uri, params=params, data=data, headers=headers, auth=auth, timeout=timeout, allow_redirects=allow_redirects, ) if response.status_code < 200 or response.status_code >= 300: raise self.exception(method, uri, response, 'Unable to update record') return json.loads(response.text) def delete(self, method, uri, params=None, data=None, headers=None, auth=None, timeout=None, allow_redirects=False): """ Delete a resource. """ response = self.request( method, uri, params=params, data=data, headers=headers, auth=auth, timeout=timeout, allow_redirects=allow_redirects, ) if response.status_code < 200 or response.status_code >= 300: raise self.exception(method, uri, response, 'Unable to delete record') return response.status_code == 204 def read_limits(self, limit=None, page_size=None): """ Takes a limit on the max number of records to read and a max page_size and calculates the max number of pages to read. :param int limit: Max number of records to read. :param int page_size: Max page size. :return dict: A dictionary of paging limits. """ page_limit = values.unset if limit is not None: if page_size is None: page_size = limit page_limit = int(ceil(limit / float(page_size))) return { 'limit': limit or values.unset, 'page_size': page_size or values.unset, 'page_limit': page_limit, } def page(self, method, uri, params=None, data=None, headers=None, auth=None, timeout=None, allow_redirects=False): """ Makes an HTTP request. """ return self.request( method, uri, params=params, data=data, headers=headers, auth=auth, timeout=timeout, allow_redirects=allow_redirects, ) def stream(self, page, limit=None, page_limit=None): """ Generates records one a time from a page, stopping at prescribed limits. :param Page page: The page to stream. :param int limit: The max number of records to read. :param int page_imit: The max number of pages to read. """ current_record = 1 current_page = 1 while page is not None: for record in page: yield record current_record += 1 if limit and limit is not values.unset and limit < current_record: return if page_limit and page_limit is not values.unset and page_limit < current_page: return page = page.next_page() current_page += 1 def create(self, method, uri, params=None, data=None, headers=None, auth=None, timeout=None, allow_redirects=False): """ Create a resource instance. """ response = self.request( method, uri, params=params, data=data, headers=headers, auth=auth, timeout=timeout, allow_redirects=allow_redirects, ) if response.status_code < 200 or response.status_code >= 300: raise self.exception(method, uri, response, 'Unable to create record') return json.loads(response.text) twilio-python-6.8.2/twilio/compat.py000066400000000000000000000007611317472742600175420ustar00rootroot00000000000000# Those are not supported by the six library and needs to be done manually try: # python 3 from urllib.parse import urlencode, urlparse, urljoin, urlunparse except ImportError: # python 2 backward compatibility # noinspection PyUnresolvedReferences from urllib import urlencode # noinspection PyUnresolvedReferences from urlparse import urlparse, urljoin, urlunparse try: # python 2 from itertools import izip except ImportError: # python 3 izip = zip twilio-python-6.8.2/twilio/http/000077500000000000000000000000001317472742600166605ustar00rootroot00000000000000twilio-python-6.8.2/twilio/http/__init__.py000066400000000000000000000006231317472742600207720ustar00rootroot00000000000000from twilio.base.exceptions import TwilioException class HttpClient(object): """ An abstract class representing an HTTP client. """ def request(self, method, url, params=None, data=None, headers=None, auth=None, timeout=None, allow_redirects=False): """ Make an HTTP request. """ raise TwilioException('HttpClient is an abstract class') twilio-python-6.8.2/twilio/http/http_client.py000066400000000000000000000053361317472742600215560ustar00rootroot00000000000000from requests import Request, Session, hooks from twilio.http import HttpClient from twilio.http.response import Response from twilio.http.request import Request as TwilioRequest import logging from twilio.compat import urlencode _logger = logging.getLogger('twilio.http_client') class TwilioHttpClient(HttpClient): """ General purpose HTTP Client for interacting with the Twilio API """ def __init__(self, pool_connections=True, request_hooks=None): self.session = Session() if pool_connections else None self.last_request = None self.last_response = None self.request_hooks = request_hooks or hooks.default_hooks() def request(self, method, url, params=None, data=None, headers=None, auth=None, timeout=None, allow_redirects=False): """ Make an HTTP Request with parameters provided. :param str method: The HTTP method to use :param str url: The URL to request :param dict params: Query parameters to append to the URL :param dict data: Parameters to go in the body of the HTTP request :param dict headers: HTTP Headers to send with the request :param tuple auth: Basic Auth arguments :param float timeout: Socket/Read timeout for the request :param boolean allow_redirects: Whether or not to allow redirects See the requests documentation for explanation of all these parameters :return: An http response :rtype: A :class:`Response ` object """ kwargs = { 'method': method.upper(), 'url': url, 'params': params, 'data': data, 'headers': headers, 'auth': auth, 'hooks': self.request_hooks } if params: _logger.info('{method} Request: {url}?{query}'.format(query=urlencode(params), **kwargs)) _logger.info('PARAMS: {params}'.format(**kwargs)) else: _logger.info('{method} Request: {url}'.format(**kwargs)) if data: _logger.info('PAYLOAD: {data}'.format(**kwargs)) self.last_response = None session = self.session or Session() request = Request(**kwargs) self.last_request = TwilioRequest(**kwargs) prepped_request = session.prepare_request(request) response = session.send( prepped_request, allow_redirects=allow_redirects, timeout=timeout, ) _logger.info('{method} Response: {status} {text}'.format(method=method, status=response.status_code, text=response.text)) self.last_response = Response(int(response.status_code), response.text) return self.last_response twilio-python-6.8.2/twilio/http/request.py000066400000000000000000000043251317472742600207260ustar00rootroot00000000000000from twilio.compat import urlencode class Request(object): """ An HTTP request. """ ANY = '*' def __init__(self, method=ANY, url=ANY, auth=ANY, params=ANY, data=ANY, headers=ANY, **kwargs): self.method = method.upper() self.url = url self.auth = auth self.params = params self.data = data self.headers = headers @classmethod def attribute_equal(cls, lhs, rhs): if lhs == cls.ANY or rhs == cls.ANY: # ANY matches everything return True lhs = lhs or None rhs = rhs or None return lhs == rhs def __eq__(self, other): if not isinstance(other, Request): return False return self.attribute_equal(self.method, other.method) and \ self.attribute_equal(self.url, other.url) and \ self.attribute_equal(self.auth, other.auth) and \ self.attribute_equal(self.params, other.params) and \ self.attribute_equal(self.data, other.data) and \ self.attribute_equal(self.headers, other.headers) def __str__(self): auth = '' if self.auth and self.auth != self.ANY: auth = '{} '.format(self.auth) params = '' if self.params and self.params != self.ANY: params = '?{}'.format(urlencode(self.params, doseq=True)) data = '' if self.data and self.data != self.ANY: if self.method == 'GET': data = '\n -G' data += '\n{}'.format('\n'.join(' -d "{}={}"'.format(k, v) for k, v in self.data.items())) headers = '' if self.headers and self.headers != self.ANY: headers = '\n{}'.format('\n'.join(' -H "{}: {}"'.format(k, v) for k, v in self.headers.items())) return '{auth}{method} {url}{params}{data}{headers}'.format( auth=auth, method=self.method, url=self.url, params=params, data=data, headers=headers, ) def __repr__(self): return str(self) twilio-python-6.8.2/twilio/http/response.py000066400000000000000000000005671317472742600211000ustar00rootroot00000000000000class Response(object): """ """ def __init__(self, status_code, text): self.content = text self.cached = False self.status_code = status_code self.ok = self.status_code < 400 @property def text(self): return self.content def __repr__(self): return 'HTTP {} {}'.format(self.status_code, self.content) twilio-python-6.8.2/twilio/http/validation_client.py000066400000000000000000000076611317472742600227340ustar00rootroot00000000000000from collections import namedtuple from requests import Request, Session from twilio.compat import urlparse from twilio.http import HttpClient from twilio.http.response import Response from twilio.jwt.validation import ClientValidationJwt ValidationPayload = namedtuple('ValidationPayload', ['method', 'path', 'query_string', 'all_headers', 'signed_headers', 'body']) class ValidationClient(HttpClient): __SIGNED_HEADERS = ['authorization', 'host'] def __init__(self, account_sid, api_key_sid, credential_sid, private_key, pool_connections=True): """ Build a ValidationClient which signs requests with private_key and allows Twilio to validate request has not been tampered with. :param str account_sid: A Twilio Account Sid starting with 'AC' :param str api_key_sid: A Twilio API Key Sid starting with 'SK' :param str credential_sid: A Credential Sid starting with 'CR', corresponds to public key Twilio will use to verify the JWT. :param str private_key: The private key used to sign the Client Validation JWT. """ self.account_sid = account_sid self.credential_sid = credential_sid self.api_key_sid = api_key_sid self.private_key = private_key self.session = Session() if pool_connections else None def request(self, method, url, params=None, data=None, headers=None, auth=None, timeout=None, allow_redirects=False): """ Make a signed HTTP Request :param str method: The HTTP method to use :param str url: The URL to request :param dict params: Query parameters to append to the URL :param dict data: Parameters to go in the body of the HTTP request :param dict headers: HTTP Headers to send with the request :param tuple auth: Basic Auth arguments :param float timeout: Socket/Read timeout for the request :param boolean allow_redirects: Whether or not to allow redirects See the requests documentation for explanation of all these parameters :return: An http response :rtype: A :class:`Response ` object """ session = self.session or Session() request = Request(method.upper(), url, params=params, data=data, headers=headers, auth=auth) prepared_request = session.prepare_request(request) if 'Host' not in prepared_request.headers and 'host' not in prepared_request.headers: prepared_request.headers['Host'] = self._get_host(prepared_request) validation_payload = self._build_validation_payload(prepared_request) jwt = ClientValidationJwt(self.account_sid, self.api_key_sid, self.credential_sid, self.private_key, validation_payload) prepared_request.headers['Twilio-Client-Validation'] = jwt.to_jwt() response = session.send( prepared_request, allow_redirects=allow_redirects, timeout=timeout, ) return Response(int(response.status_code), response.text) def _build_validation_payload(self, request): """ Extract relevant information from request to build a ClientValidationJWT :param PreparedRequest request: request we will extract information from. :return: ValidationPayload """ parsed = urlparse(request.url) path = parsed.path query_string = parsed.query or '' return ValidationPayload( method=request.method, path=path, query_string=query_string, all_headers=request.headers, signed_headers=ValidationClient.__SIGNED_HEADERS, body=request.body or '' ) def _get_host(self, request): """Pull the Host out of the request""" parsed = urlparse(request.url) return parsed.netloc twilio-python-6.8.2/twilio/jwt/000077500000000000000000000000001317472742600165055ustar00rootroot00000000000000twilio-python-6.8.2/twilio/jwt/__init__.py000066400000000000000000000117751317472742600206310ustar00rootroot00000000000000import hmac import sys from twilio.jwt import compat if sys.version_info[0] == 3 and sys.version_info[1] == 2: # PyJWT expects hmac.compare_digest to exist even under python 3.2 hmac.compare_digest = compat.compare_digest import jwt as jwt_lib try: import json except ImportError: import simplejson as json import time __all__ = ['Jwt', 'JwtDecodeError'] class JwtDecodeError(Exception): pass class Jwt(object): """Base class for building a Json Web Token""" GENERATE = object() def __init__(self, secret_key, issuer, subject=None, algorithm='HS256', nbf=GENERATE, ttl=3600, valid_until=None): self.secret_key = secret_key """:type str: The secret used to encode the JWT""" self.issuer = issuer """:type str: The issuer of this JWT""" self.subject = subject """:type str: The subject of this JWT, ommited from payload by default""" self.algorithm = algorithm """:type str: The algorithm used to encode the JWT, defaults to 'HS256'""" self.nbf = nbf """:type int: Time in secs since epoch before which this JWT is invalid. Defaults to now.""" self.ttl = ttl """:type int: Time to live of the JWT in seconds, defaults to 1 hour""" self.valid_until = valid_until """:type int: Time in secs since epoch this JWT is valid for. Overrides ttl if provided.""" self.__decoded_payload = None self.__decoded_headers = None def _generate_payload(self): """:rtype: dict the payload of the JWT to send""" raise NotImplementedError('Subclass must provide a payload.') def _generate_headers(self): """:rtype dict: Additional headers to include in the JWT, defaults to an empty dict""" return {} @classmethod def _from_jwt(cls, headers, payload, key=None): """ Class specific implementation of from_jwt which should take jwt components and return and instance of this Class with jwt information loaded. :return: Jwt object containing the headers, payload and key """ jwt = Jwt( secret_key=key, issuer=payload.get('iss', None), subject=payload.get('sub', None), algorithm=headers.get('alg', None), valid_until=payload.get('exp', None), nbf=payload.get('nbf', None), ) jwt.__decoded_payload = payload jwt.__decoded_headers = headers return jwt @property def payload(self): if self.__decoded_payload: return self.__decoded_payload payload = self._generate_payload().copy() payload['iss'] = self.issuer payload['exp'] = int(time.time()) + self.ttl if self.nbf is not None: if self.nbf == self.GENERATE: payload['nbf'] = int(time.time()) else: payload['nbf'] = self.nbf if self.valid_until: payload['exp'] = self.valid_until if self.subject: payload['sub'] = self.subject return payload @property def headers(self): if self.__decoded_headers: return self.__decoded_headers headers = self._generate_headers().copy() headers['typ'] = 'JWT' headers['alg'] = self.algorithm return headers def to_jwt(self, algorithm=None, ttl=None): """ Encode this JWT object into a JWT string :param str algorithm: override the algorithm used to encode the JWT :param int ttl: override the ttl configured in the constructor :rtype: str The JWT string """ if not self.secret_key: raise ValueError('JWT does not have a signing key configured.') headers = self.headers.copy() if algorithm: headers['alg'] = algorithm algorithm = algorithm or self.algorithm payload = self.payload.copy() if ttl: payload['exp'] = int(time.time()) + ttl return jwt_lib.encode(payload, self.secret_key, algorithm=algorithm, headers=headers) @classmethod def from_jwt(cls, jwt, key=''): """ Decode a JWT string into a Jwt object :param str jwt: JWT string :param Optional[str] key: key used to verify JWT signature, if not provided then validation is skipped. :raises JwtDecodeError if decoding JWT fails for any reason. :return: A DecodedJwt object containing the jwt information. """ verify = True if key else False try: payload = jwt_lib.decode(bytes(jwt), key, options={ 'verify_signature': verify, 'verify_exp': True, 'verify_nbf': True, }) headers = jwt_lib.get_unverified_header(jwt) except Exception as e: raise JwtDecodeError(getattr(e, 'message', str(e))) return cls._from_jwt(headers, payload, key) def __str__(self): return ''.format(self.to_jwt()) twilio-python-6.8.2/twilio/jwt/access_token/000077500000000000000000000000001317472742600211465ustar00rootroot00000000000000twilio-python-6.8.2/twilio/jwt/access_token/__init__.py000066400000000000000000000041371317472742600232640ustar00rootroot00000000000000import time from twilio.jwt import Jwt class AccessTokenGrant(object): """A Grant giving access to a Twilio Resource""" @property def key(self): """:rtype str Grant's twilio specific key""" raise NotImplementedError('Grant must have a key property.') def to_payload(self): """:return: dict something""" raise NotImplementedError('Grant must implement to_payload.') def __str__(self): '<{} {}>'.format(self.__class__.__name__, self.to_payload()) class AccessToken(Jwt): """Access Token containing one or more AccessTokenGrants used to access Twilio Resources""" def __init__(self, account_sid, signing_key_sid, secret, grants=None, identity=None, nbf=Jwt.GENERATE, ttl=3600, valid_until=None): grants = grants or [] if any(not isinstance(g, AccessTokenGrant) for g in grants): raise ValueError('Grants must be instances of AccessTokenGrant.') self.account_sid = account_sid self.signing_key_sid = signing_key_sid self.identity = identity self.grants = grants super(AccessToken, self).__init__( secret_key=secret, algorithm='HS256', issuer=signing_key_sid, subject=self.account_sid, nbf=nbf, ttl=ttl, valid_until=valid_until, ) def add_grant(self, grant): """Add a grant to this AccessToken""" if not isinstance(grant, AccessTokenGrant): raise ValueError('Grant must be an instance of AccessTokenGrant.') self.grants.append(grant) def _generate_headers(self): return { 'cty': 'twilio-fpa;v=1' } def _generate_payload(self): now = int(time.time()) payload = { 'jti': '{}-{}'.format(self.signing_key_sid, now), 'grants': {grant.key: grant.to_payload() for grant in self.grants} } if self.identity: payload['grants']['identity'] = self.identity return payload def __str__(self): return ''.format(self.to_jwt()) twilio-python-6.8.2/twilio/jwt/access_token/grants.py000066400000000000000000000127471317472742600230310ustar00rootroot00000000000000from twilio.jwt.access_token import AccessTokenGrant import warnings import functools def deprecated(func): '''This is a decorator which can be used to mark functions as deprecated. It will result in a warning being emitted when the function is used.''' @functools.wraps(func) def new_func(*args, **kwargs): warnings.simplefilter('always', DeprecationWarning) warnings.warn("Call to deprecated function {}.".format(func.__name__), category=DeprecationWarning, stacklevel=2) warnings.simplefilter('default', DeprecationWarning) return func(*args, **kwargs) return new_func class ChatGrant(AccessTokenGrant): """Grant to access Twilio Chat""" def __init__(self, service_sid=None, endpoint_id=None, deployment_role_sid=None, push_credential_sid=None): self.service_sid = service_sid self.endpoint_id = endpoint_id self.deployment_role_sid = deployment_role_sid self.push_credential_sid = push_credential_sid @property def key(self): return "chat" def to_payload(self): grant = {} if self.service_sid: grant['service_sid'] = self.service_sid if self.endpoint_id: grant['endpoint_id'] = self.endpoint_id if self.deployment_role_sid: grant['deployment_role_sid'] = self.deployment_role_sid if self.push_credential_sid: grant['push_credential_sid'] = self.push_credential_sid return grant class IpMessagingGrant(AccessTokenGrant): """Grant to access Twilio IP Messaging""" @deprecated def __init__(self, service_sid=None, endpoint_id=None, deployment_role_sid=None, push_credential_sid=None): self.service_sid = service_sid self.endpoint_id = endpoint_id self.deployment_role_sid = deployment_role_sid self.push_credential_sid = push_credential_sid @property def key(self): return "ip_messaging" def to_payload(self): grant = {} if self.service_sid: grant['service_sid'] = self.service_sid if self.endpoint_id: grant['endpoint_id'] = self.endpoint_id if self.deployment_role_sid: grant['deployment_role_sid'] = self.deployment_role_sid if self.push_credential_sid: grant['push_credential_sid'] = self.push_credential_sid return grant class SyncGrant(AccessTokenGrant): """Grant to access Twilio Sync""" def __init__(self, service_sid=None, endpoint_id=None): self.service_sid = service_sid self.endpoint_id = endpoint_id @property def key(self): return "data_sync" def to_payload(self): grant = {} if self.service_sid: grant['service_sid'] = self.service_sid if self.endpoint_id: grant['endpoint_id'] = self.endpoint_id return grant class VoiceGrant(AccessTokenGrant): """Grant to access Twilio Programmable Voice""" def __init__(self, outgoing_application_sid=None, outgoing_application_params=None, push_credential_sid=None, endpoint_id=None): self.outgoing_application_sid = outgoing_application_sid """ :type : str """ self.outgoing_application_params = outgoing_application_params """ :type : dict """ self.push_credential_sid = push_credential_sid """ :type : str """ self.endpoint_id = endpoint_id """ :type : str """ @property def key(self): return "voice" def to_payload(self): grant = {} if self.outgoing_application_sid: grant['outgoing'] = {} grant['outgoing']['application_sid'] = self.outgoing_application_sid if self.outgoing_application_params: grant['outgoing']['params'] = self.outgoing_application_params if self.push_credential_sid: grant['push_credential_sid'] = self.push_credential_sid if self.endpoint_id: grant['endpoint_id'] = self.endpoint_id return grant class ConversationsGrant(AccessTokenGrant): """Grant to access Twilio Conversations""" @deprecated def __init__(self, configuration_profile_sid=None): self.configuration_profile_sid = configuration_profile_sid @property def key(self): return "rtc" def to_payload(self): grant = {} if self.configuration_profile_sid: grant['configuration_profile_sid'] = self.configuration_profile_sid return grant class VideoGrant(AccessTokenGrant): """Grant to access Twilio Video""" def __init__(self, room=None): self.room = room @property def key(self): return "video" def to_payload(self): grant = {} if self.room: grant['room'] = self.room return grant class TaskRouterGrant(AccessTokenGrant): """Grant to access Twilio TaskRouter""" def __init__(self, workspace_sid=None, worker_sid=None, role=None): self.workspace_sid = workspace_sid self.worker_sid = worker_sid self.role = role @property def key(self): return "task_router" def to_payload(self): grant = {} if self.workspace_sid: grant['workspace_sid'] = self.workspace_sid if self.worker_sid: grant['worker_sid'] = self.worker_sid if self.role: grant['role'] = self.role return grant twilio-python-6.8.2/twilio/jwt/client/000077500000000000000000000000001317472742600177635ustar00rootroot00000000000000twilio-python-6.8.2/twilio/jwt/client/__init__.py000066400000000000000000000074631317472742600221060ustar00rootroot00000000000000from twilio.jwt import Jwt from six import iteritems from twilio.compat import urlencode class ClientCapabilityToken(Jwt): """A token to control permissions with Twilio Client""" def __init__(self, account_sid, auth_token, nbf=Jwt.GENERATE, ttl=3600, valid_until=None, **kwargs): """ :param str account_sid: The account sid to which this token is granted access. :param str auth_token: The secret key used to sign the token. Note, this auth token is not visible to the user of the token. :param int nbf: Time in secs from epic before which this token is considered invalid. :param int ttl: the amount of time in seconds from generation that this token is valid for. :param kwargs: :returns: A new CapabilityToken with zero permissions """ super(ClientCapabilityToken, self).__init__( algorithm='HS256', secret_key=auth_token, issuer=account_sid, nbf=nbf, ttl=ttl, valid_until=None, ) self.account_sid = account_sid self.auth_token = auth_token self.client_name = None self.capabilities = {} if 'allow_client_outgoing' in kwargs: self.allow_client_outgoing(**kwargs['allow_client_outgoing']) if 'allow_client_incoming' in kwargs: self.allow_client_incoming(**kwargs['allow_client_incoming']) if 'allow_event_stream' in kwargs: self.allow_event_stream(**kwargs['allow_event_stream']) def allow_client_outgoing(self, application_sid, **kwargs): """ Allow the user of this token to make outgoing connections. Keyword arguments are passed to the application. :param str application_sid: Application to contact """ scope = ScopeURI('client', 'outgoing', {'appSid': application_sid}) if kwargs: scope.add_param('appParams', urlencode(kwargs, doseq=True)) self.capabilities['outgoing'] = scope def allow_client_incoming(self, client_name): """ Allow the user of this token to accept incoming connections. :param str client_name: Client name to accept calls from """ self.client_name = client_name self.capabilities['incoming'] = ScopeURI('client', 'incoming', {'clientName': client_name}) def allow_event_stream(self, **kwargs): """ Allow the user of this token to access their event stream. """ scope = ScopeURI('stream', 'subscribe', {'path': '/2010-04-01/Events'}) if kwargs: scope.add_param('params', urlencode(kwargs, doseq=True)) self.capabilities["events"] = scope def _generate_payload(self): if 'outgoing' in self.capabilities and self.client_name is not None: self.capabilities['outgoing'].add_param('clientName', self.client_name) scope_uris = [scope_uri.to_payload() for scope_uri in self.capabilities.values()] return {'scope': ' '.join(scope_uris)} class ScopeURI(object): """A single capability granted to Twilio Client and scoped to a service""" def __init__(self, service, privilege, params=None): self.service = service self.privilege = privilege self.params = params or {} def add_param(self, key, value): self.params[key] = value def to_payload(self): if self.params: sorted_params = sorted([(k, v) for k, v in iteritems(self.params)]) encoded_params = urlencode(sorted_params) param_string = '?{}'.format(encoded_params) else: param_string = '' return 'scope:{}:{}{}'.format(self.service, self.privilege, param_string) def __str__(self): return ''.format(self.to_payload()) twilio-python-6.8.2/twilio/jwt/compat.py000066400000000000000000000021361317472742600203440ustar00rootroot00000000000000def compare_digest(a, b): """ PyJWT expects hmac.compare_digest to exist for all Python 3.x, however it was added in Python > 3.3 It has a fallback for Python 2.x but not for Pythons between 2.x and 3.3 Copied from: https://github.com/python/cpython/commit/6cea65555caf2716b4633827715004ab0291a282#diff-c49659257ec1b129707ce47a98adc96eL16 Returns the equivalent of 'a == b', but avoids content based short circuiting to reduce the vulnerability to timing attacks. """ # Consistent timing matters more here than data type flexibility if not (isinstance(a, bytes) and isinstance(b, bytes)): raise TypeError("inputs must be bytes instances") # We assume the length of the expected digest is public knowledge, # thus this early return isn't leaking anything an attacker wouldn't # already know if len(a) != len(b): return False # We assume that integers in the bytes range are all cached, # thus timing shouldn't vary much due to integer object creation result = 0 for x, y in zip(a, b): result |= x ^ y return result == 0 twilio-python-6.8.2/twilio/jwt/taskrouter/000077500000000000000000000000001317472742600207105ustar00rootroot00000000000000twilio-python-6.8.2/twilio/jwt/taskrouter/__init__.py000066400000000000000000000127201317472742600230230ustar00rootroot00000000000000from twilio.jwt import Jwt class TaskRouterCapabilityToken(Jwt): VERSION = 'v1' DOMAIN = 'https://taskrouter.twilio.com' EVENTS_BASE_URL = 'https://event-bridge.twilio.com/v1/wschannels' def __init__(self, account_sid, auth_token, workspace_sid, channel_id, **kwargs): """ :param str account_sid: Twilio account sid :param str auth_token: Twilio auth token used to sign the JWT :param str workspace_sid: TaskRouter workspace sid :param str channel_id: TaskRouter channel sid :param kwargs: :param bool allow_web_sockets: shortcut to calling allow_web_sockets, defaults to True :param bool allow_fetch_self: shortcut to calling allow_fetch_self, defaults to True :param bool allow_update_self: shortcut to calling allow_update_self, defaults to False :param bool allow_delete_self: shortcut to calling allow_delete_self, defaults to False :param bool allow_fetch_subresources: shortcut to calling allow_fetch_subresources, defaults to False :param bool allow_update_subresources: shortcut to calling allow_update_subresources, defaults to False :param bool allow_delete_subresources: shortcut to calling allow_delete_subresources, defaults to False :returns a new TaskRouterCapabilityToken with capabilities set depending on kwargs. """ super(TaskRouterCapabilityToken, self).__init__( secret_key=auth_token, issuer=account_sid, algorithm='HS256', nbf=kwargs.get('nbf', Jwt.GENERATE), ttl=kwargs.get('ttl', 3600), valid_until=kwargs.get('valid_until', None), ) self._validate_inputs(account_sid, workspace_sid, channel_id) self.account_sid = account_sid self.auth_token = auth_token self.workspace_sid = workspace_sid self.channel_id = channel_id self.policies = [] if kwargs.get('allow_web_sockets', True): self.allow_web_sockets() if kwargs.get('allow_fetch_self', True): self.allow_fetch_self() if kwargs.get('allow_update_self', False): self.allow_update_self() if kwargs.get('allow_delete_self', False): self.allow_delete_self() if kwargs.get('allow_fetch_subresources', False): self.allow_fetch_subresources() if kwargs.get('allow_delete_subresources', False): self.allow_delete_subresources() if kwargs.get('allow_update_subresources', False): self.allow_update_subresources() @property def workspace_url(self): return '{}/{}/Workspaces/{}'.format(self.DOMAIN, self.VERSION, self.workspace_sid) @property def resource_url(self): raise NotImplementedError('Subclass must set its specific resource_url.') @property def channel_prefix(self): raise NotImplementedError('Subclass must set its specific channel_id sid prefix.') def allow_fetch_self(self): self._make_policy(self.resource_url, 'GET', True) def allow_update_self(self): self._make_policy(self.resource_url, 'POST', True) def allow_delete_self(self): self._make_policy(self.resource_url, 'DELETE', True) def allow_fetch_subresources(self): self._make_policy(self.resource_url + '/**', 'GET', True) def allow_update_subresources(self): self._make_policy(self.resource_url + '/**', 'POST', True) def allow_delete_subresources(self): self._make_policy(self.resource_url + '/**', 'DELETE', True) def allow_web_sockets(self, channel_id=None): channel_id = channel_id or self.channel_id web_socket_url = '{}/{}/{}'.format(self.EVENTS_BASE_URL, self.account_sid, channel_id) self._make_policy(web_socket_url, 'GET', True) self._make_policy(web_socket_url, 'POST', True) def _generate_payload(self): payload = { 'account_sid': self.account_sid, 'workspace_sid': self.workspace_sid, 'channel': self.channel_id, 'version': self.VERSION, 'friendly_name': self.channel_id, 'policies': self.policies, } if self.channel_id.startswith('WK'): payload['worker_sid'] = self.channel_id elif self.channel_id.startswith('WQ'): payload['taskqueue_sid'] = self.channel_id return payload def _make_policy(self, url, method, allowed, query_filter=None, post_filter=None): self.policies.append({ 'url': url, 'method': method.upper(), 'allow': allowed, 'query_filter': query_filter or {}, 'post_filter': post_filter or {}, }) def _validate_inputs(self, account_sid, workspace_sid, channel_id): if not account_sid or not account_sid.startswith('AC'): raise ValueError('Invalid account sid provided {}'.format(account_sid)) if not workspace_sid or not workspace_sid.startswith('WS'): raise ValueError('Invalid workspace sid provided {}'.format(workspace_sid)) if not channel_id or not channel_id.startswith(self.channel_prefix): raise ValueError('Invalid channel id provided {}'.format(channel_id)) def __str__(self): return ''.format(self.to_jwt()) twilio-python-6.8.2/twilio/jwt/taskrouter/capabilities.py000066400000000000000000000102711317472742600237140ustar00rootroot00000000000000from twilio.jwt.taskrouter import TaskRouterCapabilityToken class WorkerCapabilityToken(TaskRouterCapabilityToken): def __init__(self, account_sid, auth_token, workspace_sid, worker_sid, ttl=3600, **kwargs): """ :param kwargs: All kwarg parameters supported by TaskRouterCapabilityToken :param bool allow_fetch_activities: shortcut to calling allow_fetch_activities, defaults to True :param bool allow_fetch_reservations: shortcut to calling allow_fetch_reservations, defaults to True :param bool allow_fetch_worker_reservations: shortcut to calling allow_fetch_worker_reservations, defaults to True :param bool allow_update_activities: shortcut to calling allow_update_activities, defaults to False :param bool allow_update_reservations: shortcut to calling allow_update_reservations, defaults to False """ super(WorkerCapabilityToken, self).__init__( account_sid=account_sid, auth_token=auth_token, workspace_sid=workspace_sid, channel_id=worker_sid, ttl=ttl, **kwargs ) if kwargs.get('allow_fetch_activities', True): self.allow_fetch_activities() if kwargs.get('allow_fetch_reservations', True): self.allow_fetch_reservations() if kwargs.get('allow_fetch_worker_reservations', True): self.allow_fetch_worker_reservations() if kwargs.get('allow_update_activities', False): self.allow_update_activities() if kwargs.get('allow_update_reservations', False): self.allow_update_reservations() @property def resource_url(self): return '{}/Workers/{}'.format(self.workspace_url, self.channel_id) @property def channel_prefix(self): return 'WK' def allow_fetch_activities(self): self._make_policy(self.workspace_url + '/Activities', 'GET', True) def allow_fetch_reservations(self): self._make_policy(self.workspace_url + '/Tasks/**', 'GET', True) def allow_fetch_worker_reservations(self): self._make_policy(self.resource_url + '/Reservations/**', 'GET', True) def allow_update_activities(self): post_filter = {'ActivitySid': {'required': True}} self._make_policy(self.resource_url, 'POST', True, post_filter=post_filter) def allow_update_reservations(self): self._make_policy(self.workspace_url + '/Tasks/**', 'POST', True) self._make_policy(self.resource_url + '/Reservations/**', 'POST', True) def __str__(self): return ''.format(self.to_jwt()) class TaskQueueCapabilityToken(TaskRouterCapabilityToken): def __init__(self, account_sid, auth_token, workspace_sid, task_queue_sid, ttl=3600, **kwargs): super(TaskQueueCapabilityToken, self).__init__( account_sid=account_sid, auth_token=auth_token, workspace_sid=workspace_sid, channel_id=task_queue_sid, ttl=ttl, **kwargs ) @property def resource_url(self): return '{}/TaskQueues/{}'.format(self.workspace_url, self.channel_id) @property def channel_prefix(self): return 'WQ' def __str__(self): return ''.format(self.to_jwt()) class WorkspaceCapabilityToken(TaskRouterCapabilityToken): def __init__(self, account_sid, auth_token, workspace_sid, ttl=3600, **kwargs): super(WorkspaceCapabilityToken, self).__init__( account_sid=account_sid, auth_token=auth_token, workspace_sid=workspace_sid, channel_id=workspace_sid, ttl=ttl, **kwargs ) @property def resource_url(self): return self.workspace_url @property def channel_prefix(self): return 'WS' def __str__(self): return ''.format(self.to_jwt()) twilio-python-6.8.2/twilio/jwt/validation/000077500000000000000000000000001317472742600206375ustar00rootroot00000000000000twilio-python-6.8.2/twilio/jwt/validation/__init__.py000066400000000000000000000061041317472742600227510ustar00rootroot00000000000000from hashlib import sha256 from six import string_types from twilio.jwt import Jwt class ClientValidationJwt(Jwt): """A JWT included on requests so that Twilio can verify request authenticity""" __CTY = 'twilio-pkrv;v=1' def __init__(self, account_sid, api_key_sid, credential_sid, private_key, validation_payload): """ Create a new ClientValidationJwt :param str account_sid: A Twilio Account Sid starting with 'AC' :param str api_key_sid: A Twilio API Key Sid starting with 'SK' :param str credential_sid: A Credential Sid starting with 'CR', public key Twilio will use to verify the JWT. :param str private_key: The private key used to sign the JWT. :param ValidationPayload validation_payload: information from the request to sign """ super(ClientValidationJwt, self).__init__( secret_key=private_key, issuer=api_key_sid, subject=account_sid, algorithm='RS256', ttl=300 # 5 minute ttl ) self.credential_sid = credential_sid self.validation_payload = validation_payload def _generate_headers(self): return { 'cty': ClientValidationJwt.__CTY, 'kid': self.credential_sid } def _generate_payload(self): # Lowercase header keys, combine and sort headers with list values all_headers = {k.lower(): self._sort_and_join(v, ',') for k, v in self.validation_payload.all_headers.items()} # Names of headers we are signing in the jwt signed_headers = sorted(self.validation_payload.signed_headers) # Stringify headers, only include headers in signed_headers headers_str = ['{}:{}'.format(h, all_headers[h]) for h in signed_headers if h in all_headers] headers_str = '\n'.join(headers_str) # Sort query string parameters query_string = self.validation_payload.query_string.split('&') query_string = self._sort_and_join(query_string, '&') req_body_hash = self._hash(self.validation_payload.body) or '' signed_headers_str = ';'.join(signed_headers) signed_payload = [ self.validation_payload.method, self.validation_payload.path, query_string, ] if headers_str: signed_payload.append(headers_str) signed_payload.append('') signed_payload.append(signed_headers_str) signed_payload.append(req_body_hash) signed_payload = '\n'.join(signed_payload) return { 'hrh': signed_headers_str, 'rqh': self._hash(signed_payload) } @classmethod def _sort_and_join(self, values, joiner): if isinstance(values, string_types): return values return joiner.join(sorted(values)) @classmethod def _hash(self, input_str): if not input_str: return input_str if not isinstance(input_str, bytes): input_str = input_str.encode('utf-8') return sha256(input_str).hexdigest() twilio-python-6.8.2/twilio/request_validator.py000066400000000000000000000044231317472742600220130ustar00rootroot00000000000000import base64 import hmac from hashlib import sha1 from six import PY3 from twilio.compat import izip, urlparse def compare(string1, string2): """Compare two strings while protecting against timing attacks :param str string1: the first string :param str string2: the second string :returns: True if the strings are equal, False if not :rtype: :obj:`bool` """ if len(string1) != len(string2): return False result = True for c1, c2 in izip(string1, string2): result &= c1 == c2 return result def remove_port(uri): """Remove the port number from a URI :param uri: full URI that Twilio requested on your server :returns: full URI without a port number :rtype: str """ new_netloc = uri.netloc.split(':')[0] new_uri = uri._replace(netloc=new_netloc) return new_uri.geturl() class RequestValidator(object): def __init__(self, token): self.token = token.encode("utf-8") def compute_signature(self, uri, params, utf=PY3): """Compute the signature for a given request :param uri: full URI that Twilio requested on your server :param params: post vars that Twilio sent with the request :param utf: whether return should be bytestring or unicode (python3) :returns: The computed signature """ s = uri if len(params) > 0: for k, v in sorted(params.items()): s += k + v # compute signature and compare signatures mac = hmac.new(self.token, s.encode("utf-8"), sha1) computed = base64.b64encode(mac.digest()) if utf: computed = computed.decode('utf-8') return computed.strip() def validate(self, uri, params, signature): """Validate a request from Twilio :param uri: full URI that Twilio requested on your server :param params: post vars that Twilio sent with the request :param signature: expected signature in HTTP X-Twilio-Signature header :returns: True if the request passes validation, False if not """ parsed_uri = urlparse(uri) if parsed_uri.scheme == "https" and parsed_uri.port: uri = remove_port(parsed_uri) return compare(self.compute_signature(uri, params), signature) twilio-python-6.8.2/twilio/rest/000077500000000000000000000000001317472742600166565ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/__init__.py000066400000000000000000000372001317472742600207710ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ import os import platform from twilio import __version__ from twilio.base.exceptions import TwilioException from twilio.base.obsolete import obsolete_client from twilio.http.http_client import TwilioHttpClient class Client(object): """ A client for accessing the Twilio API. """ def __init__(self, username=None, password=None, account_sid=None, region=None, http_client=None, environment=None): """ Initializes the Twilio Client :param str username: Username to authenticate with :param str password: Password to authenticate with :param str account_sid: Account Sid, defaults to Username :param str region: Twilio Region to make requests to :param HttpClient http_client: HttpClient, defaults to TwilioHttpClient :param dict environment: Environment to look for auth details, defaults to os.environ :returns: Twilio Client :rtype: twilio.rest.Client """ environment = environment or os.environ self.username = username or environment.get('TWILIO_ACCOUNT_SID') """ :type : str """ self.password = password or environment.get('TWILIO_AUTH_TOKEN') """ :type : str """ self.account_sid = account_sid or self.username """ :type : str """ self.region = region """ :type : str """ if not self.username or not self.password: raise TwilioException("Credentials are required to create a TwilioClient") self.auth = (self.username, self.password) """ :type : tuple(str, str) """ self.http_client = http_client or TwilioHttpClient() """ :type : HttpClient """ # Domains self._accounts = None self._api = None self._chat = None self._fax = None self._ip_messaging = None self._lookups = None self._monitor = None self._notify = None self._preview = None self._pricing = None self._proxy = None self._taskrouter = None self._trunking = None self._video = None self._messaging = None self._wireless = None self._sync = None def request(self, method, uri, params=None, data=None, headers=None, auth=None, timeout=None, allow_redirects=False): """ Makes a request to the Twilio API using the configured http client Authentication information is automatically added if none is provided :param str method: HTTP Method :param str uri: Fully qualified url :param dict[str, str] params: Query string parameters :param dict[str, str] data: POST body data :param dict[str, str] headers: HTTP Headers :param tuple(str, str) auth: Authentication :param int timeout: Timeout in seconds :param bool allow_redirects: Should the client follow redirects :returns: Response from the Twilio API :rtype: twilio.http.response.Response """ auth = auth or self.auth headers = headers or {} headers['User-Agent'] = 'twilio-python/{} (Python {})'.format( __version__, platform.python_version(), ) headers['X-Twilio-Client'] = 'python-{}'.format(__version__) headers['Accept-Charset'] = 'utf-8' if method == 'POST' and 'Content-Type' not in headers: headers['Content-Type'] = 'application/x-www-form-urlencoded' if 'Accept' not in headers: headers['Accept'] = 'application/json' if self.region: head, tail = uri.split('.', 1) if not tail.startswith(self.region): uri = '.'.join([head, self.region, tail]) return self.http_client.request( method, uri, params=params, data=data, headers=headers, auth=auth, timeout=timeout, allow_redirects=allow_redirects ) @property def accounts(self): """ Access the Accounts Twilio Domain :returns: Accounts Twilio Domain :rtype: twilio.rest.accounts.Accounts """ if self._accounts is None: from twilio.rest.accounts import Accounts self._accounts = Accounts(self) return self._accounts @property def api(self): """ Access the Api Twilio Domain :returns: Api Twilio Domain :rtype: twilio.rest.api.Api """ if self._api is None: from twilio.rest.api import Api self._api = Api(self) return self._api @property def chat(self): """ Access the Chat Twilio Domain :returns: Chat Twilio Domain :rtype: twilio.rest.chat.Chat """ if self._chat is None: from twilio.rest.chat import Chat self._chat = Chat(self) return self._chat @property def fax(self): """ Access the Fax Twilio Domain :returns: Fax Twilio Domain :rtype: twilio.rest.fax.Fax """ if self._fax is None: from twilio.rest.fax import Fax self._fax = Fax(self) return self._fax @property def ip_messaging(self): """ Access the IpMessaging Twilio Domain :returns: IpMessaging Twilio Domain :rtype: twilio.rest.ip_messaging.IpMessaging """ if self._ip_messaging is None: from twilio.rest.ip_messaging import IpMessaging self._ip_messaging = IpMessaging(self) return self._ip_messaging @property def lookups(self): """ Access the Lookups Twilio Domain :returns: Lookups Twilio Domain :rtype: twilio.rest.lookups.Lookups """ if self._lookups is None: from twilio.rest.lookups import Lookups self._lookups = Lookups(self) return self._lookups @property def monitor(self): """ Access the Monitor Twilio Domain :returns: Monitor Twilio Domain :rtype: twilio.rest.monitor.Monitor """ if self._monitor is None: from twilio.rest.monitor import Monitor self._monitor = Monitor(self) return self._monitor @property def notify(self): """ Access the Notify Twilio Domain :returns: Notify Twilio Domain :rtype: twilio.rest.notify.Notify """ if self._notify is None: from twilio.rest.notify import Notify self._notify = Notify(self) return self._notify @property def preview(self): """ Access the Preview Twilio Domain :returns: Preview Twilio Domain :rtype: twilio.rest.preview.Preview """ if self._preview is None: from twilio.rest.preview import Preview self._preview = Preview(self) return self._preview @property def pricing(self): """ Access the Pricing Twilio Domain :returns: Pricing Twilio Domain :rtype: twilio.rest.pricing.Pricing """ if self._pricing is None: from twilio.rest.pricing import Pricing self._pricing = Pricing(self) return self._pricing @property def proxy(self): """ Access the Proxy Twilio Domain :returns: Proxy Twilio Domain :rtype: twilio.rest.proxy.Proxy """ if self._proxy is None: from twilio.rest.proxy import Proxy self._proxy = Proxy(self) return self._proxy @property def taskrouter(self): """ Access the Taskrouter Twilio Domain :returns: Taskrouter Twilio Domain :rtype: twilio.rest.taskrouter.Taskrouter """ if self._taskrouter is None: from twilio.rest.taskrouter import Taskrouter self._taskrouter = Taskrouter(self) return self._taskrouter @property def trunking(self): """ Access the Trunking Twilio Domain :returns: Trunking Twilio Domain :rtype: twilio.rest.trunking.Trunking """ if self._trunking is None: from twilio.rest.trunking import Trunking self._trunking = Trunking(self) return self._trunking @property def video(self): """ Access the Video Twilio Domain :returns: Video Twilio Domain :rtype: twilio.rest.video.Video """ if self._video is None: from twilio.rest.video import Video self._video = Video(self) return self._video @property def messaging(self): """ Access the Messaging Twilio Domain :returns: Messaging Twilio Domain :rtype: twilio.rest.messaging.Messaging """ if self._messaging is None: from twilio.rest.messaging import Messaging self._messaging = Messaging(self) return self._messaging @property def wireless(self): """ Access the Wireless Twilio Domain :returns: Wireless Twilio Domain :rtype: twilio.rest.wireless.Wireless """ if self._wireless is None: from twilio.rest.wireless import Wireless self._wireless = Wireless(self) return self._wireless @property def sync(self): """ Access the Sync Twilio Domain :returns: Sync Twilio Domain :rtype: twilio.rest.sync.Sync """ if self._sync is None: from twilio.rest.sync import Sync self._sync = Sync(self) return self._sync @property def addresses(self): """ :rtype: twilio.rest.api.v2010.account.address.AddressList """ return self.api.account.addresses @property def applications(self): """ :rtype: twilio.rest.api.v2010.account.application.ApplicationList """ return self.api.account.applications @property def authorized_connect_apps(self): """ :rtype: twilio.rest.api.v2010.account.authorized_connect_app.AuthorizedConnectAppList """ return self.api.account.authorized_connect_apps @property def available_phone_numbers(self): """ :rtype: twilio.rest.api.v2010.account.available_phone_number.AvailablePhoneNumberCountryList """ return self.api.account.available_phone_numbers @property def calls(self): """ :rtype: twilio.rest.api.v2010.account.call.CallList """ return self.api.account.calls @property def conferences(self): """ :rtype: twilio.rest.api.v2010.account.conference.ConferenceList """ return self.api.account.conferences @property def connect_apps(self): """ :rtype: twilio.rest.api.v2010.account.connect_app.ConnectAppList """ return self.api.account.connect_apps @property def incoming_phone_numbers(self): """ :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberList """ return self.api.account.incoming_phone_numbers @property def keys(self): """ :rtype: twilio.rest.api.v2010.account.key.KeyList """ return self.api.account.keys @property def messages(self): """ :rtype: twilio.rest.api.v2010.account.message.MessageList """ return self.api.account.messages @property def new_keys(self): """ :rtype: twilio.rest.api.v2010.account.new_key.NewKeyList """ return self.api.account.new_keys @property def new_signing_keys(self): """ :rtype: twilio.rest.api.v2010.account.new_signing_key.NewSigningKeyList """ return self.api.account.new_signing_keys @property def notifications(self): """ :rtype: twilio.rest.api.v2010.account.notification.NotificationList """ return self.api.account.notifications @property def outgoing_caller_ids(self): """ :rtype: twilio.rest.api.v2010.account.outgoing_caller_id.OutgoingCallerIdList """ return self.api.account.outgoing_caller_ids @property def queues(self): """ :rtype: twilio.rest.api.v2010.account.queue.QueueList """ return self.api.account.queues @property def recordings(self): """ :rtype: twilio.rest.api.v2010.account.recording.RecordingList """ return self.api.account.recordings @property def signing_keys(self): """ :rtype: twilio.rest.api.v2010.account.signing_key.SigningKeyList """ return self.api.account.signing_keys @property def sip(self): """ :rtype: twilio.rest.api.v2010.account.sip.SipList """ return self.api.account.sip @property def short_codes(self): """ :rtype: twilio.rest.api.v2010.account.short_code.ShortCodeList """ return self.api.account.short_codes @property def tokens(self): """ :rtype: twilio.rest.api.v2010.account.token.TokenList """ return self.api.account.tokens @property def transcriptions(self): """ :rtype: twilio.rest.api.v2010.account.transcription.TranscriptionList """ return self.api.account.transcriptions @property def usage(self): """ :rtype: twilio.rest.api.v2010.account.usage.UsageList """ return self.api.account.usage @property def validation_requests(self): """ :rtype: twilio.rest.api.v2010.account.validation_request.ValidationRequestList """ return self.api.account.validation_requests def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return ''.format(self.account_sid) @obsolete_client class TwilioClient(object): """ Dummy client which provides no functionality. Please use twilio.rest.Client instead. """ def __init__(self, *args): pass @obsolete_client class TwilioRestClient(object): """ Dummy client which provides no functionality. Please use twilio.rest.Client instead. """ def __init__(self, *args): pass @obsolete_client class TwilioIpMessagingClient(object): """ Dummy client which provides no functionality. Please use twilio.rest.Client instead. """ def __init__(self, *args): pass @obsolete_client class TwilioLookupsClient(object): """ Dummy client which provides no functionality. Please use twilio.rest.Client instead. """ def __init__(self, *args): pass @obsolete_client class TwilioMonitorClient(object): """ Dummy client which provides no functionality. Please use twilio.rest.Client instead. """ def __init__(self, *args): pass @obsolete_client class TwilioPricingClient(object): """ Dummy client which provides no functionality. Please use twilio.rest.Client instead. """ def __init__(self, *args): pass @obsolete_client class TwilioTaskRouterClient(object): """ Dummy client which provides no functionality. Please use twilio.rest.Client instead. """ def __init__(self, *args): pass @obsolete_client class TwilioTrunkingClient(object): """ Dummy client which provides no functionality. Please use twilio.rest.Client instead. """ def __init__(self, *args): pass twilio-python-6.8.2/twilio/rest/accounts/000077500000000000000000000000001317472742600204755ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/accounts/__init__.py000066400000000000000000000021641317472742600226110ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.domain import Domain from twilio.rest.accounts.v1 import V1 class Accounts(Domain): def __init__(self, twilio): """ Initialize the Accounts Domain :returns: Domain for Accounts :rtype: twilio.rest.accounts.Accounts """ super(Accounts, self).__init__(twilio) self.base_url = 'https://accounts.twilio.com' # Versions self._v1 = None @property def v1(self): """ :returns: Version v1 of accounts :rtype: twilio.rest.accounts.v1.V1 """ if self._v1 is None: self._v1 = V1(self) return self._v1 @property def credentials(self): """ :rtype: twilio.rest.accounts.v1.credential.CredentialList """ return self.v1.credentials def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/accounts/v1/000077500000000000000000000000001317472742600210235ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/accounts/v1/__init__.py000066400000000000000000000017401317472742600231360ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.version import Version from twilio.rest.accounts.v1.credential import CredentialList class V1(Version): def __init__(self, domain): """ Initialize the V1 version of Accounts :returns: V1 version of Accounts :rtype: twilio.rest.accounts.v1.V1.V1 """ super(V1, self).__init__(domain) self.version = 'v1' self._credentials = None @property def credentials(self): """ :rtype: twilio.rest.accounts.v1.credential.CredentialList """ if self._credentials is None: self._credentials = CredentialList(self) return self._credentials def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/accounts/v1/credential/000077500000000000000000000000001317472742600231355ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/accounts/v1/credential/__init__.py000066400000000000000000000062421317472742600252520ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page from twilio.rest.accounts.v1.credential.public_key import PublicKeyList class CredentialList(ListResource): """ """ def __init__(self, version): """ Initialize the CredentialList :param Version version: Version that contains the resource :returns: twilio.rest.accounts.v1.credential.CredentialList :rtype: twilio.rest.accounts.v1.credential.CredentialList """ super(CredentialList, self).__init__(version) # Path Solution self._solution = {} # Components self._public_key = None @property def public_key(self): """ Access the public_key :returns: twilio.rest.accounts.v1.credential.public_key.PublicKeyList :rtype: twilio.rest.accounts.v1.credential.public_key.PublicKeyList """ if self._public_key is None: self._public_key = PublicKeyList(self._version,) return self._public_key def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class CredentialPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the CredentialPage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.accounts.v1.credential.CredentialPage :rtype: twilio.rest.accounts.v1.credential.CredentialPage """ super(CredentialPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of CredentialInstance :param dict payload: Payload response from the API :returns: twilio.rest.accounts.v1.credential.CredentialInstance :rtype: twilio.rest.accounts.v1.credential.CredentialInstance """ return CredentialInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class CredentialInstance(InstanceResource): """ """ def __init__(self, version, payload): """ Initialize the CredentialInstance :returns: twilio.rest.accounts.v1.credential.CredentialInstance :rtype: twilio.rest.accounts.v1.credential.CredentialInstance """ super(CredentialInstance, self).__init__(version) # Context self._context = None self._solution = {} def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/accounts/v1/credential/public_key.py000066400000000000000000000323661317472742600256470ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class PublicKeyList(ListResource): """ """ def __init__(self, version): """ Initialize the PublicKeyList :param Version version: Version that contains the resource :returns: twilio.rest.accounts.v1.credential.public_key.PublicKeyList :rtype: twilio.rest.accounts.v1.credential.public_key.PublicKeyList """ super(PublicKeyList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/Credentials/PublicKeys'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams PublicKeyInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.accounts.v1.credential.public_key.PublicKeyInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists PublicKeyInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.accounts.v1.credential.public_key.PublicKeyInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of PublicKeyInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of PublicKeyInstance :rtype: twilio.rest.accounts.v1.credential.public_key.PublicKeyPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return PublicKeyPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of PublicKeyInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of PublicKeyInstance :rtype: twilio.rest.accounts.v1.credential.public_key.PublicKeyPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return PublicKeyPage(self._version, response, self._solution) def create(self, public_key, friendly_name=values.unset, account_sid=values.unset): """ Create a new PublicKeyInstance :param unicode public_key: URL encoded representation of the public key :param unicode friendly_name: A human readable description of this resource :param unicode account_sid: The Subaccount this Credential should be associated with. :returns: Newly created PublicKeyInstance :rtype: twilio.rest.accounts.v1.credential.public_key.PublicKeyInstance """ data = values.of({'PublicKey': public_key, 'FriendlyName': friendly_name, 'AccountSid': account_sid,}) payload = self._version.create( 'POST', self._uri, data=data, ) return PublicKeyInstance(self._version, payload,) def get(self, sid): """ Constructs a PublicKeyContext :param sid: Fetch by unique Credential Sid :returns: twilio.rest.accounts.v1.credential.public_key.PublicKeyContext :rtype: twilio.rest.accounts.v1.credential.public_key.PublicKeyContext """ return PublicKeyContext(self._version, sid=sid,) def __call__(self, sid): """ Constructs a PublicKeyContext :param sid: Fetch by unique Credential Sid :returns: twilio.rest.accounts.v1.credential.public_key.PublicKeyContext :rtype: twilio.rest.accounts.v1.credential.public_key.PublicKeyContext """ return PublicKeyContext(self._version, sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class PublicKeyPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the PublicKeyPage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.accounts.v1.credential.public_key.PublicKeyPage :rtype: twilio.rest.accounts.v1.credential.public_key.PublicKeyPage """ super(PublicKeyPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of PublicKeyInstance :param dict payload: Payload response from the API :returns: twilio.rest.accounts.v1.credential.public_key.PublicKeyInstance :rtype: twilio.rest.accounts.v1.credential.public_key.PublicKeyInstance """ return PublicKeyInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class PublicKeyContext(InstanceContext): """ """ def __init__(self, version, sid): """ Initialize the PublicKeyContext :param Version version: Version that contains the resource :param sid: Fetch by unique Credential Sid :returns: twilio.rest.accounts.v1.credential.public_key.PublicKeyContext :rtype: twilio.rest.accounts.v1.credential.public_key.PublicKeyContext """ super(PublicKeyContext, self).__init__(version) # Path Solution self._solution = {'sid': sid,} self._uri = '/Credentials/PublicKeys/{sid}'.format(**self._solution) def fetch(self): """ Fetch a PublicKeyInstance :returns: Fetched PublicKeyInstance :rtype: twilio.rest.accounts.v1.credential.public_key.PublicKeyInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return PublicKeyInstance(self._version, payload, sid=self._solution['sid'],) def update(self, friendly_name=values.unset): """ Update the PublicKeyInstance :param unicode friendly_name: A human readable description of this resource :returns: Updated PublicKeyInstance :rtype: twilio.rest.accounts.v1.credential.public_key.PublicKeyInstance """ data = values.of({'FriendlyName': friendly_name,}) payload = self._version.update( 'POST', self._uri, data=data, ) return PublicKeyInstance(self._version, payload, sid=self._solution['sid'],) def delete(self): """ Deletes the PublicKeyInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class PublicKeyInstance(InstanceResource): """ """ def __init__(self, version, payload, sid=None): """ Initialize the PublicKeyInstance :returns: twilio.rest.accounts.v1.credential.public_key.PublicKeyInstance :rtype: twilio.rest.accounts.v1.credential.public_key.PublicKeyInstance """ super(PublicKeyInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'friendly_name': payload['friendly_name'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'url': payload['url'], } # Context self._context = None self._solution = {'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: PublicKeyContext for this PublicKeyInstance :rtype: twilio.rest.accounts.v1.credential.public_key.PublicKeyContext """ if self._context is None: self._context = PublicKeyContext(self._version, sid=self._solution['sid'],) return self._context @property def sid(self): """ :returns: A 34 character string that uniquely identifies this resource. :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: AccountSid the Credential resource belongs to :rtype: unicode """ return self._properties['account_sid'] @property def friendly_name(self): """ :returns: A human readable description of this resource :rtype: unicode """ return self._properties['friendly_name'] @property def date_created(self): """ :returns: The date this resource was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this resource was last updated :rtype: datetime """ return self._properties['date_updated'] @property def url(self): """ :returns: The URI for this resource, relative to `https://accounts.twilio.com` :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a PublicKeyInstance :returns: Fetched PublicKeyInstance :rtype: twilio.rest.accounts.v1.credential.public_key.PublicKeyInstance """ return self._proxy.fetch() def update(self, friendly_name=values.unset): """ Update the PublicKeyInstance :param unicode friendly_name: A human readable description of this resource :returns: Updated PublicKeyInstance :rtype: twilio.rest.accounts.v1.credential.public_key.PublicKeyInstance """ return self._proxy.update(friendly_name=friendly_name,) def delete(self): """ Deletes the PublicKeyInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/000077500000000000000000000000001317472742600174275ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/api/__init__.py000066400000000000000000000125611317472742600215450ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.domain import Domain from twilio.rest.api.v2010 import V2010 class Api(Domain): def __init__(self, twilio): """ Initialize the Api Domain :returns: Domain for Api :rtype: twilio.rest.api.Api """ super(Api, self).__init__(twilio) self.base_url = 'https://api.twilio.com' # Versions self._v2010 = None @property def v2010(self): """ :returns: Version v2010 of api :rtype: twilio.rest.api.v2010.V2010 """ if self._v2010 is None: self._v2010 = V2010(self) return self._v2010 @property def account(self): """ :returns: Account provided as the authenticating account :rtype: twilio.rest.api.v2010.account.AccountContext """ return self.v2010.account @property def accounts(self): """ :rtype: twilio.rest.api.v2010.account.AccountList """ return self.v2010.accounts @property def addresses(self): """ :rtype: twilio.rest.api.v2010.account.address.AddressList """ return self.account.addresses @property def applications(self): """ :rtype: twilio.rest.api.v2010.account.application.ApplicationList """ return self.account.applications @property def authorized_connect_apps(self): """ :rtype: twilio.rest.api.v2010.account.authorized_connect_app.AuthorizedConnectAppList """ return self.account.authorized_connect_apps @property def available_phone_numbers(self): """ :rtype: twilio.rest.api.v2010.account.available_phone_number.AvailablePhoneNumberCountryList """ return self.account.available_phone_numbers @property def calls(self): """ :rtype: twilio.rest.api.v2010.account.call.CallList """ return self.account.calls @property def conferences(self): """ :rtype: twilio.rest.api.v2010.account.conference.ConferenceList """ return self.account.conferences @property def connect_apps(self): """ :rtype: twilio.rest.api.v2010.account.connect_app.ConnectAppList """ return self.account.connect_apps @property def incoming_phone_numbers(self): """ :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberList """ return self.account.incoming_phone_numbers @property def keys(self): """ :rtype: twilio.rest.api.v2010.account.key.KeyList """ return self.account.keys @property def messages(self): """ :rtype: twilio.rest.api.v2010.account.message.MessageList """ return self.account.messages @property def new_keys(self): """ :rtype: twilio.rest.api.v2010.account.new_key.NewKeyList """ return self.account.new_keys @property def new_signing_keys(self): """ :rtype: twilio.rest.api.v2010.account.new_signing_key.NewSigningKeyList """ return self.account.new_signing_keys @property def notifications(self): """ :rtype: twilio.rest.api.v2010.account.notification.NotificationList """ return self.account.notifications @property def outgoing_caller_ids(self): """ :rtype: twilio.rest.api.v2010.account.outgoing_caller_id.OutgoingCallerIdList """ return self.account.outgoing_caller_ids @property def queues(self): """ :rtype: twilio.rest.api.v2010.account.queue.QueueList """ return self.account.queues @property def recordings(self): """ :rtype: twilio.rest.api.v2010.account.recording.RecordingList """ return self.account.recordings @property def signing_keys(self): """ :rtype: twilio.rest.api.v2010.account.signing_key.SigningKeyList """ return self.account.signing_keys @property def sip(self): """ :rtype: twilio.rest.api.v2010.account.sip.SipList """ return self.account.sip @property def short_codes(self): """ :rtype: twilio.rest.api.v2010.account.short_code.ShortCodeList """ return self.account.short_codes @property def tokens(self): """ :rtype: twilio.rest.api.v2010.account.token.TokenList """ return self.account.tokens @property def transcriptions(self): """ :rtype: twilio.rest.api.v2010.account.transcription.TranscriptionList """ return self.account.transcriptions @property def usage(self): """ :rtype: twilio.rest.api.v2010.account.usage.UsageList """ return self.account.usage @property def validation_requests(self): """ :rtype: twilio.rest.api.v2010.account.validation_request.ValidationRequestList """ return self.account.validation_requests def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/api/v2010/000077500000000000000000000000001317472742600201775ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/api/v2010/__init__.py000066400000000000000000000131761317472742600223200ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.version import Version from twilio.rest.api.v2010.account import AccountContext from twilio.rest.api.v2010.account import AccountList class V2010(Version): def __init__(self, domain): """ Initialize the V2010 version of Api :returns: V2010 version of Api :rtype: twilio.rest.api.v2010.V2010.V2010 """ super(V2010, self).__init__(domain) self.version = '2010-04-01' self._accounts = None self._account = None @property def accounts(self): """ :rtype: twilio.rest.api.v2010.account.AccountList """ if self._accounts is None: self._accounts = AccountList(self) return self._accounts @property def account(self): """ :returns: Account provided as the authenticating account :rtype: AccountContext """ if self._account is None: self._account = AccountContext(self, self.domain.twilio.account_sid) return self._account @account.setter def account(self, value): """ Setter to override the primary account :param AccountContext|AccountInstance value: account to use as primary account """ self._account = value @property def addresses(self): """ :rtype: twilio.rest.api.v2010.account.address.AddressList """ return self.account.addresses @property def applications(self): """ :rtype: twilio.rest.api.v2010.account.application.ApplicationList """ return self.account.applications @property def authorized_connect_apps(self): """ :rtype: twilio.rest.api.v2010.account.authorized_connect_app.AuthorizedConnectAppList """ return self.account.authorized_connect_apps @property def available_phone_numbers(self): """ :rtype: twilio.rest.api.v2010.account.available_phone_number.AvailablePhoneNumberCountryList """ return self.account.available_phone_numbers @property def calls(self): """ :rtype: twilio.rest.api.v2010.account.call.CallList """ return self.account.calls @property def conferences(self): """ :rtype: twilio.rest.api.v2010.account.conference.ConferenceList """ return self.account.conferences @property def connect_apps(self): """ :rtype: twilio.rest.api.v2010.account.connect_app.ConnectAppList """ return self.account.connect_apps @property def incoming_phone_numbers(self): """ :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberList """ return self.account.incoming_phone_numbers @property def keys(self): """ :rtype: twilio.rest.api.v2010.account.key.KeyList """ return self.account.keys @property def messages(self): """ :rtype: twilio.rest.api.v2010.account.message.MessageList """ return self.account.messages @property def new_keys(self): """ :rtype: twilio.rest.api.v2010.account.new_key.NewKeyList """ return self.account.new_keys @property def new_signing_keys(self): """ :rtype: twilio.rest.api.v2010.account.new_signing_key.NewSigningKeyList """ return self.account.new_signing_keys @property def notifications(self): """ :rtype: twilio.rest.api.v2010.account.notification.NotificationList """ return self.account.notifications @property def outgoing_caller_ids(self): """ :rtype: twilio.rest.api.v2010.account.outgoing_caller_id.OutgoingCallerIdList """ return self.account.outgoing_caller_ids @property def queues(self): """ :rtype: twilio.rest.api.v2010.account.queue.QueueList """ return self.account.queues @property def recordings(self): """ :rtype: twilio.rest.api.v2010.account.recording.RecordingList """ return self.account.recordings @property def signing_keys(self): """ :rtype: twilio.rest.api.v2010.account.signing_key.SigningKeyList """ return self.account.signing_keys @property def sip(self): """ :rtype: twilio.rest.api.v2010.account.sip.SipList """ return self.account.sip @property def short_codes(self): """ :rtype: twilio.rest.api.v2010.account.short_code.ShortCodeList """ return self.account.short_codes @property def tokens(self): """ :rtype: twilio.rest.api.v2010.account.token.TokenList """ return self.account.tokens @property def transcriptions(self): """ :rtype: twilio.rest.api.v2010.account.transcription.TranscriptionList """ return self.account.transcriptions @property def usage(self): """ :rtype: twilio.rest.api.v2010.account.usage.UsageList """ return self.account.usage @property def validation_requests(self): """ :rtype: twilio.rest.api.v2010.account.validation_request.ValidationRequestList """ return self.account.validation_requests def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/api/v2010/account/000077500000000000000000000000001317472742600216335ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/api/v2010/account/__init__.py000066400000000000000000001007331317472742600237500ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.api.v2010.account.address import AddressList from twilio.rest.api.v2010.account.application import ApplicationList from twilio.rest.api.v2010.account.authorized_connect_app import AuthorizedConnectAppList from twilio.rest.api.v2010.account.available_phone_number import AvailablePhoneNumberCountryList from twilio.rest.api.v2010.account.call import CallList from twilio.rest.api.v2010.account.conference import ConferenceList from twilio.rest.api.v2010.account.connect_app import ConnectAppList from twilio.rest.api.v2010.account.incoming_phone_number import IncomingPhoneNumberList from twilio.rest.api.v2010.account.key import KeyList from twilio.rest.api.v2010.account.message import MessageList from twilio.rest.api.v2010.account.new_key import NewKeyList from twilio.rest.api.v2010.account.new_signing_key import NewSigningKeyList from twilio.rest.api.v2010.account.notification import NotificationList from twilio.rest.api.v2010.account.outgoing_caller_id import OutgoingCallerIdList from twilio.rest.api.v2010.account.queue import QueueList from twilio.rest.api.v2010.account.recording import RecordingList from twilio.rest.api.v2010.account.short_code import ShortCodeList from twilio.rest.api.v2010.account.signing_key import SigningKeyList from twilio.rest.api.v2010.account.sip import SipList from twilio.rest.api.v2010.account.token import TokenList from twilio.rest.api.v2010.account.transcription import TranscriptionList from twilio.rest.api.v2010.account.usage import UsageList from twilio.rest.api.v2010.account.validation_request import ValidationRequestList class AccountList(ListResource): """ """ def __init__(self, version): """ Initialize the AccountList :param Version version: Version that contains the resource :returns: twilio.rest.api.v2010.account.AccountList :rtype: twilio.rest.api.v2010.account.AccountList """ super(AccountList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/Accounts.json'.format(**self._solution) def create(self, friendly_name=values.unset): """ Create a new AccountInstance :param unicode friendly_name: A human readable description of the account :returns: Newly created AccountInstance :rtype: twilio.rest.api.v2010.account.AccountInstance """ data = values.of({'FriendlyName': friendly_name,}) payload = self._version.create( 'POST', self._uri, data=data, ) return AccountInstance(self._version, payload,) def stream(self, friendly_name=values.unset, status=values.unset, limit=None, page_size=None): """ 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 unicode friendly_name: FriendlyName to filter on :param AccountInstance.Status status: Status to filter on :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.AccountInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(friendly_name=friendly_name, status=status, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, friendly_name=values.unset, status=values.unset, limit=None, page_size=None): """ 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 unicode friendly_name: FriendlyName to filter on :param AccountInstance.Status status: Status to filter on :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.AccountInstance] """ return list(self.stream(friendly_name=friendly_name, status=status, limit=limit, page_size=page_size,)) def page(self, friendly_name=values.unset, status=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of AccountInstance records from the API. Request is executed immediately :param unicode friendly_name: FriendlyName to filter on :param AccountInstance.Status status: Status to filter on :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of AccountInstance :rtype: twilio.rest.api.v2010.account.AccountPage """ params = values.of({ 'FriendlyName': friendly_name, 'Status': status, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return AccountPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of AccountInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of AccountInstance :rtype: twilio.rest.api.v2010.account.AccountPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return AccountPage(self._version, response, self._solution) def get(self, sid): """ Constructs a AccountContext :param sid: Fetch by unique Account Sid :returns: twilio.rest.api.v2010.account.AccountContext :rtype: twilio.rest.api.v2010.account.AccountContext """ return AccountContext(self._version, sid=sid,) def __call__(self, sid): """ Constructs a AccountContext :param sid: Fetch by unique Account Sid :returns: twilio.rest.api.v2010.account.AccountContext :rtype: twilio.rest.api.v2010.account.AccountContext """ return AccountContext(self._version, sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class AccountPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the AccountPage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.api.v2010.account.AccountPage :rtype: twilio.rest.api.v2010.account.AccountPage """ super(AccountPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of AccountInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.AccountInstance :rtype: twilio.rest.api.v2010.account.AccountInstance """ return AccountInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class AccountContext(InstanceContext): """ """ def __init__(self, version, sid): """ Initialize the AccountContext :param Version version: Version that contains the resource :param sid: Fetch by unique Account Sid :returns: twilio.rest.api.v2010.account.AccountContext :rtype: twilio.rest.api.v2010.account.AccountContext """ super(AccountContext, self).__init__(version) # Path Solution self._solution = {'sid': sid,} self._uri = '/Accounts/{sid}.json'.format(**self._solution) # Dependents self._addresses = None self._applications = None self._authorized_connect_apps = None self._available_phone_numbers = None self._calls = None self._conferences = None self._connect_apps = None self._incoming_phone_numbers = None self._keys = None self._messages = None self._new_keys = None self._new_signing_keys = None self._notifications = None self._outgoing_caller_ids = None self._queues = None self._recordings = None self._signing_keys = None self._sip = None self._short_codes = None self._tokens = None self._transcriptions = None self._usage = None self._validation_requests = None def fetch(self): """ Fetch a AccountInstance :returns: Fetched AccountInstance :rtype: twilio.rest.api.v2010.account.AccountInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return AccountInstance(self._version, payload, sid=self._solution['sid'],) def update(self, friendly_name=values.unset, status=values.unset): """ Update the AccountInstance :param unicode friendly_name: FriendlyName to update :param AccountInstance.Status status: Status to update the Account with :returns: Updated AccountInstance :rtype: twilio.rest.api.v2010.account.AccountInstance """ data = values.of({'FriendlyName': friendly_name, 'Status': status,}) payload = self._version.update( 'POST', self._uri, data=data, ) return AccountInstance(self._version, payload, sid=self._solution['sid'],) @property def addresses(self): """ Access the addresses :returns: twilio.rest.api.v2010.account.address.AddressList :rtype: twilio.rest.api.v2010.account.address.AddressList """ if self._addresses is None: self._addresses = AddressList(self._version, account_sid=self._solution['sid'],) return self._addresses @property def applications(self): """ Access the applications :returns: twilio.rest.api.v2010.account.application.ApplicationList :rtype: twilio.rest.api.v2010.account.application.ApplicationList """ if self._applications is None: self._applications = ApplicationList(self._version, account_sid=self._solution['sid'],) return self._applications @property def authorized_connect_apps(self): """ Access the authorized_connect_apps :returns: twilio.rest.api.v2010.account.authorized_connect_app.AuthorizedConnectAppList :rtype: twilio.rest.api.v2010.account.authorized_connect_app.AuthorizedConnectAppList """ if self._authorized_connect_apps is None: self._authorized_connect_apps = AuthorizedConnectAppList( self._version, account_sid=self._solution['sid'], ) return self._authorized_connect_apps @property def available_phone_numbers(self): """ Access the available_phone_numbers :returns: twilio.rest.api.v2010.account.available_phone_number.AvailablePhoneNumberCountryList :rtype: twilio.rest.api.v2010.account.available_phone_number.AvailablePhoneNumberCountryList """ if self._available_phone_numbers is None: self._available_phone_numbers = AvailablePhoneNumberCountryList( self._version, account_sid=self._solution['sid'], ) return self._available_phone_numbers @property def calls(self): """ Access the calls :returns: twilio.rest.api.v2010.account.call.CallList :rtype: twilio.rest.api.v2010.account.call.CallList """ if self._calls is None: self._calls = CallList(self._version, account_sid=self._solution['sid'],) return self._calls @property def conferences(self): """ Access the conferences :returns: twilio.rest.api.v2010.account.conference.ConferenceList :rtype: twilio.rest.api.v2010.account.conference.ConferenceList """ if self._conferences is None: self._conferences = ConferenceList(self._version, account_sid=self._solution['sid'],) return self._conferences @property def connect_apps(self): """ Access the connect_apps :returns: twilio.rest.api.v2010.account.connect_app.ConnectAppList :rtype: twilio.rest.api.v2010.account.connect_app.ConnectAppList """ if self._connect_apps is None: self._connect_apps = ConnectAppList(self._version, account_sid=self._solution['sid'],) return self._connect_apps @property def incoming_phone_numbers(self): """ Access the incoming_phone_numbers :returns: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberList :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberList """ if self._incoming_phone_numbers is None: self._incoming_phone_numbers = IncomingPhoneNumberList( self._version, account_sid=self._solution['sid'], ) return self._incoming_phone_numbers @property def keys(self): """ Access the keys :returns: twilio.rest.api.v2010.account.key.KeyList :rtype: twilio.rest.api.v2010.account.key.KeyList """ if self._keys is None: self._keys = KeyList(self._version, account_sid=self._solution['sid'],) return self._keys @property def messages(self): """ Access the messages :returns: twilio.rest.api.v2010.account.message.MessageList :rtype: twilio.rest.api.v2010.account.message.MessageList """ if self._messages is None: self._messages = MessageList(self._version, account_sid=self._solution['sid'],) return self._messages @property def new_keys(self): """ Access the new_keys :returns: twilio.rest.api.v2010.account.new_key.NewKeyList :rtype: twilio.rest.api.v2010.account.new_key.NewKeyList """ if self._new_keys is None: self._new_keys = NewKeyList(self._version, account_sid=self._solution['sid'],) return self._new_keys @property def new_signing_keys(self): """ Access the new_signing_keys :returns: twilio.rest.api.v2010.account.new_signing_key.NewSigningKeyList :rtype: twilio.rest.api.v2010.account.new_signing_key.NewSigningKeyList """ if self._new_signing_keys is None: self._new_signing_keys = NewSigningKeyList(self._version, account_sid=self._solution['sid'],) return self._new_signing_keys @property def notifications(self): """ Access the notifications :returns: twilio.rest.api.v2010.account.notification.NotificationList :rtype: twilio.rest.api.v2010.account.notification.NotificationList """ if self._notifications is None: self._notifications = NotificationList(self._version, account_sid=self._solution['sid'],) return self._notifications @property def outgoing_caller_ids(self): """ Access the outgoing_caller_ids :returns: twilio.rest.api.v2010.account.outgoing_caller_id.OutgoingCallerIdList :rtype: twilio.rest.api.v2010.account.outgoing_caller_id.OutgoingCallerIdList """ if self._outgoing_caller_ids is None: self._outgoing_caller_ids = OutgoingCallerIdList(self._version, account_sid=self._solution['sid'],) return self._outgoing_caller_ids @property def queues(self): """ Access the queues :returns: twilio.rest.api.v2010.account.queue.QueueList :rtype: twilio.rest.api.v2010.account.queue.QueueList """ if self._queues is None: self._queues = QueueList(self._version, account_sid=self._solution['sid'],) return self._queues @property def recordings(self): """ Access the recordings :returns: twilio.rest.api.v2010.account.recording.RecordingList :rtype: twilio.rest.api.v2010.account.recording.RecordingList """ if self._recordings is None: self._recordings = RecordingList(self._version, account_sid=self._solution['sid'],) return self._recordings @property def signing_keys(self): """ Access the signing_keys :returns: twilio.rest.api.v2010.account.signing_key.SigningKeyList :rtype: twilio.rest.api.v2010.account.signing_key.SigningKeyList """ if self._signing_keys is None: self._signing_keys = SigningKeyList(self._version, account_sid=self._solution['sid'],) return self._signing_keys @property def sip(self): """ Access the sip :returns: twilio.rest.api.v2010.account.sip.SipList :rtype: twilio.rest.api.v2010.account.sip.SipList """ if self._sip is None: self._sip = SipList(self._version, account_sid=self._solution['sid'],) return self._sip @property def short_codes(self): """ Access the short_codes :returns: twilio.rest.api.v2010.account.short_code.ShortCodeList :rtype: twilio.rest.api.v2010.account.short_code.ShortCodeList """ if self._short_codes is None: self._short_codes = ShortCodeList(self._version, account_sid=self._solution['sid'],) return self._short_codes @property def tokens(self): """ Access the tokens :returns: twilio.rest.api.v2010.account.token.TokenList :rtype: twilio.rest.api.v2010.account.token.TokenList """ if self._tokens is None: self._tokens = TokenList(self._version, account_sid=self._solution['sid'],) return self._tokens @property def transcriptions(self): """ Access the transcriptions :returns: twilio.rest.api.v2010.account.transcription.TranscriptionList :rtype: twilio.rest.api.v2010.account.transcription.TranscriptionList """ if self._transcriptions is None: self._transcriptions = TranscriptionList(self._version, account_sid=self._solution['sid'],) return self._transcriptions @property def usage(self): """ Access the usage :returns: twilio.rest.api.v2010.account.usage.UsageList :rtype: twilio.rest.api.v2010.account.usage.UsageList """ if self._usage is None: self._usage = UsageList(self._version, account_sid=self._solution['sid'],) return self._usage @property def validation_requests(self): """ Access the validation_requests :returns: twilio.rest.api.v2010.account.validation_request.ValidationRequestList :rtype: twilio.rest.api.v2010.account.validation_request.ValidationRequestList """ if self._validation_requests is None: self._validation_requests = ValidationRequestList(self._version, account_sid=self._solution['sid'],) return self._validation_requests def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class AccountInstance(InstanceResource): """ """ class Status(object): ACTIVE = "active" SUSPENDED = "suspended" CLOSED = "closed" class Type(object): TRIAL = "Trial" FULL = "Full" def __init__(self, version, payload, sid=None): """ Initialize the AccountInstance :returns: twilio.rest.api.v2010.account.AccountInstance :rtype: twilio.rest.api.v2010.account.AccountInstance """ super(AccountInstance, self).__init__(version) # Marshaled Properties self._properties = { 'auth_token': payload['auth_token'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'friendly_name': payload['friendly_name'], 'owner_account_sid': payload['owner_account_sid'], 'sid': payload['sid'], 'status': payload['status'], 'subresource_uris': payload['subresource_uris'], 'type': payload['type'], 'uri': payload['uri'], } # Context self._context = None self._solution = {'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.api.v2010.account.AccountContext """ if self._context is None: self._context = AccountContext(self._version, sid=self._solution['sid'],) return self._context @property def auth_token(self): """ :returns: The authorization token for this account :rtype: unicode """ return self._properties['auth_token'] @property def date_created(self): """ :returns: The date this account was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this account was last updated :rtype: datetime """ return self._properties['date_updated'] @property def friendly_name(self): """ :returns: A human readable description of this account :rtype: unicode """ return self._properties['friendly_name'] @property def owner_account_sid(self): """ :returns: The unique 34 character id representing the parent of this account :rtype: unicode """ return self._properties['owner_account_sid'] @property def sid(self): """ :returns: A 34 character string that uniquely identifies this resource. :rtype: unicode """ return self._properties['sid'] @property def status(self): """ :returns: The status of this account :rtype: AccountInstance.Status """ return self._properties['status'] @property def subresource_uris(self): """ :returns: Account Instance Subresources :rtype: unicode """ return self._properties['subresource_uris'] @property def type(self): """ :returns: The type of this account :rtype: AccountInstance.Type """ return self._properties['type'] @property def uri(self): """ :returns: The URI for this resource, relative to `https://api.twilio.com` :rtype: unicode """ return self._properties['uri'] def fetch(self): """ Fetch a AccountInstance :returns: Fetched AccountInstance :rtype: twilio.rest.api.v2010.account.AccountInstance """ return self._proxy.fetch() def update(self, friendly_name=values.unset, status=values.unset): """ Update the AccountInstance :param unicode friendly_name: FriendlyName to update :param AccountInstance.Status status: Status to update the Account with :returns: Updated AccountInstance :rtype: twilio.rest.api.v2010.account.AccountInstance """ return self._proxy.update(friendly_name=friendly_name, status=status,) @property def addresses(self): """ Access the addresses :returns: twilio.rest.api.v2010.account.address.AddressList :rtype: twilio.rest.api.v2010.account.address.AddressList """ return self._proxy.addresses @property def applications(self): """ Access the applications :returns: twilio.rest.api.v2010.account.application.ApplicationList :rtype: twilio.rest.api.v2010.account.application.ApplicationList """ return self._proxy.applications @property def authorized_connect_apps(self): """ Access the authorized_connect_apps :returns: twilio.rest.api.v2010.account.authorized_connect_app.AuthorizedConnectAppList :rtype: twilio.rest.api.v2010.account.authorized_connect_app.AuthorizedConnectAppList """ return self._proxy.authorized_connect_apps @property def available_phone_numbers(self): """ Access the available_phone_numbers :returns: twilio.rest.api.v2010.account.available_phone_number.AvailablePhoneNumberCountryList :rtype: twilio.rest.api.v2010.account.available_phone_number.AvailablePhoneNumberCountryList """ return self._proxy.available_phone_numbers @property def calls(self): """ Access the calls :returns: twilio.rest.api.v2010.account.call.CallList :rtype: twilio.rest.api.v2010.account.call.CallList """ return self._proxy.calls @property def conferences(self): """ Access the conferences :returns: twilio.rest.api.v2010.account.conference.ConferenceList :rtype: twilio.rest.api.v2010.account.conference.ConferenceList """ return self._proxy.conferences @property def connect_apps(self): """ Access the connect_apps :returns: twilio.rest.api.v2010.account.connect_app.ConnectAppList :rtype: twilio.rest.api.v2010.account.connect_app.ConnectAppList """ return self._proxy.connect_apps @property def incoming_phone_numbers(self): """ Access the incoming_phone_numbers :returns: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberList :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberList """ return self._proxy.incoming_phone_numbers @property def keys(self): """ Access the keys :returns: twilio.rest.api.v2010.account.key.KeyList :rtype: twilio.rest.api.v2010.account.key.KeyList """ return self._proxy.keys @property def messages(self): """ Access the messages :returns: twilio.rest.api.v2010.account.message.MessageList :rtype: twilio.rest.api.v2010.account.message.MessageList """ return self._proxy.messages @property def new_keys(self): """ Access the new_keys :returns: twilio.rest.api.v2010.account.new_key.NewKeyList :rtype: twilio.rest.api.v2010.account.new_key.NewKeyList """ return self._proxy.new_keys @property def new_signing_keys(self): """ Access the new_signing_keys :returns: twilio.rest.api.v2010.account.new_signing_key.NewSigningKeyList :rtype: twilio.rest.api.v2010.account.new_signing_key.NewSigningKeyList """ return self._proxy.new_signing_keys @property def notifications(self): """ Access the notifications :returns: twilio.rest.api.v2010.account.notification.NotificationList :rtype: twilio.rest.api.v2010.account.notification.NotificationList """ return self._proxy.notifications @property def outgoing_caller_ids(self): """ Access the outgoing_caller_ids :returns: twilio.rest.api.v2010.account.outgoing_caller_id.OutgoingCallerIdList :rtype: twilio.rest.api.v2010.account.outgoing_caller_id.OutgoingCallerIdList """ return self._proxy.outgoing_caller_ids @property def queues(self): """ Access the queues :returns: twilio.rest.api.v2010.account.queue.QueueList :rtype: twilio.rest.api.v2010.account.queue.QueueList """ return self._proxy.queues @property def recordings(self): """ Access the recordings :returns: twilio.rest.api.v2010.account.recording.RecordingList :rtype: twilio.rest.api.v2010.account.recording.RecordingList """ return self._proxy.recordings @property def signing_keys(self): """ Access the signing_keys :returns: twilio.rest.api.v2010.account.signing_key.SigningKeyList :rtype: twilio.rest.api.v2010.account.signing_key.SigningKeyList """ return self._proxy.signing_keys @property def sip(self): """ Access the sip :returns: twilio.rest.api.v2010.account.sip.SipList :rtype: twilio.rest.api.v2010.account.sip.SipList """ return self._proxy.sip @property def short_codes(self): """ Access the short_codes :returns: twilio.rest.api.v2010.account.short_code.ShortCodeList :rtype: twilio.rest.api.v2010.account.short_code.ShortCodeList """ return self._proxy.short_codes @property def tokens(self): """ Access the tokens :returns: twilio.rest.api.v2010.account.token.TokenList :rtype: twilio.rest.api.v2010.account.token.TokenList """ return self._proxy.tokens @property def transcriptions(self): """ Access the transcriptions :returns: twilio.rest.api.v2010.account.transcription.TranscriptionList :rtype: twilio.rest.api.v2010.account.transcription.TranscriptionList """ return self._proxy.transcriptions @property def usage(self): """ Access the usage :returns: twilio.rest.api.v2010.account.usage.UsageList :rtype: twilio.rest.api.v2010.account.usage.UsageList """ return self._proxy.usage @property def validation_requests(self): """ Access the validation_requests :returns: twilio.rest.api.v2010.account.validation_request.ValidationRequestList :rtype: twilio.rest.api.v2010.account.validation_request.ValidationRequestList """ return self._proxy.validation_requests def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/address/000077500000000000000000000000001317472742600232605ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/api/v2010/account/address/__init__.py000066400000000000000000000472501317472742600254010ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.api.v2010.account.address.dependent_phone_number import DependentPhoneNumberList class AddressList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the AddressList :param Version version: Version that contains the resource :param account_sid: The account_sid :returns: twilio.rest.api.v2010.account.address.AddressList :rtype: twilio.rest.api.v2010.account.address.AddressList """ super(AddressList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/Addresses.json'.format(**self._solution) def create(self, customer_name, street, city, region, postal_code, iso_country, friendly_name=values.unset, emergency_enabled=values.unset, auto_correct_address=values.unset): """ Create a new AddressInstance :param unicode customer_name: The customer_name :param unicode street: The street :param unicode city: The city :param unicode region: The region :param unicode postal_code: The postal_code :param unicode iso_country: The iso_country :param unicode friendly_name: The friendly_name :param bool emergency_enabled: The emergency_enabled :param bool auto_correct_address: The auto_correct_address :returns: Newly created AddressInstance :rtype: twilio.rest.api.v2010.account.address.AddressInstance """ data = values.of({ 'CustomerName': customer_name, 'Street': street, 'City': city, 'Region': region, 'PostalCode': postal_code, 'IsoCountry': iso_country, 'FriendlyName': friendly_name, 'EmergencyEnabled': emergency_enabled, 'AutoCorrectAddress': auto_correct_address, }) payload = self._version.create( 'POST', self._uri, data=data, ) return AddressInstance(self._version, payload, account_sid=self._solution['account_sid'],) def stream(self, customer_name=values.unset, friendly_name=values.unset, iso_country=values.unset, limit=None, page_size=None): """ Streams AddressInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param unicode customer_name: The customer_name :param unicode friendly_name: The friendly_name :param unicode iso_country: The iso_country :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.address.AddressInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( customer_name=customer_name, friendly_name=friendly_name, iso_country=iso_country, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, customer_name=values.unset, friendly_name=values.unset, iso_country=values.unset, limit=None, page_size=None): """ Lists AddressInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param unicode customer_name: The customer_name :param unicode friendly_name: The friendly_name :param unicode iso_country: The iso_country :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.address.AddressInstance] """ return list(self.stream( customer_name=customer_name, friendly_name=friendly_name, iso_country=iso_country, limit=limit, page_size=page_size, )) def page(self, customer_name=values.unset, friendly_name=values.unset, iso_country=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of AddressInstance records from the API. Request is executed immediately :param unicode customer_name: The customer_name :param unicode friendly_name: The friendly_name :param unicode iso_country: The iso_country :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of AddressInstance :rtype: twilio.rest.api.v2010.account.address.AddressPage """ params = values.of({ 'CustomerName': customer_name, 'FriendlyName': friendly_name, 'IsoCountry': iso_country, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return AddressPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of AddressInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of AddressInstance :rtype: twilio.rest.api.v2010.account.address.AddressPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return AddressPage(self._version, response, self._solution) def get(self, sid): """ Constructs a AddressContext :param sid: The sid :returns: twilio.rest.api.v2010.account.address.AddressContext :rtype: twilio.rest.api.v2010.account.address.AddressContext """ return AddressContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __call__(self, sid): """ Constructs a AddressContext :param sid: The sid :returns: twilio.rest.api.v2010.account.address.AddressContext :rtype: twilio.rest.api.v2010.account.address.AddressContext """ return AddressContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class AddressPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the AddressPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :returns: twilio.rest.api.v2010.account.address.AddressPage :rtype: twilio.rest.api.v2010.account.address.AddressPage """ super(AddressPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of AddressInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.address.AddressInstance :rtype: twilio.rest.api.v2010.account.address.AddressInstance """ return AddressInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class AddressContext(InstanceContext): """ """ def __init__(self, version, account_sid, sid): """ Initialize the AddressContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param sid: The sid :returns: twilio.rest.api.v2010.account.address.AddressContext :rtype: twilio.rest.api.v2010.account.address.AddressContext """ super(AddressContext, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'sid': sid,} self._uri = '/Accounts/{account_sid}/Addresses/{sid}.json'.format(**self._solution) # Dependents self._dependent_phone_numbers = None def delete(self): """ Deletes the AddressInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def fetch(self): """ Fetch a AddressInstance :returns: Fetched AddressInstance :rtype: twilio.rest.api.v2010.account.address.AddressInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return AddressInstance( self._version, payload, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) def update(self, friendly_name=values.unset, customer_name=values.unset, street=values.unset, city=values.unset, region=values.unset, postal_code=values.unset, emergency_enabled=values.unset, auto_correct_address=values.unset): """ Update the AddressInstance :param unicode friendly_name: The friendly_name :param unicode customer_name: The customer_name :param unicode street: The street :param unicode city: The city :param unicode region: The region :param unicode postal_code: The postal_code :param bool emergency_enabled: The emergency_enabled :param bool auto_correct_address: The auto_correct_address :returns: Updated AddressInstance :rtype: twilio.rest.api.v2010.account.address.AddressInstance """ data = values.of({ 'FriendlyName': friendly_name, 'CustomerName': customer_name, 'Street': street, 'City': city, 'Region': region, 'PostalCode': postal_code, 'EmergencyEnabled': emergency_enabled, 'AutoCorrectAddress': auto_correct_address, }) payload = self._version.update( 'POST', self._uri, data=data, ) return AddressInstance( self._version, payload, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) @property def dependent_phone_numbers(self): """ Access the dependent_phone_numbers :returns: twilio.rest.api.v2010.account.address.dependent_phone_number.DependentPhoneNumberList :rtype: twilio.rest.api.v2010.account.address.dependent_phone_number.DependentPhoneNumberList """ if self._dependent_phone_numbers is None: self._dependent_phone_numbers = DependentPhoneNumberList( self._version, account_sid=self._solution['account_sid'], address_sid=self._solution['sid'], ) return self._dependent_phone_numbers def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class AddressInstance(InstanceResource): """ """ def __init__(self, version, payload, account_sid, sid=None): """ Initialize the AddressInstance :returns: twilio.rest.api.v2010.account.address.AddressInstance :rtype: twilio.rest.api.v2010.account.address.AddressInstance """ super(AddressInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'city': payload['city'], 'customer_name': payload['customer_name'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'friendly_name': payload['friendly_name'], 'iso_country': payload['iso_country'], 'postal_code': payload['postal_code'], 'region': payload['region'], 'sid': payload['sid'], 'street': payload['street'], 'uri': payload['uri'], 'emergency_enabled': payload['emergency_enabled'], 'validated': payload['validated'], } # Context self._context = None self._solution = {'account_sid': account_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: AddressContext for this AddressInstance :rtype: twilio.rest.api.v2010.account.address.AddressContext """ if self._context is None: self._context = AddressContext( self._version, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def city(self): """ :returns: The city :rtype: unicode """ return self._properties['city'] @property def customer_name(self): """ :returns: The customer_name :rtype: unicode """ return self._properties['customer_name'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def iso_country(self): """ :returns: The iso_country :rtype: unicode """ return self._properties['iso_country'] @property def postal_code(self): """ :returns: The postal_code :rtype: unicode """ return self._properties['postal_code'] @property def region(self): """ :returns: The region :rtype: unicode """ return self._properties['region'] @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def street(self): """ :returns: The street :rtype: unicode """ return self._properties['street'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] @property def emergency_enabled(self): """ :returns: The emergency_enabled :rtype: bool """ return self._properties['emergency_enabled'] @property def validated(self): """ :returns: The validated :rtype: bool """ return self._properties['validated'] def delete(self): """ Deletes the AddressInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def fetch(self): """ Fetch a AddressInstance :returns: Fetched AddressInstance :rtype: twilio.rest.api.v2010.account.address.AddressInstance """ return self._proxy.fetch() def update(self, friendly_name=values.unset, customer_name=values.unset, street=values.unset, city=values.unset, region=values.unset, postal_code=values.unset, emergency_enabled=values.unset, auto_correct_address=values.unset): """ Update the AddressInstance :param unicode friendly_name: The friendly_name :param unicode customer_name: The customer_name :param unicode street: The street :param unicode city: The city :param unicode region: The region :param unicode postal_code: The postal_code :param bool emergency_enabled: The emergency_enabled :param bool auto_correct_address: The auto_correct_address :returns: Updated AddressInstance :rtype: twilio.rest.api.v2010.account.address.AddressInstance """ return self._proxy.update( friendly_name=friendly_name, customer_name=customer_name, street=street, city=city, region=region, postal_code=postal_code, emergency_enabled=emergency_enabled, auto_correct_address=auto_correct_address, ) @property def dependent_phone_numbers(self): """ Access the dependent_phone_numbers :returns: twilio.rest.api.v2010.account.address.dependent_phone_number.DependentPhoneNumberList :rtype: twilio.rest.api.v2010.account.address.dependent_phone_number.DependentPhoneNumberList """ return self._proxy.dependent_phone_numbers def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/address/dependent_phone_number.py000066400000000000000000000237501317472742600303500ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class DependentPhoneNumberList(ListResource): """ """ def __init__(self, version, account_sid, address_sid): """ Initialize the DependentPhoneNumberList :param Version version: Version that contains the resource :param account_sid: The account_sid :param address_sid: The sid :returns: twilio.rest.api.v2010.account.address.dependent_phone_number.DependentPhoneNumberList :rtype: twilio.rest.api.v2010.account.address.dependent_phone_number.DependentPhoneNumberList """ super(DependentPhoneNumberList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'address_sid': address_sid,} self._uri = '/Accounts/{account_sid}/Addresses/{address_sid}/DependentPhoneNumbers.json'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams DependentPhoneNumberInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.address.dependent_phone_number.DependentPhoneNumberInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists DependentPhoneNumberInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.address.dependent_phone_number.DependentPhoneNumberInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of DependentPhoneNumberInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of DependentPhoneNumberInstance :rtype: twilio.rest.api.v2010.account.address.dependent_phone_number.DependentPhoneNumberPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return DependentPhoneNumberPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of DependentPhoneNumberInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of DependentPhoneNumberInstance :rtype: twilio.rest.api.v2010.account.address.dependent_phone_number.DependentPhoneNumberPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return DependentPhoneNumberPage(self._version, response, self._solution) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class DependentPhoneNumberPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the DependentPhoneNumberPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param address_sid: The sid :returns: twilio.rest.api.v2010.account.address.dependent_phone_number.DependentPhoneNumberPage :rtype: twilio.rest.api.v2010.account.address.dependent_phone_number.DependentPhoneNumberPage """ super(DependentPhoneNumberPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of DependentPhoneNumberInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.address.dependent_phone_number.DependentPhoneNumberInstance :rtype: twilio.rest.api.v2010.account.address.dependent_phone_number.DependentPhoneNumberInstance """ return DependentPhoneNumberInstance( self._version, payload, account_sid=self._solution['account_sid'], address_sid=self._solution['address_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class DependentPhoneNumberInstance(InstanceResource): """ """ def __init__(self, version, payload, account_sid, address_sid): """ Initialize the DependentPhoneNumberInstance :returns: twilio.rest.api.v2010.account.address.dependent_phone_number.DependentPhoneNumberInstance :rtype: twilio.rest.api.v2010.account.address.dependent_phone_number.DependentPhoneNumberInstance """ super(DependentPhoneNumberInstance, self).__init__(version) # Marshaled Properties self._properties = { 'friendly_name': payload['friendly_name'], 'phone_number': payload['phone_number'], 'lata': payload['lata'], 'rate_center': payload['rate_center'], 'latitude': deserialize.decimal(payload['latitude']), 'longitude': deserialize.decimal(payload['longitude']), 'region': payload['region'], 'postal_code': payload['postal_code'], 'iso_country': payload['iso_country'], 'address_requirements': payload['address_requirements'], 'capabilities': payload['capabilities'], } # Context self._context = None self._solution = {'account_sid': account_sid, 'address_sid': address_sid,} @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def phone_number(self): """ :returns: The phone_number :rtype: unicode """ return self._properties['phone_number'] @property def lata(self): """ :returns: The lata :rtype: unicode """ return self._properties['lata'] @property def rate_center(self): """ :returns: The rate_center :rtype: unicode """ return self._properties['rate_center'] @property def latitude(self): """ :returns: The latitude :rtype: unicode """ return self._properties['latitude'] @property def longitude(self): """ :returns: The longitude :rtype: unicode """ return self._properties['longitude'] @property def region(self): """ :returns: The region :rtype: unicode """ return self._properties['region'] @property def postal_code(self): """ :returns: The postal_code :rtype: unicode """ return self._properties['postal_code'] @property def iso_country(self): """ :returns: The iso_country :rtype: unicode """ return self._properties['iso_country'] @property def address_requirements(self): """ :returns: The address_requirements :rtype: unicode """ return self._properties['address_requirements'] @property def capabilities(self): """ :returns: The capabilities :rtype: unicode """ return self._properties['capabilities'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/api/v2010/account/application.py000066400000000000000000000607531317472742600245230ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class ApplicationList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the ApplicationList :param Version version: Version that contains the resource :param account_sid: A string that uniquely identifies this resource :returns: twilio.rest.api.v2010.account.application.ApplicationList :rtype: twilio.rest.api.v2010.account.application.ApplicationList """ super(ApplicationList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/Applications.json'.format(**self._solution) def create(self, friendly_name, api_version=values.unset, voice_url=values.unset, voice_method=values.unset, voice_fallback_url=values.unset, voice_fallback_method=values.unset, status_callback=values.unset, status_callback_method=values.unset, voice_caller_id_lookup=values.unset, sms_url=values.unset, sms_method=values.unset, sms_fallback_url=values.unset, sms_fallback_method=values.unset, sms_status_callback=values.unset, message_status_callback=values.unset): """ Create a new ApplicationInstance :param unicode friendly_name: The friendly_name :param unicode api_version: The API version to use :param unicode voice_url: URL Twilio will make requests to when relieving a call :param unicode voice_method: HTTP method to use with the URL :param unicode voice_fallback_url: Fallback URL :param unicode voice_fallback_method: HTTP method to use with the fallback url :param unicode status_callback: URL to hit with status updates :param unicode status_callback_method: HTTP method to use with the status callback :param bool voice_caller_id_lookup: True or False :param unicode sms_url: URL Twilio will request when receiving an SMS :param unicode sms_method: HTTP method to use with sms_url :param unicode sms_fallback_url: Fallback URL if there's an error parsing TwiML :param unicode sms_fallback_method: HTTP method to use with sms_fallback_method :param unicode sms_status_callback: URL Twilio with request with status updates :param unicode message_status_callback: URL to make requests to with status updates :returns: Newly created ApplicationInstance :rtype: twilio.rest.api.v2010.account.application.ApplicationInstance """ data = values.of({ 'FriendlyName': friendly_name, 'ApiVersion': api_version, 'VoiceUrl': voice_url, 'VoiceMethod': voice_method, 'VoiceFallbackUrl': voice_fallback_url, 'VoiceFallbackMethod': voice_fallback_method, 'StatusCallback': status_callback, 'StatusCallbackMethod': status_callback_method, 'VoiceCallerIdLookup': 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, }) payload = self._version.create( 'POST', self._uri, data=data, ) return ApplicationInstance(self._version, payload, account_sid=self._solution['account_sid'],) def stream(self, friendly_name=values.unset, limit=None, page_size=None): """ Streams ApplicationInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param unicode friendly_name: Filter by friendly name :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.application.ApplicationInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(friendly_name=friendly_name, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, friendly_name=values.unset, limit=None, page_size=None): """ Lists ApplicationInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param unicode friendly_name: Filter by friendly name :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.application.ApplicationInstance] """ return list(self.stream(friendly_name=friendly_name, limit=limit, page_size=page_size,)) def page(self, friendly_name=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of ApplicationInstance records from the API. Request is executed immediately :param unicode friendly_name: Filter by friendly name :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of ApplicationInstance :rtype: twilio.rest.api.v2010.account.application.ApplicationPage """ params = values.of({ 'FriendlyName': friendly_name, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return ApplicationPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of ApplicationInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of ApplicationInstance :rtype: twilio.rest.api.v2010.account.application.ApplicationPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return ApplicationPage(self._version, response, self._solution) def get(self, sid): """ Constructs a ApplicationContext :param sid: Fetch by unique Application Sid :returns: twilio.rest.api.v2010.account.application.ApplicationContext :rtype: twilio.rest.api.v2010.account.application.ApplicationContext """ return ApplicationContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __call__(self, sid): """ Constructs a ApplicationContext :param sid: Fetch by unique Application Sid :returns: twilio.rest.api.v2010.account.application.ApplicationContext :rtype: twilio.rest.api.v2010.account.application.ApplicationContext """ return ApplicationContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ApplicationPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the ApplicationPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: A string that uniquely identifies this resource :returns: twilio.rest.api.v2010.account.application.ApplicationPage :rtype: twilio.rest.api.v2010.account.application.ApplicationPage """ super(ApplicationPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of ApplicationInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.application.ApplicationInstance :rtype: twilio.rest.api.v2010.account.application.ApplicationInstance """ return ApplicationInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ApplicationContext(InstanceContext): """ """ def __init__(self, version, account_sid, sid): """ Initialize the ApplicationContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param sid: Fetch by unique Application Sid :returns: twilio.rest.api.v2010.account.application.ApplicationContext :rtype: twilio.rest.api.v2010.account.application.ApplicationContext """ super(ApplicationContext, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'sid': sid,} self._uri = '/Accounts/{account_sid}/Applications/{sid}.json'.format(**self._solution) def delete(self): """ Deletes the ApplicationInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def fetch(self): """ Fetch a ApplicationInstance :returns: Fetched ApplicationInstance :rtype: twilio.rest.api.v2010.account.application.ApplicationInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return ApplicationInstance( self._version, payload, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) def update(self, friendly_name=values.unset, api_version=values.unset, voice_url=values.unset, voice_method=values.unset, voice_fallback_url=values.unset, voice_fallback_method=values.unset, status_callback=values.unset, status_callback_method=values.unset, voice_caller_id_lookup=values.unset, sms_url=values.unset, sms_method=values.unset, sms_fallback_url=values.unset, sms_fallback_method=values.unset, sms_status_callback=values.unset, message_status_callback=values.unset): """ Update the ApplicationInstance :param unicode friendly_name: Human readable description of this resource :param unicode api_version: The API version to use :param unicode voice_url: URL Twilio will make requests to when relieving a call :param unicode voice_method: HTTP method to use with the URL :param unicode voice_fallback_url: Fallback URL :param unicode voice_fallback_method: HTTP method to use with the fallback url :param unicode status_callback: URL to hit with status updates :param unicode status_callback_method: HTTP method to use with the status callback :param bool voice_caller_id_lookup: True or False :param unicode sms_url: URL Twilio will request when receiving an SMS :param unicode sms_method: HTTP method to use with sms_url :param unicode sms_fallback_url: Fallback URL if there's an error parsing TwiML :param unicode sms_fallback_method: HTTP method to use with sms_fallback_method :param unicode sms_status_callback: URL Twilio with request with status updates :param unicode message_status_callback: URL to make requests to with status updates :returns: Updated ApplicationInstance :rtype: twilio.rest.api.v2010.account.application.ApplicationInstance """ data = values.of({ 'FriendlyName': friendly_name, 'ApiVersion': api_version, 'VoiceUrl': voice_url, 'VoiceMethod': voice_method, 'VoiceFallbackUrl': voice_fallback_url, 'VoiceFallbackMethod': voice_fallback_method, 'StatusCallback': status_callback, 'StatusCallbackMethod': status_callback_method, 'VoiceCallerIdLookup': 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, }) payload = self._version.update( 'POST', self._uri, data=data, ) return ApplicationInstance( self._version, payload, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class ApplicationInstance(InstanceResource): """ """ def __init__(self, version, payload, account_sid, sid=None): """ Initialize the ApplicationInstance :returns: twilio.rest.api.v2010.account.application.ApplicationInstance :rtype: twilio.rest.api.v2010.account.application.ApplicationInstance """ super(ApplicationInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'api_version': payload['api_version'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'friendly_name': payload['friendly_name'], 'message_status_callback': payload['message_status_callback'], 'sid': payload['sid'], 'sms_fallback_method': payload['sms_fallback_method'], 'sms_fallback_url': payload['sms_fallback_url'], 'sms_method': payload['sms_method'], 'sms_status_callback': payload['sms_status_callback'], 'sms_url': payload['sms_url'], 'status_callback': payload['status_callback'], 'status_callback_method': payload['status_callback_method'], 'uri': payload['uri'], 'voice_caller_id_lookup': payload['voice_caller_id_lookup'], 'voice_fallback_method': payload['voice_fallback_method'], 'voice_fallback_url': payload['voice_fallback_url'], 'voice_method': payload['voice_method'], 'voice_url': payload['voice_url'], } # Context self._context = None self._solution = {'account_sid': account_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: ApplicationContext for this ApplicationInstance :rtype: twilio.rest.api.v2010.account.application.ApplicationContext """ if self._context is None: self._context = ApplicationContext( self._version, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: A string that uniquely identifies this resource :rtype: unicode """ return self._properties['account_sid'] @property def api_version(self): """ :returns: The API version to use :rtype: unicode """ return self._properties['api_version'] @property def date_created(self): """ :returns: Date this resource was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: Date this resource was last updated :rtype: datetime """ return self._properties['date_updated'] @property def friendly_name(self): """ :returns: Human readable description of this resource :rtype: unicode """ return self._properties['friendly_name'] @property def message_status_callback(self): """ :returns: URL to make requests to with status updates :rtype: unicode """ return self._properties['message_status_callback'] @property def sid(self): """ :returns: A string that uniquely identifies this resource :rtype: unicode """ return self._properties['sid'] @property def sms_fallback_method(self): """ :returns: HTTP method to use with sms_fallback_method :rtype: unicode """ return self._properties['sms_fallback_method'] @property def sms_fallback_url(self): """ :returns: Fallback URL if there's an error parsing TwiML :rtype: unicode """ return self._properties['sms_fallback_url'] @property def sms_method(self): """ :returns: HTTP method to use with sms_url :rtype: unicode """ return self._properties['sms_method'] @property def sms_status_callback(self): """ :returns: URL Twilio with request with status updates :rtype: unicode """ return self._properties['sms_status_callback'] @property def sms_url(self): """ :returns: URL Twilio will request when receiving an SMS :rtype: unicode """ return self._properties['sms_url'] @property def status_callback(self): """ :returns: URL to hit with status updates :rtype: unicode """ return self._properties['status_callback'] @property def status_callback_method(self): """ :returns: HTTP method to use with the status callback :rtype: unicode """ return self._properties['status_callback_method'] @property def uri(self): """ :returns: URI for this resource :rtype: unicode """ return self._properties['uri'] @property def voice_caller_id_lookup(self): """ :returns: True or False :rtype: bool """ return self._properties['voice_caller_id_lookup'] @property def voice_fallback_method(self): """ :returns: HTTP method to use with the fallback url :rtype: unicode """ return self._properties['voice_fallback_method'] @property def voice_fallback_url(self): """ :returns: Fallback URL :rtype: unicode """ return self._properties['voice_fallback_url'] @property def voice_method(self): """ :returns: HTTP method to use with the URL :rtype: unicode """ return self._properties['voice_method'] @property def voice_url(self): """ :returns: URL Twilio will make requests to when relieving a call :rtype: unicode """ return self._properties['voice_url'] def delete(self): """ Deletes the ApplicationInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def fetch(self): """ Fetch a ApplicationInstance :returns: Fetched ApplicationInstance :rtype: twilio.rest.api.v2010.account.application.ApplicationInstance """ return self._proxy.fetch() def update(self, friendly_name=values.unset, api_version=values.unset, voice_url=values.unset, voice_method=values.unset, voice_fallback_url=values.unset, voice_fallback_method=values.unset, status_callback=values.unset, status_callback_method=values.unset, voice_caller_id_lookup=values.unset, sms_url=values.unset, sms_method=values.unset, sms_fallback_url=values.unset, sms_fallback_method=values.unset, sms_status_callback=values.unset, message_status_callback=values.unset): """ Update the ApplicationInstance :param unicode friendly_name: Human readable description of this resource :param unicode api_version: The API version to use :param unicode voice_url: URL Twilio will make requests to when relieving a call :param unicode voice_method: HTTP method to use with the URL :param unicode voice_fallback_url: Fallback URL :param unicode voice_fallback_method: HTTP method to use with the fallback url :param unicode status_callback: URL to hit with status updates :param unicode status_callback_method: HTTP method to use with the status callback :param bool voice_caller_id_lookup: True or False :param unicode sms_url: URL Twilio will request when receiving an SMS :param unicode sms_method: HTTP method to use with sms_url :param unicode sms_fallback_url: Fallback URL if there's an error parsing TwiML :param unicode sms_fallback_method: HTTP method to use with sms_fallback_method :param unicode sms_status_callback: URL Twilio with request with status updates :param unicode message_status_callback: URL to make requests to with status updates :returns: Updated ApplicationInstance :rtype: twilio.rest.api.v2010.account.application.ApplicationInstance """ return self._proxy.update( friendly_name=friendly_name, api_version=api_version, voice_url=voice_url, voice_method=voice_method, voice_fallback_url=voice_fallback_url, voice_fallback_method=voice_fallback_method, status_callback=status_callback, status_callback_method=status_callback_method, voice_caller_id_lookup=voice_caller_id_lookup, sms_url=sms_url, sms_method=sms_method, sms_fallback_url=sms_fallback_url, sms_fallback_method=sms_fallback_method, sms_status_callback=sms_status_callback, message_status_callback=message_status_callback, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/authorized_connect_app.py000066400000000000000000000341361317472742600267430ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class AuthorizedConnectAppList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the AuthorizedConnectAppList :param Version version: Version that contains the resource :param account_sid: The unique sid that identifies this account :returns: twilio.rest.api.v2010.account.authorized_connect_app.AuthorizedConnectAppList :rtype: twilio.rest.api.v2010.account.authorized_connect_app.AuthorizedConnectAppList """ super(AuthorizedConnectAppList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/AuthorizedConnectApps.json'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams AuthorizedConnectAppInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.authorized_connect_app.AuthorizedConnectAppInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists AuthorizedConnectAppInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.authorized_connect_app.AuthorizedConnectAppInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of AuthorizedConnectAppInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of AuthorizedConnectAppInstance :rtype: twilio.rest.api.v2010.account.authorized_connect_app.AuthorizedConnectAppPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return AuthorizedConnectAppPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of AuthorizedConnectAppInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of AuthorizedConnectAppInstance :rtype: twilio.rest.api.v2010.account.authorized_connect_app.AuthorizedConnectAppPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return AuthorizedConnectAppPage(self._version, response, self._solution) def get(self, connect_app_sid): """ Constructs a AuthorizedConnectAppContext :param connect_app_sid: The connect_app_sid :returns: twilio.rest.api.v2010.account.authorized_connect_app.AuthorizedConnectAppContext :rtype: twilio.rest.api.v2010.account.authorized_connect_app.AuthorizedConnectAppContext """ return AuthorizedConnectAppContext( self._version, account_sid=self._solution['account_sid'], connect_app_sid=connect_app_sid, ) def __call__(self, connect_app_sid): """ Constructs a AuthorizedConnectAppContext :param connect_app_sid: The connect_app_sid :returns: twilio.rest.api.v2010.account.authorized_connect_app.AuthorizedConnectAppContext :rtype: twilio.rest.api.v2010.account.authorized_connect_app.AuthorizedConnectAppContext """ return AuthorizedConnectAppContext( self._version, account_sid=self._solution['account_sid'], connect_app_sid=connect_app_sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class AuthorizedConnectAppPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the AuthorizedConnectAppPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The unique sid that identifies this account :returns: twilio.rest.api.v2010.account.authorized_connect_app.AuthorizedConnectAppPage :rtype: twilio.rest.api.v2010.account.authorized_connect_app.AuthorizedConnectAppPage """ super(AuthorizedConnectAppPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of AuthorizedConnectAppInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.authorized_connect_app.AuthorizedConnectAppInstance :rtype: twilio.rest.api.v2010.account.authorized_connect_app.AuthorizedConnectAppInstance """ return AuthorizedConnectAppInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class AuthorizedConnectAppContext(InstanceContext): """ """ def __init__(self, version, account_sid, connect_app_sid): """ Initialize the AuthorizedConnectAppContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param connect_app_sid: The connect_app_sid :returns: twilio.rest.api.v2010.account.authorized_connect_app.AuthorizedConnectAppContext :rtype: twilio.rest.api.v2010.account.authorized_connect_app.AuthorizedConnectAppContext """ super(AuthorizedConnectAppContext, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'connect_app_sid': connect_app_sid,} self._uri = '/Accounts/{account_sid}/AuthorizedConnectApps/{connect_app_sid}.json'.format(**self._solution) def fetch(self): """ Fetch a AuthorizedConnectAppInstance :returns: Fetched AuthorizedConnectAppInstance :rtype: twilio.rest.api.v2010.account.authorized_connect_app.AuthorizedConnectAppInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return AuthorizedConnectAppInstance( self._version, payload, account_sid=self._solution['account_sid'], connect_app_sid=self._solution['connect_app_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class AuthorizedConnectAppInstance(InstanceResource): """ """ class Permission(object): GET_ALL = "get-all" POST_ALL = "post-all" def __init__(self, version, payload, account_sid, connect_app_sid=None): """ Initialize the AuthorizedConnectAppInstance :returns: twilio.rest.api.v2010.account.authorized_connect_app.AuthorizedConnectAppInstance :rtype: twilio.rest.api.v2010.account.authorized_connect_app.AuthorizedConnectAppInstance """ super(AuthorizedConnectAppInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'connect_app_company_name': payload['connect_app_company_name'], 'connect_app_description': payload['connect_app_description'], 'connect_app_friendly_name': payload['connect_app_friendly_name'], 'connect_app_homepage_url': payload['connect_app_homepage_url'], 'connect_app_sid': payload['connect_app_sid'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'permissions': payload['permissions'], 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'connect_app_sid': connect_app_sid or self._properties['connect_app_sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: AuthorizedConnectAppContext for this AuthorizedConnectAppInstance :rtype: twilio.rest.api.v2010.account.authorized_connect_app.AuthorizedConnectAppContext """ if self._context is None: self._context = AuthorizedConnectAppContext( self._version, account_sid=self._solution['account_sid'], connect_app_sid=self._solution['connect_app_sid'], ) return self._context @property def account_sid(self): """ :returns: The unique sid that identifies this account :rtype: unicode """ return self._properties['account_sid'] @property def connect_app_company_name(self): """ :returns: The company name set for this Connect App. :rtype: unicode """ return self._properties['connect_app_company_name'] @property def connect_app_description(self): """ :returns: Human readable description of the app :rtype: unicode """ return self._properties['connect_app_description'] @property def connect_app_friendly_name(self): """ :returns: A human readable name for the Connect App. :rtype: unicode """ return self._properties['connect_app_friendly_name'] @property def connect_app_homepage_url(self): """ :returns: The public URL for this Connect App. :rtype: unicode """ return self._properties['connect_app_homepage_url'] @property def connect_app_sid(self): """ :returns: A string that uniquely identifies this app :rtype: unicode """ return self._properties['connect_app_sid'] @property def date_created(self): """ :returns: The date this resource was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this resource was last updated :rtype: datetime """ return self._properties['date_updated'] @property def permissions(self): """ :returns: Permissions authorized to this app :rtype: AuthorizedConnectAppInstance.Permission """ return self._properties['permissions'] @property def uri(self): """ :returns: The URI for this resource :rtype: unicode """ return self._properties['uri'] def fetch(self): """ Fetch a AuthorizedConnectAppInstance :returns: Fetched AuthorizedConnectAppInstance :rtype: twilio.rest.api.v2010.account.authorized_connect_app.AuthorizedConnectAppInstance """ return self._proxy.fetch() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/available_phone_number/000077500000000000000000000000001317472742600263145ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/api/v2010/account/available_phone_number/__init__.py000066400000000000000000000370771317472742600304430ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ 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.page import Page from twilio.rest.api.v2010.account.available_phone_number.local import LocalList from twilio.rest.api.v2010.account.available_phone_number.mobile import MobileList from twilio.rest.api.v2010.account.available_phone_number.toll_free import TollFreeList class AvailablePhoneNumberCountryList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the AvailablePhoneNumberCountryList :param Version version: Version that contains the resource :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.available_phone_number.AvailablePhoneNumberCountryList :rtype: twilio.rest.api.v2010.account.available_phone_number.AvailablePhoneNumberCountryList """ super(AvailablePhoneNumberCountryList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/AvailablePhoneNumbers.json'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams AvailablePhoneNumberCountryInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.available_phone_number.AvailablePhoneNumberCountryInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists AvailablePhoneNumberCountryInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.available_phone_number.AvailablePhoneNumberCountryInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of AvailablePhoneNumberCountryInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of AvailablePhoneNumberCountryInstance :rtype: twilio.rest.api.v2010.account.available_phone_number.AvailablePhoneNumberCountryPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return AvailablePhoneNumberCountryPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of AvailablePhoneNumberCountryInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of AvailablePhoneNumberCountryInstance :rtype: twilio.rest.api.v2010.account.available_phone_number.AvailablePhoneNumberCountryPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return AvailablePhoneNumberCountryPage(self._version, response, self._solution) def get(self, country_code): """ Constructs a AvailablePhoneNumberCountryContext :param country_code: The country_code :returns: twilio.rest.api.v2010.account.available_phone_number.AvailablePhoneNumberCountryContext :rtype: twilio.rest.api.v2010.account.available_phone_number.AvailablePhoneNumberCountryContext """ return AvailablePhoneNumberCountryContext( self._version, account_sid=self._solution['account_sid'], country_code=country_code, ) def __call__(self, country_code): """ Constructs a AvailablePhoneNumberCountryContext :param country_code: The country_code :returns: twilio.rest.api.v2010.account.available_phone_number.AvailablePhoneNumberCountryContext :rtype: twilio.rest.api.v2010.account.available_phone_number.AvailablePhoneNumberCountryContext """ return AvailablePhoneNumberCountryContext( self._version, account_sid=self._solution['account_sid'], country_code=country_code, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class AvailablePhoneNumberCountryPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the AvailablePhoneNumberCountryPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.available_phone_number.AvailablePhoneNumberCountryPage :rtype: twilio.rest.api.v2010.account.available_phone_number.AvailablePhoneNumberCountryPage """ super(AvailablePhoneNumberCountryPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of AvailablePhoneNumberCountryInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.available_phone_number.AvailablePhoneNumberCountryInstance :rtype: twilio.rest.api.v2010.account.available_phone_number.AvailablePhoneNumberCountryInstance """ return AvailablePhoneNumberCountryInstance( self._version, payload, account_sid=self._solution['account_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class AvailablePhoneNumberCountryContext(InstanceContext): """ """ def __init__(self, version, account_sid, country_code): """ Initialize the AvailablePhoneNumberCountryContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param country_code: The country_code :returns: twilio.rest.api.v2010.account.available_phone_number.AvailablePhoneNumberCountryContext :rtype: twilio.rest.api.v2010.account.available_phone_number.AvailablePhoneNumberCountryContext """ super(AvailablePhoneNumberCountryContext, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'country_code': country_code,} self._uri = '/Accounts/{account_sid}/AvailablePhoneNumbers/{country_code}.json'.format(**self._solution) # Dependents self._local = None self._toll_free = None self._mobile = None def fetch(self): """ Fetch a AvailablePhoneNumberCountryInstance :returns: Fetched AvailablePhoneNumberCountryInstance :rtype: twilio.rest.api.v2010.account.available_phone_number.AvailablePhoneNumberCountryInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return AvailablePhoneNumberCountryInstance( self._version, payload, account_sid=self._solution['account_sid'], country_code=self._solution['country_code'], ) @property def local(self): """ Access the local :returns: twilio.rest.api.v2010.account.available_phone_number.local.LocalList :rtype: twilio.rest.api.v2010.account.available_phone_number.local.LocalList """ if self._local is None: self._local = LocalList( self._version, account_sid=self._solution['account_sid'], country_code=self._solution['country_code'], ) return self._local @property def toll_free(self): """ Access the toll_free :returns: twilio.rest.api.v2010.account.available_phone_number.toll_free.TollFreeList :rtype: twilio.rest.api.v2010.account.available_phone_number.toll_free.TollFreeList """ if self._toll_free is None: self._toll_free = TollFreeList( self._version, account_sid=self._solution['account_sid'], country_code=self._solution['country_code'], ) return self._toll_free @property def mobile(self): """ Access the mobile :returns: twilio.rest.api.v2010.account.available_phone_number.mobile.MobileList :rtype: twilio.rest.api.v2010.account.available_phone_number.mobile.MobileList """ if self._mobile is None: self._mobile = MobileList( self._version, account_sid=self._solution['account_sid'], country_code=self._solution['country_code'], ) return self._mobile def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class AvailablePhoneNumberCountryInstance(InstanceResource): """ """ def __init__(self, version, payload, account_sid, country_code=None): """ Initialize the AvailablePhoneNumberCountryInstance :returns: twilio.rest.api.v2010.account.available_phone_number.AvailablePhoneNumberCountryInstance :rtype: twilio.rest.api.v2010.account.available_phone_number.AvailablePhoneNumberCountryInstance """ super(AvailablePhoneNumberCountryInstance, self).__init__(version) # Marshaled Properties self._properties = { 'country_code': payload['country_code'], 'country': payload['country'], 'uri': payload['uri'], 'beta': payload['beta'], 'subresource_uris': payload['subresource_uris'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'country_code': country_code or self._properties['country_code'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: AvailablePhoneNumberCountryContext for this AvailablePhoneNumberCountryInstance :rtype: twilio.rest.api.v2010.account.available_phone_number.AvailablePhoneNumberCountryContext """ if self._context is None: self._context = AvailablePhoneNumberCountryContext( self._version, account_sid=self._solution['account_sid'], country_code=self._solution['country_code'], ) return self._context @property def country_code(self): """ :returns: The ISO Country code to lookup phone numbers for. :rtype: unicode """ return self._properties['country_code'] @property def country(self): """ :returns: The country :rtype: unicode """ return self._properties['country'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] @property def beta(self): """ :returns: The beta :rtype: bool """ return self._properties['beta'] @property def subresource_uris(self): """ :returns: The subresource_uris :rtype: unicode """ return self._properties['subresource_uris'] def fetch(self): """ Fetch a AvailablePhoneNumberCountryInstance :returns: Fetched AvailablePhoneNumberCountryInstance :rtype: twilio.rest.api.v2010.account.available_phone_number.AvailablePhoneNumberCountryInstance """ return self._proxy.fetch() @property def local(self): """ Access the local :returns: twilio.rest.api.v2010.account.available_phone_number.local.LocalList :rtype: twilio.rest.api.v2010.account.available_phone_number.local.LocalList """ return self._proxy.local @property def toll_free(self): """ Access the toll_free :returns: twilio.rest.api.v2010.account.available_phone_number.toll_free.TollFreeList :rtype: twilio.rest.api.v2010.account.available_phone_number.toll_free.TollFreeList """ return self._proxy.toll_free @property def mobile(self): """ Access the mobile :returns: twilio.rest.api.v2010.account.available_phone_number.mobile.MobileList :rtype: twilio.rest.api.v2010.account.available_phone_number.mobile.MobileList """ return self._proxy.mobile def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/available_phone_number/local.py000066400000000000000000000423021317472742600277610ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class LocalList(ListResource): """ """ def __init__(self, version, account_sid, country_code): """ Initialize the LocalList :param Version version: Version that contains the resource :param account_sid: The 34 character string that uniquely identifies your account. :param country_code: The ISO Country code to lookup phone numbers for. :returns: twilio.rest.api.v2010.account.available_phone_number.local.LocalList :rtype: twilio.rest.api.v2010.account.available_phone_number.local.LocalList """ super(LocalList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'country_code': country_code,} self._uri = '/Accounts/{account_sid}/AvailablePhoneNumbers/{country_code}/Local.json'.format(**self._solution) def stream(self, area_code=values.unset, contains=values.unset, sms_enabled=values.unset, mms_enabled=values.unset, voice_enabled=values.unset, exclude_all_address_required=values.unset, exclude_local_address_required=values.unset, exclude_foreign_address_required=values.unset, beta=values.unset, near_number=values.unset, near_lat_long=values.unset, distance=values.unset, in_postal_code=values.unset, in_region=values.unset, in_rate_center=values.unset, in_lata=values.unset, in_locality=values.unset, fax_enabled=values.unset, limit=None, page_size=None): """ Streams LocalInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param unicode area_code: The area_code :param unicode contains: The contains :param bool sms_enabled: The sms_enabled :param bool mms_enabled: The mms_enabled :param bool voice_enabled: The voice_enabled :param bool exclude_all_address_required: The exclude_all_address_required :param bool exclude_local_address_required: The exclude_local_address_required :param bool exclude_foreign_address_required: The exclude_foreign_address_required :param bool beta: The beta :param unicode near_number: The near_number :param unicode near_lat_long: The near_lat_long :param unicode distance: The distance :param unicode in_postal_code: The in_postal_code :param unicode in_region: The in_region :param unicode in_rate_center: The in_rate_center :param unicode in_lata: The in_lata :param unicode in_locality: The in_locality :param bool fax_enabled: The fax_enabled :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.available_phone_number.local.LocalInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( area_code=area_code, contains=contains, sms_enabled=sms_enabled, mms_enabled=mms_enabled, voice_enabled=voice_enabled, exclude_all_address_required=exclude_all_address_required, exclude_local_address_required=exclude_local_address_required, exclude_foreign_address_required=exclude_foreign_address_required, beta=beta, near_number=near_number, near_lat_long=near_lat_long, distance=distance, in_postal_code=in_postal_code, in_region=in_region, in_rate_center=in_rate_center, in_lata=in_lata, in_locality=in_locality, fax_enabled=fax_enabled, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, area_code=values.unset, contains=values.unset, sms_enabled=values.unset, mms_enabled=values.unset, voice_enabled=values.unset, exclude_all_address_required=values.unset, exclude_local_address_required=values.unset, exclude_foreign_address_required=values.unset, beta=values.unset, near_number=values.unset, near_lat_long=values.unset, distance=values.unset, in_postal_code=values.unset, in_region=values.unset, in_rate_center=values.unset, in_lata=values.unset, in_locality=values.unset, fax_enabled=values.unset, limit=None, page_size=None): """ Lists LocalInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param unicode area_code: The area_code :param unicode contains: The contains :param bool sms_enabled: The sms_enabled :param bool mms_enabled: The mms_enabled :param bool voice_enabled: The voice_enabled :param bool exclude_all_address_required: The exclude_all_address_required :param bool exclude_local_address_required: The exclude_local_address_required :param bool exclude_foreign_address_required: The exclude_foreign_address_required :param bool beta: The beta :param unicode near_number: The near_number :param unicode near_lat_long: The near_lat_long :param unicode distance: The distance :param unicode in_postal_code: The in_postal_code :param unicode in_region: The in_region :param unicode in_rate_center: The in_rate_center :param unicode in_lata: The in_lata :param unicode in_locality: The in_locality :param bool fax_enabled: The fax_enabled :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.available_phone_number.local.LocalInstance] """ return list(self.stream( area_code=area_code, contains=contains, sms_enabled=sms_enabled, mms_enabled=mms_enabled, voice_enabled=voice_enabled, exclude_all_address_required=exclude_all_address_required, exclude_local_address_required=exclude_local_address_required, exclude_foreign_address_required=exclude_foreign_address_required, beta=beta, near_number=near_number, near_lat_long=near_lat_long, distance=distance, in_postal_code=in_postal_code, in_region=in_region, in_rate_center=in_rate_center, in_lata=in_lata, in_locality=in_locality, fax_enabled=fax_enabled, limit=limit, page_size=page_size, )) def page(self, area_code=values.unset, contains=values.unset, sms_enabled=values.unset, mms_enabled=values.unset, voice_enabled=values.unset, exclude_all_address_required=values.unset, exclude_local_address_required=values.unset, exclude_foreign_address_required=values.unset, beta=values.unset, near_number=values.unset, near_lat_long=values.unset, distance=values.unset, in_postal_code=values.unset, in_region=values.unset, in_rate_center=values.unset, in_lata=values.unset, in_locality=values.unset, fax_enabled=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of LocalInstance records from the API. Request is executed immediately :param unicode area_code: The area_code :param unicode contains: The contains :param bool sms_enabled: The sms_enabled :param bool mms_enabled: The mms_enabled :param bool voice_enabled: The voice_enabled :param bool exclude_all_address_required: The exclude_all_address_required :param bool exclude_local_address_required: The exclude_local_address_required :param bool exclude_foreign_address_required: The exclude_foreign_address_required :param bool beta: The beta :param unicode near_number: The near_number :param unicode near_lat_long: The near_lat_long :param unicode distance: The distance :param unicode in_postal_code: The in_postal_code :param unicode in_region: The in_region :param unicode in_rate_center: The in_rate_center :param unicode in_lata: The in_lata :param unicode in_locality: The in_locality :param bool fax_enabled: The fax_enabled :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of LocalInstance :rtype: twilio.rest.api.v2010.account.available_phone_number.local.LocalPage """ params = values.of({ '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, 'NearNumber': near_number, 'NearLatLong': near_lat_long, 'Distance': distance, 'InPostalCode': in_postal_code, 'InRegion': in_region, 'InRateCenter': in_rate_center, 'InLata': in_lata, 'InLocality': in_locality, 'FaxEnabled': fax_enabled, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return LocalPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of LocalInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of LocalInstance :rtype: twilio.rest.api.v2010.account.available_phone_number.local.LocalPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return LocalPage(self._version, response, self._solution) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class LocalPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the LocalPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The 34 character string that uniquely identifies your account. :param country_code: The ISO Country code to lookup phone numbers for. :returns: twilio.rest.api.v2010.account.available_phone_number.local.LocalPage :rtype: twilio.rest.api.v2010.account.available_phone_number.local.LocalPage """ super(LocalPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of LocalInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.available_phone_number.local.LocalInstance :rtype: twilio.rest.api.v2010.account.available_phone_number.local.LocalInstance """ return LocalInstance( self._version, payload, account_sid=self._solution['account_sid'], country_code=self._solution['country_code'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class LocalInstance(InstanceResource): """ """ def __init__(self, version, payload, account_sid, country_code): """ Initialize the LocalInstance :returns: twilio.rest.api.v2010.account.available_phone_number.local.LocalInstance :rtype: twilio.rest.api.v2010.account.available_phone_number.local.LocalInstance """ super(LocalInstance, self).__init__(version) # Marshaled Properties self._properties = { 'friendly_name': payload['friendly_name'], 'phone_number': payload['phone_number'], 'lata': payload['lata'], 'locality': payload['locality'], 'rate_center': payload['rate_center'], 'latitude': deserialize.decimal(payload['latitude']), 'longitude': deserialize.decimal(payload['longitude']), 'region': payload['region'], 'postal_code': payload['postal_code'], 'iso_country': payload['iso_country'], 'address_requirements': payload['address_requirements'], 'beta': payload['beta'], 'capabilities': payload['capabilities'], } # Context self._context = None self._solution = {'account_sid': account_sid, 'country_code': country_code,} @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def phone_number(self): """ :returns: The phone_number :rtype: unicode """ return self._properties['phone_number'] @property def lata(self): """ :returns: The lata :rtype: unicode """ return self._properties['lata'] @property def locality(self): """ :returns: The locality :rtype: unicode """ return self._properties['locality'] @property def rate_center(self): """ :returns: The rate_center :rtype: unicode """ return self._properties['rate_center'] @property def latitude(self): """ :returns: The latitude :rtype: unicode """ return self._properties['latitude'] @property def longitude(self): """ :returns: The longitude :rtype: unicode """ return self._properties['longitude'] @property def region(self): """ :returns: The region :rtype: unicode """ return self._properties['region'] @property def postal_code(self): """ :returns: The postal_code :rtype: unicode """ return self._properties['postal_code'] @property def iso_country(self): """ :returns: The iso_country :rtype: unicode """ return self._properties['iso_country'] @property def address_requirements(self): """ :returns: The address_requirements :rtype: unicode """ return self._properties['address_requirements'] @property def beta(self): """ :returns: The beta :rtype: bool """ return self._properties['beta'] @property def capabilities(self): """ :returns: The capabilities :rtype: unicode """ return self._properties['capabilities'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/api/v2010/account/available_phone_number/mobile.py000066400000000000000000000423611317472742600301430ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class MobileList(ListResource): """ """ def __init__(self, version, account_sid, country_code): """ Initialize the MobileList :param Version version: Version that contains the resource :param account_sid: The 34 character string that uniquely identifies your account. :param country_code: The ISO Country code to lookup phone numbers for. :returns: twilio.rest.api.v2010.account.available_phone_number.mobile.MobileList :rtype: twilio.rest.api.v2010.account.available_phone_number.mobile.MobileList """ super(MobileList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'country_code': country_code,} self._uri = '/Accounts/{account_sid}/AvailablePhoneNumbers/{country_code}/Mobile.json'.format(**self._solution) def stream(self, area_code=values.unset, contains=values.unset, sms_enabled=values.unset, mms_enabled=values.unset, voice_enabled=values.unset, exclude_all_address_required=values.unset, exclude_local_address_required=values.unset, exclude_foreign_address_required=values.unset, beta=values.unset, near_number=values.unset, near_lat_long=values.unset, distance=values.unset, in_postal_code=values.unset, in_region=values.unset, in_rate_center=values.unset, in_lata=values.unset, in_locality=values.unset, fax_enabled=values.unset, limit=None, page_size=None): """ Streams MobileInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param unicode area_code: The area_code :param unicode contains: The contains :param bool sms_enabled: The sms_enabled :param bool mms_enabled: The mms_enabled :param bool voice_enabled: The voice_enabled :param bool exclude_all_address_required: The exclude_all_address_required :param bool exclude_local_address_required: The exclude_local_address_required :param bool exclude_foreign_address_required: The exclude_foreign_address_required :param bool beta: The beta :param unicode near_number: The near_number :param unicode near_lat_long: The near_lat_long :param unicode distance: The distance :param unicode in_postal_code: The in_postal_code :param unicode in_region: The in_region :param unicode in_rate_center: The in_rate_center :param unicode in_lata: The in_lata :param unicode in_locality: The in_locality :param bool fax_enabled: The fax_enabled :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.available_phone_number.mobile.MobileInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( area_code=area_code, contains=contains, sms_enabled=sms_enabled, mms_enabled=mms_enabled, voice_enabled=voice_enabled, exclude_all_address_required=exclude_all_address_required, exclude_local_address_required=exclude_local_address_required, exclude_foreign_address_required=exclude_foreign_address_required, beta=beta, near_number=near_number, near_lat_long=near_lat_long, distance=distance, in_postal_code=in_postal_code, in_region=in_region, in_rate_center=in_rate_center, in_lata=in_lata, in_locality=in_locality, fax_enabled=fax_enabled, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, area_code=values.unset, contains=values.unset, sms_enabled=values.unset, mms_enabled=values.unset, voice_enabled=values.unset, exclude_all_address_required=values.unset, exclude_local_address_required=values.unset, exclude_foreign_address_required=values.unset, beta=values.unset, near_number=values.unset, near_lat_long=values.unset, distance=values.unset, in_postal_code=values.unset, in_region=values.unset, in_rate_center=values.unset, in_lata=values.unset, in_locality=values.unset, fax_enabled=values.unset, limit=None, page_size=None): """ Lists MobileInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param unicode area_code: The area_code :param unicode contains: The contains :param bool sms_enabled: The sms_enabled :param bool mms_enabled: The mms_enabled :param bool voice_enabled: The voice_enabled :param bool exclude_all_address_required: The exclude_all_address_required :param bool exclude_local_address_required: The exclude_local_address_required :param bool exclude_foreign_address_required: The exclude_foreign_address_required :param bool beta: The beta :param unicode near_number: The near_number :param unicode near_lat_long: The near_lat_long :param unicode distance: The distance :param unicode in_postal_code: The in_postal_code :param unicode in_region: The in_region :param unicode in_rate_center: The in_rate_center :param unicode in_lata: The in_lata :param unicode in_locality: The in_locality :param bool fax_enabled: The fax_enabled :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.available_phone_number.mobile.MobileInstance] """ return list(self.stream( area_code=area_code, contains=contains, sms_enabled=sms_enabled, mms_enabled=mms_enabled, voice_enabled=voice_enabled, exclude_all_address_required=exclude_all_address_required, exclude_local_address_required=exclude_local_address_required, exclude_foreign_address_required=exclude_foreign_address_required, beta=beta, near_number=near_number, near_lat_long=near_lat_long, distance=distance, in_postal_code=in_postal_code, in_region=in_region, in_rate_center=in_rate_center, in_lata=in_lata, in_locality=in_locality, fax_enabled=fax_enabled, limit=limit, page_size=page_size, )) def page(self, area_code=values.unset, contains=values.unset, sms_enabled=values.unset, mms_enabled=values.unset, voice_enabled=values.unset, exclude_all_address_required=values.unset, exclude_local_address_required=values.unset, exclude_foreign_address_required=values.unset, beta=values.unset, near_number=values.unset, near_lat_long=values.unset, distance=values.unset, in_postal_code=values.unset, in_region=values.unset, in_rate_center=values.unset, in_lata=values.unset, in_locality=values.unset, fax_enabled=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of MobileInstance records from the API. Request is executed immediately :param unicode area_code: The area_code :param unicode contains: The contains :param bool sms_enabled: The sms_enabled :param bool mms_enabled: The mms_enabled :param bool voice_enabled: The voice_enabled :param bool exclude_all_address_required: The exclude_all_address_required :param bool exclude_local_address_required: The exclude_local_address_required :param bool exclude_foreign_address_required: The exclude_foreign_address_required :param bool beta: The beta :param unicode near_number: The near_number :param unicode near_lat_long: The near_lat_long :param unicode distance: The distance :param unicode in_postal_code: The in_postal_code :param unicode in_region: The in_region :param unicode in_rate_center: The in_rate_center :param unicode in_lata: The in_lata :param unicode in_locality: The in_locality :param bool fax_enabled: The fax_enabled :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of MobileInstance :rtype: twilio.rest.api.v2010.account.available_phone_number.mobile.MobilePage """ params = values.of({ '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, 'NearNumber': near_number, 'NearLatLong': near_lat_long, 'Distance': distance, 'InPostalCode': in_postal_code, 'InRegion': in_region, 'InRateCenter': in_rate_center, 'InLata': in_lata, 'InLocality': in_locality, 'FaxEnabled': fax_enabled, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return MobilePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of MobileInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of MobileInstance :rtype: twilio.rest.api.v2010.account.available_phone_number.mobile.MobilePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return MobilePage(self._version, response, self._solution) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class MobilePage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the MobilePage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The 34 character string that uniquely identifies your account. :param country_code: The ISO Country code to lookup phone numbers for. :returns: twilio.rest.api.v2010.account.available_phone_number.mobile.MobilePage :rtype: twilio.rest.api.v2010.account.available_phone_number.mobile.MobilePage """ super(MobilePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of MobileInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.available_phone_number.mobile.MobileInstance :rtype: twilio.rest.api.v2010.account.available_phone_number.mobile.MobileInstance """ return MobileInstance( self._version, payload, account_sid=self._solution['account_sid'], country_code=self._solution['country_code'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class MobileInstance(InstanceResource): """ """ def __init__(self, version, payload, account_sid, country_code): """ Initialize the MobileInstance :returns: twilio.rest.api.v2010.account.available_phone_number.mobile.MobileInstance :rtype: twilio.rest.api.v2010.account.available_phone_number.mobile.MobileInstance """ super(MobileInstance, self).__init__(version) # Marshaled Properties self._properties = { 'friendly_name': payload['friendly_name'], 'phone_number': payload['phone_number'], 'lata': payload['lata'], 'locality': payload['locality'], 'rate_center': payload['rate_center'], 'latitude': deserialize.decimal(payload['latitude']), 'longitude': deserialize.decimal(payload['longitude']), 'region': payload['region'], 'postal_code': payload['postal_code'], 'iso_country': payload['iso_country'], 'address_requirements': payload['address_requirements'], 'beta': payload['beta'], 'capabilities': payload['capabilities'], } # Context self._context = None self._solution = {'account_sid': account_sid, 'country_code': country_code,} @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def phone_number(self): """ :returns: The phone_number :rtype: unicode """ return self._properties['phone_number'] @property def lata(self): """ :returns: The lata :rtype: unicode """ return self._properties['lata'] @property def locality(self): """ :returns: The locality :rtype: unicode """ return self._properties['locality'] @property def rate_center(self): """ :returns: The rate_center :rtype: unicode """ return self._properties['rate_center'] @property def latitude(self): """ :returns: The latitude :rtype: unicode """ return self._properties['latitude'] @property def longitude(self): """ :returns: The longitude :rtype: unicode """ return self._properties['longitude'] @property def region(self): """ :returns: The region :rtype: unicode """ return self._properties['region'] @property def postal_code(self): """ :returns: The postal_code :rtype: unicode """ return self._properties['postal_code'] @property def iso_country(self): """ :returns: The iso_country :rtype: unicode """ return self._properties['iso_country'] @property def address_requirements(self): """ :returns: The address_requirements :rtype: unicode """ return self._properties['address_requirements'] @property def beta(self): """ :returns: The beta :rtype: bool """ return self._properties['beta'] @property def capabilities(self): """ :returns: The capabilities :rtype: unicode """ return self._properties['capabilities'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/api/v2010/account/available_phone_number/toll_free.py000066400000000000000000000425331317472742600306500ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class TollFreeList(ListResource): """ """ def __init__(self, version, account_sid, country_code): """ Initialize the TollFreeList :param Version version: Version that contains the resource :param account_sid: The 34 character string that uniquely identifies your account. :param country_code: The ISO Country code to lookup phone numbers for. :returns: twilio.rest.api.v2010.account.available_phone_number.toll_free.TollFreeList :rtype: twilio.rest.api.v2010.account.available_phone_number.toll_free.TollFreeList """ super(TollFreeList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'country_code': country_code,} self._uri = '/Accounts/{account_sid}/AvailablePhoneNumbers/{country_code}/TollFree.json'.format(**self._solution) def stream(self, area_code=values.unset, contains=values.unset, sms_enabled=values.unset, mms_enabled=values.unset, voice_enabled=values.unset, exclude_all_address_required=values.unset, exclude_local_address_required=values.unset, exclude_foreign_address_required=values.unset, beta=values.unset, near_number=values.unset, near_lat_long=values.unset, distance=values.unset, in_postal_code=values.unset, in_region=values.unset, in_rate_center=values.unset, in_lata=values.unset, in_locality=values.unset, fax_enabled=values.unset, limit=None, page_size=None): """ Streams TollFreeInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param unicode area_code: The area_code :param unicode contains: The contains :param bool sms_enabled: The sms_enabled :param bool mms_enabled: The mms_enabled :param bool voice_enabled: The voice_enabled :param bool exclude_all_address_required: The exclude_all_address_required :param bool exclude_local_address_required: The exclude_local_address_required :param bool exclude_foreign_address_required: The exclude_foreign_address_required :param bool beta: The beta :param unicode near_number: The near_number :param unicode near_lat_long: The near_lat_long :param unicode distance: The distance :param unicode in_postal_code: The in_postal_code :param unicode in_region: The in_region :param unicode in_rate_center: The in_rate_center :param unicode in_lata: The in_lata :param unicode in_locality: The in_locality :param bool fax_enabled: The fax_enabled :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.available_phone_number.toll_free.TollFreeInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( area_code=area_code, contains=contains, sms_enabled=sms_enabled, mms_enabled=mms_enabled, voice_enabled=voice_enabled, exclude_all_address_required=exclude_all_address_required, exclude_local_address_required=exclude_local_address_required, exclude_foreign_address_required=exclude_foreign_address_required, beta=beta, near_number=near_number, near_lat_long=near_lat_long, distance=distance, in_postal_code=in_postal_code, in_region=in_region, in_rate_center=in_rate_center, in_lata=in_lata, in_locality=in_locality, fax_enabled=fax_enabled, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, area_code=values.unset, contains=values.unset, sms_enabled=values.unset, mms_enabled=values.unset, voice_enabled=values.unset, exclude_all_address_required=values.unset, exclude_local_address_required=values.unset, exclude_foreign_address_required=values.unset, beta=values.unset, near_number=values.unset, near_lat_long=values.unset, distance=values.unset, in_postal_code=values.unset, in_region=values.unset, in_rate_center=values.unset, in_lata=values.unset, in_locality=values.unset, fax_enabled=values.unset, limit=None, page_size=None): """ Lists TollFreeInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param unicode area_code: The area_code :param unicode contains: The contains :param bool sms_enabled: The sms_enabled :param bool mms_enabled: The mms_enabled :param bool voice_enabled: The voice_enabled :param bool exclude_all_address_required: The exclude_all_address_required :param bool exclude_local_address_required: The exclude_local_address_required :param bool exclude_foreign_address_required: The exclude_foreign_address_required :param bool beta: The beta :param unicode near_number: The near_number :param unicode near_lat_long: The near_lat_long :param unicode distance: The distance :param unicode in_postal_code: The in_postal_code :param unicode in_region: The in_region :param unicode in_rate_center: The in_rate_center :param unicode in_lata: The in_lata :param unicode in_locality: The in_locality :param bool fax_enabled: The fax_enabled :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.available_phone_number.toll_free.TollFreeInstance] """ return list(self.stream( area_code=area_code, contains=contains, sms_enabled=sms_enabled, mms_enabled=mms_enabled, voice_enabled=voice_enabled, exclude_all_address_required=exclude_all_address_required, exclude_local_address_required=exclude_local_address_required, exclude_foreign_address_required=exclude_foreign_address_required, beta=beta, near_number=near_number, near_lat_long=near_lat_long, distance=distance, in_postal_code=in_postal_code, in_region=in_region, in_rate_center=in_rate_center, in_lata=in_lata, in_locality=in_locality, fax_enabled=fax_enabled, limit=limit, page_size=page_size, )) def page(self, area_code=values.unset, contains=values.unset, sms_enabled=values.unset, mms_enabled=values.unset, voice_enabled=values.unset, exclude_all_address_required=values.unset, exclude_local_address_required=values.unset, exclude_foreign_address_required=values.unset, beta=values.unset, near_number=values.unset, near_lat_long=values.unset, distance=values.unset, in_postal_code=values.unset, in_region=values.unset, in_rate_center=values.unset, in_lata=values.unset, in_locality=values.unset, fax_enabled=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of TollFreeInstance records from the API. Request is executed immediately :param unicode area_code: The area_code :param unicode contains: The contains :param bool sms_enabled: The sms_enabled :param bool mms_enabled: The mms_enabled :param bool voice_enabled: The voice_enabled :param bool exclude_all_address_required: The exclude_all_address_required :param bool exclude_local_address_required: The exclude_local_address_required :param bool exclude_foreign_address_required: The exclude_foreign_address_required :param bool beta: The beta :param unicode near_number: The near_number :param unicode near_lat_long: The near_lat_long :param unicode distance: The distance :param unicode in_postal_code: The in_postal_code :param unicode in_region: The in_region :param unicode in_rate_center: The in_rate_center :param unicode in_lata: The in_lata :param unicode in_locality: The in_locality :param bool fax_enabled: The fax_enabled :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of TollFreeInstance :rtype: twilio.rest.api.v2010.account.available_phone_number.toll_free.TollFreePage """ params = values.of({ '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, 'NearNumber': near_number, 'NearLatLong': near_lat_long, 'Distance': distance, 'InPostalCode': in_postal_code, 'InRegion': in_region, 'InRateCenter': in_rate_center, 'InLata': in_lata, 'InLocality': in_locality, 'FaxEnabled': fax_enabled, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return TollFreePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of TollFreeInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of TollFreeInstance :rtype: twilio.rest.api.v2010.account.available_phone_number.toll_free.TollFreePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return TollFreePage(self._version, response, self._solution) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class TollFreePage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the TollFreePage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The 34 character string that uniquely identifies your account. :param country_code: The ISO Country code to lookup phone numbers for. :returns: twilio.rest.api.v2010.account.available_phone_number.toll_free.TollFreePage :rtype: twilio.rest.api.v2010.account.available_phone_number.toll_free.TollFreePage """ super(TollFreePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of TollFreeInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.available_phone_number.toll_free.TollFreeInstance :rtype: twilio.rest.api.v2010.account.available_phone_number.toll_free.TollFreeInstance """ return TollFreeInstance( self._version, payload, account_sid=self._solution['account_sid'], country_code=self._solution['country_code'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class TollFreeInstance(InstanceResource): """ """ def __init__(self, version, payload, account_sid, country_code): """ Initialize the TollFreeInstance :returns: twilio.rest.api.v2010.account.available_phone_number.toll_free.TollFreeInstance :rtype: twilio.rest.api.v2010.account.available_phone_number.toll_free.TollFreeInstance """ super(TollFreeInstance, self).__init__(version) # Marshaled Properties self._properties = { 'friendly_name': payload['friendly_name'], 'phone_number': payload['phone_number'], 'lata': payload['lata'], 'locality': payload['locality'], 'rate_center': payload['rate_center'], 'latitude': deserialize.decimal(payload['latitude']), 'longitude': deserialize.decimal(payload['longitude']), 'region': payload['region'], 'postal_code': payload['postal_code'], 'iso_country': payload['iso_country'], 'address_requirements': payload['address_requirements'], 'beta': payload['beta'], 'capabilities': payload['capabilities'], } # Context self._context = None self._solution = {'account_sid': account_sid, 'country_code': country_code,} @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def phone_number(self): """ :returns: The phone_number :rtype: unicode """ return self._properties['phone_number'] @property def lata(self): """ :returns: The lata :rtype: unicode """ return self._properties['lata'] @property def locality(self): """ :returns: The locality :rtype: unicode """ return self._properties['locality'] @property def rate_center(self): """ :returns: The rate_center :rtype: unicode """ return self._properties['rate_center'] @property def latitude(self): """ :returns: The latitude :rtype: unicode """ return self._properties['latitude'] @property def longitude(self): """ :returns: The longitude :rtype: unicode """ return self._properties['longitude'] @property def region(self): """ :returns: The region :rtype: unicode """ return self._properties['region'] @property def postal_code(self): """ :returns: The postal_code :rtype: unicode """ return self._properties['postal_code'] @property def iso_country(self): """ :returns: The iso_country :rtype: unicode """ return self._properties['iso_country'] @property def address_requirements(self): """ :returns: The address_requirements :rtype: unicode """ return self._properties['address_requirements'] @property def beta(self): """ :returns: The beta :rtype: bool """ return self._properties['beta'] @property def capabilities(self): """ :returns: The capabilities :rtype: unicode """ return self._properties['capabilities'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/api/v2010/account/call/000077500000000000000000000000001317472742600225465ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/api/v2010/account/call/__init__.py000066400000000000000000000776261317472742600247010ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize 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.page import Page 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.recording import RecordingList class CallList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the CallList :param Version version: Version that contains the resource :param account_sid: The unique id of the Account responsible for creating this Call :returns: twilio.rest.api.v2010.account.call.CallList :rtype: twilio.rest.api.v2010.account.call.CallList """ super(CallList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/Calls.json'.format(**self._solution) # Components self._feedback_summaries = None def create(self, to, from_, method=values.unset, fallback_url=values.unset, fallback_method=values.unset, status_callback=values.unset, status_callback_event=values.unset, status_callback_method=values.unset, send_digits=values.unset, if_machine=values.unset, timeout=values.unset, record=values.unset, recording_channels=values.unset, recording_status_callback=values.unset, recording_status_callback_method=values.unset, sip_auth_username=values.unset, sip_auth_password=values.unset, machine_detection=values.unset, machine_detection_timeout=values.unset, url=values.unset, application_sid=values.unset): """ Create a new CallInstance :param unicode to: Phone number, SIP address or client identifier to call :param unicode from_: Twilio number from which to originate the call :param unicode method: HTTP method to use to fetch TwiML :param unicode fallback_url: Fallback URL in case of error :param unicode fallback_method: HTTP Method to use with FallbackUrl :param unicode status_callback: Status Callback URL :param unicode status_callback_event: The status_callback_event :param unicode status_callback_method: HTTP Method to use with StatusCallback :param unicode send_digits: Digits to send :param unicode if_machine: Action to take if a machine has answered the call :param unicode timeout: Number of seconds to wait for an answer :param bool record: Whether or not to record the Call :param unicode recording_channels: The recording_channels :param unicode recording_status_callback: The recording_status_callback :param unicode recording_status_callback_method: The recording_status_callback_method :param unicode sip_auth_username: The sip_auth_username :param unicode sip_auth_password: The sip_auth_password :param unicode machine_detection: Enable machine detection or end of greeting detection :param unicode machine_detection_timeout: Number of miliseconds to wait for machine detection :param unicode url: Url from which to fetch TwiML :param unicode application_sid: ApplicationSid that configures from where to fetch TwiML :returns: Newly created CallInstance :rtype: twilio.rest.api.v2010.account.call.CallInstance """ data = values.of({ 'To': to, 'From': from_, 'Url': url, 'ApplicationSid': application_sid, 'Method': method, 'FallbackUrl': fallback_url, 'FallbackMethod': fallback_method, 'StatusCallback': status_callback, 'StatusCallbackEvent': status_callback_event, 'StatusCallbackMethod': status_callback_method, 'SendDigits': send_digits, 'IfMachine': if_machine, 'Timeout': timeout, 'Record': record, 'RecordingChannels': recording_channels, 'RecordingStatusCallback': recording_status_callback, 'RecordingStatusCallbackMethod': recording_status_callback_method, 'SipAuthUsername': sip_auth_username, 'SipAuthPassword': sip_auth_password, 'MachineDetection': machine_detection, 'MachineDetectionTimeout': machine_detection_timeout, }) payload = self._version.create( 'POST', self._uri, data=data, ) return CallInstance(self._version, payload, account_sid=self._solution['account_sid'],) def stream(self, to=values.unset, from_=values.unset, parent_call_sid=values.unset, status=values.unset, start_time_before=values.unset, start_time=values.unset, start_time_after=values.unset, end_time_before=values.unset, end_time=values.unset, end_time_after=values.unset, limit=None, page_size=None): """ Streams CallInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param unicode to: Phone number or Client identifier to filter `to` on :param unicode from_: Phone number or Client identifier to filter `from` on :param unicode parent_call_sid: Parent Call Sid to filter on :param CallInstance.Status status: Status to filter on :param datetime start_time_before: StartTime to filter on :param datetime start_time: StartTime to filter on :param datetime start_time_after: StartTime to filter on :param datetime end_time_before: EndTime to filter on :param datetime end_time: EndTime to filter on :param datetime end_time_after: EndTime to filter on :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.call.CallInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( to=to, from_=from_, parent_call_sid=parent_call_sid, status=status, start_time_before=start_time_before, start_time=start_time, start_time_after=start_time_after, end_time_before=end_time_before, end_time=end_time, end_time_after=end_time_after, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, to=values.unset, from_=values.unset, parent_call_sid=values.unset, status=values.unset, start_time_before=values.unset, start_time=values.unset, start_time_after=values.unset, end_time_before=values.unset, end_time=values.unset, end_time_after=values.unset, limit=None, page_size=None): """ Lists CallInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param unicode to: Phone number or Client identifier to filter `to` on :param unicode from_: Phone number or Client identifier to filter `from` on :param unicode parent_call_sid: Parent Call Sid to filter on :param CallInstance.Status status: Status to filter on :param datetime start_time_before: StartTime to filter on :param datetime start_time: StartTime to filter on :param datetime start_time_after: StartTime to filter on :param datetime end_time_before: EndTime to filter on :param datetime end_time: EndTime to filter on :param datetime end_time_after: EndTime to filter on :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.call.CallInstance] """ return list(self.stream( to=to, from_=from_, parent_call_sid=parent_call_sid, status=status, start_time_before=start_time_before, start_time=start_time, start_time_after=start_time_after, end_time_before=end_time_before, end_time=end_time, end_time_after=end_time_after, limit=limit, page_size=page_size, )) def page(self, to=values.unset, from_=values.unset, parent_call_sid=values.unset, status=values.unset, start_time_before=values.unset, start_time=values.unset, start_time_after=values.unset, end_time_before=values.unset, end_time=values.unset, end_time_after=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of CallInstance records from the API. Request is executed immediately :param unicode to: Phone number or Client identifier to filter `to` on :param unicode from_: Phone number or Client identifier to filter `from` on :param unicode parent_call_sid: Parent Call Sid to filter on :param CallInstance.Status status: Status to filter on :param datetime start_time_before: StartTime to filter on :param datetime start_time: StartTime to filter on :param datetime start_time_after: StartTime to filter on :param datetime end_time_before: EndTime to filter on :param datetime end_time: EndTime to filter on :param datetime end_time_after: EndTime to filter on :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of CallInstance :rtype: twilio.rest.api.v2010.account.call.CallPage """ params = values.of({ 'To': to, 'From': from_, 'ParentCallSid': parent_call_sid, 'Status': status, 'StartTime<': serialize.iso8601_datetime(start_time_before), 'StartTime': serialize.iso8601_datetime(start_time), 'StartTime>': serialize.iso8601_datetime(start_time_after), 'EndTime<': serialize.iso8601_datetime(end_time_before), 'EndTime': serialize.iso8601_datetime(end_time), 'EndTime>': serialize.iso8601_datetime(end_time_after), 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return CallPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of CallInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of CallInstance :rtype: twilio.rest.api.v2010.account.call.CallPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return CallPage(self._version, response, self._solution) @property def feedback_summaries(self): """ Access the feedback_summaries :returns: twilio.rest.api.v2010.account.call.feedback_summary.FeedbackSummaryList :rtype: twilio.rest.api.v2010.account.call.feedback_summary.FeedbackSummaryList """ 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): """ Constructs a CallContext :param sid: Call Sid that uniquely identifies the Call to fetch :returns: twilio.rest.api.v2010.account.call.CallContext :rtype: twilio.rest.api.v2010.account.call.CallContext """ return CallContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __call__(self, sid): """ Constructs a CallContext :param sid: Call Sid that uniquely identifies the Call to fetch :returns: twilio.rest.api.v2010.account.call.CallContext :rtype: twilio.rest.api.v2010.account.call.CallContext """ return CallContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class CallPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the CallPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The unique id of the Account responsible for creating this Call :returns: twilio.rest.api.v2010.account.call.CallPage :rtype: twilio.rest.api.v2010.account.call.CallPage """ super(CallPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of CallInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.call.CallInstance :rtype: twilio.rest.api.v2010.account.call.CallInstance """ return CallInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class CallContext(InstanceContext): """ """ def __init__(self, version, account_sid, sid): """ Initialize the CallContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param sid: Call Sid that uniquely identifies the Call to fetch :returns: twilio.rest.api.v2010.account.call.CallContext :rtype: twilio.rest.api.v2010.account.call.CallContext """ super(CallContext, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'sid': sid,} self._uri = '/Accounts/{account_sid}/Calls/{sid}.json'.format(**self._solution) # Dependents self._recordings = None self._notifications = None self._feedback = None def delete(self): """ Deletes the CallInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def fetch(self): """ Fetch a CallInstance :returns: Fetched CallInstance :rtype: twilio.rest.api.v2010.account.call.CallInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return CallInstance( self._version, payload, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) def update(self, url=values.unset, method=values.unset, status=values.unset, fallback_url=values.unset, fallback_method=values.unset, status_callback=values.unset, status_callback_method=values.unset): """ Update the CallInstance :param unicode url: URL that returns TwiML :param unicode method: HTTP method to use to fetch TwiML :param CallInstance.UpdateStatus status: Status to update the Call with :param unicode fallback_url: Fallback URL in case of error :param unicode fallback_method: HTTP Method to use with FallbackUrl :param unicode status_callback: Status Callback URL :param unicode status_callback_method: HTTP Method to use with StatusCallback :returns: Updated CallInstance :rtype: twilio.rest.api.v2010.account.call.CallInstance """ data = values.of({ 'Url': url, 'Method': method, 'Status': status, 'FallbackUrl': fallback_url, 'FallbackMethod': fallback_method, 'StatusCallback': status_callback, 'StatusCallbackMethod': status_callback_method, }) payload = self._version.update( 'POST', self._uri, data=data, ) return CallInstance( self._version, payload, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) @property def recordings(self): """ Access the recordings :returns: twilio.rest.api.v2010.account.call.recording.RecordingList :rtype: twilio.rest.api.v2010.account.call.recording.RecordingList """ if self._recordings is None: self._recordings = RecordingList( self._version, account_sid=self._solution['account_sid'], call_sid=self._solution['sid'], ) return self._recordings @property def notifications(self): """ Access the notifications :returns: twilio.rest.api.v2010.account.call.notification.NotificationList :rtype: twilio.rest.api.v2010.account.call.notification.NotificationList """ if self._notifications is None: self._notifications = NotificationList( self._version, account_sid=self._solution['account_sid'], call_sid=self._solution['sid'], ) return self._notifications @property def feedback(self): """ Access the feedback :returns: twilio.rest.api.v2010.account.call.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.call.feedback.FeedbackList """ if self._feedback is None: self._feedback = FeedbackList( self._version, account_sid=self._solution['account_sid'], call_sid=self._solution['sid'], ) return self._feedback def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class CallInstance(InstanceResource): """ """ class Event(object): INITIATED = "initiated" RINGING = "ringing" ANSWERED = "answered" COMPLETED = "completed" class Status(object): QUEUED = "queued" RINGING = "ringing" IN_PROGRESS = "in-progress" COMPLETED = "completed" BUSY = "busy" FAILED = "failed" NO_ANSWER = "no-answer" CANCELED = "canceled" class UpdateStatus(object): CANCELED = "canceled" COMPLETED = "completed" def __init__(self, version, payload, account_sid, sid=None): """ Initialize the CallInstance :returns: twilio.rest.api.v2010.account.call.CallInstance :rtype: twilio.rest.api.v2010.account.call.CallInstance """ super(CallInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'annotation': payload['annotation'], 'answered_by': payload['answered_by'], 'api_version': payload['api_version'], 'caller_name': payload['caller_name'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'direction': payload['direction'], 'duration': payload['duration'], 'end_time': deserialize.rfc2822_datetime(payload['end_time']), 'forwarded_from': payload['forwarded_from'], 'from_': payload['from'], 'from_formatted': payload['from_formatted'], 'group_sid': payload['group_sid'], 'parent_call_sid': payload['parent_call_sid'], 'phone_number_sid': payload['phone_number_sid'], 'price': deserialize.decimal(payload['price']), 'price_unit': payload['price_unit'], 'sid': payload['sid'], 'start_time': deserialize.rfc2822_datetime(payload['start_time']), 'status': payload['status'], 'subresource_uris': payload['subresource_uris'], 'to': payload['to'], 'to_formatted': payload['to_formatted'], 'uri': payload['uri'], } # Context self._context = None self._solution = {'account_sid': account_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: CallContext for this CallInstance :rtype: twilio.rest.api.v2010.account.call.CallContext """ if self._context is None: self._context = CallContext( self._version, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: The unique id of the Account responsible for creating this Call :rtype: unicode """ return self._properties['account_sid'] @property def annotation(self): """ :returns: The annotation provided for the Call :rtype: unicode """ return self._properties['annotation'] @property def answered_by(self): """ :returns: If this call was initiated with answering machine detection, either `human` or `machine`. Empty otherwise. :rtype: unicode """ return self._properties['answered_by'] @property def api_version(self): """ :returns: The API Version the Call was created through :rtype: unicode """ return self._properties['api_version'] @property def caller_name(self): """ :returns: If this call was an incoming call to a phone number with Caller ID Lookup enabled, the caller's name. Empty otherwise. :rtype: unicode """ return self._properties['caller_name'] @property def date_created(self): """ :returns: The date that this resource was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date that this resource was last updated :rtype: datetime """ return self._properties['date_updated'] @property def direction(self): """ :returns: A string describing the direction of the call. `inbound` for inbound calls, `outbound-api` for calls initiated via the REST API or `outbound-dial` for calls initiated by a `Dial` verb. :rtype: unicode """ return self._properties['direction'] @property def duration(self): """ :returns: The duration :rtype: unicode """ return self._properties['duration'] @property def end_time(self): """ :returns: The end time of the Call. Null if the call did not complete successfully. :rtype: datetime """ return self._properties['end_time'] @property def forwarded_from(self): """ :returns: If this Call was an incoming call forwarded from another number, the forwarding phone number (depends on carrier supporting forwarding). Empty otherwise. :rtype: unicode """ return self._properties['forwarded_from'] @property def from_(self): """ :returns: The phone number, SIP address or Client identifier that made this Call. Phone numbers are in E.164 format (e.g. +16175551212). SIP addresses are formatted as `name@company.com`. Client identifiers are formatted `client:name`. :rtype: unicode """ return self._properties['from_'] @property def from_formatted(self): """ :returns: The phone number, SIP address or Client identifier that made this Call. Formatted for display. :rtype: unicode """ return self._properties['from_formatted'] @property def group_sid(self): """ :returns: A 34 character Group Sid associated with this Call. Empty if no Group is associated with the Call. :rtype: unicode """ return self._properties['group_sid'] @property def parent_call_sid(self): """ :returns: A 34 character string that uniquely identifies the Call that created this leg. :rtype: unicode """ return self._properties['parent_call_sid'] @property def phone_number_sid(self): """ :returns: If the call was inbound, this is the Sid of the IncomingPhoneNumber that received the call. If the call was outbound, it is the Sid of the OutgoingCallerId from which the call was placed. :rtype: unicode """ return self._properties['phone_number_sid'] @property def price(self): """ :returns: The charge for this call, in the currency associated with the account. Populated after the call is completed. May not be immediately available. :rtype: unicode """ return self._properties['price'] @property def price_unit(self): """ :returns: The currency in which `Price` is measured. :rtype: unicode """ return self._properties['price_unit'] @property def sid(self): """ :returns: A 34 character string that uniquely identifies this resource. :rtype: unicode """ return self._properties['sid'] @property def start_time(self): """ :returns: The start time of the Call. Null if the call has not yet been dialed. :rtype: datetime """ return self._properties['start_time'] @property def status(self): """ :returns: The status :rtype: CallInstance.Status """ return self._properties['status'] @property def subresource_uris(self): """ :returns: Call Instance Subresources :rtype: unicode """ return self._properties['subresource_uris'] @property def to(self): """ :returns: The phone number, SIP address or Client identifier that received this Call. Phone numbers are in E.164 format (e.g. +16175551212). SIP addresses are formatted as `name@company.com`. Client identifiers are formatted `client:name`. :rtype: unicode """ return self._properties['to'] @property def to_formatted(self): """ :returns: The phone number, SIP address or Client identifier that received this Call. Formatted for display. :rtype: unicode """ return self._properties['to_formatted'] @property def uri(self): """ :returns: The URI for this resource, relative to `https://api.twilio.com` :rtype: unicode """ return self._properties['uri'] def delete(self): """ Deletes the CallInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def fetch(self): """ Fetch a CallInstance :returns: Fetched CallInstance :rtype: twilio.rest.api.v2010.account.call.CallInstance """ return self._proxy.fetch() def update(self, url=values.unset, method=values.unset, status=values.unset, fallback_url=values.unset, fallback_method=values.unset, status_callback=values.unset, status_callback_method=values.unset): """ Update the CallInstance :param unicode url: URL that returns TwiML :param unicode method: HTTP method to use to fetch TwiML :param CallInstance.UpdateStatus status: Status to update the Call with :param unicode fallback_url: Fallback URL in case of error :param unicode fallback_method: HTTP Method to use with FallbackUrl :param unicode status_callback: Status Callback URL :param unicode status_callback_method: HTTP Method to use with StatusCallback :returns: Updated CallInstance :rtype: twilio.rest.api.v2010.account.call.CallInstance """ return self._proxy.update( url=url, method=method, status=status, fallback_url=fallback_url, fallback_method=fallback_method, status_callback=status_callback, status_callback_method=status_callback_method, ) @property def recordings(self): """ Access the recordings :returns: twilio.rest.api.v2010.account.call.recording.RecordingList :rtype: twilio.rest.api.v2010.account.call.recording.RecordingList """ return self._proxy.recordings @property def notifications(self): """ Access the notifications :returns: twilio.rest.api.v2010.account.call.notification.NotificationList :rtype: twilio.rest.api.v2010.account.call.notification.NotificationList """ return self._proxy.notifications @property def feedback(self): """ Access the feedback :returns: twilio.rest.api.v2010.account.call.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.call.feedback.FeedbackList """ return self._proxy.feedback def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/call/feedback.py000066400000000000000000000255011317472742600246470ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class FeedbackList(ListResource): """ """ def __init__(self, version, account_sid, call_sid): """ Initialize the FeedbackList :param Version version: Version that contains the resource :param account_sid: The account_sid :param call_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.call.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.call.feedback.FeedbackList """ super(FeedbackList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'call_sid': call_sid,} def get(self): """ Constructs a FeedbackContext :returns: twilio.rest.api.v2010.account.call.feedback.FeedbackContext :rtype: twilio.rest.api.v2010.account.call.feedback.FeedbackContext """ return FeedbackContext( self._version, account_sid=self._solution['account_sid'], call_sid=self._solution['call_sid'], ) def __call__(self): """ Constructs a FeedbackContext :returns: twilio.rest.api.v2010.account.call.feedback.FeedbackContext :rtype: twilio.rest.api.v2010.account.call.feedback.FeedbackContext """ return FeedbackContext( self._version, account_sid=self._solution['account_sid'], call_sid=self._solution['call_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class FeedbackPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the FeedbackPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param call_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.call.feedback.FeedbackPage :rtype: twilio.rest.api.v2010.account.call.feedback.FeedbackPage """ super(FeedbackPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of FeedbackInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.call.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.call.feedback.FeedbackInstance """ return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], call_sid=self._solution['call_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class FeedbackContext(InstanceContext): """ """ def __init__(self, version, account_sid, call_sid): """ Initialize the FeedbackContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param call_sid: The call sid that uniquely identifies the call :returns: twilio.rest.api.v2010.account.call.feedback.FeedbackContext :rtype: twilio.rest.api.v2010.account.call.feedback.FeedbackContext """ super(FeedbackContext, self).__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 create(self, quality_score, issue=values.unset): """ Create a new FeedbackInstance :param unicode quality_score: The quality_score :param FeedbackInstance.Issues issue: The issue :returns: Newly created FeedbackInstance :rtype: twilio.rest.api.v2010.account.call.feedback.FeedbackInstance """ data = values.of({'QualityScore': quality_score, 'Issue': issue,}) payload = self._version.create( 'POST', self._uri, data=data, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], call_sid=self._solution['call_sid'], ) def fetch(self): """ Fetch a FeedbackInstance :returns: Fetched FeedbackInstance :rtype: twilio.rest.api.v2010.account.call.feedback.FeedbackInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], call_sid=self._solution['call_sid'], ) def update(self, quality_score, issue=values.unset): """ Update the FeedbackInstance :param unicode quality_score: An integer from 1 to 5 :param FeedbackInstance.Issues issue: Issues experienced during the call :returns: Updated FeedbackInstance :rtype: twilio.rest.api.v2010.account.call.feedback.FeedbackInstance """ data = values.of({'QualityScore': quality_score, 'Issue': issue,}) payload = self._version.update( 'POST', self._uri, data=data, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], call_sid=self._solution['call_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) 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" def __init__(self, version, payload, account_sid, call_sid): """ Initialize the FeedbackInstance :returns: twilio.rest.api.v2010.account.call.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.call.feedback.FeedbackInstance """ super(FeedbackInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'issues': payload['issues'], 'quality_score': deserialize.integer(payload['quality_score']), 'sid': payload['sid'], } # Context self._context = None self._solution = {'account_sid': account_sid, 'call_sid': call_sid,} @property def _proxy(self): """ 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 :rtype: twilio.rest.api.v2010.account.call.feedback.FeedbackContext """ 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 @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def issues(self): """ :returns: The issues :rtype: FeedbackInstance.Issues """ return self._properties['issues'] @property def quality_score(self): """ :returns: 1 to 5 quality score :rtype: unicode """ return self._properties['quality_score'] @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] def create(self, quality_score, issue=values.unset): """ Create a new FeedbackInstance :param unicode quality_score: The quality_score :param FeedbackInstance.Issues issue: The issue :returns: Newly created FeedbackInstance :rtype: twilio.rest.api.v2010.account.call.feedback.FeedbackInstance """ return self._proxy.create(quality_score, issue=issue,) def fetch(self): """ Fetch a FeedbackInstance :returns: Fetched FeedbackInstance :rtype: twilio.rest.api.v2010.account.call.feedback.FeedbackInstance """ return self._proxy.fetch() def update(self, quality_score, issue=values.unset): """ Update the FeedbackInstance :param unicode quality_score: An integer from 1 to 5 :param FeedbackInstance.Issues issue: Issues experienced during the call :returns: Updated FeedbackInstance :rtype: twilio.rest.api.v2010.account.call.feedback.FeedbackInstance """ return self._proxy.update(quality_score, issue=issue,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/call/feedback_summary.py000066400000000000000000000303171317472742600264250ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize 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.page import Page class FeedbackSummaryList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the FeedbackSummaryList :param Version version: Version that contains the resource :param account_sid: The unique id of the Account responsible for creating this Call :returns: twilio.rest.api.v2010.account.call.feedback_summary.FeedbackSummaryList :rtype: twilio.rest.api.v2010.account.call.feedback_summary.FeedbackSummaryList """ super(FeedbackSummaryList, self).__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, end_date, include_subaccounts=values.unset, status_callback=values.unset, status_callback_method=values.unset): """ Create a new FeedbackSummaryInstance :param date start_date: The start_date :param date end_date: The end_date :param bool include_subaccounts: The include_subaccounts :param unicode status_callback: The status_callback :param unicode status_callback_method: The status_callback_method :returns: Newly created FeedbackSummaryInstance :rtype: twilio.rest.api.v2010.account.call.feedback_summary.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( 'POST', self._uri, data=data, ) return FeedbackSummaryInstance(self._version, payload, account_sid=self._solution['account_sid'],) def get(self, sid): """ Constructs a FeedbackSummaryContext :param sid: The sid :returns: twilio.rest.api.v2010.account.call.feedback_summary.FeedbackSummaryContext :rtype: twilio.rest.api.v2010.account.call.feedback_summary.FeedbackSummaryContext """ return FeedbackSummaryContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __call__(self, sid): """ Constructs a FeedbackSummaryContext :param sid: The sid :returns: twilio.rest.api.v2010.account.call.feedback_summary.FeedbackSummaryContext :rtype: twilio.rest.api.v2010.account.call.feedback_summary.FeedbackSummaryContext """ return FeedbackSummaryContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class FeedbackSummaryPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the FeedbackSummaryPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The unique id of the Account responsible for creating this Call :returns: twilio.rest.api.v2010.account.call.feedback_summary.FeedbackSummaryPage :rtype: twilio.rest.api.v2010.account.call.feedback_summary.FeedbackSummaryPage """ super(FeedbackSummaryPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of FeedbackSummaryInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.call.feedback_summary.FeedbackSummaryInstance :rtype: twilio.rest.api.v2010.account.call.feedback_summary.FeedbackSummaryInstance """ return FeedbackSummaryInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class FeedbackSummaryContext(InstanceContext): """ """ def __init__(self, version, account_sid, sid): """ Initialize the FeedbackSummaryContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param sid: The sid :returns: twilio.rest.api.v2010.account.call.feedback_summary.FeedbackSummaryContext :rtype: twilio.rest.api.v2010.account.call.feedback_summary.FeedbackSummaryContext """ super(FeedbackSummaryContext, self).__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 fetch(self): """ Fetch a FeedbackSummaryInstance :returns: Fetched FeedbackSummaryInstance :rtype: twilio.rest.api.v2010.account.call.feedback_summary.FeedbackSummaryInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return FeedbackSummaryInstance( self._version, payload, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the FeedbackSummaryInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class FeedbackSummaryInstance(InstanceResource): """ """ class Status(object): QUEUED = "queued" IN_PROGRESS = "in-progress" COMPLETED = "completed" FAILED = "failed" def __init__(self, version, payload, account_sid, sid=None): """ Initialize the FeedbackSummaryInstance :returns: twilio.rest.api.v2010.account.call.feedback_summary.FeedbackSummaryInstance :rtype: twilio.rest.api.v2010.account.call.feedback_summary.FeedbackSummaryInstance """ super(FeedbackSummaryInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'call_count': deserialize.integer(payload['call_count']), 'call_feedback_count': deserialize.integer(payload['call_feedback_count']), 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'end_date': deserialize.iso8601_datetime(payload['end_date']), 'include_subaccounts': payload['include_subaccounts'], 'issues': payload['issues'], 'quality_score_average': deserialize.decimal(payload['quality_score_average']), 'quality_score_median': deserialize.decimal(payload['quality_score_median']), 'quality_score_standard_deviation': deserialize.decimal(payload['quality_score_standard_deviation']), 'sid': payload['sid'], 'start_date': deserialize.iso8601_datetime(payload['start_date']), 'status': payload['status'], } # Context self._context = None self._solution = {'account_sid': account_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.api.v2010.account.call.feedback_summary.FeedbackSummaryContext """ if self._context is None: self._context = FeedbackSummaryContext( self._version, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def call_count(self): """ :returns: The call_count :rtype: unicode """ return self._properties['call_count'] @property def call_feedback_count(self): """ :returns: The call_feedback_count :rtype: unicode """ return self._properties['call_feedback_count'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def end_date(self): """ :returns: The end_date :rtype: datetime """ return self._properties['end_date'] @property def include_subaccounts(self): """ :returns: The include_subaccounts :rtype: bool """ return self._properties['include_subaccounts'] @property def issues(self): """ :returns: The issues :rtype: unicode """ return self._properties['issues'] @property def quality_score_average(self): """ :returns: The quality_score_average :rtype: unicode """ return self._properties['quality_score_average'] @property def quality_score_median(self): """ :returns: The quality_score_median :rtype: unicode """ return self._properties['quality_score_median'] @property def quality_score_standard_deviation(self): """ :returns: The quality_score_standard_deviation :rtype: unicode """ return self._properties['quality_score_standard_deviation'] @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def start_date(self): """ :returns: The start_date :rtype: datetime """ return self._properties['start_date'] @property def status(self): """ :returns: The status :rtype: FeedbackSummaryInstance.Status """ return self._properties['status'] def fetch(self): """ Fetch a FeedbackSummaryInstance :returns: Fetched FeedbackSummaryInstance :rtype: twilio.rest.api.v2010.account.call.feedback_summary.FeedbackSummaryInstance """ return self._proxy.fetch() def delete(self): """ Deletes the FeedbackSummaryInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/call/notification.py000066400000000000000000000414571317472742600256210ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize 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.page import Page class NotificationList(ListResource): """ """ def __init__(self, version, account_sid, call_sid): """ Initialize the NotificationList :param Version version: Version that contains the resource :param account_sid: The account_sid :param call_sid: The call_sid :returns: twilio.rest.api.v2010.account.call.notification.NotificationList :rtype: twilio.rest.api.v2010.account.call.notification.NotificationList """ super(NotificationList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'call_sid': call_sid,} self._uri = '/Accounts/{account_sid}/Calls/{call_sid}/Notifications.json'.format(**self._solution) def stream(self, log=values.unset, message_date_before=values.unset, message_date=values.unset, message_date_after=values.unset, limit=None, page_size=None): """ Streams NotificationInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param unicode log: The log :param date message_date_before: The message_date :param date message_date: The message_date :param date message_date_after: The message_date :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.call.notification.NotificationInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( log=log, message_date_before=message_date_before, message_date=message_date, message_date_after=message_date_after, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, log=values.unset, message_date_before=values.unset, message_date=values.unset, message_date_after=values.unset, limit=None, page_size=None): """ Lists NotificationInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param unicode log: The log :param date message_date_before: The message_date :param date message_date: The message_date :param date message_date_after: The message_date :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.call.notification.NotificationInstance] """ return list(self.stream( log=log, message_date_before=message_date_before, message_date=message_date, message_date_after=message_date_after, limit=limit, page_size=page_size, )) def page(self, log=values.unset, message_date_before=values.unset, message_date=values.unset, message_date_after=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of NotificationInstance records from the API. Request is executed immediately :param unicode log: The log :param date message_date_before: The message_date :param date message_date: The message_date :param date message_date_after: The message_date :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of NotificationInstance :rtype: twilio.rest.api.v2010.account.call.notification.NotificationPage """ params = values.of({ 'Log': log, 'MessageDate<': serialize.iso8601_date(message_date_before), 'MessageDate': serialize.iso8601_date(message_date), 'MessageDate>': serialize.iso8601_date(message_date_after), 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return NotificationPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of NotificationInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of NotificationInstance :rtype: twilio.rest.api.v2010.account.call.notification.NotificationPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return NotificationPage(self._version, response, self._solution) def get(self, sid): """ Constructs a NotificationContext :param sid: The sid :returns: twilio.rest.api.v2010.account.call.notification.NotificationContext :rtype: twilio.rest.api.v2010.account.call.notification.NotificationContext """ return NotificationContext( self._version, account_sid=self._solution['account_sid'], call_sid=self._solution['call_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a NotificationContext :param sid: The sid :returns: twilio.rest.api.v2010.account.call.notification.NotificationContext :rtype: twilio.rest.api.v2010.account.call.notification.NotificationContext """ return NotificationContext( self._version, account_sid=self._solution['account_sid'], call_sid=self._solution['call_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class NotificationPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the NotificationPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param call_sid: The call_sid :returns: twilio.rest.api.v2010.account.call.notification.NotificationPage :rtype: twilio.rest.api.v2010.account.call.notification.NotificationPage """ super(NotificationPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of NotificationInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.call.notification.NotificationInstance :rtype: twilio.rest.api.v2010.account.call.notification.NotificationInstance """ return NotificationInstance( self._version, payload, account_sid=self._solution['account_sid'], call_sid=self._solution['call_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class NotificationContext(InstanceContext): """ """ def __init__(self, version, account_sid, call_sid, sid): """ Initialize the NotificationContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param call_sid: The call_sid :param sid: The sid :returns: twilio.rest.api.v2010.account.call.notification.NotificationContext :rtype: twilio.rest.api.v2010.account.call.notification.NotificationContext """ super(NotificationContext, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'call_sid': call_sid, 'sid': sid,} self._uri = '/Accounts/{account_sid}/Calls/{call_sid}/Notifications/{sid}.json'.format(**self._solution) def fetch(self): """ Fetch a NotificationInstance :returns: Fetched NotificationInstance :rtype: twilio.rest.api.v2010.account.call.notification.NotificationInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return NotificationInstance( self._version, payload, account_sid=self._solution['account_sid'], call_sid=self._solution['call_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the NotificationInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class NotificationInstance(InstanceResource): """ """ def __init__(self, version, payload, account_sid, call_sid, sid=None): """ Initialize the NotificationInstance :returns: twilio.rest.api.v2010.account.call.notification.NotificationInstance :rtype: twilio.rest.api.v2010.account.call.notification.NotificationInstance """ super(NotificationInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'api_version': payload['api_version'], 'call_sid': payload['call_sid'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'error_code': payload['error_code'], 'log': payload['log'], 'message_date': deserialize.rfc2822_datetime(payload['message_date']), 'message_text': payload['message_text'], 'more_info': payload['more_info'], 'request_method': payload['request_method'], 'request_url': payload['request_url'], 'sid': payload['sid'], 'uri': payload['uri'], 'request_variables': payload.get('request_variables'), 'response_body': payload.get('response_body'), 'response_headers': payload.get('response_headers'), } # Context self._context = None self._solution = { 'account_sid': account_sid, 'call_sid': call_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: NotificationContext for this NotificationInstance :rtype: twilio.rest.api.v2010.account.call.notification.NotificationContext """ if self._context is None: self._context = NotificationContext( self._version, account_sid=self._solution['account_sid'], call_sid=self._solution['call_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def api_version(self): """ :returns: The api_version :rtype: unicode """ return self._properties['api_version'] @property def call_sid(self): """ :returns: The call_sid :rtype: unicode """ return self._properties['call_sid'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def error_code(self): """ :returns: The error_code :rtype: unicode """ return self._properties['error_code'] @property def log(self): """ :returns: The log :rtype: unicode """ return self._properties['log'] @property def message_date(self): """ :returns: The message_date :rtype: datetime """ return self._properties['message_date'] @property def message_text(self): """ :returns: The message_text :rtype: unicode """ return self._properties['message_text'] @property def more_info(self): """ :returns: The more_info :rtype: unicode """ return self._properties['more_info'] @property def request_method(self): """ :returns: The request_method :rtype: unicode """ return self._properties['request_method'] @property def request_url(self): """ :returns: The request_url :rtype: unicode """ return self._properties['request_url'] @property def request_variables(self): """ :returns: The request_variables :rtype: unicode """ return self._properties['request_variables'] @property def response_body(self): """ :returns: The response_body :rtype: unicode """ return self._properties['response_body'] @property def response_headers(self): """ :returns: The response_headers :rtype: unicode """ return self._properties['response_headers'] @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def fetch(self): """ Fetch a NotificationInstance :returns: Fetched NotificationInstance :rtype: twilio.rest.api.v2010.account.call.notification.NotificationInstance """ return self._proxy.fetch() def delete(self): """ Deletes the NotificationInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/call/recording.py000066400000000000000000000356741317472742600251130ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize 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.page import Page class RecordingList(ListResource): """ """ def __init__(self, version, account_sid, call_sid): """ Initialize the RecordingList :param Version version: Version that contains the resource :param account_sid: The account_sid :param call_sid: The call_sid :returns: twilio.rest.api.v2010.account.call.recording.RecordingList :rtype: twilio.rest.api.v2010.account.call.recording.RecordingList """ super(RecordingList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'call_sid': call_sid,} self._uri = '/Accounts/{account_sid}/Calls/{call_sid}/Recordings.json'.format(**self._solution) def stream(self, date_created_before=values.unset, date_created=values.unset, date_created_after=values.unset, limit=None, page_size=None): """ Streams RecordingInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param date date_created_before: The date_created :param date date_created: The date_created :param date date_created_after: The date_created :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.call.recording.RecordingInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( date_created_before=date_created_before, date_created=date_created, date_created_after=date_created_after, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, date_created_before=values.unset, date_created=values.unset, date_created_after=values.unset, limit=None, page_size=None): """ Lists RecordingInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param date date_created_before: The date_created :param date date_created: The date_created :param date date_created_after: The date_created :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.call.recording.RecordingInstance] """ return list(self.stream( date_created_before=date_created_before, date_created=date_created, date_created_after=date_created_after, limit=limit, page_size=page_size, )) def page(self, date_created_before=values.unset, date_created=values.unset, date_created_after=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of RecordingInstance records from the API. Request is executed immediately :param date date_created_before: The date_created :param date date_created: The date_created :param date date_created_after: The date_created :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of RecordingInstance :rtype: twilio.rest.api.v2010.account.call.recording.RecordingPage """ params = values.of({ 'DateCreated<': serialize.iso8601_date(date_created_before), 'DateCreated': serialize.iso8601_date(date_created), 'DateCreated>': serialize.iso8601_date(date_created_after), 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return RecordingPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of RecordingInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of RecordingInstance :rtype: twilio.rest.api.v2010.account.call.recording.RecordingPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return RecordingPage(self._version, response, self._solution) def get(self, sid): """ Constructs a RecordingContext :param sid: The sid :returns: twilio.rest.api.v2010.account.call.recording.RecordingContext :rtype: twilio.rest.api.v2010.account.call.recording.RecordingContext """ return RecordingContext( self._version, account_sid=self._solution['account_sid'], call_sid=self._solution['call_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a RecordingContext :param sid: The sid :returns: twilio.rest.api.v2010.account.call.recording.RecordingContext :rtype: twilio.rest.api.v2010.account.call.recording.RecordingContext """ return RecordingContext( self._version, account_sid=self._solution['account_sid'], call_sid=self._solution['call_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class RecordingPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the RecordingPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param call_sid: The call_sid :returns: twilio.rest.api.v2010.account.call.recording.RecordingPage :rtype: twilio.rest.api.v2010.account.call.recording.RecordingPage """ super(RecordingPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of RecordingInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.call.recording.RecordingInstance :rtype: twilio.rest.api.v2010.account.call.recording.RecordingInstance """ return RecordingInstance( self._version, payload, account_sid=self._solution['account_sid'], call_sid=self._solution['call_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class RecordingContext(InstanceContext): """ """ def __init__(self, version, account_sid, call_sid, sid): """ Initialize the RecordingContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param call_sid: The call_sid :param sid: The sid :returns: twilio.rest.api.v2010.account.call.recording.RecordingContext :rtype: twilio.rest.api.v2010.account.call.recording.RecordingContext """ super(RecordingContext, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'call_sid': call_sid, 'sid': sid,} self._uri = '/Accounts/{account_sid}/Calls/{call_sid}/Recordings/{sid}.json'.format(**self._solution) def fetch(self): """ Fetch a RecordingInstance :returns: Fetched RecordingInstance :rtype: twilio.rest.api.v2010.account.call.recording.RecordingInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return RecordingInstance( self._version, payload, account_sid=self._solution['account_sid'], call_sid=self._solution['call_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the RecordingInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class RecordingInstance(InstanceResource): """ """ def __init__(self, version, payload, account_sid, call_sid, sid=None): """ Initialize the RecordingInstance :returns: twilio.rest.api.v2010.account.call.recording.RecordingInstance :rtype: twilio.rest.api.v2010.account.call.recording.RecordingInstance """ super(RecordingInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'api_version': payload['api_version'], 'call_sid': payload['call_sid'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'duration': payload['duration'], 'sid': payload['sid'], 'price': deserialize.decimal(payload['price']), 'uri': payload['uri'], 'encryption_details': payload['encryption_details'], 'error_code': deserialize.integer(payload['error_code']), } # Context self._context = None self._solution = { 'account_sid': account_sid, 'call_sid': call_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: RecordingContext for this RecordingInstance :rtype: twilio.rest.api.v2010.account.call.recording.RecordingContext """ if self._context is None: self._context = RecordingContext( self._version, account_sid=self._solution['account_sid'], call_sid=self._solution['call_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def api_version(self): """ :returns: The api_version :rtype: unicode """ return self._properties['api_version'] @property def call_sid(self): """ :returns: The call_sid :rtype: unicode """ return self._properties['call_sid'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def duration(self): """ :returns: The duration :rtype: unicode """ return self._properties['duration'] @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def price(self): """ :returns: The price :rtype: unicode """ return self._properties['price'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] @property def encryption_details(self): """ :returns: The encryption_details :rtype: dict """ return self._properties['encryption_details'] @property def error_code(self): """ :returns: The error_code :rtype: unicode """ return self._properties['error_code'] def fetch(self): """ Fetch a RecordingInstance :returns: Fetched RecordingInstance :rtype: twilio.rest.api.v2010.account.call.recording.RecordingInstance """ return self._proxy.fetch() def delete(self): """ Deletes the RecordingInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/conference/000077500000000000000000000000001317472742600237425ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/api/v2010/account/conference/__init__.py000066400000000000000000000444111317472742600260570ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize 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.page import Page from twilio.rest.api.v2010.account.conference.participant import ParticipantList class ConferenceList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the ConferenceList :param Version version: Version that contains the resource :param account_sid: The unique sid that identifies this account :returns: twilio.rest.api.v2010.account.conference.ConferenceList :rtype: twilio.rest.api.v2010.account.conference.ConferenceList """ super(ConferenceList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/Conferences.json'.format(**self._solution) def stream(self, date_created_before=values.unset, date_created=values.unset, date_created_after=values.unset, date_updated_before=values.unset, date_updated=values.unset, date_updated_after=values.unset, friendly_name=values.unset, status=values.unset, limit=None, page_size=None): """ Streams ConferenceInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param date date_created_before: Filter by date created :param date date_created: Filter by date created :param date date_created_after: Filter by date created :param date date_updated_before: Filter by date updated :param date date_updated: Filter by date updated :param date date_updated_after: Filter by date updated :param unicode friendly_name: Filter by friendly name :param ConferenceInstance.Status status: The status of the conference :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.conference.ConferenceInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( date_created_before=date_created_before, date_created=date_created, date_created_after=date_created_after, date_updated_before=date_updated_before, date_updated=date_updated, date_updated_after=date_updated_after, friendly_name=friendly_name, status=status, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, date_created_before=values.unset, date_created=values.unset, date_created_after=values.unset, date_updated_before=values.unset, date_updated=values.unset, date_updated_after=values.unset, friendly_name=values.unset, status=values.unset, limit=None, page_size=None): """ Lists ConferenceInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param date date_created_before: Filter by date created :param date date_created: Filter by date created :param date date_created_after: Filter by date created :param date date_updated_before: Filter by date updated :param date date_updated: Filter by date updated :param date date_updated_after: Filter by date updated :param unicode friendly_name: Filter by friendly name :param ConferenceInstance.Status status: The status of the conference :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.conference.ConferenceInstance] """ return list(self.stream( date_created_before=date_created_before, date_created=date_created, date_created_after=date_created_after, date_updated_before=date_updated_before, date_updated=date_updated, date_updated_after=date_updated_after, friendly_name=friendly_name, status=status, limit=limit, page_size=page_size, )) def page(self, date_created_before=values.unset, date_created=values.unset, date_created_after=values.unset, date_updated_before=values.unset, date_updated=values.unset, date_updated_after=values.unset, friendly_name=values.unset, status=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of ConferenceInstance records from the API. Request is executed immediately :param date date_created_before: Filter by date created :param date date_created: Filter by date created :param date date_created_after: Filter by date created :param date date_updated_before: Filter by date updated :param date date_updated: Filter by date updated :param date date_updated_after: Filter by date updated :param unicode friendly_name: Filter by friendly name :param ConferenceInstance.Status status: The status of the conference :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of ConferenceInstance :rtype: twilio.rest.api.v2010.account.conference.ConferencePage """ params = values.of({ 'DateCreated<': serialize.iso8601_date(date_created_before), 'DateCreated': serialize.iso8601_date(date_created), 'DateCreated>': serialize.iso8601_date(date_created_after), 'DateUpdated<': serialize.iso8601_date(date_updated_before), 'DateUpdated': serialize.iso8601_date(date_updated), 'DateUpdated>': serialize.iso8601_date(date_updated_after), 'FriendlyName': friendly_name, 'Status': status, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return ConferencePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of ConferenceInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of ConferenceInstance :rtype: twilio.rest.api.v2010.account.conference.ConferencePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return ConferencePage(self._version, response, self._solution) def get(self, sid): """ Constructs a ConferenceContext :param sid: Fetch by unique conference Sid :returns: twilio.rest.api.v2010.account.conference.ConferenceContext :rtype: twilio.rest.api.v2010.account.conference.ConferenceContext """ return ConferenceContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __call__(self, sid): """ Constructs a ConferenceContext :param sid: Fetch by unique conference Sid :returns: twilio.rest.api.v2010.account.conference.ConferenceContext :rtype: twilio.rest.api.v2010.account.conference.ConferenceContext """ return ConferenceContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ConferencePage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the ConferencePage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The unique sid that identifies this account :returns: twilio.rest.api.v2010.account.conference.ConferencePage :rtype: twilio.rest.api.v2010.account.conference.ConferencePage """ super(ConferencePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of ConferenceInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.conference.ConferenceInstance :rtype: twilio.rest.api.v2010.account.conference.ConferenceInstance """ return ConferenceInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ConferenceContext(InstanceContext): """ """ def __init__(self, version, account_sid, sid): """ Initialize the ConferenceContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param sid: Fetch by unique conference Sid :returns: twilio.rest.api.v2010.account.conference.ConferenceContext :rtype: twilio.rest.api.v2010.account.conference.ConferenceContext """ super(ConferenceContext, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'sid': sid,} self._uri = '/Accounts/{account_sid}/Conferences/{sid}.json'.format(**self._solution) # Dependents self._participants = None def fetch(self): """ Fetch a ConferenceInstance :returns: Fetched ConferenceInstance :rtype: twilio.rest.api.v2010.account.conference.ConferenceInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return ConferenceInstance( self._version, payload, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) def update(self, status=values.unset): """ Update the ConferenceInstance :param ConferenceInstance.UpdateStatus status: The status :returns: Updated ConferenceInstance :rtype: twilio.rest.api.v2010.account.conference.ConferenceInstance """ data = values.of({'Status': status,}) payload = self._version.update( 'POST', self._uri, data=data, ) return ConferenceInstance( self._version, payload, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) @property def participants(self): """ Access the participants :returns: twilio.rest.api.v2010.account.conference.participant.ParticipantList :rtype: twilio.rest.api.v2010.account.conference.participant.ParticipantList """ if self._participants is None: self._participants = ParticipantList( self._version, account_sid=self._solution['account_sid'], conference_sid=self._solution['sid'], ) return self._participants def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class ConferenceInstance(InstanceResource): """ """ class Status(object): INIT = "init" IN_PROGRESS = "in-progress" COMPLETED = "completed" class UpdateStatus(object): COMPLETED = "completed" def __init__(self, version, payload, account_sid, sid=None): """ Initialize the ConferenceInstance :returns: twilio.rest.api.v2010.account.conference.ConferenceInstance :rtype: twilio.rest.api.v2010.account.conference.ConferenceInstance """ super(ConferenceInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'api_version': payload['api_version'], 'friendly_name': payload['friendly_name'], 'region': payload['region'], 'sid': payload['sid'], 'status': payload['status'], 'uri': payload['uri'], 'subresource_uris': payload['subresource_uris'], } # Context self._context = None self._solution = {'account_sid': account_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: ConferenceContext for this ConferenceInstance :rtype: twilio.rest.api.v2010.account.conference.ConferenceContext """ if self._context is None: self._context = ConferenceContext( self._version, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: The unique sid that identifies this account :rtype: unicode """ return self._properties['account_sid'] @property def date_created(self): """ :returns: The date this resource was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this resource was last updated :rtype: datetime """ return self._properties['date_updated'] @property def api_version(self): """ :returns: The api_version :rtype: unicode """ return self._properties['api_version'] @property def friendly_name(self): """ :returns: A human readable description of this resource :rtype: unicode """ return self._properties['friendly_name'] @property def region(self): """ :returns: The region :rtype: unicode """ return self._properties['region'] @property def sid(self): """ :returns: A string that uniquely identifies this conference :rtype: unicode """ return self._properties['sid'] @property def status(self): """ :returns: The status of the conference :rtype: ConferenceInstance.Status """ return self._properties['status'] @property def uri(self): """ :returns: The URI for this resource :rtype: unicode """ return self._properties['uri'] @property def subresource_uris(self): """ :returns: The subresource_uris :rtype: unicode """ return self._properties['subresource_uris'] def fetch(self): """ Fetch a ConferenceInstance :returns: Fetched ConferenceInstance :rtype: twilio.rest.api.v2010.account.conference.ConferenceInstance """ return self._proxy.fetch() def update(self, status=values.unset): """ Update the ConferenceInstance :param ConferenceInstance.UpdateStatus status: The status :returns: Updated ConferenceInstance :rtype: twilio.rest.api.v2010.account.conference.ConferenceInstance """ return self._proxy.update(status=status,) @property def participants(self): """ Access the participants :returns: twilio.rest.api.v2010.account.conference.participant.ParticipantList :rtype: twilio.rest.api.v2010.account.conference.participant.ParticipantList """ return self._proxy.participants def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/conference/participant.py000066400000000000000000000547271317472742600266510ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class ParticipantList(ListResource): """ """ def __init__(self, version, account_sid, conference_sid): """ Initialize the ParticipantList :param Version version: Version that contains the resource :param account_sid: The unique sid that identifies this account :param conference_sid: A string that uniquely identifies this conference :returns: twilio.rest.api.v2010.account.conference.participant.ParticipantList :rtype: twilio.rest.api.v2010.account.conference.participant.ParticipantList """ super(ParticipantList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'conference_sid': conference_sid,} self._uri = '/Accounts/{account_sid}/Conferences/{conference_sid}/Participants.json'.format(**self._solution) def create(self, from_, to, status_callback=values.unset, status_callback_method=values.unset, status_callback_event=values.unset, timeout=values.unset, record=values.unset, muted=values.unset, beep=values.unset, start_conference_on_enter=values.unset, end_conference_on_exit=values.unset, wait_url=values.unset, wait_method=values.unset, early_media=values.unset, max_participants=values.unset, conference_record=values.unset, conference_trim=values.unset, conference_status_callback=values.unset, conference_status_callback_method=values.unset, conference_status_callback_event=values.unset, recording_channels=values.unset, recording_status_callback=values.unset, recording_status_callback_method=values.unset, sip_auth_username=values.unset, sip_auth_password=values.unset, region=values.unset, conference_recording_status_callback=values.unset, conference_recording_status_callback_method=values.unset): """ Create a new ParticipantInstance :param unicode from_: The from :param unicode to: The to :param unicode status_callback: The status_callback :param unicode status_callback_method: The status_callback_method :param unicode status_callback_event: The status_callback_event :param unicode timeout: The timeout :param bool record: The record :param bool muted: The muted :param unicode beep: The beep :param bool start_conference_on_enter: The start_conference_on_enter :param bool end_conference_on_exit: The end_conference_on_exit :param unicode wait_url: The wait_url :param unicode wait_method: The wait_method :param bool early_media: The early_media :param unicode max_participants: The max_participants :param unicode conference_record: The conference_record :param unicode conference_trim: The conference_trim :param unicode conference_status_callback: The conference_status_callback :param unicode conference_status_callback_method: The conference_status_callback_method :param unicode conference_status_callback_event: The conference_status_callback_event :param unicode recording_channels: The recording_channels :param unicode recording_status_callback: The recording_status_callback :param unicode recording_status_callback_method: The recording_status_callback_method :param unicode sip_auth_username: The sip_auth_username :param unicode sip_auth_password: The sip_auth_password :param unicode region: The region :param unicode conference_recording_status_callback: The conference_recording_status_callback :param unicode conference_recording_status_callback_method: The conference_recording_status_callback_method :returns: Newly created ParticipantInstance :rtype: twilio.rest.api.v2010.account.conference.participant.ParticipantInstance """ data = values.of({ 'From': from_, 'To': to, 'StatusCallback': status_callback, 'StatusCallbackMethod': status_callback_method, 'StatusCallbackEvent': status_callback_event, 'Timeout': timeout, 'Record': record, 'Muted': muted, 'Beep': beep, 'StartConferenceOnEnter': start_conference_on_enter, 'EndConferenceOnExit': end_conference_on_exit, 'WaitUrl': wait_url, 'WaitMethod': wait_method, 'EarlyMedia': early_media, 'MaxParticipants': max_participants, 'ConferenceRecord': conference_record, 'ConferenceTrim': conference_trim, 'ConferenceStatusCallback': conference_status_callback, 'ConferenceStatusCallbackMethod': conference_status_callback_method, 'ConferenceStatusCallbackEvent': conference_status_callback_event, 'RecordingChannels': recording_channels, 'RecordingStatusCallback': recording_status_callback, 'RecordingStatusCallbackMethod': recording_status_callback_method, 'SipAuthUsername': sip_auth_username, 'SipAuthPassword': sip_auth_password, 'Region': region, 'ConferenceRecordingStatusCallback': conference_recording_status_callback, 'ConferenceRecordingStatusCallbackMethod': conference_recording_status_callback_method, }) payload = self._version.create( 'POST', self._uri, data=data, ) return ParticipantInstance( self._version, payload, account_sid=self._solution['account_sid'], conference_sid=self._solution['conference_sid'], ) def stream(self, muted=values.unset, hold=values.unset, limit=None, page_size=None): """ Streams ParticipantInstance records from the API as a generator stream. This operation lazily loads 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 muted: Filter by muted participants :param bool hold: The hold :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.conference.participant.ParticipantInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(muted=muted, hold=hold, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, muted=values.unset, hold=values.unset, limit=None, page_size=None): """ Lists ParticipantInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param bool muted: Filter by muted participants :param bool hold: The hold :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.conference.participant.ParticipantInstance] """ return list(self.stream(muted=muted, hold=hold, limit=limit, page_size=page_size,)) def page(self, muted=values.unset, hold=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of ParticipantInstance records from the API. Request is executed immediately :param bool muted: Filter by muted participants :param bool hold: The hold :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of ParticipantInstance :rtype: twilio.rest.api.v2010.account.conference.participant.ParticipantPage """ params = values.of({ 'Muted': muted, 'Hold': hold, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return ParticipantPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of ParticipantInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of ParticipantInstance :rtype: twilio.rest.api.v2010.account.conference.participant.ParticipantPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return ParticipantPage(self._version, response, self._solution) def get(self, call_sid): """ Constructs a ParticipantContext :param call_sid: The call_sid :returns: twilio.rest.api.v2010.account.conference.participant.ParticipantContext :rtype: twilio.rest.api.v2010.account.conference.participant.ParticipantContext """ return ParticipantContext( self._version, account_sid=self._solution['account_sid'], conference_sid=self._solution['conference_sid'], call_sid=call_sid, ) def __call__(self, call_sid): """ Constructs a ParticipantContext :param call_sid: The call_sid :returns: twilio.rest.api.v2010.account.conference.participant.ParticipantContext :rtype: twilio.rest.api.v2010.account.conference.participant.ParticipantContext """ return ParticipantContext( self._version, account_sid=self._solution['account_sid'], conference_sid=self._solution['conference_sid'], call_sid=call_sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ParticipantPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the ParticipantPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The unique sid that identifies this account :param conference_sid: A string that uniquely identifies this conference :returns: twilio.rest.api.v2010.account.conference.participant.ParticipantPage :rtype: twilio.rest.api.v2010.account.conference.participant.ParticipantPage """ super(ParticipantPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of ParticipantInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.conference.participant.ParticipantInstance :rtype: twilio.rest.api.v2010.account.conference.participant.ParticipantInstance """ return ParticipantInstance( self._version, payload, account_sid=self._solution['account_sid'], conference_sid=self._solution['conference_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ParticipantContext(InstanceContext): """ """ def __init__(self, version, account_sid, conference_sid, call_sid): """ Initialize the ParticipantContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param conference_sid: The string that uniquely identifies this conference :param call_sid: The call_sid :returns: twilio.rest.api.v2010.account.conference.participant.ParticipantContext :rtype: twilio.rest.api.v2010.account.conference.participant.ParticipantContext """ super(ParticipantContext, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'conference_sid': conference_sid, 'call_sid': call_sid,} self._uri = '/Accounts/{account_sid}/Conferences/{conference_sid}/Participants/{call_sid}.json'.format(**self._solution) def fetch(self): """ Fetch a ParticipantInstance :returns: Fetched ParticipantInstance :rtype: twilio.rest.api.v2010.account.conference.participant.ParticipantInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return ParticipantInstance( self._version, payload, account_sid=self._solution['account_sid'], conference_sid=self._solution['conference_sid'], call_sid=self._solution['call_sid'], ) def update(self, muted=values.unset, hold=values.unset, hold_url=values.unset, hold_method=values.unset, announce_url=values.unset, announce_method=values.unset): """ Update the ParticipantInstance :param bool muted: Indicates if the participant should be muted :param bool hold: The hold :param unicode hold_url: The hold_url :param unicode hold_method: The hold_method :param unicode announce_url: The announce_url :param unicode announce_method: The announce_method :returns: Updated ParticipantInstance :rtype: twilio.rest.api.v2010.account.conference.participant.ParticipantInstance """ data = values.of({ 'Muted': muted, 'Hold': hold, 'HoldUrl': hold_url, 'HoldMethod': hold_method, 'AnnounceUrl': announce_url, 'AnnounceMethod': announce_method, }) payload = self._version.update( 'POST', self._uri, data=data, ) return ParticipantInstance( self._version, payload, account_sid=self._solution['account_sid'], conference_sid=self._solution['conference_sid'], call_sid=self._solution['call_sid'], ) def delete(self): """ Deletes the ParticipantInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class ParticipantInstance(InstanceResource): """ """ class Status(object): QUEUED = "queued" CONNECTING = "connecting" RINGING = "ringing" CONNECTED = "connected" COMPLETE = "complete" FAILED = "failed" def __init__(self, version, payload, account_sid, conference_sid, call_sid=None): """ Initialize the ParticipantInstance :returns: twilio.rest.api.v2010.account.conference.participant.ParticipantInstance :rtype: twilio.rest.api.v2010.account.conference.participant.ParticipantInstance """ super(ParticipantInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'call_sid': payload['call_sid'], 'conference_sid': payload['conference_sid'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'end_conference_on_exit': payload['end_conference_on_exit'], 'muted': payload['muted'], 'hold': payload['hold'], 'start_conference_on_enter': payload['start_conference_on_enter'], 'status': payload['status'], 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'conference_sid': conference_sid, 'call_sid': call_sid or self._properties['call_sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: ParticipantContext for this ParticipantInstance :rtype: twilio.rest.api.v2010.account.conference.participant.ParticipantContext """ if self._context is None: self._context = ParticipantContext( self._version, account_sid=self._solution['account_sid'], conference_sid=self._solution['conference_sid'], call_sid=self._solution['call_sid'], ) return self._context @property def account_sid(self): """ :returns: The unique sid that identifies this account :rtype: unicode """ return self._properties['account_sid'] @property def call_sid(self): """ :returns: A string that uniquely identifies this call :rtype: unicode """ return self._properties['call_sid'] @property def conference_sid(self): """ :returns: A string that uniquely identifies this conference :rtype: unicode """ return self._properties['conference_sid'] @property def date_created(self): """ :returns: The date this resource was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this resource was last updated :rtype: datetime """ return self._properties['date_updated'] @property def end_conference_on_exit(self): """ :returns: Indicates if the endConferenceOnExit was set :rtype: bool """ return self._properties['end_conference_on_exit'] @property def muted(self): """ :returns: Indicates if the participant is muted :rtype: bool """ return self._properties['muted'] @property def hold(self): """ :returns: The hold :rtype: bool """ return self._properties['hold'] @property def start_conference_on_enter(self): """ :returns: Indicates if the startConferenceOnEnter attribute was set :rtype: bool """ return self._properties['start_conference_on_enter'] @property def status(self): """ :returns: The status :rtype: ParticipantInstance.Status """ return self._properties['status'] @property def uri(self): """ :returns: The URI for this resource :rtype: unicode """ return self._properties['uri'] def fetch(self): """ Fetch a ParticipantInstance :returns: Fetched ParticipantInstance :rtype: twilio.rest.api.v2010.account.conference.participant.ParticipantInstance """ return self._proxy.fetch() def update(self, muted=values.unset, hold=values.unset, hold_url=values.unset, hold_method=values.unset, announce_url=values.unset, announce_method=values.unset): """ Update the ParticipantInstance :param bool muted: Indicates if the participant should be muted :param bool hold: The hold :param unicode hold_url: The hold_url :param unicode hold_method: The hold_method :param unicode announce_url: The announce_url :param unicode announce_method: The announce_method :returns: Updated ParticipantInstance :rtype: twilio.rest.api.v2010.account.conference.participant.ParticipantInstance """ return self._proxy.update( muted=muted, hold=hold, hold_url=hold_url, hold_method=hold_method, announce_url=announce_url, announce_method=announce_method, ) def delete(self): """ Deletes the ParticipantInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/connect_app.py000066400000000000000000000413121317472742600244770ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ 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.page import Page class ConnectAppList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the ConnectAppList :param Version version: Version that contains the resource :param account_sid: The unique sid that identifies this account :returns: twilio.rest.api.v2010.account.connect_app.ConnectAppList :rtype: twilio.rest.api.v2010.account.connect_app.ConnectAppList """ super(ConnectAppList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/ConnectApps.json'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams ConnectAppInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.connect_app.ConnectAppInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists ConnectAppInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.connect_app.ConnectAppInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of ConnectAppInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of ConnectAppInstance :rtype: twilio.rest.api.v2010.account.connect_app.ConnectAppPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return ConnectAppPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of ConnectAppInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of ConnectAppInstance :rtype: twilio.rest.api.v2010.account.connect_app.ConnectAppPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return ConnectAppPage(self._version, response, self._solution) def get(self, sid): """ Constructs a ConnectAppContext :param sid: Fetch by unique connect-app Sid :returns: twilio.rest.api.v2010.account.connect_app.ConnectAppContext :rtype: twilio.rest.api.v2010.account.connect_app.ConnectAppContext """ return ConnectAppContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __call__(self, sid): """ Constructs a ConnectAppContext :param sid: Fetch by unique connect-app Sid :returns: twilio.rest.api.v2010.account.connect_app.ConnectAppContext :rtype: twilio.rest.api.v2010.account.connect_app.ConnectAppContext """ return ConnectAppContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ConnectAppPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the ConnectAppPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The unique sid that identifies this account :returns: twilio.rest.api.v2010.account.connect_app.ConnectAppPage :rtype: twilio.rest.api.v2010.account.connect_app.ConnectAppPage """ super(ConnectAppPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of ConnectAppInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.connect_app.ConnectAppInstance :rtype: twilio.rest.api.v2010.account.connect_app.ConnectAppInstance """ return ConnectAppInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ConnectAppContext(InstanceContext): """ """ def __init__(self, version, account_sid, sid): """ Initialize the ConnectAppContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param sid: Fetch by unique connect-app Sid :returns: twilio.rest.api.v2010.account.connect_app.ConnectAppContext :rtype: twilio.rest.api.v2010.account.connect_app.ConnectAppContext """ super(ConnectAppContext, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'sid': sid,} self._uri = '/Accounts/{account_sid}/ConnectApps/{sid}.json'.format(**self._solution) def fetch(self): """ Fetch a ConnectAppInstance :returns: Fetched ConnectAppInstance :rtype: twilio.rest.api.v2010.account.connect_app.ConnectAppInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return ConnectAppInstance( self._version, payload, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) def update(self, authorize_redirect_url=values.unset, company_name=values.unset, deauthorize_callback_method=values.unset, deauthorize_callback_url=values.unset, description=values.unset, friendly_name=values.unset, homepage_url=values.unset, permissions=values.unset): """ Update the ConnectAppInstance :param unicode authorize_redirect_url: URIL Twilio sends requests when users authorize :param unicode company_name: The company name set for this Connect App. :param unicode deauthorize_callback_method: HTTP method Twilio WIll use making requests to the url :param unicode deauthorize_callback_url: URL Twilio will send a request when a user de-authorizes this app :param unicode description: A more detailed human readable description :param unicode friendly_name: A human readable name for the Connect App. :param unicode homepage_url: The URL users can obtain more information :param ConnectAppInstance.Permission permissions: The set of permissions that your ConnectApp requests. :returns: Updated ConnectAppInstance :rtype: twilio.rest.api.v2010.account.connect_app.ConnectAppInstance """ data = values.of({ 'AuthorizeRedirectUrl': authorize_redirect_url, 'CompanyName': company_name, 'DeauthorizeCallbackMethod': deauthorize_callback_method, 'DeauthorizeCallbackUrl': deauthorize_callback_url, 'Description': description, 'FriendlyName': friendly_name, 'HomepageUrl': homepage_url, 'Permissions': permissions, }) payload = self._version.update( 'POST', self._uri, data=data, ) return ConnectAppInstance( self._version, payload, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class ConnectAppInstance(InstanceResource): """ """ class Permission(object): GET_ALL = "get-all" POST_ALL = "post-all" def __init__(self, version, payload, account_sid, sid=None): """ Initialize the ConnectAppInstance :returns: twilio.rest.api.v2010.account.connect_app.ConnectAppInstance :rtype: twilio.rest.api.v2010.account.connect_app.ConnectAppInstance """ super(ConnectAppInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'authorize_redirect_url': payload['authorize_redirect_url'], 'company_name': payload['company_name'], 'deauthorize_callback_method': payload['deauthorize_callback_method'], 'deauthorize_callback_url': payload['deauthorize_callback_url'], 'description': payload['description'], 'friendly_name': payload['friendly_name'], 'homepage_url': payload['homepage_url'], 'permissions': payload['permissions'], 'sid': payload['sid'], 'uri': payload['uri'], } # Context self._context = None self._solution = {'account_sid': account_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: ConnectAppContext for this ConnectAppInstance :rtype: twilio.rest.api.v2010.account.connect_app.ConnectAppContext """ if self._context is None: self._context = ConnectAppContext( self._version, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: The unique sid that identifies this account :rtype: unicode """ return self._properties['account_sid'] @property def authorize_redirect_url(self): """ :returns: URIL Twilio sends requests when users authorize :rtype: unicode """ return self._properties['authorize_redirect_url'] @property def company_name(self): """ :returns: The company name set for this Connect App. :rtype: unicode """ return self._properties['company_name'] @property def deauthorize_callback_method(self): """ :returns: HTTP method Twilio WIll use making requests to the url :rtype: unicode """ return self._properties['deauthorize_callback_method'] @property def deauthorize_callback_url(self): """ :returns: URL Twilio will send a request when a user de-authorizes this app :rtype: unicode """ return self._properties['deauthorize_callback_url'] @property def description(self): """ :returns: A more detailed human readable description :rtype: unicode """ return self._properties['description'] @property def friendly_name(self): """ :returns: A human readable name for the Connect App. :rtype: unicode """ return self._properties['friendly_name'] @property def homepage_url(self): """ :returns: The URL users can obtain more information :rtype: unicode """ return self._properties['homepage_url'] @property def permissions(self): """ :returns: The set of permissions that your ConnectApp requests. :rtype: ConnectAppInstance.Permission """ return self._properties['permissions'] @property def sid(self): """ :returns: A string that uniquely identifies this connect-apps :rtype: unicode """ return self._properties['sid'] @property def uri(self): """ :returns: The URI for this resource :rtype: unicode """ return self._properties['uri'] def fetch(self): """ Fetch a ConnectAppInstance :returns: Fetched ConnectAppInstance :rtype: twilio.rest.api.v2010.account.connect_app.ConnectAppInstance """ return self._proxy.fetch() def update(self, authorize_redirect_url=values.unset, company_name=values.unset, deauthorize_callback_method=values.unset, deauthorize_callback_url=values.unset, description=values.unset, friendly_name=values.unset, homepage_url=values.unset, permissions=values.unset): """ Update the ConnectAppInstance :param unicode authorize_redirect_url: URIL Twilio sends requests when users authorize :param unicode company_name: The company name set for this Connect App. :param unicode deauthorize_callback_method: HTTP method Twilio WIll use making requests to the url :param unicode deauthorize_callback_url: URL Twilio will send a request when a user de-authorizes this app :param unicode description: A more detailed human readable description :param unicode friendly_name: A human readable name for the Connect App. :param unicode homepage_url: The URL users can obtain more information :param ConnectAppInstance.Permission permissions: The set of permissions that your ConnectApp requests. :returns: Updated ConnectAppInstance :rtype: twilio.rest.api.v2010.account.connect_app.ConnectAppInstance """ return self._proxy.update( authorize_redirect_url=authorize_redirect_url, company_name=company_name, deauthorize_callback_method=deauthorize_callback_method, deauthorize_callback_url=deauthorize_callback_url, description=description, friendly_name=friendly_name, homepage_url=homepage_url, permissions=permissions, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/incoming_phone_number/000077500000000000000000000000001317472742600261775ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/api/v2010/account/incoming_phone_number/__init__.py000066400000000000000000001074361317472742600303230ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on import AssignedAddOnList from twilio.rest.api.v2010.account.incoming_phone_number.local import LocalList from twilio.rest.api.v2010.account.incoming_phone_number.mobile import MobileList from twilio.rest.api.v2010.account.incoming_phone_number.toll_free import TollFreeList class IncomingPhoneNumberList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the IncomingPhoneNumberList :param Version version: Version that contains the resource :param account_sid: The unique sid that identifies this account :returns: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberList :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberList """ super(IncomingPhoneNumberList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/IncomingPhoneNumbers.json'.format(**self._solution) # Components self._local = None self._mobile = None self._toll_free = None def stream(self, beta=values.unset, friendly_name=values.unset, phone_number=values.unset, origin=values.unset, limit=None, page_size=None): """ Streams IncomingPhoneNumberInstance records from the API as a generator stream. This operation lazily loads 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 beta: Include new phone numbers :param unicode friendly_name: Filter by friendly name :param unicode phone_number: Filter by incoming phone number :param unicode origin: The origin :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( beta=beta, friendly_name=friendly_name, phone_number=phone_number, origin=origin, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, beta=values.unset, friendly_name=values.unset, phone_number=values.unset, origin=values.unset, limit=None, page_size=None): """ Lists IncomingPhoneNumberInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param bool beta: Include new phone numbers :param unicode friendly_name: Filter by friendly name :param unicode phone_number: Filter by incoming phone number :param unicode origin: The origin :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberInstance] """ return list(self.stream( beta=beta, friendly_name=friendly_name, phone_number=phone_number, origin=origin, limit=limit, page_size=page_size, )) def page(self, beta=values.unset, friendly_name=values.unset, phone_number=values.unset, origin=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of IncomingPhoneNumberInstance records from the API. Request is executed immediately :param bool beta: Include new phone numbers :param unicode friendly_name: Filter by friendly name :param unicode phone_number: Filter by incoming phone number :param unicode origin: The origin :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of IncomingPhoneNumberInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberPage """ params = values.of({ 'Beta': beta, 'FriendlyName': friendly_name, 'PhoneNumber': phone_number, 'Origin': origin, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return IncomingPhoneNumberPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of IncomingPhoneNumberInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of IncomingPhoneNumberInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return IncomingPhoneNumberPage(self._version, response, self._solution) def create(self, api_version=values.unset, friendly_name=values.unset, sms_application_sid=values.unset, sms_fallback_method=values.unset, sms_fallback_url=values.unset, sms_method=values.unset, sms_url=values.unset, status_callback=values.unset, status_callback_method=values.unset, voice_application_sid=values.unset, voice_caller_id_lookup=values.unset, voice_fallback_method=values.unset, voice_fallback_url=values.unset, voice_method=values.unset, voice_url=values.unset, emergency_status=values.unset, emergency_address_sid=values.unset, trunk_sid=values.unset, identity_sid=values.unset, address_sid=values.unset, phone_number=values.unset, area_code=values.unset): """ Create a new IncomingPhoneNumberInstance :param unicode api_version: The Twilio Rest API version to use :param unicode friendly_name: A human readable description of this resource :param unicode sms_application_sid: Unique string that identifies the application :param unicode sms_fallback_method: HTTP method used with sms fallback url :param unicode sms_fallback_url: URL Twilio will request if an error occurs in executing TwiML :param unicode sms_method: HTTP method to use with sms url :param unicode sms_url: URL Twilio will request when receiving an SMS :param unicode status_callback: URL Twilio will use to pass status parameters :param unicode status_callback_method: HTTP method twilio will use with status callback :param unicode voice_application_sid: The unique sid of the application to handle this number :param bool voice_caller_id_lookup: Look up the caller's caller-ID :param unicode voice_fallback_method: HTTP method used with fallback_url :param unicode voice_fallback_url: URL Twilio will request when an error occurs in TwiML :param unicode voice_method: HTTP method used with the voice url :param unicode voice_url: URL Twilio will request when receiving a call :param IncomingPhoneNumberInstance.EmergencyStatus emergency_status: The emergency_status :param unicode emergency_address_sid: The emergency_address_sid :param unicode trunk_sid: Unique string to identify the trunk :param unicode identity_sid: Unique string that identifies the identity associated with number :param unicode address_sid: Unique string that identifies the address associated with number :param unicode phone_number: The phone number :param unicode area_code: The desired area code for the new number :returns: Newly created IncomingPhoneNumberInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberInstance """ data = values.of({ 'PhoneNumber': phone_number, 'AreaCode': area_code, 'ApiVersion': api_version, 'FriendlyName': friendly_name, 'SmsApplicationSid': sms_application_sid, 'SmsFallbackMethod': sms_fallback_method, 'SmsFallbackUrl': sms_fallback_url, 'SmsMethod': sms_method, 'SmsUrl': sms_url, 'StatusCallback': status_callback, 'StatusCallbackMethod': status_callback_method, 'VoiceApplicationSid': voice_application_sid, 'VoiceCallerIdLookup': voice_caller_id_lookup, 'VoiceFallbackMethod': voice_fallback_method, 'VoiceFallbackUrl': voice_fallback_url, 'VoiceMethod': voice_method, 'VoiceUrl': voice_url, 'EmergencyStatus': emergency_status, 'EmergencyAddressSid': emergency_address_sid, 'TrunkSid': trunk_sid, 'IdentitySid': identity_sid, 'AddressSid': address_sid, }) payload = self._version.create( 'POST', self._uri, data=data, ) return IncomingPhoneNumberInstance(self._version, payload, account_sid=self._solution['account_sid'],) @property def local(self): """ Access the local :returns: twilio.rest.api.v2010.account.incoming_phone_number.local.LocalList :rtype: twilio.rest.api.v2010.account.incoming_phone_number.local.LocalList """ if self._local is None: self._local = LocalList(self._version, account_sid=self._solution['account_sid'],) return self._local @property def mobile(self): """ Access the mobile :returns: twilio.rest.api.v2010.account.incoming_phone_number.mobile.MobileList :rtype: twilio.rest.api.v2010.account.incoming_phone_number.mobile.MobileList """ if self._mobile is None: self._mobile = MobileList(self._version, account_sid=self._solution['account_sid'],) return self._mobile @property def toll_free(self): """ Access the toll_free :returns: twilio.rest.api.v2010.account.incoming_phone_number.toll_free.TollFreeList :rtype: twilio.rest.api.v2010.account.incoming_phone_number.toll_free.TollFreeList """ if self._toll_free is None: self._toll_free = TollFreeList(self._version, account_sid=self._solution['account_sid'],) return self._toll_free def get(self, sid): """ Constructs a IncomingPhoneNumberContext :param sid: Fetch by unique incoming-phone-number Sid :returns: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberContext :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberContext """ return IncomingPhoneNumberContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __call__(self, sid): """ Constructs a IncomingPhoneNumberContext :param sid: Fetch by unique incoming-phone-number Sid :returns: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberContext :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberContext """ return IncomingPhoneNumberContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class IncomingPhoneNumberPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the IncomingPhoneNumberPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The unique sid that identifies this account :returns: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberPage :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberPage """ super(IncomingPhoneNumberPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of IncomingPhoneNumberInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberInstance """ return IncomingPhoneNumberInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class IncomingPhoneNumberContext(InstanceContext): """ """ def __init__(self, version, account_sid, sid): """ Initialize the IncomingPhoneNumberContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param sid: Fetch by unique incoming-phone-number Sid :returns: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberContext :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberContext """ super(IncomingPhoneNumberContext, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'sid': sid,} self._uri = '/Accounts/{account_sid}/IncomingPhoneNumbers/{sid}.json'.format(**self._solution) # Dependents self._assigned_add_ons = None def update(self, account_sid=values.unset, api_version=values.unset, friendly_name=values.unset, sms_application_sid=values.unset, sms_fallback_method=values.unset, sms_fallback_url=values.unset, sms_method=values.unset, sms_url=values.unset, status_callback=values.unset, status_callback_method=values.unset, voice_application_sid=values.unset, voice_caller_id_lookup=values.unset, voice_fallback_method=values.unset, voice_fallback_url=values.unset, voice_method=values.unset, voice_url=values.unset, emergency_status=values.unset, emergency_address_sid=values.unset, trunk_sid=values.unset, voice_receive_mode=values.unset, identity_sid=values.unset, address_sid=values.unset): """ Update the IncomingPhoneNumberInstance :param unicode account_sid: The new owner of the phone number :param unicode api_version: The Twilio REST API version to use :param unicode friendly_name: A human readable description of this resource :param unicode sms_application_sid: Unique string that identifies the application :param unicode sms_fallback_method: HTTP method used with sms fallback url :param unicode sms_fallback_url: URL Twilio will request if an error occurs in executing TwiML :param unicode sms_method: HTTP method to use with sms url :param unicode sms_url: URL Twilio will request when receiving an SMS :param unicode status_callback: URL Twilio will use to pass status parameters :param unicode status_callback_method: HTTP method twilio will use with status callback :param unicode voice_application_sid: The unique sid of the application to handle this number :param bool voice_caller_id_lookup: Look up the caller's caller-ID :param unicode voice_fallback_method: HTTP method used with fallback_url :param unicode voice_fallback_url: URL Twilio will request when an error occurs in TwiML :param unicode voice_method: HTTP method used with the voice url :param unicode voice_url: URL Twilio will request when receiving a call :param IncomingPhoneNumberInstance.EmergencyStatus emergency_status: The emergency_status :param unicode emergency_address_sid: The emergency_address_sid :param unicode trunk_sid: Unique string to identify the trunk :param IncomingPhoneNumberInstance.VoiceReceiveMode voice_receive_mode: The voice_receive_mode :param unicode identity_sid: Unique string that identifies the identity associated with number :param unicode address_sid: Unique string that identifies the address associated with number :returns: Updated IncomingPhoneNumberInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberInstance """ data = values.of({ 'AccountSid': account_sid, 'ApiVersion': api_version, 'FriendlyName': friendly_name, 'SmsApplicationSid': sms_application_sid, 'SmsFallbackMethod': sms_fallback_method, 'SmsFallbackUrl': sms_fallback_url, 'SmsMethod': sms_method, 'SmsUrl': sms_url, 'StatusCallback': status_callback, 'StatusCallbackMethod': status_callback_method, 'VoiceApplicationSid': voice_application_sid, 'VoiceCallerIdLookup': voice_caller_id_lookup, 'VoiceFallbackMethod': voice_fallback_method, 'VoiceFallbackUrl': voice_fallback_url, 'VoiceMethod': voice_method, 'VoiceUrl': voice_url, 'EmergencyStatus': emergency_status, 'EmergencyAddressSid': emergency_address_sid, 'TrunkSid': trunk_sid, 'VoiceReceiveMode': voice_receive_mode, 'IdentitySid': identity_sid, 'AddressSid': address_sid, }) payload = self._version.update( 'POST', self._uri, data=data, ) return IncomingPhoneNumberInstance( self._version, payload, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) def fetch(self): """ Fetch a IncomingPhoneNumberInstance :returns: Fetched IncomingPhoneNumberInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return IncomingPhoneNumberInstance( self._version, payload, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the IncomingPhoneNumberInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) @property def assigned_add_ons(self): """ Access the assigned_add_ons :returns: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.AssignedAddOnList :rtype: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.AssignedAddOnList """ if self._assigned_add_ons is None: self._assigned_add_ons = AssignedAddOnList( self._version, account_sid=self._solution['account_sid'], resource_sid=self._solution['sid'], ) return self._assigned_add_ons def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class IncomingPhoneNumberInstance(InstanceResource): """ """ class AddressRequirement(object): NONE = "none" ANY = "any" LOCAL = "local" FOREIGN = "foreign" class EmergencyStatus(object): ACTIVE = "Active" INACTIVE = "Inactive" class VoiceReceiveMode(object): VOICE = "voice" FAX = "fax" def __init__(self, version, payload, account_sid, sid=None): """ Initialize the IncomingPhoneNumberInstance :returns: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberInstance """ super(IncomingPhoneNumberInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'address_sid': payload['address_sid'], 'address_requirements': payload['address_requirements'], 'api_version': payload['api_version'], 'beta': payload['beta'], 'capabilities': payload['capabilities'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'friendly_name': payload['friendly_name'], 'identity_sid': payload['identity_sid'], 'phone_number': payload['phone_number'], 'origin': payload['origin'], 'sid': payload['sid'], 'sms_application_sid': payload['sms_application_sid'], 'sms_fallback_method': payload['sms_fallback_method'], 'sms_fallback_url': payload['sms_fallback_url'], 'sms_method': payload['sms_method'], 'sms_url': payload['sms_url'], 'status_callback': payload['status_callback'], 'status_callback_method': payload['status_callback_method'], 'trunk_sid': payload['trunk_sid'], 'uri': payload['uri'], 'voice_application_sid': payload['voice_application_sid'], 'voice_caller_id_lookup': payload['voice_caller_id_lookup'], 'voice_fallback_method': payload['voice_fallback_method'], 'voice_fallback_url': payload['voice_fallback_url'], 'voice_method': payload['voice_method'], 'voice_url': payload['voice_url'], 'emergency_status': payload['emergency_status'], 'emergency_address_sid': payload['emergency_address_sid'], } # Context self._context = None self._solution = {'account_sid': account_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: IncomingPhoneNumberContext for this IncomingPhoneNumberInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberContext """ if self._context is None: self._context = IncomingPhoneNumberContext( self._version, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: The unique sid that identifies this account :rtype: unicode """ return self._properties['account_sid'] @property def address_sid(self): """ :returns: Unique string that identifies the address associated with number :rtype: unicode """ return self._properties['address_sid'] @property def address_requirements(self): """ :returns: Indicates if the customer requires an address :rtype: IncomingPhoneNumberInstance.AddressRequirement """ return self._properties['address_requirements'] @property def api_version(self): """ :returns: The Twilio REST API version to use :rtype: unicode """ return self._properties['api_version'] @property def beta(self): """ :returns: Indicates if the phone number is a beta number :rtype: bool """ return self._properties['beta'] @property def capabilities(self): """ :returns: Indicate if a phone can receive calls or messages :rtype: unicode """ return self._properties['capabilities'] @property def date_created(self): """ :returns: The date this resource was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this resource was last updated :rtype: datetime """ return self._properties['date_updated'] @property def friendly_name(self): """ :returns: A human readable description of this resouce :rtype: unicode """ return self._properties['friendly_name'] @property def identity_sid(self): """ :returns: Unique string that identifies the identity associated with number :rtype: unicode """ return self._properties['identity_sid'] @property def phone_number(self): """ :returns: The incoming phone number :rtype: unicode """ return self._properties['phone_number'] @property def origin(self): """ :returns: The origin :rtype: unicode """ return self._properties['origin'] @property def sid(self): """ :returns: A string that uniquely identifies this resource :rtype: unicode """ return self._properties['sid'] @property def sms_application_sid(self): """ :returns: Unique string that identifies the application :rtype: unicode """ return self._properties['sms_application_sid'] @property def sms_fallback_method(self): """ :returns: HTTP method used with sms fallback url :rtype: unicode """ return self._properties['sms_fallback_method'] @property def sms_fallback_url(self): """ :returns: URL Twilio will request if an error occurs in executing TwiML :rtype: unicode """ return self._properties['sms_fallback_url'] @property def sms_method(self): """ :returns: HTTP method to use with sms url :rtype: unicode """ return self._properties['sms_method'] @property def sms_url(self): """ :returns: URL Twilio will request when receiving an SMS :rtype: unicode """ return self._properties['sms_url'] @property def status_callback(self): """ :returns: URL Twilio will use to pass status parameters :rtype: unicode """ return self._properties['status_callback'] @property def status_callback_method(self): """ :returns: HTTP method twilio will use with status callback :rtype: unicode """ return self._properties['status_callback_method'] @property def trunk_sid(self): """ :returns: Unique string to identify the trunk :rtype: unicode """ return self._properties['trunk_sid'] @property def uri(self): """ :returns: The URI for this resource :rtype: unicode """ return self._properties['uri'] @property def voice_application_sid(self): """ :returns: The unique sid of the application to handle this number :rtype: unicode """ return self._properties['voice_application_sid'] @property def voice_caller_id_lookup(self): """ :returns: Look up the caller's caller-ID :rtype: bool """ return self._properties['voice_caller_id_lookup'] @property def voice_fallback_method(self): """ :returns: HTTP method used with fallback_url :rtype: unicode """ return self._properties['voice_fallback_method'] @property def voice_fallback_url(self): """ :returns: URL Twilio will request when an error occurs in TwiML :rtype: unicode """ return self._properties['voice_fallback_url'] @property def voice_method(self): """ :returns: HTTP method used with the voice url :rtype: unicode """ return self._properties['voice_method'] @property def voice_url(self): """ :returns: URL Twilio will request when receiving a call :rtype: unicode """ return self._properties['voice_url'] @property def emergency_status(self): """ :returns: The emergency_status :rtype: IncomingPhoneNumberInstance.EmergencyStatus """ return self._properties['emergency_status'] @property def emergency_address_sid(self): """ :returns: The emergency_address_sid :rtype: unicode """ return self._properties['emergency_address_sid'] def update(self, account_sid=values.unset, api_version=values.unset, friendly_name=values.unset, sms_application_sid=values.unset, sms_fallback_method=values.unset, sms_fallback_url=values.unset, sms_method=values.unset, sms_url=values.unset, status_callback=values.unset, status_callback_method=values.unset, voice_application_sid=values.unset, voice_caller_id_lookup=values.unset, voice_fallback_method=values.unset, voice_fallback_url=values.unset, voice_method=values.unset, voice_url=values.unset, emergency_status=values.unset, emergency_address_sid=values.unset, trunk_sid=values.unset, voice_receive_mode=values.unset, identity_sid=values.unset, address_sid=values.unset): """ Update the IncomingPhoneNumberInstance :param unicode account_sid: The new owner of the phone number :param unicode api_version: The Twilio REST API version to use :param unicode friendly_name: A human readable description of this resource :param unicode sms_application_sid: Unique string that identifies the application :param unicode sms_fallback_method: HTTP method used with sms fallback url :param unicode sms_fallback_url: URL Twilio will request if an error occurs in executing TwiML :param unicode sms_method: HTTP method to use with sms url :param unicode sms_url: URL Twilio will request when receiving an SMS :param unicode status_callback: URL Twilio will use to pass status parameters :param unicode status_callback_method: HTTP method twilio will use with status callback :param unicode voice_application_sid: The unique sid of the application to handle this number :param bool voice_caller_id_lookup: Look up the caller's caller-ID :param unicode voice_fallback_method: HTTP method used with fallback_url :param unicode voice_fallback_url: URL Twilio will request when an error occurs in TwiML :param unicode voice_method: HTTP method used with the voice url :param unicode voice_url: URL Twilio will request when receiving a call :param IncomingPhoneNumberInstance.EmergencyStatus emergency_status: The emergency_status :param unicode emergency_address_sid: The emergency_address_sid :param unicode trunk_sid: Unique string to identify the trunk :param IncomingPhoneNumberInstance.VoiceReceiveMode voice_receive_mode: The voice_receive_mode :param unicode identity_sid: Unique string that identifies the identity associated with number :param unicode address_sid: Unique string that identifies the address associated with number :returns: Updated IncomingPhoneNumberInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberInstance """ return self._proxy.update( account_sid=account_sid, api_version=api_version, friendly_name=friendly_name, sms_application_sid=sms_application_sid, sms_fallback_method=sms_fallback_method, sms_fallback_url=sms_fallback_url, sms_method=sms_method, sms_url=sms_url, status_callback=status_callback, status_callback_method=status_callback_method, voice_application_sid=voice_application_sid, voice_caller_id_lookup=voice_caller_id_lookup, voice_fallback_method=voice_fallback_method, voice_fallback_url=voice_fallback_url, voice_method=voice_method, voice_url=voice_url, emergency_status=emergency_status, emergency_address_sid=emergency_address_sid, trunk_sid=trunk_sid, voice_receive_mode=voice_receive_mode, identity_sid=identity_sid, address_sid=address_sid, ) def fetch(self): """ Fetch a IncomingPhoneNumberInstance :returns: Fetched IncomingPhoneNumberInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.IncomingPhoneNumberInstance """ return self._proxy.fetch() def delete(self): """ Deletes the IncomingPhoneNumberInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() @property def assigned_add_ons(self): """ Access the assigned_add_ons :returns: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.AssignedAddOnList :rtype: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.AssignedAddOnList """ return self._proxy.assigned_add_ons def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/incoming_phone_number/assigned_add_on/000077500000000000000000000000001317472742600313005ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/api/v2010/account/incoming_phone_number/assigned_add_on/__init__.py000066400000000000000000000425631317472742600334230ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.assigned_add_on_extension import AssignedAddOnExtensionList class AssignedAddOnList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, account_sid, resource_sid): """ Initialize the AssignedAddOnList :param Version version: Version that contains the resource :param account_sid: The Account id that has installed this Add-on :param resource_sid: The Phone Number id that has installed this Add-on :returns: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.AssignedAddOnList :rtype: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.AssignedAddOnList """ super(AssignedAddOnList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'resource_sid': resource_sid,} self._uri = '/Accounts/{account_sid}/IncomingPhoneNumbers/{resource_sid}/AssignedAddOns.json'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams AssignedAddOnInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.AssignedAddOnInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists AssignedAddOnInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.AssignedAddOnInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of AssignedAddOnInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of AssignedAddOnInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.AssignedAddOnPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return AssignedAddOnPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of AssignedAddOnInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of AssignedAddOnInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.AssignedAddOnPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return AssignedAddOnPage(self._version, response, self._solution) def create(self, installed_add_on_sid): """ Create a new AssignedAddOnInstance :param unicode installed_add_on_sid: A string that uniquely identifies the Add-on installation :returns: Newly created AssignedAddOnInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.AssignedAddOnInstance """ data = values.of({'InstalledAddOnSid': installed_add_on_sid,}) payload = self._version.create( 'POST', self._uri, data=data, ) return AssignedAddOnInstance( self._version, payload, account_sid=self._solution['account_sid'], resource_sid=self._solution['resource_sid'], ) def get(self, sid): """ Constructs a AssignedAddOnContext :param sid: The unique Installed Add-on Sid :returns: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.AssignedAddOnContext :rtype: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.AssignedAddOnContext """ return AssignedAddOnContext( self._version, account_sid=self._solution['account_sid'], resource_sid=self._solution['resource_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a AssignedAddOnContext :param sid: The unique Installed Add-on Sid :returns: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.AssignedAddOnContext :rtype: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.AssignedAddOnContext """ return AssignedAddOnContext( self._version, account_sid=self._solution['account_sid'], resource_sid=self._solution['resource_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class AssignedAddOnPage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the AssignedAddOnPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The Account id that has installed this Add-on :param resource_sid: The Phone Number id that has installed this Add-on :returns: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.AssignedAddOnPage :rtype: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.AssignedAddOnPage """ super(AssignedAddOnPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of AssignedAddOnInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.AssignedAddOnInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.AssignedAddOnInstance """ return AssignedAddOnInstance( self._version, payload, account_sid=self._solution['account_sid'], resource_sid=self._solution['resource_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class AssignedAddOnContext(InstanceContext): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, account_sid, resource_sid, sid): """ Initialize the AssignedAddOnContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param resource_sid: The resource_sid :param sid: The unique Installed Add-on Sid :returns: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.AssignedAddOnContext :rtype: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.AssignedAddOnContext """ super(AssignedAddOnContext, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'resource_sid': resource_sid, 'sid': sid,} self._uri = '/Accounts/{account_sid}/IncomingPhoneNumbers/{resource_sid}/AssignedAddOns/{sid}.json'.format(**self._solution) # Dependents self._extensions = None def fetch(self): """ Fetch a AssignedAddOnInstance :returns: Fetched AssignedAddOnInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.AssignedAddOnInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return AssignedAddOnInstance( self._version, payload, account_sid=self._solution['account_sid'], resource_sid=self._solution['resource_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the AssignedAddOnInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) @property def extensions(self): """ Access the extensions :returns: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.assigned_add_on_extension.AssignedAddOnExtensionList :rtype: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.assigned_add_on_extension.AssignedAddOnExtensionList """ if self._extensions is None: self._extensions = AssignedAddOnExtensionList( self._version, account_sid=self._solution['account_sid'], resource_sid=self._solution['resource_sid'], assigned_add_on_sid=self._solution['sid'], ) return self._extensions def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class AssignedAddOnInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, payload, account_sid, resource_sid, sid=None): """ Initialize the AssignedAddOnInstance :returns: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.AssignedAddOnInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.AssignedAddOnInstance """ super(AssignedAddOnInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'resource_sid': payload['resource_sid'], 'friendly_name': payload['friendly_name'], 'description': payload['description'], 'configuration': payload['configuration'], 'unique_name': payload['unique_name'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], 'subresource_uris': payload['subresource_uris'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'resource_sid': resource_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: AssignedAddOnContext for this AssignedAddOnInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.AssignedAddOnContext """ if self._context is None: self._context = AssignedAddOnContext( self._version, account_sid=self._solution['account_sid'], resource_sid=self._solution['resource_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: A string that uniquely identifies this assigned Add-on installation :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The Account id that has installed this Add-on :rtype: unicode """ return self._properties['account_sid'] @property def resource_sid(self): """ :returns: The Phone Number id that has installed this Add-on :rtype: unicode """ return self._properties['resource_sid'] @property def friendly_name(self): """ :returns: A description of this Add-on installation :rtype: unicode """ return self._properties['friendly_name'] @property def description(self): """ :returns: A short description of the Add-on functionality :rtype: unicode """ return self._properties['description'] @property def configuration(self): """ :returns: The JSON object representing the current configuration :rtype: dict """ return self._properties['configuration'] @property def unique_name(self): """ :returns: The string that uniquely identifies this Add-on installation :rtype: unicode """ return self._properties['unique_name'] @property def date_created(self): """ :returns: The date this Add-on was installed :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this Add-on installation was last updated :rtype: datetime """ return self._properties['date_updated'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] @property def subresource_uris(self): """ :returns: The subresource_uris :rtype: unicode """ return self._properties['subresource_uris'] def fetch(self): """ Fetch a AssignedAddOnInstance :returns: Fetched AssignedAddOnInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.AssignedAddOnInstance """ return self._proxy.fetch() def delete(self): """ Deletes the AssignedAddOnInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() @property def extensions(self): """ Access the extensions :returns: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.assigned_add_on_extension.AssignedAddOnExtensionList :rtype: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.assigned_add_on_extension.AssignedAddOnExtensionList """ return self._proxy.extensions def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) assigned_add_on_extension.py000066400000000000000000000405701317472742600367760ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/api/v2010/account/incoming_phone_number/assigned_add_on# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ 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.page import Page class AssignedAddOnExtensionList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, account_sid, resource_sid, assigned_add_on_sid): """ Initialize the AssignedAddOnExtensionList :param Version version: Version that contains the resource :param account_sid: The Account id that has installed this Add-on :param resource_sid: The Phone Number id that has installed this Add-on :param assigned_add_on_sid: A string that uniquely identifies the assigned Add-on installation :returns: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.assigned_add_on_extension.AssignedAddOnExtensionList :rtype: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.assigned_add_on_extension.AssignedAddOnExtensionList """ super(AssignedAddOnExtensionList, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'resource_sid': resource_sid, 'assigned_add_on_sid': assigned_add_on_sid, } self._uri = '/Accounts/{account_sid}/IncomingPhoneNumbers/{resource_sid}/AssignedAddOns/{assigned_add_on_sid}/Extensions.json'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams AssignedAddOnExtensionInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.assigned_add_on_extension.AssignedAddOnExtensionInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists AssignedAddOnExtensionInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.assigned_add_on_extension.AssignedAddOnExtensionInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of AssignedAddOnExtensionInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of AssignedAddOnExtensionInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.assigned_add_on_extension.AssignedAddOnExtensionPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return AssignedAddOnExtensionPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of AssignedAddOnExtensionInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of AssignedAddOnExtensionInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.assigned_add_on_extension.AssignedAddOnExtensionPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return AssignedAddOnExtensionPage(self._version, response, self._solution) def get(self, sid): """ Constructs a AssignedAddOnExtensionContext :param sid: The unique Extension Sid :returns: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.assigned_add_on_extension.AssignedAddOnExtensionContext :rtype: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.assigned_add_on_extension.AssignedAddOnExtensionContext """ return AssignedAddOnExtensionContext( self._version, account_sid=self._solution['account_sid'], resource_sid=self._solution['resource_sid'], assigned_add_on_sid=self._solution['assigned_add_on_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a AssignedAddOnExtensionContext :param sid: The unique Extension Sid :returns: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.assigned_add_on_extension.AssignedAddOnExtensionContext :rtype: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.assigned_add_on_extension.AssignedAddOnExtensionContext """ return AssignedAddOnExtensionContext( self._version, account_sid=self._solution['account_sid'], resource_sid=self._solution['resource_sid'], assigned_add_on_sid=self._solution['assigned_add_on_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class AssignedAddOnExtensionPage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the AssignedAddOnExtensionPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The Account id that has installed this Add-on :param resource_sid: The Phone Number id that has installed this Add-on :param assigned_add_on_sid: A string that uniquely identifies the assigned Add-on installation :returns: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.assigned_add_on_extension.AssignedAddOnExtensionPage :rtype: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.assigned_add_on_extension.AssignedAddOnExtensionPage """ super(AssignedAddOnExtensionPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of AssignedAddOnExtensionInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.assigned_add_on_extension.AssignedAddOnExtensionInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.assigned_add_on_extension.AssignedAddOnExtensionInstance """ return AssignedAddOnExtensionInstance( self._version, payload, account_sid=self._solution['account_sid'], resource_sid=self._solution['resource_sid'], assigned_add_on_sid=self._solution['assigned_add_on_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class AssignedAddOnExtensionContext(InstanceContext): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, account_sid, resource_sid, assigned_add_on_sid, sid): """ Initialize the AssignedAddOnExtensionContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param resource_sid: The resource_sid :param assigned_add_on_sid: The assigned_add_on_sid :param sid: The unique Extension Sid :returns: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.assigned_add_on_extension.AssignedAddOnExtensionContext :rtype: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.assigned_add_on_extension.AssignedAddOnExtensionContext """ super(AssignedAddOnExtensionContext, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'resource_sid': resource_sid, 'assigned_add_on_sid': assigned_add_on_sid, 'sid': sid, } self._uri = '/Accounts/{account_sid}/IncomingPhoneNumbers/{resource_sid}/AssignedAddOns/{assigned_add_on_sid}/Extensions/{sid}.json'.format(**self._solution) def fetch(self): """ Fetch a AssignedAddOnExtensionInstance :returns: Fetched AssignedAddOnExtensionInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.assigned_add_on_extension.AssignedAddOnExtensionInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return AssignedAddOnExtensionInstance( self._version, payload, account_sid=self._solution['account_sid'], resource_sid=self._solution['resource_sid'], assigned_add_on_sid=self._solution['assigned_add_on_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class AssignedAddOnExtensionInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, payload, account_sid, resource_sid, assigned_add_on_sid, sid=None): """ Initialize the AssignedAddOnExtensionInstance :returns: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.assigned_add_on_extension.AssignedAddOnExtensionInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.assigned_add_on_extension.AssignedAddOnExtensionInstance """ super(AssignedAddOnExtensionInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'resource_sid': payload['resource_sid'], 'assigned_add_on_sid': payload['assigned_add_on_sid'], 'friendly_name': payload['friendly_name'], 'product_name': payload['product_name'], 'unique_name': payload['unique_name'], 'uri': payload['uri'], 'enabled': payload['enabled'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'resource_sid': resource_sid, 'assigned_add_on_sid': assigned_add_on_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: AssignedAddOnExtensionContext for this AssignedAddOnExtensionInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.assigned_add_on_extension.AssignedAddOnExtensionContext """ if self._context is None: self._context = AssignedAddOnExtensionContext( self._version, account_sid=self._solution['account_sid'], resource_sid=self._solution['resource_sid'], assigned_add_on_sid=self._solution['assigned_add_on_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: A string that uniquely identifies this Extension :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The Account id that has installed this Add-on :rtype: unicode """ return self._properties['account_sid'] @property def resource_sid(self): """ :returns: The Phone Number id that has installed this Add-on :rtype: unicode """ return self._properties['resource_sid'] @property def assigned_add_on_sid(self): """ :returns: A string that uniquely identifies the assigned Add-on installation :rtype: unicode """ return self._properties['assigned_add_on_sid'] @property def friendly_name(self): """ :returns: A human-readable description of this Extension :rtype: unicode """ return self._properties['friendly_name'] @property def product_name(self): """ :returns: A human-readable description of the Extension's Product :rtype: unicode """ return self._properties['product_name'] @property def unique_name(self): """ :returns: The string that uniquely identifies this Extension :rtype: unicode """ return self._properties['unique_name'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] @property def enabled(self): """ :returns: A Boolean indicating if the Extension will be invoked :rtype: bool """ return self._properties['enabled'] def fetch(self): """ Fetch a AssignedAddOnExtensionInstance :returns: Fetched AssignedAddOnExtensionInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.assigned_add_on.assigned_add_on_extension.AssignedAddOnExtensionInstance """ return self._proxy.fetch() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/incoming_phone_number/local.py000066400000000000000000000433651317472742600276560ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class LocalList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the LocalList :param Version version: Version that contains the resource :param account_sid: The unique sid that identifies this account :returns: twilio.rest.api.v2010.account.incoming_phone_number.local.LocalList :rtype: twilio.rest.api.v2010.account.incoming_phone_number.local.LocalList """ super(LocalList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/IncomingPhoneNumbers/Local.json'.format(**self._solution) def stream(self, beta=values.unset, friendly_name=values.unset, phone_number=values.unset, origin=values.unset, limit=None, page_size=None): """ Streams LocalInstance records from the API as a generator stream. This operation lazily loads 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 beta: The beta :param unicode friendly_name: The friendly_name :param unicode phone_number: The phone_number :param unicode origin: The origin :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.incoming_phone_number.local.LocalInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( beta=beta, friendly_name=friendly_name, phone_number=phone_number, origin=origin, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, beta=values.unset, friendly_name=values.unset, phone_number=values.unset, origin=values.unset, limit=None, page_size=None): """ Lists LocalInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param bool beta: The beta :param unicode friendly_name: The friendly_name :param unicode phone_number: The phone_number :param unicode origin: The origin :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.incoming_phone_number.local.LocalInstance] """ return list(self.stream( beta=beta, friendly_name=friendly_name, phone_number=phone_number, origin=origin, limit=limit, page_size=page_size, )) def page(self, beta=values.unset, friendly_name=values.unset, phone_number=values.unset, origin=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of LocalInstance records from the API. Request is executed immediately :param bool beta: The beta :param unicode friendly_name: The friendly_name :param unicode phone_number: The phone_number :param unicode origin: The origin :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of LocalInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.local.LocalPage """ params = values.of({ 'Beta': beta, 'FriendlyName': friendly_name, 'PhoneNumber': phone_number, 'Origin': origin, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return LocalPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of LocalInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of LocalInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.local.LocalPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return LocalPage(self._version, response, self._solution) def create(self, phone_number, api_version=values.unset, friendly_name=values.unset, sms_application_sid=values.unset, sms_fallback_method=values.unset, sms_fallback_url=values.unset, sms_method=values.unset, sms_url=values.unset, status_callback=values.unset, status_callback_method=values.unset, voice_application_sid=values.unset, voice_caller_id_lookup=values.unset, voice_fallback_method=values.unset, voice_fallback_url=values.unset, voice_method=values.unset, voice_url=values.unset, identity_sid=values.unset, address_sid=values.unset): """ Create a new LocalInstance :param unicode phone_number: The phone_number :param unicode api_version: The api_version :param unicode friendly_name: The friendly_name :param unicode sms_application_sid: The sms_application_sid :param unicode sms_fallback_method: The sms_fallback_method :param unicode sms_fallback_url: The sms_fallback_url :param unicode sms_method: The sms_method :param unicode sms_url: The sms_url :param unicode status_callback: The status_callback :param unicode status_callback_method: The status_callback_method :param unicode voice_application_sid: The voice_application_sid :param bool voice_caller_id_lookup: The voice_caller_id_lookup :param unicode voice_fallback_method: The voice_fallback_method :param unicode voice_fallback_url: The voice_fallback_url :param unicode voice_method: The voice_method :param unicode voice_url: The voice_url :param unicode identity_sid: The identity_sid :param unicode address_sid: The address_sid :returns: Newly created LocalInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.local.LocalInstance """ data = values.of({ 'PhoneNumber': phone_number, 'ApiVersion': api_version, 'FriendlyName': friendly_name, 'SmsApplicationSid': sms_application_sid, 'SmsFallbackMethod': sms_fallback_method, 'SmsFallbackUrl': sms_fallback_url, 'SmsMethod': sms_method, 'SmsUrl': sms_url, 'StatusCallback': status_callback, 'StatusCallbackMethod': status_callback_method, 'VoiceApplicationSid': voice_application_sid, 'VoiceCallerIdLookup': voice_caller_id_lookup, 'VoiceFallbackMethod': voice_fallback_method, 'VoiceFallbackUrl': voice_fallback_url, 'VoiceMethod': voice_method, 'VoiceUrl': voice_url, 'IdentitySid': identity_sid, 'AddressSid': address_sid, }) payload = self._version.create( 'POST', self._uri, data=data, ) return LocalInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class LocalPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the LocalPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The unique sid that identifies this account :returns: twilio.rest.api.v2010.account.incoming_phone_number.local.LocalPage :rtype: twilio.rest.api.v2010.account.incoming_phone_number.local.LocalPage """ super(LocalPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of LocalInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.incoming_phone_number.local.LocalInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.local.LocalInstance """ return LocalInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class LocalInstance(InstanceResource): """ """ class AddressRequirement(object): NONE = "none" ANY = "any" LOCAL = "local" FOREIGN = "foreign" def __init__(self, version, payload, account_sid): """ Initialize the LocalInstance :returns: twilio.rest.api.v2010.account.incoming_phone_number.local.LocalInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.local.LocalInstance """ super(LocalInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'address_sid': payload['address_sid'], 'address_requirements': payload['address_requirements'], 'api_version': payload['api_version'], 'beta': payload['beta'], 'capabilities': payload['capabilities'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'friendly_name': payload['friendly_name'], 'identity_sid': payload['identity_sid'], 'phone_number': payload['phone_number'], 'origin': payload['origin'], 'sid': payload['sid'], 'sms_application_sid': payload['sms_application_sid'], 'sms_fallback_method': payload['sms_fallback_method'], 'sms_fallback_url': payload['sms_fallback_url'], 'sms_method': payload['sms_method'], 'sms_url': payload['sms_url'], 'status_callback': payload['status_callback'], 'status_callback_method': payload['status_callback_method'], 'trunk_sid': payload['trunk_sid'], 'uri': payload['uri'], 'voice_application_sid': payload['voice_application_sid'], 'voice_caller_id_lookup': payload['voice_caller_id_lookup'], 'voice_fallback_method': payload['voice_fallback_method'], 'voice_fallback_url': payload['voice_fallback_url'], 'voice_method': payload['voice_method'], 'voice_url': payload['voice_url'], } # Context self._context = None self._solution = {'account_sid': account_sid,} @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def address_sid(self): """ :returns: The address_sid :rtype: unicode """ return self._properties['address_sid'] @property def address_requirements(self): """ :returns: The address_requirements :rtype: LocalInstance.AddressRequirement """ return self._properties['address_requirements'] @property def api_version(self): """ :returns: The api_version :rtype: unicode """ return self._properties['api_version'] @property def beta(self): """ :returns: The beta :rtype: bool """ return self._properties['beta'] @property def capabilities(self): """ :returns: The capabilities :rtype: unicode """ return self._properties['capabilities'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def identity_sid(self): """ :returns: The identity_sid :rtype: unicode """ return self._properties['identity_sid'] @property def phone_number(self): """ :returns: The phone_number :rtype: unicode """ return self._properties['phone_number'] @property def origin(self): """ :returns: The origin :rtype: unicode """ return self._properties['origin'] @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def sms_application_sid(self): """ :returns: The sms_application_sid :rtype: unicode """ return self._properties['sms_application_sid'] @property def sms_fallback_method(self): """ :returns: The sms_fallback_method :rtype: unicode """ return self._properties['sms_fallback_method'] @property def sms_fallback_url(self): """ :returns: The sms_fallback_url :rtype: unicode """ return self._properties['sms_fallback_url'] @property def sms_method(self): """ :returns: The sms_method :rtype: unicode """ return self._properties['sms_method'] @property def sms_url(self): """ :returns: The sms_url :rtype: unicode """ return self._properties['sms_url'] @property def status_callback(self): """ :returns: The status_callback :rtype: unicode """ return self._properties['status_callback'] @property def status_callback_method(self): """ :returns: The status_callback_method :rtype: unicode """ return self._properties['status_callback_method'] @property def trunk_sid(self): """ :returns: The trunk_sid :rtype: unicode """ return self._properties['trunk_sid'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] @property def voice_application_sid(self): """ :returns: The voice_application_sid :rtype: unicode """ return self._properties['voice_application_sid'] @property def voice_caller_id_lookup(self): """ :returns: The voice_caller_id_lookup :rtype: bool """ return self._properties['voice_caller_id_lookup'] @property def voice_fallback_method(self): """ :returns: The voice_fallback_method :rtype: unicode """ return self._properties['voice_fallback_method'] @property def voice_fallback_url(self): """ :returns: The voice_fallback_url :rtype: unicode """ return self._properties['voice_fallback_url'] @property def voice_method(self): """ :returns: The voice_method :rtype: unicode """ return self._properties['voice_method'] @property def voice_url(self): """ :returns: The voice_url :rtype: unicode """ return self._properties['voice_url'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/api/v2010/account/incoming_phone_number/mobile.py000066400000000000000000000434521317472742600300300ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class MobileList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the MobileList :param Version version: Version that contains the resource :param account_sid: The unique sid that identifies this account :returns: twilio.rest.api.v2010.account.incoming_phone_number.mobile.MobileList :rtype: twilio.rest.api.v2010.account.incoming_phone_number.mobile.MobileList """ super(MobileList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/IncomingPhoneNumbers/Mobile.json'.format(**self._solution) def stream(self, beta=values.unset, friendly_name=values.unset, phone_number=values.unset, origin=values.unset, limit=None, page_size=None): """ Streams MobileInstance records from the API as a generator stream. This operation lazily loads 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 beta: The beta :param unicode friendly_name: The friendly_name :param unicode phone_number: The phone_number :param unicode origin: The origin :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.incoming_phone_number.mobile.MobileInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( beta=beta, friendly_name=friendly_name, phone_number=phone_number, origin=origin, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, beta=values.unset, friendly_name=values.unset, phone_number=values.unset, origin=values.unset, limit=None, page_size=None): """ Lists MobileInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param bool beta: The beta :param unicode friendly_name: The friendly_name :param unicode phone_number: The phone_number :param unicode origin: The origin :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.incoming_phone_number.mobile.MobileInstance] """ return list(self.stream( beta=beta, friendly_name=friendly_name, phone_number=phone_number, origin=origin, limit=limit, page_size=page_size, )) def page(self, beta=values.unset, friendly_name=values.unset, phone_number=values.unset, origin=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of MobileInstance records from the API. Request is executed immediately :param bool beta: The beta :param unicode friendly_name: The friendly_name :param unicode phone_number: The phone_number :param unicode origin: The origin :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of MobileInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.mobile.MobilePage """ params = values.of({ 'Beta': beta, 'FriendlyName': friendly_name, 'PhoneNumber': phone_number, 'Origin': origin, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return MobilePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of MobileInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of MobileInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.mobile.MobilePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return MobilePage(self._version, response, self._solution) def create(self, phone_number, api_version=values.unset, friendly_name=values.unset, sms_application_sid=values.unset, sms_fallback_method=values.unset, sms_fallback_url=values.unset, sms_method=values.unset, sms_url=values.unset, status_callback=values.unset, status_callback_method=values.unset, voice_application_sid=values.unset, voice_caller_id_lookup=values.unset, voice_fallback_method=values.unset, voice_fallback_url=values.unset, voice_method=values.unset, voice_url=values.unset, identity_sid=values.unset, address_sid=values.unset): """ Create a new MobileInstance :param unicode phone_number: The phone_number :param unicode api_version: The api_version :param unicode friendly_name: The friendly_name :param unicode sms_application_sid: The sms_application_sid :param unicode sms_fallback_method: The sms_fallback_method :param unicode sms_fallback_url: The sms_fallback_url :param unicode sms_method: The sms_method :param unicode sms_url: The sms_url :param unicode status_callback: The status_callback :param unicode status_callback_method: The status_callback_method :param unicode voice_application_sid: The voice_application_sid :param bool voice_caller_id_lookup: The voice_caller_id_lookup :param unicode voice_fallback_method: The voice_fallback_method :param unicode voice_fallback_url: The voice_fallback_url :param unicode voice_method: The voice_method :param unicode voice_url: The voice_url :param unicode identity_sid: The identity_sid :param unicode address_sid: The address_sid :returns: Newly created MobileInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.mobile.MobileInstance """ data = values.of({ 'PhoneNumber': phone_number, 'ApiVersion': api_version, 'FriendlyName': friendly_name, 'SmsApplicationSid': sms_application_sid, 'SmsFallbackMethod': sms_fallback_method, 'SmsFallbackUrl': sms_fallback_url, 'SmsMethod': sms_method, 'SmsUrl': sms_url, 'StatusCallback': status_callback, 'StatusCallbackMethod': status_callback_method, 'VoiceApplicationSid': voice_application_sid, 'VoiceCallerIdLookup': voice_caller_id_lookup, 'VoiceFallbackMethod': voice_fallback_method, 'VoiceFallbackUrl': voice_fallback_url, 'VoiceMethod': voice_method, 'VoiceUrl': voice_url, 'IdentitySid': identity_sid, 'AddressSid': address_sid, }) payload = self._version.create( 'POST', self._uri, data=data, ) return MobileInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class MobilePage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the MobilePage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The unique sid that identifies this account :returns: twilio.rest.api.v2010.account.incoming_phone_number.mobile.MobilePage :rtype: twilio.rest.api.v2010.account.incoming_phone_number.mobile.MobilePage """ super(MobilePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of MobileInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.incoming_phone_number.mobile.MobileInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.mobile.MobileInstance """ return MobileInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class MobileInstance(InstanceResource): """ """ class AddressRequirement(object): NONE = "none" ANY = "any" LOCAL = "local" FOREIGN = "foreign" def __init__(self, version, payload, account_sid): """ Initialize the MobileInstance :returns: twilio.rest.api.v2010.account.incoming_phone_number.mobile.MobileInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.mobile.MobileInstance """ super(MobileInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'address_sid': payload['address_sid'], 'address_requirements': payload['address_requirements'], 'api_version': payload['api_version'], 'beta': payload['beta'], 'capabilities': payload['capabilities'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'friendly_name': payload['friendly_name'], 'identity_sid': payload['identity_sid'], 'phone_number': payload['phone_number'], 'origin': payload['origin'], 'sid': payload['sid'], 'sms_application_sid': payload['sms_application_sid'], 'sms_fallback_method': payload['sms_fallback_method'], 'sms_fallback_url': payload['sms_fallback_url'], 'sms_method': payload['sms_method'], 'sms_url': payload['sms_url'], 'status_callback': payload['status_callback'], 'status_callback_method': payload['status_callback_method'], 'trunk_sid': payload['trunk_sid'], 'uri': payload['uri'], 'voice_application_sid': payload['voice_application_sid'], 'voice_caller_id_lookup': payload['voice_caller_id_lookup'], 'voice_fallback_method': payload['voice_fallback_method'], 'voice_fallback_url': payload['voice_fallback_url'], 'voice_method': payload['voice_method'], 'voice_url': payload['voice_url'], } # Context self._context = None self._solution = {'account_sid': account_sid,} @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def address_sid(self): """ :returns: The address_sid :rtype: unicode """ return self._properties['address_sid'] @property def address_requirements(self): """ :returns: The address_requirements :rtype: MobileInstance.AddressRequirement """ return self._properties['address_requirements'] @property def api_version(self): """ :returns: The api_version :rtype: unicode """ return self._properties['api_version'] @property def beta(self): """ :returns: The beta :rtype: bool """ return self._properties['beta'] @property def capabilities(self): """ :returns: The capabilities :rtype: unicode """ return self._properties['capabilities'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def identity_sid(self): """ :returns: The identity_sid :rtype: unicode """ return self._properties['identity_sid'] @property def phone_number(self): """ :returns: The phone_number :rtype: unicode """ return self._properties['phone_number'] @property def origin(self): """ :returns: The origin :rtype: unicode """ return self._properties['origin'] @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def sms_application_sid(self): """ :returns: The sms_application_sid :rtype: unicode """ return self._properties['sms_application_sid'] @property def sms_fallback_method(self): """ :returns: The sms_fallback_method :rtype: unicode """ return self._properties['sms_fallback_method'] @property def sms_fallback_url(self): """ :returns: The sms_fallback_url :rtype: unicode """ return self._properties['sms_fallback_url'] @property def sms_method(self): """ :returns: The sms_method :rtype: unicode """ return self._properties['sms_method'] @property def sms_url(self): """ :returns: The sms_url :rtype: unicode """ return self._properties['sms_url'] @property def status_callback(self): """ :returns: The status_callback :rtype: unicode """ return self._properties['status_callback'] @property def status_callback_method(self): """ :returns: The status_callback_method :rtype: unicode """ return self._properties['status_callback_method'] @property def trunk_sid(self): """ :returns: The trunk_sid :rtype: unicode """ return self._properties['trunk_sid'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] @property def voice_application_sid(self): """ :returns: The voice_application_sid :rtype: unicode """ return self._properties['voice_application_sid'] @property def voice_caller_id_lookup(self): """ :returns: The voice_caller_id_lookup :rtype: bool """ return self._properties['voice_caller_id_lookup'] @property def voice_fallback_method(self): """ :returns: The voice_fallback_method :rtype: unicode """ return self._properties['voice_fallback_method'] @property def voice_fallback_url(self): """ :returns: The voice_fallback_url :rtype: unicode """ return self._properties['voice_fallback_url'] @property def voice_method(self): """ :returns: The voice_method :rtype: unicode """ return self._properties['voice_method'] @property def voice_url(self): """ :returns: The voice_url :rtype: unicode """ return self._properties['voice_url'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/api/v2010/account/incoming_phone_number/toll_free.py000066400000000000000000000436411317472742600305340ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class TollFreeList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the TollFreeList :param Version version: Version that contains the resource :param account_sid: The unique sid that identifies this account :returns: twilio.rest.api.v2010.account.incoming_phone_number.toll_free.TollFreeList :rtype: twilio.rest.api.v2010.account.incoming_phone_number.toll_free.TollFreeList """ super(TollFreeList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/IncomingPhoneNumbers/TollFree.json'.format(**self._solution) def stream(self, beta=values.unset, friendly_name=values.unset, phone_number=values.unset, origin=values.unset, limit=None, page_size=None): """ Streams TollFreeInstance records from the API as a generator stream. This operation lazily loads 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 beta: The beta :param unicode friendly_name: The friendly_name :param unicode phone_number: The phone_number :param unicode origin: The origin :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.incoming_phone_number.toll_free.TollFreeInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( beta=beta, friendly_name=friendly_name, phone_number=phone_number, origin=origin, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, beta=values.unset, friendly_name=values.unset, phone_number=values.unset, origin=values.unset, limit=None, page_size=None): """ Lists TollFreeInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param bool beta: The beta :param unicode friendly_name: The friendly_name :param unicode phone_number: The phone_number :param unicode origin: The origin :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.incoming_phone_number.toll_free.TollFreeInstance] """ return list(self.stream( beta=beta, friendly_name=friendly_name, phone_number=phone_number, origin=origin, limit=limit, page_size=page_size, )) def page(self, beta=values.unset, friendly_name=values.unset, phone_number=values.unset, origin=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of TollFreeInstance records from the API. Request is executed immediately :param bool beta: The beta :param unicode friendly_name: The friendly_name :param unicode phone_number: The phone_number :param unicode origin: The origin :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of TollFreeInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.toll_free.TollFreePage """ params = values.of({ 'Beta': beta, 'FriendlyName': friendly_name, 'PhoneNumber': phone_number, 'Origin': origin, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return TollFreePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of TollFreeInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of TollFreeInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.toll_free.TollFreePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return TollFreePage(self._version, response, self._solution) def create(self, phone_number, api_version=values.unset, friendly_name=values.unset, sms_application_sid=values.unset, sms_fallback_method=values.unset, sms_fallback_url=values.unset, sms_method=values.unset, sms_url=values.unset, status_callback=values.unset, status_callback_method=values.unset, voice_application_sid=values.unset, voice_caller_id_lookup=values.unset, voice_fallback_method=values.unset, voice_fallback_url=values.unset, voice_method=values.unset, voice_url=values.unset, identity_sid=values.unset, address_sid=values.unset): """ Create a new TollFreeInstance :param unicode phone_number: The phone_number :param unicode api_version: The api_version :param unicode friendly_name: The friendly_name :param unicode sms_application_sid: The sms_application_sid :param unicode sms_fallback_method: The sms_fallback_method :param unicode sms_fallback_url: The sms_fallback_url :param unicode sms_method: The sms_method :param unicode sms_url: The sms_url :param unicode status_callback: The status_callback :param unicode status_callback_method: The status_callback_method :param unicode voice_application_sid: The voice_application_sid :param bool voice_caller_id_lookup: The voice_caller_id_lookup :param unicode voice_fallback_method: The voice_fallback_method :param unicode voice_fallback_url: The voice_fallback_url :param unicode voice_method: The voice_method :param unicode voice_url: The voice_url :param unicode identity_sid: The identity_sid :param unicode address_sid: The address_sid :returns: Newly created TollFreeInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.toll_free.TollFreeInstance """ data = values.of({ 'PhoneNumber': phone_number, 'ApiVersion': api_version, 'FriendlyName': friendly_name, 'SmsApplicationSid': sms_application_sid, 'SmsFallbackMethod': sms_fallback_method, 'SmsFallbackUrl': sms_fallback_url, 'SmsMethod': sms_method, 'SmsUrl': sms_url, 'StatusCallback': status_callback, 'StatusCallbackMethod': status_callback_method, 'VoiceApplicationSid': voice_application_sid, 'VoiceCallerIdLookup': voice_caller_id_lookup, 'VoiceFallbackMethod': voice_fallback_method, 'VoiceFallbackUrl': voice_fallback_url, 'VoiceMethod': voice_method, 'VoiceUrl': voice_url, 'IdentitySid': identity_sid, 'AddressSid': address_sid, }) payload = self._version.create( 'POST', self._uri, data=data, ) return TollFreeInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class TollFreePage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the TollFreePage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The unique sid that identifies this account :returns: twilio.rest.api.v2010.account.incoming_phone_number.toll_free.TollFreePage :rtype: twilio.rest.api.v2010.account.incoming_phone_number.toll_free.TollFreePage """ super(TollFreePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of TollFreeInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.incoming_phone_number.toll_free.TollFreeInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.toll_free.TollFreeInstance """ return TollFreeInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class TollFreeInstance(InstanceResource): """ """ class AddressRequirement(object): NONE = "none" ANY = "any" LOCAL = "local" FOREIGN = "foreign" def __init__(self, version, payload, account_sid): """ Initialize the TollFreeInstance :returns: twilio.rest.api.v2010.account.incoming_phone_number.toll_free.TollFreeInstance :rtype: twilio.rest.api.v2010.account.incoming_phone_number.toll_free.TollFreeInstance """ super(TollFreeInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'address_sid': payload['address_sid'], 'address_requirements': payload['address_requirements'], 'api_version': payload['api_version'], 'beta': payload['beta'], 'capabilities': payload['capabilities'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'friendly_name': payload['friendly_name'], 'identity_sid': payload['identity_sid'], 'phone_number': payload['phone_number'], 'origin': payload['origin'], 'sid': payload['sid'], 'sms_application_sid': payload['sms_application_sid'], 'sms_fallback_method': payload['sms_fallback_method'], 'sms_fallback_url': payload['sms_fallback_url'], 'sms_method': payload['sms_method'], 'sms_url': payload['sms_url'], 'status_callback': payload['status_callback'], 'status_callback_method': payload['status_callback_method'], 'trunk_sid': payload['trunk_sid'], 'uri': payload['uri'], 'voice_application_sid': payload['voice_application_sid'], 'voice_caller_id_lookup': payload['voice_caller_id_lookup'], 'voice_fallback_method': payload['voice_fallback_method'], 'voice_fallback_url': payload['voice_fallback_url'], 'voice_method': payload['voice_method'], 'voice_url': payload['voice_url'], } # Context self._context = None self._solution = {'account_sid': account_sid,} @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def address_sid(self): """ :returns: The address_sid :rtype: unicode """ return self._properties['address_sid'] @property def address_requirements(self): """ :returns: The address_requirements :rtype: TollFreeInstance.AddressRequirement """ return self._properties['address_requirements'] @property def api_version(self): """ :returns: The api_version :rtype: unicode """ return self._properties['api_version'] @property def beta(self): """ :returns: The beta :rtype: bool """ return self._properties['beta'] @property def capabilities(self): """ :returns: The capabilities :rtype: unicode """ return self._properties['capabilities'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def identity_sid(self): """ :returns: The identity_sid :rtype: unicode """ return self._properties['identity_sid'] @property def phone_number(self): """ :returns: The phone_number :rtype: unicode """ return self._properties['phone_number'] @property def origin(self): """ :returns: The origin :rtype: unicode """ return self._properties['origin'] @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def sms_application_sid(self): """ :returns: The sms_application_sid :rtype: unicode """ return self._properties['sms_application_sid'] @property def sms_fallback_method(self): """ :returns: The sms_fallback_method :rtype: unicode """ return self._properties['sms_fallback_method'] @property def sms_fallback_url(self): """ :returns: The sms_fallback_url :rtype: unicode """ return self._properties['sms_fallback_url'] @property def sms_method(self): """ :returns: The sms_method :rtype: unicode """ return self._properties['sms_method'] @property def sms_url(self): """ :returns: The sms_url :rtype: unicode """ return self._properties['sms_url'] @property def status_callback(self): """ :returns: The status_callback :rtype: unicode """ return self._properties['status_callback'] @property def status_callback_method(self): """ :returns: The status_callback_method :rtype: unicode """ return self._properties['status_callback_method'] @property def trunk_sid(self): """ :returns: The trunk_sid :rtype: unicode """ return self._properties['trunk_sid'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] @property def voice_application_sid(self): """ :returns: The voice_application_sid :rtype: unicode """ return self._properties['voice_application_sid'] @property def voice_caller_id_lookup(self): """ :returns: The voice_caller_id_lookup :rtype: bool """ return self._properties['voice_caller_id_lookup'] @property def voice_fallback_method(self): """ :returns: The voice_fallback_method :rtype: unicode """ return self._properties['voice_fallback_method'] @property def voice_fallback_url(self): """ :returns: The voice_fallback_url :rtype: unicode """ return self._properties['voice_fallback_url'] @property def voice_method(self): """ :returns: The voice_method :rtype: unicode """ return self._properties['voice_method'] @property def voice_url(self): """ :returns: The voice_url :rtype: unicode """ return self._properties['voice_url'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/api/v2010/account/key.py000066400000000000000000000274611317472742600230070ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class KeyList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the KeyList :param Version version: Version that contains the resource :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.key.KeyList :rtype: twilio.rest.api.v2010.account.key.KeyList """ super(KeyList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/Keys.json'.format(**self._solution) def stream(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.key.KeyInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.key.KeyInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of KeyInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of KeyInstance :rtype: twilio.rest.api.v2010.account.key.KeyPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return KeyPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of KeyInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of KeyInstance :rtype: twilio.rest.api.v2010.account.key.KeyPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return KeyPage(self._version, response, self._solution) def get(self, sid): """ Constructs a KeyContext :param sid: The sid :returns: twilio.rest.api.v2010.account.key.KeyContext :rtype: twilio.rest.api.v2010.account.key.KeyContext """ return KeyContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __call__(self, sid): """ Constructs a KeyContext :param sid: The sid :returns: twilio.rest.api.v2010.account.key.KeyContext :rtype: twilio.rest.api.v2010.account.key.KeyContext """ return KeyContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class KeyPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the KeyPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.key.KeyPage :rtype: twilio.rest.api.v2010.account.key.KeyPage """ super(KeyPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of KeyInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.key.KeyInstance :rtype: twilio.rest.api.v2010.account.key.KeyInstance """ return KeyInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class KeyContext(InstanceContext): """ """ def __init__(self, version, account_sid, sid): """ Initialize the KeyContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param sid: The sid :returns: twilio.rest.api.v2010.account.key.KeyContext :rtype: twilio.rest.api.v2010.account.key.KeyContext """ super(KeyContext, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'sid': sid,} self._uri = '/Accounts/{account_sid}/Keys/{sid}.json'.format(**self._solution) def fetch(self): """ Fetch a KeyInstance :returns: Fetched KeyInstance :rtype: twilio.rest.api.v2010.account.key.KeyInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return KeyInstance( self._version, payload, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) def update(self, friendly_name=values.unset): """ Update the KeyInstance :param unicode friendly_name: The friendly_name :returns: Updated KeyInstance :rtype: twilio.rest.api.v2010.account.key.KeyInstance """ data = values.of({'FriendlyName': friendly_name,}) payload = self._version.update( 'POST', self._uri, data=data, ) return KeyInstance( self._version, payload, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the KeyInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class KeyInstance(InstanceResource): """ """ def __init__(self, version, payload, account_sid, sid=None): """ Initialize the KeyInstance :returns: twilio.rest.api.v2010.account.key.KeyInstance :rtype: twilio.rest.api.v2010.account.key.KeyInstance """ super(KeyInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'friendly_name': payload['friendly_name'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), } # Context self._context = None self._solution = {'account_sid': account_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.api.v2010.account.key.KeyContext """ if self._context is None: self._context = KeyContext( self._version, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] def fetch(self): """ Fetch a KeyInstance :returns: Fetched KeyInstance :rtype: twilio.rest.api.v2010.account.key.KeyInstance """ return self._proxy.fetch() def update(self, friendly_name=values.unset): """ Update the KeyInstance :param unicode friendly_name: The friendly_name :returns: Updated KeyInstance :rtype: twilio.rest.api.v2010.account.key.KeyInstance """ return self._proxy.update(friendly_name=friendly_name,) def delete(self): """ Deletes the KeyInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/message/000077500000000000000000000000001317472742600232575ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/api/v2010/account/message/__init__.py000066400000000000000000000556571317472742600254120ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize 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.page import Page from twilio.rest.api.v2010.account.message.feedback import FeedbackList from twilio.rest.api.v2010.account.message.media import MediaList class MessageList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the MessageList :param Version version: Version that contains the resource :param account_sid: The unique sid that identifies this account :returns: twilio.rest.api.v2010.account.message.MessageList :rtype: twilio.rest.api.v2010.account.message.MessageList """ super(MessageList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/Messages.json'.format(**self._solution) def create(self, to, status_callback=values.unset, application_sid=values.unset, max_price=values.unset, provide_feedback=values.unset, validity_period=values.unset, max_rate=values.unset, force_delivery=values.unset, provider_sid=values.unset, content_retention=values.unset, address_retention=values.unset, smart_encoded=values.unset, from_=values.unset, messaging_service_sid=values.unset, body=values.unset, media_url=values.unset): """ Create a new MessageInstance :param unicode to: The phone number to receive the message :param unicode status_callback: URL Twilio will request when the status changes :param unicode application_sid: The application to use for callbacks :param unicode max_price: The max_price :param bool provide_feedback: The provide_feedback :param unicode validity_period: The validity_period :param unicode max_rate: The max_rate :param bool force_delivery: The force_delivery :param unicode provider_sid: The provider_sid :param MessageInstance.ContentRetention content_retention: The content_retention :param MessageInstance.AddressRetention address_retention: The address_retention :param bool smart_encoded: The smart_encoded :param unicode from_: The phone number that initiated the message :param unicode messaging_service_sid: The messaging_service_sid :param unicode body: The body :param unicode media_url: The media_url :returns: Newly created MessageInstance :rtype: twilio.rest.api.v2010.account.message.MessageInstance """ data = values.of({ 'To': to, 'From': from_, 'MessagingServiceSid': messaging_service_sid, 'Body': body, 'MediaUrl': media_url, 'StatusCallback': status_callback, 'ApplicationSid': application_sid, 'MaxPrice': max_price, 'ProvideFeedback': provide_feedback, 'ValidityPeriod': validity_period, 'MaxRate': max_rate, 'ForceDelivery': force_delivery, 'ProviderSid': provider_sid, 'ContentRetention': content_retention, 'AddressRetention': address_retention, 'SmartEncoded': smart_encoded, }) payload = self._version.create( 'POST', self._uri, data=data, ) return MessageInstance(self._version, payload, account_sid=self._solution['account_sid'],) def stream(self, to=values.unset, from_=values.unset, date_sent_before=values.unset, date_sent=values.unset, date_sent_after=values.unset, limit=None, page_size=None): """ 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 unicode to: Filter by messages to this number :param unicode from_: Filter by from number :param datetime date_sent_before: Filter by date sent :param datetime date_sent: Filter by date sent :param datetime date_sent_after: Filter by date sent :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.message.MessageInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( to=to, from_=from_, date_sent_before=date_sent_before, date_sent=date_sent, date_sent_after=date_sent_after, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, to=values.unset, from_=values.unset, date_sent_before=values.unset, date_sent=values.unset, date_sent_after=values.unset, limit=None, page_size=None): """ 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 unicode to: Filter by messages to this number :param unicode from_: Filter by from number :param datetime date_sent_before: Filter by date sent :param datetime date_sent: Filter by date sent :param datetime date_sent_after: Filter by date sent :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.message.MessageInstance] """ return list(self.stream( to=to, from_=from_, date_sent_before=date_sent_before, date_sent=date_sent, date_sent_after=date_sent_after, limit=limit, page_size=page_size, )) def page(self, to=values.unset, from_=values.unset, date_sent_before=values.unset, date_sent=values.unset, date_sent_after=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of MessageInstance records from the API. Request is executed immediately :param unicode to: Filter by messages to this number :param unicode from_: Filter by from number :param datetime date_sent_before: Filter by date sent :param datetime date_sent: Filter by date sent :param datetime date_sent_after: Filter by date sent :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of MessageInstance :rtype: twilio.rest.api.v2010.account.message.MessagePage """ params = values.of({ 'To': to, 'From': from_, 'DateSent<': serialize.iso8601_datetime(date_sent_before), 'DateSent': serialize.iso8601_datetime(date_sent), 'DateSent>': serialize.iso8601_datetime(date_sent_after), 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return MessagePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of MessageInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of MessageInstance :rtype: twilio.rest.api.v2010.account.message.MessagePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return MessagePage(self._version, response, self._solution) def get(self, sid): """ Constructs a MessageContext :param sid: Fetch by unique message Sid :returns: twilio.rest.api.v2010.account.message.MessageContext :rtype: twilio.rest.api.v2010.account.message.MessageContext """ return MessageContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __call__(self, sid): """ Constructs a MessageContext :param sid: Fetch by unique message Sid :returns: twilio.rest.api.v2010.account.message.MessageContext :rtype: twilio.rest.api.v2010.account.message.MessageContext """ return MessageContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class MessagePage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the MessagePage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The unique sid that identifies this account :returns: twilio.rest.api.v2010.account.message.MessagePage :rtype: twilio.rest.api.v2010.account.message.MessagePage """ super(MessagePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of MessageInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.message.MessageInstance :rtype: twilio.rest.api.v2010.account.message.MessageInstance """ return MessageInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class MessageContext(InstanceContext): """ """ def __init__(self, version, account_sid, sid): """ Initialize the MessageContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param sid: Fetch by unique message Sid :returns: twilio.rest.api.v2010.account.message.MessageContext :rtype: twilio.rest.api.v2010.account.message.MessageContext """ super(MessageContext, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'sid': sid,} self._uri = '/Accounts/{account_sid}/Messages/{sid}.json'.format(**self._solution) # Dependents self._media = None self._feedback = None def delete(self): """ Deletes the MessageInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def fetch(self): """ Fetch a MessageInstance :returns: Fetched MessageInstance :rtype: twilio.rest.api.v2010.account.message.MessageInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return MessageInstance( self._version, payload, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) def update(self, body): """ Update the MessageInstance :param unicode body: The body :returns: Updated MessageInstance :rtype: twilio.rest.api.v2010.account.message.MessageInstance """ data = values.of({'Body': body,}) payload = self._version.update( 'POST', self._uri, data=data, ) return MessageInstance( self._version, payload, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) @property def media(self): """ Access the media :returns: twilio.rest.api.v2010.account.message.media.MediaList :rtype: twilio.rest.api.v2010.account.message.media.MediaList """ if self._media is None: self._media = MediaList( self._version, account_sid=self._solution['account_sid'], message_sid=self._solution['sid'], ) return self._media @property def feedback(self): """ Access the feedback :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackList """ if self._feedback is None: self._feedback = FeedbackList( self._version, account_sid=self._solution['account_sid'], message_sid=self._solution['sid'], ) return self._feedback def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class MessageInstance(InstanceResource): """ """ class Status(object): QUEUED = "queued" SENDING = "sending" SENT = "sent" FAILED = "failed" DELIVERED = "delivered" UNDELIVERED = "undelivered" RECEIVING = "receiving" RECEIVED = "received" ACCEPTED = "accepted" class Direction(object): INBOUND = "inbound" OUTBOUND_API = "outbound-api" OUTBOUND_CALL = "outbound-call" OUTBOUND_REPLY = "outbound-reply" class ContentRetention(object): RETAIN = "retain" DISCARD = "discard" class AddressRetention(object): RETAIN = "retain" DISCARD = "discard" def __init__(self, version, payload, account_sid, sid=None): """ Initialize the MessageInstance :returns: twilio.rest.api.v2010.account.message.MessageInstance :rtype: twilio.rest.api.v2010.account.message.MessageInstance """ super(MessageInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'api_version': payload['api_version'], 'body': payload['body'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'date_sent': deserialize.rfc2822_datetime(payload['date_sent']), 'direction': payload['direction'], 'error_code': deserialize.integer(payload['error_code']), 'error_message': payload['error_message'], 'from_': payload['from'], 'messaging_service_sid': payload['messaging_service_sid'], 'num_media': payload['num_media'], 'num_segments': payload['num_segments'], 'price': deserialize.decimal(payload['price']), 'price_unit': payload['price_unit'], 'sid': payload['sid'], 'status': payload['status'], 'subresource_uris': payload['subresource_uris'], 'to': payload['to'], 'uri': payload['uri'], } # Context self._context = None self._solution = {'account_sid': account_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: MessageContext for this MessageInstance :rtype: twilio.rest.api.v2010.account.message.MessageContext """ if self._context is None: self._context = MessageContext( self._version, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: The unique sid that identifies this account :rtype: unicode """ return self._properties['account_sid'] @property def api_version(self): """ :returns: The version of the Twilio API used to process the message. :rtype: unicode """ return self._properties['api_version'] @property def body(self): """ :returns: The text body of the message. Up to 1600 characters long. :rtype: unicode """ return self._properties['body'] @property def date_created(self): """ :returns: The date this resource was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this resource was last updated :rtype: datetime """ return self._properties['date_updated'] @property def date_sent(self): """ :returns: The date the message was sent :rtype: datetime """ return self._properties['date_sent'] @property def direction(self): """ :returns: The direction of the message :rtype: MessageInstance.Direction """ return self._properties['direction'] @property def error_code(self): """ :returns: The error code associated with the message :rtype: unicode """ return self._properties['error_code'] @property def error_message(self): """ :returns: Human readable description of the ErrorCode :rtype: unicode """ return self._properties['error_message'] @property def from_(self): """ :returns: The phone number that initiated the message :rtype: unicode """ return self._properties['from_'] @property def messaging_service_sid(self): """ :returns: The messaging_service_sid :rtype: unicode """ return self._properties['messaging_service_sid'] @property def num_media(self): """ :returns: Number of media files associated with the message :rtype: unicode """ return self._properties['num_media'] @property def num_segments(self): """ :returns: Indicates number of messages used to delivery the body :rtype: unicode """ return self._properties['num_segments'] @property def price(self): """ :returns: The amount billed for the message :rtype: unicode """ return self._properties['price'] @property def price_unit(self): """ :returns: The currency in which Price is measured :rtype: unicode """ return self._properties['price_unit'] @property def sid(self): """ :returns: A string that uniquely identifies this message :rtype: unicode """ return self._properties['sid'] @property def status(self): """ :returns: The status of this message :rtype: MessageInstance.Status """ return self._properties['status'] @property def subresource_uris(self): """ :returns: The URI for any subresources :rtype: unicode """ return self._properties['subresource_uris'] @property def to(self): """ :returns: The phone number that received the message :rtype: unicode """ return self._properties['to'] @property def uri(self): """ :returns: The URI for this resource :rtype: unicode """ return self._properties['uri'] def delete(self): """ Deletes the MessageInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def fetch(self): """ Fetch a MessageInstance :returns: Fetched MessageInstance :rtype: twilio.rest.api.v2010.account.message.MessageInstance """ return self._proxy.fetch() def update(self, body): """ Update the MessageInstance :param unicode body: The body :returns: Updated MessageInstance :rtype: twilio.rest.api.v2010.account.message.MessageInstance """ return self._proxy.update(body,) @property def media(self): """ Access the media :returns: twilio.rest.api.v2010.account.message.media.MediaList :rtype: twilio.rest.api.v2010.account.message.media.MediaList """ return self._proxy.media @property def feedback(self): """ Access the feedback :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackList """ return self._proxy.feedback def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/message/feedback.py000066400000000000000000000127711317472742600253650ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class FeedbackList(ListResource): """ """ def __init__(self, version, account_sid, message_sid): """ Initialize the FeedbackList :param Version version: Version that contains the resource :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackList """ super(FeedbackList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'message_sid': message_sid,} self._uri = '/Accounts/{account_sid}/Messages/{message_sid}/Feedback.json'.format(**self._solution) def create(self, outcome=values.unset): """ Create a new FeedbackInstance :param FeedbackInstance.Outcome outcome: The outcome :returns: Newly created FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ data = values.of({'Outcome': outcome,}) payload = self._version.create( 'POST', self._uri, data=data, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class FeedbackPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the FeedbackPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackPage :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackPage """ super(FeedbackPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of FeedbackInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class FeedbackInstance(InstanceResource): """ """ class Outcome(object): CONFIRMED = "confirmed" UMCONFIRMED = "umconfirmed" def __init__(self, version, payload, account_sid, message_sid): """ Initialize the FeedbackInstance :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ super(FeedbackInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'message_sid': payload['message_sid'], 'outcome': payload['outcome'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], } # Context self._context = None self._solution = {'account_sid': account_sid, 'message_sid': message_sid,} @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def message_sid(self): """ :returns: The message_sid :rtype: unicode """ return self._properties['message_sid'] @property def outcome(self): """ :returns: The outcome :rtype: FeedbackInstance.Outcome """ return self._properties['outcome'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/api/v2010/account/message/media.py000066400000000000000000000345061317472742600247200ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize 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.page import Page class MediaList(ListResource): """ """ def __init__(self, version, account_sid, message_sid): """ Initialize the MediaList :param Version version: Version that contains the resource :param account_sid: The unique sid that identifies this account :param message_sid: A string that uniquely identifies this message :returns: twilio.rest.api.v2010.account.message.media.MediaList :rtype: twilio.rest.api.v2010.account.message.media.MediaList """ super(MediaList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'message_sid': message_sid,} self._uri = '/Accounts/{account_sid}/Messages/{message_sid}/Media.json'.format(**self._solution) def stream(self, date_created_before=values.unset, date_created=values.unset, date_created_after=values.unset, limit=None, page_size=None): """ Streams MediaInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param datetime date_created_before: Filter by date created :param datetime date_created: Filter by date created :param datetime date_created_after: Filter by date created :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.message.media.MediaInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( date_created_before=date_created_before, date_created=date_created, date_created_after=date_created_after, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, date_created_before=values.unset, date_created=values.unset, date_created_after=values.unset, limit=None, page_size=None): """ Lists MediaInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param datetime date_created_before: Filter by date created :param datetime date_created: Filter by date created :param datetime date_created_after: Filter by date created :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.message.media.MediaInstance] """ return list(self.stream( date_created_before=date_created_before, date_created=date_created, date_created_after=date_created_after, limit=limit, page_size=page_size, )) def page(self, date_created_before=values.unset, date_created=values.unset, date_created_after=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of MediaInstance records from the API. Request is executed immediately :param datetime date_created_before: Filter by date created :param datetime date_created: Filter by date created :param datetime date_created_after: Filter by date created :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of MediaInstance :rtype: twilio.rest.api.v2010.account.message.media.MediaPage """ params = values.of({ 'DateCreated<': serialize.iso8601_datetime(date_created_before), 'DateCreated': serialize.iso8601_datetime(date_created), 'DateCreated>': serialize.iso8601_datetime(date_created_after), 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return MediaPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of MediaInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of MediaInstance :rtype: twilio.rest.api.v2010.account.message.media.MediaPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return MediaPage(self._version, response, self._solution) def get(self, sid): """ Constructs a MediaContext :param sid: Fetch by unique media Sid :returns: twilio.rest.api.v2010.account.message.media.MediaContext :rtype: twilio.rest.api.v2010.account.message.media.MediaContext """ return MediaContext( self._version, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a MediaContext :param sid: Fetch by unique media Sid :returns: twilio.rest.api.v2010.account.message.media.MediaContext :rtype: twilio.rest.api.v2010.account.message.media.MediaContext """ return MediaContext( self._version, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class MediaPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the MediaPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The unique sid that identifies this account :param message_sid: A string that uniquely identifies this message :returns: twilio.rest.api.v2010.account.message.media.MediaPage :rtype: twilio.rest.api.v2010.account.message.media.MediaPage """ super(MediaPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of MediaInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.message.media.MediaInstance :rtype: twilio.rest.api.v2010.account.message.media.MediaInstance """ return MediaInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class MediaContext(InstanceContext): """ """ def __init__(self, version, account_sid, message_sid, sid): """ Initialize the MediaContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param message_sid: The message_sid :param sid: Fetch by unique media Sid :returns: twilio.rest.api.v2010.account.message.media.MediaContext :rtype: twilio.rest.api.v2010.account.message.media.MediaContext """ super(MediaContext, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'message_sid': message_sid, 'sid': sid,} self._uri = '/Accounts/{account_sid}/Messages/{message_sid}/Media/{sid}.json'.format(**self._solution) def delete(self): """ Deletes the MediaInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def fetch(self): """ Fetch a MediaInstance :returns: Fetched MediaInstance :rtype: twilio.rest.api.v2010.account.message.media.MediaInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return MediaInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class MediaInstance(InstanceResource): """ """ def __init__(self, version, payload, account_sid, message_sid, sid=None): """ Initialize the MediaInstance :returns: twilio.rest.api.v2010.account.message.media.MediaInstance :rtype: twilio.rest.api.v2010.account.message.media.MediaInstance """ super(MediaInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'content_type': payload['content_type'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'parent_sid': payload['parent_sid'], 'sid': payload['sid'], 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ 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 :rtype: twilio.rest.api.v2010.account.message.media.MediaContext """ if self._context is None: self._context = MediaContext( self._version, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: The unique sid that identifies this account :rtype: unicode """ return self._properties['account_sid'] @property def content_type(self): """ :returns: The default mime-type of the media :rtype: unicode """ return self._properties['content_type'] @property def date_created(self): """ :returns: The date this resource was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this resource was last updated :rtype: datetime """ return self._properties['date_updated'] @property def parent_sid(self): """ :returns: The unique id of the resource that created the media. :rtype: unicode """ return self._properties['parent_sid'] @property def sid(self): """ :returns: A string that uniquely identifies this media :rtype: unicode """ return self._properties['sid'] @property def uri(self): """ :returns: The URI for this resource :rtype: unicode """ return self._properties['uri'] def delete(self): """ Deletes the MediaInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def fetch(self): """ Fetch a MediaInstance :returns: Fetched MediaInstance :rtype: twilio.rest.api.v2010.account.message.media.MediaInstance """ return self._proxy.fetch() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/new_key.py000066400000000000000000000114031317472742600236450ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class NewKeyList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the NewKeyList :param Version version: Version that contains the resource :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.new_key.NewKeyList :rtype: twilio.rest.api.v2010.account.new_key.NewKeyList """ super(NewKeyList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/Keys.json'.format(**self._solution) def create(self, friendly_name=values.unset): """ Create a new NewKeyInstance :param unicode friendly_name: The friendly_name :returns: Newly created NewKeyInstance :rtype: twilio.rest.api.v2010.account.new_key.NewKeyInstance """ data = values.of({'FriendlyName': friendly_name,}) payload = self._version.create( 'POST', self._uri, data=data, ) return NewKeyInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class NewKeyPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the NewKeyPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.new_key.NewKeyPage :rtype: twilio.rest.api.v2010.account.new_key.NewKeyPage """ super(NewKeyPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of NewKeyInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.new_key.NewKeyInstance :rtype: twilio.rest.api.v2010.account.new_key.NewKeyInstance """ return NewKeyInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class NewKeyInstance(InstanceResource): """ """ def __init__(self, version, payload, account_sid): """ Initialize the NewKeyInstance :returns: twilio.rest.api.v2010.account.new_key.NewKeyInstance :rtype: twilio.rest.api.v2010.account.new_key.NewKeyInstance """ super(NewKeyInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'friendly_name': payload['friendly_name'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'secret': payload['secret'], } # Context self._context = None self._solution = {'account_sid': account_sid,} @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def secret(self): """ :returns: The secret :rtype: unicode """ return self._properties['secret'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/api/v2010/account/new_signing_key.py000066400000000000000000000120101317472742600253560ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class NewSigningKeyList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the NewSigningKeyList :param Version version: Version that contains the resource :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.new_signing_key.NewSigningKeyList :rtype: twilio.rest.api.v2010.account.new_signing_key.NewSigningKeyList """ super(NewSigningKeyList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/SigningKeys.json'.format(**self._solution) def create(self, friendly_name=values.unset): """ Create a new NewSigningKeyInstance :param unicode friendly_name: The friendly_name :returns: Newly created NewSigningKeyInstance :rtype: twilio.rest.api.v2010.account.new_signing_key.NewSigningKeyInstance """ data = values.of({'FriendlyName': friendly_name,}) payload = self._version.create( 'POST', self._uri, data=data, ) return NewSigningKeyInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class NewSigningKeyPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the NewSigningKeyPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.new_signing_key.NewSigningKeyPage :rtype: twilio.rest.api.v2010.account.new_signing_key.NewSigningKeyPage """ super(NewSigningKeyPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of NewSigningKeyInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.new_signing_key.NewSigningKeyInstance :rtype: twilio.rest.api.v2010.account.new_signing_key.NewSigningKeyInstance """ return NewSigningKeyInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class NewSigningKeyInstance(InstanceResource): """ """ def __init__(self, version, payload, account_sid): """ Initialize the NewSigningKeyInstance :returns: twilio.rest.api.v2010.account.new_signing_key.NewSigningKeyInstance :rtype: twilio.rest.api.v2010.account.new_signing_key.NewSigningKeyInstance """ super(NewSigningKeyInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'friendly_name': payload['friendly_name'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'secret': payload['secret'], } # Context self._context = None self._solution = {'account_sid': account_sid,} @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def secret(self): """ :returns: The secret :rtype: unicode """ return self._properties['secret'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/api/v2010/account/notification.py000066400000000000000000000411461317472742600247010ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize 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.page import Page class NotificationList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the NotificationList :param Version version: Version that contains the resource :param account_sid: The unique sid that identifies this account :returns: twilio.rest.api.v2010.account.notification.NotificationList :rtype: twilio.rest.api.v2010.account.notification.NotificationList """ super(NotificationList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/Notifications.json'.format(**self._solution) def stream(self, log=values.unset, message_date_before=values.unset, message_date=values.unset, message_date_after=values.unset, limit=None, page_size=None): """ Streams NotificationInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param unicode log: Filter by log level :param date message_date_before: Filter by date :param date message_date: Filter by date :param date message_date_after: Filter by date :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.notification.NotificationInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( log=log, message_date_before=message_date_before, message_date=message_date, message_date_after=message_date_after, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, log=values.unset, message_date_before=values.unset, message_date=values.unset, message_date_after=values.unset, limit=None, page_size=None): """ Lists NotificationInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param unicode log: Filter by log level :param date message_date_before: Filter by date :param date message_date: Filter by date :param date message_date_after: Filter by date :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.notification.NotificationInstance] """ return list(self.stream( log=log, message_date_before=message_date_before, message_date=message_date, message_date_after=message_date_after, limit=limit, page_size=page_size, )) def page(self, log=values.unset, message_date_before=values.unset, message_date=values.unset, message_date_after=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of NotificationInstance records from the API. Request is executed immediately :param unicode log: Filter by log level :param date message_date_before: Filter by date :param date message_date: Filter by date :param date message_date_after: Filter by date :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of NotificationInstance :rtype: twilio.rest.api.v2010.account.notification.NotificationPage """ params = values.of({ 'Log': log, 'MessageDate<': serialize.iso8601_date(message_date_before), 'MessageDate': serialize.iso8601_date(message_date), 'MessageDate>': serialize.iso8601_date(message_date_after), 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return NotificationPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of NotificationInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of NotificationInstance :rtype: twilio.rest.api.v2010.account.notification.NotificationPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return NotificationPage(self._version, response, self._solution) def get(self, sid): """ Constructs a NotificationContext :param sid: Fetch by unique notification Sid :returns: twilio.rest.api.v2010.account.notification.NotificationContext :rtype: twilio.rest.api.v2010.account.notification.NotificationContext """ return NotificationContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __call__(self, sid): """ Constructs a NotificationContext :param sid: Fetch by unique notification Sid :returns: twilio.rest.api.v2010.account.notification.NotificationContext :rtype: twilio.rest.api.v2010.account.notification.NotificationContext """ return NotificationContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class NotificationPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the NotificationPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The unique sid that identifies this account :returns: twilio.rest.api.v2010.account.notification.NotificationPage :rtype: twilio.rest.api.v2010.account.notification.NotificationPage """ super(NotificationPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of NotificationInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.notification.NotificationInstance :rtype: twilio.rest.api.v2010.account.notification.NotificationInstance """ return NotificationInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class NotificationContext(InstanceContext): """ """ def __init__(self, version, account_sid, sid): """ Initialize the NotificationContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param sid: Fetch by unique notification Sid :returns: twilio.rest.api.v2010.account.notification.NotificationContext :rtype: twilio.rest.api.v2010.account.notification.NotificationContext """ super(NotificationContext, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'sid': sid,} self._uri = '/Accounts/{account_sid}/Notifications/{sid}.json'.format(**self._solution) def fetch(self): """ Fetch a NotificationInstance :returns: Fetched NotificationInstance :rtype: twilio.rest.api.v2010.account.notification.NotificationInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return NotificationInstance( self._version, payload, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the NotificationInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class NotificationInstance(InstanceResource): """ """ def __init__(self, version, payload, account_sid, sid=None): """ Initialize the NotificationInstance :returns: twilio.rest.api.v2010.account.notification.NotificationInstance :rtype: twilio.rest.api.v2010.account.notification.NotificationInstance """ super(NotificationInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'api_version': payload['api_version'], 'call_sid': payload['call_sid'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'error_code': payload['error_code'], 'log': payload['log'], 'message_date': deserialize.rfc2822_datetime(payload['message_date']), 'message_text': payload['message_text'], 'more_info': payload['more_info'], 'request_method': payload['request_method'], 'request_url': payload['request_url'], 'sid': payload['sid'], 'uri': payload['uri'], 'request_variables': payload.get('request_variables'), 'response_body': payload.get('response_body'), 'response_headers': payload.get('response_headers'), } # Context self._context = None self._solution = {'account_sid': account_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: NotificationContext for this NotificationInstance :rtype: twilio.rest.api.v2010.account.notification.NotificationContext """ if self._context is None: self._context = NotificationContext( self._version, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: The unique sid that identifies this account :rtype: unicode """ return self._properties['account_sid'] @property def api_version(self): """ :returns: The version of the Twilio API in use :rtype: unicode """ return self._properties['api_version'] @property def call_sid(self): """ :returns: The string that uniquely identifies the call :rtype: unicode """ return self._properties['call_sid'] @property def date_created(self): """ :returns: The date this resource was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this resource was last updated :rtype: datetime """ return self._properties['date_updated'] @property def error_code(self): """ :returns: A unique error code corresponding to the notification :rtype: unicode """ return self._properties['error_code'] @property def log(self): """ :returns: An integer log level :rtype: unicode """ return self._properties['log'] @property def message_date(self): """ :returns: The date the notification was generated :rtype: datetime """ return self._properties['message_date'] @property def message_text(self): """ :returns: The text of the notification. :rtype: unicode """ return self._properties['message_text'] @property def more_info(self): """ :returns: A URL for more information about the error code :rtype: unicode """ return self._properties['more_info'] @property def request_method(self): """ :returns: HTTP method used with the request url :rtype: unicode """ return self._properties['request_method'] @property def request_url(self): """ :returns: URL of the resource that generated the notification :rtype: unicode """ return self._properties['request_url'] @property def request_variables(self): """ :returns: Twilio-generated HTTP variables sent to the server :rtype: unicode """ return self._properties['request_variables'] @property def response_body(self): """ :returns: The HTTP body returned by your server. :rtype: unicode """ return self._properties['response_body'] @property def response_headers(self): """ :returns: The HTTP headers returned by your server. :rtype: unicode """ return self._properties['response_headers'] @property def sid(self): """ :returns: A string that uniquely identifies this notification :rtype: unicode """ return self._properties['sid'] @property def uri(self): """ :returns: The URI for this resource :rtype: unicode """ return self._properties['uri'] def fetch(self): """ Fetch a NotificationInstance :returns: Fetched NotificationInstance :rtype: twilio.rest.api.v2010.account.notification.NotificationInstance """ return self._proxy.fetch() def delete(self): """ Deletes the NotificationInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/outgoing_caller_id.py000066400000000000000000000355061317472742600260470ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class OutgoingCallerIdList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the OutgoingCallerIdList :param Version version: Version that contains the resource :param account_sid: The unique sid that identifies this account :returns: twilio.rest.api.v2010.account.outgoing_caller_id.OutgoingCallerIdList :rtype: twilio.rest.api.v2010.account.outgoing_caller_id.OutgoingCallerIdList """ super(OutgoingCallerIdList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/OutgoingCallerIds.json'.format(**self._solution) def stream(self, phone_number=values.unset, friendly_name=values.unset, limit=None, page_size=None): """ Streams OutgoingCallerIdInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param unicode phone_number: Filter by phone number :param unicode friendly_name: Filter by friendly name :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.outgoing_caller_id.OutgoingCallerIdInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( phone_number=phone_number, friendly_name=friendly_name, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, phone_number=values.unset, friendly_name=values.unset, limit=None, page_size=None): """ Lists OutgoingCallerIdInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param unicode phone_number: Filter by phone number :param unicode friendly_name: Filter by friendly name :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.outgoing_caller_id.OutgoingCallerIdInstance] """ return list(self.stream( phone_number=phone_number, friendly_name=friendly_name, limit=limit, page_size=page_size, )) def page(self, phone_number=values.unset, friendly_name=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of OutgoingCallerIdInstance records from the API. Request is executed immediately :param unicode phone_number: Filter by phone number :param unicode friendly_name: Filter by friendly name :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of OutgoingCallerIdInstance :rtype: twilio.rest.api.v2010.account.outgoing_caller_id.OutgoingCallerIdPage """ params = values.of({ 'PhoneNumber': phone_number, 'FriendlyName': friendly_name, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return OutgoingCallerIdPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of OutgoingCallerIdInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of OutgoingCallerIdInstance :rtype: twilio.rest.api.v2010.account.outgoing_caller_id.OutgoingCallerIdPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return OutgoingCallerIdPage(self._version, response, self._solution) def get(self, sid): """ Constructs a OutgoingCallerIdContext :param sid: Fetch by unique outgoing-caller-id Sid :returns: twilio.rest.api.v2010.account.outgoing_caller_id.OutgoingCallerIdContext :rtype: twilio.rest.api.v2010.account.outgoing_caller_id.OutgoingCallerIdContext """ return OutgoingCallerIdContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __call__(self, sid): """ Constructs a OutgoingCallerIdContext :param sid: Fetch by unique outgoing-caller-id Sid :returns: twilio.rest.api.v2010.account.outgoing_caller_id.OutgoingCallerIdContext :rtype: twilio.rest.api.v2010.account.outgoing_caller_id.OutgoingCallerIdContext """ return OutgoingCallerIdContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class OutgoingCallerIdPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the OutgoingCallerIdPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The unique sid that identifies this account :returns: twilio.rest.api.v2010.account.outgoing_caller_id.OutgoingCallerIdPage :rtype: twilio.rest.api.v2010.account.outgoing_caller_id.OutgoingCallerIdPage """ super(OutgoingCallerIdPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of OutgoingCallerIdInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.outgoing_caller_id.OutgoingCallerIdInstance :rtype: twilio.rest.api.v2010.account.outgoing_caller_id.OutgoingCallerIdInstance """ return OutgoingCallerIdInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class OutgoingCallerIdContext(InstanceContext): """ """ def __init__(self, version, account_sid, sid): """ Initialize the OutgoingCallerIdContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param sid: Fetch by unique outgoing-caller-id Sid :returns: twilio.rest.api.v2010.account.outgoing_caller_id.OutgoingCallerIdContext :rtype: twilio.rest.api.v2010.account.outgoing_caller_id.OutgoingCallerIdContext """ super(OutgoingCallerIdContext, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'sid': sid,} self._uri = '/Accounts/{account_sid}/OutgoingCallerIds/{sid}.json'.format(**self._solution) def fetch(self): """ Fetch a OutgoingCallerIdInstance :returns: Fetched OutgoingCallerIdInstance :rtype: twilio.rest.api.v2010.account.outgoing_caller_id.OutgoingCallerIdInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return OutgoingCallerIdInstance( self._version, payload, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) def update(self, friendly_name=values.unset): """ Update the OutgoingCallerIdInstance :param unicode friendly_name: A human readable description of the caller ID :returns: Updated OutgoingCallerIdInstance :rtype: twilio.rest.api.v2010.account.outgoing_caller_id.OutgoingCallerIdInstance """ data = values.of({'FriendlyName': friendly_name,}) payload = self._version.update( 'POST', self._uri, data=data, ) return OutgoingCallerIdInstance( self._version, payload, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the OutgoingCallerIdInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class OutgoingCallerIdInstance(InstanceResource): """ """ def __init__(self, version, payload, account_sid, sid=None): """ Initialize the OutgoingCallerIdInstance :returns: twilio.rest.api.v2010.account.outgoing_caller_id.OutgoingCallerIdInstance :rtype: twilio.rest.api.v2010.account.outgoing_caller_id.OutgoingCallerIdInstance """ super(OutgoingCallerIdInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'friendly_name': payload['friendly_name'], 'account_sid': payload['account_sid'], 'phone_number': payload['phone_number'], 'uri': payload['uri'], } # Context self._context = None self._solution = {'account_sid': account_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: OutgoingCallerIdContext for this OutgoingCallerIdInstance :rtype: twilio.rest.api.v2010.account.outgoing_caller_id.OutgoingCallerIdContext """ if self._context is None: self._context = OutgoingCallerIdContext( self._version, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: A string that uniquely identifies this outgoing-caller-ids :rtype: unicode """ return self._properties['sid'] @property def date_created(self): """ :returns: The date this resource was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this resource was last updated :rtype: datetime """ return self._properties['date_updated'] @property def friendly_name(self): """ :returns: A human readable description for this resource :rtype: unicode """ return self._properties['friendly_name'] @property def account_sid(self): """ :returns: The unique sid that identifies this account :rtype: unicode """ return self._properties['account_sid'] @property def phone_number(self): """ :returns: The incoming phone number :rtype: unicode """ return self._properties['phone_number'] @property def uri(self): """ :returns: The URI for this resource :rtype: unicode """ return self._properties['uri'] def fetch(self): """ Fetch a OutgoingCallerIdInstance :returns: Fetched OutgoingCallerIdInstance :rtype: twilio.rest.api.v2010.account.outgoing_caller_id.OutgoingCallerIdInstance """ return self._proxy.fetch() def update(self, friendly_name=values.unset): """ Update the OutgoingCallerIdInstance :param unicode friendly_name: A human readable description of the caller ID :returns: Updated OutgoingCallerIdInstance :rtype: twilio.rest.api.v2010.account.outgoing_caller_id.OutgoingCallerIdInstance """ return self._proxy.update(friendly_name=friendly_name,) def delete(self): """ Deletes the OutgoingCallerIdInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/queue/000077500000000000000000000000001317472742600227575ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/api/v2010/account/queue/__init__.py000066400000000000000000000360401317472742600250730ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.api.v2010.account.queue.member import MemberList class QueueList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the QueueList :param Version version: Version that contains the resource :param account_sid: The account_sid :returns: twilio.rest.api.v2010.account.queue.QueueList :rtype: twilio.rest.api.v2010.account.queue.QueueList """ super(QueueList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/Queues.json'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams QueueInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.queue.QueueInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists QueueInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.queue.QueueInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of QueueInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of QueueInstance :rtype: twilio.rest.api.v2010.account.queue.QueuePage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return QueuePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of QueueInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of QueueInstance :rtype: twilio.rest.api.v2010.account.queue.QueuePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return QueuePage(self._version, response, self._solution) def create(self, friendly_name, max_size=values.unset): """ Create a new QueueInstance :param unicode friendly_name: A user-provided string that identifies this queue. :param unicode max_size: The max number of calls allowed in the queue :returns: Newly created QueueInstance :rtype: twilio.rest.api.v2010.account.queue.QueueInstance """ data = values.of({'FriendlyName': friendly_name, 'MaxSize': max_size,}) payload = self._version.create( 'POST', self._uri, data=data, ) return QueueInstance(self._version, payload, account_sid=self._solution['account_sid'],) def get(self, sid): """ Constructs a QueueContext :param sid: Fetch by unique queue Sid :returns: twilio.rest.api.v2010.account.queue.QueueContext :rtype: twilio.rest.api.v2010.account.queue.QueueContext """ return QueueContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __call__(self, sid): """ Constructs a QueueContext :param sid: Fetch by unique queue Sid :returns: twilio.rest.api.v2010.account.queue.QueueContext :rtype: twilio.rest.api.v2010.account.queue.QueueContext """ return QueueContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class QueuePage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the QueuePage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :returns: twilio.rest.api.v2010.account.queue.QueuePage :rtype: twilio.rest.api.v2010.account.queue.QueuePage """ super(QueuePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of QueueInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.queue.QueueInstance :rtype: twilio.rest.api.v2010.account.queue.QueueInstance """ return QueueInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class QueueContext(InstanceContext): """ """ def __init__(self, version, account_sid, sid): """ Initialize the QueueContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param sid: Fetch by unique queue Sid :returns: twilio.rest.api.v2010.account.queue.QueueContext :rtype: twilio.rest.api.v2010.account.queue.QueueContext """ super(QueueContext, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'sid': sid,} self._uri = '/Accounts/{account_sid}/Queues/{sid}.json'.format(**self._solution) # Dependents self._members = None def fetch(self): """ Fetch a QueueInstance :returns: Fetched QueueInstance :rtype: twilio.rest.api.v2010.account.queue.QueueInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return QueueInstance( self._version, payload, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) def update(self, friendly_name=values.unset, max_size=values.unset): """ Update the QueueInstance :param unicode friendly_name: A human readable description of the queue :param unicode max_size: The max number of members allowed in the queue :returns: Updated QueueInstance :rtype: twilio.rest.api.v2010.account.queue.QueueInstance """ data = values.of({'FriendlyName': friendly_name, 'MaxSize': max_size,}) payload = self._version.update( 'POST', self._uri, data=data, ) return QueueInstance( self._version, payload, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the QueueInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) @property def members(self): """ Access the members :returns: twilio.rest.api.v2010.account.queue.member.MemberList :rtype: twilio.rest.api.v2010.account.queue.member.MemberList """ if self._members is None: self._members = MemberList( self._version, account_sid=self._solution['account_sid'], queue_sid=self._solution['sid'], ) return self._members def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class QueueInstance(InstanceResource): """ """ def __init__(self, version, payload, account_sid, sid=None): """ Initialize the QueueInstance :returns: twilio.rest.api.v2010.account.queue.QueueInstance :rtype: twilio.rest.api.v2010.account.queue.QueueInstance """ super(QueueInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'average_wait_time': deserialize.integer(payload['average_wait_time']), 'current_size': deserialize.integer(payload['current_size']), 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'friendly_name': payload['friendly_name'], 'max_size': deserialize.integer(payload['max_size']), 'sid': payload['sid'], 'uri': payload['uri'], } # Context self._context = None self._solution = {'account_sid': account_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: QueueContext for this QueueInstance :rtype: twilio.rest.api.v2010.account.queue.QueueContext """ if self._context is None: self._context = QueueContext( self._version, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def average_wait_time(self): """ :returns: Average wait time of members in the queue :rtype: unicode """ return self._properties['average_wait_time'] @property def current_size(self): """ :returns: The count of calls currently in the queue. :rtype: unicode """ return self._properties['current_size'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def friendly_name(self): """ :returns: A user-provided string that identifies this queue. :rtype: unicode """ return self._properties['friendly_name'] @property def max_size(self): """ :returns: The max number of calls allowed in the queue :rtype: unicode """ return self._properties['max_size'] @property def sid(self): """ :returns: A string that uniquely identifies this queue :rtype: unicode """ return self._properties['sid'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def fetch(self): """ Fetch a QueueInstance :returns: Fetched QueueInstance :rtype: twilio.rest.api.v2010.account.queue.QueueInstance """ return self._proxy.fetch() def update(self, friendly_name=values.unset, max_size=values.unset): """ Update the QueueInstance :param unicode friendly_name: A human readable description of the queue :param unicode max_size: The max number of members allowed in the queue :returns: Updated QueueInstance :rtype: twilio.rest.api.v2010.account.queue.QueueInstance """ return self._proxy.update(friendly_name=friendly_name, max_size=max_size,) def delete(self): """ Deletes the QueueInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() @property def members(self): """ Access the members :returns: twilio.rest.api.v2010.account.queue.member.MemberList :rtype: twilio.rest.api.v2010.account.queue.member.MemberList """ return self._proxy.members def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/queue/member.py000066400000000000000000000317151317472742600246070ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class MemberList(ListResource): """ """ def __init__(self, version, account_sid, queue_sid): """ Initialize the MemberList :param Version version: Version that contains the resource :param account_sid: The account_sid :param queue_sid: A string that uniquely identifies this queue :returns: twilio.rest.api.v2010.account.queue.member.MemberList :rtype: twilio.rest.api.v2010.account.queue.member.MemberList """ super(MemberList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'queue_sid': queue_sid,} self._uri = '/Accounts/{account_sid}/Queues/{queue_sid}/Members.json'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams MemberInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.queue.member.MemberInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists MemberInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.queue.member.MemberInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of MemberInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of MemberInstance :rtype: twilio.rest.api.v2010.account.queue.member.MemberPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return MemberPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of MemberInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of MemberInstance :rtype: twilio.rest.api.v2010.account.queue.member.MemberPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return MemberPage(self._version, response, self._solution) def get(self, call_sid): """ Constructs a MemberContext :param call_sid: The call_sid :returns: twilio.rest.api.v2010.account.queue.member.MemberContext :rtype: twilio.rest.api.v2010.account.queue.member.MemberContext """ return MemberContext( self._version, account_sid=self._solution['account_sid'], queue_sid=self._solution['queue_sid'], call_sid=call_sid, ) def __call__(self, call_sid): """ Constructs a MemberContext :param call_sid: The call_sid :returns: twilio.rest.api.v2010.account.queue.member.MemberContext :rtype: twilio.rest.api.v2010.account.queue.member.MemberContext """ return MemberContext( self._version, account_sid=self._solution['account_sid'], queue_sid=self._solution['queue_sid'], call_sid=call_sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class MemberPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the MemberPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param queue_sid: A string that uniquely identifies this queue :returns: twilio.rest.api.v2010.account.queue.member.MemberPage :rtype: twilio.rest.api.v2010.account.queue.member.MemberPage """ super(MemberPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of MemberInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.queue.member.MemberInstance :rtype: twilio.rest.api.v2010.account.queue.member.MemberInstance """ return MemberInstance( self._version, payload, account_sid=self._solution['account_sid'], queue_sid=self._solution['queue_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class MemberContext(InstanceContext): """ """ def __init__(self, version, account_sid, queue_sid, call_sid): """ Initialize the MemberContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param queue_sid: The Queue in which to find the members :param call_sid: The call_sid :returns: twilio.rest.api.v2010.account.queue.member.MemberContext :rtype: twilio.rest.api.v2010.account.queue.member.MemberContext """ super(MemberContext, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'queue_sid': queue_sid, 'call_sid': call_sid,} self._uri = '/Accounts/{account_sid}/Queues/{queue_sid}/Members/{call_sid}.json'.format(**self._solution) def fetch(self): """ Fetch a MemberInstance :returns: Fetched MemberInstance :rtype: twilio.rest.api.v2010.account.queue.member.MemberInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return MemberInstance( self._version, payload, account_sid=self._solution['account_sid'], queue_sid=self._solution['queue_sid'], call_sid=self._solution['call_sid'], ) def update(self, url, method): """ Update the MemberInstance :param unicode url: The url :param unicode method: The method :returns: Updated MemberInstance :rtype: twilio.rest.api.v2010.account.queue.member.MemberInstance """ data = values.of({'Url': url, 'Method': method,}) payload = self._version.update( 'POST', self._uri, data=data, ) return MemberInstance( self._version, payload, account_sid=self._solution['account_sid'], queue_sid=self._solution['queue_sid'], call_sid=self._solution['call_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class MemberInstance(InstanceResource): """ """ def __init__(self, version, payload, account_sid, queue_sid, call_sid=None): """ Initialize the MemberInstance :returns: twilio.rest.api.v2010.account.queue.member.MemberInstance :rtype: twilio.rest.api.v2010.account.queue.member.MemberInstance """ super(MemberInstance, self).__init__(version) # Marshaled Properties self._properties = { 'call_sid': payload['call_sid'], 'date_enqueued': deserialize.rfc2822_datetime(payload['date_enqueued']), 'position': deserialize.integer(payload['position']), 'uri': payload['uri'], 'wait_time': deserialize.integer(payload['wait_time']), } # Context self._context = None self._solution = { 'account_sid': account_sid, 'queue_sid': queue_sid, 'call_sid': call_sid or self._properties['call_sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: MemberContext for this MemberInstance :rtype: twilio.rest.api.v2010.account.queue.member.MemberContext """ if self._context is None: self._context = MemberContext( self._version, account_sid=self._solution['account_sid'], queue_sid=self._solution['queue_sid'], call_sid=self._solution['call_sid'], ) return self._context @property def call_sid(self): """ :returns: Unique string that identifies this resource :rtype: unicode """ return self._properties['call_sid'] @property def date_enqueued(self): """ :returns: The date the member was enqueued :rtype: datetime """ return self._properties['date_enqueued'] @property def position(self): """ :returns: This member's current position in the queue. :rtype: unicode """ return self._properties['position'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] @property def wait_time(self): """ :returns: The number of seconds the member has been in the queue. :rtype: unicode """ return self._properties['wait_time'] def fetch(self): """ Fetch a MemberInstance :returns: Fetched MemberInstance :rtype: twilio.rest.api.v2010.account.queue.member.MemberInstance """ return self._proxy.fetch() def update(self, url, method): """ Update the MemberInstance :param unicode url: The url :param unicode method: The method :returns: Updated MemberInstance :rtype: twilio.rest.api.v2010.account.queue.member.MemberInstance """ return self._proxy.update(url, method,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/recording/000077500000000000000000000000001317472742600236075ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/api/v2010/account/recording/__init__.py000066400000000000000000000442141317472742600257250ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize 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.page import Page from twilio.rest.api.v2010.account.recording.add_on_result import AddOnResultList from twilio.rest.api.v2010.account.recording.transcription import TranscriptionList class RecordingList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the RecordingList :param Version version: Version that contains the resource :param account_sid: The unique sid that identifies this account :returns: twilio.rest.api.v2010.account.recording.RecordingList :rtype: twilio.rest.api.v2010.account.recording.RecordingList """ super(RecordingList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/Recordings.json'.format(**self._solution) def stream(self, date_created_before=values.unset, date_created=values.unset, date_created_after=values.unset, call_sid=values.unset, limit=None, page_size=None): """ Streams RecordingInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param datetime date_created_before: Filter by date created :param datetime date_created: Filter by date created :param datetime date_created_after: Filter by date created :param unicode call_sid: Filter by call_sid :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.recording.RecordingInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( date_created_before=date_created_before, date_created=date_created, date_created_after=date_created_after, call_sid=call_sid, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, date_created_before=values.unset, date_created=values.unset, date_created_after=values.unset, call_sid=values.unset, limit=None, page_size=None): """ Lists RecordingInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param datetime date_created_before: Filter by date created :param datetime date_created: Filter by date created :param datetime date_created_after: Filter by date created :param unicode call_sid: Filter by call_sid :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.recording.RecordingInstance] """ return list(self.stream( date_created_before=date_created_before, date_created=date_created, date_created_after=date_created_after, call_sid=call_sid, limit=limit, page_size=page_size, )) def page(self, date_created_before=values.unset, date_created=values.unset, date_created_after=values.unset, call_sid=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of RecordingInstance records from the API. Request is executed immediately :param datetime date_created_before: Filter by date created :param datetime date_created: Filter by date created :param datetime date_created_after: Filter by date created :param unicode call_sid: Filter by call_sid :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of RecordingInstance :rtype: twilio.rest.api.v2010.account.recording.RecordingPage """ params = values.of({ 'DateCreated<': serialize.iso8601_datetime(date_created_before), 'DateCreated': serialize.iso8601_datetime(date_created), 'DateCreated>': serialize.iso8601_datetime(date_created_after), 'CallSid': call_sid, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return RecordingPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of RecordingInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of RecordingInstance :rtype: twilio.rest.api.v2010.account.recording.RecordingPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return RecordingPage(self._version, response, self._solution) def get(self, sid): """ Constructs a RecordingContext :param sid: Fetch by unique recording Sid :returns: twilio.rest.api.v2010.account.recording.RecordingContext :rtype: twilio.rest.api.v2010.account.recording.RecordingContext """ return RecordingContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __call__(self, sid): """ Constructs a RecordingContext :param sid: Fetch by unique recording Sid :returns: twilio.rest.api.v2010.account.recording.RecordingContext :rtype: twilio.rest.api.v2010.account.recording.RecordingContext """ return RecordingContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class RecordingPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the RecordingPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The unique sid that identifies this account :returns: twilio.rest.api.v2010.account.recording.RecordingPage :rtype: twilio.rest.api.v2010.account.recording.RecordingPage """ super(RecordingPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of RecordingInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.recording.RecordingInstance :rtype: twilio.rest.api.v2010.account.recording.RecordingInstance """ return RecordingInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class RecordingContext(InstanceContext): """ """ def __init__(self, version, account_sid, sid): """ Initialize the RecordingContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param sid: Fetch by unique recording Sid :returns: twilio.rest.api.v2010.account.recording.RecordingContext :rtype: twilio.rest.api.v2010.account.recording.RecordingContext """ super(RecordingContext, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'sid': sid,} self._uri = '/Accounts/{account_sid}/Recordings/{sid}.json'.format(**self._solution) # Dependents self._transcriptions = None self._add_on_results = None def fetch(self): """ Fetch a RecordingInstance :returns: Fetched RecordingInstance :rtype: twilio.rest.api.v2010.account.recording.RecordingInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return RecordingInstance( self._version, payload, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the RecordingInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) @property def transcriptions(self): """ Access the transcriptions :returns: twilio.rest.api.v2010.account.recording.transcription.TranscriptionList :rtype: twilio.rest.api.v2010.account.recording.transcription.TranscriptionList """ if self._transcriptions is None: self._transcriptions = TranscriptionList( self._version, account_sid=self._solution['account_sid'], recording_sid=self._solution['sid'], ) return self._transcriptions @property def add_on_results(self): """ Access the add_on_results :returns: twilio.rest.api.v2010.account.recording.add_on_result.AddOnResultList :rtype: twilio.rest.api.v2010.account.recording.add_on_result.AddOnResultList """ if self._add_on_results is None: self._add_on_results = AddOnResultList( self._version, account_sid=self._solution['account_sid'], reference_sid=self._solution['sid'], ) return self._add_on_results def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class RecordingInstance(InstanceResource): """ """ class Source(object): DIALVERB = "DialVerb" CONFERENCE = "Conference" OUTBOUNDAPI = "OutboundAPI" TRUNKING = "Trunking" RECORDVERB = "RecordVerb" class Status(object): PROCESSING = "processing" COMPLETED = "completed" FAILED = "failed" def __init__(self, version, payload, account_sid, sid=None): """ Initialize the RecordingInstance :returns: twilio.rest.api.v2010.account.recording.RecordingInstance :rtype: twilio.rest.api.v2010.account.recording.RecordingInstance """ super(RecordingInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'api_version': payload['api_version'], 'call_sid': payload['call_sid'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'duration': payload['duration'], 'sid': payload['sid'], 'price': payload['price'], 'price_unit': payload['price_unit'], 'status': payload['status'], 'channels': deserialize.integer(payload['channels']), 'source': payload['source'], 'uri': payload['uri'], 'encryption_details': payload['encryption_details'], 'error_code': deserialize.integer(payload['error_code']), } # Context self._context = None self._solution = {'account_sid': account_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: RecordingContext for this RecordingInstance :rtype: twilio.rest.api.v2010.account.recording.RecordingContext """ if self._context is None: self._context = RecordingContext( self._version, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: The unique sid that identifies this account :rtype: unicode """ return self._properties['account_sid'] @property def api_version(self): """ :returns: The version of the API in use during the recording. :rtype: unicode """ return self._properties['api_version'] @property def call_sid(self): """ :returns: The call during which the recording was made. :rtype: unicode """ return self._properties['call_sid'] @property def date_created(self): """ :returns: The date this resource was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this resource was last updated :rtype: datetime """ return self._properties['date_updated'] @property def duration(self): """ :returns: The length of the recording, in seconds. :rtype: unicode """ return self._properties['duration'] @property def sid(self): """ :returns: A string that uniquely identifies this recording :rtype: unicode """ return self._properties['sid'] @property def price(self): """ :returns: The price :rtype: unicode """ return self._properties['price'] @property def price_unit(self): """ :returns: The price_unit :rtype: unicode """ return self._properties['price_unit'] @property def status(self): """ :returns: The status :rtype: RecordingInstance.Status """ return self._properties['status'] @property def channels(self): """ :returns: The channels :rtype: unicode """ return self._properties['channels'] @property def source(self): """ :returns: The source :rtype: RecordingInstance.Source """ return self._properties['source'] @property def uri(self): """ :returns: The URI for this resource :rtype: unicode """ return self._properties['uri'] @property def encryption_details(self): """ :returns: The encryption_details :rtype: dict """ return self._properties['encryption_details'] @property def error_code(self): """ :returns: More information about the recording failure, if Status is failed. :rtype: unicode """ return self._properties['error_code'] def fetch(self): """ Fetch a RecordingInstance :returns: Fetched RecordingInstance :rtype: twilio.rest.api.v2010.account.recording.RecordingInstance """ return self._proxy.fetch() def delete(self): """ Deletes the RecordingInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() @property def transcriptions(self): """ Access the transcriptions :returns: twilio.rest.api.v2010.account.recording.transcription.TranscriptionList :rtype: twilio.rest.api.v2010.account.recording.transcription.TranscriptionList """ return self._proxy.transcriptions @property def add_on_results(self): """ Access the add_on_results :returns: twilio.rest.api.v2010.account.recording.add_on_result.AddOnResultList :rtype: twilio.rest.api.v2010.account.recording.add_on_result.AddOnResultList """ return self._proxy.add_on_results def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/recording/add_on_result/000077500000000000000000000000001317472742600264315ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/api/v2010/account/recording/add_on_result/__init__.py000066400000000000000000000371351317472742600305530ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.api.v2010.account.recording.add_on_result.payload import PayloadList class AddOnResultList(ListResource): """ """ def __init__(self, version, account_sid, reference_sid): """ Initialize the AddOnResultList :param Version version: Version that contains the resource :param account_sid: The unique sid that identifies this account :param reference_sid: A string that uniquely identifies the recording. :returns: twilio.rest.api.v2010.account.recording.add_on_result.AddOnResultList :rtype: twilio.rest.api.v2010.account.recording.add_on_result.AddOnResultList """ super(AddOnResultList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'reference_sid': reference_sid,} self._uri = '/Accounts/{account_sid}/Recordings/{reference_sid}/AddOnResults.json'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams AddOnResultInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.recording.add_on_result.AddOnResultInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists AddOnResultInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.recording.add_on_result.AddOnResultInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of AddOnResultInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of AddOnResultInstance :rtype: twilio.rest.api.v2010.account.recording.add_on_result.AddOnResultPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return AddOnResultPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of AddOnResultInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of AddOnResultInstance :rtype: twilio.rest.api.v2010.account.recording.add_on_result.AddOnResultPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return AddOnResultPage(self._version, response, self._solution) def get(self, sid): """ Constructs a AddOnResultContext :param sid: Fetch by unique result Sid :returns: twilio.rest.api.v2010.account.recording.add_on_result.AddOnResultContext :rtype: twilio.rest.api.v2010.account.recording.add_on_result.AddOnResultContext """ return AddOnResultContext( self._version, account_sid=self._solution['account_sid'], reference_sid=self._solution['reference_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a AddOnResultContext :param sid: Fetch by unique result Sid :returns: twilio.rest.api.v2010.account.recording.add_on_result.AddOnResultContext :rtype: twilio.rest.api.v2010.account.recording.add_on_result.AddOnResultContext """ return AddOnResultContext( self._version, account_sid=self._solution['account_sid'], reference_sid=self._solution['reference_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class AddOnResultPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the AddOnResultPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The unique sid that identifies this account :param reference_sid: A string that uniquely identifies the recording. :returns: twilio.rest.api.v2010.account.recording.add_on_result.AddOnResultPage :rtype: twilio.rest.api.v2010.account.recording.add_on_result.AddOnResultPage """ super(AddOnResultPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of AddOnResultInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.recording.add_on_result.AddOnResultInstance :rtype: twilio.rest.api.v2010.account.recording.add_on_result.AddOnResultInstance """ return AddOnResultInstance( self._version, payload, account_sid=self._solution['account_sid'], reference_sid=self._solution['reference_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class AddOnResultContext(InstanceContext): """ """ def __init__(self, version, account_sid, reference_sid, sid): """ Initialize the AddOnResultContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param reference_sid: The reference_sid :param sid: Fetch by unique result Sid :returns: twilio.rest.api.v2010.account.recording.add_on_result.AddOnResultContext :rtype: twilio.rest.api.v2010.account.recording.add_on_result.AddOnResultContext """ super(AddOnResultContext, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'reference_sid': reference_sid, 'sid': sid,} self._uri = '/Accounts/{account_sid}/Recordings/{reference_sid}/AddOnResults/{sid}.json'.format(**self._solution) # Dependents self._payloads = None def fetch(self): """ Fetch a AddOnResultInstance :returns: Fetched AddOnResultInstance :rtype: twilio.rest.api.v2010.account.recording.add_on_result.AddOnResultInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return AddOnResultInstance( self._version, payload, account_sid=self._solution['account_sid'], reference_sid=self._solution['reference_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the AddOnResultInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) @property def payloads(self): """ Access the payloads :returns: twilio.rest.api.v2010.account.recording.add_on_result.payload.PayloadList :rtype: twilio.rest.api.v2010.account.recording.add_on_result.payload.PayloadList """ if self._payloads is None: self._payloads = PayloadList( self._version, account_sid=self._solution['account_sid'], reference_sid=self._solution['reference_sid'], add_on_result_sid=self._solution['sid'], ) return self._payloads def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class AddOnResultInstance(InstanceResource): """ """ class Status(object): CANCELED = "canceled" COMPLETED = "completed" DELETED = "deleted" FAILED = "failed" IN_PROGRESS = "in-progress" INIT = "init" PROCESSING = "processing" QUEUED = "queued" def __init__(self, version, payload, account_sid, reference_sid, sid=None): """ Initialize the AddOnResultInstance :returns: twilio.rest.api.v2010.account.recording.add_on_result.AddOnResultInstance :rtype: twilio.rest.api.v2010.account.recording.add_on_result.AddOnResultInstance """ super(AddOnResultInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'status': payload['status'], 'add_on_sid': payload['add_on_sid'], 'add_on_configuration_sid': payload['add_on_configuration_sid'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'date_completed': deserialize.rfc2822_datetime(payload['date_completed']), 'reference_sid': payload['reference_sid'], 'subresource_uris': payload['subresource_uris'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'reference_sid': reference_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: AddOnResultContext for this AddOnResultInstance :rtype: twilio.rest.api.v2010.account.recording.add_on_result.AddOnResultContext """ if self._context is None: self._context = AddOnResultContext( self._version, account_sid=self._solution['account_sid'], reference_sid=self._solution['reference_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: A string that uniquely identifies this result :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The unique sid that identifies this account :rtype: unicode """ return self._properties['account_sid'] @property def status(self): """ :returns: The status of this result. :rtype: AddOnResultInstance.Status """ return self._properties['status'] @property def add_on_sid(self): """ :returns: A string that uniquely identifies the Add-on. :rtype: unicode """ return self._properties['add_on_sid'] @property def add_on_configuration_sid(self): """ :returns: A string that uniquely identifies the Add-on configuration. :rtype: unicode """ return self._properties['add_on_configuration_sid'] @property def date_created(self): """ :returns: The date this resource was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this resource was last updated :rtype: datetime """ return self._properties['date_updated'] @property def date_completed(self): """ :returns: The date this result was completed. :rtype: datetime """ return self._properties['date_completed'] @property def reference_sid(self): """ :returns: A string that uniquely identifies the recording. :rtype: unicode """ return self._properties['reference_sid'] @property def subresource_uris(self): """ :returns: The subresource_uris :rtype: unicode """ return self._properties['subresource_uris'] def fetch(self): """ Fetch a AddOnResultInstance :returns: Fetched AddOnResultInstance :rtype: twilio.rest.api.v2010.account.recording.add_on_result.AddOnResultInstance """ return self._proxy.fetch() def delete(self): """ Deletes the AddOnResultInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() @property def payloads(self): """ Access the payloads :returns: twilio.rest.api.v2010.account.recording.add_on_result.payload.PayloadList :rtype: twilio.rest.api.v2010.account.recording.add_on_result.payload.PayloadList """ return self._proxy.payloads def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/recording/add_on_result/payload/000077500000000000000000000000001317472742600300625ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/api/v2010/account/recording/add_on_result/payload/__init__.py000066400000000000000000000365451317472742600322100ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class PayloadList(ListResource): """ """ def __init__(self, version, account_sid, reference_sid, add_on_result_sid): """ Initialize the PayloadList :param Version version: Version that contains the resource :param account_sid: The unique sid that identifies this account :param reference_sid: A string that uniquely identifies the recording. :param add_on_result_sid: A string that uniquely identifies the result :returns: twilio.rest.api.v2010.account.recording.add_on_result.payload.PayloadList :rtype: twilio.rest.api.v2010.account.recording.add_on_result.payload.PayloadList """ super(PayloadList, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'reference_sid': reference_sid, 'add_on_result_sid': add_on_result_sid, } self._uri = '/Accounts/{account_sid}/Recordings/{reference_sid}/AddOnResults/{add_on_result_sid}/Payloads.json'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams PayloadInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.recording.add_on_result.payload.PayloadInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists PayloadInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.recording.add_on_result.payload.PayloadInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of PayloadInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of PayloadInstance :rtype: twilio.rest.api.v2010.account.recording.add_on_result.payload.PayloadPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return PayloadPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of PayloadInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of PayloadInstance :rtype: twilio.rest.api.v2010.account.recording.add_on_result.payload.PayloadPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return PayloadPage(self._version, response, self._solution) def get(self, sid): """ Constructs a PayloadContext :param sid: Fetch by unique payload Sid :returns: twilio.rest.api.v2010.account.recording.add_on_result.payload.PayloadContext :rtype: twilio.rest.api.v2010.account.recording.add_on_result.payload.PayloadContext """ return PayloadContext( self._version, account_sid=self._solution['account_sid'], reference_sid=self._solution['reference_sid'], add_on_result_sid=self._solution['add_on_result_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a PayloadContext :param sid: Fetch by unique payload Sid :returns: twilio.rest.api.v2010.account.recording.add_on_result.payload.PayloadContext :rtype: twilio.rest.api.v2010.account.recording.add_on_result.payload.PayloadContext """ return PayloadContext( self._version, account_sid=self._solution['account_sid'], reference_sid=self._solution['reference_sid'], add_on_result_sid=self._solution['add_on_result_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class PayloadPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the PayloadPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The unique sid that identifies this account :param reference_sid: A string that uniquely identifies the recording. :param add_on_result_sid: A string that uniquely identifies the result :returns: twilio.rest.api.v2010.account.recording.add_on_result.payload.PayloadPage :rtype: twilio.rest.api.v2010.account.recording.add_on_result.payload.PayloadPage """ super(PayloadPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of PayloadInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.recording.add_on_result.payload.PayloadInstance :rtype: twilio.rest.api.v2010.account.recording.add_on_result.payload.PayloadInstance """ return PayloadInstance( 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'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class PayloadContext(InstanceContext): """ """ def __init__(self, version, account_sid, reference_sid, add_on_result_sid, sid): """ Initialize the PayloadContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param reference_sid: The reference_sid :param add_on_result_sid: The add_on_result_sid :param sid: Fetch by unique payload Sid :returns: twilio.rest.api.v2010.account.recording.add_on_result.payload.PayloadContext :rtype: twilio.rest.api.v2010.account.recording.add_on_result.payload.PayloadContext """ super(PayloadContext, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'reference_sid': reference_sid, 'add_on_result_sid': add_on_result_sid, 'sid': sid, } self._uri = '/Accounts/{account_sid}/Recordings/{reference_sid}/AddOnResults/{add_on_result_sid}/Payloads/{sid}.json'.format(**self._solution) def fetch(self): """ Fetch a PayloadInstance :returns: Fetched PayloadInstance :rtype: twilio.rest.api.v2010.account.recording.add_on_result.payload.PayloadInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return PayloadInstance( 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'], sid=self._solution['sid'], ) def delete(self): """ Deletes the PayloadInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class PayloadInstance(InstanceResource): """ """ def __init__(self, version, payload, account_sid, reference_sid, add_on_result_sid, sid=None): """ Initialize the PayloadInstance :returns: twilio.rest.api.v2010.account.recording.add_on_result.payload.PayloadInstance :rtype: twilio.rest.api.v2010.account.recording.add_on_result.payload.PayloadInstance """ super(PayloadInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'add_on_result_sid': payload['add_on_result_sid'], 'account_sid': payload['account_sid'], 'label': payload['label'], 'add_on_sid': payload['add_on_sid'], 'add_on_configuration_sid': payload['add_on_configuration_sid'], 'content_type': payload['content_type'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'reference_sid': payload['reference_sid'], 'subresource_uris': payload['subresource_uris'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'reference_sid': reference_sid, 'add_on_result_sid': add_on_result_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: PayloadContext for this PayloadInstance :rtype: twilio.rest.api.v2010.account.recording.add_on_result.payload.PayloadContext """ if self._context is None: self._context = PayloadContext( self._version, account_sid=self._solution['account_sid'], reference_sid=self._solution['reference_sid'], add_on_result_sid=self._solution['add_on_result_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: A string that uniquely identifies this payload :rtype: unicode """ return self._properties['sid'] @property def add_on_result_sid(self): """ :returns: A string that uniquely identifies the result :rtype: unicode """ return self._properties['add_on_result_sid'] @property def account_sid(self): """ :returns: The unique sid that identifies this account :rtype: unicode """ return self._properties['account_sid'] @property def label(self): """ :returns: A string that describes the payload. :rtype: unicode """ return self._properties['label'] @property def add_on_sid(self): """ :returns: A string that uniquely identifies the Add-on. :rtype: unicode """ return self._properties['add_on_sid'] @property def add_on_configuration_sid(self): """ :returns: A string that uniquely identifies the Add-on configuration. :rtype: unicode """ return self._properties['add_on_configuration_sid'] @property def content_type(self): """ :returns: The MIME type of the payload. :rtype: unicode """ return self._properties['content_type'] @property def date_created(self): """ :returns: The date this resource was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this resource was last updated :rtype: datetime """ return self._properties['date_updated'] @property def reference_sid(self): """ :returns: A string that uniquely identifies the recording. :rtype: unicode """ return self._properties['reference_sid'] @property def subresource_uris(self): """ :returns: The subresource_uris :rtype: unicode """ return self._properties['subresource_uris'] def fetch(self): """ Fetch a PayloadInstance :returns: Fetched PayloadInstance :rtype: twilio.rest.api.v2010.account.recording.add_on_result.payload.PayloadInstance """ return self._proxy.fetch() def delete(self): """ Deletes the PayloadInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/recording/transcription.py000066400000000000000000000351561317472742600270720ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class TranscriptionList(ListResource): """ """ def __init__(self, version, account_sid, recording_sid): """ Initialize the TranscriptionList :param Version version: Version that contains the resource :param account_sid: The account_sid :param recording_sid: The recording_sid :returns: twilio.rest.api.v2010.account.recording.transcription.TranscriptionList :rtype: twilio.rest.api.v2010.account.recording.transcription.TranscriptionList """ super(TranscriptionList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'recording_sid': recording_sid,} self._uri = '/Accounts/{account_sid}/Recordings/{recording_sid}/Transcriptions.json'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams TranscriptionInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.recording.transcription.TranscriptionInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists TranscriptionInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.recording.transcription.TranscriptionInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of TranscriptionInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of TranscriptionInstance :rtype: twilio.rest.api.v2010.account.recording.transcription.TranscriptionPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return TranscriptionPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of TranscriptionInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of TranscriptionInstance :rtype: twilio.rest.api.v2010.account.recording.transcription.TranscriptionPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return TranscriptionPage(self._version, response, self._solution) def get(self, sid): """ Constructs a TranscriptionContext :param sid: The sid :returns: twilio.rest.api.v2010.account.recording.transcription.TranscriptionContext :rtype: twilio.rest.api.v2010.account.recording.transcription.TranscriptionContext """ return TranscriptionContext( self._version, account_sid=self._solution['account_sid'], recording_sid=self._solution['recording_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a TranscriptionContext :param sid: The sid :returns: twilio.rest.api.v2010.account.recording.transcription.TranscriptionContext :rtype: twilio.rest.api.v2010.account.recording.transcription.TranscriptionContext """ return TranscriptionContext( self._version, account_sid=self._solution['account_sid'], recording_sid=self._solution['recording_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class TranscriptionPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the TranscriptionPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param recording_sid: The recording_sid :returns: twilio.rest.api.v2010.account.recording.transcription.TranscriptionPage :rtype: twilio.rest.api.v2010.account.recording.transcription.TranscriptionPage """ super(TranscriptionPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of TranscriptionInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.recording.transcription.TranscriptionInstance :rtype: twilio.rest.api.v2010.account.recording.transcription.TranscriptionInstance """ return TranscriptionInstance( self._version, payload, account_sid=self._solution['account_sid'], recording_sid=self._solution['recording_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class TranscriptionContext(InstanceContext): """ """ def __init__(self, version, account_sid, recording_sid, sid): """ Initialize the TranscriptionContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param recording_sid: The recording_sid :param sid: The sid :returns: twilio.rest.api.v2010.account.recording.transcription.TranscriptionContext :rtype: twilio.rest.api.v2010.account.recording.transcription.TranscriptionContext """ super(TranscriptionContext, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'recording_sid': recording_sid, 'sid': sid,} self._uri = '/Accounts/{account_sid}/Recordings/{recording_sid}/Transcriptions/{sid}.json'.format(**self._solution) def fetch(self): """ Fetch a TranscriptionInstance :returns: Fetched TranscriptionInstance :rtype: twilio.rest.api.v2010.account.recording.transcription.TranscriptionInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return TranscriptionInstance( self._version, payload, account_sid=self._solution['account_sid'], recording_sid=self._solution['recording_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the TranscriptionInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class TranscriptionInstance(InstanceResource): """ """ class Status(object): IN_PROGRESS = "in-progress" COMPLETED = "completed" FAILED = "failed" def __init__(self, version, payload, account_sid, recording_sid, sid=None): """ Initialize the TranscriptionInstance :returns: twilio.rest.api.v2010.account.recording.transcription.TranscriptionInstance :rtype: twilio.rest.api.v2010.account.recording.transcription.TranscriptionInstance """ super(TranscriptionInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'api_version': payload['api_version'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'duration': payload['duration'], 'price': deserialize.decimal(payload['price']), 'price_unit': payload['price_unit'], 'recording_sid': payload['recording_sid'], 'sid': payload['sid'], 'status': payload['status'], 'transcription_text': payload['transcription_text'], 'type': payload['type'], 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'recording_sid': recording_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ 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 :rtype: twilio.rest.api.v2010.account.recording.transcription.TranscriptionContext """ if self._context is None: self._context = TranscriptionContext( self._version, account_sid=self._solution['account_sid'], recording_sid=self._solution['recording_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def api_version(self): """ :returns: The api_version :rtype: unicode """ return self._properties['api_version'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def duration(self): """ :returns: The duration :rtype: unicode """ return self._properties['duration'] @property def price(self): """ :returns: The price :rtype: unicode """ return self._properties['price'] @property def price_unit(self): """ :returns: The price_unit :rtype: unicode """ return self._properties['price_unit'] @property def recording_sid(self): """ :returns: The recording_sid :rtype: unicode """ return self._properties['recording_sid'] @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def status(self): """ :returns: The status :rtype: TranscriptionInstance.Status """ return self._properties['status'] @property def transcription_text(self): """ :returns: The transcription_text :rtype: unicode """ return self._properties['transcription_text'] @property def type(self): """ :returns: The type :rtype: unicode """ return self._properties['type'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def fetch(self): """ Fetch a TranscriptionInstance :returns: Fetched TranscriptionInstance :rtype: twilio.rest.api.v2010.account.recording.transcription.TranscriptionInstance """ return self._proxy.fetch() def delete(self): """ Deletes the TranscriptionInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/short_code.py000066400000000000000000000407571317472742600243530ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class ShortCodeList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the ShortCodeList :param Version version: Version that contains the resource :param account_sid: The unique sid that identifies this account :returns: twilio.rest.api.v2010.account.short_code.ShortCodeList :rtype: twilio.rest.api.v2010.account.short_code.ShortCodeList """ super(ShortCodeList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/SMS/ShortCodes.json'.format(**self._solution) def stream(self, friendly_name=values.unset, short_code=values.unset, limit=None, page_size=None): """ Streams ShortCodeInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param unicode friendly_name: Filter by friendly name :param unicode short_code: Filter by ShortCode :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.short_code.ShortCodeInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(friendly_name=friendly_name, short_code=short_code, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, friendly_name=values.unset, short_code=values.unset, limit=None, page_size=None): """ Lists ShortCodeInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param unicode friendly_name: Filter by friendly name :param unicode short_code: Filter by ShortCode :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.short_code.ShortCodeInstance] """ return list(self.stream( friendly_name=friendly_name, short_code=short_code, limit=limit, page_size=page_size, )) def page(self, friendly_name=values.unset, short_code=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of ShortCodeInstance records from the API. Request is executed immediately :param unicode friendly_name: Filter by friendly name :param unicode short_code: Filter by ShortCode :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of ShortCodeInstance :rtype: twilio.rest.api.v2010.account.short_code.ShortCodePage """ params = values.of({ 'FriendlyName': friendly_name, 'ShortCode': short_code, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return ShortCodePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of ShortCodeInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of ShortCodeInstance :rtype: twilio.rest.api.v2010.account.short_code.ShortCodePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return ShortCodePage(self._version, response, self._solution) def get(self, sid): """ Constructs a ShortCodeContext :param sid: Fetch by unique short-code Sid :returns: twilio.rest.api.v2010.account.short_code.ShortCodeContext :rtype: twilio.rest.api.v2010.account.short_code.ShortCodeContext """ return ShortCodeContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __call__(self, sid): """ Constructs a ShortCodeContext :param sid: Fetch by unique short-code Sid :returns: twilio.rest.api.v2010.account.short_code.ShortCodeContext :rtype: twilio.rest.api.v2010.account.short_code.ShortCodeContext """ return ShortCodeContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ShortCodePage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the ShortCodePage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The unique sid that identifies this account :returns: twilio.rest.api.v2010.account.short_code.ShortCodePage :rtype: twilio.rest.api.v2010.account.short_code.ShortCodePage """ super(ShortCodePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of ShortCodeInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.short_code.ShortCodeInstance :rtype: twilio.rest.api.v2010.account.short_code.ShortCodeInstance """ return ShortCodeInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ShortCodeContext(InstanceContext): """ """ def __init__(self, version, account_sid, sid): """ Initialize the ShortCodeContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param sid: Fetch by unique short-code Sid :returns: twilio.rest.api.v2010.account.short_code.ShortCodeContext :rtype: twilio.rest.api.v2010.account.short_code.ShortCodeContext """ super(ShortCodeContext, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'sid': sid,} self._uri = '/Accounts/{account_sid}/SMS/ShortCodes/{sid}.json'.format(**self._solution) def fetch(self): """ Fetch a ShortCodeInstance :returns: Fetched ShortCodeInstance :rtype: twilio.rest.api.v2010.account.short_code.ShortCodeInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return ShortCodeInstance( self._version, payload, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) def update(self, friendly_name=values.unset, api_version=values.unset, sms_url=values.unset, sms_method=values.unset, sms_fallback_url=values.unset, sms_fallback_method=values.unset): """ Update the ShortCodeInstance :param unicode friendly_name: A human readable description of this resource :param unicode api_version: The API version to use :param unicode sms_url: URL Twilio will request when receiving an SMS :param unicode sms_method: HTTP method to use when requesting the sms url :param unicode sms_fallback_url: URL Twilio will request if an error occurs in executing TwiML :param unicode sms_fallback_method: HTTP method Twilio will use with sms fallback url :returns: Updated ShortCodeInstance :rtype: twilio.rest.api.v2010.account.short_code.ShortCodeInstance """ data = values.of({ 'FriendlyName': friendly_name, 'ApiVersion': api_version, 'SmsUrl': sms_url, 'SmsMethod': sms_method, 'SmsFallbackUrl': sms_fallback_url, 'SmsFallbackMethod': sms_fallback_method, }) payload = self._version.update( 'POST', self._uri, data=data, ) return ShortCodeInstance( self._version, payload, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class ShortCodeInstance(InstanceResource): """ """ def __init__(self, version, payload, account_sid, sid=None): """ Initialize the ShortCodeInstance :returns: twilio.rest.api.v2010.account.short_code.ShortCodeInstance :rtype: twilio.rest.api.v2010.account.short_code.ShortCodeInstance """ super(ShortCodeInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'api_version': payload['api_version'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'friendly_name': payload['friendly_name'], 'short_code': payload['short_code'], 'sid': payload['sid'], 'sms_fallback_method': payload['sms_fallback_method'], 'sms_fallback_url': payload['sms_fallback_url'], 'sms_method': payload['sms_method'], 'sms_url': payload['sms_url'], 'uri': payload['uri'], } # Context self._context = None self._solution = {'account_sid': account_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.api.v2010.account.short_code.ShortCodeContext """ if self._context is None: self._context = ShortCodeContext( self._version, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: The unique sid that identifies this account :rtype: unicode """ return self._properties['account_sid'] @property def api_version(self): """ :returns: The API version to use :rtype: unicode """ return self._properties['api_version'] @property def date_created(self): """ :returns: The date this resource was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this resource was last updated :rtype: datetime """ return self._properties['date_updated'] @property def friendly_name(self): """ :returns: A human readable description of this resource :rtype: unicode """ return self._properties['friendly_name'] @property def short_code(self): """ :returns: The short code. e.g., 894546. :rtype: unicode """ return self._properties['short_code'] @property def sid(self): """ :returns: A string that uniquely identifies this short-codes :rtype: unicode """ return self._properties['sid'] @property def sms_fallback_method(self): """ :returns: HTTP method Twilio will use with sms fallback url :rtype: unicode """ return self._properties['sms_fallback_method'] @property def sms_fallback_url(self): """ :returns: URL Twilio will request if an error occurs in executing TwiML :rtype: unicode """ return self._properties['sms_fallback_url'] @property def sms_method(self): """ :returns: HTTP method to use when requesting the sms url :rtype: unicode """ return self._properties['sms_method'] @property def sms_url(self): """ :returns: URL Twilio will request when receiving an SMS :rtype: unicode """ return self._properties['sms_url'] @property def uri(self): """ :returns: The URI for this resource :rtype: unicode """ return self._properties['uri'] def fetch(self): """ Fetch a ShortCodeInstance :returns: Fetched ShortCodeInstance :rtype: twilio.rest.api.v2010.account.short_code.ShortCodeInstance """ return self._proxy.fetch() def update(self, friendly_name=values.unset, api_version=values.unset, sms_url=values.unset, sms_method=values.unset, sms_fallback_url=values.unset, sms_fallback_method=values.unset): """ Update the ShortCodeInstance :param unicode friendly_name: A human readable description of this resource :param unicode api_version: The API version to use :param unicode sms_url: URL Twilio will request when receiving an SMS :param unicode sms_method: HTTP method to use when requesting the sms url :param unicode sms_fallback_url: URL Twilio will request if an error occurs in executing TwiML :param unicode sms_fallback_method: HTTP method Twilio will use with sms fallback url :returns: Updated ShortCodeInstance :rtype: twilio.rest.api.v2010.account.short_code.ShortCodeInstance """ return self._proxy.update( friendly_name=friendly_name, api_version=api_version, sms_url=sms_url, sms_method=sms_method, sms_fallback_url=sms_fallback_url, sms_fallback_method=sms_fallback_method, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/signing_key.py000066400000000000000000000307231317472742600245200ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class SigningKeyList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the SigningKeyList :param Version version: Version that contains the resource :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.signing_key.SigningKeyList :rtype: twilio.rest.api.v2010.account.signing_key.SigningKeyList """ super(SigningKeyList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/SigningKeys.json'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams SigningKeyInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.signing_key.SigningKeyInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists SigningKeyInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.signing_key.SigningKeyInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of SigningKeyInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of SigningKeyInstance :rtype: twilio.rest.api.v2010.account.signing_key.SigningKeyPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return SigningKeyPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of SigningKeyInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of SigningKeyInstance :rtype: twilio.rest.api.v2010.account.signing_key.SigningKeyPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return SigningKeyPage(self._version, response, self._solution) def get(self, sid): """ Constructs a SigningKeyContext :param sid: The sid :returns: twilio.rest.api.v2010.account.signing_key.SigningKeyContext :rtype: twilio.rest.api.v2010.account.signing_key.SigningKeyContext """ return SigningKeyContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __call__(self, sid): """ Constructs a SigningKeyContext :param sid: The sid :returns: twilio.rest.api.v2010.account.signing_key.SigningKeyContext :rtype: twilio.rest.api.v2010.account.signing_key.SigningKeyContext """ return SigningKeyContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SigningKeyPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the SigningKeyPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.signing_key.SigningKeyPage :rtype: twilio.rest.api.v2010.account.signing_key.SigningKeyPage """ super(SigningKeyPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of SigningKeyInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.signing_key.SigningKeyInstance :rtype: twilio.rest.api.v2010.account.signing_key.SigningKeyInstance """ return SigningKeyInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SigningKeyContext(InstanceContext): """ """ def __init__(self, version, account_sid, sid): """ Initialize the SigningKeyContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param sid: The sid :returns: twilio.rest.api.v2010.account.signing_key.SigningKeyContext :rtype: twilio.rest.api.v2010.account.signing_key.SigningKeyContext """ super(SigningKeyContext, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'sid': sid,} self._uri = '/Accounts/{account_sid}/SigningKeys/{sid}.json'.format(**self._solution) def fetch(self): """ Fetch a SigningKeyInstance :returns: Fetched SigningKeyInstance :rtype: twilio.rest.api.v2010.account.signing_key.SigningKeyInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return SigningKeyInstance( self._version, payload, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) def update(self, friendly_name=values.unset): """ Update the SigningKeyInstance :param unicode friendly_name: The friendly_name :returns: Updated SigningKeyInstance :rtype: twilio.rest.api.v2010.account.signing_key.SigningKeyInstance """ data = values.of({'FriendlyName': friendly_name,}) payload = self._version.update( 'POST', self._uri, data=data, ) return SigningKeyInstance( self._version, payload, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the SigningKeyInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class SigningKeyInstance(InstanceResource): """ """ def __init__(self, version, payload, account_sid, sid=None): """ Initialize the SigningKeyInstance :returns: twilio.rest.api.v2010.account.signing_key.SigningKeyInstance :rtype: twilio.rest.api.v2010.account.signing_key.SigningKeyInstance """ super(SigningKeyInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'friendly_name': payload['friendly_name'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), } # Context self._context = None self._solution = {'account_sid': account_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: SigningKeyContext for this SigningKeyInstance :rtype: twilio.rest.api.v2010.account.signing_key.SigningKeyContext """ if self._context is None: self._context = SigningKeyContext( self._version, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] def fetch(self): """ Fetch a SigningKeyInstance :returns: Fetched SigningKeyInstance :rtype: twilio.rest.api.v2010.account.signing_key.SigningKeyInstance """ return self._proxy.fetch() def update(self, friendly_name=values.unset): """ Update the SigningKeyInstance :param unicode friendly_name: The friendly_name :returns: Updated SigningKeyInstance :rtype: twilio.rest.api.v2010.account.signing_key.SigningKeyInstance """ return self._proxy.update(friendly_name=friendly_name,) def delete(self): """ Deletes the SigningKeyInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/sip/000077500000000000000000000000001317472742600224265ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/api/v2010/account/sip/__init__.py000066400000000000000000000111531317472742600245400ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page from twilio.rest.api.v2010.account.sip.credential_list import CredentialListList from twilio.rest.api.v2010.account.sip.domain import DomainList from twilio.rest.api.v2010.account.sip.ip_access_control_list import IpAccessControlListList class SipList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the SipList :param Version version: Version that contains the resource :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.sip.SipList :rtype: twilio.rest.api.v2010.account.sip.SipList """ super(SipList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} # Components self._domains = None self._regions = None self._ip_access_control_lists = None self._credential_lists = None @property def domains(self): """ Access the domains :returns: twilio.rest.api.v2010.account.sip.domain.DomainList :rtype: twilio.rest.api.v2010.account.sip.domain.DomainList """ if self._domains is None: self._domains = DomainList(self._version, account_sid=self._solution['account_sid'],) return self._domains @property def ip_access_control_lists(self): """ Access the ip_access_control_lists :returns: twilio.rest.api.v2010.account.sip.ip_access_control_list.IpAccessControlListList :rtype: twilio.rest.api.v2010.account.sip.ip_access_control_list.IpAccessControlListList """ if self._ip_access_control_lists is None: self._ip_access_control_lists = IpAccessControlListList( self._version, account_sid=self._solution['account_sid'], ) return self._ip_access_control_lists @property def credential_lists(self): """ Access the credential_lists :returns: twilio.rest.api.v2010.account.sip.credential_list.CredentialListList :rtype: twilio.rest.api.v2010.account.sip.credential_list.CredentialListList """ if self._credential_lists is None: self._credential_lists = CredentialListList(self._version, account_sid=self._solution['account_sid'],) return self._credential_lists def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SipPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the SipPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.sip.SipPage :rtype: twilio.rest.api.v2010.account.sip.SipPage """ super(SipPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of SipInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.sip.SipInstance :rtype: twilio.rest.api.v2010.account.sip.SipInstance """ return SipInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SipInstance(InstanceResource): """ """ def __init__(self, version, payload, account_sid): """ Initialize the SipInstance :returns: twilio.rest.api.v2010.account.sip.SipInstance :rtype: twilio.rest.api.v2010.account.sip.SipInstance """ super(SipInstance, self).__init__(version) # Context self._context = None self._solution = {'account_sid': account_sid,} def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/api/v2010/account/sip/credential_list/000077500000000000000000000000001317472742600255735ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/api/v2010/account/sip/credential_list/__init__.py000066400000000000000000000364531317472742600277170ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.api.v2010.account.sip.credential_list.credential import CredentialList class CredentialListList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the CredentialListList :param Version version: Version that contains the resource :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.sip.credential_list.CredentialListList :rtype: twilio.rest.api.v2010.account.sip.credential_list.CredentialListList """ super(CredentialListList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/SIP/CredentialLists.json'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams CredentialListInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.sip.credential_list.CredentialListInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists CredentialListInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.sip.credential_list.CredentialListInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of CredentialListInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of CredentialListInstance :rtype: twilio.rest.api.v2010.account.sip.credential_list.CredentialListPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return CredentialListPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of CredentialListInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of CredentialListInstance :rtype: twilio.rest.api.v2010.account.sip.credential_list.CredentialListPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return CredentialListPage(self._version, response, self._solution) def create(self, friendly_name): """ Create a new CredentialListInstance :param unicode friendly_name: The friendly_name :returns: Newly created CredentialListInstance :rtype: twilio.rest.api.v2010.account.sip.credential_list.CredentialListInstance """ data = values.of({'FriendlyName': friendly_name,}) payload = self._version.create( 'POST', self._uri, data=data, ) return CredentialListInstance(self._version, payload, account_sid=self._solution['account_sid'],) def get(self, sid): """ Constructs a CredentialListContext :param sid: Fetch by unique credential Sid :returns: twilio.rest.api.v2010.account.sip.credential_list.CredentialListContext :rtype: twilio.rest.api.v2010.account.sip.credential_list.CredentialListContext """ return CredentialListContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __call__(self, sid): """ Constructs a CredentialListContext :param sid: Fetch by unique credential Sid :returns: twilio.rest.api.v2010.account.sip.credential_list.CredentialListContext :rtype: twilio.rest.api.v2010.account.sip.credential_list.CredentialListContext """ return CredentialListContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class CredentialListPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the CredentialListPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.sip.credential_list.CredentialListPage :rtype: twilio.rest.api.v2010.account.sip.credential_list.CredentialListPage """ super(CredentialListPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of CredentialListInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.sip.credential_list.CredentialListInstance :rtype: twilio.rest.api.v2010.account.sip.credential_list.CredentialListInstance """ return CredentialListInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class CredentialListContext(InstanceContext): """ """ def __init__(self, version, account_sid, sid): """ Initialize the CredentialListContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param sid: Fetch by unique credential Sid :returns: twilio.rest.api.v2010.account.sip.credential_list.CredentialListContext :rtype: twilio.rest.api.v2010.account.sip.credential_list.CredentialListContext """ super(CredentialListContext, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'sid': sid,} self._uri = '/Accounts/{account_sid}/SIP/CredentialLists/{sid}.json'.format(**self._solution) # Dependents self._credentials = None def fetch(self): """ Fetch a CredentialListInstance :returns: Fetched CredentialListInstance :rtype: twilio.rest.api.v2010.account.sip.credential_list.CredentialListInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return CredentialListInstance( self._version, payload, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) def update(self, friendly_name): """ Update the CredentialListInstance :param unicode friendly_name: The friendly_name :returns: Updated CredentialListInstance :rtype: twilio.rest.api.v2010.account.sip.credential_list.CredentialListInstance """ data = values.of({'FriendlyName': friendly_name,}) payload = self._version.update( 'POST', self._uri, data=data, ) return CredentialListInstance( self._version, payload, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the CredentialListInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) @property def credentials(self): """ Access the credentials :returns: twilio.rest.api.v2010.account.sip.credential_list.credential.CredentialList :rtype: twilio.rest.api.v2010.account.sip.credential_list.credential.CredentialList """ if self._credentials is None: self._credentials = CredentialList( self._version, account_sid=self._solution['account_sid'], credential_list_sid=self._solution['sid'], ) return self._credentials def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class CredentialListInstance(InstanceResource): """ """ def __init__(self, version, payload, account_sid, sid=None): """ Initialize the CredentialListInstance :returns: twilio.rest.api.v2010.account.sip.credential_list.CredentialListInstance :rtype: twilio.rest.api.v2010.account.sip.credential_list.CredentialListInstance """ super(CredentialListInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'friendly_name': payload['friendly_name'], 'sid': payload['sid'], 'subresource_uris': payload['subresource_uris'], 'uri': payload['uri'], } # Context self._context = None self._solution = {'account_sid': account_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: CredentialListContext for this CredentialListInstance :rtype: twilio.rest.api.v2010.account.sip.credential_list.CredentialListContext """ if self._context is None: self._context = CredentialListContext( self._version, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: The unique sid that identifies this account :rtype: unicode """ return self._properties['account_sid'] @property def date_created(self): """ :returns: The date this resource was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this resource was last updated :rtype: datetime """ return self._properties['date_updated'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def sid(self): """ :returns: A string that uniquely identifies this credential :rtype: unicode """ return self._properties['sid'] @property def subresource_uris(self): """ :returns: The subresource_uris :rtype: unicode """ return self._properties['subresource_uris'] @property def uri(self): """ :returns: The URI for this resource :rtype: unicode """ return self._properties['uri'] def fetch(self): """ Fetch a CredentialListInstance :returns: Fetched CredentialListInstance :rtype: twilio.rest.api.v2010.account.sip.credential_list.CredentialListInstance """ return self._proxy.fetch() def update(self, friendly_name): """ Update the CredentialListInstance :param unicode friendly_name: The friendly_name :returns: Updated CredentialListInstance :rtype: twilio.rest.api.v2010.account.sip.credential_list.CredentialListInstance """ return self._proxy.update(friendly_name,) def delete(self): """ Deletes the CredentialListInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() @property def credentials(self): """ Access the credentials :returns: twilio.rest.api.v2010.account.sip.credential_list.credential.CredentialList :rtype: twilio.rest.api.v2010.account.sip.credential_list.credential.CredentialList """ return self._proxy.credentials def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/sip/credential_list/credential.py000066400000000000000000000362631317472742600302710ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class CredentialList(ListResource): """ """ def __init__(self, version, account_sid, credential_list_sid): """ Initialize the CredentialList :param Version version: Version that contains the resource :param account_sid: The account_sid :param credential_list_sid: The credential_list_sid :returns: twilio.rest.api.v2010.account.sip.credential_list.credential.CredentialList :rtype: twilio.rest.api.v2010.account.sip.credential_list.credential.CredentialList """ super(CredentialList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'credential_list_sid': credential_list_sid,} self._uri = '/Accounts/{account_sid}/SIP/CredentialLists/{credential_list_sid}/Credentials.json'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams CredentialInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.sip.credential_list.credential.CredentialInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists CredentialInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.sip.credential_list.credential.CredentialInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of CredentialInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of CredentialInstance :rtype: twilio.rest.api.v2010.account.sip.credential_list.credential.CredentialPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return CredentialPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of CredentialInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of CredentialInstance :rtype: twilio.rest.api.v2010.account.sip.credential_list.credential.CredentialPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return CredentialPage(self._version, response, self._solution) def create(self, username, password): """ Create a new CredentialInstance :param unicode username: The username :param unicode password: The password :returns: Newly created CredentialInstance :rtype: twilio.rest.api.v2010.account.sip.credential_list.credential.CredentialInstance """ data = values.of({'Username': username, 'Password': password,}) payload = self._version.create( 'POST', self._uri, data=data, ) return CredentialInstance( self._version, payload, account_sid=self._solution['account_sid'], credential_list_sid=self._solution['credential_list_sid'], ) def get(self, sid): """ Constructs a CredentialContext :param sid: The sid :returns: twilio.rest.api.v2010.account.sip.credential_list.credential.CredentialContext :rtype: twilio.rest.api.v2010.account.sip.credential_list.credential.CredentialContext """ return CredentialContext( self._version, account_sid=self._solution['account_sid'], credential_list_sid=self._solution['credential_list_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a CredentialContext :param sid: The sid :returns: twilio.rest.api.v2010.account.sip.credential_list.credential.CredentialContext :rtype: twilio.rest.api.v2010.account.sip.credential_list.credential.CredentialContext """ return CredentialContext( self._version, account_sid=self._solution['account_sid'], credential_list_sid=self._solution['credential_list_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class CredentialPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the CredentialPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param credential_list_sid: The credential_list_sid :returns: twilio.rest.api.v2010.account.sip.credential_list.credential.CredentialPage :rtype: twilio.rest.api.v2010.account.sip.credential_list.credential.CredentialPage """ super(CredentialPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of CredentialInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.sip.credential_list.credential.CredentialInstance :rtype: twilio.rest.api.v2010.account.sip.credential_list.credential.CredentialInstance """ return CredentialInstance( self._version, payload, account_sid=self._solution['account_sid'], credential_list_sid=self._solution['credential_list_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class CredentialContext(InstanceContext): """ """ def __init__(self, version, account_sid, credential_list_sid, sid): """ Initialize the CredentialContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param credential_list_sid: The credential_list_sid :param sid: The sid :returns: twilio.rest.api.v2010.account.sip.credential_list.credential.CredentialContext :rtype: twilio.rest.api.v2010.account.sip.credential_list.credential.CredentialContext """ super(CredentialContext, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'credential_list_sid': credential_list_sid, 'sid': sid,} self._uri = '/Accounts/{account_sid}/SIP/CredentialLists/{credential_list_sid}/Credentials/{sid}.json'.format(**self._solution) def fetch(self): """ Fetch a CredentialInstance :returns: Fetched CredentialInstance :rtype: twilio.rest.api.v2010.account.sip.credential_list.credential.CredentialInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return CredentialInstance( self._version, payload, account_sid=self._solution['account_sid'], credential_list_sid=self._solution['credential_list_sid'], sid=self._solution['sid'], ) def update(self, password=values.unset): """ Update the CredentialInstance :param unicode password: The password :returns: Updated CredentialInstance :rtype: twilio.rest.api.v2010.account.sip.credential_list.credential.CredentialInstance """ data = values.of({'Password': password,}) payload = self._version.update( 'POST', self._uri, data=data, ) return CredentialInstance( self._version, payload, account_sid=self._solution['account_sid'], credential_list_sid=self._solution['credential_list_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the CredentialInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class CredentialInstance(InstanceResource): """ """ def __init__(self, version, payload, account_sid, credential_list_sid, sid=None): """ Initialize the CredentialInstance :returns: twilio.rest.api.v2010.account.sip.credential_list.credential.CredentialInstance :rtype: twilio.rest.api.v2010.account.sip.credential_list.credential.CredentialInstance """ super(CredentialInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'credential_list_sid': payload['credential_list_sid'], 'username': payload['username'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'credential_list_sid': credential_list_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: CredentialContext for this CredentialInstance :rtype: twilio.rest.api.v2010.account.sip.credential_list.credential.CredentialContext """ if self._context is None: self._context = CredentialContext( self._version, account_sid=self._solution['account_sid'], credential_list_sid=self._solution['credential_list_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def credential_list_sid(self): """ :returns: The credential_list_sid :rtype: unicode """ return self._properties['credential_list_sid'] @property def username(self): """ :returns: The username :rtype: unicode """ return self._properties['username'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def fetch(self): """ Fetch a CredentialInstance :returns: Fetched CredentialInstance :rtype: twilio.rest.api.v2010.account.sip.credential_list.credential.CredentialInstance """ return self._proxy.fetch() def update(self, password=values.unset): """ Update the CredentialInstance :param unicode password: The password :returns: Updated CredentialInstance :rtype: twilio.rest.api.v2010.account.sip.credential_list.credential.CredentialInstance """ return self._proxy.update(password=password,) def delete(self): """ Deletes the CredentialInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/sip/domain/000077500000000000000000000000001317472742600236755ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/api/v2010/account/sip/domain/__init__.py000066400000000000000000000555511317472742600260210ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.api.v2010.account.sip.domain.credential_list_mapping import CredentialListMappingList from twilio.rest.api.v2010.account.sip.domain.ip_access_control_list_mapping import IpAccessControlListMappingList class DomainList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the DomainList :param Version version: Version that contains the resource :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.sip.domain.DomainList :rtype: twilio.rest.api.v2010.account.sip.domain.DomainList """ super(DomainList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/SIP/Domains.json'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams DomainInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.sip.domain.DomainInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists DomainInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.sip.domain.DomainInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of DomainInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of DomainInstance :rtype: twilio.rest.api.v2010.account.sip.domain.DomainPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return DomainPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of DomainInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of DomainInstance :rtype: twilio.rest.api.v2010.account.sip.domain.DomainPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return DomainPage(self._version, response, self._solution) def create(self, domain_name, friendly_name=values.unset, auth_type=values.unset, voice_url=values.unset, voice_method=values.unset, voice_fallback_url=values.unset, voice_fallback_method=values.unset, voice_status_callback_url=values.unset, voice_status_callback_method=values.unset, sip_registration=values.unset): """ Create a new DomainInstance :param unicode domain_name: The unique address on Twilio to route SIP traffic :param unicode friendly_name: A user-specified, human-readable name for the trigger. :param unicode auth_type: The types of authentication mapped to the domain :param unicode voice_url: URL Twilio will request when receiving a call :param unicode voice_method: HTTP method to use with voice_url :param unicode voice_fallback_url: URL Twilio will request if an error occurs in executing TwiML :param unicode voice_fallback_method: HTTP method used with voice_fallback_url :param unicode voice_status_callback_url: URL that Twilio will request with status updates :param unicode voice_status_callback_method: The voice_status_callback_method :param bool sip_registration: The sip_registration :returns: Newly created DomainInstance :rtype: twilio.rest.api.v2010.account.sip.domain.DomainInstance """ data = values.of({ 'DomainName': domain_name, 'FriendlyName': friendly_name, 'AuthType': auth_type, 'VoiceUrl': voice_url, 'VoiceMethod': voice_method, 'VoiceFallbackUrl': voice_fallback_url, 'VoiceFallbackMethod': voice_fallback_method, 'VoiceStatusCallbackUrl': voice_status_callback_url, 'VoiceStatusCallbackMethod': voice_status_callback_method, 'SipRegistration': sip_registration, }) payload = self._version.create( 'POST', self._uri, data=data, ) return DomainInstance(self._version, payload, account_sid=self._solution['account_sid'],) def get(self, sid): """ Constructs a DomainContext :param sid: Fetch by unique Domain Sid :returns: twilio.rest.api.v2010.account.sip.domain.DomainContext :rtype: twilio.rest.api.v2010.account.sip.domain.DomainContext """ return DomainContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __call__(self, sid): """ Constructs a DomainContext :param sid: Fetch by unique Domain Sid :returns: twilio.rest.api.v2010.account.sip.domain.DomainContext :rtype: twilio.rest.api.v2010.account.sip.domain.DomainContext """ return DomainContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class DomainPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the DomainPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.sip.domain.DomainPage :rtype: twilio.rest.api.v2010.account.sip.domain.DomainPage """ super(DomainPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of DomainInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.sip.domain.DomainInstance :rtype: twilio.rest.api.v2010.account.sip.domain.DomainInstance """ return DomainInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class DomainContext(InstanceContext): """ """ def __init__(self, version, account_sid, sid): """ Initialize the DomainContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param sid: Fetch by unique Domain Sid :returns: twilio.rest.api.v2010.account.sip.domain.DomainContext :rtype: twilio.rest.api.v2010.account.sip.domain.DomainContext """ super(DomainContext, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'sid': sid,} self._uri = '/Accounts/{account_sid}/SIP/Domains/{sid}.json'.format(**self._solution) # Dependents self._ip_access_control_list_mappings = None self._credential_list_mappings = None def fetch(self): """ Fetch a DomainInstance :returns: Fetched DomainInstance :rtype: twilio.rest.api.v2010.account.sip.domain.DomainInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return DomainInstance( self._version, payload, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) def update(self, auth_type=values.unset, friendly_name=values.unset, voice_fallback_method=values.unset, voice_fallback_url=values.unset, voice_method=values.unset, voice_status_callback_method=values.unset, voice_status_callback_url=values.unset, voice_url=values.unset, sip_registration=values.unset): """ Update the DomainInstance :param unicode auth_type: The auth_type :param unicode friendly_name: A user-specified, human-readable name for the trigger. :param unicode voice_fallback_method: The voice_fallback_method :param unicode voice_fallback_url: The voice_fallback_url :param unicode voice_method: HTTP method to use with voice_url :param unicode voice_status_callback_method: The voice_status_callback_method :param unicode voice_status_callback_url: The voice_status_callback_url :param unicode voice_url: The voice_url :param bool sip_registration: The sip_registration :returns: Updated DomainInstance :rtype: twilio.rest.api.v2010.account.sip.domain.DomainInstance """ data = values.of({ 'AuthType': auth_type, 'FriendlyName': friendly_name, 'VoiceFallbackMethod': voice_fallback_method, 'VoiceFallbackUrl': voice_fallback_url, 'VoiceMethod': voice_method, 'VoiceStatusCallbackMethod': voice_status_callback_method, 'VoiceStatusCallbackUrl': voice_status_callback_url, 'VoiceUrl': voice_url, 'SipRegistration': sip_registration, }) payload = self._version.update( 'POST', self._uri, data=data, ) return DomainInstance( self._version, payload, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the DomainInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) @property def ip_access_control_list_mappings(self): """ Access the ip_access_control_list_mappings :returns: twilio.rest.api.v2010.account.sip.domain.ip_access_control_list_mapping.IpAccessControlListMappingList :rtype: twilio.rest.api.v2010.account.sip.domain.ip_access_control_list_mapping.IpAccessControlListMappingList """ if self._ip_access_control_list_mappings is None: self._ip_access_control_list_mappings = IpAccessControlListMappingList( self._version, account_sid=self._solution['account_sid'], domain_sid=self._solution['sid'], ) return self._ip_access_control_list_mappings @property def credential_list_mappings(self): """ Access the credential_list_mappings :returns: twilio.rest.api.v2010.account.sip.domain.credential_list_mapping.CredentialListMappingList :rtype: twilio.rest.api.v2010.account.sip.domain.credential_list_mapping.CredentialListMappingList """ if self._credential_list_mappings is None: self._credential_list_mappings = CredentialListMappingList( self._version, account_sid=self._solution['account_sid'], domain_sid=self._solution['sid'], ) return self._credential_list_mappings def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class DomainInstance(InstanceResource): """ """ def __init__(self, version, payload, account_sid, sid=None): """ Initialize the DomainInstance :returns: twilio.rest.api.v2010.account.sip.domain.DomainInstance :rtype: twilio.rest.api.v2010.account.sip.domain.DomainInstance """ super(DomainInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'api_version': payload['api_version'], 'auth_type': payload['auth_type'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'domain_name': payload['domain_name'], 'friendly_name': payload['friendly_name'], 'sid': payload['sid'], 'uri': payload['uri'], 'voice_fallback_method': payload['voice_fallback_method'], 'voice_fallback_url': payload['voice_fallback_url'], 'voice_method': payload['voice_method'], 'voice_status_callback_method': payload['voice_status_callback_method'], 'voice_status_callback_url': payload['voice_status_callback_url'], 'voice_url': payload['voice_url'], 'subresource_uris': payload['subresource_uris'], 'sip_registration': payload['sip_registration'], } # Context self._context = None self._solution = {'account_sid': account_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: DomainContext for this DomainInstance :rtype: twilio.rest.api.v2010.account.sip.domain.DomainContext """ if self._context is None: self._context = DomainContext( self._version, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: The unique id of the account that sent the message :rtype: unicode """ return self._properties['account_sid'] @property def api_version(self): """ :returns: The Twilio API version used to process the message :rtype: unicode """ return self._properties['api_version'] @property def auth_type(self): """ :returns: The types of authentication mapped to the domain :rtype: unicode """ return self._properties['auth_type'] @property def date_created(self): """ :returns: The date this resource was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this resource was last updated :rtype: datetime """ return self._properties['date_updated'] @property def domain_name(self): """ :returns: The unique address on Twilio to route SIP traffic :rtype: unicode """ return self._properties['domain_name'] @property def friendly_name(self): """ :returns: A user-specified, human-readable name for the trigger. :rtype: unicode """ return self._properties['friendly_name'] @property def sid(self): """ :returns: A string that uniquely identifies the SIP Domain :rtype: unicode """ return self._properties['sid'] @property def uri(self): """ :returns: The URI for this resource :rtype: unicode """ return self._properties['uri'] @property def voice_fallback_method(self): """ :returns: HTTP method used with voice_fallback_url :rtype: unicode """ return self._properties['voice_fallback_method'] @property def voice_fallback_url(self): """ :returns: URL Twilio will request if an error occurs in executing TwiML :rtype: unicode """ return self._properties['voice_fallback_url'] @property def voice_method(self): """ :returns: HTTP method to use with voice_url :rtype: unicode """ return self._properties['voice_method'] @property def voice_status_callback_method(self): """ :returns: The voice_status_callback_method :rtype: unicode """ return self._properties['voice_status_callback_method'] @property def voice_status_callback_url(self): """ :returns: URL that Twilio will request with status updates :rtype: unicode """ return self._properties['voice_status_callback_url'] @property def voice_url(self): """ :returns: URL Twilio will request when receiving a call :rtype: unicode """ return self._properties['voice_url'] @property def subresource_uris(self): """ :returns: The subresource_uris :rtype: unicode """ return self._properties['subresource_uris'] @property def sip_registration(self): """ :returns: If SIP registration is allowed :rtype: bool """ return self._properties['sip_registration'] def fetch(self): """ Fetch a DomainInstance :returns: Fetched DomainInstance :rtype: twilio.rest.api.v2010.account.sip.domain.DomainInstance """ return self._proxy.fetch() def update(self, auth_type=values.unset, friendly_name=values.unset, voice_fallback_method=values.unset, voice_fallback_url=values.unset, voice_method=values.unset, voice_status_callback_method=values.unset, voice_status_callback_url=values.unset, voice_url=values.unset, sip_registration=values.unset): """ Update the DomainInstance :param unicode auth_type: The auth_type :param unicode friendly_name: A user-specified, human-readable name for the trigger. :param unicode voice_fallback_method: The voice_fallback_method :param unicode voice_fallback_url: The voice_fallback_url :param unicode voice_method: HTTP method to use with voice_url :param unicode voice_status_callback_method: The voice_status_callback_method :param unicode voice_status_callback_url: The voice_status_callback_url :param unicode voice_url: The voice_url :param bool sip_registration: The sip_registration :returns: Updated DomainInstance :rtype: twilio.rest.api.v2010.account.sip.domain.DomainInstance """ return self._proxy.update( auth_type=auth_type, friendly_name=friendly_name, voice_fallback_method=voice_fallback_method, voice_fallback_url=voice_fallback_url, voice_method=voice_method, voice_status_callback_method=voice_status_callback_method, voice_status_callback_url=voice_status_callback_url, voice_url=voice_url, sip_registration=sip_registration, ) def delete(self): """ Deletes the DomainInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() @property def ip_access_control_list_mappings(self): """ Access the ip_access_control_list_mappings :returns: twilio.rest.api.v2010.account.sip.domain.ip_access_control_list_mapping.IpAccessControlListMappingList :rtype: twilio.rest.api.v2010.account.sip.domain.ip_access_control_list_mapping.IpAccessControlListMappingList """ return self._proxy.ip_access_control_list_mappings @property def credential_list_mappings(self): """ Access the credential_list_mappings :returns: twilio.rest.api.v2010.account.sip.domain.credential_list_mapping.CredentialListMappingList :rtype: twilio.rest.api.v2010.account.sip.domain.credential_list_mapping.CredentialListMappingList """ return self._proxy.credential_list_mappings def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/sip/domain/credential_list_mapping.py000066400000000000000000000353111317472742600311320ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class CredentialListMappingList(ListResource): """ """ def __init__(self, version, account_sid, domain_sid): """ Initialize the CredentialListMappingList :param Version version: Version that contains the resource :param account_sid: The account_sid :param domain_sid: A string that uniquely identifies the SIP Domain :returns: twilio.rest.api.v2010.account.sip.domain.credential_list_mapping.CredentialListMappingList :rtype: twilio.rest.api.v2010.account.sip.domain.credential_list_mapping.CredentialListMappingList """ super(CredentialListMappingList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'domain_sid': domain_sid,} self._uri = '/Accounts/{account_sid}/SIP/Domains/{domain_sid}/CredentialListMappings.json'.format(**self._solution) def create(self, credential_list_sid): """ Create a new CredentialListMappingInstance :param unicode credential_list_sid: The credential_list_sid :returns: Newly created CredentialListMappingInstance :rtype: twilio.rest.api.v2010.account.sip.domain.credential_list_mapping.CredentialListMappingInstance """ data = values.of({'CredentialListSid': credential_list_sid,}) payload = self._version.create( 'POST', self._uri, data=data, ) return CredentialListMappingInstance( self._version, payload, account_sid=self._solution['account_sid'], domain_sid=self._solution['domain_sid'], ) def stream(self, limit=None, page_size=None): """ Streams CredentialListMappingInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.sip.domain.credential_list_mapping.CredentialListMappingInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists CredentialListMappingInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.sip.domain.credential_list_mapping.CredentialListMappingInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of CredentialListMappingInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of CredentialListMappingInstance :rtype: twilio.rest.api.v2010.account.sip.domain.credential_list_mapping.CredentialListMappingPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return CredentialListMappingPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of CredentialListMappingInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of CredentialListMappingInstance :rtype: twilio.rest.api.v2010.account.sip.domain.credential_list_mapping.CredentialListMappingPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return CredentialListMappingPage(self._version, response, self._solution) def get(self, sid): """ Constructs a CredentialListMappingContext :param sid: The sid :returns: twilio.rest.api.v2010.account.sip.domain.credential_list_mapping.CredentialListMappingContext :rtype: twilio.rest.api.v2010.account.sip.domain.credential_list_mapping.CredentialListMappingContext """ return CredentialListMappingContext( self._version, account_sid=self._solution['account_sid'], domain_sid=self._solution['domain_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a CredentialListMappingContext :param sid: The sid :returns: twilio.rest.api.v2010.account.sip.domain.credential_list_mapping.CredentialListMappingContext :rtype: twilio.rest.api.v2010.account.sip.domain.credential_list_mapping.CredentialListMappingContext """ return CredentialListMappingContext( self._version, account_sid=self._solution['account_sid'], domain_sid=self._solution['domain_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class CredentialListMappingPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the CredentialListMappingPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param domain_sid: A string that uniquely identifies the SIP Domain :returns: twilio.rest.api.v2010.account.sip.domain.credential_list_mapping.CredentialListMappingPage :rtype: twilio.rest.api.v2010.account.sip.domain.credential_list_mapping.CredentialListMappingPage """ super(CredentialListMappingPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of CredentialListMappingInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.sip.domain.credential_list_mapping.CredentialListMappingInstance :rtype: twilio.rest.api.v2010.account.sip.domain.credential_list_mapping.CredentialListMappingInstance """ return CredentialListMappingInstance( self._version, payload, account_sid=self._solution['account_sid'], domain_sid=self._solution['domain_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class CredentialListMappingContext(InstanceContext): """ """ def __init__(self, version, account_sid, domain_sid, sid): """ Initialize the CredentialListMappingContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param domain_sid: The domain_sid :param sid: The sid :returns: twilio.rest.api.v2010.account.sip.domain.credential_list_mapping.CredentialListMappingContext :rtype: twilio.rest.api.v2010.account.sip.domain.credential_list_mapping.CredentialListMappingContext """ super(CredentialListMappingContext, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'domain_sid': domain_sid, 'sid': sid,} self._uri = '/Accounts/{account_sid}/SIP/Domains/{domain_sid}/CredentialListMappings/{sid}.json'.format(**self._solution) def fetch(self): """ Fetch a CredentialListMappingInstance :returns: Fetched CredentialListMappingInstance :rtype: twilio.rest.api.v2010.account.sip.domain.credential_list_mapping.CredentialListMappingInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return CredentialListMappingInstance( self._version, payload, account_sid=self._solution['account_sid'], domain_sid=self._solution['domain_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the CredentialListMappingInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class CredentialListMappingInstance(InstanceResource): """ """ def __init__(self, version, payload, account_sid, domain_sid, sid=None): """ Initialize the CredentialListMappingInstance :returns: twilio.rest.api.v2010.account.sip.domain.credential_list_mapping.CredentialListMappingInstance :rtype: twilio.rest.api.v2010.account.sip.domain.credential_list_mapping.CredentialListMappingInstance """ super(CredentialListMappingInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'friendly_name': payload['friendly_name'], 'sid': payload['sid'], 'uri': payload['uri'], 'subresource_uris': payload['subresource_uris'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'domain_sid': domain_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: CredentialListMappingContext for this CredentialListMappingInstance :rtype: twilio.rest.api.v2010.account.sip.domain.credential_list_mapping.CredentialListMappingContext """ if self._context is None: self._context = CredentialListMappingContext( self._version, account_sid=self._solution['account_sid'], domain_sid=self._solution['domain_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] @property def subresource_uris(self): """ :returns: The subresource_uris :rtype: unicode """ return self._properties['subresource_uris'] def fetch(self): """ Fetch a CredentialListMappingInstance :returns: Fetched CredentialListMappingInstance :rtype: twilio.rest.api.v2010.account.sip.domain.credential_list_mapping.CredentialListMappingInstance """ return self._proxy.fetch() def delete(self): """ Deletes the CredentialListMappingInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/sip/domain/ip_access_control_list_mapping.py000066400000000000000000000363231317472742600325150ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class IpAccessControlListMappingList(ListResource): """ """ def __init__(self, version, account_sid, domain_sid): """ Initialize the IpAccessControlListMappingList :param Version version: Version that contains the resource :param account_sid: The account_sid :param domain_sid: A string that uniquely identifies the SIP Domain :returns: twilio.rest.api.v2010.account.sip.domain.ip_access_control_list_mapping.IpAccessControlListMappingList :rtype: twilio.rest.api.v2010.account.sip.domain.ip_access_control_list_mapping.IpAccessControlListMappingList """ super(IpAccessControlListMappingList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'domain_sid': domain_sid,} self._uri = '/Accounts/{account_sid}/SIP/Domains/{domain_sid}/IpAccessControlListMappings.json'.format(**self._solution) def create(self, ip_access_control_list_sid): """ Create a new IpAccessControlListMappingInstance :param unicode ip_access_control_list_sid: The ip_access_control_list_sid :returns: Newly created IpAccessControlListMappingInstance :rtype: twilio.rest.api.v2010.account.sip.domain.ip_access_control_list_mapping.IpAccessControlListMappingInstance """ data = values.of({'IpAccessControlListSid': ip_access_control_list_sid,}) payload = self._version.create( 'POST', self._uri, data=data, ) return IpAccessControlListMappingInstance( self._version, payload, account_sid=self._solution['account_sid'], domain_sid=self._solution['domain_sid'], ) def stream(self, limit=None, page_size=None): """ Streams IpAccessControlListMappingInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.sip.domain.ip_access_control_list_mapping.IpAccessControlListMappingInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists IpAccessControlListMappingInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.sip.domain.ip_access_control_list_mapping.IpAccessControlListMappingInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of IpAccessControlListMappingInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of IpAccessControlListMappingInstance :rtype: twilio.rest.api.v2010.account.sip.domain.ip_access_control_list_mapping.IpAccessControlListMappingPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return IpAccessControlListMappingPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of IpAccessControlListMappingInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of IpAccessControlListMappingInstance :rtype: twilio.rest.api.v2010.account.sip.domain.ip_access_control_list_mapping.IpAccessControlListMappingPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return IpAccessControlListMappingPage(self._version, response, self._solution) def get(self, sid): """ Constructs a IpAccessControlListMappingContext :param sid: The sid :returns: twilio.rest.api.v2010.account.sip.domain.ip_access_control_list_mapping.IpAccessControlListMappingContext :rtype: twilio.rest.api.v2010.account.sip.domain.ip_access_control_list_mapping.IpAccessControlListMappingContext """ return IpAccessControlListMappingContext( self._version, account_sid=self._solution['account_sid'], domain_sid=self._solution['domain_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a IpAccessControlListMappingContext :param sid: The sid :returns: twilio.rest.api.v2010.account.sip.domain.ip_access_control_list_mapping.IpAccessControlListMappingContext :rtype: twilio.rest.api.v2010.account.sip.domain.ip_access_control_list_mapping.IpAccessControlListMappingContext """ return IpAccessControlListMappingContext( self._version, account_sid=self._solution['account_sid'], domain_sid=self._solution['domain_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class IpAccessControlListMappingPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the IpAccessControlListMappingPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param domain_sid: A string that uniquely identifies the SIP Domain :returns: twilio.rest.api.v2010.account.sip.domain.ip_access_control_list_mapping.IpAccessControlListMappingPage :rtype: twilio.rest.api.v2010.account.sip.domain.ip_access_control_list_mapping.IpAccessControlListMappingPage """ super(IpAccessControlListMappingPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of IpAccessControlListMappingInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.sip.domain.ip_access_control_list_mapping.IpAccessControlListMappingInstance :rtype: twilio.rest.api.v2010.account.sip.domain.ip_access_control_list_mapping.IpAccessControlListMappingInstance """ return IpAccessControlListMappingInstance( self._version, payload, account_sid=self._solution['account_sid'], domain_sid=self._solution['domain_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class IpAccessControlListMappingContext(InstanceContext): """ """ def __init__(self, version, account_sid, domain_sid, sid): """ Initialize the IpAccessControlListMappingContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param domain_sid: The domain_sid :param sid: The sid :returns: twilio.rest.api.v2010.account.sip.domain.ip_access_control_list_mapping.IpAccessControlListMappingContext :rtype: twilio.rest.api.v2010.account.sip.domain.ip_access_control_list_mapping.IpAccessControlListMappingContext """ super(IpAccessControlListMappingContext, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'domain_sid': domain_sid, 'sid': sid,} self._uri = '/Accounts/{account_sid}/SIP/Domains/{domain_sid}/IpAccessControlListMappings/{sid}.json'.format(**self._solution) def fetch(self): """ Fetch a IpAccessControlListMappingInstance :returns: Fetched IpAccessControlListMappingInstance :rtype: twilio.rest.api.v2010.account.sip.domain.ip_access_control_list_mapping.IpAccessControlListMappingInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return IpAccessControlListMappingInstance( self._version, payload, account_sid=self._solution['account_sid'], domain_sid=self._solution['domain_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the IpAccessControlListMappingInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class IpAccessControlListMappingInstance(InstanceResource): """ """ def __init__(self, version, payload, account_sid, domain_sid, sid=None): """ Initialize the IpAccessControlListMappingInstance :returns: twilio.rest.api.v2010.account.sip.domain.ip_access_control_list_mapping.IpAccessControlListMappingInstance :rtype: twilio.rest.api.v2010.account.sip.domain.ip_access_control_list_mapping.IpAccessControlListMappingInstance """ super(IpAccessControlListMappingInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'friendly_name': payload['friendly_name'], 'sid': payload['sid'], 'uri': payload['uri'], 'subresource_uris': payload['subresource_uris'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'domain_sid': domain_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: IpAccessControlListMappingContext for this IpAccessControlListMappingInstance :rtype: twilio.rest.api.v2010.account.sip.domain.ip_access_control_list_mapping.IpAccessControlListMappingContext """ if self._context is None: self._context = IpAccessControlListMappingContext( self._version, account_sid=self._solution['account_sid'], domain_sid=self._solution['domain_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] @property def subresource_uris(self): """ :returns: The subresource_uris :rtype: unicode """ return self._properties['subresource_uris'] def fetch(self): """ Fetch a IpAccessControlListMappingInstance :returns: Fetched IpAccessControlListMappingInstance :rtype: twilio.rest.api.v2010.account.sip.domain.ip_access_control_list_mapping.IpAccessControlListMappingInstance """ return self._proxy.fetch() def delete(self): """ Deletes the IpAccessControlListMappingInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/sip/ip_access_control_list/000077500000000000000000000000001317472742600271525ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/api/v2010/account/sip/ip_access_control_list/__init__.py000066400000000000000000000400041317472742600312610ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.api.v2010.account.sip.ip_access_control_list.ip_address import IpAddressList class IpAccessControlListList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the IpAccessControlListList :param Version version: Version that contains the resource :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.sip.ip_access_control_list.IpAccessControlListList :rtype: twilio.rest.api.v2010.account.sip.ip_access_control_list.IpAccessControlListList """ super(IpAccessControlListList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/SIP/IpAccessControlLists.json'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams IpAccessControlListInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.sip.ip_access_control_list.IpAccessControlListInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists IpAccessControlListInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.sip.ip_access_control_list.IpAccessControlListInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of IpAccessControlListInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of IpAccessControlListInstance :rtype: twilio.rest.api.v2010.account.sip.ip_access_control_list.IpAccessControlListPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return IpAccessControlListPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of IpAccessControlListInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of IpAccessControlListInstance :rtype: twilio.rest.api.v2010.account.sip.ip_access_control_list.IpAccessControlListPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return IpAccessControlListPage(self._version, response, self._solution) def create(self, friendly_name): """ Create a new IpAccessControlListInstance :param unicode friendly_name: A human readable description of this resource :returns: Newly created IpAccessControlListInstance :rtype: twilio.rest.api.v2010.account.sip.ip_access_control_list.IpAccessControlListInstance """ data = values.of({'FriendlyName': friendly_name,}) payload = self._version.create( 'POST', self._uri, data=data, ) return IpAccessControlListInstance(self._version, payload, account_sid=self._solution['account_sid'],) def get(self, sid): """ Constructs a IpAccessControlListContext :param sid: Fetch by unique ip-access-control-list Sid :returns: twilio.rest.api.v2010.account.sip.ip_access_control_list.IpAccessControlListContext :rtype: twilio.rest.api.v2010.account.sip.ip_access_control_list.IpAccessControlListContext """ return IpAccessControlListContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __call__(self, sid): """ Constructs a IpAccessControlListContext :param sid: Fetch by unique ip-access-control-list Sid :returns: twilio.rest.api.v2010.account.sip.ip_access_control_list.IpAccessControlListContext :rtype: twilio.rest.api.v2010.account.sip.ip_access_control_list.IpAccessControlListContext """ return IpAccessControlListContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class IpAccessControlListPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the IpAccessControlListPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.sip.ip_access_control_list.IpAccessControlListPage :rtype: twilio.rest.api.v2010.account.sip.ip_access_control_list.IpAccessControlListPage """ super(IpAccessControlListPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of IpAccessControlListInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.sip.ip_access_control_list.IpAccessControlListInstance :rtype: twilio.rest.api.v2010.account.sip.ip_access_control_list.IpAccessControlListInstance """ return IpAccessControlListInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class IpAccessControlListContext(InstanceContext): """ """ def __init__(self, version, account_sid, sid): """ Initialize the IpAccessControlListContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param sid: Fetch by unique ip-access-control-list Sid :returns: twilio.rest.api.v2010.account.sip.ip_access_control_list.IpAccessControlListContext :rtype: twilio.rest.api.v2010.account.sip.ip_access_control_list.IpAccessControlListContext """ super(IpAccessControlListContext, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'sid': sid,} self._uri = '/Accounts/{account_sid}/SIP/IpAccessControlLists/{sid}.json'.format(**self._solution) # Dependents self._ip_addresses = None def fetch(self): """ Fetch a IpAccessControlListInstance :returns: Fetched IpAccessControlListInstance :rtype: twilio.rest.api.v2010.account.sip.ip_access_control_list.IpAccessControlListInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return IpAccessControlListInstance( self._version, payload, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) def update(self, friendly_name): """ Update the IpAccessControlListInstance :param unicode friendly_name: A human readable description of this resource :returns: Updated IpAccessControlListInstance :rtype: twilio.rest.api.v2010.account.sip.ip_access_control_list.IpAccessControlListInstance """ data = values.of({'FriendlyName': friendly_name,}) payload = self._version.update( 'POST', self._uri, data=data, ) return IpAccessControlListInstance( self._version, payload, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the IpAccessControlListInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) @property def ip_addresses(self): """ Access the ip_addresses :returns: twilio.rest.api.v2010.account.sip.ip_access_control_list.ip_address.IpAddressList :rtype: twilio.rest.api.v2010.account.sip.ip_access_control_list.ip_address.IpAddressList """ if self._ip_addresses is None: self._ip_addresses = IpAddressList( self._version, account_sid=self._solution['account_sid'], ip_access_control_list_sid=self._solution['sid'], ) return self._ip_addresses def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class IpAccessControlListInstance(InstanceResource): """ """ def __init__(self, version, payload, account_sid, sid=None): """ Initialize the IpAccessControlListInstance :returns: twilio.rest.api.v2010.account.sip.ip_access_control_list.IpAccessControlListInstance :rtype: twilio.rest.api.v2010.account.sip.ip_access_control_list.IpAccessControlListInstance """ super(IpAccessControlListInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'friendly_name': payload['friendly_name'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'subresource_uris': payload['subresource_uris'], 'uri': payload['uri'], } # Context self._context = None self._solution = {'account_sid': account_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: IpAccessControlListContext for this IpAccessControlListInstance :rtype: twilio.rest.api.v2010.account.sip.ip_access_control_list.IpAccessControlListContext """ if self._context is None: self._context = IpAccessControlListContext( self._version, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: A string that uniquely identifies this resource :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The unique sid that identifies this account :rtype: unicode """ return self._properties['account_sid'] @property def friendly_name(self): """ :returns: A human readable description of this resource :rtype: unicode """ return self._properties['friendly_name'] @property def date_created(self): """ :returns: The date this resource was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this resource was last updated :rtype: datetime """ return self._properties['date_updated'] @property def subresource_uris(self): """ :returns: The subresource_uris :rtype: unicode """ return self._properties['subresource_uris'] @property def uri(self): """ :returns: The URI for this resource :rtype: unicode """ return self._properties['uri'] def fetch(self): """ Fetch a IpAccessControlListInstance :returns: Fetched IpAccessControlListInstance :rtype: twilio.rest.api.v2010.account.sip.ip_access_control_list.IpAccessControlListInstance """ return self._proxy.fetch() def update(self, friendly_name): """ Update the IpAccessControlListInstance :param unicode friendly_name: A human readable description of this resource :returns: Updated IpAccessControlListInstance :rtype: twilio.rest.api.v2010.account.sip.ip_access_control_list.IpAccessControlListInstance """ return self._proxy.update(friendly_name,) def delete(self): """ Deletes the IpAccessControlListInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() @property def ip_addresses(self): """ Access the ip_addresses :returns: twilio.rest.api.v2010.account.sip.ip_access_control_list.ip_address.IpAddressList :rtype: twilio.rest.api.v2010.account.sip.ip_access_control_list.ip_address.IpAddressList """ return self._proxy.ip_addresses def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/sip/ip_access_control_list/ip_address.py000066400000000000000000000401631317472742600316450ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class IpAddressList(ListResource): """ """ def __init__(self, version, account_sid, ip_access_control_list_sid): """ Initialize the IpAddressList :param Version version: Version that contains the resource :param account_sid: The account_sid :param ip_access_control_list_sid: The ip_access_control_list_sid :returns: twilio.rest.api.v2010.account.sip.ip_access_control_list.ip_address.IpAddressList :rtype: twilio.rest.api.v2010.account.sip.ip_access_control_list.ip_address.IpAddressList """ super(IpAddressList, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'ip_access_control_list_sid': ip_access_control_list_sid, } self._uri = '/Accounts/{account_sid}/SIP/IpAccessControlLists/{ip_access_control_list_sid}/IpAddresses.json'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams IpAddressInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.sip.ip_access_control_list.ip_address.IpAddressInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists IpAddressInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.sip.ip_access_control_list.ip_address.IpAddressInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of IpAddressInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of IpAddressInstance :rtype: twilio.rest.api.v2010.account.sip.ip_access_control_list.ip_address.IpAddressPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return IpAddressPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of IpAddressInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of IpAddressInstance :rtype: twilio.rest.api.v2010.account.sip.ip_access_control_list.ip_address.IpAddressPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return IpAddressPage(self._version, response, self._solution) def create(self, friendly_name, ip_address): """ Create a new IpAddressInstance :param unicode friendly_name: The friendly_name :param unicode ip_address: The ip_address :returns: Newly created IpAddressInstance :rtype: twilio.rest.api.v2010.account.sip.ip_access_control_list.ip_address.IpAddressInstance """ data = values.of({'FriendlyName': friendly_name, 'IpAddress': ip_address,}) payload = self._version.create( 'POST', self._uri, data=data, ) return IpAddressInstance( self._version, payload, account_sid=self._solution['account_sid'], ip_access_control_list_sid=self._solution['ip_access_control_list_sid'], ) def get(self, sid): """ Constructs a IpAddressContext :param sid: The sid :returns: twilio.rest.api.v2010.account.sip.ip_access_control_list.ip_address.IpAddressContext :rtype: twilio.rest.api.v2010.account.sip.ip_access_control_list.ip_address.IpAddressContext """ return IpAddressContext( self._version, account_sid=self._solution['account_sid'], ip_access_control_list_sid=self._solution['ip_access_control_list_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a IpAddressContext :param sid: The sid :returns: twilio.rest.api.v2010.account.sip.ip_access_control_list.ip_address.IpAddressContext :rtype: twilio.rest.api.v2010.account.sip.ip_access_control_list.ip_address.IpAddressContext """ return IpAddressContext( self._version, account_sid=self._solution['account_sid'], ip_access_control_list_sid=self._solution['ip_access_control_list_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class IpAddressPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the IpAddressPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param ip_access_control_list_sid: The ip_access_control_list_sid :returns: twilio.rest.api.v2010.account.sip.ip_access_control_list.ip_address.IpAddressPage :rtype: twilio.rest.api.v2010.account.sip.ip_access_control_list.ip_address.IpAddressPage """ super(IpAddressPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of IpAddressInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.sip.ip_access_control_list.ip_address.IpAddressInstance :rtype: twilio.rest.api.v2010.account.sip.ip_access_control_list.ip_address.IpAddressInstance """ return IpAddressInstance( self._version, payload, account_sid=self._solution['account_sid'], ip_access_control_list_sid=self._solution['ip_access_control_list_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class IpAddressContext(InstanceContext): """ """ def __init__(self, version, account_sid, ip_access_control_list_sid, sid): """ Initialize the IpAddressContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param ip_access_control_list_sid: The ip_access_control_list_sid :param sid: The sid :returns: twilio.rest.api.v2010.account.sip.ip_access_control_list.ip_address.IpAddressContext :rtype: twilio.rest.api.v2010.account.sip.ip_access_control_list.ip_address.IpAddressContext """ super(IpAddressContext, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'ip_access_control_list_sid': ip_access_control_list_sid, 'sid': sid, } self._uri = '/Accounts/{account_sid}/SIP/IpAccessControlLists/{ip_access_control_list_sid}/IpAddresses/{sid}.json'.format(**self._solution) def fetch(self): """ Fetch a IpAddressInstance :returns: Fetched IpAddressInstance :rtype: twilio.rest.api.v2010.account.sip.ip_access_control_list.ip_address.IpAddressInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return IpAddressInstance( self._version, payload, account_sid=self._solution['account_sid'], ip_access_control_list_sid=self._solution['ip_access_control_list_sid'], sid=self._solution['sid'], ) def update(self, ip_address=values.unset, friendly_name=values.unset): """ Update the IpAddressInstance :param unicode ip_address: The ip_address :param unicode friendly_name: The friendly_name :returns: Updated IpAddressInstance :rtype: twilio.rest.api.v2010.account.sip.ip_access_control_list.ip_address.IpAddressInstance """ data = values.of({'IpAddress': ip_address, 'FriendlyName': friendly_name,}) payload = self._version.update( 'POST', self._uri, data=data, ) return IpAddressInstance( self._version, payload, account_sid=self._solution['account_sid'], ip_access_control_list_sid=self._solution['ip_access_control_list_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the IpAddressInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class IpAddressInstance(InstanceResource): """ """ def __init__(self, version, payload, account_sid, ip_access_control_list_sid, sid=None): """ Initialize the IpAddressInstance :returns: twilio.rest.api.v2010.account.sip.ip_access_control_list.ip_address.IpAddressInstance :rtype: twilio.rest.api.v2010.account.sip.ip_access_control_list.ip_address.IpAddressInstance """ super(IpAddressInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'friendly_name': payload['friendly_name'], 'ip_address': payload['ip_address'], 'ip_access_control_list_sid': payload['ip_access_control_list_sid'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'ip_access_control_list_sid': ip_access_control_list_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: IpAddressContext for this IpAddressInstance :rtype: twilio.rest.api.v2010.account.sip.ip_access_control_list.ip_address.IpAddressContext """ if self._context is None: self._context = IpAddressContext( self._version, account_sid=self._solution['account_sid'], ip_access_control_list_sid=self._solution['ip_access_control_list_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def ip_address(self): """ :returns: The ip_address :rtype: unicode """ return self._properties['ip_address'] @property def ip_access_control_list_sid(self): """ :returns: The ip_access_control_list_sid :rtype: unicode """ return self._properties['ip_access_control_list_sid'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def fetch(self): """ Fetch a IpAddressInstance :returns: Fetched IpAddressInstance :rtype: twilio.rest.api.v2010.account.sip.ip_access_control_list.ip_address.IpAddressInstance """ return self._proxy.fetch() def update(self, ip_address=values.unset, friendly_name=values.unset): """ Update the IpAddressInstance :param unicode ip_address: The ip_address :param unicode friendly_name: The friendly_name :returns: Updated IpAddressInstance :rtype: twilio.rest.api.v2010.account.sip.ip_access_control_list.ip_address.IpAddressInstance """ return self._proxy.update(ip_address=ip_address, friendly_name=friendly_name,) def delete(self): """ Deletes the IpAddressInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/token.py000066400000000000000000000124701317472742600233310ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class TokenList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the TokenList :param Version version: Version that contains the resource :param account_sid: The unique sid that identifies this account :returns: twilio.rest.api.v2010.account.token.TokenList :rtype: twilio.rest.api.v2010.account.token.TokenList """ super(TokenList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/Tokens.json'.format(**self._solution) def create(self, ttl=values.unset): """ Create a new TokenInstance :param unicode ttl: The duration in seconds the credentials are valid :returns: Newly created TokenInstance :rtype: twilio.rest.api.v2010.account.token.TokenInstance """ data = values.of({'Ttl': ttl,}) payload = self._version.create( 'POST', self._uri, data=data, ) return TokenInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class TokenPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the TokenPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The unique sid that identifies this account :returns: twilio.rest.api.v2010.account.token.TokenPage :rtype: twilio.rest.api.v2010.account.token.TokenPage """ super(TokenPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of TokenInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.token.TokenInstance :rtype: twilio.rest.api.v2010.account.token.TokenInstance """ return TokenInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class TokenInstance(InstanceResource): """ """ def __init__(self, version, payload, account_sid): """ Initialize the TokenInstance :returns: twilio.rest.api.v2010.account.token.TokenInstance :rtype: twilio.rest.api.v2010.account.token.TokenInstance """ super(TokenInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'ice_servers': payload['ice_servers'], 'password': payload['password'], 'ttl': payload['ttl'], 'username': payload['username'], } # Context self._context = None self._solution = {'account_sid': account_sid,} @property def account_sid(self): """ :returns: The unique sid that identifies this account :rtype: unicode """ return self._properties['account_sid'] @property def date_created(self): """ :returns: The date this resource was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this resource was last updated :rtype: datetime """ return self._properties['date_updated'] @property def ice_servers(self): """ :returns: An array representing the ephemeral credentials :rtype: unicode """ return self._properties['ice_servers'] @property def password(self): """ :returns: The temporary password used for authenticating :rtype: unicode """ return self._properties['password'] @property def ttl(self): """ :returns: The duration in seconds the credentials are valid :rtype: unicode """ return self._properties['ttl'] @property def username(self): """ :returns: The temporary username that uniquely identifies a Token. :rtype: unicode """ return self._properties['username'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/api/v2010/account/transcription.py000066400000000000000000000340141317472742600251060ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class TranscriptionList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the TranscriptionList :param Version version: Version that contains the resource :param account_sid: The unique sid that identifies this account :returns: twilio.rest.api.v2010.account.transcription.TranscriptionList :rtype: twilio.rest.api.v2010.account.transcription.TranscriptionList """ super(TranscriptionList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/Transcriptions.json'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams TranscriptionInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.transcription.TranscriptionInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists TranscriptionInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.transcription.TranscriptionInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of TranscriptionInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of TranscriptionInstance :rtype: twilio.rest.api.v2010.account.transcription.TranscriptionPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return TranscriptionPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of TranscriptionInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of TranscriptionInstance :rtype: twilio.rest.api.v2010.account.transcription.TranscriptionPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return TranscriptionPage(self._version, response, self._solution) def get(self, sid): """ Constructs a TranscriptionContext :param sid: Fetch by unique transcription Sid :returns: twilio.rest.api.v2010.account.transcription.TranscriptionContext :rtype: twilio.rest.api.v2010.account.transcription.TranscriptionContext """ return TranscriptionContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __call__(self, sid): """ Constructs a TranscriptionContext :param sid: Fetch by unique transcription Sid :returns: twilio.rest.api.v2010.account.transcription.TranscriptionContext :rtype: twilio.rest.api.v2010.account.transcription.TranscriptionContext """ return TranscriptionContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class TranscriptionPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the TranscriptionPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The unique sid that identifies this account :returns: twilio.rest.api.v2010.account.transcription.TranscriptionPage :rtype: twilio.rest.api.v2010.account.transcription.TranscriptionPage """ super(TranscriptionPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of TranscriptionInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.transcription.TranscriptionInstance :rtype: twilio.rest.api.v2010.account.transcription.TranscriptionInstance """ return TranscriptionInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class TranscriptionContext(InstanceContext): """ """ def __init__(self, version, account_sid, sid): """ Initialize the TranscriptionContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param sid: Fetch by unique transcription Sid :returns: twilio.rest.api.v2010.account.transcription.TranscriptionContext :rtype: twilio.rest.api.v2010.account.transcription.TranscriptionContext """ super(TranscriptionContext, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'sid': sid,} self._uri = '/Accounts/{account_sid}/Transcriptions/{sid}.json'.format(**self._solution) def fetch(self): """ Fetch a TranscriptionInstance :returns: Fetched TranscriptionInstance :rtype: twilio.rest.api.v2010.account.transcription.TranscriptionInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return TranscriptionInstance( self._version, payload, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the TranscriptionInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class TranscriptionInstance(InstanceResource): """ """ class Status(object): IN_PROGRESS = "in-progress" COMPLETED = "completed" FAILED = "failed" def __init__(self, version, payload, account_sid, sid=None): """ Initialize the TranscriptionInstance :returns: twilio.rest.api.v2010.account.transcription.TranscriptionInstance :rtype: twilio.rest.api.v2010.account.transcription.TranscriptionInstance """ super(TranscriptionInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'api_version': payload['api_version'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'duration': payload['duration'], 'price': deserialize.decimal(payload['price']), 'price_unit': payload['price_unit'], 'recording_sid': payload['recording_sid'], 'sid': payload['sid'], 'status': payload['status'], 'transcription_text': payload['transcription_text'], 'type': payload['type'], 'uri': payload['uri'], } # Context self._context = None self._solution = {'account_sid': account_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.api.v2010.account.transcription.TranscriptionContext """ if self._context is None: self._context = TranscriptionContext( self._version, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: The unique sid that identifies this account :rtype: unicode """ return self._properties['account_sid'] @property def api_version(self): """ :returns: The api_version :rtype: unicode """ return self._properties['api_version'] @property def date_created(self): """ :returns: The date this resource was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this resource was last updated :rtype: datetime """ return self._properties['date_updated'] @property def duration(self): """ :returns: The duration of the transcribed audio, in seconds. :rtype: unicode """ return self._properties['duration'] @property def price(self): """ :returns: The charge for this transcription :rtype: unicode """ return self._properties['price'] @property def price_unit(self): """ :returns: The currency in which Price is measured :rtype: unicode """ return self._properties['price_unit'] @property def recording_sid(self): """ :returns: The string that uniquely identifies the recording :rtype: unicode """ return self._properties['recording_sid'] @property def sid(self): """ :returns: A string that uniquely identifies this transcription :rtype: unicode """ return self._properties['sid'] @property def status(self): """ :returns: The status of the transcription :rtype: TranscriptionInstance.Status """ return self._properties['status'] @property def transcription_text(self): """ :returns: The text content of the transcription. :rtype: unicode """ return self._properties['transcription_text'] @property def type(self): """ :returns: The type :rtype: unicode """ return self._properties['type'] @property def uri(self): """ :returns: The URI for this resource :rtype: unicode """ return self._properties['uri'] def fetch(self): """ Fetch a TranscriptionInstance :returns: Fetched TranscriptionInstance :rtype: twilio.rest.api.v2010.account.transcription.TranscriptionInstance """ return self._proxy.fetch() def delete(self): """ Deletes the TranscriptionInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/usage/000077500000000000000000000000001317472742600227375ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/api/v2010/account/usage/__init__.py000066400000000000000000000075361317472742600250630ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page from twilio.rest.api.v2010.account.usage.record import RecordList from twilio.rest.api.v2010.account.usage.trigger import TriggerList class UsageList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the UsageList :param Version version: Version that contains the resource :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.usage.UsageList :rtype: twilio.rest.api.v2010.account.usage.UsageList """ super(UsageList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} # Components self._records = None self._triggers = None @property def records(self): """ Access the records :returns: twilio.rest.api.v2010.account.usage.record.RecordList :rtype: twilio.rest.api.v2010.account.usage.record.RecordList """ if self._records is None: self._records = RecordList(self._version, account_sid=self._solution['account_sid'],) return self._records @property def triggers(self): """ Access the triggers :returns: twilio.rest.api.v2010.account.usage.trigger.TriggerList :rtype: twilio.rest.api.v2010.account.usage.trigger.TriggerList """ if self._triggers is None: self._triggers = TriggerList(self._version, account_sid=self._solution['account_sid'],) return self._triggers def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class UsagePage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the UsagePage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.usage.UsagePage :rtype: twilio.rest.api.v2010.account.usage.UsagePage """ super(UsagePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of UsageInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.usage.UsageInstance :rtype: twilio.rest.api.v2010.account.usage.UsageInstance """ return UsageInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class UsageInstance(InstanceResource): """ """ def __init__(self, version, payload, account_sid): """ Initialize the UsageInstance :returns: twilio.rest.api.v2010.account.usage.UsageInstance :rtype: twilio.rest.api.v2010.account.usage.UsageInstance """ super(UsageInstance, self).__init__(version) # Context self._context = None self._solution = {'account_sid': account_sid,} def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/api/v2010/account/usage/record/000077500000000000000000000000001317472742600242155ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/api/v2010/account/usage/record/__init__.py000066400000000000000000000714631317472742600263410ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page from twilio.rest.api.v2010.account.usage.record.all_time import AllTimeList from twilio.rest.api.v2010.account.usage.record.daily import DailyList from twilio.rest.api.v2010.account.usage.record.last_month import LastMonthList from twilio.rest.api.v2010.account.usage.record.monthly import MonthlyList from twilio.rest.api.v2010.account.usage.record.this_month import ThisMonthList from twilio.rest.api.v2010.account.usage.record.today import TodayList from twilio.rest.api.v2010.account.usage.record.yearly import YearlyList from twilio.rest.api.v2010.account.usage.record.yesterday import YesterdayList class RecordList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the RecordList :param Version version: Version that contains the resource :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.usage.record.RecordList :rtype: twilio.rest.api.v2010.account.usage.record.RecordList """ super(RecordList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/Usage/Records.json'.format(**self._solution) # Components self._all_time = None self._daily = None self._last_month = None self._monthly = None self._this_month = None self._today = None self._yearly = None self._yesterday = None def stream(self, category=values.unset, start_date=values.unset, end_date=values.unset, limit=None, page_size=None): """ Streams RecordInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param RecordInstance.Category category: Only include usage of a given category :param date start_date: Filter by start date :param date end_date: Filter by end date :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.usage.record.RecordInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( category=category, start_date=start_date, end_date=end_date, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, category=values.unset, start_date=values.unset, end_date=values.unset, limit=None, page_size=None): """ Lists RecordInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param RecordInstance.Category category: Only include usage of a given category :param date start_date: Filter by start date :param date end_date: Filter by end date :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.usage.record.RecordInstance] """ return list(self.stream( category=category, start_date=start_date, end_date=end_date, limit=limit, page_size=page_size, )) def page(self, category=values.unset, start_date=values.unset, end_date=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of RecordInstance records from the API. Request is executed immediately :param RecordInstance.Category category: Only include usage of a given category :param date start_date: Filter by start date :param date end_date: Filter by end date :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of RecordInstance :rtype: twilio.rest.api.v2010.account.usage.record.RecordPage """ params = values.of({ 'Category': category, 'StartDate': serialize.iso8601_date(start_date), 'EndDate': serialize.iso8601_date(end_date), 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return RecordPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of RecordInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of RecordInstance :rtype: twilio.rest.api.v2010.account.usage.record.RecordPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return RecordPage(self._version, response, self._solution) @property def all_time(self): """ Access the all_time :returns: twilio.rest.api.v2010.account.usage.record.all_time.AllTimeList :rtype: twilio.rest.api.v2010.account.usage.record.all_time.AllTimeList """ if self._all_time is None: self._all_time = AllTimeList(self._version, account_sid=self._solution['account_sid'],) return self._all_time @property def daily(self): """ Access the daily :returns: twilio.rest.api.v2010.account.usage.record.daily.DailyList :rtype: twilio.rest.api.v2010.account.usage.record.daily.DailyList """ if self._daily is None: self._daily = DailyList(self._version, account_sid=self._solution['account_sid'],) return self._daily @property def last_month(self): """ Access the last_month :returns: twilio.rest.api.v2010.account.usage.record.last_month.LastMonthList :rtype: twilio.rest.api.v2010.account.usage.record.last_month.LastMonthList """ if self._last_month is None: self._last_month = LastMonthList(self._version, account_sid=self._solution['account_sid'],) return self._last_month @property def monthly(self): """ Access the monthly :returns: twilio.rest.api.v2010.account.usage.record.monthly.MonthlyList :rtype: twilio.rest.api.v2010.account.usage.record.monthly.MonthlyList """ if self._monthly is None: self._monthly = MonthlyList(self._version, account_sid=self._solution['account_sid'],) return self._monthly @property def this_month(self): """ Access the this_month :returns: twilio.rest.api.v2010.account.usage.record.this_month.ThisMonthList :rtype: twilio.rest.api.v2010.account.usage.record.this_month.ThisMonthList """ if self._this_month is None: self._this_month = ThisMonthList(self._version, account_sid=self._solution['account_sid'],) return self._this_month @property def today(self): """ Access the today :returns: twilio.rest.api.v2010.account.usage.record.today.TodayList :rtype: twilio.rest.api.v2010.account.usage.record.today.TodayList """ if self._today is None: self._today = TodayList(self._version, account_sid=self._solution['account_sid'],) return self._today @property def yearly(self): """ Access the yearly :returns: twilio.rest.api.v2010.account.usage.record.yearly.YearlyList :rtype: twilio.rest.api.v2010.account.usage.record.yearly.YearlyList """ if self._yearly is None: self._yearly = YearlyList(self._version, account_sid=self._solution['account_sid'],) return self._yearly @property def yesterday(self): """ Access the yesterday :returns: twilio.rest.api.v2010.account.usage.record.yesterday.YesterdayList :rtype: twilio.rest.api.v2010.account.usage.record.yesterday.YesterdayList """ if self._yesterday is None: self._yesterday = YesterdayList(self._version, account_sid=self._solution['account_sid'],) return self._yesterday def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class RecordPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the RecordPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.usage.record.RecordPage :rtype: twilio.rest.api.v2010.account.usage.record.RecordPage """ super(RecordPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of RecordInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.usage.record.RecordInstance :rtype: twilio.rest.api.v2010.account.usage.record.RecordInstance """ return RecordInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class RecordInstance(InstanceResource): """ """ class Category(object): ANSWERING_MACHINE_DETECTION = "answering-machine-detection" AUTHY_AUTHENTICATIONS = "authy-authentications" AUTHY_CALLS_OUTBOUND = "authy-calls-outbound" AUTHY_MONTHLY_FEES = "authy-monthly-fees" AUTHY_PHONE_INTELLIGENCE = "authy-phone-intelligence" AUTHY_PHONE_VERIFICATIONS = "authy-phone-verifications" AUTHY_SMS_OUTBOUND = "authy-sms-outbound" CALL_PROGESS_EVENTS = "call-progess-events" CALLERIDLOOKUPS = "calleridlookups" CALLS = "calls" CALLS_CLIENT = "calls-client" 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_OUTBOUND = "calls-outbound" CALLS_RECORDINGS = "calls-recordings" CALLS_SIP = "calls-sip" CALLS_SIP_INBOUND = "calls-sip-inbound" CALLS_SIP_OUTBOUND = "calls-sip-outbound" CARRIER_LOOKUPS = "carrier-lookups" CONVERSATIONS = "conversations" CONVERSATIONS_API_REQUESTS = "conversations-api-requests" CONVERSATIONS_CONVERSATION_EVENTS = "conversations-conversation-events" CONVERSATIONS_ENDPOINT_CONNECTIVITY = "conversations-endpoint-connectivity" CONVERSATIONS_EVENTS = "conversations-events" CONVERSATIONS_PARTICIPANT_EVENTS = "conversations-participant-events" CONVERSATIONS_PARTICIPANTS = "conversations-participants" CPS = "cps" GROUP_ROOMS_MEDIA_DOWNLOADED = "group-rooms-media-downloaded" GROUP_ROOMS_MEDIA_RECORDED = "group-rooms-media-recorded" GROUP_ROOMS_MEDIA_ROUTED = "group-rooms-media-routed" GROUP_ROOMS_MEDIA_STORED = "group-rooms-media-stored" GROUP_ROOMS_PARTICIPANT_MINUTES = "group-rooms-participant-minutes" GROUP_ROOMS_RECORDED_MINUTES = "group-rooms-recorded-minutes" 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" LOOKUPS = "lookups" MARKETPLACE = "marketplace" MARKETPLACE_ALGORITHMIA_NAMED_ENTITY_RECOGNITION = "marketplace-algorithmia-named-entity-recognition" MARKETPLACE_DIGITAL_SEGMENT_BUSINESS_INFO = "marketplace-digital-segment-business-info" MARKETPLACE_GOOGLE_SPEECH_TO_TEXT = "marketplace-google-speech-to-text" MARKETPLACE_IBM_WATSON_MESSAGE_INSIGHTS = "marketplace-ibm-watson-message-insights" MARKETPLACE_IBM_WATSON_MESSAGE_SENTIMENT = "marketplace-ibm-watson-message-sentiment" MARKETPLACE_IBM_WATSON_RECORDING_ANALYSIS = "marketplace-ibm-watson-recording-analysis" MARKETPLACE_ICEHOOK_SYSTEMS_SCOUT = "marketplace-icehook-systems-scout" MARKETPLACE_INFOGROUP_DATAAXLE_BIZINFO = "marketplace-infogroup-dataaxle-bizinfo" MARKETPLACE_CADENCE_TRANSCRIPTION = "marketplace-cadence-transcription" MARKETPLACE_CADENCE_TRANSLATION = "marketplace-cadence-translation" MARKETPLACE_CAPIO_SPEECH_TO_TEXT = "marketplace-capio-speech-to-text" MARKETPLACE_FACEBOOK_OFFLINE_CONVERSIONS = "marketplace-facebook-offline-conversions" MARKETPLACE_KEEN_IO_CONTACT_CENTER_ANALYTICS = "marketplace-keen-io-contact-center-analytics" MARKETPLACE_MARCHEX_CLEANCALL = "marketplace-marchex-cleancall" MARKETPLACE_MARCHEX_SENTIMENT_ANALYSIS_FOR_SMS = "marketplace-marchex-sentiment-analysis-for-sms" MARKETPLACE_MARKETPLACE_NEXTCALLER_SOCIAL_ID = "marketplace-marketplace-nextcaller-social-id" MARKETPLACE_MOBILE_COMMONS_OPT_OUT_CLASSIFIER = "marketplace-mobile-commons-opt-out-classifier" MARKETPLACE_NEXIWAVE_VOICEMAIL_TO_TEXT = "marketplace-nexiwave-voicemail-to-text" MARKETPLACE_NEXTCALLER_ADVANCED_CALLER_IDENTIFICATION = "marketplace-nextcaller-advanced-caller-identification" MARKETPLACE_NOMOROBO_SPAM_SCORE = "marketplace-nomorobo-spam-score" MARKETPLACE_PAYFONE_TCPA_COMPLIANCE = "marketplace-payfone-tcpa-compliance" MARKETPLACE_TELO_OPENCNAM = "marketplace-telo-opencnam" MARKETPLACE_TRUECNAM_TRUE_SPAM = "marketplace-truecnam-true-spam" MARKETPLACE_TWILIO_CALLER_NAME_LOOKUP_US = "marketplace-twilio-caller-name-lookup-us" MARKETPLACE_TWILIO_CARRIER_INFORMATION_LOOKUP = "marketplace-twilio-carrier-information-lookup" MARKETPLACE_VOICEBASE_PCI = "marketplace-voicebase-pci" MARKETPLACE_VOICEBASE_TRANSCRIPTION = "marketplace-voicebase-transcription" MARKETPLACE_WHITEPAGES_PRO_CALLER_IDENTIFICATION = "marketplace-whitepages-pro-caller-identification" MARKETPLACE_WHITEPAGES_PRO_PHONE_INTELLIGENCE = "marketplace-whitepages-pro-phone-intelligence" MARKETPLACE_WHITEPAGES_PRO_PHONE_REPUTATION = "marketplace-whitepages-pro-phone-reputation" MARKETPLACE_WOLFRAM_SHORT_ANSWER = "marketplace-wolfram-short-answer" MARKETPLACE_WOLFARM_SPOKEN_RESULTS = "marketplace-wolfarm-spoken-results" MARKETPLACE_DEEPGRAM_PHRASE_DETECTOR = "marketplace-deepgram-phrase-detector" MARKETPLACE_CONVRIZA_ABABA = "marketplace-convriza-ababa" MARKETPLACE_IBM_WATSON_TONE_ANALYZER = "marketplace-ibm-watson-tone-analyzer" MARKETPLACE_REMEETING_AUTOMATIC_SPEECH_RECOGNITION = "marketplace-remeeting-automatic-speech-recognition" MARKETPLACE_TCPA_DEFENSE_SOLUTIONS_BLACKLIST_FEED = "marketplace-tcpa-defense-solutions-blacklist-feed" MARKETPLACE_VOICEBASE_TRANSCRIPTION_CUSTOM_VOCABULARY = "marketplace-voicebase-transcription-custom-vocabulary" MARKETPLACE_YTICA_CONTACT_CENTER_REPORTING_ANALYTICS = "marketplace-ytica-contact-center-reporting-analytics" MEDIASTORAGE = "mediastorage" MMS = "mms" MMS_INBOUND = "mms-inbound" MMS_INBOUND_LONGCODE = "mms-inbound-longcode" MMS_INBOUND_SHORTCODE = "mms-inbound-shortcode" MMS_OUTBOUND = "mms-outbound" MMS_OUTBOUND_LONGCODE = "mms-outbound-longcode" MMS_OUTBOUND_SHORTCODE = "mms-outbound-shortcode" MONITOR_READS = "monitor-reads" MONITOR_STORAGE = "monitor-storage" MONITOR_WRITES = "monitor-writes" NOTIFY = "notify" NOTIFY_ACTIONS_ATTEMPTS = "notify-actions-attempts" NOTIFY_CHANNELS = "notify-channels" NUMBER_FORMAT_LOOKUPS = "number-format-lookups" PCHAT = "pchat" PCHAT_ACTIONS = "pchat-actions" PCHAT_APS = "pchat-aps" PCHAT_NOTIFICATIONS = "pchat-notifications" PCHAT_READS = "pchat-reads" PCHAT_USERS = "pchat-users" PCHAT_MESSAGES = "pchat-messages" PEER_TO_PEER_ROOMS_PARTICIPANT_MINUTES = "peer-to-peer-rooms-participant-minutes" PFAX = "pfax" PFAX_MINUTES = "pfax-minutes" PFAX_MINUTES_INBOUND = "pfax-minutes-inbound" PFAX_MINUTES_OUTBOUND = "pfax-minutes-outbound" PFAX_PAGES = "pfax-pages" PHONENUMBERS = "phonenumbers" PHONENUMBERS_CPS = "phonenumbers-cps" PHONENUMBERS_EMERGENCY = "phonenumbers-emergency" PHONENUMBERS_LOCAL = "phonenumbers-local" PHONENUMBERS_MOBILE = "phonenumbers-mobile" PHONENUMBERS_SETUPS = "phonenumbers-setups" PHONENUMBERS_TOLLFREE = "phonenumbers-tollfree" PREMIUMSUPPORT = "premiumsupport" PV = "pv" PV_ROOM_PARTICIPANTS = "pv-room-participants" PV_ROOM_PARTICIPANTS_AU1 = "pv-room-participants-au1" PV_ROOM_PARTICIPANTS_BR1 = "pv-room-participants-br1" PV_ROOM_PARTICIPANTS_IE1 = "pv-room-participants-ie1" PV_ROOM_PARTICIPANTS_JP1 = "pv-room-participants-jp1" PV_ROOM_PARTICIPANTS_SG1 = "pv-room-participants-sg1" PV_ROOM_PARTICIPANTS_US1 = "pv-room-participants-us1" PV_ROOM_PARTICIPANTS_US2 = "pv-room-participants-us2" PV_ROOMS = "pv-rooms" PV_SIP_ENDPOINT_REGISTRATIONS = "pv-sip-endpoint-registrations" RECORDINGS = "recordings" RECORDINGSTORAGE = "recordingstorage" ROOMS_GROUP_MINUTES = "rooms-group-minutes" ROOMS_GROUP_BANDWIDTH = "rooms-group-bandwidth" 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_UK = "shortcodes-uk" SHORTCODES_VANITY = "shortcodes-vanity" SMS = "sms" SMS_INBOUND = "sms-inbound" SMS_INBOUND_LONGCODE = "sms-inbound-longcode" SMS_INBOUND_SHORTCODE = "sms-inbound-shortcode" 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_MESSAGES_FEATURES = "sms-messages-features" SPEECH_RECOGNITION = "speech-recognition" SYNC = "sync" SYNC_ACTIONS = "sync-actions" SYNC_ENDPOINT_HOURS = "sync-endpoint-hours" SYNC_ENDPOINT_HOURS_ABOVE_DAILY_CAP = "sync-endpoint-hours-above-daily-cap" TASKROUTER_TASKS = "taskrouter-tasks" TOTALPRICE = "totalprice" TRANSCRIPTIONS = "transcriptions" TRUNKING_CPS = "trunking-cps" TRUNKING_EMERGENCY_CALLS = "trunking-emergency-calls" TRUNKING_ORIGINATION = "trunking-origination" TRUNKING_ORIGINATION_LOCAL = "trunking-origination-local" TRUNKING_ORIGINATION_MOBILE = "trunking-origination-mobile" TRUNKING_ORIGINATION_TOLLFREE = "trunking-origination-tollfree" TRUNKING_RECORDINGS = "trunking-recordings" TRUNKING_SECURE = "trunking-secure" TRUNKING_TERMINATION = "trunking-termination" TURNMEGABYTES = "turnmegabytes" TURNMEGABYTES_AUSTRALIA = "turnmegabytes-australia" TURNMEGABYTES_BRASIL = "turnmegabytes-brasil" TURNMEGABYTES_INDIA = "turnmegabytes-india" TURNMEGABYTES_IRELAND = "turnmegabytes-ireland" TURNMEGABYTES_JAPAN = "turnmegabytes-japan" TURNMEGABYTES_SINGAPORE = "turnmegabytes-singapore" TURNMEGABYTES_USEAST = "turnmegabytes-useast" TURNMEGABYTES_USWEST = "turnmegabytes-uswest" TWILIO_INTERCONNECT = "twilio-interconnect" VOICE_INSIGHTS = "voice-insights" VOICE_INSIGHTS_AUDIO_TRACE = "voice-insights-audio-trace" VOICE_INSIGHTS_CARRIER_CALLS = "voice-insights-carrier-calls" WIRELESS = "wireless" 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_USAGE = "wireless-usage" WIRELESS_USAGE_COMMANDS = "wireless-usage-commands" WIRELESS_USAGE_COMMANDS_AFRICA = "wireless-usage-commands-africa" WIRELESS_USAGE_COMMANDS_ASIA = "wireless-usage-commands-asia" WIRELESS_USAGE_COMMANDS_CENTRALANDSOUTHAMERICA = "wireless-usage-commands-centralandsouthamerica" WIRELESS_USAGE_COMMANDS_EUROPE = "wireless-usage-commands-europe" WIRELESS_USAGE_COMMANDS_HOME = "wireless-usage-commands-home" WIRELESS_USAGE_COMMANDS_NORTHAMERICA = "wireless-usage-commands-northamerica" WIRELESS_USAGE_COMMANDS_OCEANIA = "wireless-usage-commands-oceania" WIRELESS_USAGE_COMMANDS_ROAMING = "wireless-usage-commands-roaming" WIRELESS_USAGE_DATA = "wireless-usage-data" WIRELESS_USAGE_DATA_AFRICA = "wireless-usage-data-africa" WIRELESS_USAGE_DATA_ASIA = "wireless-usage-data-asia" WIRELESS_USAGE_DATA_CENTRALANDSOUTHAMERICA = "wireless-usage-data-centralandsouthamerica" WIRELESS_USAGE_DATA_CUSTOM_ADDITIONALMB = "wireless-usage-data-custom-additionalmb" WIRELESS_USAGE_DATA_CUSTOM_FIRST5MB = "wireless-usage-data-custom-first5mb" WIRELESS_USAGE_DATA_DOMESTIC_ROAMING = "wireless-usage-data-domestic-roaming" WIRELESS_USAGE_DATA_EUROPE = "wireless-usage-data-europe" WIRELESS_USAGE_DATA_INDIVIDUAL_ADDITIONALGB = "wireless-usage-data-individual-additionalgb" WIRELESS_USAGE_DATA_INDIVIDUAL_FIRSTGB = "wireless-usage-data-individual-firstgb" WIRELESS_USAGE_DATA_INTERNATIONAL_ROAMING_CANADA = "wireless-usage-data-international-roaming-canada" WIRELESS_USAGE_DATA_INTERNATIONAL_ROAMING_INDIA = "wireless-usage-data-international-roaming-india" WIRELESS_USAGE_DATA_INTERNATIONAL_ROAMING_MEXICO = "wireless-usage-data-international-roaming-mexico" WIRELESS_USAGE_DATA_NORTHAMERICA = "wireless-usage-data-northamerica" WIRELESS_USAGE_DATA_OCEANIA = "wireless-usage-data-oceania" WIRELESS_USAGE_DATA_POOLED = "wireless-usage-data-pooled" WIRELESS_USAGE_DATA_POOLED_DOWNLINK = "wireless-usage-data-pooled-downlink" WIRELESS_USAGE_DATA_POOLED_UPLINK = "wireless-usage-data-pooled-uplink" WIRELESS_USAGE_MRC = "wireless-usage-mrc" WIRELESS_USAGE_MRC_CUSTOM = "wireless-usage-mrc-custom" WIRELESS_USAGE_MRC_INDIVIDUAL = "wireless-usage-mrc-individual" WIRELESS_USAGE_MRC_POOLED = "wireless-usage-mrc-pooled" WIRELESS_USAGE_MRC_SUSPENDED = "wireless-usage-mrc-suspended" WIRELESS_USAGE_VOICE = "wireless-usage-voice" WIRELESS_USAGE_SMS = "wireless-usage-sms" def __init__(self, version, payload, account_sid): """ Initialize the RecordInstance :returns: twilio.rest.api.v2010.account.usage.record.RecordInstance :rtype: twilio.rest.api.v2010.account.usage.record.RecordInstance """ super(RecordInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'api_version': payload['api_version'], 'category': payload['category'], 'count': payload['count'], 'count_unit': payload['count_unit'], 'description': payload['description'], 'end_date': deserialize.iso8601_date(payload['end_date']), 'price': deserialize.decimal(payload['price']), 'price_unit': payload['price_unit'], 'start_date': deserialize.iso8601_date(payload['start_date']), 'subresource_uris': payload['subresource_uris'], 'uri': payload['uri'], 'usage': payload['usage'], 'usage_unit': payload['usage_unit'], } # Context self._context = None self._solution = {'account_sid': account_sid,} @property def account_sid(self): """ :returns: The Account that accrued the usage :rtype: unicode """ return self._properties['account_sid'] @property def api_version(self): """ :returns: The api_version :rtype: unicode """ return self._properties['api_version'] @property def category(self): """ :returns: The category of usage :rtype: RecordInstance.Category """ return self._properties['category'] @property def count(self): """ :returns: The number of usage events (e.g. the number of calls). :rtype: unicode """ return self._properties['count'] @property def count_unit(self): """ :returns: The unit in which `Count` is measured :rtype: unicode """ return self._properties['count_unit'] @property def description(self): """ :returns: A human-readable description of the usage category. :rtype: unicode """ return self._properties['description'] @property def end_date(self): """ :returns: The last date usage is included in this record :rtype: date """ return self._properties['end_date'] @property def price(self): """ :returns: The total price of the usage :rtype: unicode """ return self._properties['price'] @property def price_unit(self): """ :returns: The currency in which `Price` is measured :rtype: unicode """ return self._properties['price_unit'] @property def start_date(self): """ :returns: The first date usage is included in this record :rtype: date """ return self._properties['start_date'] @property def subresource_uris(self): """ :returns: Subresources Uris for this UsageRecord :rtype: unicode """ return self._properties['subresource_uris'] @property def uri(self): """ :returns: The URI for this resource :rtype: unicode """ return self._properties['uri'] @property def usage(self): """ :returns: The amount of usage :rtype: unicode """ return self._properties['usage'] @property def usage_unit(self): """ :returns: The units in which `Usage` is measured :rtype: unicode """ return self._properties['usage_unit'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/api/v2010/account/usage/record/all_time.py000066400000000000000000000607021317472742600263620ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class AllTimeList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the AllTimeList :param Version version: Version that contains the resource :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.usage.record.all_time.AllTimeList :rtype: twilio.rest.api.v2010.account.usage.record.all_time.AllTimeList """ super(AllTimeList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/Usage/Records/AllTime.json'.format(**self._solution) def stream(self, category=values.unset, start_date=values.unset, end_date=values.unset, limit=None, page_size=None): """ Streams AllTimeInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param AllTimeInstance.Category category: The category :param date start_date: The start_date :param date end_date: The end_date :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.usage.record.all_time.AllTimeInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( category=category, start_date=start_date, end_date=end_date, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, category=values.unset, start_date=values.unset, end_date=values.unset, limit=None, page_size=None): """ Lists AllTimeInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param AllTimeInstance.Category category: The category :param date start_date: The start_date :param date end_date: The end_date :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.usage.record.all_time.AllTimeInstance] """ return list(self.stream( category=category, start_date=start_date, end_date=end_date, limit=limit, page_size=page_size, )) def page(self, category=values.unset, start_date=values.unset, end_date=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of AllTimeInstance records from the API. Request is executed immediately :param AllTimeInstance.Category category: The category :param date start_date: The start_date :param date end_date: The end_date :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of AllTimeInstance :rtype: twilio.rest.api.v2010.account.usage.record.all_time.AllTimePage """ params = values.of({ 'Category': category, 'StartDate': serialize.iso8601_date(start_date), 'EndDate': serialize.iso8601_date(end_date), 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return AllTimePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of AllTimeInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of AllTimeInstance :rtype: twilio.rest.api.v2010.account.usage.record.all_time.AllTimePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return AllTimePage(self._version, response, self._solution) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class AllTimePage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the AllTimePage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.usage.record.all_time.AllTimePage :rtype: twilio.rest.api.v2010.account.usage.record.all_time.AllTimePage """ super(AllTimePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of AllTimeInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.usage.record.all_time.AllTimeInstance :rtype: twilio.rest.api.v2010.account.usage.record.all_time.AllTimeInstance """ return AllTimeInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class AllTimeInstance(InstanceResource): """ """ class Category(object): ANSWERING_MACHINE_DETECTION = "answering-machine-detection" AUTHY_AUTHENTICATIONS = "authy-authentications" AUTHY_CALLS_OUTBOUND = "authy-calls-outbound" AUTHY_MONTHLY_FEES = "authy-monthly-fees" AUTHY_PHONE_INTELLIGENCE = "authy-phone-intelligence" AUTHY_PHONE_VERIFICATIONS = "authy-phone-verifications" AUTHY_SMS_OUTBOUND = "authy-sms-outbound" CALL_PROGESS_EVENTS = "call-progess-events" CALLERIDLOOKUPS = "calleridlookups" CALLS = "calls" CALLS_CLIENT = "calls-client" 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_OUTBOUND = "calls-outbound" CALLS_RECORDINGS = "calls-recordings" CALLS_SIP = "calls-sip" CALLS_SIP_INBOUND = "calls-sip-inbound" CALLS_SIP_OUTBOUND = "calls-sip-outbound" CARRIER_LOOKUPS = "carrier-lookups" CONVERSATIONS = "conversations" CONVERSATIONS_API_REQUESTS = "conversations-api-requests" CONVERSATIONS_CONVERSATION_EVENTS = "conversations-conversation-events" CONVERSATIONS_ENDPOINT_CONNECTIVITY = "conversations-endpoint-connectivity" CONVERSATIONS_EVENTS = "conversations-events" CONVERSATIONS_PARTICIPANT_EVENTS = "conversations-participant-events" CONVERSATIONS_PARTICIPANTS = "conversations-participants" CPS = "cps" GROUP_ROOMS_MEDIA_DOWNLOADED = "group-rooms-media-downloaded" GROUP_ROOMS_MEDIA_RECORDED = "group-rooms-media-recorded" GROUP_ROOMS_MEDIA_ROUTED = "group-rooms-media-routed" GROUP_ROOMS_MEDIA_STORED = "group-rooms-media-stored" GROUP_ROOMS_PARTICIPANT_MINUTES = "group-rooms-participant-minutes" GROUP_ROOMS_RECORDED_MINUTES = "group-rooms-recorded-minutes" 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" LOOKUPS = "lookups" MARKETPLACE = "marketplace" MARKETPLACE_ALGORITHMIA_NAMED_ENTITY_RECOGNITION = "marketplace-algorithmia-named-entity-recognition" MARKETPLACE_DIGITAL_SEGMENT_BUSINESS_INFO = "marketplace-digital-segment-business-info" MARKETPLACE_GOOGLE_SPEECH_TO_TEXT = "marketplace-google-speech-to-text" MARKETPLACE_IBM_WATSON_MESSAGE_INSIGHTS = "marketplace-ibm-watson-message-insights" MARKETPLACE_IBM_WATSON_MESSAGE_SENTIMENT = "marketplace-ibm-watson-message-sentiment" MARKETPLACE_IBM_WATSON_RECORDING_ANALYSIS = "marketplace-ibm-watson-recording-analysis" MARKETPLACE_ICEHOOK_SYSTEMS_SCOUT = "marketplace-icehook-systems-scout" MARKETPLACE_INFOGROUP_DATAAXLE_BIZINFO = "marketplace-infogroup-dataaxle-bizinfo" MARKETPLACE_CADENCE_TRANSCRIPTION = "marketplace-cadence-transcription" MARKETPLACE_CADENCE_TRANSLATION = "marketplace-cadence-translation" MARKETPLACE_CAPIO_SPEECH_TO_TEXT = "marketplace-capio-speech-to-text" MARKETPLACE_FACEBOOK_OFFLINE_CONVERSIONS = "marketplace-facebook-offline-conversions" MARKETPLACE_KEEN_IO_CONTACT_CENTER_ANALYTICS = "marketplace-keen-io-contact-center-analytics" MARKETPLACE_MARCHEX_CLEANCALL = "marketplace-marchex-cleancall" MARKETPLACE_MARCHEX_SENTIMENT_ANALYSIS_FOR_SMS = "marketplace-marchex-sentiment-analysis-for-sms" MARKETPLACE_MARKETPLACE_NEXTCALLER_SOCIAL_ID = "marketplace-marketplace-nextcaller-social-id" MARKETPLACE_MOBILE_COMMONS_OPT_OUT_CLASSIFIER = "marketplace-mobile-commons-opt-out-classifier" MARKETPLACE_NEXIWAVE_VOICEMAIL_TO_TEXT = "marketplace-nexiwave-voicemail-to-text" MARKETPLACE_NEXTCALLER_ADVANCED_CALLER_IDENTIFICATION = "marketplace-nextcaller-advanced-caller-identification" MARKETPLACE_NOMOROBO_SPAM_SCORE = "marketplace-nomorobo-spam-score" MARKETPLACE_PAYFONE_TCPA_COMPLIANCE = "marketplace-payfone-tcpa-compliance" MARKETPLACE_TELO_OPENCNAM = "marketplace-telo-opencnam" MARKETPLACE_TRUECNAM_TRUE_SPAM = "marketplace-truecnam-true-spam" MARKETPLACE_TWILIO_CALLER_NAME_LOOKUP_US = "marketplace-twilio-caller-name-lookup-us" MARKETPLACE_TWILIO_CARRIER_INFORMATION_LOOKUP = "marketplace-twilio-carrier-information-lookup" MARKETPLACE_VOICEBASE_PCI = "marketplace-voicebase-pci" MARKETPLACE_VOICEBASE_TRANSCRIPTION = "marketplace-voicebase-transcription" MARKETPLACE_WHITEPAGES_PRO_CALLER_IDENTIFICATION = "marketplace-whitepages-pro-caller-identification" MARKETPLACE_WHITEPAGES_PRO_PHONE_INTELLIGENCE = "marketplace-whitepages-pro-phone-intelligence" MARKETPLACE_WHITEPAGES_PRO_PHONE_REPUTATION = "marketplace-whitepages-pro-phone-reputation" MARKETPLACE_WOLFRAM_SHORT_ANSWER = "marketplace-wolfram-short-answer" MARKETPLACE_WOLFARM_SPOKEN_RESULTS = "marketplace-wolfarm-spoken-results" MARKETPLACE_DEEPGRAM_PHRASE_DETECTOR = "marketplace-deepgram-phrase-detector" MARKETPLACE_CONVRIZA_ABABA = "marketplace-convriza-ababa" MARKETPLACE_IBM_WATSON_TONE_ANALYZER = "marketplace-ibm-watson-tone-analyzer" MARKETPLACE_REMEETING_AUTOMATIC_SPEECH_RECOGNITION = "marketplace-remeeting-automatic-speech-recognition" MARKETPLACE_TCPA_DEFENSE_SOLUTIONS_BLACKLIST_FEED = "marketplace-tcpa-defense-solutions-blacklist-feed" MARKETPLACE_VOICEBASE_TRANSCRIPTION_CUSTOM_VOCABULARY = "marketplace-voicebase-transcription-custom-vocabulary" MARKETPLACE_YTICA_CONTACT_CENTER_REPORTING_ANALYTICS = "marketplace-ytica-contact-center-reporting-analytics" MEDIASTORAGE = "mediastorage" MMS = "mms" MMS_INBOUND = "mms-inbound" MMS_INBOUND_LONGCODE = "mms-inbound-longcode" MMS_INBOUND_SHORTCODE = "mms-inbound-shortcode" MMS_OUTBOUND = "mms-outbound" MMS_OUTBOUND_LONGCODE = "mms-outbound-longcode" MMS_OUTBOUND_SHORTCODE = "mms-outbound-shortcode" MONITOR_READS = "monitor-reads" MONITOR_STORAGE = "monitor-storage" MONITOR_WRITES = "monitor-writes" NOTIFY = "notify" NOTIFY_ACTIONS_ATTEMPTS = "notify-actions-attempts" NOTIFY_CHANNELS = "notify-channels" NUMBER_FORMAT_LOOKUPS = "number-format-lookups" PCHAT = "pchat" PCHAT_ACTIONS = "pchat-actions" PCHAT_APS = "pchat-aps" PCHAT_NOTIFICATIONS = "pchat-notifications" PCHAT_READS = "pchat-reads" PCHAT_USERS = "pchat-users" PCHAT_MESSAGES = "pchat-messages" PEER_TO_PEER_ROOMS_PARTICIPANT_MINUTES = "peer-to-peer-rooms-participant-minutes" PFAX = "pfax" PFAX_MINUTES = "pfax-minutes" PFAX_MINUTES_INBOUND = "pfax-minutes-inbound" PFAX_MINUTES_OUTBOUND = "pfax-minutes-outbound" PFAX_PAGES = "pfax-pages" PHONENUMBERS = "phonenumbers" PHONENUMBERS_CPS = "phonenumbers-cps" PHONENUMBERS_EMERGENCY = "phonenumbers-emergency" PHONENUMBERS_LOCAL = "phonenumbers-local" PHONENUMBERS_MOBILE = "phonenumbers-mobile" PHONENUMBERS_SETUPS = "phonenumbers-setups" PHONENUMBERS_TOLLFREE = "phonenumbers-tollfree" PREMIUMSUPPORT = "premiumsupport" PV = "pv" PV_ROOM_PARTICIPANTS = "pv-room-participants" PV_ROOM_PARTICIPANTS_AU1 = "pv-room-participants-au1" PV_ROOM_PARTICIPANTS_BR1 = "pv-room-participants-br1" PV_ROOM_PARTICIPANTS_IE1 = "pv-room-participants-ie1" PV_ROOM_PARTICIPANTS_JP1 = "pv-room-participants-jp1" PV_ROOM_PARTICIPANTS_SG1 = "pv-room-participants-sg1" PV_ROOM_PARTICIPANTS_US1 = "pv-room-participants-us1" PV_ROOM_PARTICIPANTS_US2 = "pv-room-participants-us2" PV_ROOMS = "pv-rooms" PV_SIP_ENDPOINT_REGISTRATIONS = "pv-sip-endpoint-registrations" RECORDINGS = "recordings" RECORDINGSTORAGE = "recordingstorage" ROOMS_GROUP_MINUTES = "rooms-group-minutes" ROOMS_GROUP_BANDWIDTH = "rooms-group-bandwidth" 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_UK = "shortcodes-uk" SHORTCODES_VANITY = "shortcodes-vanity" SMS = "sms" SMS_INBOUND = "sms-inbound" SMS_INBOUND_LONGCODE = "sms-inbound-longcode" SMS_INBOUND_SHORTCODE = "sms-inbound-shortcode" 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_MESSAGES_FEATURES = "sms-messages-features" SPEECH_RECOGNITION = "speech-recognition" SYNC = "sync" SYNC_ACTIONS = "sync-actions" SYNC_ENDPOINT_HOURS = "sync-endpoint-hours" SYNC_ENDPOINT_HOURS_ABOVE_DAILY_CAP = "sync-endpoint-hours-above-daily-cap" TASKROUTER_TASKS = "taskrouter-tasks" TOTALPRICE = "totalprice" TRANSCRIPTIONS = "transcriptions" TRUNKING_CPS = "trunking-cps" TRUNKING_EMERGENCY_CALLS = "trunking-emergency-calls" TRUNKING_ORIGINATION = "trunking-origination" TRUNKING_ORIGINATION_LOCAL = "trunking-origination-local" TRUNKING_ORIGINATION_MOBILE = "trunking-origination-mobile" TRUNKING_ORIGINATION_TOLLFREE = "trunking-origination-tollfree" TRUNKING_RECORDINGS = "trunking-recordings" TRUNKING_SECURE = "trunking-secure" TRUNKING_TERMINATION = "trunking-termination" TURNMEGABYTES = "turnmegabytes" TURNMEGABYTES_AUSTRALIA = "turnmegabytes-australia" TURNMEGABYTES_BRASIL = "turnmegabytes-brasil" TURNMEGABYTES_INDIA = "turnmegabytes-india" TURNMEGABYTES_IRELAND = "turnmegabytes-ireland" TURNMEGABYTES_JAPAN = "turnmegabytes-japan" TURNMEGABYTES_SINGAPORE = "turnmegabytes-singapore" TURNMEGABYTES_USEAST = "turnmegabytes-useast" TURNMEGABYTES_USWEST = "turnmegabytes-uswest" TWILIO_INTERCONNECT = "twilio-interconnect" VOICE_INSIGHTS = "voice-insights" VOICE_INSIGHTS_AUDIO_TRACE = "voice-insights-audio-trace" VOICE_INSIGHTS_CARRIER_CALLS = "voice-insights-carrier-calls" WIRELESS = "wireless" 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_USAGE = "wireless-usage" WIRELESS_USAGE_COMMANDS = "wireless-usage-commands" WIRELESS_USAGE_COMMANDS_AFRICA = "wireless-usage-commands-africa" WIRELESS_USAGE_COMMANDS_ASIA = "wireless-usage-commands-asia" WIRELESS_USAGE_COMMANDS_CENTRALANDSOUTHAMERICA = "wireless-usage-commands-centralandsouthamerica" WIRELESS_USAGE_COMMANDS_EUROPE = "wireless-usage-commands-europe" WIRELESS_USAGE_COMMANDS_HOME = "wireless-usage-commands-home" WIRELESS_USAGE_COMMANDS_NORTHAMERICA = "wireless-usage-commands-northamerica" WIRELESS_USAGE_COMMANDS_OCEANIA = "wireless-usage-commands-oceania" WIRELESS_USAGE_COMMANDS_ROAMING = "wireless-usage-commands-roaming" WIRELESS_USAGE_DATA = "wireless-usage-data" WIRELESS_USAGE_DATA_AFRICA = "wireless-usage-data-africa" WIRELESS_USAGE_DATA_ASIA = "wireless-usage-data-asia" WIRELESS_USAGE_DATA_CENTRALANDSOUTHAMERICA = "wireless-usage-data-centralandsouthamerica" WIRELESS_USAGE_DATA_CUSTOM_ADDITIONALMB = "wireless-usage-data-custom-additionalmb" WIRELESS_USAGE_DATA_CUSTOM_FIRST5MB = "wireless-usage-data-custom-first5mb" WIRELESS_USAGE_DATA_DOMESTIC_ROAMING = "wireless-usage-data-domestic-roaming" WIRELESS_USAGE_DATA_EUROPE = "wireless-usage-data-europe" WIRELESS_USAGE_DATA_INDIVIDUAL_ADDITIONALGB = "wireless-usage-data-individual-additionalgb" WIRELESS_USAGE_DATA_INDIVIDUAL_FIRSTGB = "wireless-usage-data-individual-firstgb" WIRELESS_USAGE_DATA_INTERNATIONAL_ROAMING_CANADA = "wireless-usage-data-international-roaming-canada" WIRELESS_USAGE_DATA_INTERNATIONAL_ROAMING_INDIA = "wireless-usage-data-international-roaming-india" WIRELESS_USAGE_DATA_INTERNATIONAL_ROAMING_MEXICO = "wireless-usage-data-international-roaming-mexico" WIRELESS_USAGE_DATA_NORTHAMERICA = "wireless-usage-data-northamerica" WIRELESS_USAGE_DATA_OCEANIA = "wireless-usage-data-oceania" WIRELESS_USAGE_DATA_POOLED = "wireless-usage-data-pooled" WIRELESS_USAGE_DATA_POOLED_DOWNLINK = "wireless-usage-data-pooled-downlink" WIRELESS_USAGE_DATA_POOLED_UPLINK = "wireless-usage-data-pooled-uplink" WIRELESS_USAGE_MRC = "wireless-usage-mrc" WIRELESS_USAGE_MRC_CUSTOM = "wireless-usage-mrc-custom" WIRELESS_USAGE_MRC_INDIVIDUAL = "wireless-usage-mrc-individual" WIRELESS_USAGE_MRC_POOLED = "wireless-usage-mrc-pooled" WIRELESS_USAGE_MRC_SUSPENDED = "wireless-usage-mrc-suspended" WIRELESS_USAGE_VOICE = "wireless-usage-voice" WIRELESS_USAGE_SMS = "wireless-usage-sms" def __init__(self, version, payload, account_sid): """ Initialize the AllTimeInstance :returns: twilio.rest.api.v2010.account.usage.record.all_time.AllTimeInstance :rtype: twilio.rest.api.v2010.account.usage.record.all_time.AllTimeInstance """ super(AllTimeInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'api_version': payload['api_version'], 'category': payload['category'], 'count': payload['count'], 'count_unit': payload['count_unit'], 'description': payload['description'], 'end_date': deserialize.iso8601_date(payload['end_date']), 'price': deserialize.decimal(payload['price']), 'price_unit': payload['price_unit'], 'start_date': deserialize.iso8601_date(payload['start_date']), 'subresource_uris': payload['subresource_uris'], 'uri': payload['uri'], 'usage': payload['usage'], 'usage_unit': payload['usage_unit'], } # Context self._context = None self._solution = {'account_sid': account_sid,} @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def api_version(self): """ :returns: The api_version :rtype: unicode """ return self._properties['api_version'] @property def category(self): """ :returns: The category :rtype: AllTimeInstance.Category """ return self._properties['category'] @property def count(self): """ :returns: The count :rtype: unicode """ return self._properties['count'] @property def count_unit(self): """ :returns: The count_unit :rtype: unicode """ return self._properties['count_unit'] @property def description(self): """ :returns: The description :rtype: unicode """ return self._properties['description'] @property def end_date(self): """ :returns: The end_date :rtype: date """ return self._properties['end_date'] @property def price(self): """ :returns: The price :rtype: unicode """ return self._properties['price'] @property def price_unit(self): """ :returns: The price_unit :rtype: unicode """ return self._properties['price_unit'] @property def start_date(self): """ :returns: The start_date :rtype: date """ return self._properties['start_date'] @property def subresource_uris(self): """ :returns: The subresource_uris :rtype: unicode """ return self._properties['subresource_uris'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] @property def usage(self): """ :returns: The usage :rtype: unicode """ return self._properties['usage'] @property def usage_unit(self): """ :returns: The usage_unit :rtype: unicode """ return self._properties['usage_unit'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/api/v2010/account/usage/record/daily.py000066400000000000000000000605201317472742600256740ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class DailyList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the DailyList :param Version version: Version that contains the resource :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.usage.record.daily.DailyList :rtype: twilio.rest.api.v2010.account.usage.record.daily.DailyList """ super(DailyList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/Usage/Records/Daily.json'.format(**self._solution) def stream(self, category=values.unset, start_date=values.unset, end_date=values.unset, limit=None, page_size=None): """ Streams DailyInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param DailyInstance.Category category: The category :param date start_date: The start_date :param date end_date: The end_date :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.usage.record.daily.DailyInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( category=category, start_date=start_date, end_date=end_date, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, category=values.unset, start_date=values.unset, end_date=values.unset, limit=None, page_size=None): """ Lists DailyInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param DailyInstance.Category category: The category :param date start_date: The start_date :param date end_date: The end_date :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.usage.record.daily.DailyInstance] """ return list(self.stream( category=category, start_date=start_date, end_date=end_date, limit=limit, page_size=page_size, )) def page(self, category=values.unset, start_date=values.unset, end_date=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of DailyInstance records from the API. Request is executed immediately :param DailyInstance.Category category: The category :param date start_date: The start_date :param date end_date: The end_date :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of DailyInstance :rtype: twilio.rest.api.v2010.account.usage.record.daily.DailyPage """ params = values.of({ 'Category': category, 'StartDate': serialize.iso8601_date(start_date), 'EndDate': serialize.iso8601_date(end_date), 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return DailyPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of DailyInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of DailyInstance :rtype: twilio.rest.api.v2010.account.usage.record.daily.DailyPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return DailyPage(self._version, response, self._solution) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class DailyPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the DailyPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.usage.record.daily.DailyPage :rtype: twilio.rest.api.v2010.account.usage.record.daily.DailyPage """ super(DailyPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of DailyInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.usage.record.daily.DailyInstance :rtype: twilio.rest.api.v2010.account.usage.record.daily.DailyInstance """ return DailyInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class DailyInstance(InstanceResource): """ """ class Category(object): ANSWERING_MACHINE_DETECTION = "answering-machine-detection" AUTHY_AUTHENTICATIONS = "authy-authentications" AUTHY_CALLS_OUTBOUND = "authy-calls-outbound" AUTHY_MONTHLY_FEES = "authy-monthly-fees" AUTHY_PHONE_INTELLIGENCE = "authy-phone-intelligence" AUTHY_PHONE_VERIFICATIONS = "authy-phone-verifications" AUTHY_SMS_OUTBOUND = "authy-sms-outbound" CALL_PROGESS_EVENTS = "call-progess-events" CALLERIDLOOKUPS = "calleridlookups" CALLS = "calls" CALLS_CLIENT = "calls-client" 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_OUTBOUND = "calls-outbound" CALLS_RECORDINGS = "calls-recordings" CALLS_SIP = "calls-sip" CALLS_SIP_INBOUND = "calls-sip-inbound" CALLS_SIP_OUTBOUND = "calls-sip-outbound" CARRIER_LOOKUPS = "carrier-lookups" CONVERSATIONS = "conversations" CONVERSATIONS_API_REQUESTS = "conversations-api-requests" CONVERSATIONS_CONVERSATION_EVENTS = "conversations-conversation-events" CONVERSATIONS_ENDPOINT_CONNECTIVITY = "conversations-endpoint-connectivity" CONVERSATIONS_EVENTS = "conversations-events" CONVERSATIONS_PARTICIPANT_EVENTS = "conversations-participant-events" CONVERSATIONS_PARTICIPANTS = "conversations-participants" CPS = "cps" GROUP_ROOMS_MEDIA_DOWNLOADED = "group-rooms-media-downloaded" GROUP_ROOMS_MEDIA_RECORDED = "group-rooms-media-recorded" GROUP_ROOMS_MEDIA_ROUTED = "group-rooms-media-routed" GROUP_ROOMS_MEDIA_STORED = "group-rooms-media-stored" GROUP_ROOMS_PARTICIPANT_MINUTES = "group-rooms-participant-minutes" GROUP_ROOMS_RECORDED_MINUTES = "group-rooms-recorded-minutes" 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" LOOKUPS = "lookups" MARKETPLACE = "marketplace" MARKETPLACE_ALGORITHMIA_NAMED_ENTITY_RECOGNITION = "marketplace-algorithmia-named-entity-recognition" MARKETPLACE_DIGITAL_SEGMENT_BUSINESS_INFO = "marketplace-digital-segment-business-info" MARKETPLACE_GOOGLE_SPEECH_TO_TEXT = "marketplace-google-speech-to-text" MARKETPLACE_IBM_WATSON_MESSAGE_INSIGHTS = "marketplace-ibm-watson-message-insights" MARKETPLACE_IBM_WATSON_MESSAGE_SENTIMENT = "marketplace-ibm-watson-message-sentiment" MARKETPLACE_IBM_WATSON_RECORDING_ANALYSIS = "marketplace-ibm-watson-recording-analysis" MARKETPLACE_ICEHOOK_SYSTEMS_SCOUT = "marketplace-icehook-systems-scout" MARKETPLACE_INFOGROUP_DATAAXLE_BIZINFO = "marketplace-infogroup-dataaxle-bizinfo" MARKETPLACE_CADENCE_TRANSCRIPTION = "marketplace-cadence-transcription" MARKETPLACE_CADENCE_TRANSLATION = "marketplace-cadence-translation" MARKETPLACE_CAPIO_SPEECH_TO_TEXT = "marketplace-capio-speech-to-text" MARKETPLACE_FACEBOOK_OFFLINE_CONVERSIONS = "marketplace-facebook-offline-conversions" MARKETPLACE_KEEN_IO_CONTACT_CENTER_ANALYTICS = "marketplace-keen-io-contact-center-analytics" MARKETPLACE_MARCHEX_CLEANCALL = "marketplace-marchex-cleancall" MARKETPLACE_MARCHEX_SENTIMENT_ANALYSIS_FOR_SMS = "marketplace-marchex-sentiment-analysis-for-sms" MARKETPLACE_MARKETPLACE_NEXTCALLER_SOCIAL_ID = "marketplace-marketplace-nextcaller-social-id" MARKETPLACE_MOBILE_COMMONS_OPT_OUT_CLASSIFIER = "marketplace-mobile-commons-opt-out-classifier" MARKETPLACE_NEXIWAVE_VOICEMAIL_TO_TEXT = "marketplace-nexiwave-voicemail-to-text" MARKETPLACE_NEXTCALLER_ADVANCED_CALLER_IDENTIFICATION = "marketplace-nextcaller-advanced-caller-identification" MARKETPLACE_NOMOROBO_SPAM_SCORE = "marketplace-nomorobo-spam-score" MARKETPLACE_PAYFONE_TCPA_COMPLIANCE = "marketplace-payfone-tcpa-compliance" MARKETPLACE_TELO_OPENCNAM = "marketplace-telo-opencnam" MARKETPLACE_TRUECNAM_TRUE_SPAM = "marketplace-truecnam-true-spam" MARKETPLACE_TWILIO_CALLER_NAME_LOOKUP_US = "marketplace-twilio-caller-name-lookup-us" MARKETPLACE_TWILIO_CARRIER_INFORMATION_LOOKUP = "marketplace-twilio-carrier-information-lookup" MARKETPLACE_VOICEBASE_PCI = "marketplace-voicebase-pci" MARKETPLACE_VOICEBASE_TRANSCRIPTION = "marketplace-voicebase-transcription" MARKETPLACE_WHITEPAGES_PRO_CALLER_IDENTIFICATION = "marketplace-whitepages-pro-caller-identification" MARKETPLACE_WHITEPAGES_PRO_PHONE_INTELLIGENCE = "marketplace-whitepages-pro-phone-intelligence" MARKETPLACE_WHITEPAGES_PRO_PHONE_REPUTATION = "marketplace-whitepages-pro-phone-reputation" MARKETPLACE_WOLFRAM_SHORT_ANSWER = "marketplace-wolfram-short-answer" MARKETPLACE_WOLFARM_SPOKEN_RESULTS = "marketplace-wolfarm-spoken-results" MARKETPLACE_DEEPGRAM_PHRASE_DETECTOR = "marketplace-deepgram-phrase-detector" MARKETPLACE_CONVRIZA_ABABA = "marketplace-convriza-ababa" MARKETPLACE_IBM_WATSON_TONE_ANALYZER = "marketplace-ibm-watson-tone-analyzer" MARKETPLACE_REMEETING_AUTOMATIC_SPEECH_RECOGNITION = "marketplace-remeeting-automatic-speech-recognition" MARKETPLACE_TCPA_DEFENSE_SOLUTIONS_BLACKLIST_FEED = "marketplace-tcpa-defense-solutions-blacklist-feed" MARKETPLACE_VOICEBASE_TRANSCRIPTION_CUSTOM_VOCABULARY = "marketplace-voicebase-transcription-custom-vocabulary" MARKETPLACE_YTICA_CONTACT_CENTER_REPORTING_ANALYTICS = "marketplace-ytica-contact-center-reporting-analytics" MEDIASTORAGE = "mediastorage" MMS = "mms" MMS_INBOUND = "mms-inbound" MMS_INBOUND_LONGCODE = "mms-inbound-longcode" MMS_INBOUND_SHORTCODE = "mms-inbound-shortcode" MMS_OUTBOUND = "mms-outbound" MMS_OUTBOUND_LONGCODE = "mms-outbound-longcode" MMS_OUTBOUND_SHORTCODE = "mms-outbound-shortcode" MONITOR_READS = "monitor-reads" MONITOR_STORAGE = "monitor-storage" MONITOR_WRITES = "monitor-writes" NOTIFY = "notify" NOTIFY_ACTIONS_ATTEMPTS = "notify-actions-attempts" NOTIFY_CHANNELS = "notify-channels" NUMBER_FORMAT_LOOKUPS = "number-format-lookups" PCHAT = "pchat" PCHAT_ACTIONS = "pchat-actions" PCHAT_APS = "pchat-aps" PCHAT_NOTIFICATIONS = "pchat-notifications" PCHAT_READS = "pchat-reads" PCHAT_USERS = "pchat-users" PCHAT_MESSAGES = "pchat-messages" PEER_TO_PEER_ROOMS_PARTICIPANT_MINUTES = "peer-to-peer-rooms-participant-minutes" PFAX = "pfax" PFAX_MINUTES = "pfax-minutes" PFAX_MINUTES_INBOUND = "pfax-minutes-inbound" PFAX_MINUTES_OUTBOUND = "pfax-minutes-outbound" PFAX_PAGES = "pfax-pages" PHONENUMBERS = "phonenumbers" PHONENUMBERS_CPS = "phonenumbers-cps" PHONENUMBERS_EMERGENCY = "phonenumbers-emergency" PHONENUMBERS_LOCAL = "phonenumbers-local" PHONENUMBERS_MOBILE = "phonenumbers-mobile" PHONENUMBERS_SETUPS = "phonenumbers-setups" PHONENUMBERS_TOLLFREE = "phonenumbers-tollfree" PREMIUMSUPPORT = "premiumsupport" PV = "pv" PV_ROOM_PARTICIPANTS = "pv-room-participants" PV_ROOM_PARTICIPANTS_AU1 = "pv-room-participants-au1" PV_ROOM_PARTICIPANTS_BR1 = "pv-room-participants-br1" PV_ROOM_PARTICIPANTS_IE1 = "pv-room-participants-ie1" PV_ROOM_PARTICIPANTS_JP1 = "pv-room-participants-jp1" PV_ROOM_PARTICIPANTS_SG1 = "pv-room-participants-sg1" PV_ROOM_PARTICIPANTS_US1 = "pv-room-participants-us1" PV_ROOM_PARTICIPANTS_US2 = "pv-room-participants-us2" PV_ROOMS = "pv-rooms" PV_SIP_ENDPOINT_REGISTRATIONS = "pv-sip-endpoint-registrations" RECORDINGS = "recordings" RECORDINGSTORAGE = "recordingstorage" ROOMS_GROUP_MINUTES = "rooms-group-minutes" ROOMS_GROUP_BANDWIDTH = "rooms-group-bandwidth" 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_UK = "shortcodes-uk" SHORTCODES_VANITY = "shortcodes-vanity" SMS = "sms" SMS_INBOUND = "sms-inbound" SMS_INBOUND_LONGCODE = "sms-inbound-longcode" SMS_INBOUND_SHORTCODE = "sms-inbound-shortcode" 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_MESSAGES_FEATURES = "sms-messages-features" SPEECH_RECOGNITION = "speech-recognition" SYNC = "sync" SYNC_ACTIONS = "sync-actions" SYNC_ENDPOINT_HOURS = "sync-endpoint-hours" SYNC_ENDPOINT_HOURS_ABOVE_DAILY_CAP = "sync-endpoint-hours-above-daily-cap" TASKROUTER_TASKS = "taskrouter-tasks" TOTALPRICE = "totalprice" TRANSCRIPTIONS = "transcriptions" TRUNKING_CPS = "trunking-cps" TRUNKING_EMERGENCY_CALLS = "trunking-emergency-calls" TRUNKING_ORIGINATION = "trunking-origination" TRUNKING_ORIGINATION_LOCAL = "trunking-origination-local" TRUNKING_ORIGINATION_MOBILE = "trunking-origination-mobile" TRUNKING_ORIGINATION_TOLLFREE = "trunking-origination-tollfree" TRUNKING_RECORDINGS = "trunking-recordings" TRUNKING_SECURE = "trunking-secure" TRUNKING_TERMINATION = "trunking-termination" TURNMEGABYTES = "turnmegabytes" TURNMEGABYTES_AUSTRALIA = "turnmegabytes-australia" TURNMEGABYTES_BRASIL = "turnmegabytes-brasil" TURNMEGABYTES_INDIA = "turnmegabytes-india" TURNMEGABYTES_IRELAND = "turnmegabytes-ireland" TURNMEGABYTES_JAPAN = "turnmegabytes-japan" TURNMEGABYTES_SINGAPORE = "turnmegabytes-singapore" TURNMEGABYTES_USEAST = "turnmegabytes-useast" TURNMEGABYTES_USWEST = "turnmegabytes-uswest" TWILIO_INTERCONNECT = "twilio-interconnect" VOICE_INSIGHTS = "voice-insights" VOICE_INSIGHTS_AUDIO_TRACE = "voice-insights-audio-trace" VOICE_INSIGHTS_CARRIER_CALLS = "voice-insights-carrier-calls" WIRELESS = "wireless" 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_USAGE = "wireless-usage" WIRELESS_USAGE_COMMANDS = "wireless-usage-commands" WIRELESS_USAGE_COMMANDS_AFRICA = "wireless-usage-commands-africa" WIRELESS_USAGE_COMMANDS_ASIA = "wireless-usage-commands-asia" WIRELESS_USAGE_COMMANDS_CENTRALANDSOUTHAMERICA = "wireless-usage-commands-centralandsouthamerica" WIRELESS_USAGE_COMMANDS_EUROPE = "wireless-usage-commands-europe" WIRELESS_USAGE_COMMANDS_HOME = "wireless-usage-commands-home" WIRELESS_USAGE_COMMANDS_NORTHAMERICA = "wireless-usage-commands-northamerica" WIRELESS_USAGE_COMMANDS_OCEANIA = "wireless-usage-commands-oceania" WIRELESS_USAGE_COMMANDS_ROAMING = "wireless-usage-commands-roaming" WIRELESS_USAGE_DATA = "wireless-usage-data" WIRELESS_USAGE_DATA_AFRICA = "wireless-usage-data-africa" WIRELESS_USAGE_DATA_ASIA = "wireless-usage-data-asia" WIRELESS_USAGE_DATA_CENTRALANDSOUTHAMERICA = "wireless-usage-data-centralandsouthamerica" WIRELESS_USAGE_DATA_CUSTOM_ADDITIONALMB = "wireless-usage-data-custom-additionalmb" WIRELESS_USAGE_DATA_CUSTOM_FIRST5MB = "wireless-usage-data-custom-first5mb" WIRELESS_USAGE_DATA_DOMESTIC_ROAMING = "wireless-usage-data-domestic-roaming" WIRELESS_USAGE_DATA_EUROPE = "wireless-usage-data-europe" WIRELESS_USAGE_DATA_INDIVIDUAL_ADDITIONALGB = "wireless-usage-data-individual-additionalgb" WIRELESS_USAGE_DATA_INDIVIDUAL_FIRSTGB = "wireless-usage-data-individual-firstgb" WIRELESS_USAGE_DATA_INTERNATIONAL_ROAMING_CANADA = "wireless-usage-data-international-roaming-canada" WIRELESS_USAGE_DATA_INTERNATIONAL_ROAMING_INDIA = "wireless-usage-data-international-roaming-india" WIRELESS_USAGE_DATA_INTERNATIONAL_ROAMING_MEXICO = "wireless-usage-data-international-roaming-mexico" WIRELESS_USAGE_DATA_NORTHAMERICA = "wireless-usage-data-northamerica" WIRELESS_USAGE_DATA_OCEANIA = "wireless-usage-data-oceania" WIRELESS_USAGE_DATA_POOLED = "wireless-usage-data-pooled" WIRELESS_USAGE_DATA_POOLED_DOWNLINK = "wireless-usage-data-pooled-downlink" WIRELESS_USAGE_DATA_POOLED_UPLINK = "wireless-usage-data-pooled-uplink" WIRELESS_USAGE_MRC = "wireless-usage-mrc" WIRELESS_USAGE_MRC_CUSTOM = "wireless-usage-mrc-custom" WIRELESS_USAGE_MRC_INDIVIDUAL = "wireless-usage-mrc-individual" WIRELESS_USAGE_MRC_POOLED = "wireless-usage-mrc-pooled" WIRELESS_USAGE_MRC_SUSPENDED = "wireless-usage-mrc-suspended" WIRELESS_USAGE_VOICE = "wireless-usage-voice" WIRELESS_USAGE_SMS = "wireless-usage-sms" def __init__(self, version, payload, account_sid): """ Initialize the DailyInstance :returns: twilio.rest.api.v2010.account.usage.record.daily.DailyInstance :rtype: twilio.rest.api.v2010.account.usage.record.daily.DailyInstance """ super(DailyInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'api_version': payload['api_version'], 'category': payload['category'], 'count': payload['count'], 'count_unit': payload['count_unit'], 'description': payload['description'], 'end_date': deserialize.iso8601_date(payload['end_date']), 'price': deserialize.decimal(payload['price']), 'price_unit': payload['price_unit'], 'start_date': deserialize.iso8601_date(payload['start_date']), 'subresource_uris': payload['subresource_uris'], 'uri': payload['uri'], 'usage': payload['usage'], 'usage_unit': payload['usage_unit'], } # Context self._context = None self._solution = {'account_sid': account_sid,} @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def api_version(self): """ :returns: The api_version :rtype: unicode """ return self._properties['api_version'] @property def category(self): """ :returns: The category :rtype: DailyInstance.Category """ return self._properties['category'] @property def count(self): """ :returns: The count :rtype: unicode """ return self._properties['count'] @property def count_unit(self): """ :returns: The count_unit :rtype: unicode """ return self._properties['count_unit'] @property def description(self): """ :returns: The description :rtype: unicode """ return self._properties['description'] @property def end_date(self): """ :returns: The end_date :rtype: date """ return self._properties['end_date'] @property def price(self): """ :returns: The price :rtype: unicode """ return self._properties['price'] @property def price_unit(self): """ :returns: The price_unit :rtype: unicode """ return self._properties['price_unit'] @property def start_date(self): """ :returns: The start_date :rtype: date """ return self._properties['start_date'] @property def subresource_uris(self): """ :returns: The subresource_uris :rtype: unicode """ return self._properties['subresource_uris'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] @property def usage(self): """ :returns: The usage :rtype: unicode """ return self._properties['usage'] @property def usage_unit(self): """ :returns: The usage_unit :rtype: unicode """ return self._properties['usage_unit'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/api/v2010/account/usage/record/last_month.py000066400000000000000000000610501317472742600267410ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class LastMonthList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the LastMonthList :param Version version: Version that contains the resource :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.usage.record.last_month.LastMonthList :rtype: twilio.rest.api.v2010.account.usage.record.last_month.LastMonthList """ super(LastMonthList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/Usage/Records/LastMonth.json'.format(**self._solution) def stream(self, category=values.unset, start_date=values.unset, end_date=values.unset, limit=None, page_size=None): """ Streams LastMonthInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param LastMonthInstance.Category category: The category :param date start_date: The start_date :param date end_date: The end_date :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.usage.record.last_month.LastMonthInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( category=category, start_date=start_date, end_date=end_date, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, category=values.unset, start_date=values.unset, end_date=values.unset, limit=None, page_size=None): """ Lists LastMonthInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param LastMonthInstance.Category category: The category :param date start_date: The start_date :param date end_date: The end_date :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.usage.record.last_month.LastMonthInstance] """ return list(self.stream( category=category, start_date=start_date, end_date=end_date, limit=limit, page_size=page_size, )) def page(self, category=values.unset, start_date=values.unset, end_date=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of LastMonthInstance records from the API. Request is executed immediately :param LastMonthInstance.Category category: The category :param date start_date: The start_date :param date end_date: The end_date :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of LastMonthInstance :rtype: twilio.rest.api.v2010.account.usage.record.last_month.LastMonthPage """ params = values.of({ 'Category': category, 'StartDate': serialize.iso8601_date(start_date), 'EndDate': serialize.iso8601_date(end_date), 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return LastMonthPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of LastMonthInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of LastMonthInstance :rtype: twilio.rest.api.v2010.account.usage.record.last_month.LastMonthPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return LastMonthPage(self._version, response, self._solution) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class LastMonthPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the LastMonthPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.usage.record.last_month.LastMonthPage :rtype: twilio.rest.api.v2010.account.usage.record.last_month.LastMonthPage """ super(LastMonthPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of LastMonthInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.usage.record.last_month.LastMonthInstance :rtype: twilio.rest.api.v2010.account.usage.record.last_month.LastMonthInstance """ return LastMonthInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class LastMonthInstance(InstanceResource): """ """ class Category(object): ANSWERING_MACHINE_DETECTION = "answering-machine-detection" AUTHY_AUTHENTICATIONS = "authy-authentications" AUTHY_CALLS_OUTBOUND = "authy-calls-outbound" AUTHY_MONTHLY_FEES = "authy-monthly-fees" AUTHY_PHONE_INTELLIGENCE = "authy-phone-intelligence" AUTHY_PHONE_VERIFICATIONS = "authy-phone-verifications" AUTHY_SMS_OUTBOUND = "authy-sms-outbound" CALL_PROGESS_EVENTS = "call-progess-events" CALLERIDLOOKUPS = "calleridlookups" CALLS = "calls" CALLS_CLIENT = "calls-client" 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_OUTBOUND = "calls-outbound" CALLS_RECORDINGS = "calls-recordings" CALLS_SIP = "calls-sip" CALLS_SIP_INBOUND = "calls-sip-inbound" CALLS_SIP_OUTBOUND = "calls-sip-outbound" CARRIER_LOOKUPS = "carrier-lookups" CONVERSATIONS = "conversations" CONVERSATIONS_API_REQUESTS = "conversations-api-requests" CONVERSATIONS_CONVERSATION_EVENTS = "conversations-conversation-events" CONVERSATIONS_ENDPOINT_CONNECTIVITY = "conversations-endpoint-connectivity" CONVERSATIONS_EVENTS = "conversations-events" CONVERSATIONS_PARTICIPANT_EVENTS = "conversations-participant-events" CONVERSATIONS_PARTICIPANTS = "conversations-participants" CPS = "cps" GROUP_ROOMS_MEDIA_DOWNLOADED = "group-rooms-media-downloaded" GROUP_ROOMS_MEDIA_RECORDED = "group-rooms-media-recorded" GROUP_ROOMS_MEDIA_ROUTED = "group-rooms-media-routed" GROUP_ROOMS_MEDIA_STORED = "group-rooms-media-stored" GROUP_ROOMS_PARTICIPANT_MINUTES = "group-rooms-participant-minutes" GROUP_ROOMS_RECORDED_MINUTES = "group-rooms-recorded-minutes" 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" LOOKUPS = "lookups" MARKETPLACE = "marketplace" MARKETPLACE_ALGORITHMIA_NAMED_ENTITY_RECOGNITION = "marketplace-algorithmia-named-entity-recognition" MARKETPLACE_DIGITAL_SEGMENT_BUSINESS_INFO = "marketplace-digital-segment-business-info" MARKETPLACE_GOOGLE_SPEECH_TO_TEXT = "marketplace-google-speech-to-text" MARKETPLACE_IBM_WATSON_MESSAGE_INSIGHTS = "marketplace-ibm-watson-message-insights" MARKETPLACE_IBM_WATSON_MESSAGE_SENTIMENT = "marketplace-ibm-watson-message-sentiment" MARKETPLACE_IBM_WATSON_RECORDING_ANALYSIS = "marketplace-ibm-watson-recording-analysis" MARKETPLACE_ICEHOOK_SYSTEMS_SCOUT = "marketplace-icehook-systems-scout" MARKETPLACE_INFOGROUP_DATAAXLE_BIZINFO = "marketplace-infogroup-dataaxle-bizinfo" MARKETPLACE_CADENCE_TRANSCRIPTION = "marketplace-cadence-transcription" MARKETPLACE_CADENCE_TRANSLATION = "marketplace-cadence-translation" MARKETPLACE_CAPIO_SPEECH_TO_TEXT = "marketplace-capio-speech-to-text" MARKETPLACE_FACEBOOK_OFFLINE_CONVERSIONS = "marketplace-facebook-offline-conversions" MARKETPLACE_KEEN_IO_CONTACT_CENTER_ANALYTICS = "marketplace-keen-io-contact-center-analytics" MARKETPLACE_MARCHEX_CLEANCALL = "marketplace-marchex-cleancall" MARKETPLACE_MARCHEX_SENTIMENT_ANALYSIS_FOR_SMS = "marketplace-marchex-sentiment-analysis-for-sms" MARKETPLACE_MARKETPLACE_NEXTCALLER_SOCIAL_ID = "marketplace-marketplace-nextcaller-social-id" MARKETPLACE_MOBILE_COMMONS_OPT_OUT_CLASSIFIER = "marketplace-mobile-commons-opt-out-classifier" MARKETPLACE_NEXIWAVE_VOICEMAIL_TO_TEXT = "marketplace-nexiwave-voicemail-to-text" MARKETPLACE_NEXTCALLER_ADVANCED_CALLER_IDENTIFICATION = "marketplace-nextcaller-advanced-caller-identification" MARKETPLACE_NOMOROBO_SPAM_SCORE = "marketplace-nomorobo-spam-score" MARKETPLACE_PAYFONE_TCPA_COMPLIANCE = "marketplace-payfone-tcpa-compliance" MARKETPLACE_TELO_OPENCNAM = "marketplace-telo-opencnam" MARKETPLACE_TRUECNAM_TRUE_SPAM = "marketplace-truecnam-true-spam" MARKETPLACE_TWILIO_CALLER_NAME_LOOKUP_US = "marketplace-twilio-caller-name-lookup-us" MARKETPLACE_TWILIO_CARRIER_INFORMATION_LOOKUP = "marketplace-twilio-carrier-information-lookup" MARKETPLACE_VOICEBASE_PCI = "marketplace-voicebase-pci" MARKETPLACE_VOICEBASE_TRANSCRIPTION = "marketplace-voicebase-transcription" MARKETPLACE_WHITEPAGES_PRO_CALLER_IDENTIFICATION = "marketplace-whitepages-pro-caller-identification" MARKETPLACE_WHITEPAGES_PRO_PHONE_INTELLIGENCE = "marketplace-whitepages-pro-phone-intelligence" MARKETPLACE_WHITEPAGES_PRO_PHONE_REPUTATION = "marketplace-whitepages-pro-phone-reputation" MARKETPLACE_WOLFRAM_SHORT_ANSWER = "marketplace-wolfram-short-answer" MARKETPLACE_WOLFARM_SPOKEN_RESULTS = "marketplace-wolfarm-spoken-results" MARKETPLACE_DEEPGRAM_PHRASE_DETECTOR = "marketplace-deepgram-phrase-detector" MARKETPLACE_CONVRIZA_ABABA = "marketplace-convriza-ababa" MARKETPLACE_IBM_WATSON_TONE_ANALYZER = "marketplace-ibm-watson-tone-analyzer" MARKETPLACE_REMEETING_AUTOMATIC_SPEECH_RECOGNITION = "marketplace-remeeting-automatic-speech-recognition" MARKETPLACE_TCPA_DEFENSE_SOLUTIONS_BLACKLIST_FEED = "marketplace-tcpa-defense-solutions-blacklist-feed" MARKETPLACE_VOICEBASE_TRANSCRIPTION_CUSTOM_VOCABULARY = "marketplace-voicebase-transcription-custom-vocabulary" MARKETPLACE_YTICA_CONTACT_CENTER_REPORTING_ANALYTICS = "marketplace-ytica-contact-center-reporting-analytics" MEDIASTORAGE = "mediastorage" MMS = "mms" MMS_INBOUND = "mms-inbound" MMS_INBOUND_LONGCODE = "mms-inbound-longcode" MMS_INBOUND_SHORTCODE = "mms-inbound-shortcode" MMS_OUTBOUND = "mms-outbound" MMS_OUTBOUND_LONGCODE = "mms-outbound-longcode" MMS_OUTBOUND_SHORTCODE = "mms-outbound-shortcode" MONITOR_READS = "monitor-reads" MONITOR_STORAGE = "monitor-storage" MONITOR_WRITES = "monitor-writes" NOTIFY = "notify" NOTIFY_ACTIONS_ATTEMPTS = "notify-actions-attempts" NOTIFY_CHANNELS = "notify-channels" NUMBER_FORMAT_LOOKUPS = "number-format-lookups" PCHAT = "pchat" PCHAT_ACTIONS = "pchat-actions" PCHAT_APS = "pchat-aps" PCHAT_NOTIFICATIONS = "pchat-notifications" PCHAT_READS = "pchat-reads" PCHAT_USERS = "pchat-users" PCHAT_MESSAGES = "pchat-messages" PEER_TO_PEER_ROOMS_PARTICIPANT_MINUTES = "peer-to-peer-rooms-participant-minutes" PFAX = "pfax" PFAX_MINUTES = "pfax-minutes" PFAX_MINUTES_INBOUND = "pfax-minutes-inbound" PFAX_MINUTES_OUTBOUND = "pfax-minutes-outbound" PFAX_PAGES = "pfax-pages" PHONENUMBERS = "phonenumbers" PHONENUMBERS_CPS = "phonenumbers-cps" PHONENUMBERS_EMERGENCY = "phonenumbers-emergency" PHONENUMBERS_LOCAL = "phonenumbers-local" PHONENUMBERS_MOBILE = "phonenumbers-mobile" PHONENUMBERS_SETUPS = "phonenumbers-setups" PHONENUMBERS_TOLLFREE = "phonenumbers-tollfree" PREMIUMSUPPORT = "premiumsupport" PV = "pv" PV_ROOM_PARTICIPANTS = "pv-room-participants" PV_ROOM_PARTICIPANTS_AU1 = "pv-room-participants-au1" PV_ROOM_PARTICIPANTS_BR1 = "pv-room-participants-br1" PV_ROOM_PARTICIPANTS_IE1 = "pv-room-participants-ie1" PV_ROOM_PARTICIPANTS_JP1 = "pv-room-participants-jp1" PV_ROOM_PARTICIPANTS_SG1 = "pv-room-participants-sg1" PV_ROOM_PARTICIPANTS_US1 = "pv-room-participants-us1" PV_ROOM_PARTICIPANTS_US2 = "pv-room-participants-us2" PV_ROOMS = "pv-rooms" PV_SIP_ENDPOINT_REGISTRATIONS = "pv-sip-endpoint-registrations" RECORDINGS = "recordings" RECORDINGSTORAGE = "recordingstorage" ROOMS_GROUP_MINUTES = "rooms-group-minutes" ROOMS_GROUP_BANDWIDTH = "rooms-group-bandwidth" 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_UK = "shortcodes-uk" SHORTCODES_VANITY = "shortcodes-vanity" SMS = "sms" SMS_INBOUND = "sms-inbound" SMS_INBOUND_LONGCODE = "sms-inbound-longcode" SMS_INBOUND_SHORTCODE = "sms-inbound-shortcode" 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_MESSAGES_FEATURES = "sms-messages-features" SPEECH_RECOGNITION = "speech-recognition" SYNC = "sync" SYNC_ACTIONS = "sync-actions" SYNC_ENDPOINT_HOURS = "sync-endpoint-hours" SYNC_ENDPOINT_HOURS_ABOVE_DAILY_CAP = "sync-endpoint-hours-above-daily-cap" TASKROUTER_TASKS = "taskrouter-tasks" TOTALPRICE = "totalprice" TRANSCRIPTIONS = "transcriptions" TRUNKING_CPS = "trunking-cps" TRUNKING_EMERGENCY_CALLS = "trunking-emergency-calls" TRUNKING_ORIGINATION = "trunking-origination" TRUNKING_ORIGINATION_LOCAL = "trunking-origination-local" TRUNKING_ORIGINATION_MOBILE = "trunking-origination-mobile" TRUNKING_ORIGINATION_TOLLFREE = "trunking-origination-tollfree" TRUNKING_RECORDINGS = "trunking-recordings" TRUNKING_SECURE = "trunking-secure" TRUNKING_TERMINATION = "trunking-termination" TURNMEGABYTES = "turnmegabytes" TURNMEGABYTES_AUSTRALIA = "turnmegabytes-australia" TURNMEGABYTES_BRASIL = "turnmegabytes-brasil" TURNMEGABYTES_INDIA = "turnmegabytes-india" TURNMEGABYTES_IRELAND = "turnmegabytes-ireland" TURNMEGABYTES_JAPAN = "turnmegabytes-japan" TURNMEGABYTES_SINGAPORE = "turnmegabytes-singapore" TURNMEGABYTES_USEAST = "turnmegabytes-useast" TURNMEGABYTES_USWEST = "turnmegabytes-uswest" TWILIO_INTERCONNECT = "twilio-interconnect" VOICE_INSIGHTS = "voice-insights" VOICE_INSIGHTS_AUDIO_TRACE = "voice-insights-audio-trace" VOICE_INSIGHTS_CARRIER_CALLS = "voice-insights-carrier-calls" WIRELESS = "wireless" 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_USAGE = "wireless-usage" WIRELESS_USAGE_COMMANDS = "wireless-usage-commands" WIRELESS_USAGE_COMMANDS_AFRICA = "wireless-usage-commands-africa" WIRELESS_USAGE_COMMANDS_ASIA = "wireless-usage-commands-asia" WIRELESS_USAGE_COMMANDS_CENTRALANDSOUTHAMERICA = "wireless-usage-commands-centralandsouthamerica" WIRELESS_USAGE_COMMANDS_EUROPE = "wireless-usage-commands-europe" WIRELESS_USAGE_COMMANDS_HOME = "wireless-usage-commands-home" WIRELESS_USAGE_COMMANDS_NORTHAMERICA = "wireless-usage-commands-northamerica" WIRELESS_USAGE_COMMANDS_OCEANIA = "wireless-usage-commands-oceania" WIRELESS_USAGE_COMMANDS_ROAMING = "wireless-usage-commands-roaming" WIRELESS_USAGE_DATA = "wireless-usage-data" WIRELESS_USAGE_DATA_AFRICA = "wireless-usage-data-africa" WIRELESS_USAGE_DATA_ASIA = "wireless-usage-data-asia" WIRELESS_USAGE_DATA_CENTRALANDSOUTHAMERICA = "wireless-usage-data-centralandsouthamerica" WIRELESS_USAGE_DATA_CUSTOM_ADDITIONALMB = "wireless-usage-data-custom-additionalmb" WIRELESS_USAGE_DATA_CUSTOM_FIRST5MB = "wireless-usage-data-custom-first5mb" WIRELESS_USAGE_DATA_DOMESTIC_ROAMING = "wireless-usage-data-domestic-roaming" WIRELESS_USAGE_DATA_EUROPE = "wireless-usage-data-europe" WIRELESS_USAGE_DATA_INDIVIDUAL_ADDITIONALGB = "wireless-usage-data-individual-additionalgb" WIRELESS_USAGE_DATA_INDIVIDUAL_FIRSTGB = "wireless-usage-data-individual-firstgb" WIRELESS_USAGE_DATA_INTERNATIONAL_ROAMING_CANADA = "wireless-usage-data-international-roaming-canada" WIRELESS_USAGE_DATA_INTERNATIONAL_ROAMING_INDIA = "wireless-usage-data-international-roaming-india" WIRELESS_USAGE_DATA_INTERNATIONAL_ROAMING_MEXICO = "wireless-usage-data-international-roaming-mexico" WIRELESS_USAGE_DATA_NORTHAMERICA = "wireless-usage-data-northamerica" WIRELESS_USAGE_DATA_OCEANIA = "wireless-usage-data-oceania" WIRELESS_USAGE_DATA_POOLED = "wireless-usage-data-pooled" WIRELESS_USAGE_DATA_POOLED_DOWNLINK = "wireless-usage-data-pooled-downlink" WIRELESS_USAGE_DATA_POOLED_UPLINK = "wireless-usage-data-pooled-uplink" WIRELESS_USAGE_MRC = "wireless-usage-mrc" WIRELESS_USAGE_MRC_CUSTOM = "wireless-usage-mrc-custom" WIRELESS_USAGE_MRC_INDIVIDUAL = "wireless-usage-mrc-individual" WIRELESS_USAGE_MRC_POOLED = "wireless-usage-mrc-pooled" WIRELESS_USAGE_MRC_SUSPENDED = "wireless-usage-mrc-suspended" WIRELESS_USAGE_VOICE = "wireless-usage-voice" WIRELESS_USAGE_SMS = "wireless-usage-sms" def __init__(self, version, payload, account_sid): """ Initialize the LastMonthInstance :returns: twilio.rest.api.v2010.account.usage.record.last_month.LastMonthInstance :rtype: twilio.rest.api.v2010.account.usage.record.last_month.LastMonthInstance """ super(LastMonthInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'api_version': payload['api_version'], 'category': payload['category'], 'count': payload['count'], 'count_unit': payload['count_unit'], 'description': payload['description'], 'end_date': deserialize.iso8601_date(payload['end_date']), 'price': deserialize.decimal(payload['price']), 'price_unit': payload['price_unit'], 'start_date': deserialize.iso8601_date(payload['start_date']), 'subresource_uris': payload['subresource_uris'], 'uri': payload['uri'], 'usage': payload['usage'], 'usage_unit': payload['usage_unit'], } # Context self._context = None self._solution = {'account_sid': account_sid,} @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def api_version(self): """ :returns: The api_version :rtype: unicode """ return self._properties['api_version'] @property def category(self): """ :returns: The category :rtype: LastMonthInstance.Category """ return self._properties['category'] @property def count(self): """ :returns: The count :rtype: unicode """ return self._properties['count'] @property def count_unit(self): """ :returns: The count_unit :rtype: unicode """ return self._properties['count_unit'] @property def description(self): """ :returns: The description :rtype: unicode """ return self._properties['description'] @property def end_date(self): """ :returns: The end_date :rtype: date """ return self._properties['end_date'] @property def price(self): """ :returns: The price :rtype: unicode """ return self._properties['price'] @property def price_unit(self): """ :returns: The price_unit :rtype: unicode """ return self._properties['price_unit'] @property def start_date(self): """ :returns: The start_date :rtype: date """ return self._properties['start_date'] @property def subresource_uris(self): """ :returns: The subresource_uris :rtype: unicode """ return self._properties['subresource_uris'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] @property def usage(self): """ :returns: The usage :rtype: unicode """ return self._properties['usage'] @property def usage_unit(self): """ :returns: The usage_unit :rtype: unicode """ return self._properties['usage_unit'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/api/v2010/account/usage/record/monthly.py000066400000000000000000000606661317472742600262770ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class MonthlyList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the MonthlyList :param Version version: Version that contains the resource :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.usage.record.monthly.MonthlyList :rtype: twilio.rest.api.v2010.account.usage.record.monthly.MonthlyList """ super(MonthlyList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/Usage/Records/Monthly.json'.format(**self._solution) def stream(self, category=values.unset, start_date=values.unset, end_date=values.unset, limit=None, page_size=None): """ Streams MonthlyInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param MonthlyInstance.Category category: The category :param date start_date: The start_date :param date end_date: The end_date :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.usage.record.monthly.MonthlyInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( category=category, start_date=start_date, end_date=end_date, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, category=values.unset, start_date=values.unset, end_date=values.unset, limit=None, page_size=None): """ Lists MonthlyInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param MonthlyInstance.Category category: The category :param date start_date: The start_date :param date end_date: The end_date :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.usage.record.monthly.MonthlyInstance] """ return list(self.stream( category=category, start_date=start_date, end_date=end_date, limit=limit, page_size=page_size, )) def page(self, category=values.unset, start_date=values.unset, end_date=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of MonthlyInstance records from the API. Request is executed immediately :param MonthlyInstance.Category category: The category :param date start_date: The start_date :param date end_date: The end_date :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of MonthlyInstance :rtype: twilio.rest.api.v2010.account.usage.record.monthly.MonthlyPage """ params = values.of({ 'Category': category, 'StartDate': serialize.iso8601_date(start_date), 'EndDate': serialize.iso8601_date(end_date), 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return MonthlyPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of MonthlyInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of MonthlyInstance :rtype: twilio.rest.api.v2010.account.usage.record.monthly.MonthlyPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return MonthlyPage(self._version, response, self._solution) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class MonthlyPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the MonthlyPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.usage.record.monthly.MonthlyPage :rtype: twilio.rest.api.v2010.account.usage.record.monthly.MonthlyPage """ super(MonthlyPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of MonthlyInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.usage.record.monthly.MonthlyInstance :rtype: twilio.rest.api.v2010.account.usage.record.monthly.MonthlyInstance """ return MonthlyInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class MonthlyInstance(InstanceResource): """ """ class Category(object): ANSWERING_MACHINE_DETECTION = "answering-machine-detection" AUTHY_AUTHENTICATIONS = "authy-authentications" AUTHY_CALLS_OUTBOUND = "authy-calls-outbound" AUTHY_MONTHLY_FEES = "authy-monthly-fees" AUTHY_PHONE_INTELLIGENCE = "authy-phone-intelligence" AUTHY_PHONE_VERIFICATIONS = "authy-phone-verifications" AUTHY_SMS_OUTBOUND = "authy-sms-outbound" CALL_PROGESS_EVENTS = "call-progess-events" CALLERIDLOOKUPS = "calleridlookups" CALLS = "calls" CALLS_CLIENT = "calls-client" 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_OUTBOUND = "calls-outbound" CALLS_RECORDINGS = "calls-recordings" CALLS_SIP = "calls-sip" CALLS_SIP_INBOUND = "calls-sip-inbound" CALLS_SIP_OUTBOUND = "calls-sip-outbound" CARRIER_LOOKUPS = "carrier-lookups" CONVERSATIONS = "conversations" CONVERSATIONS_API_REQUESTS = "conversations-api-requests" CONVERSATIONS_CONVERSATION_EVENTS = "conversations-conversation-events" CONVERSATIONS_ENDPOINT_CONNECTIVITY = "conversations-endpoint-connectivity" CONVERSATIONS_EVENTS = "conversations-events" CONVERSATIONS_PARTICIPANT_EVENTS = "conversations-participant-events" CONVERSATIONS_PARTICIPANTS = "conversations-participants" CPS = "cps" GROUP_ROOMS_MEDIA_DOWNLOADED = "group-rooms-media-downloaded" GROUP_ROOMS_MEDIA_RECORDED = "group-rooms-media-recorded" GROUP_ROOMS_MEDIA_ROUTED = "group-rooms-media-routed" GROUP_ROOMS_MEDIA_STORED = "group-rooms-media-stored" GROUP_ROOMS_PARTICIPANT_MINUTES = "group-rooms-participant-minutes" GROUP_ROOMS_RECORDED_MINUTES = "group-rooms-recorded-minutes" 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" LOOKUPS = "lookups" MARKETPLACE = "marketplace" MARKETPLACE_ALGORITHMIA_NAMED_ENTITY_RECOGNITION = "marketplace-algorithmia-named-entity-recognition" MARKETPLACE_DIGITAL_SEGMENT_BUSINESS_INFO = "marketplace-digital-segment-business-info" MARKETPLACE_GOOGLE_SPEECH_TO_TEXT = "marketplace-google-speech-to-text" MARKETPLACE_IBM_WATSON_MESSAGE_INSIGHTS = "marketplace-ibm-watson-message-insights" MARKETPLACE_IBM_WATSON_MESSAGE_SENTIMENT = "marketplace-ibm-watson-message-sentiment" MARKETPLACE_IBM_WATSON_RECORDING_ANALYSIS = "marketplace-ibm-watson-recording-analysis" MARKETPLACE_ICEHOOK_SYSTEMS_SCOUT = "marketplace-icehook-systems-scout" MARKETPLACE_INFOGROUP_DATAAXLE_BIZINFO = "marketplace-infogroup-dataaxle-bizinfo" MARKETPLACE_CADENCE_TRANSCRIPTION = "marketplace-cadence-transcription" MARKETPLACE_CADENCE_TRANSLATION = "marketplace-cadence-translation" MARKETPLACE_CAPIO_SPEECH_TO_TEXT = "marketplace-capio-speech-to-text" MARKETPLACE_FACEBOOK_OFFLINE_CONVERSIONS = "marketplace-facebook-offline-conversions" MARKETPLACE_KEEN_IO_CONTACT_CENTER_ANALYTICS = "marketplace-keen-io-contact-center-analytics" MARKETPLACE_MARCHEX_CLEANCALL = "marketplace-marchex-cleancall" MARKETPLACE_MARCHEX_SENTIMENT_ANALYSIS_FOR_SMS = "marketplace-marchex-sentiment-analysis-for-sms" MARKETPLACE_MARKETPLACE_NEXTCALLER_SOCIAL_ID = "marketplace-marketplace-nextcaller-social-id" MARKETPLACE_MOBILE_COMMONS_OPT_OUT_CLASSIFIER = "marketplace-mobile-commons-opt-out-classifier" MARKETPLACE_NEXIWAVE_VOICEMAIL_TO_TEXT = "marketplace-nexiwave-voicemail-to-text" MARKETPLACE_NEXTCALLER_ADVANCED_CALLER_IDENTIFICATION = "marketplace-nextcaller-advanced-caller-identification" MARKETPLACE_NOMOROBO_SPAM_SCORE = "marketplace-nomorobo-spam-score" MARKETPLACE_PAYFONE_TCPA_COMPLIANCE = "marketplace-payfone-tcpa-compliance" MARKETPLACE_TELO_OPENCNAM = "marketplace-telo-opencnam" MARKETPLACE_TRUECNAM_TRUE_SPAM = "marketplace-truecnam-true-spam" MARKETPLACE_TWILIO_CALLER_NAME_LOOKUP_US = "marketplace-twilio-caller-name-lookup-us" MARKETPLACE_TWILIO_CARRIER_INFORMATION_LOOKUP = "marketplace-twilio-carrier-information-lookup" MARKETPLACE_VOICEBASE_PCI = "marketplace-voicebase-pci" MARKETPLACE_VOICEBASE_TRANSCRIPTION = "marketplace-voicebase-transcription" MARKETPLACE_WHITEPAGES_PRO_CALLER_IDENTIFICATION = "marketplace-whitepages-pro-caller-identification" MARKETPLACE_WHITEPAGES_PRO_PHONE_INTELLIGENCE = "marketplace-whitepages-pro-phone-intelligence" MARKETPLACE_WHITEPAGES_PRO_PHONE_REPUTATION = "marketplace-whitepages-pro-phone-reputation" MARKETPLACE_WOLFRAM_SHORT_ANSWER = "marketplace-wolfram-short-answer" MARKETPLACE_WOLFARM_SPOKEN_RESULTS = "marketplace-wolfarm-spoken-results" MARKETPLACE_DEEPGRAM_PHRASE_DETECTOR = "marketplace-deepgram-phrase-detector" MARKETPLACE_CONVRIZA_ABABA = "marketplace-convriza-ababa" MARKETPLACE_IBM_WATSON_TONE_ANALYZER = "marketplace-ibm-watson-tone-analyzer" MARKETPLACE_REMEETING_AUTOMATIC_SPEECH_RECOGNITION = "marketplace-remeeting-automatic-speech-recognition" MARKETPLACE_TCPA_DEFENSE_SOLUTIONS_BLACKLIST_FEED = "marketplace-tcpa-defense-solutions-blacklist-feed" MARKETPLACE_VOICEBASE_TRANSCRIPTION_CUSTOM_VOCABULARY = "marketplace-voicebase-transcription-custom-vocabulary" MARKETPLACE_YTICA_CONTACT_CENTER_REPORTING_ANALYTICS = "marketplace-ytica-contact-center-reporting-analytics" MEDIASTORAGE = "mediastorage" MMS = "mms" MMS_INBOUND = "mms-inbound" MMS_INBOUND_LONGCODE = "mms-inbound-longcode" MMS_INBOUND_SHORTCODE = "mms-inbound-shortcode" MMS_OUTBOUND = "mms-outbound" MMS_OUTBOUND_LONGCODE = "mms-outbound-longcode" MMS_OUTBOUND_SHORTCODE = "mms-outbound-shortcode" MONITOR_READS = "monitor-reads" MONITOR_STORAGE = "monitor-storage" MONITOR_WRITES = "monitor-writes" NOTIFY = "notify" NOTIFY_ACTIONS_ATTEMPTS = "notify-actions-attempts" NOTIFY_CHANNELS = "notify-channels" NUMBER_FORMAT_LOOKUPS = "number-format-lookups" PCHAT = "pchat" PCHAT_ACTIONS = "pchat-actions" PCHAT_APS = "pchat-aps" PCHAT_NOTIFICATIONS = "pchat-notifications" PCHAT_READS = "pchat-reads" PCHAT_USERS = "pchat-users" PCHAT_MESSAGES = "pchat-messages" PEER_TO_PEER_ROOMS_PARTICIPANT_MINUTES = "peer-to-peer-rooms-participant-minutes" PFAX = "pfax" PFAX_MINUTES = "pfax-minutes" PFAX_MINUTES_INBOUND = "pfax-minutes-inbound" PFAX_MINUTES_OUTBOUND = "pfax-minutes-outbound" PFAX_PAGES = "pfax-pages" PHONENUMBERS = "phonenumbers" PHONENUMBERS_CPS = "phonenumbers-cps" PHONENUMBERS_EMERGENCY = "phonenumbers-emergency" PHONENUMBERS_LOCAL = "phonenumbers-local" PHONENUMBERS_MOBILE = "phonenumbers-mobile" PHONENUMBERS_SETUPS = "phonenumbers-setups" PHONENUMBERS_TOLLFREE = "phonenumbers-tollfree" PREMIUMSUPPORT = "premiumsupport" PV = "pv" PV_ROOM_PARTICIPANTS = "pv-room-participants" PV_ROOM_PARTICIPANTS_AU1 = "pv-room-participants-au1" PV_ROOM_PARTICIPANTS_BR1 = "pv-room-participants-br1" PV_ROOM_PARTICIPANTS_IE1 = "pv-room-participants-ie1" PV_ROOM_PARTICIPANTS_JP1 = "pv-room-participants-jp1" PV_ROOM_PARTICIPANTS_SG1 = "pv-room-participants-sg1" PV_ROOM_PARTICIPANTS_US1 = "pv-room-participants-us1" PV_ROOM_PARTICIPANTS_US2 = "pv-room-participants-us2" PV_ROOMS = "pv-rooms" PV_SIP_ENDPOINT_REGISTRATIONS = "pv-sip-endpoint-registrations" RECORDINGS = "recordings" RECORDINGSTORAGE = "recordingstorage" ROOMS_GROUP_MINUTES = "rooms-group-minutes" ROOMS_GROUP_BANDWIDTH = "rooms-group-bandwidth" 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_UK = "shortcodes-uk" SHORTCODES_VANITY = "shortcodes-vanity" SMS = "sms" SMS_INBOUND = "sms-inbound" SMS_INBOUND_LONGCODE = "sms-inbound-longcode" SMS_INBOUND_SHORTCODE = "sms-inbound-shortcode" 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_MESSAGES_FEATURES = "sms-messages-features" SPEECH_RECOGNITION = "speech-recognition" SYNC = "sync" SYNC_ACTIONS = "sync-actions" SYNC_ENDPOINT_HOURS = "sync-endpoint-hours" SYNC_ENDPOINT_HOURS_ABOVE_DAILY_CAP = "sync-endpoint-hours-above-daily-cap" TASKROUTER_TASKS = "taskrouter-tasks" TOTALPRICE = "totalprice" TRANSCRIPTIONS = "transcriptions" TRUNKING_CPS = "trunking-cps" TRUNKING_EMERGENCY_CALLS = "trunking-emergency-calls" TRUNKING_ORIGINATION = "trunking-origination" TRUNKING_ORIGINATION_LOCAL = "trunking-origination-local" TRUNKING_ORIGINATION_MOBILE = "trunking-origination-mobile" TRUNKING_ORIGINATION_TOLLFREE = "trunking-origination-tollfree" TRUNKING_RECORDINGS = "trunking-recordings" TRUNKING_SECURE = "trunking-secure" TRUNKING_TERMINATION = "trunking-termination" TURNMEGABYTES = "turnmegabytes" TURNMEGABYTES_AUSTRALIA = "turnmegabytes-australia" TURNMEGABYTES_BRASIL = "turnmegabytes-brasil" TURNMEGABYTES_INDIA = "turnmegabytes-india" TURNMEGABYTES_IRELAND = "turnmegabytes-ireland" TURNMEGABYTES_JAPAN = "turnmegabytes-japan" TURNMEGABYTES_SINGAPORE = "turnmegabytes-singapore" TURNMEGABYTES_USEAST = "turnmegabytes-useast" TURNMEGABYTES_USWEST = "turnmegabytes-uswest" TWILIO_INTERCONNECT = "twilio-interconnect" VOICE_INSIGHTS = "voice-insights" VOICE_INSIGHTS_AUDIO_TRACE = "voice-insights-audio-trace" VOICE_INSIGHTS_CARRIER_CALLS = "voice-insights-carrier-calls" WIRELESS = "wireless" 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_USAGE = "wireless-usage" WIRELESS_USAGE_COMMANDS = "wireless-usage-commands" WIRELESS_USAGE_COMMANDS_AFRICA = "wireless-usage-commands-africa" WIRELESS_USAGE_COMMANDS_ASIA = "wireless-usage-commands-asia" WIRELESS_USAGE_COMMANDS_CENTRALANDSOUTHAMERICA = "wireless-usage-commands-centralandsouthamerica" WIRELESS_USAGE_COMMANDS_EUROPE = "wireless-usage-commands-europe" WIRELESS_USAGE_COMMANDS_HOME = "wireless-usage-commands-home" WIRELESS_USAGE_COMMANDS_NORTHAMERICA = "wireless-usage-commands-northamerica" WIRELESS_USAGE_COMMANDS_OCEANIA = "wireless-usage-commands-oceania" WIRELESS_USAGE_COMMANDS_ROAMING = "wireless-usage-commands-roaming" WIRELESS_USAGE_DATA = "wireless-usage-data" WIRELESS_USAGE_DATA_AFRICA = "wireless-usage-data-africa" WIRELESS_USAGE_DATA_ASIA = "wireless-usage-data-asia" WIRELESS_USAGE_DATA_CENTRALANDSOUTHAMERICA = "wireless-usage-data-centralandsouthamerica" WIRELESS_USAGE_DATA_CUSTOM_ADDITIONALMB = "wireless-usage-data-custom-additionalmb" WIRELESS_USAGE_DATA_CUSTOM_FIRST5MB = "wireless-usage-data-custom-first5mb" WIRELESS_USAGE_DATA_DOMESTIC_ROAMING = "wireless-usage-data-domestic-roaming" WIRELESS_USAGE_DATA_EUROPE = "wireless-usage-data-europe" WIRELESS_USAGE_DATA_INDIVIDUAL_ADDITIONALGB = "wireless-usage-data-individual-additionalgb" WIRELESS_USAGE_DATA_INDIVIDUAL_FIRSTGB = "wireless-usage-data-individual-firstgb" WIRELESS_USAGE_DATA_INTERNATIONAL_ROAMING_CANADA = "wireless-usage-data-international-roaming-canada" WIRELESS_USAGE_DATA_INTERNATIONAL_ROAMING_INDIA = "wireless-usage-data-international-roaming-india" WIRELESS_USAGE_DATA_INTERNATIONAL_ROAMING_MEXICO = "wireless-usage-data-international-roaming-mexico" WIRELESS_USAGE_DATA_NORTHAMERICA = "wireless-usage-data-northamerica" WIRELESS_USAGE_DATA_OCEANIA = "wireless-usage-data-oceania" WIRELESS_USAGE_DATA_POOLED = "wireless-usage-data-pooled" WIRELESS_USAGE_DATA_POOLED_DOWNLINK = "wireless-usage-data-pooled-downlink" WIRELESS_USAGE_DATA_POOLED_UPLINK = "wireless-usage-data-pooled-uplink" WIRELESS_USAGE_MRC = "wireless-usage-mrc" WIRELESS_USAGE_MRC_CUSTOM = "wireless-usage-mrc-custom" WIRELESS_USAGE_MRC_INDIVIDUAL = "wireless-usage-mrc-individual" WIRELESS_USAGE_MRC_POOLED = "wireless-usage-mrc-pooled" WIRELESS_USAGE_MRC_SUSPENDED = "wireless-usage-mrc-suspended" WIRELESS_USAGE_VOICE = "wireless-usage-voice" WIRELESS_USAGE_SMS = "wireless-usage-sms" def __init__(self, version, payload, account_sid): """ Initialize the MonthlyInstance :returns: twilio.rest.api.v2010.account.usage.record.monthly.MonthlyInstance :rtype: twilio.rest.api.v2010.account.usage.record.monthly.MonthlyInstance """ super(MonthlyInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'api_version': payload['api_version'], 'category': payload['category'], 'count': payload['count'], 'count_unit': payload['count_unit'], 'description': payload['description'], 'end_date': deserialize.iso8601_date(payload['end_date']), 'price': deserialize.decimal(payload['price']), 'price_unit': payload['price_unit'], 'start_date': deserialize.iso8601_date(payload['start_date']), 'subresource_uris': payload['subresource_uris'], 'uri': payload['uri'], 'usage': payload['usage'], 'usage_unit': payload['usage_unit'], } # Context self._context = None self._solution = {'account_sid': account_sid,} @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def api_version(self): """ :returns: The api_version :rtype: unicode """ return self._properties['api_version'] @property def category(self): """ :returns: The category :rtype: MonthlyInstance.Category """ return self._properties['category'] @property def count(self): """ :returns: The count :rtype: unicode """ return self._properties['count'] @property def count_unit(self): """ :returns: The count_unit :rtype: unicode """ return self._properties['count_unit'] @property def description(self): """ :returns: The description :rtype: unicode """ return self._properties['description'] @property def end_date(self): """ :returns: The end_date :rtype: date """ return self._properties['end_date'] @property def price(self): """ :returns: The price :rtype: unicode """ return self._properties['price'] @property def price_unit(self): """ :returns: The price_unit :rtype: unicode """ return self._properties['price_unit'] @property def start_date(self): """ :returns: The start_date :rtype: date """ return self._properties['start_date'] @property def subresource_uris(self): """ :returns: The subresource_uris :rtype: unicode """ return self._properties['subresource_uris'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] @property def usage(self): """ :returns: The usage :rtype: unicode """ return self._properties['usage'] @property def usage_unit(self): """ :returns: The usage_unit :rtype: unicode """ return self._properties['usage_unit'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/api/v2010/account/usage/record/this_month.py000066400000000000000000000610501317472742600267450ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class ThisMonthList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the ThisMonthList :param Version version: Version that contains the resource :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.usage.record.this_month.ThisMonthList :rtype: twilio.rest.api.v2010.account.usage.record.this_month.ThisMonthList """ super(ThisMonthList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/Usage/Records/ThisMonth.json'.format(**self._solution) def stream(self, category=values.unset, start_date=values.unset, end_date=values.unset, limit=None, page_size=None): """ Streams ThisMonthInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param ThisMonthInstance.Category category: The category :param date start_date: The start_date :param date end_date: The end_date :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.usage.record.this_month.ThisMonthInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( category=category, start_date=start_date, end_date=end_date, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, category=values.unset, start_date=values.unset, end_date=values.unset, limit=None, page_size=None): """ Lists ThisMonthInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param ThisMonthInstance.Category category: The category :param date start_date: The start_date :param date end_date: The end_date :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.usage.record.this_month.ThisMonthInstance] """ return list(self.stream( category=category, start_date=start_date, end_date=end_date, limit=limit, page_size=page_size, )) def page(self, category=values.unset, start_date=values.unset, end_date=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of ThisMonthInstance records from the API. Request is executed immediately :param ThisMonthInstance.Category category: The category :param date start_date: The start_date :param date end_date: The end_date :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of ThisMonthInstance :rtype: twilio.rest.api.v2010.account.usage.record.this_month.ThisMonthPage """ params = values.of({ 'Category': category, 'StartDate': serialize.iso8601_date(start_date), 'EndDate': serialize.iso8601_date(end_date), 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return ThisMonthPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of ThisMonthInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of ThisMonthInstance :rtype: twilio.rest.api.v2010.account.usage.record.this_month.ThisMonthPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return ThisMonthPage(self._version, response, self._solution) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ThisMonthPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the ThisMonthPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.usage.record.this_month.ThisMonthPage :rtype: twilio.rest.api.v2010.account.usage.record.this_month.ThisMonthPage """ super(ThisMonthPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of ThisMonthInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.usage.record.this_month.ThisMonthInstance :rtype: twilio.rest.api.v2010.account.usage.record.this_month.ThisMonthInstance """ return ThisMonthInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ThisMonthInstance(InstanceResource): """ """ class Category(object): ANSWERING_MACHINE_DETECTION = "answering-machine-detection" AUTHY_AUTHENTICATIONS = "authy-authentications" AUTHY_CALLS_OUTBOUND = "authy-calls-outbound" AUTHY_MONTHLY_FEES = "authy-monthly-fees" AUTHY_PHONE_INTELLIGENCE = "authy-phone-intelligence" AUTHY_PHONE_VERIFICATIONS = "authy-phone-verifications" AUTHY_SMS_OUTBOUND = "authy-sms-outbound" CALL_PROGESS_EVENTS = "call-progess-events" CALLERIDLOOKUPS = "calleridlookups" CALLS = "calls" CALLS_CLIENT = "calls-client" 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_OUTBOUND = "calls-outbound" CALLS_RECORDINGS = "calls-recordings" CALLS_SIP = "calls-sip" CALLS_SIP_INBOUND = "calls-sip-inbound" CALLS_SIP_OUTBOUND = "calls-sip-outbound" CARRIER_LOOKUPS = "carrier-lookups" CONVERSATIONS = "conversations" CONVERSATIONS_API_REQUESTS = "conversations-api-requests" CONVERSATIONS_CONVERSATION_EVENTS = "conversations-conversation-events" CONVERSATIONS_ENDPOINT_CONNECTIVITY = "conversations-endpoint-connectivity" CONVERSATIONS_EVENTS = "conversations-events" CONVERSATIONS_PARTICIPANT_EVENTS = "conversations-participant-events" CONVERSATIONS_PARTICIPANTS = "conversations-participants" CPS = "cps" GROUP_ROOMS_MEDIA_DOWNLOADED = "group-rooms-media-downloaded" GROUP_ROOMS_MEDIA_RECORDED = "group-rooms-media-recorded" GROUP_ROOMS_MEDIA_ROUTED = "group-rooms-media-routed" GROUP_ROOMS_MEDIA_STORED = "group-rooms-media-stored" GROUP_ROOMS_PARTICIPANT_MINUTES = "group-rooms-participant-minutes" GROUP_ROOMS_RECORDED_MINUTES = "group-rooms-recorded-minutes" 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" LOOKUPS = "lookups" MARKETPLACE = "marketplace" MARKETPLACE_ALGORITHMIA_NAMED_ENTITY_RECOGNITION = "marketplace-algorithmia-named-entity-recognition" MARKETPLACE_DIGITAL_SEGMENT_BUSINESS_INFO = "marketplace-digital-segment-business-info" MARKETPLACE_GOOGLE_SPEECH_TO_TEXT = "marketplace-google-speech-to-text" MARKETPLACE_IBM_WATSON_MESSAGE_INSIGHTS = "marketplace-ibm-watson-message-insights" MARKETPLACE_IBM_WATSON_MESSAGE_SENTIMENT = "marketplace-ibm-watson-message-sentiment" MARKETPLACE_IBM_WATSON_RECORDING_ANALYSIS = "marketplace-ibm-watson-recording-analysis" MARKETPLACE_ICEHOOK_SYSTEMS_SCOUT = "marketplace-icehook-systems-scout" MARKETPLACE_INFOGROUP_DATAAXLE_BIZINFO = "marketplace-infogroup-dataaxle-bizinfo" MARKETPLACE_CADENCE_TRANSCRIPTION = "marketplace-cadence-transcription" MARKETPLACE_CADENCE_TRANSLATION = "marketplace-cadence-translation" MARKETPLACE_CAPIO_SPEECH_TO_TEXT = "marketplace-capio-speech-to-text" MARKETPLACE_FACEBOOK_OFFLINE_CONVERSIONS = "marketplace-facebook-offline-conversions" MARKETPLACE_KEEN_IO_CONTACT_CENTER_ANALYTICS = "marketplace-keen-io-contact-center-analytics" MARKETPLACE_MARCHEX_CLEANCALL = "marketplace-marchex-cleancall" MARKETPLACE_MARCHEX_SENTIMENT_ANALYSIS_FOR_SMS = "marketplace-marchex-sentiment-analysis-for-sms" MARKETPLACE_MARKETPLACE_NEXTCALLER_SOCIAL_ID = "marketplace-marketplace-nextcaller-social-id" MARKETPLACE_MOBILE_COMMONS_OPT_OUT_CLASSIFIER = "marketplace-mobile-commons-opt-out-classifier" MARKETPLACE_NEXIWAVE_VOICEMAIL_TO_TEXT = "marketplace-nexiwave-voicemail-to-text" MARKETPLACE_NEXTCALLER_ADVANCED_CALLER_IDENTIFICATION = "marketplace-nextcaller-advanced-caller-identification" MARKETPLACE_NOMOROBO_SPAM_SCORE = "marketplace-nomorobo-spam-score" MARKETPLACE_PAYFONE_TCPA_COMPLIANCE = "marketplace-payfone-tcpa-compliance" MARKETPLACE_TELO_OPENCNAM = "marketplace-telo-opencnam" MARKETPLACE_TRUECNAM_TRUE_SPAM = "marketplace-truecnam-true-spam" MARKETPLACE_TWILIO_CALLER_NAME_LOOKUP_US = "marketplace-twilio-caller-name-lookup-us" MARKETPLACE_TWILIO_CARRIER_INFORMATION_LOOKUP = "marketplace-twilio-carrier-information-lookup" MARKETPLACE_VOICEBASE_PCI = "marketplace-voicebase-pci" MARKETPLACE_VOICEBASE_TRANSCRIPTION = "marketplace-voicebase-transcription" MARKETPLACE_WHITEPAGES_PRO_CALLER_IDENTIFICATION = "marketplace-whitepages-pro-caller-identification" MARKETPLACE_WHITEPAGES_PRO_PHONE_INTELLIGENCE = "marketplace-whitepages-pro-phone-intelligence" MARKETPLACE_WHITEPAGES_PRO_PHONE_REPUTATION = "marketplace-whitepages-pro-phone-reputation" MARKETPLACE_WOLFRAM_SHORT_ANSWER = "marketplace-wolfram-short-answer" MARKETPLACE_WOLFARM_SPOKEN_RESULTS = "marketplace-wolfarm-spoken-results" MARKETPLACE_DEEPGRAM_PHRASE_DETECTOR = "marketplace-deepgram-phrase-detector" MARKETPLACE_CONVRIZA_ABABA = "marketplace-convriza-ababa" MARKETPLACE_IBM_WATSON_TONE_ANALYZER = "marketplace-ibm-watson-tone-analyzer" MARKETPLACE_REMEETING_AUTOMATIC_SPEECH_RECOGNITION = "marketplace-remeeting-automatic-speech-recognition" MARKETPLACE_TCPA_DEFENSE_SOLUTIONS_BLACKLIST_FEED = "marketplace-tcpa-defense-solutions-blacklist-feed" MARKETPLACE_VOICEBASE_TRANSCRIPTION_CUSTOM_VOCABULARY = "marketplace-voicebase-transcription-custom-vocabulary" MARKETPLACE_YTICA_CONTACT_CENTER_REPORTING_ANALYTICS = "marketplace-ytica-contact-center-reporting-analytics" MEDIASTORAGE = "mediastorage" MMS = "mms" MMS_INBOUND = "mms-inbound" MMS_INBOUND_LONGCODE = "mms-inbound-longcode" MMS_INBOUND_SHORTCODE = "mms-inbound-shortcode" MMS_OUTBOUND = "mms-outbound" MMS_OUTBOUND_LONGCODE = "mms-outbound-longcode" MMS_OUTBOUND_SHORTCODE = "mms-outbound-shortcode" MONITOR_READS = "monitor-reads" MONITOR_STORAGE = "monitor-storage" MONITOR_WRITES = "monitor-writes" NOTIFY = "notify" NOTIFY_ACTIONS_ATTEMPTS = "notify-actions-attempts" NOTIFY_CHANNELS = "notify-channels" NUMBER_FORMAT_LOOKUPS = "number-format-lookups" PCHAT = "pchat" PCHAT_ACTIONS = "pchat-actions" PCHAT_APS = "pchat-aps" PCHAT_NOTIFICATIONS = "pchat-notifications" PCHAT_READS = "pchat-reads" PCHAT_USERS = "pchat-users" PCHAT_MESSAGES = "pchat-messages" PEER_TO_PEER_ROOMS_PARTICIPANT_MINUTES = "peer-to-peer-rooms-participant-minutes" PFAX = "pfax" PFAX_MINUTES = "pfax-minutes" PFAX_MINUTES_INBOUND = "pfax-minutes-inbound" PFAX_MINUTES_OUTBOUND = "pfax-minutes-outbound" PFAX_PAGES = "pfax-pages" PHONENUMBERS = "phonenumbers" PHONENUMBERS_CPS = "phonenumbers-cps" PHONENUMBERS_EMERGENCY = "phonenumbers-emergency" PHONENUMBERS_LOCAL = "phonenumbers-local" PHONENUMBERS_MOBILE = "phonenumbers-mobile" PHONENUMBERS_SETUPS = "phonenumbers-setups" PHONENUMBERS_TOLLFREE = "phonenumbers-tollfree" PREMIUMSUPPORT = "premiumsupport" PV = "pv" PV_ROOM_PARTICIPANTS = "pv-room-participants" PV_ROOM_PARTICIPANTS_AU1 = "pv-room-participants-au1" PV_ROOM_PARTICIPANTS_BR1 = "pv-room-participants-br1" PV_ROOM_PARTICIPANTS_IE1 = "pv-room-participants-ie1" PV_ROOM_PARTICIPANTS_JP1 = "pv-room-participants-jp1" PV_ROOM_PARTICIPANTS_SG1 = "pv-room-participants-sg1" PV_ROOM_PARTICIPANTS_US1 = "pv-room-participants-us1" PV_ROOM_PARTICIPANTS_US2 = "pv-room-participants-us2" PV_ROOMS = "pv-rooms" PV_SIP_ENDPOINT_REGISTRATIONS = "pv-sip-endpoint-registrations" RECORDINGS = "recordings" RECORDINGSTORAGE = "recordingstorage" ROOMS_GROUP_MINUTES = "rooms-group-minutes" ROOMS_GROUP_BANDWIDTH = "rooms-group-bandwidth" 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_UK = "shortcodes-uk" SHORTCODES_VANITY = "shortcodes-vanity" SMS = "sms" SMS_INBOUND = "sms-inbound" SMS_INBOUND_LONGCODE = "sms-inbound-longcode" SMS_INBOUND_SHORTCODE = "sms-inbound-shortcode" 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_MESSAGES_FEATURES = "sms-messages-features" SPEECH_RECOGNITION = "speech-recognition" SYNC = "sync" SYNC_ACTIONS = "sync-actions" SYNC_ENDPOINT_HOURS = "sync-endpoint-hours" SYNC_ENDPOINT_HOURS_ABOVE_DAILY_CAP = "sync-endpoint-hours-above-daily-cap" TASKROUTER_TASKS = "taskrouter-tasks" TOTALPRICE = "totalprice" TRANSCRIPTIONS = "transcriptions" TRUNKING_CPS = "trunking-cps" TRUNKING_EMERGENCY_CALLS = "trunking-emergency-calls" TRUNKING_ORIGINATION = "trunking-origination" TRUNKING_ORIGINATION_LOCAL = "trunking-origination-local" TRUNKING_ORIGINATION_MOBILE = "trunking-origination-mobile" TRUNKING_ORIGINATION_TOLLFREE = "trunking-origination-tollfree" TRUNKING_RECORDINGS = "trunking-recordings" TRUNKING_SECURE = "trunking-secure" TRUNKING_TERMINATION = "trunking-termination" TURNMEGABYTES = "turnmegabytes" TURNMEGABYTES_AUSTRALIA = "turnmegabytes-australia" TURNMEGABYTES_BRASIL = "turnmegabytes-brasil" TURNMEGABYTES_INDIA = "turnmegabytes-india" TURNMEGABYTES_IRELAND = "turnmegabytes-ireland" TURNMEGABYTES_JAPAN = "turnmegabytes-japan" TURNMEGABYTES_SINGAPORE = "turnmegabytes-singapore" TURNMEGABYTES_USEAST = "turnmegabytes-useast" TURNMEGABYTES_USWEST = "turnmegabytes-uswest" TWILIO_INTERCONNECT = "twilio-interconnect" VOICE_INSIGHTS = "voice-insights" VOICE_INSIGHTS_AUDIO_TRACE = "voice-insights-audio-trace" VOICE_INSIGHTS_CARRIER_CALLS = "voice-insights-carrier-calls" WIRELESS = "wireless" 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_USAGE = "wireless-usage" WIRELESS_USAGE_COMMANDS = "wireless-usage-commands" WIRELESS_USAGE_COMMANDS_AFRICA = "wireless-usage-commands-africa" WIRELESS_USAGE_COMMANDS_ASIA = "wireless-usage-commands-asia" WIRELESS_USAGE_COMMANDS_CENTRALANDSOUTHAMERICA = "wireless-usage-commands-centralandsouthamerica" WIRELESS_USAGE_COMMANDS_EUROPE = "wireless-usage-commands-europe" WIRELESS_USAGE_COMMANDS_HOME = "wireless-usage-commands-home" WIRELESS_USAGE_COMMANDS_NORTHAMERICA = "wireless-usage-commands-northamerica" WIRELESS_USAGE_COMMANDS_OCEANIA = "wireless-usage-commands-oceania" WIRELESS_USAGE_COMMANDS_ROAMING = "wireless-usage-commands-roaming" WIRELESS_USAGE_DATA = "wireless-usage-data" WIRELESS_USAGE_DATA_AFRICA = "wireless-usage-data-africa" WIRELESS_USAGE_DATA_ASIA = "wireless-usage-data-asia" WIRELESS_USAGE_DATA_CENTRALANDSOUTHAMERICA = "wireless-usage-data-centralandsouthamerica" WIRELESS_USAGE_DATA_CUSTOM_ADDITIONALMB = "wireless-usage-data-custom-additionalmb" WIRELESS_USAGE_DATA_CUSTOM_FIRST5MB = "wireless-usage-data-custom-first5mb" WIRELESS_USAGE_DATA_DOMESTIC_ROAMING = "wireless-usage-data-domestic-roaming" WIRELESS_USAGE_DATA_EUROPE = "wireless-usage-data-europe" WIRELESS_USAGE_DATA_INDIVIDUAL_ADDITIONALGB = "wireless-usage-data-individual-additionalgb" WIRELESS_USAGE_DATA_INDIVIDUAL_FIRSTGB = "wireless-usage-data-individual-firstgb" WIRELESS_USAGE_DATA_INTERNATIONAL_ROAMING_CANADA = "wireless-usage-data-international-roaming-canada" WIRELESS_USAGE_DATA_INTERNATIONAL_ROAMING_INDIA = "wireless-usage-data-international-roaming-india" WIRELESS_USAGE_DATA_INTERNATIONAL_ROAMING_MEXICO = "wireless-usage-data-international-roaming-mexico" WIRELESS_USAGE_DATA_NORTHAMERICA = "wireless-usage-data-northamerica" WIRELESS_USAGE_DATA_OCEANIA = "wireless-usage-data-oceania" WIRELESS_USAGE_DATA_POOLED = "wireless-usage-data-pooled" WIRELESS_USAGE_DATA_POOLED_DOWNLINK = "wireless-usage-data-pooled-downlink" WIRELESS_USAGE_DATA_POOLED_UPLINK = "wireless-usage-data-pooled-uplink" WIRELESS_USAGE_MRC = "wireless-usage-mrc" WIRELESS_USAGE_MRC_CUSTOM = "wireless-usage-mrc-custom" WIRELESS_USAGE_MRC_INDIVIDUAL = "wireless-usage-mrc-individual" WIRELESS_USAGE_MRC_POOLED = "wireless-usage-mrc-pooled" WIRELESS_USAGE_MRC_SUSPENDED = "wireless-usage-mrc-suspended" WIRELESS_USAGE_VOICE = "wireless-usage-voice" WIRELESS_USAGE_SMS = "wireless-usage-sms" def __init__(self, version, payload, account_sid): """ Initialize the ThisMonthInstance :returns: twilio.rest.api.v2010.account.usage.record.this_month.ThisMonthInstance :rtype: twilio.rest.api.v2010.account.usage.record.this_month.ThisMonthInstance """ super(ThisMonthInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'api_version': payload['api_version'], 'category': payload['category'], 'count': payload['count'], 'count_unit': payload['count_unit'], 'description': payload['description'], 'end_date': deserialize.iso8601_date(payload['end_date']), 'price': deserialize.decimal(payload['price']), 'price_unit': payload['price_unit'], 'start_date': deserialize.iso8601_date(payload['start_date']), 'subresource_uris': payload['subresource_uris'], 'uri': payload['uri'], 'usage': payload['usage'], 'usage_unit': payload['usage_unit'], } # Context self._context = None self._solution = {'account_sid': account_sid,} @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def api_version(self): """ :returns: The api_version :rtype: unicode """ return self._properties['api_version'] @property def category(self): """ :returns: The category :rtype: ThisMonthInstance.Category """ return self._properties['category'] @property def count(self): """ :returns: The count :rtype: unicode """ return self._properties['count'] @property def count_unit(self): """ :returns: The count_unit :rtype: unicode """ return self._properties['count_unit'] @property def description(self): """ :returns: The description :rtype: unicode """ return self._properties['description'] @property def end_date(self): """ :returns: The end_date :rtype: date """ return self._properties['end_date'] @property def price(self): """ :returns: The price :rtype: unicode """ return self._properties['price'] @property def price_unit(self): """ :returns: The price_unit :rtype: unicode """ return self._properties['price_unit'] @property def start_date(self): """ :returns: The start_date :rtype: date """ return self._properties['start_date'] @property def subresource_uris(self): """ :returns: The subresource_uris :rtype: unicode """ return self._properties['subresource_uris'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] @property def usage(self): """ :returns: The usage :rtype: unicode """ return self._properties['usage'] @property def usage_unit(self): """ :returns: The usage_unit :rtype: unicode """ return self._properties['usage_unit'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/api/v2010/account/usage/record/today.py000066400000000000000000000605201317472742600257120ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class TodayList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the TodayList :param Version version: Version that contains the resource :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.usage.record.today.TodayList :rtype: twilio.rest.api.v2010.account.usage.record.today.TodayList """ super(TodayList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/Usage/Records/Today.json'.format(**self._solution) def stream(self, category=values.unset, start_date=values.unset, end_date=values.unset, limit=None, page_size=None): """ Streams TodayInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param TodayInstance.Category category: The category :param date start_date: The start_date :param date end_date: The end_date :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.usage.record.today.TodayInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( category=category, start_date=start_date, end_date=end_date, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, category=values.unset, start_date=values.unset, end_date=values.unset, limit=None, page_size=None): """ Lists TodayInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param TodayInstance.Category category: The category :param date start_date: The start_date :param date end_date: The end_date :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.usage.record.today.TodayInstance] """ return list(self.stream( category=category, start_date=start_date, end_date=end_date, limit=limit, page_size=page_size, )) def page(self, category=values.unset, start_date=values.unset, end_date=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of TodayInstance records from the API. Request is executed immediately :param TodayInstance.Category category: The category :param date start_date: The start_date :param date end_date: The end_date :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of TodayInstance :rtype: twilio.rest.api.v2010.account.usage.record.today.TodayPage """ params = values.of({ 'Category': category, 'StartDate': serialize.iso8601_date(start_date), 'EndDate': serialize.iso8601_date(end_date), 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return TodayPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of TodayInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of TodayInstance :rtype: twilio.rest.api.v2010.account.usage.record.today.TodayPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return TodayPage(self._version, response, self._solution) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class TodayPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the TodayPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.usage.record.today.TodayPage :rtype: twilio.rest.api.v2010.account.usage.record.today.TodayPage """ super(TodayPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of TodayInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.usage.record.today.TodayInstance :rtype: twilio.rest.api.v2010.account.usage.record.today.TodayInstance """ return TodayInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class TodayInstance(InstanceResource): """ """ class Category(object): ANSWERING_MACHINE_DETECTION = "answering-machine-detection" AUTHY_AUTHENTICATIONS = "authy-authentications" AUTHY_CALLS_OUTBOUND = "authy-calls-outbound" AUTHY_MONTHLY_FEES = "authy-monthly-fees" AUTHY_PHONE_INTELLIGENCE = "authy-phone-intelligence" AUTHY_PHONE_VERIFICATIONS = "authy-phone-verifications" AUTHY_SMS_OUTBOUND = "authy-sms-outbound" CALL_PROGESS_EVENTS = "call-progess-events" CALLERIDLOOKUPS = "calleridlookups" CALLS = "calls" CALLS_CLIENT = "calls-client" 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_OUTBOUND = "calls-outbound" CALLS_RECORDINGS = "calls-recordings" CALLS_SIP = "calls-sip" CALLS_SIP_INBOUND = "calls-sip-inbound" CALLS_SIP_OUTBOUND = "calls-sip-outbound" CARRIER_LOOKUPS = "carrier-lookups" CONVERSATIONS = "conversations" CONVERSATIONS_API_REQUESTS = "conversations-api-requests" CONVERSATIONS_CONVERSATION_EVENTS = "conversations-conversation-events" CONVERSATIONS_ENDPOINT_CONNECTIVITY = "conversations-endpoint-connectivity" CONVERSATIONS_EVENTS = "conversations-events" CONVERSATIONS_PARTICIPANT_EVENTS = "conversations-participant-events" CONVERSATIONS_PARTICIPANTS = "conversations-participants" CPS = "cps" GROUP_ROOMS_MEDIA_DOWNLOADED = "group-rooms-media-downloaded" GROUP_ROOMS_MEDIA_RECORDED = "group-rooms-media-recorded" GROUP_ROOMS_MEDIA_ROUTED = "group-rooms-media-routed" GROUP_ROOMS_MEDIA_STORED = "group-rooms-media-stored" GROUP_ROOMS_PARTICIPANT_MINUTES = "group-rooms-participant-minutes" GROUP_ROOMS_RECORDED_MINUTES = "group-rooms-recorded-minutes" 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" LOOKUPS = "lookups" MARKETPLACE = "marketplace" MARKETPLACE_ALGORITHMIA_NAMED_ENTITY_RECOGNITION = "marketplace-algorithmia-named-entity-recognition" MARKETPLACE_DIGITAL_SEGMENT_BUSINESS_INFO = "marketplace-digital-segment-business-info" MARKETPLACE_GOOGLE_SPEECH_TO_TEXT = "marketplace-google-speech-to-text" MARKETPLACE_IBM_WATSON_MESSAGE_INSIGHTS = "marketplace-ibm-watson-message-insights" MARKETPLACE_IBM_WATSON_MESSAGE_SENTIMENT = "marketplace-ibm-watson-message-sentiment" MARKETPLACE_IBM_WATSON_RECORDING_ANALYSIS = "marketplace-ibm-watson-recording-analysis" MARKETPLACE_ICEHOOK_SYSTEMS_SCOUT = "marketplace-icehook-systems-scout" MARKETPLACE_INFOGROUP_DATAAXLE_BIZINFO = "marketplace-infogroup-dataaxle-bizinfo" MARKETPLACE_CADENCE_TRANSCRIPTION = "marketplace-cadence-transcription" MARKETPLACE_CADENCE_TRANSLATION = "marketplace-cadence-translation" MARKETPLACE_CAPIO_SPEECH_TO_TEXT = "marketplace-capio-speech-to-text" MARKETPLACE_FACEBOOK_OFFLINE_CONVERSIONS = "marketplace-facebook-offline-conversions" MARKETPLACE_KEEN_IO_CONTACT_CENTER_ANALYTICS = "marketplace-keen-io-contact-center-analytics" MARKETPLACE_MARCHEX_CLEANCALL = "marketplace-marchex-cleancall" MARKETPLACE_MARCHEX_SENTIMENT_ANALYSIS_FOR_SMS = "marketplace-marchex-sentiment-analysis-for-sms" MARKETPLACE_MARKETPLACE_NEXTCALLER_SOCIAL_ID = "marketplace-marketplace-nextcaller-social-id" MARKETPLACE_MOBILE_COMMONS_OPT_OUT_CLASSIFIER = "marketplace-mobile-commons-opt-out-classifier" MARKETPLACE_NEXIWAVE_VOICEMAIL_TO_TEXT = "marketplace-nexiwave-voicemail-to-text" MARKETPLACE_NEXTCALLER_ADVANCED_CALLER_IDENTIFICATION = "marketplace-nextcaller-advanced-caller-identification" MARKETPLACE_NOMOROBO_SPAM_SCORE = "marketplace-nomorobo-spam-score" MARKETPLACE_PAYFONE_TCPA_COMPLIANCE = "marketplace-payfone-tcpa-compliance" MARKETPLACE_TELO_OPENCNAM = "marketplace-telo-opencnam" MARKETPLACE_TRUECNAM_TRUE_SPAM = "marketplace-truecnam-true-spam" MARKETPLACE_TWILIO_CALLER_NAME_LOOKUP_US = "marketplace-twilio-caller-name-lookup-us" MARKETPLACE_TWILIO_CARRIER_INFORMATION_LOOKUP = "marketplace-twilio-carrier-information-lookup" MARKETPLACE_VOICEBASE_PCI = "marketplace-voicebase-pci" MARKETPLACE_VOICEBASE_TRANSCRIPTION = "marketplace-voicebase-transcription" MARKETPLACE_WHITEPAGES_PRO_CALLER_IDENTIFICATION = "marketplace-whitepages-pro-caller-identification" MARKETPLACE_WHITEPAGES_PRO_PHONE_INTELLIGENCE = "marketplace-whitepages-pro-phone-intelligence" MARKETPLACE_WHITEPAGES_PRO_PHONE_REPUTATION = "marketplace-whitepages-pro-phone-reputation" MARKETPLACE_WOLFRAM_SHORT_ANSWER = "marketplace-wolfram-short-answer" MARKETPLACE_WOLFARM_SPOKEN_RESULTS = "marketplace-wolfarm-spoken-results" MARKETPLACE_DEEPGRAM_PHRASE_DETECTOR = "marketplace-deepgram-phrase-detector" MARKETPLACE_CONVRIZA_ABABA = "marketplace-convriza-ababa" MARKETPLACE_IBM_WATSON_TONE_ANALYZER = "marketplace-ibm-watson-tone-analyzer" MARKETPLACE_REMEETING_AUTOMATIC_SPEECH_RECOGNITION = "marketplace-remeeting-automatic-speech-recognition" MARKETPLACE_TCPA_DEFENSE_SOLUTIONS_BLACKLIST_FEED = "marketplace-tcpa-defense-solutions-blacklist-feed" MARKETPLACE_VOICEBASE_TRANSCRIPTION_CUSTOM_VOCABULARY = "marketplace-voicebase-transcription-custom-vocabulary" MARKETPLACE_YTICA_CONTACT_CENTER_REPORTING_ANALYTICS = "marketplace-ytica-contact-center-reporting-analytics" MEDIASTORAGE = "mediastorage" MMS = "mms" MMS_INBOUND = "mms-inbound" MMS_INBOUND_LONGCODE = "mms-inbound-longcode" MMS_INBOUND_SHORTCODE = "mms-inbound-shortcode" MMS_OUTBOUND = "mms-outbound" MMS_OUTBOUND_LONGCODE = "mms-outbound-longcode" MMS_OUTBOUND_SHORTCODE = "mms-outbound-shortcode" MONITOR_READS = "monitor-reads" MONITOR_STORAGE = "monitor-storage" MONITOR_WRITES = "monitor-writes" NOTIFY = "notify" NOTIFY_ACTIONS_ATTEMPTS = "notify-actions-attempts" NOTIFY_CHANNELS = "notify-channels" NUMBER_FORMAT_LOOKUPS = "number-format-lookups" PCHAT = "pchat" PCHAT_ACTIONS = "pchat-actions" PCHAT_APS = "pchat-aps" PCHAT_NOTIFICATIONS = "pchat-notifications" PCHAT_READS = "pchat-reads" PCHAT_USERS = "pchat-users" PCHAT_MESSAGES = "pchat-messages" PEER_TO_PEER_ROOMS_PARTICIPANT_MINUTES = "peer-to-peer-rooms-participant-minutes" PFAX = "pfax" PFAX_MINUTES = "pfax-minutes" PFAX_MINUTES_INBOUND = "pfax-minutes-inbound" PFAX_MINUTES_OUTBOUND = "pfax-minutes-outbound" PFAX_PAGES = "pfax-pages" PHONENUMBERS = "phonenumbers" PHONENUMBERS_CPS = "phonenumbers-cps" PHONENUMBERS_EMERGENCY = "phonenumbers-emergency" PHONENUMBERS_LOCAL = "phonenumbers-local" PHONENUMBERS_MOBILE = "phonenumbers-mobile" PHONENUMBERS_SETUPS = "phonenumbers-setups" PHONENUMBERS_TOLLFREE = "phonenumbers-tollfree" PREMIUMSUPPORT = "premiumsupport" PV = "pv" PV_ROOM_PARTICIPANTS = "pv-room-participants" PV_ROOM_PARTICIPANTS_AU1 = "pv-room-participants-au1" PV_ROOM_PARTICIPANTS_BR1 = "pv-room-participants-br1" PV_ROOM_PARTICIPANTS_IE1 = "pv-room-participants-ie1" PV_ROOM_PARTICIPANTS_JP1 = "pv-room-participants-jp1" PV_ROOM_PARTICIPANTS_SG1 = "pv-room-participants-sg1" PV_ROOM_PARTICIPANTS_US1 = "pv-room-participants-us1" PV_ROOM_PARTICIPANTS_US2 = "pv-room-participants-us2" PV_ROOMS = "pv-rooms" PV_SIP_ENDPOINT_REGISTRATIONS = "pv-sip-endpoint-registrations" RECORDINGS = "recordings" RECORDINGSTORAGE = "recordingstorage" ROOMS_GROUP_MINUTES = "rooms-group-minutes" ROOMS_GROUP_BANDWIDTH = "rooms-group-bandwidth" 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_UK = "shortcodes-uk" SHORTCODES_VANITY = "shortcodes-vanity" SMS = "sms" SMS_INBOUND = "sms-inbound" SMS_INBOUND_LONGCODE = "sms-inbound-longcode" SMS_INBOUND_SHORTCODE = "sms-inbound-shortcode" 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_MESSAGES_FEATURES = "sms-messages-features" SPEECH_RECOGNITION = "speech-recognition" SYNC = "sync" SYNC_ACTIONS = "sync-actions" SYNC_ENDPOINT_HOURS = "sync-endpoint-hours" SYNC_ENDPOINT_HOURS_ABOVE_DAILY_CAP = "sync-endpoint-hours-above-daily-cap" TASKROUTER_TASKS = "taskrouter-tasks" TOTALPRICE = "totalprice" TRANSCRIPTIONS = "transcriptions" TRUNKING_CPS = "trunking-cps" TRUNKING_EMERGENCY_CALLS = "trunking-emergency-calls" TRUNKING_ORIGINATION = "trunking-origination" TRUNKING_ORIGINATION_LOCAL = "trunking-origination-local" TRUNKING_ORIGINATION_MOBILE = "trunking-origination-mobile" TRUNKING_ORIGINATION_TOLLFREE = "trunking-origination-tollfree" TRUNKING_RECORDINGS = "trunking-recordings" TRUNKING_SECURE = "trunking-secure" TRUNKING_TERMINATION = "trunking-termination" TURNMEGABYTES = "turnmegabytes" TURNMEGABYTES_AUSTRALIA = "turnmegabytes-australia" TURNMEGABYTES_BRASIL = "turnmegabytes-brasil" TURNMEGABYTES_INDIA = "turnmegabytes-india" TURNMEGABYTES_IRELAND = "turnmegabytes-ireland" TURNMEGABYTES_JAPAN = "turnmegabytes-japan" TURNMEGABYTES_SINGAPORE = "turnmegabytes-singapore" TURNMEGABYTES_USEAST = "turnmegabytes-useast" TURNMEGABYTES_USWEST = "turnmegabytes-uswest" TWILIO_INTERCONNECT = "twilio-interconnect" VOICE_INSIGHTS = "voice-insights" VOICE_INSIGHTS_AUDIO_TRACE = "voice-insights-audio-trace" VOICE_INSIGHTS_CARRIER_CALLS = "voice-insights-carrier-calls" WIRELESS = "wireless" 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_USAGE = "wireless-usage" WIRELESS_USAGE_COMMANDS = "wireless-usage-commands" WIRELESS_USAGE_COMMANDS_AFRICA = "wireless-usage-commands-africa" WIRELESS_USAGE_COMMANDS_ASIA = "wireless-usage-commands-asia" WIRELESS_USAGE_COMMANDS_CENTRALANDSOUTHAMERICA = "wireless-usage-commands-centralandsouthamerica" WIRELESS_USAGE_COMMANDS_EUROPE = "wireless-usage-commands-europe" WIRELESS_USAGE_COMMANDS_HOME = "wireless-usage-commands-home" WIRELESS_USAGE_COMMANDS_NORTHAMERICA = "wireless-usage-commands-northamerica" WIRELESS_USAGE_COMMANDS_OCEANIA = "wireless-usage-commands-oceania" WIRELESS_USAGE_COMMANDS_ROAMING = "wireless-usage-commands-roaming" WIRELESS_USAGE_DATA = "wireless-usage-data" WIRELESS_USAGE_DATA_AFRICA = "wireless-usage-data-africa" WIRELESS_USAGE_DATA_ASIA = "wireless-usage-data-asia" WIRELESS_USAGE_DATA_CENTRALANDSOUTHAMERICA = "wireless-usage-data-centralandsouthamerica" WIRELESS_USAGE_DATA_CUSTOM_ADDITIONALMB = "wireless-usage-data-custom-additionalmb" WIRELESS_USAGE_DATA_CUSTOM_FIRST5MB = "wireless-usage-data-custom-first5mb" WIRELESS_USAGE_DATA_DOMESTIC_ROAMING = "wireless-usage-data-domestic-roaming" WIRELESS_USAGE_DATA_EUROPE = "wireless-usage-data-europe" WIRELESS_USAGE_DATA_INDIVIDUAL_ADDITIONALGB = "wireless-usage-data-individual-additionalgb" WIRELESS_USAGE_DATA_INDIVIDUAL_FIRSTGB = "wireless-usage-data-individual-firstgb" WIRELESS_USAGE_DATA_INTERNATIONAL_ROAMING_CANADA = "wireless-usage-data-international-roaming-canada" WIRELESS_USAGE_DATA_INTERNATIONAL_ROAMING_INDIA = "wireless-usage-data-international-roaming-india" WIRELESS_USAGE_DATA_INTERNATIONAL_ROAMING_MEXICO = "wireless-usage-data-international-roaming-mexico" WIRELESS_USAGE_DATA_NORTHAMERICA = "wireless-usage-data-northamerica" WIRELESS_USAGE_DATA_OCEANIA = "wireless-usage-data-oceania" WIRELESS_USAGE_DATA_POOLED = "wireless-usage-data-pooled" WIRELESS_USAGE_DATA_POOLED_DOWNLINK = "wireless-usage-data-pooled-downlink" WIRELESS_USAGE_DATA_POOLED_UPLINK = "wireless-usage-data-pooled-uplink" WIRELESS_USAGE_MRC = "wireless-usage-mrc" WIRELESS_USAGE_MRC_CUSTOM = "wireless-usage-mrc-custom" WIRELESS_USAGE_MRC_INDIVIDUAL = "wireless-usage-mrc-individual" WIRELESS_USAGE_MRC_POOLED = "wireless-usage-mrc-pooled" WIRELESS_USAGE_MRC_SUSPENDED = "wireless-usage-mrc-suspended" WIRELESS_USAGE_VOICE = "wireless-usage-voice" WIRELESS_USAGE_SMS = "wireless-usage-sms" def __init__(self, version, payload, account_sid): """ Initialize the TodayInstance :returns: twilio.rest.api.v2010.account.usage.record.today.TodayInstance :rtype: twilio.rest.api.v2010.account.usage.record.today.TodayInstance """ super(TodayInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'api_version': payload['api_version'], 'category': payload['category'], 'count': payload['count'], 'count_unit': payload['count_unit'], 'description': payload['description'], 'end_date': deserialize.iso8601_date(payload['end_date']), 'price': deserialize.decimal(payload['price']), 'price_unit': payload['price_unit'], 'start_date': deserialize.iso8601_date(payload['start_date']), 'subresource_uris': payload['subresource_uris'], 'uri': payload['uri'], 'usage': payload['usage'], 'usage_unit': payload['usage_unit'], } # Context self._context = None self._solution = {'account_sid': account_sid,} @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def api_version(self): """ :returns: The api_version :rtype: unicode """ return self._properties['api_version'] @property def category(self): """ :returns: The category :rtype: TodayInstance.Category """ return self._properties['category'] @property def count(self): """ :returns: The count :rtype: unicode """ return self._properties['count'] @property def count_unit(self): """ :returns: The count_unit :rtype: unicode """ return self._properties['count_unit'] @property def description(self): """ :returns: The description :rtype: unicode """ return self._properties['description'] @property def end_date(self): """ :returns: The end_date :rtype: date """ return self._properties['end_date'] @property def price(self): """ :returns: The price :rtype: unicode """ return self._properties['price'] @property def price_unit(self): """ :returns: The price_unit :rtype: unicode """ return self._properties['price_unit'] @property def start_date(self): """ :returns: The start_date :rtype: date """ return self._properties['start_date'] @property def subresource_uris(self): """ :returns: The subresource_uris :rtype: unicode """ return self._properties['subresource_uris'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] @property def usage(self): """ :returns: The usage :rtype: unicode """ return self._properties['usage'] @property def usage_unit(self): """ :returns: The usage_unit :rtype: unicode """ return self._properties['usage_unit'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/api/v2010/account/usage/record/yearly.py000066400000000000000000000606031317472742600261010ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class YearlyList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the YearlyList :param Version version: Version that contains the resource :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.usage.record.yearly.YearlyList :rtype: twilio.rest.api.v2010.account.usage.record.yearly.YearlyList """ super(YearlyList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/Usage/Records/Yearly.json'.format(**self._solution) def stream(self, category=values.unset, start_date=values.unset, end_date=values.unset, limit=None, page_size=None): """ Streams YearlyInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param YearlyInstance.Category category: The category :param date start_date: The start_date :param date end_date: The end_date :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.usage.record.yearly.YearlyInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( category=category, start_date=start_date, end_date=end_date, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, category=values.unset, start_date=values.unset, end_date=values.unset, limit=None, page_size=None): """ Lists YearlyInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param YearlyInstance.Category category: The category :param date start_date: The start_date :param date end_date: The end_date :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.usage.record.yearly.YearlyInstance] """ return list(self.stream( category=category, start_date=start_date, end_date=end_date, limit=limit, page_size=page_size, )) def page(self, category=values.unset, start_date=values.unset, end_date=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of YearlyInstance records from the API. Request is executed immediately :param YearlyInstance.Category category: The category :param date start_date: The start_date :param date end_date: The end_date :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of YearlyInstance :rtype: twilio.rest.api.v2010.account.usage.record.yearly.YearlyPage """ params = values.of({ 'Category': category, 'StartDate': serialize.iso8601_date(start_date), 'EndDate': serialize.iso8601_date(end_date), 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return YearlyPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of YearlyInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of YearlyInstance :rtype: twilio.rest.api.v2010.account.usage.record.yearly.YearlyPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return YearlyPage(self._version, response, self._solution) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class YearlyPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the YearlyPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.usage.record.yearly.YearlyPage :rtype: twilio.rest.api.v2010.account.usage.record.yearly.YearlyPage """ super(YearlyPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of YearlyInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.usage.record.yearly.YearlyInstance :rtype: twilio.rest.api.v2010.account.usage.record.yearly.YearlyInstance """ return YearlyInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class YearlyInstance(InstanceResource): """ """ class Category(object): ANSWERING_MACHINE_DETECTION = "answering-machine-detection" AUTHY_AUTHENTICATIONS = "authy-authentications" AUTHY_CALLS_OUTBOUND = "authy-calls-outbound" AUTHY_MONTHLY_FEES = "authy-monthly-fees" AUTHY_PHONE_INTELLIGENCE = "authy-phone-intelligence" AUTHY_PHONE_VERIFICATIONS = "authy-phone-verifications" AUTHY_SMS_OUTBOUND = "authy-sms-outbound" CALL_PROGESS_EVENTS = "call-progess-events" CALLERIDLOOKUPS = "calleridlookups" CALLS = "calls" CALLS_CLIENT = "calls-client" 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_OUTBOUND = "calls-outbound" CALLS_RECORDINGS = "calls-recordings" CALLS_SIP = "calls-sip" CALLS_SIP_INBOUND = "calls-sip-inbound" CALLS_SIP_OUTBOUND = "calls-sip-outbound" CARRIER_LOOKUPS = "carrier-lookups" CONVERSATIONS = "conversations" CONVERSATIONS_API_REQUESTS = "conversations-api-requests" CONVERSATIONS_CONVERSATION_EVENTS = "conversations-conversation-events" CONVERSATIONS_ENDPOINT_CONNECTIVITY = "conversations-endpoint-connectivity" CONVERSATIONS_EVENTS = "conversations-events" CONVERSATIONS_PARTICIPANT_EVENTS = "conversations-participant-events" CONVERSATIONS_PARTICIPANTS = "conversations-participants" CPS = "cps" GROUP_ROOMS_MEDIA_DOWNLOADED = "group-rooms-media-downloaded" GROUP_ROOMS_MEDIA_RECORDED = "group-rooms-media-recorded" GROUP_ROOMS_MEDIA_ROUTED = "group-rooms-media-routed" GROUP_ROOMS_MEDIA_STORED = "group-rooms-media-stored" GROUP_ROOMS_PARTICIPANT_MINUTES = "group-rooms-participant-minutes" GROUP_ROOMS_RECORDED_MINUTES = "group-rooms-recorded-minutes" 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" LOOKUPS = "lookups" MARKETPLACE = "marketplace" MARKETPLACE_ALGORITHMIA_NAMED_ENTITY_RECOGNITION = "marketplace-algorithmia-named-entity-recognition" MARKETPLACE_DIGITAL_SEGMENT_BUSINESS_INFO = "marketplace-digital-segment-business-info" MARKETPLACE_GOOGLE_SPEECH_TO_TEXT = "marketplace-google-speech-to-text" MARKETPLACE_IBM_WATSON_MESSAGE_INSIGHTS = "marketplace-ibm-watson-message-insights" MARKETPLACE_IBM_WATSON_MESSAGE_SENTIMENT = "marketplace-ibm-watson-message-sentiment" MARKETPLACE_IBM_WATSON_RECORDING_ANALYSIS = "marketplace-ibm-watson-recording-analysis" MARKETPLACE_ICEHOOK_SYSTEMS_SCOUT = "marketplace-icehook-systems-scout" MARKETPLACE_INFOGROUP_DATAAXLE_BIZINFO = "marketplace-infogroup-dataaxle-bizinfo" MARKETPLACE_CADENCE_TRANSCRIPTION = "marketplace-cadence-transcription" MARKETPLACE_CADENCE_TRANSLATION = "marketplace-cadence-translation" MARKETPLACE_CAPIO_SPEECH_TO_TEXT = "marketplace-capio-speech-to-text" MARKETPLACE_FACEBOOK_OFFLINE_CONVERSIONS = "marketplace-facebook-offline-conversions" MARKETPLACE_KEEN_IO_CONTACT_CENTER_ANALYTICS = "marketplace-keen-io-contact-center-analytics" MARKETPLACE_MARCHEX_CLEANCALL = "marketplace-marchex-cleancall" MARKETPLACE_MARCHEX_SENTIMENT_ANALYSIS_FOR_SMS = "marketplace-marchex-sentiment-analysis-for-sms" MARKETPLACE_MARKETPLACE_NEXTCALLER_SOCIAL_ID = "marketplace-marketplace-nextcaller-social-id" MARKETPLACE_MOBILE_COMMONS_OPT_OUT_CLASSIFIER = "marketplace-mobile-commons-opt-out-classifier" MARKETPLACE_NEXIWAVE_VOICEMAIL_TO_TEXT = "marketplace-nexiwave-voicemail-to-text" MARKETPLACE_NEXTCALLER_ADVANCED_CALLER_IDENTIFICATION = "marketplace-nextcaller-advanced-caller-identification" MARKETPLACE_NOMOROBO_SPAM_SCORE = "marketplace-nomorobo-spam-score" MARKETPLACE_PAYFONE_TCPA_COMPLIANCE = "marketplace-payfone-tcpa-compliance" MARKETPLACE_TELO_OPENCNAM = "marketplace-telo-opencnam" MARKETPLACE_TRUECNAM_TRUE_SPAM = "marketplace-truecnam-true-spam" MARKETPLACE_TWILIO_CALLER_NAME_LOOKUP_US = "marketplace-twilio-caller-name-lookup-us" MARKETPLACE_TWILIO_CARRIER_INFORMATION_LOOKUP = "marketplace-twilio-carrier-information-lookup" MARKETPLACE_VOICEBASE_PCI = "marketplace-voicebase-pci" MARKETPLACE_VOICEBASE_TRANSCRIPTION = "marketplace-voicebase-transcription" MARKETPLACE_WHITEPAGES_PRO_CALLER_IDENTIFICATION = "marketplace-whitepages-pro-caller-identification" MARKETPLACE_WHITEPAGES_PRO_PHONE_INTELLIGENCE = "marketplace-whitepages-pro-phone-intelligence" MARKETPLACE_WHITEPAGES_PRO_PHONE_REPUTATION = "marketplace-whitepages-pro-phone-reputation" MARKETPLACE_WOLFRAM_SHORT_ANSWER = "marketplace-wolfram-short-answer" MARKETPLACE_WOLFARM_SPOKEN_RESULTS = "marketplace-wolfarm-spoken-results" MARKETPLACE_DEEPGRAM_PHRASE_DETECTOR = "marketplace-deepgram-phrase-detector" MARKETPLACE_CONVRIZA_ABABA = "marketplace-convriza-ababa" MARKETPLACE_IBM_WATSON_TONE_ANALYZER = "marketplace-ibm-watson-tone-analyzer" MARKETPLACE_REMEETING_AUTOMATIC_SPEECH_RECOGNITION = "marketplace-remeeting-automatic-speech-recognition" MARKETPLACE_TCPA_DEFENSE_SOLUTIONS_BLACKLIST_FEED = "marketplace-tcpa-defense-solutions-blacklist-feed" MARKETPLACE_VOICEBASE_TRANSCRIPTION_CUSTOM_VOCABULARY = "marketplace-voicebase-transcription-custom-vocabulary" MARKETPLACE_YTICA_CONTACT_CENTER_REPORTING_ANALYTICS = "marketplace-ytica-contact-center-reporting-analytics" MEDIASTORAGE = "mediastorage" MMS = "mms" MMS_INBOUND = "mms-inbound" MMS_INBOUND_LONGCODE = "mms-inbound-longcode" MMS_INBOUND_SHORTCODE = "mms-inbound-shortcode" MMS_OUTBOUND = "mms-outbound" MMS_OUTBOUND_LONGCODE = "mms-outbound-longcode" MMS_OUTBOUND_SHORTCODE = "mms-outbound-shortcode" MONITOR_READS = "monitor-reads" MONITOR_STORAGE = "monitor-storage" MONITOR_WRITES = "monitor-writes" NOTIFY = "notify" NOTIFY_ACTIONS_ATTEMPTS = "notify-actions-attempts" NOTIFY_CHANNELS = "notify-channels" NUMBER_FORMAT_LOOKUPS = "number-format-lookups" PCHAT = "pchat" PCHAT_ACTIONS = "pchat-actions" PCHAT_APS = "pchat-aps" PCHAT_NOTIFICATIONS = "pchat-notifications" PCHAT_READS = "pchat-reads" PCHAT_USERS = "pchat-users" PCHAT_MESSAGES = "pchat-messages" PEER_TO_PEER_ROOMS_PARTICIPANT_MINUTES = "peer-to-peer-rooms-participant-minutes" PFAX = "pfax" PFAX_MINUTES = "pfax-minutes" PFAX_MINUTES_INBOUND = "pfax-minutes-inbound" PFAX_MINUTES_OUTBOUND = "pfax-minutes-outbound" PFAX_PAGES = "pfax-pages" PHONENUMBERS = "phonenumbers" PHONENUMBERS_CPS = "phonenumbers-cps" PHONENUMBERS_EMERGENCY = "phonenumbers-emergency" PHONENUMBERS_LOCAL = "phonenumbers-local" PHONENUMBERS_MOBILE = "phonenumbers-mobile" PHONENUMBERS_SETUPS = "phonenumbers-setups" PHONENUMBERS_TOLLFREE = "phonenumbers-tollfree" PREMIUMSUPPORT = "premiumsupport" PV = "pv" PV_ROOM_PARTICIPANTS = "pv-room-participants" PV_ROOM_PARTICIPANTS_AU1 = "pv-room-participants-au1" PV_ROOM_PARTICIPANTS_BR1 = "pv-room-participants-br1" PV_ROOM_PARTICIPANTS_IE1 = "pv-room-participants-ie1" PV_ROOM_PARTICIPANTS_JP1 = "pv-room-participants-jp1" PV_ROOM_PARTICIPANTS_SG1 = "pv-room-participants-sg1" PV_ROOM_PARTICIPANTS_US1 = "pv-room-participants-us1" PV_ROOM_PARTICIPANTS_US2 = "pv-room-participants-us2" PV_ROOMS = "pv-rooms" PV_SIP_ENDPOINT_REGISTRATIONS = "pv-sip-endpoint-registrations" RECORDINGS = "recordings" RECORDINGSTORAGE = "recordingstorage" ROOMS_GROUP_MINUTES = "rooms-group-minutes" ROOMS_GROUP_BANDWIDTH = "rooms-group-bandwidth" 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_UK = "shortcodes-uk" SHORTCODES_VANITY = "shortcodes-vanity" SMS = "sms" SMS_INBOUND = "sms-inbound" SMS_INBOUND_LONGCODE = "sms-inbound-longcode" SMS_INBOUND_SHORTCODE = "sms-inbound-shortcode" 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_MESSAGES_FEATURES = "sms-messages-features" SPEECH_RECOGNITION = "speech-recognition" SYNC = "sync" SYNC_ACTIONS = "sync-actions" SYNC_ENDPOINT_HOURS = "sync-endpoint-hours" SYNC_ENDPOINT_HOURS_ABOVE_DAILY_CAP = "sync-endpoint-hours-above-daily-cap" TASKROUTER_TASKS = "taskrouter-tasks" TOTALPRICE = "totalprice" TRANSCRIPTIONS = "transcriptions" TRUNKING_CPS = "trunking-cps" TRUNKING_EMERGENCY_CALLS = "trunking-emergency-calls" TRUNKING_ORIGINATION = "trunking-origination" TRUNKING_ORIGINATION_LOCAL = "trunking-origination-local" TRUNKING_ORIGINATION_MOBILE = "trunking-origination-mobile" TRUNKING_ORIGINATION_TOLLFREE = "trunking-origination-tollfree" TRUNKING_RECORDINGS = "trunking-recordings" TRUNKING_SECURE = "trunking-secure" TRUNKING_TERMINATION = "trunking-termination" TURNMEGABYTES = "turnmegabytes" TURNMEGABYTES_AUSTRALIA = "turnmegabytes-australia" TURNMEGABYTES_BRASIL = "turnmegabytes-brasil" TURNMEGABYTES_INDIA = "turnmegabytes-india" TURNMEGABYTES_IRELAND = "turnmegabytes-ireland" TURNMEGABYTES_JAPAN = "turnmegabytes-japan" TURNMEGABYTES_SINGAPORE = "turnmegabytes-singapore" TURNMEGABYTES_USEAST = "turnmegabytes-useast" TURNMEGABYTES_USWEST = "turnmegabytes-uswest" TWILIO_INTERCONNECT = "twilio-interconnect" VOICE_INSIGHTS = "voice-insights" VOICE_INSIGHTS_AUDIO_TRACE = "voice-insights-audio-trace" VOICE_INSIGHTS_CARRIER_CALLS = "voice-insights-carrier-calls" WIRELESS = "wireless" 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_USAGE = "wireless-usage" WIRELESS_USAGE_COMMANDS = "wireless-usage-commands" WIRELESS_USAGE_COMMANDS_AFRICA = "wireless-usage-commands-africa" WIRELESS_USAGE_COMMANDS_ASIA = "wireless-usage-commands-asia" WIRELESS_USAGE_COMMANDS_CENTRALANDSOUTHAMERICA = "wireless-usage-commands-centralandsouthamerica" WIRELESS_USAGE_COMMANDS_EUROPE = "wireless-usage-commands-europe" WIRELESS_USAGE_COMMANDS_HOME = "wireless-usage-commands-home" WIRELESS_USAGE_COMMANDS_NORTHAMERICA = "wireless-usage-commands-northamerica" WIRELESS_USAGE_COMMANDS_OCEANIA = "wireless-usage-commands-oceania" WIRELESS_USAGE_COMMANDS_ROAMING = "wireless-usage-commands-roaming" WIRELESS_USAGE_DATA = "wireless-usage-data" WIRELESS_USAGE_DATA_AFRICA = "wireless-usage-data-africa" WIRELESS_USAGE_DATA_ASIA = "wireless-usage-data-asia" WIRELESS_USAGE_DATA_CENTRALANDSOUTHAMERICA = "wireless-usage-data-centralandsouthamerica" WIRELESS_USAGE_DATA_CUSTOM_ADDITIONALMB = "wireless-usage-data-custom-additionalmb" WIRELESS_USAGE_DATA_CUSTOM_FIRST5MB = "wireless-usage-data-custom-first5mb" WIRELESS_USAGE_DATA_DOMESTIC_ROAMING = "wireless-usage-data-domestic-roaming" WIRELESS_USAGE_DATA_EUROPE = "wireless-usage-data-europe" WIRELESS_USAGE_DATA_INDIVIDUAL_ADDITIONALGB = "wireless-usage-data-individual-additionalgb" WIRELESS_USAGE_DATA_INDIVIDUAL_FIRSTGB = "wireless-usage-data-individual-firstgb" WIRELESS_USAGE_DATA_INTERNATIONAL_ROAMING_CANADA = "wireless-usage-data-international-roaming-canada" WIRELESS_USAGE_DATA_INTERNATIONAL_ROAMING_INDIA = "wireless-usage-data-international-roaming-india" WIRELESS_USAGE_DATA_INTERNATIONAL_ROAMING_MEXICO = "wireless-usage-data-international-roaming-mexico" WIRELESS_USAGE_DATA_NORTHAMERICA = "wireless-usage-data-northamerica" WIRELESS_USAGE_DATA_OCEANIA = "wireless-usage-data-oceania" WIRELESS_USAGE_DATA_POOLED = "wireless-usage-data-pooled" WIRELESS_USAGE_DATA_POOLED_DOWNLINK = "wireless-usage-data-pooled-downlink" WIRELESS_USAGE_DATA_POOLED_UPLINK = "wireless-usage-data-pooled-uplink" WIRELESS_USAGE_MRC = "wireless-usage-mrc" WIRELESS_USAGE_MRC_CUSTOM = "wireless-usage-mrc-custom" WIRELESS_USAGE_MRC_INDIVIDUAL = "wireless-usage-mrc-individual" WIRELESS_USAGE_MRC_POOLED = "wireless-usage-mrc-pooled" WIRELESS_USAGE_MRC_SUSPENDED = "wireless-usage-mrc-suspended" WIRELESS_USAGE_VOICE = "wireless-usage-voice" WIRELESS_USAGE_SMS = "wireless-usage-sms" def __init__(self, version, payload, account_sid): """ Initialize the YearlyInstance :returns: twilio.rest.api.v2010.account.usage.record.yearly.YearlyInstance :rtype: twilio.rest.api.v2010.account.usage.record.yearly.YearlyInstance """ super(YearlyInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'api_version': payload['api_version'], 'category': payload['category'], 'count': payload['count'], 'count_unit': payload['count_unit'], 'description': payload['description'], 'end_date': deserialize.iso8601_date(payload['end_date']), 'price': deserialize.decimal(payload['price']), 'price_unit': payload['price_unit'], 'start_date': deserialize.iso8601_date(payload['start_date']), 'subresource_uris': payload['subresource_uris'], 'uri': payload['uri'], 'usage': payload['usage'], 'usage_unit': payload['usage_unit'], } # Context self._context = None self._solution = {'account_sid': account_sid,} @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def api_version(self): """ :returns: The api_version :rtype: unicode """ return self._properties['api_version'] @property def category(self): """ :returns: The category :rtype: YearlyInstance.Category """ return self._properties['category'] @property def count(self): """ :returns: The count :rtype: unicode """ return self._properties['count'] @property def count_unit(self): """ :returns: The count_unit :rtype: unicode """ return self._properties['count_unit'] @property def description(self): """ :returns: The description :rtype: unicode """ return self._properties['description'] @property def end_date(self): """ :returns: The end_date :rtype: date """ return self._properties['end_date'] @property def price(self): """ :returns: The price :rtype: unicode """ return self._properties['price'] @property def price_unit(self): """ :returns: The price_unit :rtype: unicode """ return self._properties['price_unit'] @property def start_date(self): """ :returns: The start_date :rtype: date """ return self._properties['start_date'] @property def subresource_uris(self): """ :returns: The subresource_uris :rtype: unicode """ return self._properties['subresource_uris'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] @property def usage(self): """ :returns: The usage :rtype: unicode """ return self._properties['usage'] @property def usage_unit(self): """ :returns: The usage_unit :rtype: unicode """ return self._properties['usage_unit'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/api/v2010/account/usage/record/yesterday.py000066400000000000000000000610341317472742600266040ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class YesterdayList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the YesterdayList :param Version version: Version that contains the resource :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.usage.record.yesterday.YesterdayList :rtype: twilio.rest.api.v2010.account.usage.record.yesterday.YesterdayList """ super(YesterdayList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/Usage/Records/Yesterday.json'.format(**self._solution) def stream(self, category=values.unset, start_date=values.unset, end_date=values.unset, limit=None, page_size=None): """ Streams YesterdayInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param YesterdayInstance.Category category: The category :param date start_date: The start_date :param date end_date: The end_date :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.usage.record.yesterday.YesterdayInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( category=category, start_date=start_date, end_date=end_date, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, category=values.unset, start_date=values.unset, end_date=values.unset, limit=None, page_size=None): """ Lists YesterdayInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param YesterdayInstance.Category category: The category :param date start_date: The start_date :param date end_date: The end_date :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.usage.record.yesterday.YesterdayInstance] """ return list(self.stream( category=category, start_date=start_date, end_date=end_date, limit=limit, page_size=page_size, )) def page(self, category=values.unset, start_date=values.unset, end_date=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of YesterdayInstance records from the API. Request is executed immediately :param YesterdayInstance.Category category: The category :param date start_date: The start_date :param date end_date: The end_date :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of YesterdayInstance :rtype: twilio.rest.api.v2010.account.usage.record.yesterday.YesterdayPage """ params = values.of({ 'Category': category, 'StartDate': serialize.iso8601_date(start_date), 'EndDate': serialize.iso8601_date(end_date), 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return YesterdayPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of YesterdayInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of YesterdayInstance :rtype: twilio.rest.api.v2010.account.usage.record.yesterday.YesterdayPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return YesterdayPage(self._version, response, self._solution) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class YesterdayPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the YesterdayPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.usage.record.yesterday.YesterdayPage :rtype: twilio.rest.api.v2010.account.usage.record.yesterday.YesterdayPage """ super(YesterdayPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of YesterdayInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.usage.record.yesterday.YesterdayInstance :rtype: twilio.rest.api.v2010.account.usage.record.yesterday.YesterdayInstance """ return YesterdayInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class YesterdayInstance(InstanceResource): """ """ class Category(object): ANSWERING_MACHINE_DETECTION = "answering-machine-detection" AUTHY_AUTHENTICATIONS = "authy-authentications" AUTHY_CALLS_OUTBOUND = "authy-calls-outbound" AUTHY_MONTHLY_FEES = "authy-monthly-fees" AUTHY_PHONE_INTELLIGENCE = "authy-phone-intelligence" AUTHY_PHONE_VERIFICATIONS = "authy-phone-verifications" AUTHY_SMS_OUTBOUND = "authy-sms-outbound" CALL_PROGESS_EVENTS = "call-progess-events" CALLERIDLOOKUPS = "calleridlookups" CALLS = "calls" CALLS_CLIENT = "calls-client" 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_OUTBOUND = "calls-outbound" CALLS_RECORDINGS = "calls-recordings" CALLS_SIP = "calls-sip" CALLS_SIP_INBOUND = "calls-sip-inbound" CALLS_SIP_OUTBOUND = "calls-sip-outbound" CARRIER_LOOKUPS = "carrier-lookups" CONVERSATIONS = "conversations" CONVERSATIONS_API_REQUESTS = "conversations-api-requests" CONVERSATIONS_CONVERSATION_EVENTS = "conversations-conversation-events" CONVERSATIONS_ENDPOINT_CONNECTIVITY = "conversations-endpoint-connectivity" CONVERSATIONS_EVENTS = "conversations-events" CONVERSATIONS_PARTICIPANT_EVENTS = "conversations-participant-events" CONVERSATIONS_PARTICIPANTS = "conversations-participants" CPS = "cps" GROUP_ROOMS_MEDIA_DOWNLOADED = "group-rooms-media-downloaded" GROUP_ROOMS_MEDIA_RECORDED = "group-rooms-media-recorded" GROUP_ROOMS_MEDIA_ROUTED = "group-rooms-media-routed" GROUP_ROOMS_MEDIA_STORED = "group-rooms-media-stored" GROUP_ROOMS_PARTICIPANT_MINUTES = "group-rooms-participant-minutes" GROUP_ROOMS_RECORDED_MINUTES = "group-rooms-recorded-minutes" 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" LOOKUPS = "lookups" MARKETPLACE = "marketplace" MARKETPLACE_ALGORITHMIA_NAMED_ENTITY_RECOGNITION = "marketplace-algorithmia-named-entity-recognition" MARKETPLACE_DIGITAL_SEGMENT_BUSINESS_INFO = "marketplace-digital-segment-business-info" MARKETPLACE_GOOGLE_SPEECH_TO_TEXT = "marketplace-google-speech-to-text" MARKETPLACE_IBM_WATSON_MESSAGE_INSIGHTS = "marketplace-ibm-watson-message-insights" MARKETPLACE_IBM_WATSON_MESSAGE_SENTIMENT = "marketplace-ibm-watson-message-sentiment" MARKETPLACE_IBM_WATSON_RECORDING_ANALYSIS = "marketplace-ibm-watson-recording-analysis" MARKETPLACE_ICEHOOK_SYSTEMS_SCOUT = "marketplace-icehook-systems-scout" MARKETPLACE_INFOGROUP_DATAAXLE_BIZINFO = "marketplace-infogroup-dataaxle-bizinfo" MARKETPLACE_CADENCE_TRANSCRIPTION = "marketplace-cadence-transcription" MARKETPLACE_CADENCE_TRANSLATION = "marketplace-cadence-translation" MARKETPLACE_CAPIO_SPEECH_TO_TEXT = "marketplace-capio-speech-to-text" MARKETPLACE_FACEBOOK_OFFLINE_CONVERSIONS = "marketplace-facebook-offline-conversions" MARKETPLACE_KEEN_IO_CONTACT_CENTER_ANALYTICS = "marketplace-keen-io-contact-center-analytics" MARKETPLACE_MARCHEX_CLEANCALL = "marketplace-marchex-cleancall" MARKETPLACE_MARCHEX_SENTIMENT_ANALYSIS_FOR_SMS = "marketplace-marchex-sentiment-analysis-for-sms" MARKETPLACE_MARKETPLACE_NEXTCALLER_SOCIAL_ID = "marketplace-marketplace-nextcaller-social-id" MARKETPLACE_MOBILE_COMMONS_OPT_OUT_CLASSIFIER = "marketplace-mobile-commons-opt-out-classifier" MARKETPLACE_NEXIWAVE_VOICEMAIL_TO_TEXT = "marketplace-nexiwave-voicemail-to-text" MARKETPLACE_NEXTCALLER_ADVANCED_CALLER_IDENTIFICATION = "marketplace-nextcaller-advanced-caller-identification" MARKETPLACE_NOMOROBO_SPAM_SCORE = "marketplace-nomorobo-spam-score" MARKETPLACE_PAYFONE_TCPA_COMPLIANCE = "marketplace-payfone-tcpa-compliance" MARKETPLACE_TELO_OPENCNAM = "marketplace-telo-opencnam" MARKETPLACE_TRUECNAM_TRUE_SPAM = "marketplace-truecnam-true-spam" MARKETPLACE_TWILIO_CALLER_NAME_LOOKUP_US = "marketplace-twilio-caller-name-lookup-us" MARKETPLACE_TWILIO_CARRIER_INFORMATION_LOOKUP = "marketplace-twilio-carrier-information-lookup" MARKETPLACE_VOICEBASE_PCI = "marketplace-voicebase-pci" MARKETPLACE_VOICEBASE_TRANSCRIPTION = "marketplace-voicebase-transcription" MARKETPLACE_WHITEPAGES_PRO_CALLER_IDENTIFICATION = "marketplace-whitepages-pro-caller-identification" MARKETPLACE_WHITEPAGES_PRO_PHONE_INTELLIGENCE = "marketplace-whitepages-pro-phone-intelligence" MARKETPLACE_WHITEPAGES_PRO_PHONE_REPUTATION = "marketplace-whitepages-pro-phone-reputation" MARKETPLACE_WOLFRAM_SHORT_ANSWER = "marketplace-wolfram-short-answer" MARKETPLACE_WOLFARM_SPOKEN_RESULTS = "marketplace-wolfarm-spoken-results" MARKETPLACE_DEEPGRAM_PHRASE_DETECTOR = "marketplace-deepgram-phrase-detector" MARKETPLACE_CONVRIZA_ABABA = "marketplace-convriza-ababa" MARKETPLACE_IBM_WATSON_TONE_ANALYZER = "marketplace-ibm-watson-tone-analyzer" MARKETPLACE_REMEETING_AUTOMATIC_SPEECH_RECOGNITION = "marketplace-remeeting-automatic-speech-recognition" MARKETPLACE_TCPA_DEFENSE_SOLUTIONS_BLACKLIST_FEED = "marketplace-tcpa-defense-solutions-blacklist-feed" MARKETPLACE_VOICEBASE_TRANSCRIPTION_CUSTOM_VOCABULARY = "marketplace-voicebase-transcription-custom-vocabulary" MARKETPLACE_YTICA_CONTACT_CENTER_REPORTING_ANALYTICS = "marketplace-ytica-contact-center-reporting-analytics" MEDIASTORAGE = "mediastorage" MMS = "mms" MMS_INBOUND = "mms-inbound" MMS_INBOUND_LONGCODE = "mms-inbound-longcode" MMS_INBOUND_SHORTCODE = "mms-inbound-shortcode" MMS_OUTBOUND = "mms-outbound" MMS_OUTBOUND_LONGCODE = "mms-outbound-longcode" MMS_OUTBOUND_SHORTCODE = "mms-outbound-shortcode" MONITOR_READS = "monitor-reads" MONITOR_STORAGE = "monitor-storage" MONITOR_WRITES = "monitor-writes" NOTIFY = "notify" NOTIFY_ACTIONS_ATTEMPTS = "notify-actions-attempts" NOTIFY_CHANNELS = "notify-channels" NUMBER_FORMAT_LOOKUPS = "number-format-lookups" PCHAT = "pchat" PCHAT_ACTIONS = "pchat-actions" PCHAT_APS = "pchat-aps" PCHAT_NOTIFICATIONS = "pchat-notifications" PCHAT_READS = "pchat-reads" PCHAT_USERS = "pchat-users" PCHAT_MESSAGES = "pchat-messages" PEER_TO_PEER_ROOMS_PARTICIPANT_MINUTES = "peer-to-peer-rooms-participant-minutes" PFAX = "pfax" PFAX_MINUTES = "pfax-minutes" PFAX_MINUTES_INBOUND = "pfax-minutes-inbound" PFAX_MINUTES_OUTBOUND = "pfax-minutes-outbound" PFAX_PAGES = "pfax-pages" PHONENUMBERS = "phonenumbers" PHONENUMBERS_CPS = "phonenumbers-cps" PHONENUMBERS_EMERGENCY = "phonenumbers-emergency" PHONENUMBERS_LOCAL = "phonenumbers-local" PHONENUMBERS_MOBILE = "phonenumbers-mobile" PHONENUMBERS_SETUPS = "phonenumbers-setups" PHONENUMBERS_TOLLFREE = "phonenumbers-tollfree" PREMIUMSUPPORT = "premiumsupport" PV = "pv" PV_ROOM_PARTICIPANTS = "pv-room-participants" PV_ROOM_PARTICIPANTS_AU1 = "pv-room-participants-au1" PV_ROOM_PARTICIPANTS_BR1 = "pv-room-participants-br1" PV_ROOM_PARTICIPANTS_IE1 = "pv-room-participants-ie1" PV_ROOM_PARTICIPANTS_JP1 = "pv-room-participants-jp1" PV_ROOM_PARTICIPANTS_SG1 = "pv-room-participants-sg1" PV_ROOM_PARTICIPANTS_US1 = "pv-room-participants-us1" PV_ROOM_PARTICIPANTS_US2 = "pv-room-participants-us2" PV_ROOMS = "pv-rooms" PV_SIP_ENDPOINT_REGISTRATIONS = "pv-sip-endpoint-registrations" RECORDINGS = "recordings" RECORDINGSTORAGE = "recordingstorage" ROOMS_GROUP_MINUTES = "rooms-group-minutes" ROOMS_GROUP_BANDWIDTH = "rooms-group-bandwidth" 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_UK = "shortcodes-uk" SHORTCODES_VANITY = "shortcodes-vanity" SMS = "sms" SMS_INBOUND = "sms-inbound" SMS_INBOUND_LONGCODE = "sms-inbound-longcode" SMS_INBOUND_SHORTCODE = "sms-inbound-shortcode" 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_MESSAGES_FEATURES = "sms-messages-features" SPEECH_RECOGNITION = "speech-recognition" SYNC = "sync" SYNC_ACTIONS = "sync-actions" SYNC_ENDPOINT_HOURS = "sync-endpoint-hours" SYNC_ENDPOINT_HOURS_ABOVE_DAILY_CAP = "sync-endpoint-hours-above-daily-cap" TASKROUTER_TASKS = "taskrouter-tasks" TOTALPRICE = "totalprice" TRANSCRIPTIONS = "transcriptions" TRUNKING_CPS = "trunking-cps" TRUNKING_EMERGENCY_CALLS = "trunking-emergency-calls" TRUNKING_ORIGINATION = "trunking-origination" TRUNKING_ORIGINATION_LOCAL = "trunking-origination-local" TRUNKING_ORIGINATION_MOBILE = "trunking-origination-mobile" TRUNKING_ORIGINATION_TOLLFREE = "trunking-origination-tollfree" TRUNKING_RECORDINGS = "trunking-recordings" TRUNKING_SECURE = "trunking-secure" TRUNKING_TERMINATION = "trunking-termination" TURNMEGABYTES = "turnmegabytes" TURNMEGABYTES_AUSTRALIA = "turnmegabytes-australia" TURNMEGABYTES_BRASIL = "turnmegabytes-brasil" TURNMEGABYTES_INDIA = "turnmegabytes-india" TURNMEGABYTES_IRELAND = "turnmegabytes-ireland" TURNMEGABYTES_JAPAN = "turnmegabytes-japan" TURNMEGABYTES_SINGAPORE = "turnmegabytes-singapore" TURNMEGABYTES_USEAST = "turnmegabytes-useast" TURNMEGABYTES_USWEST = "turnmegabytes-uswest" TWILIO_INTERCONNECT = "twilio-interconnect" VOICE_INSIGHTS = "voice-insights" VOICE_INSIGHTS_AUDIO_TRACE = "voice-insights-audio-trace" VOICE_INSIGHTS_CARRIER_CALLS = "voice-insights-carrier-calls" WIRELESS = "wireless" 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_USAGE = "wireless-usage" WIRELESS_USAGE_COMMANDS = "wireless-usage-commands" WIRELESS_USAGE_COMMANDS_AFRICA = "wireless-usage-commands-africa" WIRELESS_USAGE_COMMANDS_ASIA = "wireless-usage-commands-asia" WIRELESS_USAGE_COMMANDS_CENTRALANDSOUTHAMERICA = "wireless-usage-commands-centralandsouthamerica" WIRELESS_USAGE_COMMANDS_EUROPE = "wireless-usage-commands-europe" WIRELESS_USAGE_COMMANDS_HOME = "wireless-usage-commands-home" WIRELESS_USAGE_COMMANDS_NORTHAMERICA = "wireless-usage-commands-northamerica" WIRELESS_USAGE_COMMANDS_OCEANIA = "wireless-usage-commands-oceania" WIRELESS_USAGE_COMMANDS_ROAMING = "wireless-usage-commands-roaming" WIRELESS_USAGE_DATA = "wireless-usage-data" WIRELESS_USAGE_DATA_AFRICA = "wireless-usage-data-africa" WIRELESS_USAGE_DATA_ASIA = "wireless-usage-data-asia" WIRELESS_USAGE_DATA_CENTRALANDSOUTHAMERICA = "wireless-usage-data-centralandsouthamerica" WIRELESS_USAGE_DATA_CUSTOM_ADDITIONALMB = "wireless-usage-data-custom-additionalmb" WIRELESS_USAGE_DATA_CUSTOM_FIRST5MB = "wireless-usage-data-custom-first5mb" WIRELESS_USAGE_DATA_DOMESTIC_ROAMING = "wireless-usage-data-domestic-roaming" WIRELESS_USAGE_DATA_EUROPE = "wireless-usage-data-europe" WIRELESS_USAGE_DATA_INDIVIDUAL_ADDITIONALGB = "wireless-usage-data-individual-additionalgb" WIRELESS_USAGE_DATA_INDIVIDUAL_FIRSTGB = "wireless-usage-data-individual-firstgb" WIRELESS_USAGE_DATA_INTERNATIONAL_ROAMING_CANADA = "wireless-usage-data-international-roaming-canada" WIRELESS_USAGE_DATA_INTERNATIONAL_ROAMING_INDIA = "wireless-usage-data-international-roaming-india" WIRELESS_USAGE_DATA_INTERNATIONAL_ROAMING_MEXICO = "wireless-usage-data-international-roaming-mexico" WIRELESS_USAGE_DATA_NORTHAMERICA = "wireless-usage-data-northamerica" WIRELESS_USAGE_DATA_OCEANIA = "wireless-usage-data-oceania" WIRELESS_USAGE_DATA_POOLED = "wireless-usage-data-pooled" WIRELESS_USAGE_DATA_POOLED_DOWNLINK = "wireless-usage-data-pooled-downlink" WIRELESS_USAGE_DATA_POOLED_UPLINK = "wireless-usage-data-pooled-uplink" WIRELESS_USAGE_MRC = "wireless-usage-mrc" WIRELESS_USAGE_MRC_CUSTOM = "wireless-usage-mrc-custom" WIRELESS_USAGE_MRC_INDIVIDUAL = "wireless-usage-mrc-individual" WIRELESS_USAGE_MRC_POOLED = "wireless-usage-mrc-pooled" WIRELESS_USAGE_MRC_SUSPENDED = "wireless-usage-mrc-suspended" WIRELESS_USAGE_VOICE = "wireless-usage-voice" WIRELESS_USAGE_SMS = "wireless-usage-sms" def __init__(self, version, payload, account_sid): """ Initialize the YesterdayInstance :returns: twilio.rest.api.v2010.account.usage.record.yesterday.YesterdayInstance :rtype: twilio.rest.api.v2010.account.usage.record.yesterday.YesterdayInstance """ super(YesterdayInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'api_version': payload['api_version'], 'category': payload['category'], 'count': payload['count'], 'count_unit': payload['count_unit'], 'description': payload['description'], 'end_date': deserialize.iso8601_date(payload['end_date']), 'price': deserialize.decimal(payload['price']), 'price_unit': payload['price_unit'], 'start_date': deserialize.iso8601_date(payload['start_date']), 'subresource_uris': payload['subresource_uris'], 'uri': payload['uri'], 'usage': payload['usage'], 'usage_unit': payload['usage_unit'], } # Context self._context = None self._solution = {'account_sid': account_sid,} @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def api_version(self): """ :returns: The api_version :rtype: unicode """ return self._properties['api_version'] @property def category(self): """ :returns: The category :rtype: YesterdayInstance.Category """ return self._properties['category'] @property def count(self): """ :returns: The count :rtype: unicode """ return self._properties['count'] @property def count_unit(self): """ :returns: The count_unit :rtype: unicode """ return self._properties['count_unit'] @property def description(self): """ :returns: The description :rtype: unicode """ return self._properties['description'] @property def end_date(self): """ :returns: The end_date :rtype: date """ return self._properties['end_date'] @property def price(self): """ :returns: The price :rtype: unicode """ return self._properties['price'] @property def price_unit(self): """ :returns: The price_unit :rtype: unicode """ return self._properties['price_unit'] @property def start_date(self): """ :returns: The start_date :rtype: date """ return self._properties['start_date'] @property def subresource_uris(self): """ :returns: The subresource_uris :rtype: unicode """ return self._properties['subresource_uris'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] @property def usage(self): """ :returns: The usage :rtype: unicode """ return self._properties['usage'] @property def usage_unit(self): """ :returns: The usage_unit :rtype: unicode """ return self._properties['usage_unit'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/api/v2010/account/usage/trigger.py000066400000000000000000001014541317472742600247610ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class TriggerList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the TriggerList :param Version version: Version that contains the resource :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.usage.trigger.TriggerList :rtype: twilio.rest.api.v2010.account.usage.trigger.TriggerList """ super(TriggerList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/Usage/Triggers.json'.format(**self._solution) def create(self, callback_url, trigger_value, usage_category, callback_method=values.unset, friendly_name=values.unset, recurring=values.unset, trigger_by=values.unset): """ Create a new TriggerInstance :param unicode callback_url: URL Twilio will request when the trigger fires :param unicode trigger_value: the value at which the trigger will fire :param TriggerInstance.UsageCategory usage_category: The usage category the trigger watches :param unicode callback_method: HTTP method to use with callback_url :param unicode friendly_name: A user-specified, human-readable name for the trigger. :param TriggerInstance.Recurring recurring: How this trigger recurs :param TriggerInstance.TriggerField trigger_by: The field in the UsageRecord that fires the trigger :returns: Newly created TriggerInstance :rtype: twilio.rest.api.v2010.account.usage.trigger.TriggerInstance """ data = values.of({ 'CallbackUrl': callback_url, 'TriggerValue': trigger_value, 'UsageCategory': usage_category, 'CallbackMethod': callback_method, 'FriendlyName': friendly_name, 'Recurring': recurring, 'TriggerBy': trigger_by, }) payload = self._version.create( 'POST', self._uri, data=data, ) return TriggerInstance(self._version, payload, account_sid=self._solution['account_sid'],) def stream(self, recurring=values.unset, trigger_by=values.unset, usage_category=values.unset, limit=None, page_size=None): """ Streams TriggerInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param TriggerInstance.Recurring recurring: Filter by recurring :param TriggerInstance.TriggerField trigger_by: Filter by trigger by :param TriggerInstance.UsageCategory usage_category: Filter by Usage Category :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.usage.trigger.TriggerInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( recurring=recurring, trigger_by=trigger_by, usage_category=usage_category, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, recurring=values.unset, trigger_by=values.unset, usage_category=values.unset, limit=None, page_size=None): """ Lists TriggerInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param TriggerInstance.Recurring recurring: Filter by recurring :param TriggerInstance.TriggerField trigger_by: Filter by trigger by :param TriggerInstance.UsageCategory usage_category: Filter by Usage Category :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.api.v2010.account.usage.trigger.TriggerInstance] """ return list(self.stream( recurring=recurring, trigger_by=trigger_by, usage_category=usage_category, limit=limit, page_size=page_size, )) def page(self, recurring=values.unset, trigger_by=values.unset, usage_category=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of TriggerInstance records from the API. Request is executed immediately :param TriggerInstance.Recurring recurring: Filter by recurring :param TriggerInstance.TriggerField trigger_by: Filter by trigger by :param TriggerInstance.UsageCategory usage_category: Filter by Usage Category :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of TriggerInstance :rtype: twilio.rest.api.v2010.account.usage.trigger.TriggerPage """ params = values.of({ 'Recurring': recurring, 'TriggerBy': trigger_by, 'UsageCategory': usage_category, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return TriggerPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of TriggerInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of TriggerInstance :rtype: twilio.rest.api.v2010.account.usage.trigger.TriggerPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return TriggerPage(self._version, response, self._solution) def get(self, sid): """ Constructs a TriggerContext :param sid: Fetch by unique usage-trigger Sid :returns: twilio.rest.api.v2010.account.usage.trigger.TriggerContext :rtype: twilio.rest.api.v2010.account.usage.trigger.TriggerContext """ return TriggerContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __call__(self, sid): """ Constructs a TriggerContext :param sid: Fetch by unique usage-trigger Sid :returns: twilio.rest.api.v2010.account.usage.trigger.TriggerContext :rtype: twilio.rest.api.v2010.account.usage.trigger.TriggerContext """ return TriggerContext(self._version, account_sid=self._solution['account_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class TriggerPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the TriggerPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: A 34 character string that uniquely identifies this resource. :returns: twilio.rest.api.v2010.account.usage.trigger.TriggerPage :rtype: twilio.rest.api.v2010.account.usage.trigger.TriggerPage """ super(TriggerPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of TriggerInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.usage.trigger.TriggerInstance :rtype: twilio.rest.api.v2010.account.usage.trigger.TriggerInstance """ return TriggerInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class TriggerContext(InstanceContext): """ """ def __init__(self, version, account_sid, sid): """ Initialize the TriggerContext :param Version version: Version that contains the resource :param account_sid: The account_sid :param sid: Fetch by unique usage-trigger Sid :returns: twilio.rest.api.v2010.account.usage.trigger.TriggerContext :rtype: twilio.rest.api.v2010.account.usage.trigger.TriggerContext """ super(TriggerContext, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid, 'sid': sid,} self._uri = '/Accounts/{account_sid}/Usage/Triggers/{sid}.json'.format(**self._solution) def fetch(self): """ Fetch a TriggerInstance :returns: Fetched TriggerInstance :rtype: twilio.rest.api.v2010.account.usage.trigger.TriggerInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return TriggerInstance( self._version, payload, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) def update(self, callback_method=values.unset, callback_url=values.unset, friendly_name=values.unset): """ Update the TriggerInstance :param unicode callback_method: HTTP method to use with callback_url :param unicode callback_url: URL Twilio will request when the trigger fires :param unicode friendly_name: A user-specified, human-readable name for the trigger. :returns: Updated TriggerInstance :rtype: twilio.rest.api.v2010.account.usage.trigger.TriggerInstance """ data = values.of({ 'CallbackMethod': callback_method, 'CallbackUrl': callback_url, 'FriendlyName': friendly_name, }) payload = self._version.update( 'POST', self._uri, data=data, ) return TriggerInstance( self._version, payload, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the TriggerInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class TriggerInstance(InstanceResource): """ """ class UsageCategory(object): ANSWERING_MACHINE_DETECTION = "answering-machine-detection" AUTHY_AUTHENTICATIONS = "authy-authentications" AUTHY_CALLS_OUTBOUND = "authy-calls-outbound" AUTHY_MONTHLY_FEES = "authy-monthly-fees" AUTHY_PHONE_INTELLIGENCE = "authy-phone-intelligence" AUTHY_PHONE_VERIFICATIONS = "authy-phone-verifications" AUTHY_SMS_OUTBOUND = "authy-sms-outbound" CALL_PROGESS_EVENTS = "call-progess-events" CALLERIDLOOKUPS = "calleridlookups" CALLS = "calls" CALLS_CLIENT = "calls-client" 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_OUTBOUND = "calls-outbound" CALLS_RECORDINGS = "calls-recordings" CALLS_SIP = "calls-sip" CALLS_SIP_INBOUND = "calls-sip-inbound" CALLS_SIP_OUTBOUND = "calls-sip-outbound" CARRIER_LOOKUPS = "carrier-lookups" CONVERSATIONS = "conversations" CONVERSATIONS_API_REQUESTS = "conversations-api-requests" CONVERSATIONS_CONVERSATION_EVENTS = "conversations-conversation-events" CONVERSATIONS_ENDPOINT_CONNECTIVITY = "conversations-endpoint-connectivity" CONVERSATIONS_EVENTS = "conversations-events" CONVERSATIONS_PARTICIPANT_EVENTS = "conversations-participant-events" CONVERSATIONS_PARTICIPANTS = "conversations-participants" CPS = "cps" GROUP_ROOMS_MEDIA_DOWNLOADED = "group-rooms-media-downloaded" GROUP_ROOMS_MEDIA_RECORDED = "group-rooms-media-recorded" GROUP_ROOMS_MEDIA_ROUTED = "group-rooms-media-routed" GROUP_ROOMS_MEDIA_STORED = "group-rooms-media-stored" GROUP_ROOMS_PARTICIPANT_MINUTES = "group-rooms-participant-minutes" GROUP_ROOMS_RECORDED_MINUTES = "group-rooms-recorded-minutes" 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" LOOKUPS = "lookups" MARKETPLACE = "marketplace" MARKETPLACE_ALGORITHMIA_NAMED_ENTITY_RECOGNITION = "marketplace-algorithmia-named-entity-recognition" MARKETPLACE_DIGITAL_SEGMENT_BUSINESS_INFO = "marketplace-digital-segment-business-info" MARKETPLACE_GOOGLE_SPEECH_TO_TEXT = "marketplace-google-speech-to-text" MARKETPLACE_IBM_WATSON_MESSAGE_INSIGHTS = "marketplace-ibm-watson-message-insights" MARKETPLACE_IBM_WATSON_MESSAGE_SENTIMENT = "marketplace-ibm-watson-message-sentiment" MARKETPLACE_IBM_WATSON_RECORDING_ANALYSIS = "marketplace-ibm-watson-recording-analysis" MARKETPLACE_ICEHOOK_SYSTEMS_SCOUT = "marketplace-icehook-systems-scout" MARKETPLACE_INFOGROUP_DATAAXLE_BIZINFO = "marketplace-infogroup-dataaxle-bizinfo" MARKETPLACE_CADENCE_TRANSCRIPTION = "marketplace-cadence-transcription" MARKETPLACE_CADENCE_TRANSLATION = "marketplace-cadence-translation" MARKETPLACE_CAPIO_SPEECH_TO_TEXT = "marketplace-capio-speech-to-text" MARKETPLACE_FACEBOOK_OFFLINE_CONVERSIONS = "marketplace-facebook-offline-conversions" MARKETPLACE_KEEN_IO_CONTACT_CENTER_ANALYTICS = "marketplace-keen-io-contact-center-analytics" MARKETPLACE_MARCHEX_CLEANCALL = "marketplace-marchex-cleancall" MARKETPLACE_MARCHEX_SENTIMENT_ANALYSIS_FOR_SMS = "marketplace-marchex-sentiment-analysis-for-sms" MARKETPLACE_MARKETPLACE_NEXTCALLER_SOCIAL_ID = "marketplace-marketplace-nextcaller-social-id" MARKETPLACE_MOBILE_COMMONS_OPT_OUT_CLASSIFIER = "marketplace-mobile-commons-opt-out-classifier" MARKETPLACE_NEXIWAVE_VOICEMAIL_TO_TEXT = "marketplace-nexiwave-voicemail-to-text" MARKETPLACE_NEXTCALLER_ADVANCED_CALLER_IDENTIFICATION = "marketplace-nextcaller-advanced-caller-identification" MARKETPLACE_NOMOROBO_SPAM_SCORE = "marketplace-nomorobo-spam-score" MARKETPLACE_PAYFONE_TCPA_COMPLIANCE = "marketplace-payfone-tcpa-compliance" MARKETPLACE_TELO_OPENCNAM = "marketplace-telo-opencnam" MARKETPLACE_TRUECNAM_TRUE_SPAM = "marketplace-truecnam-true-spam" MARKETPLACE_TWILIO_CALLER_NAME_LOOKUP_US = "marketplace-twilio-caller-name-lookup-us" MARKETPLACE_TWILIO_CARRIER_INFORMATION_LOOKUP = "marketplace-twilio-carrier-information-lookup" MARKETPLACE_VOICEBASE_PCI = "marketplace-voicebase-pci" MARKETPLACE_VOICEBASE_TRANSCRIPTION = "marketplace-voicebase-transcription" MARKETPLACE_WHITEPAGES_PRO_CALLER_IDENTIFICATION = "marketplace-whitepages-pro-caller-identification" MARKETPLACE_WHITEPAGES_PRO_PHONE_INTELLIGENCE = "marketplace-whitepages-pro-phone-intelligence" MARKETPLACE_WHITEPAGES_PRO_PHONE_REPUTATION = "marketplace-whitepages-pro-phone-reputation" MARKETPLACE_WOLFRAM_SHORT_ANSWER = "marketplace-wolfram-short-answer" MARKETPLACE_WOLFARM_SPOKEN_RESULTS = "marketplace-wolfarm-spoken-results" MARKETPLACE_DEEPGRAM_PHRASE_DETECTOR = "marketplace-deepgram-phrase-detector" MARKETPLACE_CONVRIZA_ABABA = "marketplace-convriza-ababa" MARKETPLACE_IBM_WATSON_TONE_ANALYZER = "marketplace-ibm-watson-tone-analyzer" MARKETPLACE_REMEETING_AUTOMATIC_SPEECH_RECOGNITION = "marketplace-remeeting-automatic-speech-recognition" MARKETPLACE_TCPA_DEFENSE_SOLUTIONS_BLACKLIST_FEED = "marketplace-tcpa-defense-solutions-blacklist-feed" MARKETPLACE_VOICEBASE_TRANSCRIPTION_CUSTOM_VOCABULARY = "marketplace-voicebase-transcription-custom-vocabulary" MARKETPLACE_YTICA_CONTACT_CENTER_REPORTING_ANALYTICS = "marketplace-ytica-contact-center-reporting-analytics" MEDIASTORAGE = "mediastorage" MMS = "mms" MMS_INBOUND = "mms-inbound" MMS_INBOUND_LONGCODE = "mms-inbound-longcode" MMS_INBOUND_SHORTCODE = "mms-inbound-shortcode" MMS_OUTBOUND = "mms-outbound" MMS_OUTBOUND_LONGCODE = "mms-outbound-longcode" MMS_OUTBOUND_SHORTCODE = "mms-outbound-shortcode" MONITOR_READS = "monitor-reads" MONITOR_STORAGE = "monitor-storage" MONITOR_WRITES = "monitor-writes" NOTIFY = "notify" NOTIFY_ACTIONS_ATTEMPTS = "notify-actions-attempts" NOTIFY_CHANNELS = "notify-channels" NUMBER_FORMAT_LOOKUPS = "number-format-lookups" PCHAT = "pchat" PCHAT_ACTIONS = "pchat-actions" PCHAT_APS = "pchat-aps" PCHAT_NOTIFICATIONS = "pchat-notifications" PCHAT_READS = "pchat-reads" PCHAT_USERS = "pchat-users" PCHAT_MESSAGES = "pchat-messages" PEER_TO_PEER_ROOMS_PARTICIPANT_MINUTES = "peer-to-peer-rooms-participant-minutes" PFAX = "pfax" PFAX_MINUTES = "pfax-minutes" PFAX_MINUTES_INBOUND = "pfax-minutes-inbound" PFAX_MINUTES_OUTBOUND = "pfax-minutes-outbound" PFAX_PAGES = "pfax-pages" PHONENUMBERS = "phonenumbers" PHONENUMBERS_CPS = "phonenumbers-cps" PHONENUMBERS_EMERGENCY = "phonenumbers-emergency" PHONENUMBERS_LOCAL = "phonenumbers-local" PHONENUMBERS_MOBILE = "phonenumbers-mobile" PHONENUMBERS_SETUPS = "phonenumbers-setups" PHONENUMBERS_TOLLFREE = "phonenumbers-tollfree" PREMIUMSUPPORT = "premiumsupport" PV = "pv" PV_ROOM_PARTICIPANTS = "pv-room-participants" PV_ROOM_PARTICIPANTS_AU1 = "pv-room-participants-au1" PV_ROOM_PARTICIPANTS_BR1 = "pv-room-participants-br1" PV_ROOM_PARTICIPANTS_IE1 = "pv-room-participants-ie1" PV_ROOM_PARTICIPANTS_JP1 = "pv-room-participants-jp1" PV_ROOM_PARTICIPANTS_SG1 = "pv-room-participants-sg1" PV_ROOM_PARTICIPANTS_US1 = "pv-room-participants-us1" PV_ROOM_PARTICIPANTS_US2 = "pv-room-participants-us2" PV_ROOMS = "pv-rooms" PV_SIP_ENDPOINT_REGISTRATIONS = "pv-sip-endpoint-registrations" RECORDINGS = "recordings" RECORDINGSTORAGE = "recordingstorage" ROOMS_GROUP_MINUTES = "rooms-group-minutes" ROOMS_GROUP_BANDWIDTH = "rooms-group-bandwidth" 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_UK = "shortcodes-uk" SHORTCODES_VANITY = "shortcodes-vanity" SMS = "sms" SMS_INBOUND = "sms-inbound" SMS_INBOUND_LONGCODE = "sms-inbound-longcode" SMS_INBOUND_SHORTCODE = "sms-inbound-shortcode" 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_MESSAGES_FEATURES = "sms-messages-features" SPEECH_RECOGNITION = "speech-recognition" SYNC = "sync" SYNC_ACTIONS = "sync-actions" SYNC_ENDPOINT_HOURS = "sync-endpoint-hours" SYNC_ENDPOINT_HOURS_ABOVE_DAILY_CAP = "sync-endpoint-hours-above-daily-cap" TASKROUTER_TASKS = "taskrouter-tasks" TOTALPRICE = "totalprice" TRANSCRIPTIONS = "transcriptions" TRUNKING_CPS = "trunking-cps" TRUNKING_EMERGENCY_CALLS = "trunking-emergency-calls" TRUNKING_ORIGINATION = "trunking-origination" TRUNKING_ORIGINATION_LOCAL = "trunking-origination-local" TRUNKING_ORIGINATION_MOBILE = "trunking-origination-mobile" TRUNKING_ORIGINATION_TOLLFREE = "trunking-origination-tollfree" TRUNKING_RECORDINGS = "trunking-recordings" TRUNKING_SECURE = "trunking-secure" TRUNKING_TERMINATION = "trunking-termination" TURNMEGABYTES = "turnmegabytes" TURNMEGABYTES_AUSTRALIA = "turnmegabytes-australia" TURNMEGABYTES_BRASIL = "turnmegabytes-brasil" TURNMEGABYTES_INDIA = "turnmegabytes-india" TURNMEGABYTES_IRELAND = "turnmegabytes-ireland" TURNMEGABYTES_JAPAN = "turnmegabytes-japan" TURNMEGABYTES_SINGAPORE = "turnmegabytes-singapore" TURNMEGABYTES_USEAST = "turnmegabytes-useast" TURNMEGABYTES_USWEST = "turnmegabytes-uswest" TWILIO_INTERCONNECT = "twilio-interconnect" VOICE_INSIGHTS = "voice-insights" VOICE_INSIGHTS_AUDIO_TRACE = "voice-insights-audio-trace" VOICE_INSIGHTS_CARRIER_CALLS = "voice-insights-carrier-calls" WIRELESS = "wireless" 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_USAGE = "wireless-usage" WIRELESS_USAGE_COMMANDS = "wireless-usage-commands" WIRELESS_USAGE_COMMANDS_AFRICA = "wireless-usage-commands-africa" WIRELESS_USAGE_COMMANDS_ASIA = "wireless-usage-commands-asia" WIRELESS_USAGE_COMMANDS_CENTRALANDSOUTHAMERICA = "wireless-usage-commands-centralandsouthamerica" WIRELESS_USAGE_COMMANDS_EUROPE = "wireless-usage-commands-europe" WIRELESS_USAGE_COMMANDS_HOME = "wireless-usage-commands-home" WIRELESS_USAGE_COMMANDS_NORTHAMERICA = "wireless-usage-commands-northamerica" WIRELESS_USAGE_COMMANDS_OCEANIA = "wireless-usage-commands-oceania" WIRELESS_USAGE_COMMANDS_ROAMING = "wireless-usage-commands-roaming" WIRELESS_USAGE_DATA = "wireless-usage-data" WIRELESS_USAGE_DATA_AFRICA = "wireless-usage-data-africa" WIRELESS_USAGE_DATA_ASIA = "wireless-usage-data-asia" WIRELESS_USAGE_DATA_CENTRALANDSOUTHAMERICA = "wireless-usage-data-centralandsouthamerica" WIRELESS_USAGE_DATA_CUSTOM_ADDITIONALMB = "wireless-usage-data-custom-additionalmb" WIRELESS_USAGE_DATA_CUSTOM_FIRST5MB = "wireless-usage-data-custom-first5mb" WIRELESS_USAGE_DATA_DOMESTIC_ROAMING = "wireless-usage-data-domestic-roaming" WIRELESS_USAGE_DATA_EUROPE = "wireless-usage-data-europe" WIRELESS_USAGE_DATA_INDIVIDUAL_ADDITIONALGB = "wireless-usage-data-individual-additionalgb" WIRELESS_USAGE_DATA_INDIVIDUAL_FIRSTGB = "wireless-usage-data-individual-firstgb" WIRELESS_USAGE_DATA_INTERNATIONAL_ROAMING_CANADA = "wireless-usage-data-international-roaming-canada" WIRELESS_USAGE_DATA_INTERNATIONAL_ROAMING_INDIA = "wireless-usage-data-international-roaming-india" WIRELESS_USAGE_DATA_INTERNATIONAL_ROAMING_MEXICO = "wireless-usage-data-international-roaming-mexico" WIRELESS_USAGE_DATA_NORTHAMERICA = "wireless-usage-data-northamerica" WIRELESS_USAGE_DATA_OCEANIA = "wireless-usage-data-oceania" WIRELESS_USAGE_DATA_POOLED = "wireless-usage-data-pooled" WIRELESS_USAGE_DATA_POOLED_DOWNLINK = "wireless-usage-data-pooled-downlink" WIRELESS_USAGE_DATA_POOLED_UPLINK = "wireless-usage-data-pooled-uplink" WIRELESS_USAGE_MRC = "wireless-usage-mrc" WIRELESS_USAGE_MRC_CUSTOM = "wireless-usage-mrc-custom" WIRELESS_USAGE_MRC_INDIVIDUAL = "wireless-usage-mrc-individual" WIRELESS_USAGE_MRC_POOLED = "wireless-usage-mrc-pooled" WIRELESS_USAGE_MRC_SUSPENDED = "wireless-usage-mrc-suspended" WIRELESS_USAGE_VOICE = "wireless-usage-voice" WIRELESS_USAGE_SMS = "wireless-usage-sms" class Recurring(object): DAILY = "daily" MONTHLY = "monthly" YEARLY = "yearly" ALLTIME = "alltime" class TriggerField(object): COUNT = "count" USAGE = "usage" PRICE = "price" def __init__(self, version, payload, account_sid, sid=None): """ Initialize the TriggerInstance :returns: twilio.rest.api.v2010.account.usage.trigger.TriggerInstance :rtype: twilio.rest.api.v2010.account.usage.trigger.TriggerInstance """ super(TriggerInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'api_version': payload['api_version'], 'callback_method': payload['callback_method'], 'callback_url': payload['callback_url'], 'current_value': payload['current_value'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_fired': deserialize.rfc2822_datetime(payload['date_fired']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'friendly_name': payload['friendly_name'], 'recurring': payload['recurring'], 'sid': payload['sid'], 'trigger_by': payload['trigger_by'], 'trigger_value': payload['trigger_value'], 'uri': payload['uri'], 'usage_category': payload['usage_category'], 'usage_record_uri': payload['usage_record_uri'], } # Context self._context = None self._solution = {'account_sid': account_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: TriggerContext for this TriggerInstance :rtype: twilio.rest.api.v2010.account.usage.trigger.TriggerContext """ if self._context is None: self._context = TriggerContext( self._version, account_sid=self._solution['account_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: The account this trigger monitors. :rtype: unicode """ return self._properties['account_sid'] @property def api_version(self): """ :returns: The api_version :rtype: unicode """ return self._properties['api_version'] @property def callback_method(self): """ :returns: HTTP method to use with callback_url :rtype: unicode """ return self._properties['callback_method'] @property def callback_url(self): """ :returns: URL Twilio will request when the trigger fires :rtype: unicode """ return self._properties['callback_url'] @property def current_value(self): """ :returns: The current value of the field the trigger is watching. :rtype: unicode """ return self._properties['current_value'] @property def date_created(self): """ :returns: The date this resource was created :rtype: datetime """ return self._properties['date_created'] @property def date_fired(self): """ :returns: The date the trigger was last fired :rtype: datetime """ return self._properties['date_fired'] @property def date_updated(self): """ :returns: The date this resource was last updated :rtype: datetime """ return self._properties['date_updated'] @property def friendly_name(self): """ :returns: A user-specified, human-readable name for the trigger. :rtype: unicode """ return self._properties['friendly_name'] @property def recurring(self): """ :returns: How this trigger recurs :rtype: TriggerInstance.Recurring """ return self._properties['recurring'] @property def sid(self): """ :returns: The trigger's unique Sid :rtype: unicode """ return self._properties['sid'] @property def trigger_by(self): """ :returns: The field in the UsageRecord that fires the trigger :rtype: TriggerInstance.TriggerField """ return self._properties['trigger_by'] @property def trigger_value(self): """ :returns: the value at which the trigger will fire :rtype: unicode """ return self._properties['trigger_value'] @property def uri(self): """ :returns: The URI for this resource :rtype: unicode """ return self._properties['uri'] @property def usage_category(self): """ :returns: The usage category the trigger watches :rtype: TriggerInstance.UsageCategory """ return self._properties['usage_category'] @property def usage_record_uri(self): """ :returns: The URI of the UsageRecord this trigger is watching :rtype: unicode """ return self._properties['usage_record_uri'] def fetch(self): """ Fetch a TriggerInstance :returns: Fetched TriggerInstance :rtype: twilio.rest.api.v2010.account.usage.trigger.TriggerInstance """ return self._proxy.fetch() def update(self, callback_method=values.unset, callback_url=values.unset, friendly_name=values.unset): """ Update the TriggerInstance :param unicode callback_method: HTTP method to use with callback_url :param unicode callback_url: URL Twilio will request when the trigger fires :param unicode friendly_name: A user-specified, human-readable name for the trigger. :returns: Updated TriggerInstance :rtype: twilio.rest.api.v2010.account.usage.trigger.TriggerInstance """ return self._proxy.update( callback_method=callback_method, callback_url=callback_url, friendly_name=friendly_name, ) def delete(self): """ Deletes the TriggerInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/api/v2010/account/validation_request.py000066400000000000000000000133761317472742600261210ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class ValidationRequestList(ListResource): """ """ def __init__(self, version, account_sid): """ Initialize the ValidationRequestList :param Version version: Version that contains the resource :param account_sid: The account_sid :returns: twilio.rest.api.v2010.account.validation_request.ValidationRequestList :rtype: twilio.rest.api.v2010.account.validation_request.ValidationRequestList """ super(ValidationRequestList, self).__init__(version) # Path Solution self._solution = {'account_sid': account_sid,} self._uri = '/Accounts/{account_sid}/OutgoingCallerIds.json'.format(**self._solution) def create(self, phone_number, friendly_name=values.unset, call_delay=values.unset, extension=values.unset, status_callback=values.unset, status_callback_method=values.unset): """ Create a new ValidationRequestInstance :param unicode phone_number: The phone_number :param unicode friendly_name: The friendly_name :param unicode call_delay: The call_delay :param unicode extension: The extension :param unicode status_callback: The status_callback :param unicode status_callback_method: The status_callback_method :returns: Newly created ValidationRequestInstance :rtype: twilio.rest.api.v2010.account.validation_request.ValidationRequestInstance """ data = values.of({ 'PhoneNumber': phone_number, 'FriendlyName': friendly_name, 'CallDelay': call_delay, 'Extension': extension, 'StatusCallback': status_callback, 'StatusCallbackMethod': status_callback_method, }) payload = self._version.create( 'POST', self._uri, data=data, ) return ValidationRequestInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ValidationRequestPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the ValidationRequestPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :returns: twilio.rest.api.v2010.account.validation_request.ValidationRequestPage :rtype: twilio.rest.api.v2010.account.validation_request.ValidationRequestPage """ super(ValidationRequestPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of ValidationRequestInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.validation_request.ValidationRequestInstance :rtype: twilio.rest.api.v2010.account.validation_request.ValidationRequestInstance """ return ValidationRequestInstance(self._version, payload, account_sid=self._solution['account_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ValidationRequestInstance(InstanceResource): """ """ def __init__(self, version, payload, account_sid): """ Initialize the ValidationRequestInstance :returns: twilio.rest.api.v2010.account.validation_request.ValidationRequestInstance :rtype: twilio.rest.api.v2010.account.validation_request.ValidationRequestInstance """ super(ValidationRequestInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'phone_number': payload['phone_number'], 'friendly_name': payload['friendly_name'], 'validation_code': deserialize.integer(payload['validation_code']), 'call_sid': payload['call_sid'], } # Context self._context = None self._solution = {'account_sid': account_sid,} @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def phone_number(self): """ :returns: The phone_number :rtype: unicode """ return self._properties['phone_number'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def validation_code(self): """ :returns: The validation_code :rtype: unicode """ return self._properties['validation_code'] @property def call_sid(self): """ :returns: The call_sid :rtype: unicode """ return self._properties['call_sid'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/chat/000077500000000000000000000000001317472742600175755ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/chat/__init__.py000066400000000000000000000027601317472742600217130ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.domain import Domain from twilio.rest.chat.v1 import V1 from twilio.rest.chat.v2 import V2 class Chat(Domain): def __init__(self, twilio): """ Initialize the Chat Domain :returns: Domain for Chat :rtype: twilio.rest.chat.Chat """ super(Chat, self).__init__(twilio) self.base_url = 'https://chat.twilio.com' # Versions self._v1 = None self._v2 = None @property def v1(self): """ :returns: Version v1 of chat :rtype: twilio.rest.chat.v1.V1 """ if self._v1 is None: self._v1 = V1(self) return self._v1 @property def v2(self): """ :returns: Version v2 of chat :rtype: twilio.rest.chat.v2.V2 """ if self._v2 is None: self._v2 = V2(self) return self._v2 @property def credentials(self): """ :rtype: twilio.rest.chat.v2.credential.CredentialList """ return self.v2.credentials @property def services(self): """ :rtype: twilio.rest.chat.v2.service.ServiceList """ return self.v2.services def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/chat/v1/000077500000000000000000000000001317472742600201235ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/chat/v1/__init__.py000066400000000000000000000024011317472742600222310ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.version import Version from twilio.rest.chat.v1.credential import CredentialList from twilio.rest.chat.v1.service import ServiceList class V1(Version): def __init__(self, domain): """ Initialize the V1 version of Chat :returns: V1 version of Chat :rtype: twilio.rest.chat.v1.V1.V1 """ super(V1, self).__init__(domain) self.version = 'v1' self._credentials = None self._services = None @property def credentials(self): """ :rtype: twilio.rest.chat.v1.credential.CredentialList """ if self._credentials is None: self._credentials = CredentialList(self) return self._credentials @property def services(self): """ :rtype: twilio.rest.chat.v1.service.ServiceList """ if self._services is None: self._services = ServiceList(self) return self._services def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/chat/v1/credential.py000066400000000000000000000350461317472742600226170ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class CredentialList(ListResource): """ """ def __init__(self, version): """ Initialize the CredentialList :param Version version: Version that contains the resource :returns: twilio.rest.chat.v1.credential.CredentialList :rtype: twilio.rest.chat.v1.credential.CredentialList """ super(CredentialList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/Credentials'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams CredentialInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v1.credential.CredentialInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists CredentialInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v1.credential.CredentialInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of CredentialInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of CredentialInstance :rtype: twilio.rest.chat.v1.credential.CredentialPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return CredentialPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of CredentialInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of CredentialInstance :rtype: twilio.rest.chat.v1.credential.CredentialPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return CredentialPage(self._version, response, self._solution) def create(self, type, friendly_name=values.unset, certificate=values.unset, private_key=values.unset, sandbox=values.unset, api_key=values.unset, secret=values.unset): """ Create a new CredentialInstance :param CredentialInstance.PushService type: The type :param unicode friendly_name: The friendly_name :param unicode certificate: The certificate :param unicode private_key: The private_key :param bool sandbox: The sandbox :param unicode api_key: The api_key :param unicode secret: The secret :returns: Newly created CredentialInstance :rtype: twilio.rest.chat.v1.credential.CredentialInstance """ data = values.of({ 'Type': type, 'FriendlyName': friendly_name, 'Certificate': certificate, 'PrivateKey': private_key, 'Sandbox': sandbox, 'ApiKey': api_key, 'Secret': secret, }) payload = self._version.create( 'POST', self._uri, data=data, ) return CredentialInstance(self._version, payload,) def get(self, sid): """ Constructs a CredentialContext :param sid: The sid :returns: twilio.rest.chat.v1.credential.CredentialContext :rtype: twilio.rest.chat.v1.credential.CredentialContext """ return CredentialContext(self._version, sid=sid,) def __call__(self, sid): """ Constructs a CredentialContext :param sid: The sid :returns: twilio.rest.chat.v1.credential.CredentialContext :rtype: twilio.rest.chat.v1.credential.CredentialContext """ return CredentialContext(self._version, sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class CredentialPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the CredentialPage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.chat.v1.credential.CredentialPage :rtype: twilio.rest.chat.v1.credential.CredentialPage """ super(CredentialPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of CredentialInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v1.credential.CredentialInstance :rtype: twilio.rest.chat.v1.credential.CredentialInstance """ return CredentialInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class CredentialContext(InstanceContext): """ """ def __init__(self, version, sid): """ Initialize the CredentialContext :param Version version: Version that contains the resource :param sid: The sid :returns: twilio.rest.chat.v1.credential.CredentialContext :rtype: twilio.rest.chat.v1.credential.CredentialContext """ super(CredentialContext, self).__init__(version) # Path Solution self._solution = {'sid': sid,} self._uri = '/Credentials/{sid}'.format(**self._solution) def fetch(self): """ Fetch a CredentialInstance :returns: Fetched CredentialInstance :rtype: twilio.rest.chat.v1.credential.CredentialInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return CredentialInstance(self._version, payload, sid=self._solution['sid'],) def update(self, friendly_name=values.unset, certificate=values.unset, private_key=values.unset, sandbox=values.unset, api_key=values.unset, secret=values.unset): """ Update the CredentialInstance :param unicode friendly_name: The friendly_name :param unicode certificate: The certificate :param unicode private_key: The private_key :param bool sandbox: The sandbox :param unicode api_key: The api_key :param unicode secret: The secret :returns: Updated CredentialInstance :rtype: twilio.rest.chat.v1.credential.CredentialInstance """ data = values.of({ 'FriendlyName': friendly_name, 'Certificate': certificate, 'PrivateKey': private_key, 'Sandbox': sandbox, 'ApiKey': api_key, 'Secret': secret, }) payload = self._version.update( 'POST', self._uri, data=data, ) return CredentialInstance(self._version, payload, sid=self._solution['sid'],) def delete(self): """ Deletes the CredentialInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class CredentialInstance(InstanceResource): """ """ class PushService(object): GCM = "gcm" APN = "apn" FCM = "fcm" def __init__(self, version, payload, sid=None): """ Initialize the CredentialInstance :returns: twilio.rest.chat.v1.credential.CredentialInstance :rtype: twilio.rest.chat.v1.credential.CredentialInstance """ super(CredentialInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'friendly_name': payload['friendly_name'], 'type': payload['type'], 'sandbox': payload['sandbox'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'url': payload['url'], } # Context self._context = None self._solution = {'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: CredentialContext for this CredentialInstance :rtype: twilio.rest.chat.v1.credential.CredentialContext """ if self._context is None: self._context = CredentialContext(self._version, sid=self._solution['sid'],) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def type(self): """ :returns: The type :rtype: CredentialInstance.PushService """ return self._properties['type'] @property def sandbox(self): """ :returns: The sandbox :rtype: unicode """ return self._properties['sandbox'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a CredentialInstance :returns: Fetched CredentialInstance :rtype: twilio.rest.chat.v1.credential.CredentialInstance """ return self._proxy.fetch() def update(self, friendly_name=values.unset, certificate=values.unset, private_key=values.unset, sandbox=values.unset, api_key=values.unset, secret=values.unset): """ Update the CredentialInstance :param unicode friendly_name: The friendly_name :param unicode certificate: The certificate :param unicode private_key: The private_key :param bool sandbox: The sandbox :param unicode api_key: The api_key :param unicode secret: The secret :returns: Updated CredentialInstance :rtype: twilio.rest.chat.v1.credential.CredentialInstance """ return self._proxy.update( friendly_name=friendly_name, certificate=certificate, private_key=private_key, sandbox=sandbox, api_key=api_key, secret=secret, ) def delete(self): """ Deletes the CredentialInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/chat/v1/service/000077500000000000000000000000001317472742600215635ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/chat/v1/service/__init__.py000066400000000000000000001405141317472742600237010ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.chat.v1.service.channel import ChannelList from twilio.rest.chat.v1.service.role import RoleList from twilio.rest.chat.v1.service.user import UserList class ServiceList(ListResource): """ """ def __init__(self, version): """ Initialize the ServiceList :param Version version: Version that contains the resource :returns: twilio.rest.chat.v1.service.ServiceList :rtype: twilio.rest.chat.v1.service.ServiceList """ super(ServiceList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/Services'.format(**self._solution) def create(self, friendly_name): """ Create a new ServiceInstance :param unicode friendly_name: The friendly_name :returns: Newly created ServiceInstance :rtype: twilio.rest.chat.v1.service.ServiceInstance """ data = values.of({'FriendlyName': friendly_name,}) payload = self._version.create( 'POST', self._uri, data=data, ) return ServiceInstance(self._version, payload,) def stream(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v1.service.ServiceInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v1.service.ServiceInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of ServiceInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of ServiceInstance :rtype: twilio.rest.chat.v1.service.ServicePage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return ServicePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of ServiceInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of ServiceInstance :rtype: twilio.rest.chat.v1.service.ServicePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return ServicePage(self._version, response, self._solution) def get(self, sid): """ Constructs a ServiceContext :param sid: The sid :returns: twilio.rest.chat.v1.service.ServiceContext :rtype: twilio.rest.chat.v1.service.ServiceContext """ return ServiceContext(self._version, sid=sid,) def __call__(self, sid): """ Constructs a ServiceContext :param sid: The sid :returns: twilio.rest.chat.v1.service.ServiceContext :rtype: twilio.rest.chat.v1.service.ServiceContext """ return ServiceContext(self._version, sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ServicePage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the ServicePage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.chat.v1.service.ServicePage :rtype: twilio.rest.chat.v1.service.ServicePage """ super(ServicePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of ServiceInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v1.service.ServiceInstance :rtype: twilio.rest.chat.v1.service.ServiceInstance """ return ServiceInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ServiceContext(InstanceContext): """ """ def __init__(self, version, sid): """ Initialize the ServiceContext :param Version version: Version that contains the resource :param sid: The sid :returns: twilio.rest.chat.v1.service.ServiceContext :rtype: twilio.rest.chat.v1.service.ServiceContext """ super(ServiceContext, self).__init__(version) # Path Solution self._solution = {'sid': sid,} self._uri = '/Services/{sid}'.format(**self._solution) # Dependents self._channels = None self._roles = None self._users = None def fetch(self): """ Fetch a ServiceInstance :returns: Fetched ServiceInstance :rtype: twilio.rest.chat.v1.service.ServiceInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return ServiceInstance(self._version, payload, sid=self._solution['sid'],) def delete(self): """ Deletes the ServiceInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, friendly_name=values.unset, default_service_role_sid=values.unset, default_channel_role_sid=values.unset, default_channel_creator_role_sid=values.unset, read_status_enabled=values.unset, reachability_enabled=values.unset, typing_indicator_timeout=values.unset, consumption_report_interval=values.unset, notifications_new_message_enabled=values.unset, notifications_new_message_template=values.unset, notifications_added_to_channel_enabled=values.unset, notifications_added_to_channel_template=values.unset, notifications_removed_from_channel_enabled=values.unset, notifications_removed_from_channel_template=values.unset, notifications_invited_to_channel_enabled=values.unset, notifications_invited_to_channel_template=values.unset, pre_webhook_url=values.unset, post_webhook_url=values.unset, webhook_method=values.unset, webhook_filters=values.unset, webhooks_on_message_send_url=values.unset, webhooks_on_message_send_method=values.unset, webhooks_on_message_send_format=values.unset, webhooks_on_message_update_url=values.unset, webhooks_on_message_update_method=values.unset, webhooks_on_message_update_format=values.unset, webhooks_on_message_remove_url=values.unset, webhooks_on_message_remove_method=values.unset, webhooks_on_message_remove_format=values.unset, webhooks_on_channel_add_url=values.unset, webhooks_on_channel_add_method=values.unset, webhooks_on_channel_add_format=values.unset, webhooks_on_channel_destroy_url=values.unset, webhooks_on_channel_destroy_method=values.unset, webhooks_on_channel_destroy_format=values.unset, webhooks_on_channel_update_url=values.unset, webhooks_on_channel_update_method=values.unset, webhooks_on_channel_update_format=values.unset, webhooks_on_member_add_url=values.unset, webhooks_on_member_add_method=values.unset, webhooks_on_member_add_format=values.unset, webhooks_on_member_remove_url=values.unset, webhooks_on_member_remove_method=values.unset, webhooks_on_member_remove_format=values.unset, webhooks_on_message_sent_url=values.unset, webhooks_on_message_sent_method=values.unset, webhooks_on_message_sent_format=values.unset, webhooks_on_message_updated_url=values.unset, webhooks_on_message_updated_method=values.unset, webhooks_on_message_updated_format=values.unset, webhooks_on_message_removed_url=values.unset, webhooks_on_message_removed_method=values.unset, webhooks_on_message_removed_format=values.unset, webhooks_on_channel_added_url=values.unset, webhooks_on_channel_added_method=values.unset, webhooks_on_channel_added_format=values.unset, webhooks_on_channel_destroyed_url=values.unset, webhooks_on_channel_destroyed_method=values.unset, webhooks_on_channel_destroyed_format=values.unset, webhooks_on_channel_updated_url=values.unset, webhooks_on_channel_updated_method=values.unset, webhooks_on_channel_updated_format=values.unset, webhooks_on_member_added_url=values.unset, webhooks_on_member_added_method=values.unset, webhooks_on_member_added_format=values.unset, webhooks_on_member_removed_url=values.unset, webhooks_on_member_removed_method=values.unset, webhooks_on_member_removed_format=values.unset, limits_channel_members=values.unset, limits_user_channels=values.unset): """ Update the ServiceInstance :param unicode friendly_name: The friendly_name :param unicode default_service_role_sid: The default_service_role_sid :param unicode default_channel_role_sid: The default_channel_role_sid :param unicode default_channel_creator_role_sid: The default_channel_creator_role_sid :param bool read_status_enabled: The read_status_enabled :param bool reachability_enabled: The reachability_enabled :param unicode typing_indicator_timeout: The typing_indicator_timeout :param unicode consumption_report_interval: The consumption_report_interval :param bool notifications_new_message_enabled: The notifications.new_message.enabled :param unicode notifications_new_message_template: The notifications.new_message.template :param bool notifications_added_to_channel_enabled: The notifications.added_to_channel.enabled :param unicode notifications_added_to_channel_template: The notifications.added_to_channel.template :param bool notifications_removed_from_channel_enabled: The notifications.removed_from_channel.enabled :param unicode notifications_removed_from_channel_template: The notifications.removed_from_channel.template :param bool notifications_invited_to_channel_enabled: The notifications.invited_to_channel.enabled :param unicode notifications_invited_to_channel_template: The notifications.invited_to_channel.template :param unicode pre_webhook_url: The pre_webhook_url :param unicode post_webhook_url: The post_webhook_url :param unicode webhook_method: The webhook_method :param unicode webhook_filters: The webhook_filters :param unicode webhooks_on_message_send_url: The webhooks.on_message_send.url :param unicode webhooks_on_message_send_method: The webhooks.on_message_send.method :param unicode webhooks_on_message_send_format: The webhooks.on_message_send.format :param unicode webhooks_on_message_update_url: The webhooks.on_message_update.url :param unicode webhooks_on_message_update_method: The webhooks.on_message_update.method :param unicode webhooks_on_message_update_format: The webhooks.on_message_update.format :param unicode webhooks_on_message_remove_url: The webhooks.on_message_remove.url :param unicode webhooks_on_message_remove_method: The webhooks.on_message_remove.method :param unicode webhooks_on_message_remove_format: The webhooks.on_message_remove.format :param unicode webhooks_on_channel_add_url: The webhooks.on_channel_add.url :param unicode webhooks_on_channel_add_method: The webhooks.on_channel_add.method :param unicode webhooks_on_channel_add_format: The webhooks.on_channel_add.format :param unicode webhooks_on_channel_destroy_url: The webhooks.on_channel_destroy.url :param unicode webhooks_on_channel_destroy_method: The webhooks.on_channel_destroy.method :param unicode webhooks_on_channel_destroy_format: The webhooks.on_channel_destroy.format :param unicode webhooks_on_channel_update_url: The webhooks.on_channel_update.url :param unicode webhooks_on_channel_update_method: The webhooks.on_channel_update.method :param unicode webhooks_on_channel_update_format: The webhooks.on_channel_update.format :param unicode webhooks_on_member_add_url: The webhooks.on_member_add.url :param unicode webhooks_on_member_add_method: The webhooks.on_member_add.method :param unicode webhooks_on_member_add_format: The webhooks.on_member_add.format :param unicode webhooks_on_member_remove_url: The webhooks.on_member_remove.url :param unicode webhooks_on_member_remove_method: The webhooks.on_member_remove.method :param unicode webhooks_on_member_remove_format: The webhooks.on_member_remove.format :param unicode webhooks_on_message_sent_url: The webhooks.on_message_sent.url :param unicode webhooks_on_message_sent_method: The webhooks.on_message_sent.method :param unicode webhooks_on_message_sent_format: The webhooks.on_message_sent.format :param unicode webhooks_on_message_updated_url: The webhooks.on_message_updated.url :param unicode webhooks_on_message_updated_method: The webhooks.on_message_updated.method :param unicode webhooks_on_message_updated_format: The webhooks.on_message_updated.format :param unicode webhooks_on_message_removed_url: The webhooks.on_message_removed.url :param unicode webhooks_on_message_removed_method: The webhooks.on_message_removed.method :param unicode webhooks_on_message_removed_format: The webhooks.on_message_removed.format :param unicode webhooks_on_channel_added_url: The webhooks.on_channel_added.url :param unicode webhooks_on_channel_added_method: The webhooks.on_channel_added.method :param unicode webhooks_on_channel_added_format: The webhooks.on_channel_added.format :param unicode webhooks_on_channel_destroyed_url: The webhooks.on_channel_destroyed.url :param unicode webhooks_on_channel_destroyed_method: The webhooks.on_channel_destroyed.method :param unicode webhooks_on_channel_destroyed_format: The webhooks.on_channel_destroyed.format :param unicode webhooks_on_channel_updated_url: The webhooks.on_channel_updated.url :param unicode webhooks_on_channel_updated_method: The webhooks.on_channel_updated.method :param unicode webhooks_on_channel_updated_format: The webhooks.on_channel_updated.format :param unicode webhooks_on_member_added_url: The webhooks.on_member_added.url :param unicode webhooks_on_member_added_method: The webhooks.on_member_added.method :param unicode webhooks_on_member_added_format: The webhooks.on_member_added.format :param unicode webhooks_on_member_removed_url: The webhooks.on_member_removed.url :param unicode webhooks_on_member_removed_method: The webhooks.on_member_removed.method :param unicode webhooks_on_member_removed_format: The webhooks.on_member_removed.format :param unicode limits_channel_members: The limits.channel_members :param unicode limits_user_channels: The limits.user_channels :returns: Updated ServiceInstance :rtype: twilio.rest.chat.v1.service.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, 'TypingIndicatorTimeout': typing_indicator_timeout, 'ConsumptionReportInterval': consumption_report_interval, 'Notifications.NewMessage.Enabled': notifications_new_message_enabled, 'Notifications.NewMessage.Template': notifications_new_message_template, 'Notifications.AddedToChannel.Enabled': notifications_added_to_channel_enabled, 'Notifications.AddedToChannel.Template': notifications_added_to_channel_template, 'Notifications.RemovedFromChannel.Enabled': notifications_removed_from_channel_enabled, 'Notifications.RemovedFromChannel.Template': notifications_removed_from_channel_template, 'Notifications.InvitedToChannel.Enabled': notifications_invited_to_channel_enabled, 'Notifications.InvitedToChannel.Template': notifications_invited_to_channel_template, 'PreWebhookUrl': pre_webhook_url, 'PostWebhookUrl': post_webhook_url, 'WebhookMethod': webhook_method, 'WebhookFilters': webhook_filters, 'Webhooks.OnMessageSend.Url': webhooks_on_message_send_url, 'Webhooks.OnMessageSend.Method': webhooks_on_message_send_method, 'Webhooks.OnMessageSend.Format': webhooks_on_message_send_format, 'Webhooks.OnMessageUpdate.Url': webhooks_on_message_update_url, 'Webhooks.OnMessageUpdate.Method': webhooks_on_message_update_method, 'Webhooks.OnMessageUpdate.Format': webhooks_on_message_update_format, 'Webhooks.OnMessageRemove.Url': webhooks_on_message_remove_url, 'Webhooks.OnMessageRemove.Method': webhooks_on_message_remove_method, 'Webhooks.OnMessageRemove.Format': webhooks_on_message_remove_format, 'Webhooks.OnChannelAdd.Url': webhooks_on_channel_add_url, 'Webhooks.OnChannelAdd.Method': webhooks_on_channel_add_method, 'Webhooks.OnChannelAdd.Format': webhooks_on_channel_add_format, 'Webhooks.OnChannelDestroy.Url': webhooks_on_channel_destroy_url, 'Webhooks.OnChannelDestroy.Method': webhooks_on_channel_destroy_method, 'Webhooks.OnChannelDestroy.Format': webhooks_on_channel_destroy_format, 'Webhooks.OnChannelUpdate.Url': webhooks_on_channel_update_url, 'Webhooks.OnChannelUpdate.Method': webhooks_on_channel_update_method, 'Webhooks.OnChannelUpdate.Format': webhooks_on_channel_update_format, 'Webhooks.OnMemberAdd.Url': webhooks_on_member_add_url, 'Webhooks.OnMemberAdd.Method': webhooks_on_member_add_method, 'Webhooks.OnMemberAdd.Format': webhooks_on_member_add_format, 'Webhooks.OnMemberRemove.Url': webhooks_on_member_remove_url, 'Webhooks.OnMemberRemove.Method': webhooks_on_member_remove_method, 'Webhooks.OnMemberRemove.Format': webhooks_on_member_remove_format, 'Webhooks.OnMessageSent.Url': webhooks_on_message_sent_url, 'Webhooks.OnMessageSent.Method': webhooks_on_message_sent_method, 'Webhooks.OnMessageSent.Format': webhooks_on_message_sent_format, 'Webhooks.OnMessageUpdated.Url': webhooks_on_message_updated_url, 'Webhooks.OnMessageUpdated.Method': webhooks_on_message_updated_method, 'Webhooks.OnMessageUpdated.Format': webhooks_on_message_updated_format, 'Webhooks.OnMessageRemoved.Url': webhooks_on_message_removed_url, 'Webhooks.OnMessageRemoved.Method': webhooks_on_message_removed_method, 'Webhooks.OnMessageRemoved.Format': webhooks_on_message_removed_format, 'Webhooks.OnChannelAdded.Url': webhooks_on_channel_added_url, 'Webhooks.OnChannelAdded.Method': webhooks_on_channel_added_method, 'Webhooks.OnChannelAdded.Format': webhooks_on_channel_added_format, 'Webhooks.OnChannelDestroyed.Url': webhooks_on_channel_destroyed_url, 'Webhooks.OnChannelDestroyed.Method': webhooks_on_channel_destroyed_method, 'Webhooks.OnChannelDestroyed.Format': webhooks_on_channel_destroyed_format, 'Webhooks.OnChannelUpdated.Url': webhooks_on_channel_updated_url, 'Webhooks.OnChannelUpdated.Method': webhooks_on_channel_updated_method, 'Webhooks.OnChannelUpdated.Format': webhooks_on_channel_updated_format, 'Webhooks.OnMemberAdded.Url': webhooks_on_member_added_url, 'Webhooks.OnMemberAdded.Method': webhooks_on_member_added_method, 'Webhooks.OnMemberAdded.Format': webhooks_on_member_added_format, 'Webhooks.OnMemberRemoved.Url': webhooks_on_member_removed_url, 'Webhooks.OnMemberRemoved.Method': webhooks_on_member_removed_method, 'Webhooks.OnMemberRemoved.Format': webhooks_on_member_removed_format, 'Limits.ChannelMembers': limits_channel_members, 'Limits.UserChannels': limits_user_channels, }) payload = self._version.update( 'POST', self._uri, data=data, ) return ServiceInstance(self._version, payload, sid=self._solution['sid'],) @property def channels(self): """ Access the channels :returns: twilio.rest.chat.v1.service.channel.ChannelList :rtype: twilio.rest.chat.v1.service.channel.ChannelList """ if self._channels is None: self._channels = ChannelList(self._version, service_sid=self._solution['sid'],) return self._channels @property def roles(self): """ Access the roles :returns: twilio.rest.chat.v1.service.role.RoleList :rtype: twilio.rest.chat.v1.service.role.RoleList """ if self._roles is None: self._roles = RoleList(self._version, service_sid=self._solution['sid'],) return self._roles @property def users(self): """ Access the users :returns: twilio.rest.chat.v1.service.user.UserList :rtype: twilio.rest.chat.v1.service.user.UserList """ if self._users is None: self._users = UserList(self._version, service_sid=self._solution['sid'],) return self._users def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class ServiceInstance(InstanceResource): """ """ def __init__(self, version, payload, sid=None): """ Initialize the ServiceInstance :returns: twilio.rest.chat.v1.service.ServiceInstance :rtype: twilio.rest.chat.v1.service.ServiceInstance """ super(ServiceInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'friendly_name': payload['friendly_name'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'default_service_role_sid': payload['default_service_role_sid'], 'default_channel_role_sid': payload['default_channel_role_sid'], 'default_channel_creator_role_sid': payload['default_channel_creator_role_sid'], 'read_status_enabled': payload['read_status_enabled'], 'reachability_enabled': payload['reachability_enabled'], 'typing_indicator_timeout': deserialize.integer(payload['typing_indicator_timeout']), 'consumption_report_interval': deserialize.integer(payload['consumption_report_interval']), 'limits': payload['limits'], 'webhooks': payload['webhooks'], 'pre_webhook_url': payload['pre_webhook_url'], 'post_webhook_url': payload['post_webhook_url'], 'webhook_method': payload['webhook_method'], 'webhook_filters': payload['webhook_filters'], 'notifications': payload['notifications'], 'url': payload['url'], 'links': payload['links'], } # Context self._context = None self._solution = {'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.chat.v1.service.ServiceContext """ if self._context is None: self._context = ServiceContext(self._version, sid=self._solution['sid'],) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def default_service_role_sid(self): """ :returns: The default_service_role_sid :rtype: unicode """ return self._properties['default_service_role_sid'] @property def default_channel_role_sid(self): """ :returns: The default_channel_role_sid :rtype: unicode """ return self._properties['default_channel_role_sid'] @property def default_channel_creator_role_sid(self): """ :returns: The default_channel_creator_role_sid :rtype: unicode """ return self._properties['default_channel_creator_role_sid'] @property def read_status_enabled(self): """ :returns: The read_status_enabled :rtype: bool """ return self._properties['read_status_enabled'] @property def reachability_enabled(self): """ :returns: The reachability_enabled :rtype: bool """ return self._properties['reachability_enabled'] @property def typing_indicator_timeout(self): """ :returns: The typing_indicator_timeout :rtype: unicode """ return self._properties['typing_indicator_timeout'] @property def consumption_report_interval(self): """ :returns: The consumption_report_interval :rtype: unicode """ return self._properties['consumption_report_interval'] @property def limits(self): """ :returns: The limits :rtype: dict """ return self._properties['limits'] @property def webhooks(self): """ :returns: The webhooks :rtype: dict """ return self._properties['webhooks'] @property def pre_webhook_url(self): """ :returns: The pre_webhook_url :rtype: unicode """ return self._properties['pre_webhook_url'] @property def post_webhook_url(self): """ :returns: The post_webhook_url :rtype: unicode """ return self._properties['post_webhook_url'] @property def webhook_method(self): """ :returns: The webhook_method :rtype: unicode """ return self._properties['webhook_method'] @property def webhook_filters(self): """ :returns: The webhook_filters :rtype: unicode """ return self._properties['webhook_filters'] @property def notifications(self): """ :returns: The notifications :rtype: dict """ return self._properties['notifications'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a ServiceInstance :returns: Fetched ServiceInstance :rtype: twilio.rest.chat.v1.service.ServiceInstance """ return self._proxy.fetch() def delete(self): """ Deletes the ServiceInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, friendly_name=values.unset, default_service_role_sid=values.unset, default_channel_role_sid=values.unset, default_channel_creator_role_sid=values.unset, read_status_enabled=values.unset, reachability_enabled=values.unset, typing_indicator_timeout=values.unset, consumption_report_interval=values.unset, notifications_new_message_enabled=values.unset, notifications_new_message_template=values.unset, notifications_added_to_channel_enabled=values.unset, notifications_added_to_channel_template=values.unset, notifications_removed_from_channel_enabled=values.unset, notifications_removed_from_channel_template=values.unset, notifications_invited_to_channel_enabled=values.unset, notifications_invited_to_channel_template=values.unset, pre_webhook_url=values.unset, post_webhook_url=values.unset, webhook_method=values.unset, webhook_filters=values.unset, webhooks_on_message_send_url=values.unset, webhooks_on_message_send_method=values.unset, webhooks_on_message_send_format=values.unset, webhooks_on_message_update_url=values.unset, webhooks_on_message_update_method=values.unset, webhooks_on_message_update_format=values.unset, webhooks_on_message_remove_url=values.unset, webhooks_on_message_remove_method=values.unset, webhooks_on_message_remove_format=values.unset, webhooks_on_channel_add_url=values.unset, webhooks_on_channel_add_method=values.unset, webhooks_on_channel_add_format=values.unset, webhooks_on_channel_destroy_url=values.unset, webhooks_on_channel_destroy_method=values.unset, webhooks_on_channel_destroy_format=values.unset, webhooks_on_channel_update_url=values.unset, webhooks_on_channel_update_method=values.unset, webhooks_on_channel_update_format=values.unset, webhooks_on_member_add_url=values.unset, webhooks_on_member_add_method=values.unset, webhooks_on_member_add_format=values.unset, webhooks_on_member_remove_url=values.unset, webhooks_on_member_remove_method=values.unset, webhooks_on_member_remove_format=values.unset, webhooks_on_message_sent_url=values.unset, webhooks_on_message_sent_method=values.unset, webhooks_on_message_sent_format=values.unset, webhooks_on_message_updated_url=values.unset, webhooks_on_message_updated_method=values.unset, webhooks_on_message_updated_format=values.unset, webhooks_on_message_removed_url=values.unset, webhooks_on_message_removed_method=values.unset, webhooks_on_message_removed_format=values.unset, webhooks_on_channel_added_url=values.unset, webhooks_on_channel_added_method=values.unset, webhooks_on_channel_added_format=values.unset, webhooks_on_channel_destroyed_url=values.unset, webhooks_on_channel_destroyed_method=values.unset, webhooks_on_channel_destroyed_format=values.unset, webhooks_on_channel_updated_url=values.unset, webhooks_on_channel_updated_method=values.unset, webhooks_on_channel_updated_format=values.unset, webhooks_on_member_added_url=values.unset, webhooks_on_member_added_method=values.unset, webhooks_on_member_added_format=values.unset, webhooks_on_member_removed_url=values.unset, webhooks_on_member_removed_method=values.unset, webhooks_on_member_removed_format=values.unset, limits_channel_members=values.unset, limits_user_channels=values.unset): """ Update the ServiceInstance :param unicode friendly_name: The friendly_name :param unicode default_service_role_sid: The default_service_role_sid :param unicode default_channel_role_sid: The default_channel_role_sid :param unicode default_channel_creator_role_sid: The default_channel_creator_role_sid :param bool read_status_enabled: The read_status_enabled :param bool reachability_enabled: The reachability_enabled :param unicode typing_indicator_timeout: The typing_indicator_timeout :param unicode consumption_report_interval: The consumption_report_interval :param bool notifications_new_message_enabled: The notifications.new_message.enabled :param unicode notifications_new_message_template: The notifications.new_message.template :param bool notifications_added_to_channel_enabled: The notifications.added_to_channel.enabled :param unicode notifications_added_to_channel_template: The notifications.added_to_channel.template :param bool notifications_removed_from_channel_enabled: The notifications.removed_from_channel.enabled :param unicode notifications_removed_from_channel_template: The notifications.removed_from_channel.template :param bool notifications_invited_to_channel_enabled: The notifications.invited_to_channel.enabled :param unicode notifications_invited_to_channel_template: The notifications.invited_to_channel.template :param unicode pre_webhook_url: The pre_webhook_url :param unicode post_webhook_url: The post_webhook_url :param unicode webhook_method: The webhook_method :param unicode webhook_filters: The webhook_filters :param unicode webhooks_on_message_send_url: The webhooks.on_message_send.url :param unicode webhooks_on_message_send_method: The webhooks.on_message_send.method :param unicode webhooks_on_message_send_format: The webhooks.on_message_send.format :param unicode webhooks_on_message_update_url: The webhooks.on_message_update.url :param unicode webhooks_on_message_update_method: The webhooks.on_message_update.method :param unicode webhooks_on_message_update_format: The webhooks.on_message_update.format :param unicode webhooks_on_message_remove_url: The webhooks.on_message_remove.url :param unicode webhooks_on_message_remove_method: The webhooks.on_message_remove.method :param unicode webhooks_on_message_remove_format: The webhooks.on_message_remove.format :param unicode webhooks_on_channel_add_url: The webhooks.on_channel_add.url :param unicode webhooks_on_channel_add_method: The webhooks.on_channel_add.method :param unicode webhooks_on_channel_add_format: The webhooks.on_channel_add.format :param unicode webhooks_on_channel_destroy_url: The webhooks.on_channel_destroy.url :param unicode webhooks_on_channel_destroy_method: The webhooks.on_channel_destroy.method :param unicode webhooks_on_channel_destroy_format: The webhooks.on_channel_destroy.format :param unicode webhooks_on_channel_update_url: The webhooks.on_channel_update.url :param unicode webhooks_on_channel_update_method: The webhooks.on_channel_update.method :param unicode webhooks_on_channel_update_format: The webhooks.on_channel_update.format :param unicode webhooks_on_member_add_url: The webhooks.on_member_add.url :param unicode webhooks_on_member_add_method: The webhooks.on_member_add.method :param unicode webhooks_on_member_add_format: The webhooks.on_member_add.format :param unicode webhooks_on_member_remove_url: The webhooks.on_member_remove.url :param unicode webhooks_on_member_remove_method: The webhooks.on_member_remove.method :param unicode webhooks_on_member_remove_format: The webhooks.on_member_remove.format :param unicode webhooks_on_message_sent_url: The webhooks.on_message_sent.url :param unicode webhooks_on_message_sent_method: The webhooks.on_message_sent.method :param unicode webhooks_on_message_sent_format: The webhooks.on_message_sent.format :param unicode webhooks_on_message_updated_url: The webhooks.on_message_updated.url :param unicode webhooks_on_message_updated_method: The webhooks.on_message_updated.method :param unicode webhooks_on_message_updated_format: The webhooks.on_message_updated.format :param unicode webhooks_on_message_removed_url: The webhooks.on_message_removed.url :param unicode webhooks_on_message_removed_method: The webhooks.on_message_removed.method :param unicode webhooks_on_message_removed_format: The webhooks.on_message_removed.format :param unicode webhooks_on_channel_added_url: The webhooks.on_channel_added.url :param unicode webhooks_on_channel_added_method: The webhooks.on_channel_added.method :param unicode webhooks_on_channel_added_format: The webhooks.on_channel_added.format :param unicode webhooks_on_channel_destroyed_url: The webhooks.on_channel_destroyed.url :param unicode webhooks_on_channel_destroyed_method: The webhooks.on_channel_destroyed.method :param unicode webhooks_on_channel_destroyed_format: The webhooks.on_channel_destroyed.format :param unicode webhooks_on_channel_updated_url: The webhooks.on_channel_updated.url :param unicode webhooks_on_channel_updated_method: The webhooks.on_channel_updated.method :param unicode webhooks_on_channel_updated_format: The webhooks.on_channel_updated.format :param unicode webhooks_on_member_added_url: The webhooks.on_member_added.url :param unicode webhooks_on_member_added_method: The webhooks.on_member_added.method :param unicode webhooks_on_member_added_format: The webhooks.on_member_added.format :param unicode webhooks_on_member_removed_url: The webhooks.on_member_removed.url :param unicode webhooks_on_member_removed_method: The webhooks.on_member_removed.method :param unicode webhooks_on_member_removed_format: The webhooks.on_member_removed.format :param unicode limits_channel_members: The limits.channel_members :param unicode limits_user_channels: The limits.user_channels :returns: Updated ServiceInstance :rtype: twilio.rest.chat.v1.service.ServiceInstance """ return self._proxy.update( friendly_name=friendly_name, default_service_role_sid=default_service_role_sid, default_channel_role_sid=default_channel_role_sid, default_channel_creator_role_sid=default_channel_creator_role_sid, read_status_enabled=read_status_enabled, reachability_enabled=reachability_enabled, typing_indicator_timeout=typing_indicator_timeout, consumption_report_interval=consumption_report_interval, notifications_new_message_enabled=notifications_new_message_enabled, notifications_new_message_template=notifications_new_message_template, notifications_added_to_channel_enabled=notifications_added_to_channel_enabled, notifications_added_to_channel_template=notifications_added_to_channel_template, notifications_removed_from_channel_enabled=notifications_removed_from_channel_enabled, notifications_removed_from_channel_template=notifications_removed_from_channel_template, notifications_invited_to_channel_enabled=notifications_invited_to_channel_enabled, notifications_invited_to_channel_template=notifications_invited_to_channel_template, pre_webhook_url=pre_webhook_url, post_webhook_url=post_webhook_url, webhook_method=webhook_method, webhook_filters=webhook_filters, webhooks_on_message_send_url=webhooks_on_message_send_url, webhooks_on_message_send_method=webhooks_on_message_send_method, webhooks_on_message_send_format=webhooks_on_message_send_format, webhooks_on_message_update_url=webhooks_on_message_update_url, webhooks_on_message_update_method=webhooks_on_message_update_method, webhooks_on_message_update_format=webhooks_on_message_update_format, webhooks_on_message_remove_url=webhooks_on_message_remove_url, webhooks_on_message_remove_method=webhooks_on_message_remove_method, webhooks_on_message_remove_format=webhooks_on_message_remove_format, webhooks_on_channel_add_url=webhooks_on_channel_add_url, webhooks_on_channel_add_method=webhooks_on_channel_add_method, webhooks_on_channel_add_format=webhooks_on_channel_add_format, webhooks_on_channel_destroy_url=webhooks_on_channel_destroy_url, webhooks_on_channel_destroy_method=webhooks_on_channel_destroy_method, webhooks_on_channel_destroy_format=webhooks_on_channel_destroy_format, webhooks_on_channel_update_url=webhooks_on_channel_update_url, webhooks_on_channel_update_method=webhooks_on_channel_update_method, webhooks_on_channel_update_format=webhooks_on_channel_update_format, webhooks_on_member_add_url=webhooks_on_member_add_url, webhooks_on_member_add_method=webhooks_on_member_add_method, webhooks_on_member_add_format=webhooks_on_member_add_format, webhooks_on_member_remove_url=webhooks_on_member_remove_url, webhooks_on_member_remove_method=webhooks_on_member_remove_method, webhooks_on_member_remove_format=webhooks_on_member_remove_format, webhooks_on_message_sent_url=webhooks_on_message_sent_url, webhooks_on_message_sent_method=webhooks_on_message_sent_method, webhooks_on_message_sent_format=webhooks_on_message_sent_format, webhooks_on_message_updated_url=webhooks_on_message_updated_url, webhooks_on_message_updated_method=webhooks_on_message_updated_method, webhooks_on_message_updated_format=webhooks_on_message_updated_format, webhooks_on_message_removed_url=webhooks_on_message_removed_url, webhooks_on_message_removed_method=webhooks_on_message_removed_method, webhooks_on_message_removed_format=webhooks_on_message_removed_format, webhooks_on_channel_added_url=webhooks_on_channel_added_url, webhooks_on_channel_added_method=webhooks_on_channel_added_method, webhooks_on_channel_added_format=webhooks_on_channel_added_format, webhooks_on_channel_destroyed_url=webhooks_on_channel_destroyed_url, webhooks_on_channel_destroyed_method=webhooks_on_channel_destroyed_method, webhooks_on_channel_destroyed_format=webhooks_on_channel_destroyed_format, webhooks_on_channel_updated_url=webhooks_on_channel_updated_url, webhooks_on_channel_updated_method=webhooks_on_channel_updated_method, webhooks_on_channel_updated_format=webhooks_on_channel_updated_format, webhooks_on_member_added_url=webhooks_on_member_added_url, webhooks_on_member_added_method=webhooks_on_member_added_method, webhooks_on_member_added_format=webhooks_on_member_added_format, webhooks_on_member_removed_url=webhooks_on_member_removed_url, webhooks_on_member_removed_method=webhooks_on_member_removed_method, webhooks_on_member_removed_format=webhooks_on_member_removed_format, limits_channel_members=limits_channel_members, limits_user_channels=limits_user_channels, ) @property def channels(self): """ Access the channels :returns: twilio.rest.chat.v1.service.channel.ChannelList :rtype: twilio.rest.chat.v1.service.channel.ChannelList """ return self._proxy.channels @property def roles(self): """ Access the roles :returns: twilio.rest.chat.v1.service.role.RoleList :rtype: twilio.rest.chat.v1.service.role.RoleList """ return self._proxy.roles @property def users(self): """ Access the users :returns: twilio.rest.chat.v1.service.user.UserList :rtype: twilio.rest.chat.v1.service.user.UserList """ return self._proxy.users def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/chat/v1/service/channel/000077500000000000000000000000001317472742600231735ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/chat/v1/service/channel/__init__.py000066400000000000000000000445711317472742600253170ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.chat.v1.service.channel.invite import InviteList from twilio.rest.chat.v1.service.channel.member import MemberList from twilio.rest.chat.v1.service.channel.message import MessageList class ChannelList(ListResource): """ """ def __init__(self, version, service_sid): """ Initialize the ChannelList :param Version version: Version that contains the resource :param service_sid: The service_sid :returns: twilio.rest.chat.v1.service.channel.ChannelList :rtype: twilio.rest.chat.v1.service.channel.ChannelList """ super(ChannelList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid,} self._uri = '/Services/{service_sid}/Channels'.format(**self._solution) def create(self, friendly_name=values.unset, unique_name=values.unset, attributes=values.unset, type=values.unset): """ Create a new ChannelInstance :param unicode friendly_name: The friendly_name :param unicode unique_name: The unique_name :param unicode attributes: The attributes :param ChannelInstance.ChannelType type: The type :returns: Newly created ChannelInstance :rtype: twilio.rest.chat.v1.service.channel.ChannelInstance """ data = values.of({ 'FriendlyName': friendly_name, 'UniqueName': unique_name, 'Attributes': attributes, 'Type': type, }) payload = self._version.create( 'POST', self._uri, data=data, ) return ChannelInstance(self._version, payload, service_sid=self._solution['service_sid'],) def stream(self, type=values.unset, limit=None, page_size=None): """ Streams ChannelInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param ChannelInstance.ChannelType type: The type :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v1.service.channel.ChannelInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(type=type, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, type=values.unset, limit=None, page_size=None): """ Lists ChannelInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param ChannelInstance.ChannelType type: The type :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v1.service.channel.ChannelInstance] """ return list(self.stream(type=type, limit=limit, page_size=page_size,)) def page(self, type=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of ChannelInstance records from the API. Request is executed immediately :param ChannelInstance.ChannelType type: The type :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of ChannelInstance :rtype: twilio.rest.chat.v1.service.channel.ChannelPage """ params = values.of({'Type': type, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return ChannelPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of ChannelInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of ChannelInstance :rtype: twilio.rest.chat.v1.service.channel.ChannelPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return ChannelPage(self._version, response, self._solution) def get(self, sid): """ Constructs a ChannelContext :param sid: The sid :returns: twilio.rest.chat.v1.service.channel.ChannelContext :rtype: twilio.rest.chat.v1.service.channel.ChannelContext """ return ChannelContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __call__(self, sid): """ Constructs a ChannelContext :param sid: The sid :returns: twilio.rest.chat.v1.service.channel.ChannelContext :rtype: twilio.rest.chat.v1.service.channel.ChannelContext """ return ChannelContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ChannelPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the ChannelPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :returns: twilio.rest.chat.v1.service.channel.ChannelPage :rtype: twilio.rest.chat.v1.service.channel.ChannelPage """ super(ChannelPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of ChannelInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v1.service.channel.ChannelInstance :rtype: twilio.rest.chat.v1.service.channel.ChannelInstance """ return ChannelInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ChannelContext(InstanceContext): """ """ def __init__(self, version, service_sid, sid): """ Initialize the ChannelContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param sid: The sid :returns: twilio.rest.chat.v1.service.channel.ChannelContext :rtype: twilio.rest.chat.v1.service.channel.ChannelContext """ super(ChannelContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Channels/{sid}'.format(**self._solution) # Dependents self._members = None self._messages = None self._invites = None def fetch(self): """ Fetch a ChannelInstance :returns: Fetched ChannelInstance :rtype: twilio.rest.chat.v1.service.channel.ChannelInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return ChannelInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the ChannelInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, friendly_name=values.unset, unique_name=values.unset, attributes=values.unset): """ Update the ChannelInstance :param unicode friendly_name: The friendly_name :param unicode unique_name: The unique_name :param unicode attributes: The attributes :returns: Updated ChannelInstance :rtype: twilio.rest.chat.v1.service.channel.ChannelInstance """ data = values.of({'FriendlyName': friendly_name, 'UniqueName': unique_name, 'Attributes': attributes,}) payload = self._version.update( 'POST', self._uri, data=data, ) return ChannelInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) @property def members(self): """ Access the members :returns: twilio.rest.chat.v1.service.channel.member.MemberList :rtype: twilio.rest.chat.v1.service.channel.member.MemberList """ if self._members is None: self._members = MemberList( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['sid'], ) return self._members @property def messages(self): """ Access the messages :returns: twilio.rest.chat.v1.service.channel.message.MessageList :rtype: twilio.rest.chat.v1.service.channel.message.MessageList """ if self._messages is None: self._messages = MessageList( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['sid'], ) return self._messages @property def invites(self): """ Access the invites :returns: twilio.rest.chat.v1.service.channel.invite.InviteList :rtype: twilio.rest.chat.v1.service.channel.invite.InviteList """ if self._invites is None: self._invites = InviteList( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['sid'], ) return self._invites def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class ChannelInstance(InstanceResource): """ """ class ChannelType(object): PUBLIC = "public" PRIVATE = "private" def __init__(self, version, payload, service_sid, sid=None): """ Initialize the ChannelInstance :returns: twilio.rest.chat.v1.service.channel.ChannelInstance :rtype: twilio.rest.chat.v1.service.channel.ChannelInstance """ super(ChannelInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'friendly_name': payload['friendly_name'], 'unique_name': payload['unique_name'], 'attributes': payload['attributes'], 'type': payload['type'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'created_by': payload['created_by'], 'members_count': deserialize.integer(payload['members_count']), 'messages_count': deserialize.integer(payload['messages_count']), 'url': payload['url'], 'links': payload['links'], } # Context self._context = None self._solution = {'service_sid': service_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: ChannelContext for this ChannelInstance :rtype: twilio.rest.chat.v1.service.channel.ChannelContext """ if self._context is None: self._context = ChannelContext( self._version, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def unique_name(self): """ :returns: The unique_name :rtype: unicode """ return self._properties['unique_name'] @property def attributes(self): """ :returns: The attributes :rtype: unicode """ return self._properties['attributes'] @property def type(self): """ :returns: The type :rtype: ChannelInstance.ChannelType """ return self._properties['type'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def created_by(self): """ :returns: The created_by :rtype: unicode """ return self._properties['created_by'] @property def members_count(self): """ :returns: The members_count :rtype: unicode """ return self._properties['members_count'] @property def messages_count(self): """ :returns: The messages_count :rtype: unicode """ return self._properties['messages_count'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a ChannelInstance :returns: Fetched ChannelInstance :rtype: twilio.rest.chat.v1.service.channel.ChannelInstance """ return self._proxy.fetch() def delete(self): """ Deletes the ChannelInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, friendly_name=values.unset, unique_name=values.unset, attributes=values.unset): """ Update the ChannelInstance :param unicode friendly_name: The friendly_name :param unicode unique_name: The unique_name :param unicode attributes: The attributes :returns: Updated ChannelInstance :rtype: twilio.rest.chat.v1.service.channel.ChannelInstance """ return self._proxy.update(friendly_name=friendly_name, unique_name=unique_name, attributes=attributes,) @property def members(self): """ Access the members :returns: twilio.rest.chat.v1.service.channel.member.MemberList :rtype: twilio.rest.chat.v1.service.channel.member.MemberList """ return self._proxy.members @property def messages(self): """ Access the messages :returns: twilio.rest.chat.v1.service.channel.message.MessageList :rtype: twilio.rest.chat.v1.service.channel.message.MessageList """ return self._proxy.messages @property def invites(self): """ Access the invites :returns: twilio.rest.chat.v1.service.channel.invite.InviteList :rtype: twilio.rest.chat.v1.service.channel.invite.InviteList """ return self._proxy.invites def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/chat/v1/service/channel/invite.py000066400000000000000000000341671317472742600250560ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class InviteList(ListResource): """ """ def __init__(self, version, service_sid, channel_sid): """ Initialize the InviteList :param Version version: Version that contains the resource :param service_sid: The service_sid :param channel_sid: The channel_sid :returns: twilio.rest.chat.v1.service.channel.invite.InviteList :rtype: twilio.rest.chat.v1.service.channel.invite.InviteList """ super(InviteList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'channel_sid': channel_sid,} self._uri = '/Services/{service_sid}/Channels/{channel_sid}/Invites'.format(**self._solution) def create(self, identity, role_sid=values.unset): """ Create a new InviteInstance :param unicode identity: The identity :param unicode role_sid: The role_sid :returns: Newly created InviteInstance :rtype: twilio.rest.chat.v1.service.channel.invite.InviteInstance """ data = values.of({'Identity': identity, 'RoleSid': role_sid,}) payload = self._version.create( 'POST', self._uri, data=data, ) return InviteInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], ) def stream(self, identity=values.unset, limit=None, page_size=None): """ Streams InviteInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param unicode identity: The identity :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v1.service.channel.invite.InviteInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(identity=identity, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, identity=values.unset, limit=None, page_size=None): """ Lists InviteInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param unicode identity: The identity :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v1.service.channel.invite.InviteInstance] """ return list(self.stream(identity=identity, limit=limit, page_size=page_size,)) def page(self, identity=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of InviteInstance records from the API. Request is executed immediately :param unicode identity: The identity :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of InviteInstance :rtype: twilio.rest.chat.v1.service.channel.invite.InvitePage """ params = values.of({ 'Identity': identity, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return InvitePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of InviteInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of InviteInstance :rtype: twilio.rest.chat.v1.service.channel.invite.InvitePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return InvitePage(self._version, response, self._solution) def get(self, sid): """ Constructs a InviteContext :param sid: The sid :returns: twilio.rest.chat.v1.service.channel.invite.InviteContext :rtype: twilio.rest.chat.v1.service.channel.invite.InviteContext """ return InviteContext( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a InviteContext :param sid: The sid :returns: twilio.rest.chat.v1.service.channel.invite.InviteContext :rtype: twilio.rest.chat.v1.service.channel.invite.InviteContext """ return InviteContext( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class InvitePage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the InvitePage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :param channel_sid: The channel_sid :returns: twilio.rest.chat.v1.service.channel.invite.InvitePage :rtype: twilio.rest.chat.v1.service.channel.invite.InvitePage """ super(InvitePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of InviteInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v1.service.channel.invite.InviteInstance :rtype: twilio.rest.chat.v1.service.channel.invite.InviteInstance """ return InviteInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class InviteContext(InstanceContext): """ """ def __init__(self, version, service_sid, channel_sid, sid): """ Initialize the InviteContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param channel_sid: The channel_sid :param sid: The sid :returns: twilio.rest.chat.v1.service.channel.invite.InviteContext :rtype: twilio.rest.chat.v1.service.channel.invite.InviteContext """ super(InviteContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'channel_sid': channel_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Channels/{channel_sid}/Invites/{sid}'.format(**self._solution) def fetch(self): """ Fetch a InviteInstance :returns: Fetched InviteInstance :rtype: twilio.rest.chat.v1.service.channel.invite.InviteInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return InviteInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the InviteInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class InviteInstance(InstanceResource): """ """ def __init__(self, version, payload, service_sid, channel_sid, sid=None): """ Initialize the InviteInstance :returns: twilio.rest.chat.v1.service.channel.invite.InviteInstance :rtype: twilio.rest.chat.v1.service.channel.invite.InviteInstance """ super(InviteInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'channel_sid': payload['channel_sid'], 'service_sid': payload['service_sid'], 'identity': payload['identity'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'role_sid': payload['role_sid'], 'created_by': payload['created_by'], 'url': payload['url'], } # Context self._context = None self._solution = { 'service_sid': service_sid, 'channel_sid': channel_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: InviteContext for this InviteInstance :rtype: twilio.rest.chat.v1.service.channel.invite.InviteContext """ if self._context is None: self._context = InviteContext( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def channel_sid(self): """ :returns: The channel_sid :rtype: unicode """ return self._properties['channel_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def identity(self): """ :returns: The identity :rtype: unicode """ return self._properties['identity'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def role_sid(self): """ :returns: The role_sid :rtype: unicode """ return self._properties['role_sid'] @property def created_by(self): """ :returns: The created_by :rtype: unicode """ return self._properties['created_by'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a InviteInstance :returns: Fetched InviteInstance :rtype: twilio.rest.chat.v1.service.channel.invite.InviteInstance """ return self._proxy.fetch() def delete(self): """ Deletes the InviteInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/chat/v1/service/channel/member.py000066400000000000000000000376261317472742600250320ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class MemberList(ListResource): """ """ def __init__(self, version, service_sid, channel_sid): """ Initialize the MemberList :param Version version: Version that contains the resource :param service_sid: The service_sid :param channel_sid: The channel_sid :returns: twilio.rest.chat.v1.service.channel.member.MemberList :rtype: twilio.rest.chat.v1.service.channel.member.MemberList """ super(MemberList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'channel_sid': channel_sid,} self._uri = '/Services/{service_sid}/Channels/{channel_sid}/Members'.format(**self._solution) def create(self, identity, role_sid=values.unset): """ Create a new MemberInstance :param unicode identity: The identity :param unicode role_sid: The role_sid :returns: Newly created MemberInstance :rtype: twilio.rest.chat.v1.service.channel.member.MemberInstance """ data = values.of({'Identity': identity, 'RoleSid': role_sid,}) payload = self._version.create( 'POST', self._uri, data=data, ) return MemberInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], ) def stream(self, identity=values.unset, limit=None, page_size=None): """ Streams MemberInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param unicode identity: The identity :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v1.service.channel.member.MemberInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(identity=identity, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, identity=values.unset, limit=None, page_size=None): """ Lists MemberInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param unicode identity: The identity :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v1.service.channel.member.MemberInstance] """ return list(self.stream(identity=identity, limit=limit, page_size=page_size,)) def page(self, identity=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of MemberInstance records from the API. Request is executed immediately :param unicode identity: The identity :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of MemberInstance :rtype: twilio.rest.chat.v1.service.channel.member.MemberPage """ params = values.of({ 'Identity': identity, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return MemberPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of MemberInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of MemberInstance :rtype: twilio.rest.chat.v1.service.channel.member.MemberPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return MemberPage(self._version, response, self._solution) def get(self, sid): """ Constructs a MemberContext :param sid: The sid :returns: twilio.rest.chat.v1.service.channel.member.MemberContext :rtype: twilio.rest.chat.v1.service.channel.member.MemberContext """ return MemberContext( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a MemberContext :param sid: The sid :returns: twilio.rest.chat.v1.service.channel.member.MemberContext :rtype: twilio.rest.chat.v1.service.channel.member.MemberContext """ return MemberContext( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class MemberPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the MemberPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :param channel_sid: The channel_sid :returns: twilio.rest.chat.v1.service.channel.member.MemberPage :rtype: twilio.rest.chat.v1.service.channel.member.MemberPage """ super(MemberPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of MemberInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v1.service.channel.member.MemberInstance :rtype: twilio.rest.chat.v1.service.channel.member.MemberInstance """ return MemberInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class MemberContext(InstanceContext): """ """ def __init__(self, version, service_sid, channel_sid, sid): """ Initialize the MemberContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param channel_sid: The channel_sid :param sid: The sid :returns: twilio.rest.chat.v1.service.channel.member.MemberContext :rtype: twilio.rest.chat.v1.service.channel.member.MemberContext """ super(MemberContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'channel_sid': channel_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Channels/{channel_sid}/Members/{sid}'.format(**self._solution) def fetch(self): """ Fetch a MemberInstance :returns: Fetched MemberInstance :rtype: twilio.rest.chat.v1.service.channel.member.MemberInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return MemberInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the MemberInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, role_sid=values.unset, last_consumed_message_index=values.unset): """ Update the MemberInstance :param unicode role_sid: The role_sid :param unicode last_consumed_message_index: The last_consumed_message_index :returns: Updated MemberInstance :rtype: twilio.rest.chat.v1.service.channel.member.MemberInstance """ data = values.of({'RoleSid': role_sid, 'LastConsumedMessageIndex': last_consumed_message_index,}) payload = self._version.update( 'POST', self._uri, data=data, ) return MemberInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class MemberInstance(InstanceResource): """ """ def __init__(self, version, payload, service_sid, channel_sid, sid=None): """ Initialize the MemberInstance :returns: twilio.rest.chat.v1.service.channel.member.MemberInstance :rtype: twilio.rest.chat.v1.service.channel.member.MemberInstance """ super(MemberInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'channel_sid': payload['channel_sid'], 'service_sid': payload['service_sid'], 'identity': payload['identity'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'role_sid': payload['role_sid'], 'last_consumed_message_index': deserialize.integer(payload['last_consumed_message_index']), 'last_consumption_timestamp': deserialize.iso8601_datetime(payload['last_consumption_timestamp']), 'url': payload['url'], } # Context self._context = None self._solution = { 'service_sid': service_sid, 'channel_sid': channel_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: MemberContext for this MemberInstance :rtype: twilio.rest.chat.v1.service.channel.member.MemberContext """ if self._context is None: self._context = MemberContext( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def channel_sid(self): """ :returns: The channel_sid :rtype: unicode """ return self._properties['channel_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def identity(self): """ :returns: The identity :rtype: unicode """ return self._properties['identity'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def role_sid(self): """ :returns: The role_sid :rtype: unicode """ return self._properties['role_sid'] @property def last_consumed_message_index(self): """ :returns: The last_consumed_message_index :rtype: unicode """ return self._properties['last_consumed_message_index'] @property def last_consumption_timestamp(self): """ :returns: The last_consumption_timestamp :rtype: datetime """ return self._properties['last_consumption_timestamp'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a MemberInstance :returns: Fetched MemberInstance :rtype: twilio.rest.chat.v1.service.channel.member.MemberInstance """ return self._proxy.fetch() def delete(self): """ Deletes the MemberInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, role_sid=values.unset, last_consumed_message_index=values.unset): """ Update the MemberInstance :param unicode role_sid: The role_sid :param unicode last_consumed_message_index: The last_consumed_message_index :returns: Updated MemberInstance :rtype: twilio.rest.chat.v1.service.channel.member.MemberInstance """ return self._proxy.update(role_sid=role_sid, last_consumed_message_index=last_consumed_message_index,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/chat/v1/service/channel/message.py000066400000000000000000000400431317472742600251720ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class MessageList(ListResource): """ """ def __init__(self, version, service_sid, channel_sid): """ Initialize the MessageList :param Version version: Version that contains the resource :param service_sid: The service_sid :param channel_sid: The channel_sid :returns: twilio.rest.chat.v1.service.channel.message.MessageList :rtype: twilio.rest.chat.v1.service.channel.message.MessageList """ super(MessageList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'channel_sid': channel_sid,} self._uri = '/Services/{service_sid}/Channels/{channel_sid}/Messages'.format(**self._solution) def create(self, body, from_=values.unset, attributes=values.unset): """ Create a new MessageInstance :param unicode body: The body :param unicode from_: The from :param unicode attributes: The attributes :returns: Newly created MessageInstance :rtype: twilio.rest.chat.v1.service.channel.message.MessageInstance """ data = values.of({'Body': body, 'From': from_, 'Attributes': attributes,}) payload = self._version.create( 'POST', self._uri, data=data, ) return MessageInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], ) def stream(self, order=values.unset, limit=None, page_size=None): """ 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 MessageInstance.OrderType order: The order :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v1.service.channel.message.MessageInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(order=order, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, order=values.unset, limit=None, page_size=None): """ 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 MessageInstance.OrderType order: The order :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v1.service.channel.message.MessageInstance] """ return list(self.stream(order=order, limit=limit, page_size=page_size,)) def page(self, order=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of MessageInstance records from the API. Request is executed immediately :param MessageInstance.OrderType order: The order :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of MessageInstance :rtype: twilio.rest.chat.v1.service.channel.message.MessagePage """ params = values.of({ 'Order': order, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return MessagePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of MessageInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of MessageInstance :rtype: twilio.rest.chat.v1.service.channel.message.MessagePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return MessagePage(self._version, response, self._solution) def get(self, sid): """ Constructs a MessageContext :param sid: The sid :returns: twilio.rest.chat.v1.service.channel.message.MessageContext :rtype: twilio.rest.chat.v1.service.channel.message.MessageContext """ return MessageContext( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a MessageContext :param sid: The sid :returns: twilio.rest.chat.v1.service.channel.message.MessageContext :rtype: twilio.rest.chat.v1.service.channel.message.MessageContext """ return MessageContext( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class MessagePage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the MessagePage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :param channel_sid: The channel_sid :returns: twilio.rest.chat.v1.service.channel.message.MessagePage :rtype: twilio.rest.chat.v1.service.channel.message.MessagePage """ super(MessagePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of MessageInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v1.service.channel.message.MessageInstance :rtype: twilio.rest.chat.v1.service.channel.message.MessageInstance """ return MessageInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class MessageContext(InstanceContext): """ """ def __init__(self, version, service_sid, channel_sid, sid): """ Initialize the MessageContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param channel_sid: The channel_sid :param sid: The sid :returns: twilio.rest.chat.v1.service.channel.message.MessageContext :rtype: twilio.rest.chat.v1.service.channel.message.MessageContext """ super(MessageContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'channel_sid': channel_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Channels/{channel_sid}/Messages/{sid}'.format(**self._solution) def fetch(self): """ Fetch a MessageInstance :returns: Fetched MessageInstance :rtype: twilio.rest.chat.v1.service.channel.message.MessageInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return MessageInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the MessageInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, body=values.unset, attributes=values.unset): """ Update the MessageInstance :param unicode body: The body :param unicode attributes: The attributes :returns: Updated MessageInstance :rtype: twilio.rest.chat.v1.service.channel.message.MessageInstance """ data = values.of({'Body': body, 'Attributes': attributes,}) payload = self._version.update( 'POST', self._uri, data=data, ) return MessageInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class MessageInstance(InstanceResource): """ """ class OrderType(object): ASC = "asc" DESC = "desc" def __init__(self, version, payload, service_sid, channel_sid, sid=None): """ Initialize the MessageInstance :returns: twilio.rest.chat.v1.service.channel.message.MessageInstance :rtype: twilio.rest.chat.v1.service.channel.message.MessageInstance """ super(MessageInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'attributes': payload['attributes'], 'service_sid': payload['service_sid'], 'to': payload['to'], 'channel_sid': payload['channel_sid'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'was_edited': payload['was_edited'], 'from_': payload['from'], 'body': payload['body'], 'index': deserialize.integer(payload['index']), 'url': payload['url'], } # Context self._context = None self._solution = { 'service_sid': service_sid, 'channel_sid': channel_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: MessageContext for this MessageInstance :rtype: twilio.rest.chat.v1.service.channel.message.MessageContext """ if self._context is None: self._context = MessageContext( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def attributes(self): """ :returns: The attributes :rtype: unicode """ return self._properties['attributes'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def to(self): """ :returns: The to :rtype: unicode """ return self._properties['to'] @property def channel_sid(self): """ :returns: The channel_sid :rtype: unicode """ return self._properties['channel_sid'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def was_edited(self): """ :returns: The was_edited :rtype: bool """ return self._properties['was_edited'] @property def from_(self): """ :returns: The from :rtype: unicode """ return self._properties['from_'] @property def body(self): """ :returns: The body :rtype: unicode """ return self._properties['body'] @property def index(self): """ :returns: The index :rtype: unicode """ return self._properties['index'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a MessageInstance :returns: Fetched MessageInstance :rtype: twilio.rest.chat.v1.service.channel.message.MessageInstance """ return self._proxy.fetch() def delete(self): """ Deletes the MessageInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, body=values.unset, attributes=values.unset): """ Update the MessageInstance :param unicode body: The body :param unicode attributes: The attributes :returns: Updated MessageInstance :rtype: twilio.rest.chat.v1.service.channel.message.MessageInstance """ return self._proxy.update(body=body, attributes=attributes,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/chat/v1/service/role.py000066400000000000000000000327321317472742600231050ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class RoleList(ListResource): """ """ def __init__(self, version, service_sid): """ Initialize the RoleList :param Version version: Version that contains the resource :param service_sid: The service_sid :returns: twilio.rest.chat.v1.service.role.RoleList :rtype: twilio.rest.chat.v1.service.role.RoleList """ super(RoleList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid,} self._uri = '/Services/{service_sid}/Roles'.format(**self._solution) def create(self, friendly_name, type, permission): """ Create a new RoleInstance :param unicode friendly_name: The friendly_name :param RoleInstance.RoleType type: The type :param unicode permission: The permission :returns: Newly created RoleInstance :rtype: twilio.rest.chat.v1.service.role.RoleInstance """ data = values.of({'FriendlyName': friendly_name, 'Type': type, 'Permission': permission,}) payload = self._version.create( 'POST', self._uri, data=data, ) return RoleInstance(self._version, payload, service_sid=self._solution['service_sid'],) def stream(self, limit=None, page_size=None): """ Streams RoleInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v1.service.role.RoleInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists RoleInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v1.service.role.RoleInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of RoleInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of RoleInstance :rtype: twilio.rest.chat.v1.service.role.RolePage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return RolePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of RoleInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of RoleInstance :rtype: twilio.rest.chat.v1.service.role.RolePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return RolePage(self._version, response, self._solution) def get(self, sid): """ Constructs a RoleContext :param sid: The sid :returns: twilio.rest.chat.v1.service.role.RoleContext :rtype: twilio.rest.chat.v1.service.role.RoleContext """ return RoleContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __call__(self, sid): """ Constructs a RoleContext :param sid: The sid :returns: twilio.rest.chat.v1.service.role.RoleContext :rtype: twilio.rest.chat.v1.service.role.RoleContext """ return RoleContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class RolePage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the RolePage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :returns: twilio.rest.chat.v1.service.role.RolePage :rtype: twilio.rest.chat.v1.service.role.RolePage """ super(RolePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of RoleInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v1.service.role.RoleInstance :rtype: twilio.rest.chat.v1.service.role.RoleInstance """ return RoleInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class RoleContext(InstanceContext): """ """ def __init__(self, version, service_sid, sid): """ Initialize the RoleContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param sid: The sid :returns: twilio.rest.chat.v1.service.role.RoleContext :rtype: twilio.rest.chat.v1.service.role.RoleContext """ super(RoleContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Roles/{sid}'.format(**self._solution) def fetch(self): """ Fetch a RoleInstance :returns: Fetched RoleInstance :rtype: twilio.rest.chat.v1.service.role.RoleInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return RoleInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the RoleInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, permission): """ Update the RoleInstance :param unicode permission: The permission :returns: Updated RoleInstance :rtype: twilio.rest.chat.v1.service.role.RoleInstance """ data = values.of({'Permission': permission,}) payload = self._version.update( 'POST', self._uri, data=data, ) return RoleInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class RoleInstance(InstanceResource): """ """ class RoleType(object): CHANNEL = "channel" DEPLOYMENT = "deployment" def __init__(self, version, payload, service_sid, sid=None): """ Initialize the RoleInstance :returns: twilio.rest.chat.v1.service.role.RoleInstance :rtype: twilio.rest.chat.v1.service.role.RoleInstance """ super(RoleInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'friendly_name': payload['friendly_name'], 'type': payload['type'], 'permissions': payload['permissions'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'url': payload['url'], } # Context self._context = None self._solution = {'service_sid': service_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: RoleContext for this RoleInstance :rtype: twilio.rest.chat.v1.service.role.RoleContext """ if self._context is None: self._context = RoleContext( self._version, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def type(self): """ :returns: The type :rtype: RoleInstance.RoleType """ return self._properties['type'] @property def permissions(self): """ :returns: The permissions :rtype: unicode """ return self._properties['permissions'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a RoleInstance :returns: Fetched RoleInstance :rtype: twilio.rest.chat.v1.service.role.RoleInstance """ return self._proxy.fetch() def delete(self): """ Deletes the RoleInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, permission): """ Update the RoleInstance :param unicode permission: The permission :returns: Updated RoleInstance :rtype: twilio.rest.chat.v1.service.role.RoleInstance """ return self._proxy.update(permission,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/chat/v1/service/user/000077500000000000000000000000001317472742600225415ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/chat/v1/service/user/__init__.py000066400000000000000000000401201317472742600246470ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.chat.v1.service.user.user_channel import UserChannelList class UserList(ListResource): """ """ def __init__(self, version, service_sid): """ Initialize the UserList :param Version version: Version that contains the resource :param service_sid: The service_sid :returns: twilio.rest.chat.v1.service.user.UserList :rtype: twilio.rest.chat.v1.service.user.UserList """ super(UserList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid,} self._uri = '/Services/{service_sid}/Users'.format(**self._solution) def create(self, identity, role_sid=values.unset, attributes=values.unset, friendly_name=values.unset): """ Create a new UserInstance :param unicode identity: The identity :param unicode role_sid: The role_sid :param unicode attributes: The attributes :param unicode friendly_name: The friendly_name :returns: Newly created UserInstance :rtype: twilio.rest.chat.v1.service.user.UserInstance """ data = values.of({ 'Identity': identity, 'RoleSid': role_sid, 'Attributes': attributes, 'FriendlyName': friendly_name, }) payload = self._version.create( 'POST', self._uri, data=data, ) return UserInstance(self._version, payload, service_sid=self._solution['service_sid'],) def stream(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v1.service.user.UserInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v1.service.user.UserInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of UserInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of UserInstance :rtype: twilio.rest.chat.v1.service.user.UserPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return UserPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of UserInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of UserInstance :rtype: twilio.rest.chat.v1.service.user.UserPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return UserPage(self._version, response, self._solution) def get(self, sid): """ Constructs a UserContext :param sid: The sid :returns: twilio.rest.chat.v1.service.user.UserContext :rtype: twilio.rest.chat.v1.service.user.UserContext """ return UserContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __call__(self, sid): """ Constructs a UserContext :param sid: The sid :returns: twilio.rest.chat.v1.service.user.UserContext :rtype: twilio.rest.chat.v1.service.user.UserContext """ return UserContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class UserPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the UserPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :returns: twilio.rest.chat.v1.service.user.UserPage :rtype: twilio.rest.chat.v1.service.user.UserPage """ super(UserPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of UserInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v1.service.user.UserInstance :rtype: twilio.rest.chat.v1.service.user.UserInstance """ return UserInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class UserContext(InstanceContext): """ """ def __init__(self, version, service_sid, sid): """ Initialize the UserContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param sid: The sid :returns: twilio.rest.chat.v1.service.user.UserContext :rtype: twilio.rest.chat.v1.service.user.UserContext """ super(UserContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Users/{sid}'.format(**self._solution) # Dependents self._user_channels = None def fetch(self): """ Fetch a UserInstance :returns: Fetched UserInstance :rtype: twilio.rest.chat.v1.service.user.UserInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return UserInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the UserInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, role_sid=values.unset, attributes=values.unset, friendly_name=values.unset): """ Update the UserInstance :param unicode role_sid: The role_sid :param unicode attributes: The attributes :param unicode friendly_name: The friendly_name :returns: Updated UserInstance :rtype: twilio.rest.chat.v1.service.user.UserInstance """ data = values.of({'RoleSid': role_sid, 'Attributes': attributes, 'FriendlyName': friendly_name,}) payload = self._version.update( 'POST', self._uri, data=data, ) return UserInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) @property def user_channels(self): """ Access the user_channels :returns: twilio.rest.chat.v1.service.user.user_channel.UserChannelList :rtype: twilio.rest.chat.v1.service.user.user_channel.UserChannelList """ if self._user_channels is None: self._user_channels = UserChannelList( self._version, service_sid=self._solution['service_sid'], user_sid=self._solution['sid'], ) return self._user_channels def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class UserInstance(InstanceResource): """ """ def __init__(self, version, payload, service_sid, sid=None): """ Initialize the UserInstance :returns: twilio.rest.chat.v1.service.user.UserInstance :rtype: twilio.rest.chat.v1.service.user.UserInstance """ super(UserInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'attributes': payload['attributes'], 'friendly_name': payload['friendly_name'], 'role_sid': payload['role_sid'], 'identity': payload['identity'], 'is_online': payload['is_online'], 'is_notifiable': payload['is_notifiable'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'joined_channels_count': deserialize.integer(payload['joined_channels_count']), 'links': payload['links'], 'url': payload['url'], } # Context self._context = None self._solution = {'service_sid': service_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.chat.v1.service.user.UserContext """ if self._context is None: self._context = UserContext( self._version, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def attributes(self): """ :returns: The attributes :rtype: unicode """ return self._properties['attributes'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def role_sid(self): """ :returns: The role_sid :rtype: unicode """ return self._properties['role_sid'] @property def identity(self): """ :returns: The identity :rtype: unicode """ return self._properties['identity'] @property def is_online(self): """ :returns: The is_online :rtype: bool """ return self._properties['is_online'] @property def is_notifiable(self): """ :returns: The is_notifiable :rtype: bool """ return self._properties['is_notifiable'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def joined_channels_count(self): """ :returns: The joined_channels_count :rtype: unicode """ return self._properties['joined_channels_count'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a UserInstance :returns: Fetched UserInstance :rtype: twilio.rest.chat.v1.service.user.UserInstance """ return self._proxy.fetch() def delete(self): """ Deletes the UserInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, role_sid=values.unset, attributes=values.unset, friendly_name=values.unset): """ Update the UserInstance :param unicode role_sid: The role_sid :param unicode attributes: The attributes :param unicode friendly_name: The friendly_name :returns: Updated UserInstance :rtype: twilio.rest.chat.v1.service.user.UserInstance """ return self._proxy.update(role_sid=role_sid, attributes=attributes, friendly_name=friendly_name,) @property def user_channels(self): """ Access the user_channels :returns: twilio.rest.chat.v1.service.user.user_channel.UserChannelList :rtype: twilio.rest.chat.v1.service.user.user_channel.UserChannelList """ return self._proxy.user_channels def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/chat/v1/service/user/user_channel.py000066400000000000000000000220471317472742600255660ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class UserChannelList(ListResource): """ """ def __init__(self, version, service_sid, user_sid): """ Initialize the UserChannelList :param Version version: Version that contains the resource :param service_sid: The service_sid :param user_sid: The sid :returns: twilio.rest.chat.v1.service.user.user_channel.UserChannelList :rtype: twilio.rest.chat.v1.service.user.user_channel.UserChannelList """ super(UserChannelList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'user_sid': user_sid,} self._uri = '/Services/{service_sid}/Users/{user_sid}/Channels'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams UserChannelInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v1.service.user.user_channel.UserChannelInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists UserChannelInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v1.service.user.user_channel.UserChannelInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of UserChannelInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of UserChannelInstance :rtype: twilio.rest.chat.v1.service.user.user_channel.UserChannelPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return UserChannelPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of UserChannelInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of UserChannelInstance :rtype: twilio.rest.chat.v1.service.user.user_channel.UserChannelPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return UserChannelPage(self._version, response, self._solution) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class UserChannelPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the UserChannelPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :param user_sid: The sid :returns: twilio.rest.chat.v1.service.user.user_channel.UserChannelPage :rtype: twilio.rest.chat.v1.service.user.user_channel.UserChannelPage """ super(UserChannelPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of UserChannelInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v1.service.user.user_channel.UserChannelInstance :rtype: twilio.rest.chat.v1.service.user.user_channel.UserChannelInstance """ return UserChannelInstance( self._version, payload, service_sid=self._solution['service_sid'], user_sid=self._solution['user_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class UserChannelInstance(InstanceResource): """ """ class ChannelStatus(object): JOINED = "joined" INVITED = "invited" NOT_PARTICIPATING = "not_participating" def __init__(self, version, payload, service_sid, user_sid): """ Initialize the UserChannelInstance :returns: twilio.rest.chat.v1.service.user.user_channel.UserChannelInstance :rtype: twilio.rest.chat.v1.service.user.user_channel.UserChannelInstance """ super(UserChannelInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'channel_sid': payload['channel_sid'], 'member_sid': payload['member_sid'], 'status': payload['status'], 'last_consumed_message_index': deserialize.integer(payload['last_consumed_message_index']), 'unread_messages_count': deserialize.integer(payload['unread_messages_count']), 'links': payload['links'], } # Context self._context = None self._solution = {'service_sid': service_sid, 'user_sid': user_sid,} @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def channel_sid(self): """ :returns: The channel_sid :rtype: unicode """ return self._properties['channel_sid'] @property def member_sid(self): """ :returns: The member_sid :rtype: unicode """ return self._properties['member_sid'] @property def status(self): """ :returns: The status :rtype: UserChannelInstance.ChannelStatus """ return self._properties['status'] @property def last_consumed_message_index(self): """ :returns: The last_consumed_message_index :rtype: unicode """ return self._properties['last_consumed_message_index'] @property def unread_messages_count(self): """ :returns: The unread_messages_count :rtype: unicode """ return self._properties['unread_messages_count'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/chat/v2/000077500000000000000000000000001317472742600201245ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/chat/v2/__init__.py000066400000000000000000000024011317472742600222320ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.version import Version from twilio.rest.chat.v2.credential import CredentialList from twilio.rest.chat.v2.service import ServiceList class V2(Version): def __init__(self, domain): """ Initialize the V2 version of Chat :returns: V2 version of Chat :rtype: twilio.rest.chat.v2.V2.V2 """ super(V2, self).__init__(domain) self.version = 'v2' self._credentials = None self._services = None @property def credentials(self): """ :rtype: twilio.rest.chat.v2.credential.CredentialList """ if self._credentials is None: self._credentials = CredentialList(self) return self._credentials @property def services(self): """ :rtype: twilio.rest.chat.v2.service.ServiceList """ if self._services is None: self._services = ServiceList(self) return self._services def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/chat/v2/credential.py000066400000000000000000000350461317472742600226200ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class CredentialList(ListResource): """ """ def __init__(self, version): """ Initialize the CredentialList :param Version version: Version that contains the resource :returns: twilio.rest.chat.v2.credential.CredentialList :rtype: twilio.rest.chat.v2.credential.CredentialList """ super(CredentialList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/Credentials'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams CredentialInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.credential.CredentialInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists CredentialInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.credential.CredentialInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of CredentialInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of CredentialInstance :rtype: twilio.rest.chat.v2.credential.CredentialPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return CredentialPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of CredentialInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of CredentialInstance :rtype: twilio.rest.chat.v2.credential.CredentialPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return CredentialPage(self._version, response, self._solution) def create(self, type, friendly_name=values.unset, certificate=values.unset, private_key=values.unset, sandbox=values.unset, api_key=values.unset, secret=values.unset): """ Create a new CredentialInstance :param CredentialInstance.PushService type: The type :param unicode friendly_name: The friendly_name :param unicode certificate: The certificate :param unicode private_key: The private_key :param bool sandbox: The sandbox :param unicode api_key: The api_key :param unicode secret: The secret :returns: Newly created CredentialInstance :rtype: twilio.rest.chat.v2.credential.CredentialInstance """ data = values.of({ 'Type': type, 'FriendlyName': friendly_name, 'Certificate': certificate, 'PrivateKey': private_key, 'Sandbox': sandbox, 'ApiKey': api_key, 'Secret': secret, }) payload = self._version.create( 'POST', self._uri, data=data, ) return CredentialInstance(self._version, payload,) def get(self, sid): """ Constructs a CredentialContext :param sid: The sid :returns: twilio.rest.chat.v2.credential.CredentialContext :rtype: twilio.rest.chat.v2.credential.CredentialContext """ return CredentialContext(self._version, sid=sid,) def __call__(self, sid): """ Constructs a CredentialContext :param sid: The sid :returns: twilio.rest.chat.v2.credential.CredentialContext :rtype: twilio.rest.chat.v2.credential.CredentialContext """ return CredentialContext(self._version, sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class CredentialPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the CredentialPage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.chat.v2.credential.CredentialPage :rtype: twilio.rest.chat.v2.credential.CredentialPage """ super(CredentialPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of CredentialInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v2.credential.CredentialInstance :rtype: twilio.rest.chat.v2.credential.CredentialInstance """ return CredentialInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class CredentialContext(InstanceContext): """ """ def __init__(self, version, sid): """ Initialize the CredentialContext :param Version version: Version that contains the resource :param sid: The sid :returns: twilio.rest.chat.v2.credential.CredentialContext :rtype: twilio.rest.chat.v2.credential.CredentialContext """ super(CredentialContext, self).__init__(version) # Path Solution self._solution = {'sid': sid,} self._uri = '/Credentials/{sid}'.format(**self._solution) def fetch(self): """ Fetch a CredentialInstance :returns: Fetched CredentialInstance :rtype: twilio.rest.chat.v2.credential.CredentialInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return CredentialInstance(self._version, payload, sid=self._solution['sid'],) def update(self, friendly_name=values.unset, certificate=values.unset, private_key=values.unset, sandbox=values.unset, api_key=values.unset, secret=values.unset): """ Update the CredentialInstance :param unicode friendly_name: The friendly_name :param unicode certificate: The certificate :param unicode private_key: The private_key :param bool sandbox: The sandbox :param unicode api_key: The api_key :param unicode secret: The secret :returns: Updated CredentialInstance :rtype: twilio.rest.chat.v2.credential.CredentialInstance """ data = values.of({ 'FriendlyName': friendly_name, 'Certificate': certificate, 'PrivateKey': private_key, 'Sandbox': sandbox, 'ApiKey': api_key, 'Secret': secret, }) payload = self._version.update( 'POST', self._uri, data=data, ) return CredentialInstance(self._version, payload, sid=self._solution['sid'],) def delete(self): """ Deletes the CredentialInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class CredentialInstance(InstanceResource): """ """ class PushService(object): GCM = "gcm" APN = "apn" FCM = "fcm" def __init__(self, version, payload, sid=None): """ Initialize the CredentialInstance :returns: twilio.rest.chat.v2.credential.CredentialInstance :rtype: twilio.rest.chat.v2.credential.CredentialInstance """ super(CredentialInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'friendly_name': payload['friendly_name'], 'type': payload['type'], 'sandbox': payload['sandbox'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'url': payload['url'], } # Context self._context = None self._solution = {'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: CredentialContext for this CredentialInstance :rtype: twilio.rest.chat.v2.credential.CredentialContext """ if self._context is None: self._context = CredentialContext(self._version, sid=self._solution['sid'],) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def type(self): """ :returns: The type :rtype: CredentialInstance.PushService """ return self._properties['type'] @property def sandbox(self): """ :returns: The sandbox :rtype: unicode """ return self._properties['sandbox'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a CredentialInstance :returns: Fetched CredentialInstance :rtype: twilio.rest.chat.v2.credential.CredentialInstance """ return self._proxy.fetch() def update(self, friendly_name=values.unset, certificate=values.unset, private_key=values.unset, sandbox=values.unset, api_key=values.unset, secret=values.unset): """ Update the CredentialInstance :param unicode friendly_name: The friendly_name :param unicode certificate: The certificate :param unicode private_key: The private_key :param bool sandbox: The sandbox :param unicode api_key: The api_key :param unicode secret: The secret :returns: Updated CredentialInstance :rtype: twilio.rest.chat.v2.credential.CredentialInstance """ return self._proxy.update( friendly_name=friendly_name, certificate=certificate, private_key=private_key, sandbox=sandbox, api_key=api_key, secret=secret, ) def delete(self): """ Deletes the CredentialInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/chat/v2/service/000077500000000000000000000000001317472742600215645ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/chat/v2/service/__init__.py000066400000000000000000000770301317472742600237040ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.chat.v2.service.binding import BindingList from twilio.rest.chat.v2.service.channel import ChannelList from twilio.rest.chat.v2.service.role import RoleList from twilio.rest.chat.v2.service.user import UserList class ServiceList(ListResource): """ """ def __init__(self, version): """ Initialize the ServiceList :param Version version: Version that contains the resource :returns: twilio.rest.chat.v2.service.ServiceList :rtype: twilio.rest.chat.v2.service.ServiceList """ super(ServiceList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/Services'.format(**self._solution) def create(self, friendly_name): """ Create a new ServiceInstance :param unicode friendly_name: The friendly_name :returns: Newly created ServiceInstance :rtype: twilio.rest.chat.v2.service.ServiceInstance """ data = values.of({'FriendlyName': friendly_name,}) payload = self._version.create( 'POST', self._uri, data=data, ) return ServiceInstance(self._version, payload,) def stream(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.ServiceInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.ServiceInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of ServiceInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of ServiceInstance :rtype: twilio.rest.chat.v2.service.ServicePage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return ServicePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of ServiceInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of ServiceInstance :rtype: twilio.rest.chat.v2.service.ServicePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return ServicePage(self._version, response, self._solution) def get(self, sid): """ Constructs a ServiceContext :param sid: The sid :returns: twilio.rest.chat.v2.service.ServiceContext :rtype: twilio.rest.chat.v2.service.ServiceContext """ return ServiceContext(self._version, sid=sid,) def __call__(self, sid): """ Constructs a ServiceContext :param sid: The sid :returns: twilio.rest.chat.v2.service.ServiceContext :rtype: twilio.rest.chat.v2.service.ServiceContext """ return ServiceContext(self._version, sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ServicePage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the ServicePage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.chat.v2.service.ServicePage :rtype: twilio.rest.chat.v2.service.ServicePage """ super(ServicePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of ServiceInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v2.service.ServiceInstance :rtype: twilio.rest.chat.v2.service.ServiceInstance """ return ServiceInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ServiceContext(InstanceContext): """ """ def __init__(self, version, sid): """ Initialize the ServiceContext :param Version version: Version that contains the resource :param sid: The sid :returns: twilio.rest.chat.v2.service.ServiceContext :rtype: twilio.rest.chat.v2.service.ServiceContext """ super(ServiceContext, self).__init__(version) # Path Solution self._solution = {'sid': sid,} self._uri = '/Services/{sid}'.format(**self._solution) # Dependents self._channels = None self._roles = None self._users = None self._bindings = None def fetch(self): """ Fetch a ServiceInstance :returns: Fetched ServiceInstance :rtype: twilio.rest.chat.v2.service.ServiceInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return ServiceInstance(self._version, payload, sid=self._solution['sid'],) def delete(self): """ Deletes the ServiceInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, friendly_name=values.unset, default_service_role_sid=values.unset, default_channel_role_sid=values.unset, default_channel_creator_role_sid=values.unset, read_status_enabled=values.unset, reachability_enabled=values.unset, typing_indicator_timeout=values.unset, consumption_report_interval=values.unset, notifications_new_message_enabled=values.unset, notifications_new_message_template=values.unset, notifications_new_message_sound=values.unset, notifications_new_message_badge_count_enabled=values.unset, notifications_added_to_channel_enabled=values.unset, notifications_added_to_channel_template=values.unset, notifications_added_to_channel_sound=values.unset, notifications_removed_from_channel_enabled=values.unset, notifications_removed_from_channel_template=values.unset, notifications_removed_from_channel_sound=values.unset, notifications_invited_to_channel_enabled=values.unset, notifications_invited_to_channel_template=values.unset, notifications_invited_to_channel_sound=values.unset, pre_webhook_url=values.unset, post_webhook_url=values.unset, webhook_method=values.unset, webhook_filters=values.unset, limits_channel_members=values.unset, limits_user_channels=values.unset, media_compatibility_message=values.unset, pre_webhook_retry_count=values.unset, post_webhook_retry_count=values.unset): """ Update the ServiceInstance :param unicode friendly_name: The friendly_name :param unicode default_service_role_sid: The default_service_role_sid :param unicode default_channel_role_sid: The default_channel_role_sid :param unicode default_channel_creator_role_sid: The default_channel_creator_role_sid :param bool read_status_enabled: The read_status_enabled :param bool reachability_enabled: The reachability_enabled :param unicode typing_indicator_timeout: The typing_indicator_timeout :param unicode consumption_report_interval: The consumption_report_interval :param bool notifications_new_message_enabled: The notifications.new_message.enabled :param unicode notifications_new_message_template: The notifications.new_message.template :param unicode notifications_new_message_sound: The notifications.new_message.sound :param bool notifications_new_message_badge_count_enabled: The notifications.new_message.badge_count_enabled :param bool notifications_added_to_channel_enabled: The notifications.added_to_channel.enabled :param unicode notifications_added_to_channel_template: The notifications.added_to_channel.template :param unicode notifications_added_to_channel_sound: The notifications.added_to_channel.sound :param bool notifications_removed_from_channel_enabled: The notifications.removed_from_channel.enabled :param unicode notifications_removed_from_channel_template: The notifications.removed_from_channel.template :param unicode notifications_removed_from_channel_sound: The notifications.removed_from_channel.sound :param bool notifications_invited_to_channel_enabled: The notifications.invited_to_channel.enabled :param unicode notifications_invited_to_channel_template: The notifications.invited_to_channel.template :param unicode notifications_invited_to_channel_sound: The notifications.invited_to_channel.sound :param unicode pre_webhook_url: The pre_webhook_url :param unicode post_webhook_url: The post_webhook_url :param unicode webhook_method: The webhook_method :param unicode webhook_filters: The webhook_filters :param unicode limits_channel_members: The limits.channel_members :param unicode limits_user_channels: The limits.user_channels :param unicode media_compatibility_message: The media.compatibility_message :param unicode pre_webhook_retry_count: The pre_webhook_retry_count :param unicode post_webhook_retry_count: The post_webhook_retry_count :returns: Updated ServiceInstance :rtype: twilio.rest.chat.v2.service.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, 'TypingIndicatorTimeout': typing_indicator_timeout, 'ConsumptionReportInterval': consumption_report_interval, 'Notifications.NewMessage.Enabled': 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.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.Template': notifications_removed_from_channel_template, 'Notifications.RemovedFromChannel.Sound': notifications_removed_from_channel_sound, 'Notifications.InvitedToChannel.Enabled': 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, 'PostWebhookUrl': post_webhook_url, 'WebhookMethod': webhook_method, 'WebhookFilters': webhook_filters, 'Limits.ChannelMembers': limits_channel_members, 'Limits.UserChannels': limits_user_channels, 'Media.CompatibilityMessage': media_compatibility_message, 'PreWebhookRetryCount': pre_webhook_retry_count, 'PostWebhookRetryCount': post_webhook_retry_count, }) payload = self._version.update( 'POST', self._uri, data=data, ) return ServiceInstance(self._version, payload, sid=self._solution['sid'],) @property def channels(self): """ Access the channels :returns: twilio.rest.chat.v2.service.channel.ChannelList :rtype: twilio.rest.chat.v2.service.channel.ChannelList """ if self._channels is None: self._channels = ChannelList(self._version, service_sid=self._solution['sid'],) return self._channels @property def roles(self): """ Access the roles :returns: twilio.rest.chat.v2.service.role.RoleList :rtype: twilio.rest.chat.v2.service.role.RoleList """ if self._roles is None: self._roles = RoleList(self._version, service_sid=self._solution['sid'],) return self._roles @property def users(self): """ Access the users :returns: twilio.rest.chat.v2.service.user.UserList :rtype: twilio.rest.chat.v2.service.user.UserList """ if self._users is None: self._users = UserList(self._version, service_sid=self._solution['sid'],) return self._users @property def bindings(self): """ Access the bindings :returns: twilio.rest.chat.v2.service.binding.BindingList :rtype: twilio.rest.chat.v2.service.binding.BindingList """ if self._bindings is None: self._bindings = BindingList(self._version, service_sid=self._solution['sid'],) return self._bindings def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class ServiceInstance(InstanceResource): """ """ def __init__(self, version, payload, sid=None): """ Initialize the ServiceInstance :returns: twilio.rest.chat.v2.service.ServiceInstance :rtype: twilio.rest.chat.v2.service.ServiceInstance """ super(ServiceInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'friendly_name': payload['friendly_name'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'default_service_role_sid': payload['default_service_role_sid'], 'default_channel_role_sid': payload['default_channel_role_sid'], 'default_channel_creator_role_sid': payload['default_channel_creator_role_sid'], 'read_status_enabled': payload['read_status_enabled'], 'reachability_enabled': payload['reachability_enabled'], 'typing_indicator_timeout': deserialize.integer(payload['typing_indicator_timeout']), 'consumption_report_interval': deserialize.integer(payload['consumption_report_interval']), 'limits': payload['limits'], 'pre_webhook_url': payload['pre_webhook_url'], 'post_webhook_url': payload['post_webhook_url'], 'webhook_method': payload['webhook_method'], 'webhook_filters': payload['webhook_filters'], 'pre_webhook_retry_count': deserialize.integer(payload['pre_webhook_retry_count']), 'post_webhook_retry_count': deserialize.integer(payload['post_webhook_retry_count']), 'notifications': payload['notifications'], 'media': payload['media'], 'url': payload['url'], 'links': payload['links'], } # Context self._context = None self._solution = {'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.chat.v2.service.ServiceContext """ if self._context is None: self._context = ServiceContext(self._version, sid=self._solution['sid'],) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def default_service_role_sid(self): """ :returns: The default_service_role_sid :rtype: unicode """ return self._properties['default_service_role_sid'] @property def default_channel_role_sid(self): """ :returns: The default_channel_role_sid :rtype: unicode """ return self._properties['default_channel_role_sid'] @property def default_channel_creator_role_sid(self): """ :returns: The default_channel_creator_role_sid :rtype: unicode """ return self._properties['default_channel_creator_role_sid'] @property def read_status_enabled(self): """ :returns: The read_status_enabled :rtype: bool """ return self._properties['read_status_enabled'] @property def reachability_enabled(self): """ :returns: The reachability_enabled :rtype: bool """ return self._properties['reachability_enabled'] @property def typing_indicator_timeout(self): """ :returns: The typing_indicator_timeout :rtype: unicode """ return self._properties['typing_indicator_timeout'] @property def consumption_report_interval(self): """ :returns: The consumption_report_interval :rtype: unicode """ return self._properties['consumption_report_interval'] @property def limits(self): """ :returns: The limits :rtype: dict """ return self._properties['limits'] @property def pre_webhook_url(self): """ :returns: The pre_webhook_url :rtype: unicode """ return self._properties['pre_webhook_url'] @property def post_webhook_url(self): """ :returns: The post_webhook_url :rtype: unicode """ return self._properties['post_webhook_url'] @property def webhook_method(self): """ :returns: The webhook_method :rtype: unicode """ return self._properties['webhook_method'] @property def webhook_filters(self): """ :returns: The webhook_filters :rtype: unicode """ return self._properties['webhook_filters'] @property def pre_webhook_retry_count(self): """ :returns: The pre_webhook_retry_count :rtype: unicode """ return self._properties['pre_webhook_retry_count'] @property def post_webhook_retry_count(self): """ :returns: The post_webhook_retry_count :rtype: unicode """ return self._properties['post_webhook_retry_count'] @property def notifications(self): """ :returns: The notifications :rtype: dict """ return self._properties['notifications'] @property def media(self): """ :returns: The media :rtype: dict """ return self._properties['media'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a ServiceInstance :returns: Fetched ServiceInstance :rtype: twilio.rest.chat.v2.service.ServiceInstance """ return self._proxy.fetch() def delete(self): """ Deletes the ServiceInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, friendly_name=values.unset, default_service_role_sid=values.unset, default_channel_role_sid=values.unset, default_channel_creator_role_sid=values.unset, read_status_enabled=values.unset, reachability_enabled=values.unset, typing_indicator_timeout=values.unset, consumption_report_interval=values.unset, notifications_new_message_enabled=values.unset, notifications_new_message_template=values.unset, notifications_new_message_sound=values.unset, notifications_new_message_badge_count_enabled=values.unset, notifications_added_to_channel_enabled=values.unset, notifications_added_to_channel_template=values.unset, notifications_added_to_channel_sound=values.unset, notifications_removed_from_channel_enabled=values.unset, notifications_removed_from_channel_template=values.unset, notifications_removed_from_channel_sound=values.unset, notifications_invited_to_channel_enabled=values.unset, notifications_invited_to_channel_template=values.unset, notifications_invited_to_channel_sound=values.unset, pre_webhook_url=values.unset, post_webhook_url=values.unset, webhook_method=values.unset, webhook_filters=values.unset, limits_channel_members=values.unset, limits_user_channels=values.unset, media_compatibility_message=values.unset, pre_webhook_retry_count=values.unset, post_webhook_retry_count=values.unset): """ Update the ServiceInstance :param unicode friendly_name: The friendly_name :param unicode default_service_role_sid: The default_service_role_sid :param unicode default_channel_role_sid: The default_channel_role_sid :param unicode default_channel_creator_role_sid: The default_channel_creator_role_sid :param bool read_status_enabled: The read_status_enabled :param bool reachability_enabled: The reachability_enabled :param unicode typing_indicator_timeout: The typing_indicator_timeout :param unicode consumption_report_interval: The consumption_report_interval :param bool notifications_new_message_enabled: The notifications.new_message.enabled :param unicode notifications_new_message_template: The notifications.new_message.template :param unicode notifications_new_message_sound: The notifications.new_message.sound :param bool notifications_new_message_badge_count_enabled: The notifications.new_message.badge_count_enabled :param bool notifications_added_to_channel_enabled: The notifications.added_to_channel.enabled :param unicode notifications_added_to_channel_template: The notifications.added_to_channel.template :param unicode notifications_added_to_channel_sound: The notifications.added_to_channel.sound :param bool notifications_removed_from_channel_enabled: The notifications.removed_from_channel.enabled :param unicode notifications_removed_from_channel_template: The notifications.removed_from_channel.template :param unicode notifications_removed_from_channel_sound: The notifications.removed_from_channel.sound :param bool notifications_invited_to_channel_enabled: The notifications.invited_to_channel.enabled :param unicode notifications_invited_to_channel_template: The notifications.invited_to_channel.template :param unicode notifications_invited_to_channel_sound: The notifications.invited_to_channel.sound :param unicode pre_webhook_url: The pre_webhook_url :param unicode post_webhook_url: The post_webhook_url :param unicode webhook_method: The webhook_method :param unicode webhook_filters: The webhook_filters :param unicode limits_channel_members: The limits.channel_members :param unicode limits_user_channels: The limits.user_channels :param unicode media_compatibility_message: The media.compatibility_message :param unicode pre_webhook_retry_count: The pre_webhook_retry_count :param unicode post_webhook_retry_count: The post_webhook_retry_count :returns: Updated ServiceInstance :rtype: twilio.rest.chat.v2.service.ServiceInstance """ return self._proxy.update( friendly_name=friendly_name, default_service_role_sid=default_service_role_sid, default_channel_role_sid=default_channel_role_sid, default_channel_creator_role_sid=default_channel_creator_role_sid, read_status_enabled=read_status_enabled, reachability_enabled=reachability_enabled, typing_indicator_timeout=typing_indicator_timeout, consumption_report_interval=consumption_report_interval, notifications_new_message_enabled=notifications_new_message_enabled, notifications_new_message_template=notifications_new_message_template, notifications_new_message_sound=notifications_new_message_sound, notifications_new_message_badge_count_enabled=notifications_new_message_badge_count_enabled, notifications_added_to_channel_enabled=notifications_added_to_channel_enabled, notifications_added_to_channel_template=notifications_added_to_channel_template, notifications_added_to_channel_sound=notifications_added_to_channel_sound, notifications_removed_from_channel_enabled=notifications_removed_from_channel_enabled, notifications_removed_from_channel_template=notifications_removed_from_channel_template, notifications_removed_from_channel_sound=notifications_removed_from_channel_sound, notifications_invited_to_channel_enabled=notifications_invited_to_channel_enabled, notifications_invited_to_channel_template=notifications_invited_to_channel_template, notifications_invited_to_channel_sound=notifications_invited_to_channel_sound, pre_webhook_url=pre_webhook_url, post_webhook_url=post_webhook_url, webhook_method=webhook_method, webhook_filters=webhook_filters, limits_channel_members=limits_channel_members, limits_user_channels=limits_user_channels, media_compatibility_message=media_compatibility_message, pre_webhook_retry_count=pre_webhook_retry_count, post_webhook_retry_count=post_webhook_retry_count, ) @property def channels(self): """ Access the channels :returns: twilio.rest.chat.v2.service.channel.ChannelList :rtype: twilio.rest.chat.v2.service.channel.ChannelList """ return self._proxy.channels @property def roles(self): """ Access the roles :returns: twilio.rest.chat.v2.service.role.RoleList :rtype: twilio.rest.chat.v2.service.role.RoleList """ return self._proxy.roles @property def users(self): """ Access the users :returns: twilio.rest.chat.v2.service.user.UserList :rtype: twilio.rest.chat.v2.service.user.UserList """ return self._proxy.users @property def bindings(self): """ Access the bindings :returns: twilio.rest.chat.v2.service.binding.BindingList :rtype: twilio.rest.chat.v2.service.binding.BindingList """ return self._proxy.bindings def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/chat/v2/service/binding.py000066400000000000000000000331721317472742600235560ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class BindingList(ListResource): """ """ def __init__(self, version, service_sid): """ Initialize the BindingList :param Version version: Version that contains the resource :param service_sid: The service_sid :returns: twilio.rest.chat.v2.service.binding.BindingList :rtype: twilio.rest.chat.v2.service.binding.BindingList """ super(BindingList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid,} self._uri = '/Services/{service_sid}/Bindings'.format(**self._solution) def stream(self, binding_type=values.unset, identity=values.unset, limit=None, page_size=None): """ Streams BindingInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param BindingInstance.BindingType binding_type: The binding_type :param unicode identity: The identity :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.binding.BindingInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(binding_type=binding_type, identity=identity, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, binding_type=values.unset, identity=values.unset, limit=None, page_size=None): """ Lists BindingInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param BindingInstance.BindingType binding_type: The binding_type :param unicode identity: The identity :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.binding.BindingInstance] """ return list(self.stream( binding_type=binding_type, identity=identity, limit=limit, page_size=page_size, )) def page(self, binding_type=values.unset, identity=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of BindingInstance records from the API. Request is executed immediately :param BindingInstance.BindingType binding_type: The binding_type :param unicode identity: The identity :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of BindingInstance :rtype: twilio.rest.chat.v2.service.binding.BindingPage """ params = values.of({ 'BindingType': binding_type, 'Identity': identity, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return BindingPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of BindingInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of BindingInstance :rtype: twilio.rest.chat.v2.service.binding.BindingPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return BindingPage(self._version, response, self._solution) def get(self, sid): """ Constructs a BindingContext :param sid: The sid :returns: twilio.rest.chat.v2.service.binding.BindingContext :rtype: twilio.rest.chat.v2.service.binding.BindingContext """ return BindingContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __call__(self, sid): """ Constructs a BindingContext :param sid: The sid :returns: twilio.rest.chat.v2.service.binding.BindingContext :rtype: twilio.rest.chat.v2.service.binding.BindingContext """ return BindingContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class BindingPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the BindingPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :returns: twilio.rest.chat.v2.service.binding.BindingPage :rtype: twilio.rest.chat.v2.service.binding.BindingPage """ super(BindingPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of BindingInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v2.service.binding.BindingInstance :rtype: twilio.rest.chat.v2.service.binding.BindingInstance """ return BindingInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class BindingContext(InstanceContext): """ """ def __init__(self, version, service_sid, sid): """ Initialize the BindingContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param sid: The sid :returns: twilio.rest.chat.v2.service.binding.BindingContext :rtype: twilio.rest.chat.v2.service.binding.BindingContext """ super(BindingContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Bindings/{sid}'.format(**self._solution) def fetch(self): """ Fetch a BindingInstance :returns: Fetched BindingInstance :rtype: twilio.rest.chat.v2.service.binding.BindingInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return BindingInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the BindingInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class BindingInstance(InstanceResource): """ """ class BindingType(object): GCM = "gcm" APN = "apn" FCM = "fcm" def __init__(self, version, payload, service_sid, sid=None): """ Initialize the BindingInstance :returns: twilio.rest.chat.v2.service.binding.BindingInstance :rtype: twilio.rest.chat.v2.service.binding.BindingInstance """ super(BindingInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'endpoint': payload['endpoint'], 'identity': payload['identity'], 'credential_sid': payload['credential_sid'], 'binding_type': payload['binding_type'], 'message_types': payload['message_types'], 'url': payload['url'], 'links': payload['links'], } # Context self._context = None self._solution = {'service_sid': service_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: BindingContext for this BindingInstance :rtype: twilio.rest.chat.v2.service.binding.BindingContext """ if self._context is None: self._context = BindingContext( self._version, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def endpoint(self): """ :returns: The endpoint :rtype: unicode """ return self._properties['endpoint'] @property def identity(self): """ :returns: The identity :rtype: unicode """ return self._properties['identity'] @property def credential_sid(self): """ :returns: The credential_sid :rtype: unicode """ return self._properties['credential_sid'] @property def binding_type(self): """ :returns: The binding_type :rtype: BindingInstance.BindingType """ return self._properties['binding_type'] @property def message_types(self): """ :returns: The message_types :rtype: unicode """ return self._properties['message_types'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a BindingInstance :returns: Fetched BindingInstance :rtype: twilio.rest.chat.v2.service.binding.BindingInstance """ return self._proxy.fetch() def delete(self): """ Deletes the BindingInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/chat/v2/service/channel/000077500000000000000000000000001317472742600231745ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/chat/v2/service/channel/__init__.py000066400000000000000000000473171317472742600253210ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize 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.page import Page from twilio.rest.chat.v2.service.channel.invite import InviteList from twilio.rest.chat.v2.service.channel.member import MemberList from twilio.rest.chat.v2.service.channel.message import MessageList class ChannelList(ListResource): """ """ def __init__(self, version, service_sid): """ Initialize the ChannelList :param Version version: Version that contains the resource :param service_sid: The service_sid :returns: twilio.rest.chat.v2.service.channel.ChannelList :rtype: twilio.rest.chat.v2.service.channel.ChannelList """ super(ChannelList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid,} self._uri = '/Services/{service_sid}/Channels'.format(**self._solution) def create(self, friendly_name=values.unset, unique_name=values.unset, attributes=values.unset, type=values.unset, date_created=values.unset, date_updated=values.unset, created_by=values.unset): """ Create a new ChannelInstance :param unicode friendly_name: The friendly_name :param unicode unique_name: The unique_name :param unicode attributes: The attributes :param ChannelInstance.ChannelType type: The type :param datetime date_created: The date_created :param datetime date_updated: The date_updated :param unicode created_by: The created_by :returns: Newly created ChannelInstance :rtype: twilio.rest.chat.v2.service.channel.ChannelInstance """ data = values.of({ 'FriendlyName': friendly_name, 'UniqueName': unique_name, 'Attributes': attributes, 'Type': type, 'DateCreated': serialize.iso8601_datetime(date_created), 'DateUpdated': serialize.iso8601_datetime(date_updated), 'CreatedBy': created_by, }) payload = self._version.create( 'POST', self._uri, data=data, ) return ChannelInstance(self._version, payload, service_sid=self._solution['service_sid'],) def stream(self, type=values.unset, limit=None, page_size=None): """ Streams ChannelInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param ChannelInstance.ChannelType type: The type :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.channel.ChannelInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(type=type, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, type=values.unset, limit=None, page_size=None): """ Lists ChannelInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param ChannelInstance.ChannelType type: The type :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.channel.ChannelInstance] """ return list(self.stream(type=type, limit=limit, page_size=page_size,)) def page(self, type=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of ChannelInstance records from the API. Request is executed immediately :param ChannelInstance.ChannelType type: The type :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of ChannelInstance :rtype: twilio.rest.chat.v2.service.channel.ChannelPage """ params = values.of({'Type': type, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return ChannelPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of ChannelInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of ChannelInstance :rtype: twilio.rest.chat.v2.service.channel.ChannelPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return ChannelPage(self._version, response, self._solution) def get(self, sid): """ Constructs a ChannelContext :param sid: The sid :returns: twilio.rest.chat.v2.service.channel.ChannelContext :rtype: twilio.rest.chat.v2.service.channel.ChannelContext """ return ChannelContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __call__(self, sid): """ Constructs a ChannelContext :param sid: The sid :returns: twilio.rest.chat.v2.service.channel.ChannelContext :rtype: twilio.rest.chat.v2.service.channel.ChannelContext """ return ChannelContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ChannelPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the ChannelPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :returns: twilio.rest.chat.v2.service.channel.ChannelPage :rtype: twilio.rest.chat.v2.service.channel.ChannelPage """ super(ChannelPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of ChannelInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v2.service.channel.ChannelInstance :rtype: twilio.rest.chat.v2.service.channel.ChannelInstance """ return ChannelInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ChannelContext(InstanceContext): """ """ def __init__(self, version, service_sid, sid): """ Initialize the ChannelContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param sid: The sid :returns: twilio.rest.chat.v2.service.channel.ChannelContext :rtype: twilio.rest.chat.v2.service.channel.ChannelContext """ super(ChannelContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Channels/{sid}'.format(**self._solution) # Dependents self._members = None self._messages = None self._invites = None def fetch(self): """ Fetch a ChannelInstance :returns: Fetched ChannelInstance :rtype: twilio.rest.chat.v2.service.channel.ChannelInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return ChannelInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the ChannelInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, friendly_name=values.unset, unique_name=values.unset, attributes=values.unset, date_created=values.unset, date_updated=values.unset, created_by=values.unset): """ Update the ChannelInstance :param unicode friendly_name: The friendly_name :param unicode unique_name: The unique_name :param unicode attributes: The attributes :param datetime date_created: The date_created :param datetime date_updated: The date_updated :param unicode created_by: The created_by :returns: Updated ChannelInstance :rtype: twilio.rest.chat.v2.service.channel.ChannelInstance """ data = values.of({ 'FriendlyName': friendly_name, 'UniqueName': unique_name, 'Attributes': attributes, 'DateCreated': serialize.iso8601_datetime(date_created), 'DateUpdated': serialize.iso8601_datetime(date_updated), 'CreatedBy': created_by, }) payload = self._version.update( 'POST', self._uri, data=data, ) return ChannelInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) @property def members(self): """ Access the members :returns: twilio.rest.chat.v2.service.channel.member.MemberList :rtype: twilio.rest.chat.v2.service.channel.member.MemberList """ if self._members is None: self._members = MemberList( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['sid'], ) return self._members @property def messages(self): """ Access the messages :returns: twilio.rest.chat.v2.service.channel.message.MessageList :rtype: twilio.rest.chat.v2.service.channel.message.MessageList """ if self._messages is None: self._messages = MessageList( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['sid'], ) return self._messages @property def invites(self): """ Access the invites :returns: twilio.rest.chat.v2.service.channel.invite.InviteList :rtype: twilio.rest.chat.v2.service.channel.invite.InviteList """ if self._invites is None: self._invites = InviteList( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['sid'], ) return self._invites def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class ChannelInstance(InstanceResource): """ """ class ChannelType(object): PUBLIC = "public" PRIVATE = "private" def __init__(self, version, payload, service_sid, sid=None): """ Initialize the ChannelInstance :returns: twilio.rest.chat.v2.service.channel.ChannelInstance :rtype: twilio.rest.chat.v2.service.channel.ChannelInstance """ super(ChannelInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'friendly_name': payload['friendly_name'], 'unique_name': payload['unique_name'], 'attributes': payload['attributes'], 'type': payload['type'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'created_by': payload['created_by'], 'members_count': deserialize.integer(payload['members_count']), 'messages_count': deserialize.integer(payload['messages_count']), 'url': payload['url'], 'links': payload['links'], } # Context self._context = None self._solution = {'service_sid': service_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: ChannelContext for this ChannelInstance :rtype: twilio.rest.chat.v2.service.channel.ChannelContext """ if self._context is None: self._context = ChannelContext( self._version, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def unique_name(self): """ :returns: The unique_name :rtype: unicode """ return self._properties['unique_name'] @property def attributes(self): """ :returns: The attributes :rtype: unicode """ return self._properties['attributes'] @property def type(self): """ :returns: The type :rtype: ChannelInstance.ChannelType """ return self._properties['type'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def created_by(self): """ :returns: The created_by :rtype: unicode """ return self._properties['created_by'] @property def members_count(self): """ :returns: The members_count :rtype: unicode """ return self._properties['members_count'] @property def messages_count(self): """ :returns: The messages_count :rtype: unicode """ return self._properties['messages_count'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a ChannelInstance :returns: Fetched ChannelInstance :rtype: twilio.rest.chat.v2.service.channel.ChannelInstance """ return self._proxy.fetch() def delete(self): """ Deletes the ChannelInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, friendly_name=values.unset, unique_name=values.unset, attributes=values.unset, date_created=values.unset, date_updated=values.unset, created_by=values.unset): """ Update the ChannelInstance :param unicode friendly_name: The friendly_name :param unicode unique_name: The unique_name :param unicode attributes: The attributes :param datetime date_created: The date_created :param datetime date_updated: The date_updated :param unicode created_by: The created_by :returns: Updated ChannelInstance :rtype: twilio.rest.chat.v2.service.channel.ChannelInstance """ return self._proxy.update( friendly_name=friendly_name, unique_name=unique_name, attributes=attributes, date_created=date_created, date_updated=date_updated, created_by=created_by, ) @property def members(self): """ Access the members :returns: twilio.rest.chat.v2.service.channel.member.MemberList :rtype: twilio.rest.chat.v2.service.channel.member.MemberList """ return self._proxy.members @property def messages(self): """ Access the messages :returns: twilio.rest.chat.v2.service.channel.message.MessageList :rtype: twilio.rest.chat.v2.service.channel.message.MessageList """ return self._proxy.messages @property def invites(self): """ Access the invites :returns: twilio.rest.chat.v2.service.channel.invite.InviteList :rtype: twilio.rest.chat.v2.service.channel.invite.InviteList """ return self._proxy.invites def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/chat/v2/service/channel/invite.py000066400000000000000000000341671317472742600250570ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class InviteList(ListResource): """ """ def __init__(self, version, service_sid, channel_sid): """ Initialize the InviteList :param Version version: Version that contains the resource :param service_sid: The service_sid :param channel_sid: The channel_sid :returns: twilio.rest.chat.v2.service.channel.invite.InviteList :rtype: twilio.rest.chat.v2.service.channel.invite.InviteList """ super(InviteList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'channel_sid': channel_sid,} self._uri = '/Services/{service_sid}/Channels/{channel_sid}/Invites'.format(**self._solution) def create(self, identity, role_sid=values.unset): """ Create a new InviteInstance :param unicode identity: The identity :param unicode role_sid: The role_sid :returns: Newly created InviteInstance :rtype: twilio.rest.chat.v2.service.channel.invite.InviteInstance """ data = values.of({'Identity': identity, 'RoleSid': role_sid,}) payload = self._version.create( 'POST', self._uri, data=data, ) return InviteInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], ) def stream(self, identity=values.unset, limit=None, page_size=None): """ Streams InviteInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param unicode identity: The identity :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.channel.invite.InviteInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(identity=identity, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, identity=values.unset, limit=None, page_size=None): """ Lists InviteInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param unicode identity: The identity :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.channel.invite.InviteInstance] """ return list(self.stream(identity=identity, limit=limit, page_size=page_size,)) def page(self, identity=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of InviteInstance records from the API. Request is executed immediately :param unicode identity: The identity :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of InviteInstance :rtype: twilio.rest.chat.v2.service.channel.invite.InvitePage """ params = values.of({ 'Identity': identity, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return InvitePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of InviteInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of InviteInstance :rtype: twilio.rest.chat.v2.service.channel.invite.InvitePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return InvitePage(self._version, response, self._solution) def get(self, sid): """ Constructs a InviteContext :param sid: The sid :returns: twilio.rest.chat.v2.service.channel.invite.InviteContext :rtype: twilio.rest.chat.v2.service.channel.invite.InviteContext """ return InviteContext( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a InviteContext :param sid: The sid :returns: twilio.rest.chat.v2.service.channel.invite.InviteContext :rtype: twilio.rest.chat.v2.service.channel.invite.InviteContext """ return InviteContext( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class InvitePage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the InvitePage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :param channel_sid: The channel_sid :returns: twilio.rest.chat.v2.service.channel.invite.InvitePage :rtype: twilio.rest.chat.v2.service.channel.invite.InvitePage """ super(InvitePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of InviteInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v2.service.channel.invite.InviteInstance :rtype: twilio.rest.chat.v2.service.channel.invite.InviteInstance """ return InviteInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class InviteContext(InstanceContext): """ """ def __init__(self, version, service_sid, channel_sid, sid): """ Initialize the InviteContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param channel_sid: The channel_sid :param sid: The sid :returns: twilio.rest.chat.v2.service.channel.invite.InviteContext :rtype: twilio.rest.chat.v2.service.channel.invite.InviteContext """ super(InviteContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'channel_sid': channel_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Channels/{channel_sid}/Invites/{sid}'.format(**self._solution) def fetch(self): """ Fetch a InviteInstance :returns: Fetched InviteInstance :rtype: twilio.rest.chat.v2.service.channel.invite.InviteInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return InviteInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the InviteInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class InviteInstance(InstanceResource): """ """ def __init__(self, version, payload, service_sid, channel_sid, sid=None): """ Initialize the InviteInstance :returns: twilio.rest.chat.v2.service.channel.invite.InviteInstance :rtype: twilio.rest.chat.v2.service.channel.invite.InviteInstance """ super(InviteInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'channel_sid': payload['channel_sid'], 'service_sid': payload['service_sid'], 'identity': payload['identity'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'role_sid': payload['role_sid'], 'created_by': payload['created_by'], 'url': payload['url'], } # Context self._context = None self._solution = { 'service_sid': service_sid, 'channel_sid': channel_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: InviteContext for this InviteInstance :rtype: twilio.rest.chat.v2.service.channel.invite.InviteContext """ if self._context is None: self._context = InviteContext( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def channel_sid(self): """ :returns: The channel_sid :rtype: unicode """ return self._properties['channel_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def identity(self): """ :returns: The identity :rtype: unicode """ return self._properties['identity'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def role_sid(self): """ :returns: The role_sid :rtype: unicode """ return self._properties['role_sid'] @property def created_by(self): """ :returns: The created_by :rtype: unicode """ return self._properties['created_by'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a InviteInstance :returns: Fetched InviteInstance :rtype: twilio.rest.chat.v2.service.channel.invite.InviteInstance """ return self._proxy.fetch() def delete(self): """ Deletes the InviteInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/chat/v2/service/channel/member.py000066400000000000000000000434171317472742600250260ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize 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.page import Page class MemberList(ListResource): """ """ def __init__(self, version, service_sid, channel_sid): """ Initialize the MemberList :param Version version: Version that contains the resource :param service_sid: The service_sid :param channel_sid: The channel_sid :returns: twilio.rest.chat.v2.service.channel.member.MemberList :rtype: twilio.rest.chat.v2.service.channel.member.MemberList """ super(MemberList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'channel_sid': channel_sid,} self._uri = '/Services/{service_sid}/Channels/{channel_sid}/Members'.format(**self._solution) def create(self, identity, role_sid=values.unset, last_consumed_message_index=values.unset, last_consumption_timestamp=values.unset, date_created=values.unset, date_updated=values.unset): """ Create a new MemberInstance :param unicode identity: The identity :param unicode role_sid: The role_sid :param unicode last_consumed_message_index: The last_consumed_message_index :param datetime last_consumption_timestamp: The last_consumption_timestamp :param datetime date_created: The date_created :param datetime date_updated: The date_updated :returns: Newly created MemberInstance :rtype: twilio.rest.chat.v2.service.channel.member.MemberInstance """ data = values.of({ 'Identity': identity, 'RoleSid': role_sid, 'LastConsumedMessageIndex': last_consumed_message_index, 'LastConsumptionTimestamp': serialize.iso8601_datetime(last_consumption_timestamp), 'DateCreated': serialize.iso8601_datetime(date_created), 'DateUpdated': serialize.iso8601_datetime(date_updated), }) payload = self._version.create( 'POST', self._uri, data=data, ) return MemberInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], ) def stream(self, identity=values.unset, limit=None, page_size=None): """ Streams MemberInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param unicode identity: The identity :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.channel.member.MemberInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(identity=identity, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, identity=values.unset, limit=None, page_size=None): """ Lists MemberInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param unicode identity: The identity :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.channel.member.MemberInstance] """ return list(self.stream(identity=identity, limit=limit, page_size=page_size,)) def page(self, identity=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of MemberInstance records from the API. Request is executed immediately :param unicode identity: The identity :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of MemberInstance :rtype: twilio.rest.chat.v2.service.channel.member.MemberPage """ params = values.of({ 'Identity': identity, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return MemberPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of MemberInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of MemberInstance :rtype: twilio.rest.chat.v2.service.channel.member.MemberPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return MemberPage(self._version, response, self._solution) def get(self, sid): """ Constructs a MemberContext :param sid: The sid :returns: twilio.rest.chat.v2.service.channel.member.MemberContext :rtype: twilio.rest.chat.v2.service.channel.member.MemberContext """ return MemberContext( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a MemberContext :param sid: The sid :returns: twilio.rest.chat.v2.service.channel.member.MemberContext :rtype: twilio.rest.chat.v2.service.channel.member.MemberContext """ return MemberContext( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class MemberPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the MemberPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :param channel_sid: The channel_sid :returns: twilio.rest.chat.v2.service.channel.member.MemberPage :rtype: twilio.rest.chat.v2.service.channel.member.MemberPage """ super(MemberPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of MemberInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v2.service.channel.member.MemberInstance :rtype: twilio.rest.chat.v2.service.channel.member.MemberInstance """ return MemberInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class MemberContext(InstanceContext): """ """ def __init__(self, version, service_sid, channel_sid, sid): """ Initialize the MemberContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param channel_sid: The channel_sid :param sid: The sid :returns: twilio.rest.chat.v2.service.channel.member.MemberContext :rtype: twilio.rest.chat.v2.service.channel.member.MemberContext """ super(MemberContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'channel_sid': channel_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Channels/{channel_sid}/Members/{sid}'.format(**self._solution) def fetch(self): """ Fetch a MemberInstance :returns: Fetched MemberInstance :rtype: twilio.rest.chat.v2.service.channel.member.MemberInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return MemberInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the MemberInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, role_sid=values.unset, last_consumed_message_index=values.unset, last_consumption_timestamp=values.unset, date_created=values.unset, date_updated=values.unset): """ Update the MemberInstance :param unicode role_sid: The role_sid :param unicode last_consumed_message_index: The last_consumed_message_index :param datetime last_consumption_timestamp: The last_consumption_timestamp :param datetime date_created: The date_created :param datetime date_updated: The date_updated :returns: Updated MemberInstance :rtype: twilio.rest.chat.v2.service.channel.member.MemberInstance """ data = values.of({ 'RoleSid': role_sid, 'LastConsumedMessageIndex': last_consumed_message_index, 'LastConsumptionTimestamp': serialize.iso8601_datetime(last_consumption_timestamp), 'DateCreated': serialize.iso8601_datetime(date_created), 'DateUpdated': serialize.iso8601_datetime(date_updated), }) payload = self._version.update( 'POST', self._uri, data=data, ) return MemberInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class MemberInstance(InstanceResource): """ """ def __init__(self, version, payload, service_sid, channel_sid, sid=None): """ Initialize the MemberInstance :returns: twilio.rest.chat.v2.service.channel.member.MemberInstance :rtype: twilio.rest.chat.v2.service.channel.member.MemberInstance """ super(MemberInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'channel_sid': payload['channel_sid'], 'service_sid': payload['service_sid'], 'identity': payload['identity'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'role_sid': payload['role_sid'], 'last_consumed_message_index': deserialize.integer(payload['last_consumed_message_index']), 'last_consumption_timestamp': deserialize.iso8601_datetime(payload['last_consumption_timestamp']), 'url': payload['url'], } # Context self._context = None self._solution = { 'service_sid': service_sid, 'channel_sid': channel_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: MemberContext for this MemberInstance :rtype: twilio.rest.chat.v2.service.channel.member.MemberContext """ if self._context is None: self._context = MemberContext( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def channel_sid(self): """ :returns: The channel_sid :rtype: unicode """ return self._properties['channel_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def identity(self): """ :returns: The identity :rtype: unicode """ return self._properties['identity'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def role_sid(self): """ :returns: The role_sid :rtype: unicode """ return self._properties['role_sid'] @property def last_consumed_message_index(self): """ :returns: The last_consumed_message_index :rtype: unicode """ return self._properties['last_consumed_message_index'] @property def last_consumption_timestamp(self): """ :returns: The last_consumption_timestamp :rtype: datetime """ return self._properties['last_consumption_timestamp'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a MemberInstance :returns: Fetched MemberInstance :rtype: twilio.rest.chat.v2.service.channel.member.MemberInstance """ return self._proxy.fetch() def delete(self): """ Deletes the MemberInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, role_sid=values.unset, last_consumed_message_index=values.unset, last_consumption_timestamp=values.unset, date_created=values.unset, date_updated=values.unset): """ Update the MemberInstance :param unicode role_sid: The role_sid :param unicode last_consumed_message_index: The last_consumed_message_index :param datetime last_consumption_timestamp: The last_consumption_timestamp :param datetime date_created: The date_created :param datetime date_updated: The date_updated :returns: Updated MemberInstance :rtype: twilio.rest.chat.v2.service.channel.member.MemberInstance """ return self._proxy.update( role_sid=role_sid, last_consumed_message_index=last_consumed_message_index, last_consumption_timestamp=last_consumption_timestamp, date_created=date_created, date_updated=date_updated, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/chat/v2/service/channel/message.py000066400000000000000000000443471317472742600252060ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize 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.page import Page class MessageList(ListResource): """ """ def __init__(self, version, service_sid, channel_sid): """ Initialize the MessageList :param Version version: Version that contains the resource :param service_sid: The service_sid :param channel_sid: The channel_sid :returns: twilio.rest.chat.v2.service.channel.message.MessageList :rtype: twilio.rest.chat.v2.service.channel.message.MessageList """ super(MessageList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'channel_sid': channel_sid,} self._uri = '/Services/{service_sid}/Channels/{channel_sid}/Messages'.format(**self._solution) def create(self, from_=values.unset, attributes=values.unset, date_created=values.unset, date_updated=values.unset, last_updated_by=values.unset, body=values.unset, media_sid=values.unset): """ Create a new MessageInstance :param unicode from_: The from :param unicode attributes: The attributes :param datetime date_created: The date_created :param datetime date_updated: The date_updated :param unicode last_updated_by: The last_updated_by :param unicode body: The body :param unicode media_sid: The media_sid :returns: Newly created MessageInstance :rtype: twilio.rest.chat.v2.service.channel.message.MessageInstance """ data = values.of({ 'From': from_, 'Attributes': attributes, 'DateCreated': serialize.iso8601_datetime(date_created), 'DateUpdated': serialize.iso8601_datetime(date_updated), 'LastUpdatedBy': last_updated_by, 'Body': body, 'MediaSid': media_sid, }) payload = self._version.create( 'POST', self._uri, data=data, ) return MessageInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], ) def stream(self, order=values.unset, limit=None, page_size=None): """ 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 MessageInstance.OrderType order: The order :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.channel.message.MessageInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(order=order, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, order=values.unset, limit=None, page_size=None): """ 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 MessageInstance.OrderType order: The order :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.channel.message.MessageInstance] """ return list(self.stream(order=order, limit=limit, page_size=page_size,)) def page(self, order=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of MessageInstance records from the API. Request is executed immediately :param MessageInstance.OrderType order: The order :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of MessageInstance :rtype: twilio.rest.chat.v2.service.channel.message.MessagePage """ params = values.of({ 'Order': order, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return MessagePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of MessageInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of MessageInstance :rtype: twilio.rest.chat.v2.service.channel.message.MessagePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return MessagePage(self._version, response, self._solution) def get(self, sid): """ Constructs a MessageContext :param sid: The sid :returns: twilio.rest.chat.v2.service.channel.message.MessageContext :rtype: twilio.rest.chat.v2.service.channel.message.MessageContext """ return MessageContext( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a MessageContext :param sid: The sid :returns: twilio.rest.chat.v2.service.channel.message.MessageContext :rtype: twilio.rest.chat.v2.service.channel.message.MessageContext """ return MessageContext( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class MessagePage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the MessagePage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :param channel_sid: The channel_sid :returns: twilio.rest.chat.v2.service.channel.message.MessagePage :rtype: twilio.rest.chat.v2.service.channel.message.MessagePage """ super(MessagePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of MessageInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v2.service.channel.message.MessageInstance :rtype: twilio.rest.chat.v2.service.channel.message.MessageInstance """ return MessageInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class MessageContext(InstanceContext): """ """ def __init__(self, version, service_sid, channel_sid, sid): """ Initialize the MessageContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param channel_sid: The channel_sid :param sid: The sid :returns: twilio.rest.chat.v2.service.channel.message.MessageContext :rtype: twilio.rest.chat.v2.service.channel.message.MessageContext """ super(MessageContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'channel_sid': channel_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Channels/{channel_sid}/Messages/{sid}'.format(**self._solution) def fetch(self): """ Fetch a MessageInstance :returns: Fetched MessageInstance :rtype: twilio.rest.chat.v2.service.channel.message.MessageInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return MessageInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the MessageInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, body=values.unset, attributes=values.unset, date_created=values.unset, date_updated=values.unset, last_updated_by=values.unset): """ Update the MessageInstance :param unicode body: The body :param unicode attributes: The attributes :param datetime date_created: The date_created :param datetime date_updated: The date_updated :param unicode last_updated_by: The last_updated_by :returns: Updated MessageInstance :rtype: twilio.rest.chat.v2.service.channel.message.MessageInstance """ data = values.of({ 'Body': body, 'Attributes': attributes, 'DateCreated': serialize.iso8601_datetime(date_created), 'DateUpdated': serialize.iso8601_datetime(date_updated), 'LastUpdatedBy': last_updated_by, }) payload = self._version.update( 'POST', self._uri, data=data, ) return MessageInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class MessageInstance(InstanceResource): """ """ class OrderType(object): ASC = "asc" DESC = "desc" def __init__(self, version, payload, service_sid, channel_sid, sid=None): """ Initialize the MessageInstance :returns: twilio.rest.chat.v2.service.channel.message.MessageInstance :rtype: twilio.rest.chat.v2.service.channel.message.MessageInstance """ super(MessageInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'attributes': payload['attributes'], 'service_sid': payload['service_sid'], 'to': payload['to'], 'channel_sid': payload['channel_sid'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'last_updated_by': payload['last_updated_by'], 'was_edited': payload['was_edited'], 'from_': payload['from'], 'body': payload['body'], 'index': deserialize.integer(payload['index']), 'type': payload['type'], 'media': payload['media'], 'url': payload['url'], } # Context self._context = None self._solution = { 'service_sid': service_sid, 'channel_sid': channel_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: MessageContext for this MessageInstance :rtype: twilio.rest.chat.v2.service.channel.message.MessageContext """ if self._context is None: self._context = MessageContext( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def attributes(self): """ :returns: The attributes :rtype: unicode """ return self._properties['attributes'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def to(self): """ :returns: The to :rtype: unicode """ return self._properties['to'] @property def channel_sid(self): """ :returns: The channel_sid :rtype: unicode """ return self._properties['channel_sid'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def last_updated_by(self): """ :returns: The last_updated_by :rtype: unicode """ return self._properties['last_updated_by'] @property def was_edited(self): """ :returns: The was_edited :rtype: bool """ return self._properties['was_edited'] @property def from_(self): """ :returns: The from :rtype: unicode """ return self._properties['from_'] @property def body(self): """ :returns: The body :rtype: unicode """ return self._properties['body'] @property def index(self): """ :returns: The index :rtype: unicode """ return self._properties['index'] @property def type(self): """ :returns: The type :rtype: unicode """ return self._properties['type'] @property def media(self): """ :returns: The media :rtype: dict """ return self._properties['media'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a MessageInstance :returns: Fetched MessageInstance :rtype: twilio.rest.chat.v2.service.channel.message.MessageInstance """ return self._proxy.fetch() def delete(self): """ Deletes the MessageInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, body=values.unset, attributes=values.unset, date_created=values.unset, date_updated=values.unset, last_updated_by=values.unset): """ Update the MessageInstance :param unicode body: The body :param unicode attributes: The attributes :param datetime date_created: The date_created :param datetime date_updated: The date_updated :param unicode last_updated_by: The last_updated_by :returns: Updated MessageInstance :rtype: twilio.rest.chat.v2.service.channel.message.MessageInstance """ return self._proxy.update( body=body, attributes=attributes, date_created=date_created, date_updated=date_updated, last_updated_by=last_updated_by, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/chat/v2/service/role.py000066400000000000000000000327321317472742600231060ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class RoleList(ListResource): """ """ def __init__(self, version, service_sid): """ Initialize the RoleList :param Version version: Version that contains the resource :param service_sid: The service_sid :returns: twilio.rest.chat.v2.service.role.RoleList :rtype: twilio.rest.chat.v2.service.role.RoleList """ super(RoleList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid,} self._uri = '/Services/{service_sid}/Roles'.format(**self._solution) def create(self, friendly_name, type, permission): """ Create a new RoleInstance :param unicode friendly_name: The friendly_name :param RoleInstance.RoleType type: The type :param unicode permission: The permission :returns: Newly created RoleInstance :rtype: twilio.rest.chat.v2.service.role.RoleInstance """ data = values.of({'FriendlyName': friendly_name, 'Type': type, 'Permission': permission,}) payload = self._version.create( 'POST', self._uri, data=data, ) return RoleInstance(self._version, payload, service_sid=self._solution['service_sid'],) def stream(self, limit=None, page_size=None): """ Streams RoleInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.role.RoleInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists RoleInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.role.RoleInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of RoleInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of RoleInstance :rtype: twilio.rest.chat.v2.service.role.RolePage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return RolePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of RoleInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of RoleInstance :rtype: twilio.rest.chat.v2.service.role.RolePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return RolePage(self._version, response, self._solution) def get(self, sid): """ Constructs a RoleContext :param sid: The sid :returns: twilio.rest.chat.v2.service.role.RoleContext :rtype: twilio.rest.chat.v2.service.role.RoleContext """ return RoleContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __call__(self, sid): """ Constructs a RoleContext :param sid: The sid :returns: twilio.rest.chat.v2.service.role.RoleContext :rtype: twilio.rest.chat.v2.service.role.RoleContext """ return RoleContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class RolePage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the RolePage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :returns: twilio.rest.chat.v2.service.role.RolePage :rtype: twilio.rest.chat.v2.service.role.RolePage """ super(RolePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of RoleInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v2.service.role.RoleInstance :rtype: twilio.rest.chat.v2.service.role.RoleInstance """ return RoleInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class RoleContext(InstanceContext): """ """ def __init__(self, version, service_sid, sid): """ Initialize the RoleContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param sid: The sid :returns: twilio.rest.chat.v2.service.role.RoleContext :rtype: twilio.rest.chat.v2.service.role.RoleContext """ super(RoleContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Roles/{sid}'.format(**self._solution) def fetch(self): """ Fetch a RoleInstance :returns: Fetched RoleInstance :rtype: twilio.rest.chat.v2.service.role.RoleInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return RoleInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the RoleInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, permission): """ Update the RoleInstance :param unicode permission: The permission :returns: Updated RoleInstance :rtype: twilio.rest.chat.v2.service.role.RoleInstance """ data = values.of({'Permission': permission,}) payload = self._version.update( 'POST', self._uri, data=data, ) return RoleInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class RoleInstance(InstanceResource): """ """ class RoleType(object): CHANNEL = "channel" DEPLOYMENT = "deployment" def __init__(self, version, payload, service_sid, sid=None): """ Initialize the RoleInstance :returns: twilio.rest.chat.v2.service.role.RoleInstance :rtype: twilio.rest.chat.v2.service.role.RoleInstance """ super(RoleInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'friendly_name': payload['friendly_name'], 'type': payload['type'], 'permissions': payload['permissions'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'url': payload['url'], } # Context self._context = None self._solution = {'service_sid': service_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: RoleContext for this RoleInstance :rtype: twilio.rest.chat.v2.service.role.RoleContext """ if self._context is None: self._context = RoleContext( self._version, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def type(self): """ :returns: The type :rtype: RoleInstance.RoleType """ return self._properties['type'] @property def permissions(self): """ :returns: The permissions :rtype: unicode """ return self._properties['permissions'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a RoleInstance :returns: Fetched RoleInstance :rtype: twilio.rest.chat.v2.service.role.RoleInstance """ return self._proxy.fetch() def delete(self): """ Deletes the RoleInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, permission): """ Update the RoleInstance :param unicode permission: The permission :returns: Updated RoleInstance :rtype: twilio.rest.chat.v2.service.role.RoleInstance """ return self._proxy.update(permission,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/chat/v2/service/user/000077500000000000000000000000001317472742600225425ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/chat/v2/service/user/__init__.py000066400000000000000000000420041317472742600246530ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.chat.v2.service.user.user_binding import UserBindingList from twilio.rest.chat.v2.service.user.user_channel import UserChannelList class UserList(ListResource): """ """ def __init__(self, version, service_sid): """ Initialize the UserList :param Version version: Version that contains the resource :param service_sid: The service_sid :returns: twilio.rest.chat.v2.service.user.UserList :rtype: twilio.rest.chat.v2.service.user.UserList """ super(UserList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid,} self._uri = '/Services/{service_sid}/Users'.format(**self._solution) def create(self, identity, role_sid=values.unset, attributes=values.unset, friendly_name=values.unset): """ Create a new UserInstance :param unicode identity: The identity :param unicode role_sid: The role_sid :param unicode attributes: The attributes :param unicode friendly_name: The friendly_name :returns: Newly created UserInstance :rtype: twilio.rest.chat.v2.service.user.UserInstance """ data = values.of({ 'Identity': identity, 'RoleSid': role_sid, 'Attributes': attributes, 'FriendlyName': friendly_name, }) payload = self._version.create( 'POST', self._uri, data=data, ) return UserInstance(self._version, payload, service_sid=self._solution['service_sid'],) def stream(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.user.UserInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.user.UserInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of UserInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of UserInstance :rtype: twilio.rest.chat.v2.service.user.UserPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return UserPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of UserInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of UserInstance :rtype: twilio.rest.chat.v2.service.user.UserPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return UserPage(self._version, response, self._solution) def get(self, sid): """ Constructs a UserContext :param sid: The sid :returns: twilio.rest.chat.v2.service.user.UserContext :rtype: twilio.rest.chat.v2.service.user.UserContext """ return UserContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __call__(self, sid): """ Constructs a UserContext :param sid: The sid :returns: twilio.rest.chat.v2.service.user.UserContext :rtype: twilio.rest.chat.v2.service.user.UserContext """ return UserContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class UserPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the UserPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :returns: twilio.rest.chat.v2.service.user.UserPage :rtype: twilio.rest.chat.v2.service.user.UserPage """ super(UserPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of UserInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v2.service.user.UserInstance :rtype: twilio.rest.chat.v2.service.user.UserInstance """ return UserInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class UserContext(InstanceContext): """ """ def __init__(self, version, service_sid, sid): """ Initialize the UserContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param sid: The sid :returns: twilio.rest.chat.v2.service.user.UserContext :rtype: twilio.rest.chat.v2.service.user.UserContext """ super(UserContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Users/{sid}'.format(**self._solution) # Dependents self._user_channels = None self._user_bindings = None def fetch(self): """ Fetch a UserInstance :returns: Fetched UserInstance :rtype: twilio.rest.chat.v2.service.user.UserInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return UserInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the UserInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, role_sid=values.unset, attributes=values.unset, friendly_name=values.unset): """ Update the UserInstance :param unicode role_sid: The role_sid :param unicode attributes: The attributes :param unicode friendly_name: The friendly_name :returns: Updated UserInstance :rtype: twilio.rest.chat.v2.service.user.UserInstance """ data = values.of({'RoleSid': role_sid, 'Attributes': attributes, 'FriendlyName': friendly_name,}) payload = self._version.update( 'POST', self._uri, data=data, ) return UserInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) @property def user_channels(self): """ Access the user_channels :returns: twilio.rest.chat.v2.service.user.user_channel.UserChannelList :rtype: twilio.rest.chat.v2.service.user.user_channel.UserChannelList """ if self._user_channels is None: self._user_channels = UserChannelList( self._version, service_sid=self._solution['service_sid'], user_sid=self._solution['sid'], ) return self._user_channels @property def user_bindings(self): """ Access the user_bindings :returns: twilio.rest.chat.v2.service.user.user_binding.UserBindingList :rtype: twilio.rest.chat.v2.service.user.user_binding.UserBindingList """ if self._user_bindings is None: self._user_bindings = UserBindingList( self._version, service_sid=self._solution['service_sid'], user_sid=self._solution['sid'], ) return self._user_bindings def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class UserInstance(InstanceResource): """ """ def __init__(self, version, payload, service_sid, sid=None): """ Initialize the UserInstance :returns: twilio.rest.chat.v2.service.user.UserInstance :rtype: twilio.rest.chat.v2.service.user.UserInstance """ super(UserInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'attributes': payload['attributes'], 'friendly_name': payload['friendly_name'], 'role_sid': payload['role_sid'], 'identity': payload['identity'], 'is_online': payload['is_online'], 'is_notifiable': payload['is_notifiable'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'joined_channels_count': deserialize.integer(payload['joined_channels_count']), 'links': payload['links'], 'url': payload['url'], } # Context self._context = None self._solution = {'service_sid': service_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.chat.v2.service.user.UserContext """ if self._context is None: self._context = UserContext( self._version, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def attributes(self): """ :returns: The attributes :rtype: unicode """ return self._properties['attributes'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def role_sid(self): """ :returns: The role_sid :rtype: unicode """ return self._properties['role_sid'] @property def identity(self): """ :returns: The identity :rtype: unicode """ return self._properties['identity'] @property def is_online(self): """ :returns: The is_online :rtype: bool """ return self._properties['is_online'] @property def is_notifiable(self): """ :returns: The is_notifiable :rtype: bool """ return self._properties['is_notifiable'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def joined_channels_count(self): """ :returns: The joined_channels_count :rtype: unicode """ return self._properties['joined_channels_count'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a UserInstance :returns: Fetched UserInstance :rtype: twilio.rest.chat.v2.service.user.UserInstance """ return self._proxy.fetch() def delete(self): """ Deletes the UserInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, role_sid=values.unset, attributes=values.unset, friendly_name=values.unset): """ Update the UserInstance :param unicode role_sid: The role_sid :param unicode attributes: The attributes :param unicode friendly_name: The friendly_name :returns: Updated UserInstance :rtype: twilio.rest.chat.v2.service.user.UserInstance """ return self._proxy.update(role_sid=role_sid, attributes=attributes, friendly_name=friendly_name,) @property def user_channels(self): """ Access the user_channels :returns: twilio.rest.chat.v2.service.user.user_channel.UserChannelList :rtype: twilio.rest.chat.v2.service.user.user_channel.UserChannelList """ return self._proxy.user_channels @property def user_bindings(self): """ Access the user_bindings :returns: twilio.rest.chat.v2.service.user.user_binding.UserBindingList :rtype: twilio.rest.chat.v2.service.user.user_binding.UserBindingList """ return self._proxy.user_bindings def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/chat/v2/service/user/user_binding.py000066400000000000000000000346121317472742600255720ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class UserBindingList(ListResource): """ """ def __init__(self, version, service_sid, user_sid): """ Initialize the UserBindingList :param Version version: Version that contains the resource :param service_sid: The service_sid :param user_sid: The user_sid :returns: twilio.rest.chat.v2.service.user.user_binding.UserBindingList :rtype: twilio.rest.chat.v2.service.user.user_binding.UserBindingList """ super(UserBindingList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'user_sid': user_sid,} self._uri = '/Services/{service_sid}/Users/{user_sid}/Bindings'.format(**self._solution) def stream(self, binding_type=values.unset, limit=None, page_size=None): """ Streams UserBindingInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param UserBindingInstance.BindingType binding_type: The binding_type :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.user.user_binding.UserBindingInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(binding_type=binding_type, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, binding_type=values.unset, limit=None, page_size=None): """ Lists UserBindingInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param UserBindingInstance.BindingType binding_type: The binding_type :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.user.user_binding.UserBindingInstance] """ return list(self.stream(binding_type=binding_type, limit=limit, page_size=page_size,)) def page(self, binding_type=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of UserBindingInstance records from the API. Request is executed immediately :param UserBindingInstance.BindingType binding_type: The binding_type :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of UserBindingInstance :rtype: twilio.rest.chat.v2.service.user.user_binding.UserBindingPage """ params = values.of({ 'BindingType': binding_type, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return UserBindingPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of UserBindingInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of UserBindingInstance :rtype: twilio.rest.chat.v2.service.user.user_binding.UserBindingPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return UserBindingPage(self._version, response, self._solution) def get(self, sid): """ Constructs a UserBindingContext :param sid: The sid :returns: twilio.rest.chat.v2.service.user.user_binding.UserBindingContext :rtype: twilio.rest.chat.v2.service.user.user_binding.UserBindingContext """ return UserBindingContext( self._version, service_sid=self._solution['service_sid'], user_sid=self._solution['user_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a UserBindingContext :param sid: The sid :returns: twilio.rest.chat.v2.service.user.user_binding.UserBindingContext :rtype: twilio.rest.chat.v2.service.user.user_binding.UserBindingContext """ return UserBindingContext( self._version, service_sid=self._solution['service_sid'], user_sid=self._solution['user_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class UserBindingPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the UserBindingPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :param user_sid: The user_sid :returns: twilio.rest.chat.v2.service.user.user_binding.UserBindingPage :rtype: twilio.rest.chat.v2.service.user.user_binding.UserBindingPage """ super(UserBindingPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of UserBindingInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v2.service.user.user_binding.UserBindingInstance :rtype: twilio.rest.chat.v2.service.user.user_binding.UserBindingInstance """ return UserBindingInstance( self._version, payload, service_sid=self._solution['service_sid'], user_sid=self._solution['user_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class UserBindingContext(InstanceContext): """ """ def __init__(self, version, service_sid, user_sid, sid): """ Initialize the UserBindingContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param user_sid: The user_sid :param sid: The sid :returns: twilio.rest.chat.v2.service.user.user_binding.UserBindingContext :rtype: twilio.rest.chat.v2.service.user.user_binding.UserBindingContext """ super(UserBindingContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'user_sid': user_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Users/{user_sid}/Bindings/{sid}'.format(**self._solution) def fetch(self): """ Fetch a UserBindingInstance :returns: Fetched UserBindingInstance :rtype: twilio.rest.chat.v2.service.user.user_binding.UserBindingInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return UserBindingInstance( self._version, payload, service_sid=self._solution['service_sid'], user_sid=self._solution['user_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the UserBindingInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class UserBindingInstance(InstanceResource): """ """ class BindingType(object): GCM = "gcm" APN = "apn" FCM = "fcm" def __init__(self, version, payload, service_sid, user_sid, sid=None): """ Initialize the UserBindingInstance :returns: twilio.rest.chat.v2.service.user.user_binding.UserBindingInstance :rtype: twilio.rest.chat.v2.service.user.user_binding.UserBindingInstance """ super(UserBindingInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'endpoint': payload['endpoint'], 'identity': payload['identity'], 'user_sid': payload['user_sid'], 'credential_sid': payload['credential_sid'], 'binding_type': payload['binding_type'], 'message_types': payload['message_types'], 'url': payload['url'], } # Context self._context = None self._solution = { 'service_sid': service_sid, 'user_sid': user_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: UserBindingContext for this UserBindingInstance :rtype: twilio.rest.chat.v2.service.user.user_binding.UserBindingContext """ if self._context is None: self._context = UserBindingContext( self._version, service_sid=self._solution['service_sid'], user_sid=self._solution['user_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def endpoint(self): """ :returns: The endpoint :rtype: unicode """ return self._properties['endpoint'] @property def identity(self): """ :returns: The identity :rtype: unicode """ return self._properties['identity'] @property def user_sid(self): """ :returns: The user_sid :rtype: unicode """ return self._properties['user_sid'] @property def credential_sid(self): """ :returns: The credential_sid :rtype: unicode """ return self._properties['credential_sid'] @property def binding_type(self): """ :returns: The binding_type :rtype: UserBindingInstance.BindingType """ return self._properties['binding_type'] @property def message_types(self): """ :returns: The message_types :rtype: unicode """ return self._properties['message_types'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a UserBindingInstance :returns: Fetched UserBindingInstance :rtype: twilio.rest.chat.v2.service.user.user_binding.UserBindingInstance """ return self._proxy.fetch() def delete(self): """ Deletes the UserBindingInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/chat/v2/service/user/user_channel.py000066400000000000000000000220471317472742600255670ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class UserChannelList(ListResource): """ """ def __init__(self, version, service_sid, user_sid): """ Initialize the UserChannelList :param Version version: Version that contains the resource :param service_sid: The service_sid :param user_sid: The sid :returns: twilio.rest.chat.v2.service.user.user_channel.UserChannelList :rtype: twilio.rest.chat.v2.service.user.user_channel.UserChannelList """ super(UserChannelList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'user_sid': user_sid,} self._uri = '/Services/{service_sid}/Users/{user_sid}/Channels'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams UserChannelInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.user.user_channel.UserChannelInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists UserChannelInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.user.user_channel.UserChannelInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of UserChannelInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of UserChannelInstance :rtype: twilio.rest.chat.v2.service.user.user_channel.UserChannelPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return UserChannelPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of UserChannelInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of UserChannelInstance :rtype: twilio.rest.chat.v2.service.user.user_channel.UserChannelPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return UserChannelPage(self._version, response, self._solution) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class UserChannelPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the UserChannelPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :param user_sid: The sid :returns: twilio.rest.chat.v2.service.user.user_channel.UserChannelPage :rtype: twilio.rest.chat.v2.service.user.user_channel.UserChannelPage """ super(UserChannelPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of UserChannelInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v2.service.user.user_channel.UserChannelInstance :rtype: twilio.rest.chat.v2.service.user.user_channel.UserChannelInstance """ return UserChannelInstance( self._version, payload, service_sid=self._solution['service_sid'], user_sid=self._solution['user_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class UserChannelInstance(InstanceResource): """ """ class ChannelStatus(object): JOINED = "joined" INVITED = "invited" NOT_PARTICIPATING = "not_participating" def __init__(self, version, payload, service_sid, user_sid): """ Initialize the UserChannelInstance :returns: twilio.rest.chat.v2.service.user.user_channel.UserChannelInstance :rtype: twilio.rest.chat.v2.service.user.user_channel.UserChannelInstance """ super(UserChannelInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'channel_sid': payload['channel_sid'], 'member_sid': payload['member_sid'], 'status': payload['status'], 'last_consumed_message_index': deserialize.integer(payload['last_consumed_message_index']), 'unread_messages_count': deserialize.integer(payload['unread_messages_count']), 'links': payload['links'], } # Context self._context = None self._solution = {'service_sid': service_sid, 'user_sid': user_sid,} @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def channel_sid(self): """ :returns: The channel_sid :rtype: unicode """ return self._properties['channel_sid'] @property def member_sid(self): """ :returns: The member_sid :rtype: unicode """ return self._properties['member_sid'] @property def status(self): """ :returns: The status :rtype: UserChannelInstance.ChannelStatus """ return self._properties['status'] @property def last_consumed_message_index(self): """ :returns: The last_consumed_message_index :rtype: unicode """ return self._properties['last_consumed_message_index'] @property def unread_messages_count(self): """ :returns: The unread_messages_count :rtype: unicode """ return self._properties['unread_messages_count'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/fax/000077500000000000000000000000001317472742600174345ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/fax/__init__.py000066400000000000000000000020361317472742600215460ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.domain import Domain from twilio.rest.fax.v1 import V1 class Fax(Domain): def __init__(self, twilio): """ Initialize the Fax Domain :returns: Domain for Fax :rtype: twilio.rest.fax.Fax """ super(Fax, self).__init__(twilio) self.base_url = 'https://fax.twilio.com' # Versions self._v1 = None @property def v1(self): """ :returns: Version v1 of fax :rtype: twilio.rest.fax.v1.V1 """ if self._v1 is None: self._v1 = V1(self) return self._v1 @property def faxes(self): """ :rtype: twilio.rest.fax.v1.fax.FaxList """ return self.v1.faxes def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/fax/v1/000077500000000000000000000000001317472742600177625ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/fax/v1/__init__.py000066400000000000000000000016011317472742600220710ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.version import Version from twilio.rest.fax.v1.fax import FaxList class V1(Version): def __init__(self, domain): """ Initialize the V1 version of Fax :returns: V1 version of Fax :rtype: twilio.rest.fax.v1.V1.V1 """ super(V1, self).__init__(domain) self.version = 'v1' self._faxes = None @property def faxes(self): """ :rtype: twilio.rest.fax.v1.fax.FaxList """ if self._faxes is None: self._faxes = FaxList(self) return self._faxes def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/fax/v1/fax/000077500000000000000000000000001317472742600205405ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/fax/v1/fax/__init__.py000066400000000000000000000456351317472742600226660ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize 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.page import Page from twilio.rest.fax.v1.fax.fax_media import FaxMediaList class FaxList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version): """ Initialize the FaxList :param Version version: Version that contains the resource :returns: twilio.rest.fax.v1.fax.FaxList :rtype: twilio.rest.fax.v1.fax.FaxList """ super(FaxList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/Faxes'.format(**self._solution) def stream(self, from_=values.unset, to=values.unset, date_created_on_or_before=values.unset, date_created_after=values.unset, limit=None, page_size=None): """ Streams FaxInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param unicode from_: Include only faxes sent from :param unicode to: Include only faxes sent to :param datetime date_created_on_or_before: Include only faxes created on or before :param datetime date_created_after: Include only faxes created after :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.fax.v1.fax.FaxInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( from_=from_, to=to, date_created_on_or_before=date_created_on_or_before, date_created_after=date_created_after, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, from_=values.unset, to=values.unset, date_created_on_or_before=values.unset, date_created_after=values.unset, limit=None, page_size=None): """ Lists FaxInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param unicode from_: Include only faxes sent from :param unicode to: Include only faxes sent to :param datetime date_created_on_or_before: Include only faxes created on or before :param datetime date_created_after: Include only faxes created after :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.fax.v1.fax.FaxInstance] """ return list(self.stream( from_=from_, to=to, date_created_on_or_before=date_created_on_or_before, date_created_after=date_created_after, limit=limit, page_size=page_size, )) def page(self, from_=values.unset, to=values.unset, date_created_on_or_before=values.unset, date_created_after=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of FaxInstance records from the API. Request is executed immediately :param unicode from_: Include only faxes sent from :param unicode to: Include only faxes sent to :param datetime date_created_on_or_before: Include only faxes created on or before :param datetime date_created_after: Include only faxes created after :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of FaxInstance :rtype: twilio.rest.fax.v1.fax.FaxPage """ params = values.of({ 'From': from_, 'To': to, 'DateCreatedOnOrBefore': serialize.iso8601_datetime(date_created_on_or_before), 'DateCreatedAfter': serialize.iso8601_datetime(date_created_after), 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return FaxPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of FaxInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of FaxInstance :rtype: twilio.rest.fax.v1.fax.FaxPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return FaxPage(self._version, response, self._solution) def create(self, to, media_url, quality=values.unset, status_callback=values.unset, from_=values.unset, sip_auth_username=values.unset, sip_auth_password=values.unset, store_media=values.unset): """ Create a new FaxInstance :param unicode to: The phone number or SIP address to send the fax to :param unicode media_url: URL that points to the fax media :param FaxInstance.Quality quality: The quality of this fax :param unicode status_callback: URL for fax status callbacks :param unicode from_: Twilio number from which to originate the fax :param unicode sip_auth_username: Username for SIP authentication :param unicode sip_auth_password: Password for SIP authentication :param bool store_media: Whether or not to store media :returns: Newly created FaxInstance :rtype: twilio.rest.fax.v1.fax.FaxInstance """ data = values.of({ 'To': to, 'MediaUrl': media_url, 'Quality': quality, 'StatusCallback': status_callback, 'From': from_, 'SipAuthUsername': sip_auth_username, 'SipAuthPassword': sip_auth_password, 'StoreMedia': store_media, }) payload = self._version.create( 'POST', self._uri, data=data, ) return FaxInstance(self._version, payload,) def get(self, sid): """ Constructs a FaxContext :param sid: A string that uniquely identifies this fax. :returns: twilio.rest.fax.v1.fax.FaxContext :rtype: twilio.rest.fax.v1.fax.FaxContext """ return FaxContext(self._version, sid=sid,) def __call__(self, sid): """ Constructs a FaxContext :param sid: A string that uniquely identifies this fax. :returns: twilio.rest.fax.v1.fax.FaxContext :rtype: twilio.rest.fax.v1.fax.FaxContext """ return FaxContext(self._version, sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class FaxPage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the FaxPage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.fax.v1.fax.FaxPage :rtype: twilio.rest.fax.v1.fax.FaxPage """ super(FaxPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of FaxInstance :param dict payload: Payload response from the API :returns: twilio.rest.fax.v1.fax.FaxInstance :rtype: twilio.rest.fax.v1.fax.FaxInstance """ return FaxInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class FaxContext(InstanceContext): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, sid): """ Initialize the FaxContext :param Version version: Version that contains the resource :param sid: A string that uniquely identifies this fax. :returns: twilio.rest.fax.v1.fax.FaxContext :rtype: twilio.rest.fax.v1.fax.FaxContext """ super(FaxContext, self).__init__(version) # Path Solution self._solution = {'sid': sid,} self._uri = '/Faxes/{sid}'.format(**self._solution) # Dependents self._media = None def fetch(self): """ Fetch a FaxInstance :returns: Fetched FaxInstance :rtype: twilio.rest.fax.v1.fax.FaxInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return FaxInstance(self._version, payload, sid=self._solution['sid'],) def update(self, status=values.unset): """ Update the FaxInstance :param FaxInstance.UpdateStatus status: The updated status of this fax :returns: Updated FaxInstance :rtype: twilio.rest.fax.v1.fax.FaxInstance """ data = values.of({'Status': status,}) payload = self._version.update( 'POST', self._uri, data=data, ) return FaxInstance(self._version, payload, sid=self._solution['sid'],) def delete(self): """ Deletes the FaxInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) @property def media(self): """ Access the media :returns: twilio.rest.fax.v1.fax.fax_media.FaxMediaList :rtype: twilio.rest.fax.v1.fax.fax_media.FaxMediaList """ if self._media is None: self._media = FaxMediaList(self._version, fax_sid=self._solution['sid'],) return self._media def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class FaxInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ class Direction(object): INBOUND = "inbound" OUTBOUND = "outbound" class Quality(object): STANDARD = "standard" FINE = "fine" SUPERFINE = "superfine" class Status(object): QUEUED = "queued" PROCESSING = "processing" SENDING = "sending" DELIVERED = "delivered" RECEIVING = "receiving" RECEIVED = "received" NO_ANSWER = "no-answer" BUSY = "busy" FAILED = "failed" CANCELED = "canceled" class UpdateStatus(object): CANCELED = "canceled" def __init__(self, version, payload, sid=None): """ Initialize the FaxInstance :returns: twilio.rest.fax.v1.fax.FaxInstance :rtype: twilio.rest.fax.v1.fax.FaxInstance """ super(FaxInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'from_': payload['from'], 'to': payload['to'], 'quality': payload['quality'], 'media_sid': payload['media_sid'], 'media_url': payload['media_url'], 'num_pages': deserialize.integer(payload['num_pages']), 'duration': deserialize.integer(payload['duration']), 'status': payload['status'], 'direction': payload['direction'], 'api_version': payload['api_version'], 'price': deserialize.decimal(payload['price']), 'price_unit': payload['price_unit'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'links': payload['links'], 'url': payload['url'], } # Context self._context = None self._solution = {'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: FaxContext for this FaxInstance :rtype: twilio.rest.fax.v1.fax.FaxContext """ if self._context is None: self._context = FaxContext(self._version, sid=self._solution['sid'],) return self._context @property def sid(self): """ :returns: A string that uniquely identifies this fax. :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: Account SID :rtype: unicode """ return self._properties['account_sid'] @property def from_(self): """ :returns: The party that sent the fax :rtype: unicode """ return self._properties['from_'] @property def to(self): """ :returns: The party that received the fax :rtype: unicode """ return self._properties['to'] @property def quality(self): """ :returns: The quality of this fax :rtype: FaxInstance.Quality """ return self._properties['quality'] @property def media_sid(self): """ :returns: Media SID :rtype: unicode """ return self._properties['media_sid'] @property def media_url(self): """ :returns: URL pointing to fax media :rtype: unicode """ return self._properties['media_url'] @property def num_pages(self): """ :returns: Number of pages :rtype: unicode """ return self._properties['num_pages'] @property def duration(self): """ :returns: The time taken to transmit the fax :rtype: unicode """ return self._properties['duration'] @property def status(self): """ :returns: The status of this fax :rtype: FaxInstance.Status """ return self._properties['status'] @property def direction(self): """ :returns: The direction of this fax :rtype: FaxInstance.Direction """ return self._properties['direction'] @property def api_version(self): """ :returns: The API version used :rtype: unicode """ return self._properties['api_version'] @property def price(self): """ :returns: Fax transmission price :rtype: unicode """ return self._properties['price'] @property def price_unit(self): """ :returns: Currency used for billing :rtype: unicode """ return self._properties['price_unit'] @property def date_created(self): """ :returns: The date this fax was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this fax was updated :rtype: datetime """ return self._properties['date_updated'] @property def links(self): """ :returns: Nested resource URLs :rtype: unicode """ return self._properties['links'] @property def url(self): """ :returns: The URL of this resource :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a FaxInstance :returns: Fetched FaxInstance :rtype: twilio.rest.fax.v1.fax.FaxInstance """ return self._proxy.fetch() def update(self, status=values.unset): """ Update the FaxInstance :param FaxInstance.UpdateStatus status: The updated status of this fax :returns: Updated FaxInstance :rtype: twilio.rest.fax.v1.fax.FaxInstance """ return self._proxy.update(status=status,) def delete(self): """ Deletes the FaxInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() @property def media(self): """ Access the media :returns: twilio.rest.fax.v1.fax.fax_media.FaxMediaList :rtype: twilio.rest.fax.v1.fax.fax_media.FaxMediaList """ return self._proxy.media def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/fax/v1/fax/fax_media.py000066400000000000000000000301741317472742600230340ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class FaxMediaList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, fax_sid): """ Initialize the FaxMediaList :param Version version: Version that contains the resource :param fax_sid: Fax SID :returns: twilio.rest.fax.v1.fax.fax_media.FaxMediaList :rtype: twilio.rest.fax.v1.fax.fax_media.FaxMediaList """ super(FaxMediaList, self).__init__(version) # Path Solution self._solution = {'fax_sid': fax_sid,} self._uri = '/Faxes/{fax_sid}/Media'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams FaxMediaInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.fax.v1.fax.fax_media.FaxMediaInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists FaxMediaInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.fax.v1.fax.fax_media.FaxMediaInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of FaxMediaInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of FaxMediaInstance :rtype: twilio.rest.fax.v1.fax.fax_media.FaxMediaPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return FaxMediaPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of FaxMediaInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of FaxMediaInstance :rtype: twilio.rest.fax.v1.fax.fax_media.FaxMediaPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return FaxMediaPage(self._version, response, self._solution) def get(self, sid): """ Constructs a FaxMediaContext :param sid: A string that uniquely identifies this fax media :returns: twilio.rest.fax.v1.fax.fax_media.FaxMediaContext :rtype: twilio.rest.fax.v1.fax.fax_media.FaxMediaContext """ return FaxMediaContext(self._version, fax_sid=self._solution['fax_sid'], sid=sid,) def __call__(self, sid): """ Constructs a FaxMediaContext :param sid: A string that uniquely identifies this fax media :returns: twilio.rest.fax.v1.fax.fax_media.FaxMediaContext :rtype: twilio.rest.fax.v1.fax.fax_media.FaxMediaContext """ return FaxMediaContext(self._version, fax_sid=self._solution['fax_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class FaxMediaPage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the FaxMediaPage :param Version version: Version that contains the resource :param Response response: Response from the API :param fax_sid: Fax SID :returns: twilio.rest.fax.v1.fax.fax_media.FaxMediaPage :rtype: twilio.rest.fax.v1.fax.fax_media.FaxMediaPage """ super(FaxMediaPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of FaxMediaInstance :param dict payload: Payload response from the API :returns: twilio.rest.fax.v1.fax.fax_media.FaxMediaInstance :rtype: twilio.rest.fax.v1.fax.fax_media.FaxMediaInstance """ return FaxMediaInstance(self._version, payload, fax_sid=self._solution['fax_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class FaxMediaContext(InstanceContext): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, fax_sid, sid): """ Initialize the FaxMediaContext :param Version version: Version that contains the resource :param fax_sid: Fax SID :param sid: A string that uniquely identifies this fax media :returns: twilio.rest.fax.v1.fax.fax_media.FaxMediaContext :rtype: twilio.rest.fax.v1.fax.fax_media.FaxMediaContext """ super(FaxMediaContext, self).__init__(version) # Path Solution self._solution = {'fax_sid': fax_sid, 'sid': sid,} self._uri = '/Faxes/{fax_sid}/Media/{sid}'.format(**self._solution) def fetch(self): """ Fetch a FaxMediaInstance :returns: Fetched FaxMediaInstance :rtype: twilio.rest.fax.v1.fax.fax_media.FaxMediaInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return FaxMediaInstance( self._version, payload, fax_sid=self._solution['fax_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the FaxMediaInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class FaxMediaInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, payload, fax_sid, sid=None): """ Initialize the FaxMediaInstance :returns: twilio.rest.fax.v1.fax.fax_media.FaxMediaInstance :rtype: twilio.rest.fax.v1.fax.fax_media.FaxMediaInstance """ super(FaxMediaInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'fax_sid': payload['fax_sid'], 'content_type': payload['content_type'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'url': payload['url'], } # Context self._context = None self._solution = {'fax_sid': fax_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: FaxMediaContext for this FaxMediaInstance :rtype: twilio.rest.fax.v1.fax.fax_media.FaxMediaContext """ if self._context is None: self._context = FaxMediaContext( self._version, fax_sid=self._solution['fax_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: A string that uniquely identifies this fax media :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: Account SID :rtype: unicode """ return self._properties['account_sid'] @property def fax_sid(self): """ :returns: Fax SID :rtype: unicode """ return self._properties['fax_sid'] @property def content_type(self): """ :returns: Media content type :rtype: unicode """ return self._properties['content_type'] @property def date_created(self): """ :returns: The date this fax media was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this fax media was updated :rtype: datetime """ return self._properties['date_updated'] @property def url(self): """ :returns: The URL of this resource :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a FaxMediaInstance :returns: Fetched FaxMediaInstance :rtype: twilio.rest.fax.v1.fax.fax_media.FaxMediaInstance """ return self._proxy.fetch() def delete(self): """ Deletes the FaxMediaInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/ip_messaging/000077500000000000000000000000001317472742600213235ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/ip_messaging/__init__.py000066400000000000000000000031321317472742600234330ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.domain import Domain from twilio.rest.ip_messaging.v1 import V1 from twilio.rest.ip_messaging.v2 import V2 class IpMessaging(Domain): def __init__(self, twilio): """ Initialize the IpMessaging Domain :returns: Domain for IpMessaging :rtype: twilio.rest.ip_messaging.IpMessaging """ super(IpMessaging, self).__init__(twilio) self.base_url = 'https://ip-messaging.twilio.com' # Versions self._v1 = None self._v2 = None @property def v1(self): """ :returns: Version v1 of ip_messaging :rtype: twilio.rest.ip_messaging.v1.V1 """ if self._v1 is None: self._v1 = V1(self) return self._v1 @property def v2(self): """ :returns: Version v2 of ip_messaging :rtype: twilio.rest.ip_messaging.v2.V2 """ if self._v2 is None: self._v2 = V2(self) return self._v2 @property def credentials(self): """ :rtype: twilio.rest.chat.v2.credential.CredentialList """ return self.v2.credentials @property def services(self): """ :rtype: twilio.rest.chat.v2.service.ServiceList """ return self.v2.services def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/ip_messaging/v1/000077500000000000000000000000001317472742600216515ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/ip_messaging/v1/__init__.py000066400000000000000000000024561317472742600237710ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.version import Version from twilio.rest.ip_messaging.v1.credential import CredentialList from twilio.rest.ip_messaging.v1.service import ServiceList class V1(Version): def __init__(self, domain): """ Initialize the V1 version of IpMessaging :returns: V1 version of IpMessaging :rtype: twilio.rest.ip_messaging.v1.V1.V1 """ super(V1, self).__init__(domain) self.version = 'v1' self._credentials = None self._services = None @property def credentials(self): """ :rtype: twilio.rest.chat.v1.credential.CredentialList """ if self._credentials is None: self._credentials = CredentialList(self) return self._credentials @property def services(self): """ :rtype: twilio.rest.chat.v1.service.ServiceList """ if self._services is None: self._services = ServiceList(self) return self._services def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/ip_messaging/v1/credential.py000066400000000000000000000351021317472742600243360ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class CredentialList(ListResource): """ """ def __init__(self, version): """ Initialize the CredentialList :param Version version: Version that contains the resource :returns: twilio.rest.chat.v1.credential.CredentialList :rtype: twilio.rest.chat.v1.credential.CredentialList """ super(CredentialList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/Credentials'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams CredentialInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v1.credential.CredentialInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists CredentialInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v1.credential.CredentialInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of CredentialInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of CredentialInstance :rtype: twilio.rest.chat.v1.credential.CredentialPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return CredentialPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of CredentialInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of CredentialInstance :rtype: twilio.rest.chat.v1.credential.CredentialPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return CredentialPage(self._version, response, self._solution) def create(self, type, friendly_name=values.unset, certificate=values.unset, private_key=values.unset, sandbox=values.unset, api_key=values.unset, secret=values.unset): """ Create a new CredentialInstance :param CredentialInstance.PushService type: The type :param unicode friendly_name: The friendly_name :param unicode certificate: The certificate :param unicode private_key: The private_key :param bool sandbox: The sandbox :param unicode api_key: The api_key :param unicode secret: The secret :returns: Newly created CredentialInstance :rtype: twilio.rest.chat.v1.credential.CredentialInstance """ data = values.of({ 'Type': type, 'FriendlyName': friendly_name, 'Certificate': certificate, 'PrivateKey': private_key, 'Sandbox': sandbox, 'ApiKey': api_key, 'Secret': secret, }) payload = self._version.create( 'POST', self._uri, data=data, ) return CredentialInstance(self._version, payload,) def get(self, sid): """ Constructs a CredentialContext :param sid: The sid :returns: twilio.rest.chat.v1.credential.CredentialContext :rtype: twilio.rest.chat.v1.credential.CredentialContext """ return CredentialContext(self._version, sid=sid,) def __call__(self, sid): """ Constructs a CredentialContext :param sid: The sid :returns: twilio.rest.chat.v1.credential.CredentialContext :rtype: twilio.rest.chat.v1.credential.CredentialContext """ return CredentialContext(self._version, sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class CredentialPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the CredentialPage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.chat.v1.credential.CredentialPage :rtype: twilio.rest.chat.v1.credential.CredentialPage """ super(CredentialPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of CredentialInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v1.credential.CredentialInstance :rtype: twilio.rest.chat.v1.credential.CredentialInstance """ return CredentialInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class CredentialContext(InstanceContext): """ """ def __init__(self, version, sid): """ Initialize the CredentialContext :param Version version: Version that contains the resource :param sid: The sid :returns: twilio.rest.chat.v1.credential.CredentialContext :rtype: twilio.rest.chat.v1.credential.CredentialContext """ super(CredentialContext, self).__init__(version) # Path Solution self._solution = {'sid': sid,} self._uri = '/Credentials/{sid}'.format(**self._solution) def fetch(self): """ Fetch a CredentialInstance :returns: Fetched CredentialInstance :rtype: twilio.rest.chat.v1.credential.CredentialInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return CredentialInstance(self._version, payload, sid=self._solution['sid'],) def update(self, friendly_name=values.unset, certificate=values.unset, private_key=values.unset, sandbox=values.unset, api_key=values.unset, secret=values.unset): """ Update the CredentialInstance :param unicode friendly_name: The friendly_name :param unicode certificate: The certificate :param unicode private_key: The private_key :param bool sandbox: The sandbox :param unicode api_key: The api_key :param unicode secret: The secret :returns: Updated CredentialInstance :rtype: twilio.rest.chat.v1.credential.CredentialInstance """ data = values.of({ 'FriendlyName': friendly_name, 'Certificate': certificate, 'PrivateKey': private_key, 'Sandbox': sandbox, 'ApiKey': api_key, 'Secret': secret, }) payload = self._version.update( 'POST', self._uri, data=data, ) return CredentialInstance(self._version, payload, sid=self._solution['sid'],) def delete(self): """ Deletes the CredentialInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class CredentialInstance(InstanceResource): """ """ class PushService(object): GCM = "gcm" APN = "apn" FCM = "fcm" def __init__(self, version, payload, sid=None): """ Initialize the CredentialInstance :returns: twilio.rest.chat.v1.credential.CredentialInstance :rtype: twilio.rest.chat.v1.credential.CredentialInstance """ super(CredentialInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'friendly_name': payload['friendly_name'], 'type': payload['type'], 'sandbox': payload['sandbox'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'url': payload['url'], } # Context self._context = None self._solution = {'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: CredentialContext for this CredentialInstance :rtype: twilio.rest.chat.v1.credential.CredentialContext """ if self._context is None: self._context = CredentialContext(self._version, sid=self._solution['sid'],) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def type(self): """ :returns: The type :rtype: CredentialInstance.PushService """ return self._properties['type'] @property def sandbox(self): """ :returns: The sandbox :rtype: unicode """ return self._properties['sandbox'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a CredentialInstance :returns: Fetched CredentialInstance :rtype: twilio.rest.chat.v1.credential.CredentialInstance """ return self._proxy.fetch() def update(self, friendly_name=values.unset, certificate=values.unset, private_key=values.unset, sandbox=values.unset, api_key=values.unset, secret=values.unset): """ Update the CredentialInstance :param unicode friendly_name: The friendly_name :param unicode certificate: The certificate :param unicode private_key: The private_key :param bool sandbox: The sandbox :param unicode api_key: The api_key :param unicode secret: The secret :returns: Updated CredentialInstance :rtype: twilio.rest.chat.v1.credential.CredentialInstance """ return self._proxy.update( friendly_name=friendly_name, certificate=certificate, private_key=private_key, sandbox=sandbox, api_key=api_key, secret=secret, ) def delete(self): """ Deletes the CredentialInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/ip_messaging/v1/service/000077500000000000000000000000001317472742600233115ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/ip_messaging/v1/service/__init__.py000066400000000000000000001406001317472742600254230ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.ip_messaging.v1.service.channel import ChannelList from twilio.rest.ip_messaging.v1.service.role import RoleList from twilio.rest.ip_messaging.v1.service.user import UserList class ServiceList(ListResource): """ """ def __init__(self, version): """ Initialize the ServiceList :param Version version: Version that contains the resource :returns: twilio.rest.chat.v1.service.ServiceList :rtype: twilio.rest.chat.v1.service.ServiceList """ super(ServiceList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/Services'.format(**self._solution) def create(self, friendly_name): """ Create a new ServiceInstance :param unicode friendly_name: The friendly_name :returns: Newly created ServiceInstance :rtype: twilio.rest.chat.v1.service.ServiceInstance """ data = values.of({'FriendlyName': friendly_name,}) payload = self._version.create( 'POST', self._uri, data=data, ) return ServiceInstance(self._version, payload,) def stream(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v1.service.ServiceInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v1.service.ServiceInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of ServiceInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of ServiceInstance :rtype: twilio.rest.chat.v1.service.ServicePage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return ServicePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of ServiceInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of ServiceInstance :rtype: twilio.rest.chat.v1.service.ServicePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return ServicePage(self._version, response, self._solution) def get(self, sid): """ Constructs a ServiceContext :param sid: The sid :returns: twilio.rest.chat.v1.service.ServiceContext :rtype: twilio.rest.chat.v1.service.ServiceContext """ return ServiceContext(self._version, sid=sid,) def __call__(self, sid): """ Constructs a ServiceContext :param sid: The sid :returns: twilio.rest.chat.v1.service.ServiceContext :rtype: twilio.rest.chat.v1.service.ServiceContext """ return ServiceContext(self._version, sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ServicePage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the ServicePage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.chat.v1.service.ServicePage :rtype: twilio.rest.chat.v1.service.ServicePage """ super(ServicePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of ServiceInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v1.service.ServiceInstance :rtype: twilio.rest.chat.v1.service.ServiceInstance """ return ServiceInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ServiceContext(InstanceContext): """ """ def __init__(self, version, sid): """ Initialize the ServiceContext :param Version version: Version that contains the resource :param sid: The sid :returns: twilio.rest.chat.v1.service.ServiceContext :rtype: twilio.rest.chat.v1.service.ServiceContext """ super(ServiceContext, self).__init__(version) # Path Solution self._solution = {'sid': sid,} self._uri = '/Services/{sid}'.format(**self._solution) # Dependents self._channels = None self._roles = None self._users = None def fetch(self): """ Fetch a ServiceInstance :returns: Fetched ServiceInstance :rtype: twilio.rest.chat.v1.service.ServiceInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return ServiceInstance(self._version, payload, sid=self._solution['sid'],) def delete(self): """ Deletes the ServiceInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, friendly_name=values.unset, default_service_role_sid=values.unset, default_channel_role_sid=values.unset, default_channel_creator_role_sid=values.unset, read_status_enabled=values.unset, reachability_enabled=values.unset, typing_indicator_timeout=values.unset, consumption_report_interval=values.unset, notifications_new_message_enabled=values.unset, notifications_new_message_template=values.unset, notifications_added_to_channel_enabled=values.unset, notifications_added_to_channel_template=values.unset, notifications_removed_from_channel_enabled=values.unset, notifications_removed_from_channel_template=values.unset, notifications_invited_to_channel_enabled=values.unset, notifications_invited_to_channel_template=values.unset, pre_webhook_url=values.unset, post_webhook_url=values.unset, webhook_method=values.unset, webhook_filters=values.unset, webhooks_on_message_send_url=values.unset, webhooks_on_message_send_method=values.unset, webhooks_on_message_send_format=values.unset, webhooks_on_message_update_url=values.unset, webhooks_on_message_update_method=values.unset, webhooks_on_message_update_format=values.unset, webhooks_on_message_remove_url=values.unset, webhooks_on_message_remove_method=values.unset, webhooks_on_message_remove_format=values.unset, webhooks_on_channel_add_url=values.unset, webhooks_on_channel_add_method=values.unset, webhooks_on_channel_add_format=values.unset, webhooks_on_channel_destroy_url=values.unset, webhooks_on_channel_destroy_method=values.unset, webhooks_on_channel_destroy_format=values.unset, webhooks_on_channel_update_url=values.unset, webhooks_on_channel_update_method=values.unset, webhooks_on_channel_update_format=values.unset, webhooks_on_member_add_url=values.unset, webhooks_on_member_add_method=values.unset, webhooks_on_member_add_format=values.unset, webhooks_on_member_remove_url=values.unset, webhooks_on_member_remove_method=values.unset, webhooks_on_member_remove_format=values.unset, webhooks_on_message_sent_url=values.unset, webhooks_on_message_sent_method=values.unset, webhooks_on_message_sent_format=values.unset, webhooks_on_message_updated_url=values.unset, webhooks_on_message_updated_method=values.unset, webhooks_on_message_updated_format=values.unset, webhooks_on_message_removed_url=values.unset, webhooks_on_message_removed_method=values.unset, webhooks_on_message_removed_format=values.unset, webhooks_on_channel_added_url=values.unset, webhooks_on_channel_added_method=values.unset, webhooks_on_channel_added_format=values.unset, webhooks_on_channel_destroyed_url=values.unset, webhooks_on_channel_destroyed_method=values.unset, webhooks_on_channel_destroyed_format=values.unset, webhooks_on_channel_updated_url=values.unset, webhooks_on_channel_updated_method=values.unset, webhooks_on_channel_updated_format=values.unset, webhooks_on_member_added_url=values.unset, webhooks_on_member_added_method=values.unset, webhooks_on_member_added_format=values.unset, webhooks_on_member_removed_url=values.unset, webhooks_on_member_removed_method=values.unset, webhooks_on_member_removed_format=values.unset, limits_channel_members=values.unset, limits_user_channels=values.unset): """ Update the ServiceInstance :param unicode friendly_name: The friendly_name :param unicode default_service_role_sid: The default_service_role_sid :param unicode default_channel_role_sid: The default_channel_role_sid :param unicode default_channel_creator_role_sid: The default_channel_creator_role_sid :param bool read_status_enabled: The read_status_enabled :param bool reachability_enabled: The reachability_enabled :param unicode typing_indicator_timeout: The typing_indicator_timeout :param unicode consumption_report_interval: The consumption_report_interval :param bool notifications_new_message_enabled: The notifications.new_message.enabled :param unicode notifications_new_message_template: The notifications.new_message.template :param bool notifications_added_to_channel_enabled: The notifications.added_to_channel.enabled :param unicode notifications_added_to_channel_template: The notifications.added_to_channel.template :param bool notifications_removed_from_channel_enabled: The notifications.removed_from_channel.enabled :param unicode notifications_removed_from_channel_template: The notifications.removed_from_channel.template :param bool notifications_invited_to_channel_enabled: The notifications.invited_to_channel.enabled :param unicode notifications_invited_to_channel_template: The notifications.invited_to_channel.template :param unicode pre_webhook_url: The pre_webhook_url :param unicode post_webhook_url: The post_webhook_url :param unicode webhook_method: The webhook_method :param unicode webhook_filters: The webhook_filters :param unicode webhooks_on_message_send_url: The webhooks.on_message_send.url :param unicode webhooks_on_message_send_method: The webhooks.on_message_send.method :param unicode webhooks_on_message_send_format: The webhooks.on_message_send.format :param unicode webhooks_on_message_update_url: The webhooks.on_message_update.url :param unicode webhooks_on_message_update_method: The webhooks.on_message_update.method :param unicode webhooks_on_message_update_format: The webhooks.on_message_update.format :param unicode webhooks_on_message_remove_url: The webhooks.on_message_remove.url :param unicode webhooks_on_message_remove_method: The webhooks.on_message_remove.method :param unicode webhooks_on_message_remove_format: The webhooks.on_message_remove.format :param unicode webhooks_on_channel_add_url: The webhooks.on_channel_add.url :param unicode webhooks_on_channel_add_method: The webhooks.on_channel_add.method :param unicode webhooks_on_channel_add_format: The webhooks.on_channel_add.format :param unicode webhooks_on_channel_destroy_url: The webhooks.on_channel_destroy.url :param unicode webhooks_on_channel_destroy_method: The webhooks.on_channel_destroy.method :param unicode webhooks_on_channel_destroy_format: The webhooks.on_channel_destroy.format :param unicode webhooks_on_channel_update_url: The webhooks.on_channel_update.url :param unicode webhooks_on_channel_update_method: The webhooks.on_channel_update.method :param unicode webhooks_on_channel_update_format: The webhooks.on_channel_update.format :param unicode webhooks_on_member_add_url: The webhooks.on_member_add.url :param unicode webhooks_on_member_add_method: The webhooks.on_member_add.method :param unicode webhooks_on_member_add_format: The webhooks.on_member_add.format :param unicode webhooks_on_member_remove_url: The webhooks.on_member_remove.url :param unicode webhooks_on_member_remove_method: The webhooks.on_member_remove.method :param unicode webhooks_on_member_remove_format: The webhooks.on_member_remove.format :param unicode webhooks_on_message_sent_url: The webhooks.on_message_sent.url :param unicode webhooks_on_message_sent_method: The webhooks.on_message_sent.method :param unicode webhooks_on_message_sent_format: The webhooks.on_message_sent.format :param unicode webhooks_on_message_updated_url: The webhooks.on_message_updated.url :param unicode webhooks_on_message_updated_method: The webhooks.on_message_updated.method :param unicode webhooks_on_message_updated_format: The webhooks.on_message_updated.format :param unicode webhooks_on_message_removed_url: The webhooks.on_message_removed.url :param unicode webhooks_on_message_removed_method: The webhooks.on_message_removed.method :param unicode webhooks_on_message_removed_format: The webhooks.on_message_removed.format :param unicode webhooks_on_channel_added_url: The webhooks.on_channel_added.url :param unicode webhooks_on_channel_added_method: The webhooks.on_channel_added.method :param unicode webhooks_on_channel_added_format: The webhooks.on_channel_added.format :param unicode webhooks_on_channel_destroyed_url: The webhooks.on_channel_destroyed.url :param unicode webhooks_on_channel_destroyed_method: The webhooks.on_channel_destroyed.method :param unicode webhooks_on_channel_destroyed_format: The webhooks.on_channel_destroyed.format :param unicode webhooks_on_channel_updated_url: The webhooks.on_channel_updated.url :param unicode webhooks_on_channel_updated_method: The webhooks.on_channel_updated.method :param unicode webhooks_on_channel_updated_format: The webhooks.on_channel_updated.format :param unicode webhooks_on_member_added_url: The webhooks.on_member_added.url :param unicode webhooks_on_member_added_method: The webhooks.on_member_added.method :param unicode webhooks_on_member_added_format: The webhooks.on_member_added.format :param unicode webhooks_on_member_removed_url: The webhooks.on_member_removed.url :param unicode webhooks_on_member_removed_method: The webhooks.on_member_removed.method :param unicode webhooks_on_member_removed_format: The webhooks.on_member_removed.format :param unicode limits_channel_members: The limits.channel_members :param unicode limits_user_channels: The limits.user_channels :returns: Updated ServiceInstance :rtype: twilio.rest.chat.v1.service.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, 'TypingIndicatorTimeout': typing_indicator_timeout, 'ConsumptionReportInterval': consumption_report_interval, 'Notifications.NewMessage.Enabled': notifications_new_message_enabled, 'Notifications.NewMessage.Template': notifications_new_message_template, 'Notifications.AddedToChannel.Enabled': notifications_added_to_channel_enabled, 'Notifications.AddedToChannel.Template': notifications_added_to_channel_template, 'Notifications.RemovedFromChannel.Enabled': notifications_removed_from_channel_enabled, 'Notifications.RemovedFromChannel.Template': notifications_removed_from_channel_template, 'Notifications.InvitedToChannel.Enabled': notifications_invited_to_channel_enabled, 'Notifications.InvitedToChannel.Template': notifications_invited_to_channel_template, 'PreWebhookUrl': pre_webhook_url, 'PostWebhookUrl': post_webhook_url, 'WebhookMethod': webhook_method, 'WebhookFilters': webhook_filters, 'Webhooks.OnMessageSend.Url': webhooks_on_message_send_url, 'Webhooks.OnMessageSend.Method': webhooks_on_message_send_method, 'Webhooks.OnMessageSend.Format': webhooks_on_message_send_format, 'Webhooks.OnMessageUpdate.Url': webhooks_on_message_update_url, 'Webhooks.OnMessageUpdate.Method': webhooks_on_message_update_method, 'Webhooks.OnMessageUpdate.Format': webhooks_on_message_update_format, 'Webhooks.OnMessageRemove.Url': webhooks_on_message_remove_url, 'Webhooks.OnMessageRemove.Method': webhooks_on_message_remove_method, 'Webhooks.OnMessageRemove.Format': webhooks_on_message_remove_format, 'Webhooks.OnChannelAdd.Url': webhooks_on_channel_add_url, 'Webhooks.OnChannelAdd.Method': webhooks_on_channel_add_method, 'Webhooks.OnChannelAdd.Format': webhooks_on_channel_add_format, 'Webhooks.OnChannelDestroy.Url': webhooks_on_channel_destroy_url, 'Webhooks.OnChannelDestroy.Method': webhooks_on_channel_destroy_method, 'Webhooks.OnChannelDestroy.Format': webhooks_on_channel_destroy_format, 'Webhooks.OnChannelUpdate.Url': webhooks_on_channel_update_url, 'Webhooks.OnChannelUpdate.Method': webhooks_on_channel_update_method, 'Webhooks.OnChannelUpdate.Format': webhooks_on_channel_update_format, 'Webhooks.OnMemberAdd.Url': webhooks_on_member_add_url, 'Webhooks.OnMemberAdd.Method': webhooks_on_member_add_method, 'Webhooks.OnMemberAdd.Format': webhooks_on_member_add_format, 'Webhooks.OnMemberRemove.Url': webhooks_on_member_remove_url, 'Webhooks.OnMemberRemove.Method': webhooks_on_member_remove_method, 'Webhooks.OnMemberRemove.Format': webhooks_on_member_remove_format, 'Webhooks.OnMessageSent.Url': webhooks_on_message_sent_url, 'Webhooks.OnMessageSent.Method': webhooks_on_message_sent_method, 'Webhooks.OnMessageSent.Format': webhooks_on_message_sent_format, 'Webhooks.OnMessageUpdated.Url': webhooks_on_message_updated_url, 'Webhooks.OnMessageUpdated.Method': webhooks_on_message_updated_method, 'Webhooks.OnMessageUpdated.Format': webhooks_on_message_updated_format, 'Webhooks.OnMessageRemoved.Url': webhooks_on_message_removed_url, 'Webhooks.OnMessageRemoved.Method': webhooks_on_message_removed_method, 'Webhooks.OnMessageRemoved.Format': webhooks_on_message_removed_format, 'Webhooks.OnChannelAdded.Url': webhooks_on_channel_added_url, 'Webhooks.OnChannelAdded.Method': webhooks_on_channel_added_method, 'Webhooks.OnChannelAdded.Format': webhooks_on_channel_added_format, 'Webhooks.OnChannelDestroyed.Url': webhooks_on_channel_destroyed_url, 'Webhooks.OnChannelDestroyed.Method': webhooks_on_channel_destroyed_method, 'Webhooks.OnChannelDestroyed.Format': webhooks_on_channel_destroyed_format, 'Webhooks.OnChannelUpdated.Url': webhooks_on_channel_updated_url, 'Webhooks.OnChannelUpdated.Method': webhooks_on_channel_updated_method, 'Webhooks.OnChannelUpdated.Format': webhooks_on_channel_updated_format, 'Webhooks.OnMemberAdded.Url': webhooks_on_member_added_url, 'Webhooks.OnMemberAdded.Method': webhooks_on_member_added_method, 'Webhooks.OnMemberAdded.Format': webhooks_on_member_added_format, 'Webhooks.OnMemberRemoved.Url': webhooks_on_member_removed_url, 'Webhooks.OnMemberRemoved.Method': webhooks_on_member_removed_method, 'Webhooks.OnMemberRemoved.Format': webhooks_on_member_removed_format, 'Limits.ChannelMembers': limits_channel_members, 'Limits.UserChannels': limits_user_channels, }) payload = self._version.update( 'POST', self._uri, data=data, ) return ServiceInstance(self._version, payload, sid=self._solution['sid'],) @property def channels(self): """ Access the channels :returns: twilio.rest.chat.v1.service.channel.ChannelList :rtype: twilio.rest.chat.v1.service.channel.ChannelList """ if self._channels is None: self._channels = ChannelList(self._version, service_sid=self._solution['sid'],) return self._channels @property def roles(self): """ Access the roles :returns: twilio.rest.chat.v1.service.role.RoleList :rtype: twilio.rest.chat.v1.service.role.RoleList """ if self._roles is None: self._roles = RoleList(self._version, service_sid=self._solution['sid'],) return self._roles @property def users(self): """ Access the users :returns: twilio.rest.chat.v1.service.user.UserList :rtype: twilio.rest.chat.v1.service.user.UserList """ if self._users is None: self._users = UserList(self._version, service_sid=self._solution['sid'],) return self._users def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class ServiceInstance(InstanceResource): """ """ def __init__(self, version, payload, sid=None): """ Initialize the ServiceInstance :returns: twilio.rest.chat.v1.service.ServiceInstance :rtype: twilio.rest.chat.v1.service.ServiceInstance """ super(ServiceInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'friendly_name': payload['friendly_name'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'default_service_role_sid': payload['default_service_role_sid'], 'default_channel_role_sid': payload['default_channel_role_sid'], 'default_channel_creator_role_sid': payload['default_channel_creator_role_sid'], 'read_status_enabled': payload['read_status_enabled'], 'reachability_enabled': payload['reachability_enabled'], 'typing_indicator_timeout': deserialize.integer(payload['typing_indicator_timeout']), 'consumption_report_interval': deserialize.integer(payload['consumption_report_interval']), 'limits': payload['limits'], 'webhooks': payload['webhooks'], 'pre_webhook_url': payload['pre_webhook_url'], 'post_webhook_url': payload['post_webhook_url'], 'webhook_method': payload['webhook_method'], 'webhook_filters': payload['webhook_filters'], 'notifications': payload['notifications'], 'url': payload['url'], 'links': payload['links'], } # Context self._context = None self._solution = {'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.chat.v1.service.ServiceContext """ if self._context is None: self._context = ServiceContext(self._version, sid=self._solution['sid'],) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def default_service_role_sid(self): """ :returns: The default_service_role_sid :rtype: unicode """ return self._properties['default_service_role_sid'] @property def default_channel_role_sid(self): """ :returns: The default_channel_role_sid :rtype: unicode """ return self._properties['default_channel_role_sid'] @property def default_channel_creator_role_sid(self): """ :returns: The default_channel_creator_role_sid :rtype: unicode """ return self._properties['default_channel_creator_role_sid'] @property def read_status_enabled(self): """ :returns: The read_status_enabled :rtype: bool """ return self._properties['read_status_enabled'] @property def reachability_enabled(self): """ :returns: The reachability_enabled :rtype: bool """ return self._properties['reachability_enabled'] @property def typing_indicator_timeout(self): """ :returns: The typing_indicator_timeout :rtype: unicode """ return self._properties['typing_indicator_timeout'] @property def consumption_report_interval(self): """ :returns: The consumption_report_interval :rtype: unicode """ return self._properties['consumption_report_interval'] @property def limits(self): """ :returns: The limits :rtype: dict """ return self._properties['limits'] @property def webhooks(self): """ :returns: The webhooks :rtype: dict """ return self._properties['webhooks'] @property def pre_webhook_url(self): """ :returns: The pre_webhook_url :rtype: unicode """ return self._properties['pre_webhook_url'] @property def post_webhook_url(self): """ :returns: The post_webhook_url :rtype: unicode """ return self._properties['post_webhook_url'] @property def webhook_method(self): """ :returns: The webhook_method :rtype: unicode """ return self._properties['webhook_method'] @property def webhook_filters(self): """ :returns: The webhook_filters :rtype: unicode """ return self._properties['webhook_filters'] @property def notifications(self): """ :returns: The notifications :rtype: dict """ return self._properties['notifications'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a ServiceInstance :returns: Fetched ServiceInstance :rtype: twilio.rest.chat.v1.service.ServiceInstance """ return self._proxy.fetch() def delete(self): """ Deletes the ServiceInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, friendly_name=values.unset, default_service_role_sid=values.unset, default_channel_role_sid=values.unset, default_channel_creator_role_sid=values.unset, read_status_enabled=values.unset, reachability_enabled=values.unset, typing_indicator_timeout=values.unset, consumption_report_interval=values.unset, notifications_new_message_enabled=values.unset, notifications_new_message_template=values.unset, notifications_added_to_channel_enabled=values.unset, notifications_added_to_channel_template=values.unset, notifications_removed_from_channel_enabled=values.unset, notifications_removed_from_channel_template=values.unset, notifications_invited_to_channel_enabled=values.unset, notifications_invited_to_channel_template=values.unset, pre_webhook_url=values.unset, post_webhook_url=values.unset, webhook_method=values.unset, webhook_filters=values.unset, webhooks_on_message_send_url=values.unset, webhooks_on_message_send_method=values.unset, webhooks_on_message_send_format=values.unset, webhooks_on_message_update_url=values.unset, webhooks_on_message_update_method=values.unset, webhooks_on_message_update_format=values.unset, webhooks_on_message_remove_url=values.unset, webhooks_on_message_remove_method=values.unset, webhooks_on_message_remove_format=values.unset, webhooks_on_channel_add_url=values.unset, webhooks_on_channel_add_method=values.unset, webhooks_on_channel_add_format=values.unset, webhooks_on_channel_destroy_url=values.unset, webhooks_on_channel_destroy_method=values.unset, webhooks_on_channel_destroy_format=values.unset, webhooks_on_channel_update_url=values.unset, webhooks_on_channel_update_method=values.unset, webhooks_on_channel_update_format=values.unset, webhooks_on_member_add_url=values.unset, webhooks_on_member_add_method=values.unset, webhooks_on_member_add_format=values.unset, webhooks_on_member_remove_url=values.unset, webhooks_on_member_remove_method=values.unset, webhooks_on_member_remove_format=values.unset, webhooks_on_message_sent_url=values.unset, webhooks_on_message_sent_method=values.unset, webhooks_on_message_sent_format=values.unset, webhooks_on_message_updated_url=values.unset, webhooks_on_message_updated_method=values.unset, webhooks_on_message_updated_format=values.unset, webhooks_on_message_removed_url=values.unset, webhooks_on_message_removed_method=values.unset, webhooks_on_message_removed_format=values.unset, webhooks_on_channel_added_url=values.unset, webhooks_on_channel_added_method=values.unset, webhooks_on_channel_added_format=values.unset, webhooks_on_channel_destroyed_url=values.unset, webhooks_on_channel_destroyed_method=values.unset, webhooks_on_channel_destroyed_format=values.unset, webhooks_on_channel_updated_url=values.unset, webhooks_on_channel_updated_method=values.unset, webhooks_on_channel_updated_format=values.unset, webhooks_on_member_added_url=values.unset, webhooks_on_member_added_method=values.unset, webhooks_on_member_added_format=values.unset, webhooks_on_member_removed_url=values.unset, webhooks_on_member_removed_method=values.unset, webhooks_on_member_removed_format=values.unset, limits_channel_members=values.unset, limits_user_channels=values.unset): """ Update the ServiceInstance :param unicode friendly_name: The friendly_name :param unicode default_service_role_sid: The default_service_role_sid :param unicode default_channel_role_sid: The default_channel_role_sid :param unicode default_channel_creator_role_sid: The default_channel_creator_role_sid :param bool read_status_enabled: The read_status_enabled :param bool reachability_enabled: The reachability_enabled :param unicode typing_indicator_timeout: The typing_indicator_timeout :param unicode consumption_report_interval: The consumption_report_interval :param bool notifications_new_message_enabled: The notifications.new_message.enabled :param unicode notifications_new_message_template: The notifications.new_message.template :param bool notifications_added_to_channel_enabled: The notifications.added_to_channel.enabled :param unicode notifications_added_to_channel_template: The notifications.added_to_channel.template :param bool notifications_removed_from_channel_enabled: The notifications.removed_from_channel.enabled :param unicode notifications_removed_from_channel_template: The notifications.removed_from_channel.template :param bool notifications_invited_to_channel_enabled: The notifications.invited_to_channel.enabled :param unicode notifications_invited_to_channel_template: The notifications.invited_to_channel.template :param unicode pre_webhook_url: The pre_webhook_url :param unicode post_webhook_url: The post_webhook_url :param unicode webhook_method: The webhook_method :param unicode webhook_filters: The webhook_filters :param unicode webhooks_on_message_send_url: The webhooks.on_message_send.url :param unicode webhooks_on_message_send_method: The webhooks.on_message_send.method :param unicode webhooks_on_message_send_format: The webhooks.on_message_send.format :param unicode webhooks_on_message_update_url: The webhooks.on_message_update.url :param unicode webhooks_on_message_update_method: The webhooks.on_message_update.method :param unicode webhooks_on_message_update_format: The webhooks.on_message_update.format :param unicode webhooks_on_message_remove_url: The webhooks.on_message_remove.url :param unicode webhooks_on_message_remove_method: The webhooks.on_message_remove.method :param unicode webhooks_on_message_remove_format: The webhooks.on_message_remove.format :param unicode webhooks_on_channel_add_url: The webhooks.on_channel_add.url :param unicode webhooks_on_channel_add_method: The webhooks.on_channel_add.method :param unicode webhooks_on_channel_add_format: The webhooks.on_channel_add.format :param unicode webhooks_on_channel_destroy_url: The webhooks.on_channel_destroy.url :param unicode webhooks_on_channel_destroy_method: The webhooks.on_channel_destroy.method :param unicode webhooks_on_channel_destroy_format: The webhooks.on_channel_destroy.format :param unicode webhooks_on_channel_update_url: The webhooks.on_channel_update.url :param unicode webhooks_on_channel_update_method: The webhooks.on_channel_update.method :param unicode webhooks_on_channel_update_format: The webhooks.on_channel_update.format :param unicode webhooks_on_member_add_url: The webhooks.on_member_add.url :param unicode webhooks_on_member_add_method: The webhooks.on_member_add.method :param unicode webhooks_on_member_add_format: The webhooks.on_member_add.format :param unicode webhooks_on_member_remove_url: The webhooks.on_member_remove.url :param unicode webhooks_on_member_remove_method: The webhooks.on_member_remove.method :param unicode webhooks_on_member_remove_format: The webhooks.on_member_remove.format :param unicode webhooks_on_message_sent_url: The webhooks.on_message_sent.url :param unicode webhooks_on_message_sent_method: The webhooks.on_message_sent.method :param unicode webhooks_on_message_sent_format: The webhooks.on_message_sent.format :param unicode webhooks_on_message_updated_url: The webhooks.on_message_updated.url :param unicode webhooks_on_message_updated_method: The webhooks.on_message_updated.method :param unicode webhooks_on_message_updated_format: The webhooks.on_message_updated.format :param unicode webhooks_on_message_removed_url: The webhooks.on_message_removed.url :param unicode webhooks_on_message_removed_method: The webhooks.on_message_removed.method :param unicode webhooks_on_message_removed_format: The webhooks.on_message_removed.format :param unicode webhooks_on_channel_added_url: The webhooks.on_channel_added.url :param unicode webhooks_on_channel_added_method: The webhooks.on_channel_added.method :param unicode webhooks_on_channel_added_format: The webhooks.on_channel_added.format :param unicode webhooks_on_channel_destroyed_url: The webhooks.on_channel_destroyed.url :param unicode webhooks_on_channel_destroyed_method: The webhooks.on_channel_destroyed.method :param unicode webhooks_on_channel_destroyed_format: The webhooks.on_channel_destroyed.format :param unicode webhooks_on_channel_updated_url: The webhooks.on_channel_updated.url :param unicode webhooks_on_channel_updated_method: The webhooks.on_channel_updated.method :param unicode webhooks_on_channel_updated_format: The webhooks.on_channel_updated.format :param unicode webhooks_on_member_added_url: The webhooks.on_member_added.url :param unicode webhooks_on_member_added_method: The webhooks.on_member_added.method :param unicode webhooks_on_member_added_format: The webhooks.on_member_added.format :param unicode webhooks_on_member_removed_url: The webhooks.on_member_removed.url :param unicode webhooks_on_member_removed_method: The webhooks.on_member_removed.method :param unicode webhooks_on_member_removed_format: The webhooks.on_member_removed.format :param unicode limits_channel_members: The limits.channel_members :param unicode limits_user_channels: The limits.user_channels :returns: Updated ServiceInstance :rtype: twilio.rest.chat.v1.service.ServiceInstance """ return self._proxy.update( friendly_name=friendly_name, default_service_role_sid=default_service_role_sid, default_channel_role_sid=default_channel_role_sid, default_channel_creator_role_sid=default_channel_creator_role_sid, read_status_enabled=read_status_enabled, reachability_enabled=reachability_enabled, typing_indicator_timeout=typing_indicator_timeout, consumption_report_interval=consumption_report_interval, notifications_new_message_enabled=notifications_new_message_enabled, notifications_new_message_template=notifications_new_message_template, notifications_added_to_channel_enabled=notifications_added_to_channel_enabled, notifications_added_to_channel_template=notifications_added_to_channel_template, notifications_removed_from_channel_enabled=notifications_removed_from_channel_enabled, notifications_removed_from_channel_template=notifications_removed_from_channel_template, notifications_invited_to_channel_enabled=notifications_invited_to_channel_enabled, notifications_invited_to_channel_template=notifications_invited_to_channel_template, pre_webhook_url=pre_webhook_url, post_webhook_url=post_webhook_url, webhook_method=webhook_method, webhook_filters=webhook_filters, webhooks_on_message_send_url=webhooks_on_message_send_url, webhooks_on_message_send_method=webhooks_on_message_send_method, webhooks_on_message_send_format=webhooks_on_message_send_format, webhooks_on_message_update_url=webhooks_on_message_update_url, webhooks_on_message_update_method=webhooks_on_message_update_method, webhooks_on_message_update_format=webhooks_on_message_update_format, webhooks_on_message_remove_url=webhooks_on_message_remove_url, webhooks_on_message_remove_method=webhooks_on_message_remove_method, webhooks_on_message_remove_format=webhooks_on_message_remove_format, webhooks_on_channel_add_url=webhooks_on_channel_add_url, webhooks_on_channel_add_method=webhooks_on_channel_add_method, webhooks_on_channel_add_format=webhooks_on_channel_add_format, webhooks_on_channel_destroy_url=webhooks_on_channel_destroy_url, webhooks_on_channel_destroy_method=webhooks_on_channel_destroy_method, webhooks_on_channel_destroy_format=webhooks_on_channel_destroy_format, webhooks_on_channel_update_url=webhooks_on_channel_update_url, webhooks_on_channel_update_method=webhooks_on_channel_update_method, webhooks_on_channel_update_format=webhooks_on_channel_update_format, webhooks_on_member_add_url=webhooks_on_member_add_url, webhooks_on_member_add_method=webhooks_on_member_add_method, webhooks_on_member_add_format=webhooks_on_member_add_format, webhooks_on_member_remove_url=webhooks_on_member_remove_url, webhooks_on_member_remove_method=webhooks_on_member_remove_method, webhooks_on_member_remove_format=webhooks_on_member_remove_format, webhooks_on_message_sent_url=webhooks_on_message_sent_url, webhooks_on_message_sent_method=webhooks_on_message_sent_method, webhooks_on_message_sent_format=webhooks_on_message_sent_format, webhooks_on_message_updated_url=webhooks_on_message_updated_url, webhooks_on_message_updated_method=webhooks_on_message_updated_method, webhooks_on_message_updated_format=webhooks_on_message_updated_format, webhooks_on_message_removed_url=webhooks_on_message_removed_url, webhooks_on_message_removed_method=webhooks_on_message_removed_method, webhooks_on_message_removed_format=webhooks_on_message_removed_format, webhooks_on_channel_added_url=webhooks_on_channel_added_url, webhooks_on_channel_added_method=webhooks_on_channel_added_method, webhooks_on_channel_added_format=webhooks_on_channel_added_format, webhooks_on_channel_destroyed_url=webhooks_on_channel_destroyed_url, webhooks_on_channel_destroyed_method=webhooks_on_channel_destroyed_method, webhooks_on_channel_destroyed_format=webhooks_on_channel_destroyed_format, webhooks_on_channel_updated_url=webhooks_on_channel_updated_url, webhooks_on_channel_updated_method=webhooks_on_channel_updated_method, webhooks_on_channel_updated_format=webhooks_on_channel_updated_format, webhooks_on_member_added_url=webhooks_on_member_added_url, webhooks_on_member_added_method=webhooks_on_member_added_method, webhooks_on_member_added_format=webhooks_on_member_added_format, webhooks_on_member_removed_url=webhooks_on_member_removed_url, webhooks_on_member_removed_method=webhooks_on_member_removed_method, webhooks_on_member_removed_format=webhooks_on_member_removed_format, limits_channel_members=limits_channel_members, limits_user_channels=limits_user_channels, ) @property def channels(self): """ Access the channels :returns: twilio.rest.chat.v1.service.channel.ChannelList :rtype: twilio.rest.chat.v1.service.channel.ChannelList """ return self._proxy.channels @property def roles(self): """ Access the roles :returns: twilio.rest.chat.v1.service.role.RoleList :rtype: twilio.rest.chat.v1.service.role.RoleList """ return self._proxy.roles @property def users(self): """ Access the users :returns: twilio.rest.chat.v1.service.user.UserList :rtype: twilio.rest.chat.v1.service.user.UserList """ return self._proxy.users def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/ip_messaging/v1/service/channel/000077500000000000000000000000001317472742600247215ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/ip_messaging/v1/service/channel/__init__.py000066400000000000000000000446551317472742600270500ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.ip_messaging.v1.service.channel.invite import InviteList from twilio.rest.ip_messaging.v1.service.channel.member import MemberList from twilio.rest.ip_messaging.v1.service.channel.message import MessageList class ChannelList(ListResource): """ """ def __init__(self, version, service_sid): """ Initialize the ChannelList :param Version version: Version that contains the resource :param service_sid: The service_sid :returns: twilio.rest.chat.v1.service.channel.ChannelList :rtype: twilio.rest.chat.v1.service.channel.ChannelList """ super(ChannelList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid,} self._uri = '/Services/{service_sid}/Channels'.format(**self._solution) def create(self, friendly_name=values.unset, unique_name=values.unset, attributes=values.unset, type=values.unset): """ Create a new ChannelInstance :param unicode friendly_name: The friendly_name :param unicode unique_name: The unique_name :param unicode attributes: The attributes :param ChannelInstance.ChannelType type: The type :returns: Newly created ChannelInstance :rtype: twilio.rest.chat.v1.service.channel.ChannelInstance """ data = values.of({ 'FriendlyName': friendly_name, 'UniqueName': unique_name, 'Attributes': attributes, 'Type': type, }) payload = self._version.create( 'POST', self._uri, data=data, ) return ChannelInstance(self._version, payload, service_sid=self._solution['service_sid'],) def stream(self, type=values.unset, limit=None, page_size=None): """ Streams ChannelInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param ChannelInstance.ChannelType type: The type :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v1.service.channel.ChannelInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(type=type, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, type=values.unset, limit=None, page_size=None): """ Lists ChannelInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param ChannelInstance.ChannelType type: The type :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v1.service.channel.ChannelInstance] """ return list(self.stream(type=type, limit=limit, page_size=page_size,)) def page(self, type=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of ChannelInstance records from the API. Request is executed immediately :param ChannelInstance.ChannelType type: The type :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of ChannelInstance :rtype: twilio.rest.chat.v1.service.channel.ChannelPage """ params = values.of({'Type': type, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return ChannelPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of ChannelInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of ChannelInstance :rtype: twilio.rest.chat.v1.service.channel.ChannelPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return ChannelPage(self._version, response, self._solution) def get(self, sid): """ Constructs a ChannelContext :param sid: The sid :returns: twilio.rest.chat.v1.service.channel.ChannelContext :rtype: twilio.rest.chat.v1.service.channel.ChannelContext """ return ChannelContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __call__(self, sid): """ Constructs a ChannelContext :param sid: The sid :returns: twilio.rest.chat.v1.service.channel.ChannelContext :rtype: twilio.rest.chat.v1.service.channel.ChannelContext """ return ChannelContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ChannelPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the ChannelPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :returns: twilio.rest.chat.v1.service.channel.ChannelPage :rtype: twilio.rest.chat.v1.service.channel.ChannelPage """ super(ChannelPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of ChannelInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v1.service.channel.ChannelInstance :rtype: twilio.rest.chat.v1.service.channel.ChannelInstance """ return ChannelInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ChannelContext(InstanceContext): """ """ def __init__(self, version, service_sid, sid): """ Initialize the ChannelContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param sid: The sid :returns: twilio.rest.chat.v1.service.channel.ChannelContext :rtype: twilio.rest.chat.v1.service.channel.ChannelContext """ super(ChannelContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Channels/{sid}'.format(**self._solution) # Dependents self._members = None self._messages = None self._invites = None def fetch(self): """ Fetch a ChannelInstance :returns: Fetched ChannelInstance :rtype: twilio.rest.chat.v1.service.channel.ChannelInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return ChannelInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the ChannelInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, friendly_name=values.unset, unique_name=values.unset, attributes=values.unset): """ Update the ChannelInstance :param unicode friendly_name: The friendly_name :param unicode unique_name: The unique_name :param unicode attributes: The attributes :returns: Updated ChannelInstance :rtype: twilio.rest.chat.v1.service.channel.ChannelInstance """ data = values.of({'FriendlyName': friendly_name, 'UniqueName': unique_name, 'Attributes': attributes,}) payload = self._version.update( 'POST', self._uri, data=data, ) return ChannelInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) @property def members(self): """ Access the members :returns: twilio.rest.chat.v1.service.channel.member.MemberList :rtype: twilio.rest.chat.v1.service.channel.member.MemberList """ if self._members is None: self._members = MemberList( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['sid'], ) return self._members @property def messages(self): """ Access the messages :returns: twilio.rest.chat.v1.service.channel.message.MessageList :rtype: twilio.rest.chat.v1.service.channel.message.MessageList """ if self._messages is None: self._messages = MessageList( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['sid'], ) return self._messages @property def invites(self): """ Access the invites :returns: twilio.rest.chat.v1.service.channel.invite.InviteList :rtype: twilio.rest.chat.v1.service.channel.invite.InviteList """ if self._invites is None: self._invites = InviteList( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['sid'], ) return self._invites def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class ChannelInstance(InstanceResource): """ """ class ChannelType(object): PUBLIC = "public" PRIVATE = "private" def __init__(self, version, payload, service_sid, sid=None): """ Initialize the ChannelInstance :returns: twilio.rest.chat.v1.service.channel.ChannelInstance :rtype: twilio.rest.chat.v1.service.channel.ChannelInstance """ super(ChannelInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'friendly_name': payload['friendly_name'], 'unique_name': payload['unique_name'], 'attributes': payload['attributes'], 'type': payload['type'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'created_by': payload['created_by'], 'members_count': deserialize.integer(payload['members_count']), 'messages_count': deserialize.integer(payload['messages_count']), 'url': payload['url'], 'links': payload['links'], } # Context self._context = None self._solution = {'service_sid': service_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: ChannelContext for this ChannelInstance :rtype: twilio.rest.chat.v1.service.channel.ChannelContext """ if self._context is None: self._context = ChannelContext( self._version, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def unique_name(self): """ :returns: The unique_name :rtype: unicode """ return self._properties['unique_name'] @property def attributes(self): """ :returns: The attributes :rtype: unicode """ return self._properties['attributes'] @property def type(self): """ :returns: The type :rtype: ChannelInstance.ChannelType """ return self._properties['type'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def created_by(self): """ :returns: The created_by :rtype: unicode """ return self._properties['created_by'] @property def members_count(self): """ :returns: The members_count :rtype: unicode """ return self._properties['members_count'] @property def messages_count(self): """ :returns: The messages_count :rtype: unicode """ return self._properties['messages_count'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a ChannelInstance :returns: Fetched ChannelInstance :rtype: twilio.rest.chat.v1.service.channel.ChannelInstance """ return self._proxy.fetch() def delete(self): """ Deletes the ChannelInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, friendly_name=values.unset, unique_name=values.unset, attributes=values.unset): """ Update the ChannelInstance :param unicode friendly_name: The friendly_name :param unicode unique_name: The unique_name :param unicode attributes: The attributes :returns: Updated ChannelInstance :rtype: twilio.rest.chat.v1.service.channel.ChannelInstance """ return self._proxy.update(friendly_name=friendly_name, unique_name=unique_name, attributes=attributes,) @property def members(self): """ Access the members :returns: twilio.rest.chat.v1.service.channel.member.MemberList :rtype: twilio.rest.chat.v1.service.channel.member.MemberList """ return self._proxy.members @property def messages(self): """ Access the messages :returns: twilio.rest.chat.v1.service.channel.message.MessageList :rtype: twilio.rest.chat.v1.service.channel.message.MessageList """ return self._proxy.messages @property def invites(self): """ Access the invites :returns: twilio.rest.chat.v1.service.channel.invite.InviteList :rtype: twilio.rest.chat.v1.service.channel.invite.InviteList """ return self._proxy.invites def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/ip_messaging/v1/service/channel/invite.py000066400000000000000000000342231317472742600265750ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class InviteList(ListResource): """ """ def __init__(self, version, service_sid, channel_sid): """ Initialize the InviteList :param Version version: Version that contains the resource :param service_sid: The service_sid :param channel_sid: The channel_sid :returns: twilio.rest.chat.v1.service.channel.invite.InviteList :rtype: twilio.rest.chat.v1.service.channel.invite.InviteList """ super(InviteList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'channel_sid': channel_sid,} self._uri = '/Services/{service_sid}/Channels/{channel_sid}/Invites'.format(**self._solution) def create(self, identity, role_sid=values.unset): """ Create a new InviteInstance :param unicode identity: The identity :param unicode role_sid: The role_sid :returns: Newly created InviteInstance :rtype: twilio.rest.chat.v1.service.channel.invite.InviteInstance """ data = values.of({'Identity': identity, 'RoleSid': role_sid,}) payload = self._version.create( 'POST', self._uri, data=data, ) return InviteInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], ) def stream(self, identity=values.unset, limit=None, page_size=None): """ Streams InviteInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param unicode identity: The identity :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v1.service.channel.invite.InviteInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(identity=identity, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, identity=values.unset, limit=None, page_size=None): """ Lists InviteInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param unicode identity: The identity :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v1.service.channel.invite.InviteInstance] """ return list(self.stream(identity=identity, limit=limit, page_size=page_size,)) def page(self, identity=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of InviteInstance records from the API. Request is executed immediately :param unicode identity: The identity :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of InviteInstance :rtype: twilio.rest.chat.v1.service.channel.invite.InvitePage """ params = values.of({ 'Identity': identity, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return InvitePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of InviteInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of InviteInstance :rtype: twilio.rest.chat.v1.service.channel.invite.InvitePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return InvitePage(self._version, response, self._solution) def get(self, sid): """ Constructs a InviteContext :param sid: The sid :returns: twilio.rest.chat.v1.service.channel.invite.InviteContext :rtype: twilio.rest.chat.v1.service.channel.invite.InviteContext """ return InviteContext( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a InviteContext :param sid: The sid :returns: twilio.rest.chat.v1.service.channel.invite.InviteContext :rtype: twilio.rest.chat.v1.service.channel.invite.InviteContext """ return InviteContext( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class InvitePage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the InvitePage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :param channel_sid: The channel_sid :returns: twilio.rest.chat.v1.service.channel.invite.InvitePage :rtype: twilio.rest.chat.v1.service.channel.invite.InvitePage """ super(InvitePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of InviteInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v1.service.channel.invite.InviteInstance :rtype: twilio.rest.chat.v1.service.channel.invite.InviteInstance """ return InviteInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class InviteContext(InstanceContext): """ """ def __init__(self, version, service_sid, channel_sid, sid): """ Initialize the InviteContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param channel_sid: The channel_sid :param sid: The sid :returns: twilio.rest.chat.v1.service.channel.invite.InviteContext :rtype: twilio.rest.chat.v1.service.channel.invite.InviteContext """ super(InviteContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'channel_sid': channel_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Channels/{channel_sid}/Invites/{sid}'.format(**self._solution) def fetch(self): """ Fetch a InviteInstance :returns: Fetched InviteInstance :rtype: twilio.rest.chat.v1.service.channel.invite.InviteInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return InviteInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the InviteInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class InviteInstance(InstanceResource): """ """ def __init__(self, version, payload, service_sid, channel_sid, sid=None): """ Initialize the InviteInstance :returns: twilio.rest.chat.v1.service.channel.invite.InviteInstance :rtype: twilio.rest.chat.v1.service.channel.invite.InviteInstance """ super(InviteInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'channel_sid': payload['channel_sid'], 'service_sid': payload['service_sid'], 'identity': payload['identity'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'role_sid': payload['role_sid'], 'created_by': payload['created_by'], 'url': payload['url'], } # Context self._context = None self._solution = { 'service_sid': service_sid, 'channel_sid': channel_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: InviteContext for this InviteInstance :rtype: twilio.rest.chat.v1.service.channel.invite.InviteContext """ if self._context is None: self._context = InviteContext( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def channel_sid(self): """ :returns: The channel_sid :rtype: unicode """ return self._properties['channel_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def identity(self): """ :returns: The identity :rtype: unicode """ return self._properties['identity'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def role_sid(self): """ :returns: The role_sid :rtype: unicode """ return self._properties['role_sid'] @property def created_by(self): """ :returns: The created_by :rtype: unicode """ return self._properties['created_by'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a InviteInstance :returns: Fetched InviteInstance :rtype: twilio.rest.chat.v1.service.channel.invite.InviteInstance """ return self._proxy.fetch() def delete(self): """ Deletes the InviteInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/ip_messaging/v1/service/channel/member.py000066400000000000000000000376621317472742600265600ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class MemberList(ListResource): """ """ def __init__(self, version, service_sid, channel_sid): """ Initialize the MemberList :param Version version: Version that contains the resource :param service_sid: The service_sid :param channel_sid: The channel_sid :returns: twilio.rest.chat.v1.service.channel.member.MemberList :rtype: twilio.rest.chat.v1.service.channel.member.MemberList """ super(MemberList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'channel_sid': channel_sid,} self._uri = '/Services/{service_sid}/Channels/{channel_sid}/Members'.format(**self._solution) def create(self, identity, role_sid=values.unset): """ Create a new MemberInstance :param unicode identity: The identity :param unicode role_sid: The role_sid :returns: Newly created MemberInstance :rtype: twilio.rest.chat.v1.service.channel.member.MemberInstance """ data = values.of({'Identity': identity, 'RoleSid': role_sid,}) payload = self._version.create( 'POST', self._uri, data=data, ) return MemberInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], ) def stream(self, identity=values.unset, limit=None, page_size=None): """ Streams MemberInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param unicode identity: The identity :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v1.service.channel.member.MemberInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(identity=identity, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, identity=values.unset, limit=None, page_size=None): """ Lists MemberInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param unicode identity: The identity :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v1.service.channel.member.MemberInstance] """ return list(self.stream(identity=identity, limit=limit, page_size=page_size,)) def page(self, identity=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of MemberInstance records from the API. Request is executed immediately :param unicode identity: The identity :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of MemberInstance :rtype: twilio.rest.chat.v1.service.channel.member.MemberPage """ params = values.of({ 'Identity': identity, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return MemberPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of MemberInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of MemberInstance :rtype: twilio.rest.chat.v1.service.channel.member.MemberPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return MemberPage(self._version, response, self._solution) def get(self, sid): """ Constructs a MemberContext :param sid: The sid :returns: twilio.rest.chat.v1.service.channel.member.MemberContext :rtype: twilio.rest.chat.v1.service.channel.member.MemberContext """ return MemberContext( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a MemberContext :param sid: The sid :returns: twilio.rest.chat.v1.service.channel.member.MemberContext :rtype: twilio.rest.chat.v1.service.channel.member.MemberContext """ return MemberContext( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class MemberPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the MemberPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :param channel_sid: The channel_sid :returns: twilio.rest.chat.v1.service.channel.member.MemberPage :rtype: twilio.rest.chat.v1.service.channel.member.MemberPage """ super(MemberPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of MemberInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v1.service.channel.member.MemberInstance :rtype: twilio.rest.chat.v1.service.channel.member.MemberInstance """ return MemberInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class MemberContext(InstanceContext): """ """ def __init__(self, version, service_sid, channel_sid, sid): """ Initialize the MemberContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param channel_sid: The channel_sid :param sid: The sid :returns: twilio.rest.chat.v1.service.channel.member.MemberContext :rtype: twilio.rest.chat.v1.service.channel.member.MemberContext """ super(MemberContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'channel_sid': channel_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Channels/{channel_sid}/Members/{sid}'.format(**self._solution) def fetch(self): """ Fetch a MemberInstance :returns: Fetched MemberInstance :rtype: twilio.rest.chat.v1.service.channel.member.MemberInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return MemberInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the MemberInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, role_sid=values.unset, last_consumed_message_index=values.unset): """ Update the MemberInstance :param unicode role_sid: The role_sid :param unicode last_consumed_message_index: The last_consumed_message_index :returns: Updated MemberInstance :rtype: twilio.rest.chat.v1.service.channel.member.MemberInstance """ data = values.of({'RoleSid': role_sid, 'LastConsumedMessageIndex': last_consumed_message_index,}) payload = self._version.update( 'POST', self._uri, data=data, ) return MemberInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class MemberInstance(InstanceResource): """ """ def __init__(self, version, payload, service_sid, channel_sid, sid=None): """ Initialize the MemberInstance :returns: twilio.rest.chat.v1.service.channel.member.MemberInstance :rtype: twilio.rest.chat.v1.service.channel.member.MemberInstance """ super(MemberInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'channel_sid': payload['channel_sid'], 'service_sid': payload['service_sid'], 'identity': payload['identity'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'role_sid': payload['role_sid'], 'last_consumed_message_index': deserialize.integer(payload['last_consumed_message_index']), 'last_consumption_timestamp': deserialize.iso8601_datetime(payload['last_consumption_timestamp']), 'url': payload['url'], } # Context self._context = None self._solution = { 'service_sid': service_sid, 'channel_sid': channel_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: MemberContext for this MemberInstance :rtype: twilio.rest.chat.v1.service.channel.member.MemberContext """ if self._context is None: self._context = MemberContext( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def channel_sid(self): """ :returns: The channel_sid :rtype: unicode """ return self._properties['channel_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def identity(self): """ :returns: The identity :rtype: unicode """ return self._properties['identity'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def role_sid(self): """ :returns: The role_sid :rtype: unicode """ return self._properties['role_sid'] @property def last_consumed_message_index(self): """ :returns: The last_consumed_message_index :rtype: unicode """ return self._properties['last_consumed_message_index'] @property def last_consumption_timestamp(self): """ :returns: The last_consumption_timestamp :rtype: datetime """ return self._properties['last_consumption_timestamp'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a MemberInstance :returns: Fetched MemberInstance :rtype: twilio.rest.chat.v1.service.channel.member.MemberInstance """ return self._proxy.fetch() def delete(self): """ Deletes the MemberInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, role_sid=values.unset, last_consumed_message_index=values.unset): """ Update the MemberInstance :param unicode role_sid: The role_sid :param unicode last_consumed_message_index: The last_consumed_message_index :returns: Updated MemberInstance :rtype: twilio.rest.chat.v1.service.channel.member.MemberInstance """ return self._proxy.update(role_sid=role_sid, last_consumed_message_index=last_consumed_message_index,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/ip_messaging/v1/service/channel/message.py000066400000000000000000000400771317472742600267270ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class MessageList(ListResource): """ """ def __init__(self, version, service_sid, channel_sid): """ Initialize the MessageList :param Version version: Version that contains the resource :param service_sid: The service_sid :param channel_sid: The channel_sid :returns: twilio.rest.chat.v1.service.channel.message.MessageList :rtype: twilio.rest.chat.v1.service.channel.message.MessageList """ super(MessageList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'channel_sid': channel_sid,} self._uri = '/Services/{service_sid}/Channels/{channel_sid}/Messages'.format(**self._solution) def create(self, body, from_=values.unset, attributes=values.unset): """ Create a new MessageInstance :param unicode body: The body :param unicode from_: The from :param unicode attributes: The attributes :returns: Newly created MessageInstance :rtype: twilio.rest.chat.v1.service.channel.message.MessageInstance """ data = values.of({'Body': body, 'From': from_, 'Attributes': attributes,}) payload = self._version.create( 'POST', self._uri, data=data, ) return MessageInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], ) def stream(self, order=values.unset, limit=None, page_size=None): """ 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 MessageInstance.OrderType order: The order :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v1.service.channel.message.MessageInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(order=order, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, order=values.unset, limit=None, page_size=None): """ 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 MessageInstance.OrderType order: The order :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v1.service.channel.message.MessageInstance] """ return list(self.stream(order=order, limit=limit, page_size=page_size,)) def page(self, order=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of MessageInstance records from the API. Request is executed immediately :param MessageInstance.OrderType order: The order :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of MessageInstance :rtype: twilio.rest.chat.v1.service.channel.message.MessagePage """ params = values.of({ 'Order': order, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return MessagePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of MessageInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of MessageInstance :rtype: twilio.rest.chat.v1.service.channel.message.MessagePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return MessagePage(self._version, response, self._solution) def get(self, sid): """ Constructs a MessageContext :param sid: The sid :returns: twilio.rest.chat.v1.service.channel.message.MessageContext :rtype: twilio.rest.chat.v1.service.channel.message.MessageContext """ return MessageContext( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a MessageContext :param sid: The sid :returns: twilio.rest.chat.v1.service.channel.message.MessageContext :rtype: twilio.rest.chat.v1.service.channel.message.MessageContext """ return MessageContext( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class MessagePage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the MessagePage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :param channel_sid: The channel_sid :returns: twilio.rest.chat.v1.service.channel.message.MessagePage :rtype: twilio.rest.chat.v1.service.channel.message.MessagePage """ super(MessagePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of MessageInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v1.service.channel.message.MessageInstance :rtype: twilio.rest.chat.v1.service.channel.message.MessageInstance """ return MessageInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class MessageContext(InstanceContext): """ """ def __init__(self, version, service_sid, channel_sid, sid): """ Initialize the MessageContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param channel_sid: The channel_sid :param sid: The sid :returns: twilio.rest.chat.v1.service.channel.message.MessageContext :rtype: twilio.rest.chat.v1.service.channel.message.MessageContext """ super(MessageContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'channel_sid': channel_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Channels/{channel_sid}/Messages/{sid}'.format(**self._solution) def fetch(self): """ Fetch a MessageInstance :returns: Fetched MessageInstance :rtype: twilio.rest.chat.v1.service.channel.message.MessageInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return MessageInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the MessageInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, body=values.unset, attributes=values.unset): """ Update the MessageInstance :param unicode body: The body :param unicode attributes: The attributes :returns: Updated MessageInstance :rtype: twilio.rest.chat.v1.service.channel.message.MessageInstance """ data = values.of({'Body': body, 'Attributes': attributes,}) payload = self._version.update( 'POST', self._uri, data=data, ) return MessageInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class MessageInstance(InstanceResource): """ """ class OrderType(object): ASC = "asc" DESC = "desc" def __init__(self, version, payload, service_sid, channel_sid, sid=None): """ Initialize the MessageInstance :returns: twilio.rest.chat.v1.service.channel.message.MessageInstance :rtype: twilio.rest.chat.v1.service.channel.message.MessageInstance """ super(MessageInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'attributes': payload['attributes'], 'service_sid': payload['service_sid'], 'to': payload['to'], 'channel_sid': payload['channel_sid'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'was_edited': payload['was_edited'], 'from_': payload['from'], 'body': payload['body'], 'index': deserialize.integer(payload['index']), 'url': payload['url'], } # Context self._context = None self._solution = { 'service_sid': service_sid, 'channel_sid': channel_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: MessageContext for this MessageInstance :rtype: twilio.rest.chat.v1.service.channel.message.MessageContext """ if self._context is None: self._context = MessageContext( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def attributes(self): """ :returns: The attributes :rtype: unicode """ return self._properties['attributes'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def to(self): """ :returns: The to :rtype: unicode """ return self._properties['to'] @property def channel_sid(self): """ :returns: The channel_sid :rtype: unicode """ return self._properties['channel_sid'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def was_edited(self): """ :returns: The was_edited :rtype: bool """ return self._properties['was_edited'] @property def from_(self): """ :returns: The from :rtype: unicode """ return self._properties['from_'] @property def body(self): """ :returns: The body :rtype: unicode """ return self._properties['body'] @property def index(self): """ :returns: The index :rtype: unicode """ return self._properties['index'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a MessageInstance :returns: Fetched MessageInstance :rtype: twilio.rest.chat.v1.service.channel.message.MessageInstance """ return self._proxy.fetch() def delete(self): """ Deletes the MessageInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, body=values.unset, attributes=values.unset): """ Update the MessageInstance :param unicode body: The body :param unicode attributes: The attributes :returns: Updated MessageInstance :rtype: twilio.rest.chat.v1.service.channel.message.MessageInstance """ return self._proxy.update(body=body, attributes=attributes,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/ip_messaging/v1/service/role.py000066400000000000000000000327661317472742600246420ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class RoleList(ListResource): """ """ def __init__(self, version, service_sid): """ Initialize the RoleList :param Version version: Version that contains the resource :param service_sid: The service_sid :returns: twilio.rest.chat.v1.service.role.RoleList :rtype: twilio.rest.chat.v1.service.role.RoleList """ super(RoleList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid,} self._uri = '/Services/{service_sid}/Roles'.format(**self._solution) def create(self, friendly_name, type, permission): """ Create a new RoleInstance :param unicode friendly_name: The friendly_name :param RoleInstance.RoleType type: The type :param unicode permission: The permission :returns: Newly created RoleInstance :rtype: twilio.rest.chat.v1.service.role.RoleInstance """ data = values.of({'FriendlyName': friendly_name, 'Type': type, 'Permission': permission,}) payload = self._version.create( 'POST', self._uri, data=data, ) return RoleInstance(self._version, payload, service_sid=self._solution['service_sid'],) def stream(self, limit=None, page_size=None): """ Streams RoleInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v1.service.role.RoleInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists RoleInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v1.service.role.RoleInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of RoleInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of RoleInstance :rtype: twilio.rest.chat.v1.service.role.RolePage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return RolePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of RoleInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of RoleInstance :rtype: twilio.rest.chat.v1.service.role.RolePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return RolePage(self._version, response, self._solution) def get(self, sid): """ Constructs a RoleContext :param sid: The sid :returns: twilio.rest.chat.v1.service.role.RoleContext :rtype: twilio.rest.chat.v1.service.role.RoleContext """ return RoleContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __call__(self, sid): """ Constructs a RoleContext :param sid: The sid :returns: twilio.rest.chat.v1.service.role.RoleContext :rtype: twilio.rest.chat.v1.service.role.RoleContext """ return RoleContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class RolePage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the RolePage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :returns: twilio.rest.chat.v1.service.role.RolePage :rtype: twilio.rest.chat.v1.service.role.RolePage """ super(RolePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of RoleInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v1.service.role.RoleInstance :rtype: twilio.rest.chat.v1.service.role.RoleInstance """ return RoleInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class RoleContext(InstanceContext): """ """ def __init__(self, version, service_sid, sid): """ Initialize the RoleContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param sid: The sid :returns: twilio.rest.chat.v1.service.role.RoleContext :rtype: twilio.rest.chat.v1.service.role.RoleContext """ super(RoleContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Roles/{sid}'.format(**self._solution) def fetch(self): """ Fetch a RoleInstance :returns: Fetched RoleInstance :rtype: twilio.rest.chat.v1.service.role.RoleInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return RoleInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the RoleInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, permission): """ Update the RoleInstance :param unicode permission: The permission :returns: Updated RoleInstance :rtype: twilio.rest.chat.v1.service.role.RoleInstance """ data = values.of({'Permission': permission,}) payload = self._version.update( 'POST', self._uri, data=data, ) return RoleInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class RoleInstance(InstanceResource): """ """ class RoleType(object): CHANNEL = "channel" DEPLOYMENT = "deployment" def __init__(self, version, payload, service_sid, sid=None): """ Initialize the RoleInstance :returns: twilio.rest.chat.v1.service.role.RoleInstance :rtype: twilio.rest.chat.v1.service.role.RoleInstance """ super(RoleInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'friendly_name': payload['friendly_name'], 'type': payload['type'], 'permissions': payload['permissions'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'url': payload['url'], } # Context self._context = None self._solution = {'service_sid': service_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: RoleContext for this RoleInstance :rtype: twilio.rest.chat.v1.service.role.RoleContext """ if self._context is None: self._context = RoleContext( self._version, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def type(self): """ :returns: The type :rtype: RoleInstance.RoleType """ return self._properties['type'] @property def permissions(self): """ :returns: The permissions :rtype: unicode """ return self._properties['permissions'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a RoleInstance :returns: Fetched RoleInstance :rtype: twilio.rest.chat.v1.service.role.RoleInstance """ return self._proxy.fetch() def delete(self): """ Deletes the RoleInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, permission): """ Update the RoleInstance :param unicode permission: The permission :returns: Updated RoleInstance :rtype: twilio.rest.chat.v1.service.role.RoleInstance """ return self._proxy.update(permission,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/ip_messaging/v1/service/user/000077500000000000000000000000001317472742600242675ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/ip_messaging/v1/service/user/__init__.py000066400000000000000000000401641317472742600264050ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.ip_messaging.v1.service.user.user_channel import UserChannelList class UserList(ListResource): """ """ def __init__(self, version, service_sid): """ Initialize the UserList :param Version version: Version that contains the resource :param service_sid: The service_sid :returns: twilio.rest.chat.v1.service.user.UserList :rtype: twilio.rest.chat.v1.service.user.UserList """ super(UserList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid,} self._uri = '/Services/{service_sid}/Users'.format(**self._solution) def create(self, identity, role_sid=values.unset, attributes=values.unset, friendly_name=values.unset): """ Create a new UserInstance :param unicode identity: The identity :param unicode role_sid: The role_sid :param unicode attributes: The attributes :param unicode friendly_name: The friendly_name :returns: Newly created UserInstance :rtype: twilio.rest.chat.v1.service.user.UserInstance """ data = values.of({ 'Identity': identity, 'RoleSid': role_sid, 'Attributes': attributes, 'FriendlyName': friendly_name, }) payload = self._version.create( 'POST', self._uri, data=data, ) return UserInstance(self._version, payload, service_sid=self._solution['service_sid'],) def stream(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v1.service.user.UserInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v1.service.user.UserInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of UserInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of UserInstance :rtype: twilio.rest.chat.v1.service.user.UserPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return UserPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of UserInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of UserInstance :rtype: twilio.rest.chat.v1.service.user.UserPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return UserPage(self._version, response, self._solution) def get(self, sid): """ Constructs a UserContext :param sid: The sid :returns: twilio.rest.chat.v1.service.user.UserContext :rtype: twilio.rest.chat.v1.service.user.UserContext """ return UserContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __call__(self, sid): """ Constructs a UserContext :param sid: The sid :returns: twilio.rest.chat.v1.service.user.UserContext :rtype: twilio.rest.chat.v1.service.user.UserContext """ return UserContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class UserPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the UserPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :returns: twilio.rest.chat.v1.service.user.UserPage :rtype: twilio.rest.chat.v1.service.user.UserPage """ super(UserPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of UserInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v1.service.user.UserInstance :rtype: twilio.rest.chat.v1.service.user.UserInstance """ return UserInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class UserContext(InstanceContext): """ """ def __init__(self, version, service_sid, sid): """ Initialize the UserContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param sid: The sid :returns: twilio.rest.chat.v1.service.user.UserContext :rtype: twilio.rest.chat.v1.service.user.UserContext """ super(UserContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Users/{sid}'.format(**self._solution) # Dependents self._user_channels = None def fetch(self): """ Fetch a UserInstance :returns: Fetched UserInstance :rtype: twilio.rest.chat.v1.service.user.UserInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return UserInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the UserInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, role_sid=values.unset, attributes=values.unset, friendly_name=values.unset): """ Update the UserInstance :param unicode role_sid: The role_sid :param unicode attributes: The attributes :param unicode friendly_name: The friendly_name :returns: Updated UserInstance :rtype: twilio.rest.chat.v1.service.user.UserInstance """ data = values.of({'RoleSid': role_sid, 'Attributes': attributes, 'FriendlyName': friendly_name,}) payload = self._version.update( 'POST', self._uri, data=data, ) return UserInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) @property def user_channels(self): """ Access the user_channels :returns: twilio.rest.chat.v1.service.user.user_channel.UserChannelList :rtype: twilio.rest.chat.v1.service.user.user_channel.UserChannelList """ if self._user_channels is None: self._user_channels = UserChannelList( self._version, service_sid=self._solution['service_sid'], user_sid=self._solution['sid'], ) return self._user_channels def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class UserInstance(InstanceResource): """ """ def __init__(self, version, payload, service_sid, sid=None): """ Initialize the UserInstance :returns: twilio.rest.chat.v1.service.user.UserInstance :rtype: twilio.rest.chat.v1.service.user.UserInstance """ super(UserInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'attributes': payload['attributes'], 'friendly_name': payload['friendly_name'], 'role_sid': payload['role_sid'], 'identity': payload['identity'], 'is_online': payload['is_online'], 'is_notifiable': payload['is_notifiable'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'joined_channels_count': deserialize.integer(payload['joined_channels_count']), 'links': payload['links'], 'url': payload['url'], } # Context self._context = None self._solution = {'service_sid': service_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.chat.v1.service.user.UserContext """ if self._context is None: self._context = UserContext( self._version, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def attributes(self): """ :returns: The attributes :rtype: unicode """ return self._properties['attributes'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def role_sid(self): """ :returns: The role_sid :rtype: unicode """ return self._properties['role_sid'] @property def identity(self): """ :returns: The identity :rtype: unicode """ return self._properties['identity'] @property def is_online(self): """ :returns: The is_online :rtype: bool """ return self._properties['is_online'] @property def is_notifiable(self): """ :returns: The is_notifiable :rtype: bool """ return self._properties['is_notifiable'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def joined_channels_count(self): """ :returns: The joined_channels_count :rtype: unicode """ return self._properties['joined_channels_count'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a UserInstance :returns: Fetched UserInstance :rtype: twilio.rest.chat.v1.service.user.UserInstance """ return self._proxy.fetch() def delete(self): """ Deletes the UserInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, role_sid=values.unset, attributes=values.unset, friendly_name=values.unset): """ Update the UserInstance :param unicode role_sid: The role_sid :param unicode attributes: The attributes :param unicode friendly_name: The friendly_name :returns: Updated UserInstance :rtype: twilio.rest.chat.v1.service.user.UserInstance """ return self._proxy.update(role_sid=role_sid, attributes=attributes, friendly_name=friendly_name,) @property def user_channels(self): """ Access the user_channels :returns: twilio.rest.chat.v1.service.user.user_channel.UserChannelList :rtype: twilio.rest.chat.v1.service.user.user_channel.UserChannelList """ return self._proxy.user_channels def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/ip_messaging/v1/service/user/user_channel.py000066400000000000000000000220741317472742600273140ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class UserChannelList(ListResource): """ """ def __init__(self, version, service_sid, user_sid): """ Initialize the UserChannelList :param Version version: Version that contains the resource :param service_sid: The service_sid :param user_sid: The sid :returns: twilio.rest.chat.v1.service.user.user_channel.UserChannelList :rtype: twilio.rest.chat.v1.service.user.user_channel.UserChannelList """ super(UserChannelList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'user_sid': user_sid,} self._uri = '/Services/{service_sid}/Users/{user_sid}/Channels'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams UserChannelInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v1.service.user.user_channel.UserChannelInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists UserChannelInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v1.service.user.user_channel.UserChannelInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of UserChannelInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of UserChannelInstance :rtype: twilio.rest.chat.v1.service.user.user_channel.UserChannelPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return UserChannelPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of UserChannelInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of UserChannelInstance :rtype: twilio.rest.chat.v1.service.user.user_channel.UserChannelPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return UserChannelPage(self._version, response, self._solution) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class UserChannelPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the UserChannelPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :param user_sid: The sid :returns: twilio.rest.chat.v1.service.user.user_channel.UserChannelPage :rtype: twilio.rest.chat.v1.service.user.user_channel.UserChannelPage """ super(UserChannelPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of UserChannelInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v1.service.user.user_channel.UserChannelInstance :rtype: twilio.rest.chat.v1.service.user.user_channel.UserChannelInstance """ return UserChannelInstance( self._version, payload, service_sid=self._solution['service_sid'], user_sid=self._solution['user_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class UserChannelInstance(InstanceResource): """ """ class ChannelStatus(object): JOINED = "joined" INVITED = "invited" NOT_PARTICIPATING = "not_participating" def __init__(self, version, payload, service_sid, user_sid): """ Initialize the UserChannelInstance :returns: twilio.rest.chat.v1.service.user.user_channel.UserChannelInstance :rtype: twilio.rest.chat.v1.service.user.user_channel.UserChannelInstance """ super(UserChannelInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'channel_sid': payload['channel_sid'], 'member_sid': payload['member_sid'], 'status': payload['status'], 'last_consumed_message_index': deserialize.integer(payload['last_consumed_message_index']), 'unread_messages_count': deserialize.integer(payload['unread_messages_count']), 'links': payload['links'], } # Context self._context = None self._solution = {'service_sid': service_sid, 'user_sid': user_sid,} @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def channel_sid(self): """ :returns: The channel_sid :rtype: unicode """ return self._properties['channel_sid'] @property def member_sid(self): """ :returns: The member_sid :rtype: unicode """ return self._properties['member_sid'] @property def status(self): """ :returns: The status :rtype: UserChannelInstance.ChannelStatus """ return self._properties['status'] @property def last_consumed_message_index(self): """ :returns: The last_consumed_message_index :rtype: unicode """ return self._properties['last_consumed_message_index'] @property def unread_messages_count(self): """ :returns: The unread_messages_count :rtype: unicode """ return self._properties['unread_messages_count'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/ip_messaging/v2/000077500000000000000000000000001317472742600216525ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/ip_messaging/v2/__init__.py000066400000000000000000000024561317472742600237720ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.version import Version from twilio.rest.ip_messaging.v2.credential import CredentialList from twilio.rest.ip_messaging.v2.service import ServiceList class V2(Version): def __init__(self, domain): """ Initialize the V2 version of IpMessaging :returns: V2 version of IpMessaging :rtype: twilio.rest.ip_messaging.v2.V2.V2 """ super(V2, self).__init__(domain) self.version = 'v2' self._credentials = None self._services = None @property def credentials(self): """ :rtype: twilio.rest.chat.v2.credential.CredentialList """ if self._credentials is None: self._credentials = CredentialList(self) return self._credentials @property def services(self): """ :rtype: twilio.rest.chat.v2.service.ServiceList """ if self._services is None: self._services = ServiceList(self) return self._services def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/ip_messaging/v2/credential.py000066400000000000000000000351021317472742600243370ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class CredentialList(ListResource): """ """ def __init__(self, version): """ Initialize the CredentialList :param Version version: Version that contains the resource :returns: twilio.rest.chat.v2.credential.CredentialList :rtype: twilio.rest.chat.v2.credential.CredentialList """ super(CredentialList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/Credentials'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams CredentialInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.credential.CredentialInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists CredentialInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.credential.CredentialInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of CredentialInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of CredentialInstance :rtype: twilio.rest.chat.v2.credential.CredentialPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return CredentialPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of CredentialInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of CredentialInstance :rtype: twilio.rest.chat.v2.credential.CredentialPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return CredentialPage(self._version, response, self._solution) def create(self, type, friendly_name=values.unset, certificate=values.unset, private_key=values.unset, sandbox=values.unset, api_key=values.unset, secret=values.unset): """ Create a new CredentialInstance :param CredentialInstance.PushService type: The type :param unicode friendly_name: The friendly_name :param unicode certificate: The certificate :param unicode private_key: The private_key :param bool sandbox: The sandbox :param unicode api_key: The api_key :param unicode secret: The secret :returns: Newly created CredentialInstance :rtype: twilio.rest.chat.v2.credential.CredentialInstance """ data = values.of({ 'Type': type, 'FriendlyName': friendly_name, 'Certificate': certificate, 'PrivateKey': private_key, 'Sandbox': sandbox, 'ApiKey': api_key, 'Secret': secret, }) payload = self._version.create( 'POST', self._uri, data=data, ) return CredentialInstance(self._version, payload,) def get(self, sid): """ Constructs a CredentialContext :param sid: The sid :returns: twilio.rest.chat.v2.credential.CredentialContext :rtype: twilio.rest.chat.v2.credential.CredentialContext """ return CredentialContext(self._version, sid=sid,) def __call__(self, sid): """ Constructs a CredentialContext :param sid: The sid :returns: twilio.rest.chat.v2.credential.CredentialContext :rtype: twilio.rest.chat.v2.credential.CredentialContext """ return CredentialContext(self._version, sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class CredentialPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the CredentialPage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.chat.v2.credential.CredentialPage :rtype: twilio.rest.chat.v2.credential.CredentialPage """ super(CredentialPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of CredentialInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v2.credential.CredentialInstance :rtype: twilio.rest.chat.v2.credential.CredentialInstance """ return CredentialInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class CredentialContext(InstanceContext): """ """ def __init__(self, version, sid): """ Initialize the CredentialContext :param Version version: Version that contains the resource :param sid: The sid :returns: twilio.rest.chat.v2.credential.CredentialContext :rtype: twilio.rest.chat.v2.credential.CredentialContext """ super(CredentialContext, self).__init__(version) # Path Solution self._solution = {'sid': sid,} self._uri = '/Credentials/{sid}'.format(**self._solution) def fetch(self): """ Fetch a CredentialInstance :returns: Fetched CredentialInstance :rtype: twilio.rest.chat.v2.credential.CredentialInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return CredentialInstance(self._version, payload, sid=self._solution['sid'],) def update(self, friendly_name=values.unset, certificate=values.unset, private_key=values.unset, sandbox=values.unset, api_key=values.unset, secret=values.unset): """ Update the CredentialInstance :param unicode friendly_name: The friendly_name :param unicode certificate: The certificate :param unicode private_key: The private_key :param bool sandbox: The sandbox :param unicode api_key: The api_key :param unicode secret: The secret :returns: Updated CredentialInstance :rtype: twilio.rest.chat.v2.credential.CredentialInstance """ data = values.of({ 'FriendlyName': friendly_name, 'Certificate': certificate, 'PrivateKey': private_key, 'Sandbox': sandbox, 'ApiKey': api_key, 'Secret': secret, }) payload = self._version.update( 'POST', self._uri, data=data, ) return CredentialInstance(self._version, payload, sid=self._solution['sid'],) def delete(self): """ Deletes the CredentialInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class CredentialInstance(InstanceResource): """ """ class PushService(object): GCM = "gcm" APN = "apn" FCM = "fcm" def __init__(self, version, payload, sid=None): """ Initialize the CredentialInstance :returns: twilio.rest.chat.v2.credential.CredentialInstance :rtype: twilio.rest.chat.v2.credential.CredentialInstance """ super(CredentialInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'friendly_name': payload['friendly_name'], 'type': payload['type'], 'sandbox': payload['sandbox'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'url': payload['url'], } # Context self._context = None self._solution = {'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: CredentialContext for this CredentialInstance :rtype: twilio.rest.chat.v2.credential.CredentialContext """ if self._context is None: self._context = CredentialContext(self._version, sid=self._solution['sid'],) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def type(self): """ :returns: The type :rtype: CredentialInstance.PushService """ return self._properties['type'] @property def sandbox(self): """ :returns: The sandbox :rtype: unicode """ return self._properties['sandbox'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a CredentialInstance :returns: Fetched CredentialInstance :rtype: twilio.rest.chat.v2.credential.CredentialInstance """ return self._proxy.fetch() def update(self, friendly_name=values.unset, certificate=values.unset, private_key=values.unset, sandbox=values.unset, api_key=values.unset, secret=values.unset): """ Update the CredentialInstance :param unicode friendly_name: The friendly_name :param unicode certificate: The certificate :param unicode private_key: The private_key :param bool sandbox: The sandbox :param unicode api_key: The api_key :param unicode secret: The secret :returns: Updated CredentialInstance :rtype: twilio.rest.chat.v2.credential.CredentialInstance """ return self._proxy.update( friendly_name=friendly_name, certificate=certificate, private_key=private_key, sandbox=sandbox, api_key=api_key, secret=secret, ) def delete(self): """ Deletes the CredentialInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/ip_messaging/v2/service/000077500000000000000000000000001317472742600233125ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/ip_messaging/v2/service/__init__.py000066400000000000000000000771241317472742600254360ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.ip_messaging.v2.service.binding import BindingList from twilio.rest.ip_messaging.v2.service.channel import ChannelList from twilio.rest.ip_messaging.v2.service.role import RoleList from twilio.rest.ip_messaging.v2.service.user import UserList class ServiceList(ListResource): """ """ def __init__(self, version): """ Initialize the ServiceList :param Version version: Version that contains the resource :returns: twilio.rest.chat.v2.service.ServiceList :rtype: twilio.rest.chat.v2.service.ServiceList """ super(ServiceList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/Services'.format(**self._solution) def create(self, friendly_name): """ Create a new ServiceInstance :param unicode friendly_name: The friendly_name :returns: Newly created ServiceInstance :rtype: twilio.rest.chat.v2.service.ServiceInstance """ data = values.of({'FriendlyName': friendly_name,}) payload = self._version.create( 'POST', self._uri, data=data, ) return ServiceInstance(self._version, payload,) def stream(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.ServiceInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.ServiceInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of ServiceInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of ServiceInstance :rtype: twilio.rest.chat.v2.service.ServicePage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return ServicePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of ServiceInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of ServiceInstance :rtype: twilio.rest.chat.v2.service.ServicePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return ServicePage(self._version, response, self._solution) def get(self, sid): """ Constructs a ServiceContext :param sid: The sid :returns: twilio.rest.chat.v2.service.ServiceContext :rtype: twilio.rest.chat.v2.service.ServiceContext """ return ServiceContext(self._version, sid=sid,) def __call__(self, sid): """ Constructs a ServiceContext :param sid: The sid :returns: twilio.rest.chat.v2.service.ServiceContext :rtype: twilio.rest.chat.v2.service.ServiceContext """ return ServiceContext(self._version, sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ServicePage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the ServicePage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.chat.v2.service.ServicePage :rtype: twilio.rest.chat.v2.service.ServicePage """ super(ServicePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of ServiceInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v2.service.ServiceInstance :rtype: twilio.rest.chat.v2.service.ServiceInstance """ return ServiceInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ServiceContext(InstanceContext): """ """ def __init__(self, version, sid): """ Initialize the ServiceContext :param Version version: Version that contains the resource :param sid: The sid :returns: twilio.rest.chat.v2.service.ServiceContext :rtype: twilio.rest.chat.v2.service.ServiceContext """ super(ServiceContext, self).__init__(version) # Path Solution self._solution = {'sid': sid,} self._uri = '/Services/{sid}'.format(**self._solution) # Dependents self._channels = None self._roles = None self._users = None self._bindings = None def fetch(self): """ Fetch a ServiceInstance :returns: Fetched ServiceInstance :rtype: twilio.rest.chat.v2.service.ServiceInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return ServiceInstance(self._version, payload, sid=self._solution['sid'],) def delete(self): """ Deletes the ServiceInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, friendly_name=values.unset, default_service_role_sid=values.unset, default_channel_role_sid=values.unset, default_channel_creator_role_sid=values.unset, read_status_enabled=values.unset, reachability_enabled=values.unset, typing_indicator_timeout=values.unset, consumption_report_interval=values.unset, notifications_new_message_enabled=values.unset, notifications_new_message_template=values.unset, notifications_new_message_sound=values.unset, notifications_new_message_badge_count_enabled=values.unset, notifications_added_to_channel_enabled=values.unset, notifications_added_to_channel_template=values.unset, notifications_added_to_channel_sound=values.unset, notifications_removed_from_channel_enabled=values.unset, notifications_removed_from_channel_template=values.unset, notifications_removed_from_channel_sound=values.unset, notifications_invited_to_channel_enabled=values.unset, notifications_invited_to_channel_template=values.unset, notifications_invited_to_channel_sound=values.unset, pre_webhook_url=values.unset, post_webhook_url=values.unset, webhook_method=values.unset, webhook_filters=values.unset, limits_channel_members=values.unset, limits_user_channels=values.unset, media_compatibility_message=values.unset, pre_webhook_retry_count=values.unset, post_webhook_retry_count=values.unset): """ Update the ServiceInstance :param unicode friendly_name: The friendly_name :param unicode default_service_role_sid: The default_service_role_sid :param unicode default_channel_role_sid: The default_channel_role_sid :param unicode default_channel_creator_role_sid: The default_channel_creator_role_sid :param bool read_status_enabled: The read_status_enabled :param bool reachability_enabled: The reachability_enabled :param unicode typing_indicator_timeout: The typing_indicator_timeout :param unicode consumption_report_interval: The consumption_report_interval :param bool notifications_new_message_enabled: The notifications.new_message.enabled :param unicode notifications_new_message_template: The notifications.new_message.template :param unicode notifications_new_message_sound: The notifications.new_message.sound :param bool notifications_new_message_badge_count_enabled: The notifications.new_message.badge_count_enabled :param bool notifications_added_to_channel_enabled: The notifications.added_to_channel.enabled :param unicode notifications_added_to_channel_template: The notifications.added_to_channel.template :param unicode notifications_added_to_channel_sound: The notifications.added_to_channel.sound :param bool notifications_removed_from_channel_enabled: The notifications.removed_from_channel.enabled :param unicode notifications_removed_from_channel_template: The notifications.removed_from_channel.template :param unicode notifications_removed_from_channel_sound: The notifications.removed_from_channel.sound :param bool notifications_invited_to_channel_enabled: The notifications.invited_to_channel.enabled :param unicode notifications_invited_to_channel_template: The notifications.invited_to_channel.template :param unicode notifications_invited_to_channel_sound: The notifications.invited_to_channel.sound :param unicode pre_webhook_url: The pre_webhook_url :param unicode post_webhook_url: The post_webhook_url :param unicode webhook_method: The webhook_method :param unicode webhook_filters: The webhook_filters :param unicode limits_channel_members: The limits.channel_members :param unicode limits_user_channels: The limits.user_channels :param unicode media_compatibility_message: The media.compatibility_message :param unicode pre_webhook_retry_count: The pre_webhook_retry_count :param unicode post_webhook_retry_count: The post_webhook_retry_count :returns: Updated ServiceInstance :rtype: twilio.rest.chat.v2.service.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, 'TypingIndicatorTimeout': typing_indicator_timeout, 'ConsumptionReportInterval': consumption_report_interval, 'Notifications.NewMessage.Enabled': 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.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.Template': notifications_removed_from_channel_template, 'Notifications.RemovedFromChannel.Sound': notifications_removed_from_channel_sound, 'Notifications.InvitedToChannel.Enabled': 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, 'PostWebhookUrl': post_webhook_url, 'WebhookMethod': webhook_method, 'WebhookFilters': webhook_filters, 'Limits.ChannelMembers': limits_channel_members, 'Limits.UserChannels': limits_user_channels, 'Media.CompatibilityMessage': media_compatibility_message, 'PreWebhookRetryCount': pre_webhook_retry_count, 'PostWebhookRetryCount': post_webhook_retry_count, }) payload = self._version.update( 'POST', self._uri, data=data, ) return ServiceInstance(self._version, payload, sid=self._solution['sid'],) @property def channels(self): """ Access the channels :returns: twilio.rest.chat.v2.service.channel.ChannelList :rtype: twilio.rest.chat.v2.service.channel.ChannelList """ if self._channels is None: self._channels = ChannelList(self._version, service_sid=self._solution['sid'],) return self._channels @property def roles(self): """ Access the roles :returns: twilio.rest.chat.v2.service.role.RoleList :rtype: twilio.rest.chat.v2.service.role.RoleList """ if self._roles is None: self._roles = RoleList(self._version, service_sid=self._solution['sid'],) return self._roles @property def users(self): """ Access the users :returns: twilio.rest.chat.v2.service.user.UserList :rtype: twilio.rest.chat.v2.service.user.UserList """ if self._users is None: self._users = UserList(self._version, service_sid=self._solution['sid'],) return self._users @property def bindings(self): """ Access the bindings :returns: twilio.rest.chat.v2.service.binding.BindingList :rtype: twilio.rest.chat.v2.service.binding.BindingList """ if self._bindings is None: self._bindings = BindingList(self._version, service_sid=self._solution['sid'],) return self._bindings def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class ServiceInstance(InstanceResource): """ """ def __init__(self, version, payload, sid=None): """ Initialize the ServiceInstance :returns: twilio.rest.chat.v2.service.ServiceInstance :rtype: twilio.rest.chat.v2.service.ServiceInstance """ super(ServiceInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'friendly_name': payload['friendly_name'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'default_service_role_sid': payload['default_service_role_sid'], 'default_channel_role_sid': payload['default_channel_role_sid'], 'default_channel_creator_role_sid': payload['default_channel_creator_role_sid'], 'read_status_enabled': payload['read_status_enabled'], 'reachability_enabled': payload['reachability_enabled'], 'typing_indicator_timeout': deserialize.integer(payload['typing_indicator_timeout']), 'consumption_report_interval': deserialize.integer(payload['consumption_report_interval']), 'limits': payload['limits'], 'pre_webhook_url': payload['pre_webhook_url'], 'post_webhook_url': payload['post_webhook_url'], 'webhook_method': payload['webhook_method'], 'webhook_filters': payload['webhook_filters'], 'pre_webhook_retry_count': deserialize.integer(payload['pre_webhook_retry_count']), 'post_webhook_retry_count': deserialize.integer(payload['post_webhook_retry_count']), 'notifications': payload['notifications'], 'media': payload['media'], 'url': payload['url'], 'links': payload['links'], } # Context self._context = None self._solution = {'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.chat.v2.service.ServiceContext """ if self._context is None: self._context = ServiceContext(self._version, sid=self._solution['sid'],) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def default_service_role_sid(self): """ :returns: The default_service_role_sid :rtype: unicode """ return self._properties['default_service_role_sid'] @property def default_channel_role_sid(self): """ :returns: The default_channel_role_sid :rtype: unicode """ return self._properties['default_channel_role_sid'] @property def default_channel_creator_role_sid(self): """ :returns: The default_channel_creator_role_sid :rtype: unicode """ return self._properties['default_channel_creator_role_sid'] @property def read_status_enabled(self): """ :returns: The read_status_enabled :rtype: bool """ return self._properties['read_status_enabled'] @property def reachability_enabled(self): """ :returns: The reachability_enabled :rtype: bool """ return self._properties['reachability_enabled'] @property def typing_indicator_timeout(self): """ :returns: The typing_indicator_timeout :rtype: unicode """ return self._properties['typing_indicator_timeout'] @property def consumption_report_interval(self): """ :returns: The consumption_report_interval :rtype: unicode """ return self._properties['consumption_report_interval'] @property def limits(self): """ :returns: The limits :rtype: dict """ return self._properties['limits'] @property def pre_webhook_url(self): """ :returns: The pre_webhook_url :rtype: unicode """ return self._properties['pre_webhook_url'] @property def post_webhook_url(self): """ :returns: The post_webhook_url :rtype: unicode """ return self._properties['post_webhook_url'] @property def webhook_method(self): """ :returns: The webhook_method :rtype: unicode """ return self._properties['webhook_method'] @property def webhook_filters(self): """ :returns: The webhook_filters :rtype: unicode """ return self._properties['webhook_filters'] @property def pre_webhook_retry_count(self): """ :returns: The pre_webhook_retry_count :rtype: unicode """ return self._properties['pre_webhook_retry_count'] @property def post_webhook_retry_count(self): """ :returns: The post_webhook_retry_count :rtype: unicode """ return self._properties['post_webhook_retry_count'] @property def notifications(self): """ :returns: The notifications :rtype: dict """ return self._properties['notifications'] @property def media(self): """ :returns: The media :rtype: dict """ return self._properties['media'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a ServiceInstance :returns: Fetched ServiceInstance :rtype: twilio.rest.chat.v2.service.ServiceInstance """ return self._proxy.fetch() def delete(self): """ Deletes the ServiceInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, friendly_name=values.unset, default_service_role_sid=values.unset, default_channel_role_sid=values.unset, default_channel_creator_role_sid=values.unset, read_status_enabled=values.unset, reachability_enabled=values.unset, typing_indicator_timeout=values.unset, consumption_report_interval=values.unset, notifications_new_message_enabled=values.unset, notifications_new_message_template=values.unset, notifications_new_message_sound=values.unset, notifications_new_message_badge_count_enabled=values.unset, notifications_added_to_channel_enabled=values.unset, notifications_added_to_channel_template=values.unset, notifications_added_to_channel_sound=values.unset, notifications_removed_from_channel_enabled=values.unset, notifications_removed_from_channel_template=values.unset, notifications_removed_from_channel_sound=values.unset, notifications_invited_to_channel_enabled=values.unset, notifications_invited_to_channel_template=values.unset, notifications_invited_to_channel_sound=values.unset, pre_webhook_url=values.unset, post_webhook_url=values.unset, webhook_method=values.unset, webhook_filters=values.unset, limits_channel_members=values.unset, limits_user_channels=values.unset, media_compatibility_message=values.unset, pre_webhook_retry_count=values.unset, post_webhook_retry_count=values.unset): """ Update the ServiceInstance :param unicode friendly_name: The friendly_name :param unicode default_service_role_sid: The default_service_role_sid :param unicode default_channel_role_sid: The default_channel_role_sid :param unicode default_channel_creator_role_sid: The default_channel_creator_role_sid :param bool read_status_enabled: The read_status_enabled :param bool reachability_enabled: The reachability_enabled :param unicode typing_indicator_timeout: The typing_indicator_timeout :param unicode consumption_report_interval: The consumption_report_interval :param bool notifications_new_message_enabled: The notifications.new_message.enabled :param unicode notifications_new_message_template: The notifications.new_message.template :param unicode notifications_new_message_sound: The notifications.new_message.sound :param bool notifications_new_message_badge_count_enabled: The notifications.new_message.badge_count_enabled :param bool notifications_added_to_channel_enabled: The notifications.added_to_channel.enabled :param unicode notifications_added_to_channel_template: The notifications.added_to_channel.template :param unicode notifications_added_to_channel_sound: The notifications.added_to_channel.sound :param bool notifications_removed_from_channel_enabled: The notifications.removed_from_channel.enabled :param unicode notifications_removed_from_channel_template: The notifications.removed_from_channel.template :param unicode notifications_removed_from_channel_sound: The notifications.removed_from_channel.sound :param bool notifications_invited_to_channel_enabled: The notifications.invited_to_channel.enabled :param unicode notifications_invited_to_channel_template: The notifications.invited_to_channel.template :param unicode notifications_invited_to_channel_sound: The notifications.invited_to_channel.sound :param unicode pre_webhook_url: The pre_webhook_url :param unicode post_webhook_url: The post_webhook_url :param unicode webhook_method: The webhook_method :param unicode webhook_filters: The webhook_filters :param unicode limits_channel_members: The limits.channel_members :param unicode limits_user_channels: The limits.user_channels :param unicode media_compatibility_message: The media.compatibility_message :param unicode pre_webhook_retry_count: The pre_webhook_retry_count :param unicode post_webhook_retry_count: The post_webhook_retry_count :returns: Updated ServiceInstance :rtype: twilio.rest.chat.v2.service.ServiceInstance """ return self._proxy.update( friendly_name=friendly_name, default_service_role_sid=default_service_role_sid, default_channel_role_sid=default_channel_role_sid, default_channel_creator_role_sid=default_channel_creator_role_sid, read_status_enabled=read_status_enabled, reachability_enabled=reachability_enabled, typing_indicator_timeout=typing_indicator_timeout, consumption_report_interval=consumption_report_interval, notifications_new_message_enabled=notifications_new_message_enabled, notifications_new_message_template=notifications_new_message_template, notifications_new_message_sound=notifications_new_message_sound, notifications_new_message_badge_count_enabled=notifications_new_message_badge_count_enabled, notifications_added_to_channel_enabled=notifications_added_to_channel_enabled, notifications_added_to_channel_template=notifications_added_to_channel_template, notifications_added_to_channel_sound=notifications_added_to_channel_sound, notifications_removed_from_channel_enabled=notifications_removed_from_channel_enabled, notifications_removed_from_channel_template=notifications_removed_from_channel_template, notifications_removed_from_channel_sound=notifications_removed_from_channel_sound, notifications_invited_to_channel_enabled=notifications_invited_to_channel_enabled, notifications_invited_to_channel_template=notifications_invited_to_channel_template, notifications_invited_to_channel_sound=notifications_invited_to_channel_sound, pre_webhook_url=pre_webhook_url, post_webhook_url=post_webhook_url, webhook_method=webhook_method, webhook_filters=webhook_filters, limits_channel_members=limits_channel_members, limits_user_channels=limits_user_channels, media_compatibility_message=media_compatibility_message, pre_webhook_retry_count=pre_webhook_retry_count, post_webhook_retry_count=post_webhook_retry_count, ) @property def channels(self): """ Access the channels :returns: twilio.rest.chat.v2.service.channel.ChannelList :rtype: twilio.rest.chat.v2.service.channel.ChannelList """ return self._proxy.channels @property def roles(self): """ Access the roles :returns: twilio.rest.chat.v2.service.role.RoleList :rtype: twilio.rest.chat.v2.service.role.RoleList """ return self._proxy.roles @property def users(self): """ Access the users :returns: twilio.rest.chat.v2.service.user.UserList :rtype: twilio.rest.chat.v2.service.user.UserList """ return self._proxy.users @property def bindings(self): """ Access the bindings :returns: twilio.rest.chat.v2.service.binding.BindingList :rtype: twilio.rest.chat.v2.service.binding.BindingList """ return self._proxy.bindings def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/ip_messaging/v2/service/binding.py000066400000000000000000000332261317472742600253040ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class BindingList(ListResource): """ """ def __init__(self, version, service_sid): """ Initialize the BindingList :param Version version: Version that contains the resource :param service_sid: The service_sid :returns: twilio.rest.chat.v2.service.binding.BindingList :rtype: twilio.rest.chat.v2.service.binding.BindingList """ super(BindingList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid,} self._uri = '/Services/{service_sid}/Bindings'.format(**self._solution) def stream(self, binding_type=values.unset, identity=values.unset, limit=None, page_size=None): """ Streams BindingInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param BindingInstance.BindingType binding_type: The binding_type :param unicode identity: The identity :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.binding.BindingInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(binding_type=binding_type, identity=identity, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, binding_type=values.unset, identity=values.unset, limit=None, page_size=None): """ Lists BindingInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param BindingInstance.BindingType binding_type: The binding_type :param unicode identity: The identity :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.binding.BindingInstance] """ return list(self.stream( binding_type=binding_type, identity=identity, limit=limit, page_size=page_size, )) def page(self, binding_type=values.unset, identity=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of BindingInstance records from the API. Request is executed immediately :param BindingInstance.BindingType binding_type: The binding_type :param unicode identity: The identity :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of BindingInstance :rtype: twilio.rest.chat.v2.service.binding.BindingPage """ params = values.of({ 'BindingType': binding_type, 'Identity': identity, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return BindingPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of BindingInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of BindingInstance :rtype: twilio.rest.chat.v2.service.binding.BindingPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return BindingPage(self._version, response, self._solution) def get(self, sid): """ Constructs a BindingContext :param sid: The sid :returns: twilio.rest.chat.v2.service.binding.BindingContext :rtype: twilio.rest.chat.v2.service.binding.BindingContext """ return BindingContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __call__(self, sid): """ Constructs a BindingContext :param sid: The sid :returns: twilio.rest.chat.v2.service.binding.BindingContext :rtype: twilio.rest.chat.v2.service.binding.BindingContext """ return BindingContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class BindingPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the BindingPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :returns: twilio.rest.chat.v2.service.binding.BindingPage :rtype: twilio.rest.chat.v2.service.binding.BindingPage """ super(BindingPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of BindingInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v2.service.binding.BindingInstance :rtype: twilio.rest.chat.v2.service.binding.BindingInstance """ return BindingInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class BindingContext(InstanceContext): """ """ def __init__(self, version, service_sid, sid): """ Initialize the BindingContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param sid: The sid :returns: twilio.rest.chat.v2.service.binding.BindingContext :rtype: twilio.rest.chat.v2.service.binding.BindingContext """ super(BindingContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Bindings/{sid}'.format(**self._solution) def fetch(self): """ Fetch a BindingInstance :returns: Fetched BindingInstance :rtype: twilio.rest.chat.v2.service.binding.BindingInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return BindingInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the BindingInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class BindingInstance(InstanceResource): """ """ class BindingType(object): GCM = "gcm" APN = "apn" FCM = "fcm" def __init__(self, version, payload, service_sid, sid=None): """ Initialize the BindingInstance :returns: twilio.rest.chat.v2.service.binding.BindingInstance :rtype: twilio.rest.chat.v2.service.binding.BindingInstance """ super(BindingInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'endpoint': payload['endpoint'], 'identity': payload['identity'], 'credential_sid': payload['credential_sid'], 'binding_type': payload['binding_type'], 'message_types': payload['message_types'], 'url': payload['url'], 'links': payload['links'], } # Context self._context = None self._solution = {'service_sid': service_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: BindingContext for this BindingInstance :rtype: twilio.rest.chat.v2.service.binding.BindingContext """ if self._context is None: self._context = BindingContext( self._version, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def endpoint(self): """ :returns: The endpoint :rtype: unicode """ return self._properties['endpoint'] @property def identity(self): """ :returns: The identity :rtype: unicode """ return self._properties['identity'] @property def credential_sid(self): """ :returns: The credential_sid :rtype: unicode """ return self._properties['credential_sid'] @property def binding_type(self): """ :returns: The binding_type :rtype: BindingInstance.BindingType """ return self._properties['binding_type'] @property def message_types(self): """ :returns: The message_types :rtype: unicode """ return self._properties['message_types'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a BindingInstance :returns: Fetched BindingInstance :rtype: twilio.rest.chat.v2.service.binding.BindingInstance """ return self._proxy.fetch() def delete(self): """ Deletes the BindingInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/ip_messaging/v2/service/channel/000077500000000000000000000000001317472742600247225ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/ip_messaging/v2/service/channel/__init__.py000066400000000000000000000474031317472742600270430ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize 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.page import Page from twilio.rest.ip_messaging.v2.service.channel.invite import InviteList from twilio.rest.ip_messaging.v2.service.channel.member import MemberList from twilio.rest.ip_messaging.v2.service.channel.message import MessageList class ChannelList(ListResource): """ """ def __init__(self, version, service_sid): """ Initialize the ChannelList :param Version version: Version that contains the resource :param service_sid: The service_sid :returns: twilio.rest.chat.v2.service.channel.ChannelList :rtype: twilio.rest.chat.v2.service.channel.ChannelList """ super(ChannelList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid,} self._uri = '/Services/{service_sid}/Channels'.format(**self._solution) def create(self, friendly_name=values.unset, unique_name=values.unset, attributes=values.unset, type=values.unset, date_created=values.unset, date_updated=values.unset, created_by=values.unset): """ Create a new ChannelInstance :param unicode friendly_name: The friendly_name :param unicode unique_name: The unique_name :param unicode attributes: The attributes :param ChannelInstance.ChannelType type: The type :param datetime date_created: The date_created :param datetime date_updated: The date_updated :param unicode created_by: The created_by :returns: Newly created ChannelInstance :rtype: twilio.rest.chat.v2.service.channel.ChannelInstance """ data = values.of({ 'FriendlyName': friendly_name, 'UniqueName': unique_name, 'Attributes': attributes, 'Type': type, 'DateCreated': serialize.iso8601_datetime(date_created), 'DateUpdated': serialize.iso8601_datetime(date_updated), 'CreatedBy': created_by, }) payload = self._version.create( 'POST', self._uri, data=data, ) return ChannelInstance(self._version, payload, service_sid=self._solution['service_sid'],) def stream(self, type=values.unset, limit=None, page_size=None): """ Streams ChannelInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param ChannelInstance.ChannelType type: The type :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.channel.ChannelInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(type=type, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, type=values.unset, limit=None, page_size=None): """ Lists ChannelInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param ChannelInstance.ChannelType type: The type :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.channel.ChannelInstance] """ return list(self.stream(type=type, limit=limit, page_size=page_size,)) def page(self, type=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of ChannelInstance records from the API. Request is executed immediately :param ChannelInstance.ChannelType type: The type :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of ChannelInstance :rtype: twilio.rest.chat.v2.service.channel.ChannelPage """ params = values.of({'Type': type, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return ChannelPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of ChannelInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of ChannelInstance :rtype: twilio.rest.chat.v2.service.channel.ChannelPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return ChannelPage(self._version, response, self._solution) def get(self, sid): """ Constructs a ChannelContext :param sid: The sid :returns: twilio.rest.chat.v2.service.channel.ChannelContext :rtype: twilio.rest.chat.v2.service.channel.ChannelContext """ return ChannelContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __call__(self, sid): """ Constructs a ChannelContext :param sid: The sid :returns: twilio.rest.chat.v2.service.channel.ChannelContext :rtype: twilio.rest.chat.v2.service.channel.ChannelContext """ return ChannelContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ChannelPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the ChannelPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :returns: twilio.rest.chat.v2.service.channel.ChannelPage :rtype: twilio.rest.chat.v2.service.channel.ChannelPage """ super(ChannelPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of ChannelInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v2.service.channel.ChannelInstance :rtype: twilio.rest.chat.v2.service.channel.ChannelInstance """ return ChannelInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ChannelContext(InstanceContext): """ """ def __init__(self, version, service_sid, sid): """ Initialize the ChannelContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param sid: The sid :returns: twilio.rest.chat.v2.service.channel.ChannelContext :rtype: twilio.rest.chat.v2.service.channel.ChannelContext """ super(ChannelContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Channels/{sid}'.format(**self._solution) # Dependents self._members = None self._messages = None self._invites = None def fetch(self): """ Fetch a ChannelInstance :returns: Fetched ChannelInstance :rtype: twilio.rest.chat.v2.service.channel.ChannelInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return ChannelInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the ChannelInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, friendly_name=values.unset, unique_name=values.unset, attributes=values.unset, date_created=values.unset, date_updated=values.unset, created_by=values.unset): """ Update the ChannelInstance :param unicode friendly_name: The friendly_name :param unicode unique_name: The unique_name :param unicode attributes: The attributes :param datetime date_created: The date_created :param datetime date_updated: The date_updated :param unicode created_by: The created_by :returns: Updated ChannelInstance :rtype: twilio.rest.chat.v2.service.channel.ChannelInstance """ data = values.of({ 'FriendlyName': friendly_name, 'UniqueName': unique_name, 'Attributes': attributes, 'DateCreated': serialize.iso8601_datetime(date_created), 'DateUpdated': serialize.iso8601_datetime(date_updated), 'CreatedBy': created_by, }) payload = self._version.update( 'POST', self._uri, data=data, ) return ChannelInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) @property def members(self): """ Access the members :returns: twilio.rest.chat.v2.service.channel.member.MemberList :rtype: twilio.rest.chat.v2.service.channel.member.MemberList """ if self._members is None: self._members = MemberList( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['sid'], ) return self._members @property def messages(self): """ Access the messages :returns: twilio.rest.chat.v2.service.channel.message.MessageList :rtype: twilio.rest.chat.v2.service.channel.message.MessageList """ if self._messages is None: self._messages = MessageList( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['sid'], ) return self._messages @property def invites(self): """ Access the invites :returns: twilio.rest.chat.v2.service.channel.invite.InviteList :rtype: twilio.rest.chat.v2.service.channel.invite.InviteList """ if self._invites is None: self._invites = InviteList( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['sid'], ) return self._invites def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class ChannelInstance(InstanceResource): """ """ class ChannelType(object): PUBLIC = "public" PRIVATE = "private" def __init__(self, version, payload, service_sid, sid=None): """ Initialize the ChannelInstance :returns: twilio.rest.chat.v2.service.channel.ChannelInstance :rtype: twilio.rest.chat.v2.service.channel.ChannelInstance """ super(ChannelInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'friendly_name': payload['friendly_name'], 'unique_name': payload['unique_name'], 'attributes': payload['attributes'], 'type': payload['type'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'created_by': payload['created_by'], 'members_count': deserialize.integer(payload['members_count']), 'messages_count': deserialize.integer(payload['messages_count']), 'url': payload['url'], 'links': payload['links'], } # Context self._context = None self._solution = {'service_sid': service_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: ChannelContext for this ChannelInstance :rtype: twilio.rest.chat.v2.service.channel.ChannelContext """ if self._context is None: self._context = ChannelContext( self._version, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def unique_name(self): """ :returns: The unique_name :rtype: unicode """ return self._properties['unique_name'] @property def attributes(self): """ :returns: The attributes :rtype: unicode """ return self._properties['attributes'] @property def type(self): """ :returns: The type :rtype: ChannelInstance.ChannelType """ return self._properties['type'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def created_by(self): """ :returns: The created_by :rtype: unicode """ return self._properties['created_by'] @property def members_count(self): """ :returns: The members_count :rtype: unicode """ return self._properties['members_count'] @property def messages_count(self): """ :returns: The messages_count :rtype: unicode """ return self._properties['messages_count'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a ChannelInstance :returns: Fetched ChannelInstance :rtype: twilio.rest.chat.v2.service.channel.ChannelInstance """ return self._proxy.fetch() def delete(self): """ Deletes the ChannelInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, friendly_name=values.unset, unique_name=values.unset, attributes=values.unset, date_created=values.unset, date_updated=values.unset, created_by=values.unset): """ Update the ChannelInstance :param unicode friendly_name: The friendly_name :param unicode unique_name: The unique_name :param unicode attributes: The attributes :param datetime date_created: The date_created :param datetime date_updated: The date_updated :param unicode created_by: The created_by :returns: Updated ChannelInstance :rtype: twilio.rest.chat.v2.service.channel.ChannelInstance """ return self._proxy.update( friendly_name=friendly_name, unique_name=unique_name, attributes=attributes, date_created=date_created, date_updated=date_updated, created_by=created_by, ) @property def members(self): """ Access the members :returns: twilio.rest.chat.v2.service.channel.member.MemberList :rtype: twilio.rest.chat.v2.service.channel.member.MemberList """ return self._proxy.members @property def messages(self): """ Access the messages :returns: twilio.rest.chat.v2.service.channel.message.MessageList :rtype: twilio.rest.chat.v2.service.channel.message.MessageList """ return self._proxy.messages @property def invites(self): """ Access the invites :returns: twilio.rest.chat.v2.service.channel.invite.InviteList :rtype: twilio.rest.chat.v2.service.channel.invite.InviteList """ return self._proxy.invites def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/ip_messaging/v2/service/channel/invite.py000066400000000000000000000342231317472742600265760ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class InviteList(ListResource): """ """ def __init__(self, version, service_sid, channel_sid): """ Initialize the InviteList :param Version version: Version that contains the resource :param service_sid: The service_sid :param channel_sid: The channel_sid :returns: twilio.rest.chat.v2.service.channel.invite.InviteList :rtype: twilio.rest.chat.v2.service.channel.invite.InviteList """ super(InviteList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'channel_sid': channel_sid,} self._uri = '/Services/{service_sid}/Channels/{channel_sid}/Invites'.format(**self._solution) def create(self, identity, role_sid=values.unset): """ Create a new InviteInstance :param unicode identity: The identity :param unicode role_sid: The role_sid :returns: Newly created InviteInstance :rtype: twilio.rest.chat.v2.service.channel.invite.InviteInstance """ data = values.of({'Identity': identity, 'RoleSid': role_sid,}) payload = self._version.create( 'POST', self._uri, data=data, ) return InviteInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], ) def stream(self, identity=values.unset, limit=None, page_size=None): """ Streams InviteInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param unicode identity: The identity :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.channel.invite.InviteInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(identity=identity, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, identity=values.unset, limit=None, page_size=None): """ Lists InviteInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param unicode identity: The identity :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.channel.invite.InviteInstance] """ return list(self.stream(identity=identity, limit=limit, page_size=page_size,)) def page(self, identity=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of InviteInstance records from the API. Request is executed immediately :param unicode identity: The identity :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of InviteInstance :rtype: twilio.rest.chat.v2.service.channel.invite.InvitePage """ params = values.of({ 'Identity': identity, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return InvitePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of InviteInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of InviteInstance :rtype: twilio.rest.chat.v2.service.channel.invite.InvitePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return InvitePage(self._version, response, self._solution) def get(self, sid): """ Constructs a InviteContext :param sid: The sid :returns: twilio.rest.chat.v2.service.channel.invite.InviteContext :rtype: twilio.rest.chat.v2.service.channel.invite.InviteContext """ return InviteContext( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a InviteContext :param sid: The sid :returns: twilio.rest.chat.v2.service.channel.invite.InviteContext :rtype: twilio.rest.chat.v2.service.channel.invite.InviteContext """ return InviteContext( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class InvitePage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the InvitePage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :param channel_sid: The channel_sid :returns: twilio.rest.chat.v2.service.channel.invite.InvitePage :rtype: twilio.rest.chat.v2.service.channel.invite.InvitePage """ super(InvitePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of InviteInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v2.service.channel.invite.InviteInstance :rtype: twilio.rest.chat.v2.service.channel.invite.InviteInstance """ return InviteInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class InviteContext(InstanceContext): """ """ def __init__(self, version, service_sid, channel_sid, sid): """ Initialize the InviteContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param channel_sid: The channel_sid :param sid: The sid :returns: twilio.rest.chat.v2.service.channel.invite.InviteContext :rtype: twilio.rest.chat.v2.service.channel.invite.InviteContext """ super(InviteContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'channel_sid': channel_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Channels/{channel_sid}/Invites/{sid}'.format(**self._solution) def fetch(self): """ Fetch a InviteInstance :returns: Fetched InviteInstance :rtype: twilio.rest.chat.v2.service.channel.invite.InviteInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return InviteInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the InviteInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class InviteInstance(InstanceResource): """ """ def __init__(self, version, payload, service_sid, channel_sid, sid=None): """ Initialize the InviteInstance :returns: twilio.rest.chat.v2.service.channel.invite.InviteInstance :rtype: twilio.rest.chat.v2.service.channel.invite.InviteInstance """ super(InviteInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'channel_sid': payload['channel_sid'], 'service_sid': payload['service_sid'], 'identity': payload['identity'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'role_sid': payload['role_sid'], 'created_by': payload['created_by'], 'url': payload['url'], } # Context self._context = None self._solution = { 'service_sid': service_sid, 'channel_sid': channel_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: InviteContext for this InviteInstance :rtype: twilio.rest.chat.v2.service.channel.invite.InviteContext """ if self._context is None: self._context = InviteContext( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def channel_sid(self): """ :returns: The channel_sid :rtype: unicode """ return self._properties['channel_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def identity(self): """ :returns: The identity :rtype: unicode """ return self._properties['identity'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def role_sid(self): """ :returns: The role_sid :rtype: unicode """ return self._properties['role_sid'] @property def created_by(self): """ :returns: The created_by :rtype: unicode """ return self._properties['created_by'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a InviteInstance :returns: Fetched InviteInstance :rtype: twilio.rest.chat.v2.service.channel.invite.InviteInstance """ return self._proxy.fetch() def delete(self): """ Deletes the InviteInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/ip_messaging/v2/service/channel/member.py000066400000000000000000000434531317472742600265540ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize 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.page import Page class MemberList(ListResource): """ """ def __init__(self, version, service_sid, channel_sid): """ Initialize the MemberList :param Version version: Version that contains the resource :param service_sid: The service_sid :param channel_sid: The channel_sid :returns: twilio.rest.chat.v2.service.channel.member.MemberList :rtype: twilio.rest.chat.v2.service.channel.member.MemberList """ super(MemberList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'channel_sid': channel_sid,} self._uri = '/Services/{service_sid}/Channels/{channel_sid}/Members'.format(**self._solution) def create(self, identity, role_sid=values.unset, last_consumed_message_index=values.unset, last_consumption_timestamp=values.unset, date_created=values.unset, date_updated=values.unset): """ Create a new MemberInstance :param unicode identity: The identity :param unicode role_sid: The role_sid :param unicode last_consumed_message_index: The last_consumed_message_index :param datetime last_consumption_timestamp: The last_consumption_timestamp :param datetime date_created: The date_created :param datetime date_updated: The date_updated :returns: Newly created MemberInstance :rtype: twilio.rest.chat.v2.service.channel.member.MemberInstance """ data = values.of({ 'Identity': identity, 'RoleSid': role_sid, 'LastConsumedMessageIndex': last_consumed_message_index, 'LastConsumptionTimestamp': serialize.iso8601_datetime(last_consumption_timestamp), 'DateCreated': serialize.iso8601_datetime(date_created), 'DateUpdated': serialize.iso8601_datetime(date_updated), }) payload = self._version.create( 'POST', self._uri, data=data, ) return MemberInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], ) def stream(self, identity=values.unset, limit=None, page_size=None): """ Streams MemberInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param unicode identity: The identity :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.channel.member.MemberInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(identity=identity, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, identity=values.unset, limit=None, page_size=None): """ Lists MemberInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param unicode identity: The identity :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.channel.member.MemberInstance] """ return list(self.stream(identity=identity, limit=limit, page_size=page_size,)) def page(self, identity=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of MemberInstance records from the API. Request is executed immediately :param unicode identity: The identity :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of MemberInstance :rtype: twilio.rest.chat.v2.service.channel.member.MemberPage """ params = values.of({ 'Identity': identity, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return MemberPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of MemberInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of MemberInstance :rtype: twilio.rest.chat.v2.service.channel.member.MemberPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return MemberPage(self._version, response, self._solution) def get(self, sid): """ Constructs a MemberContext :param sid: The sid :returns: twilio.rest.chat.v2.service.channel.member.MemberContext :rtype: twilio.rest.chat.v2.service.channel.member.MemberContext """ return MemberContext( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a MemberContext :param sid: The sid :returns: twilio.rest.chat.v2.service.channel.member.MemberContext :rtype: twilio.rest.chat.v2.service.channel.member.MemberContext """ return MemberContext( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class MemberPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the MemberPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :param channel_sid: The channel_sid :returns: twilio.rest.chat.v2.service.channel.member.MemberPage :rtype: twilio.rest.chat.v2.service.channel.member.MemberPage """ super(MemberPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of MemberInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v2.service.channel.member.MemberInstance :rtype: twilio.rest.chat.v2.service.channel.member.MemberInstance """ return MemberInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class MemberContext(InstanceContext): """ """ def __init__(self, version, service_sid, channel_sid, sid): """ Initialize the MemberContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param channel_sid: The channel_sid :param sid: The sid :returns: twilio.rest.chat.v2.service.channel.member.MemberContext :rtype: twilio.rest.chat.v2.service.channel.member.MemberContext """ super(MemberContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'channel_sid': channel_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Channels/{channel_sid}/Members/{sid}'.format(**self._solution) def fetch(self): """ Fetch a MemberInstance :returns: Fetched MemberInstance :rtype: twilio.rest.chat.v2.service.channel.member.MemberInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return MemberInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the MemberInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, role_sid=values.unset, last_consumed_message_index=values.unset, last_consumption_timestamp=values.unset, date_created=values.unset, date_updated=values.unset): """ Update the MemberInstance :param unicode role_sid: The role_sid :param unicode last_consumed_message_index: The last_consumed_message_index :param datetime last_consumption_timestamp: The last_consumption_timestamp :param datetime date_created: The date_created :param datetime date_updated: The date_updated :returns: Updated MemberInstance :rtype: twilio.rest.chat.v2.service.channel.member.MemberInstance """ data = values.of({ 'RoleSid': role_sid, 'LastConsumedMessageIndex': last_consumed_message_index, 'LastConsumptionTimestamp': serialize.iso8601_datetime(last_consumption_timestamp), 'DateCreated': serialize.iso8601_datetime(date_created), 'DateUpdated': serialize.iso8601_datetime(date_updated), }) payload = self._version.update( 'POST', self._uri, data=data, ) return MemberInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class MemberInstance(InstanceResource): """ """ def __init__(self, version, payload, service_sid, channel_sid, sid=None): """ Initialize the MemberInstance :returns: twilio.rest.chat.v2.service.channel.member.MemberInstance :rtype: twilio.rest.chat.v2.service.channel.member.MemberInstance """ super(MemberInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'channel_sid': payload['channel_sid'], 'service_sid': payload['service_sid'], 'identity': payload['identity'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'role_sid': payload['role_sid'], 'last_consumed_message_index': deserialize.integer(payload['last_consumed_message_index']), 'last_consumption_timestamp': deserialize.iso8601_datetime(payload['last_consumption_timestamp']), 'url': payload['url'], } # Context self._context = None self._solution = { 'service_sid': service_sid, 'channel_sid': channel_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: MemberContext for this MemberInstance :rtype: twilio.rest.chat.v2.service.channel.member.MemberContext """ if self._context is None: self._context = MemberContext( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def channel_sid(self): """ :returns: The channel_sid :rtype: unicode """ return self._properties['channel_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def identity(self): """ :returns: The identity :rtype: unicode """ return self._properties['identity'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def role_sid(self): """ :returns: The role_sid :rtype: unicode """ return self._properties['role_sid'] @property def last_consumed_message_index(self): """ :returns: The last_consumed_message_index :rtype: unicode """ return self._properties['last_consumed_message_index'] @property def last_consumption_timestamp(self): """ :returns: The last_consumption_timestamp :rtype: datetime """ return self._properties['last_consumption_timestamp'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a MemberInstance :returns: Fetched MemberInstance :rtype: twilio.rest.chat.v2.service.channel.member.MemberInstance """ return self._proxy.fetch() def delete(self): """ Deletes the MemberInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, role_sid=values.unset, last_consumed_message_index=values.unset, last_consumption_timestamp=values.unset, date_created=values.unset, date_updated=values.unset): """ Update the MemberInstance :param unicode role_sid: The role_sid :param unicode last_consumed_message_index: The last_consumed_message_index :param datetime last_consumption_timestamp: The last_consumption_timestamp :param datetime date_created: The date_created :param datetime date_updated: The date_updated :returns: Updated MemberInstance :rtype: twilio.rest.chat.v2.service.channel.member.MemberInstance """ return self._proxy.update( role_sid=role_sid, last_consumed_message_index=last_consumed_message_index, last_consumption_timestamp=last_consumption_timestamp, date_created=date_created, date_updated=date_updated, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/ip_messaging/v2/service/channel/message.py000066400000000000000000000444031317472742600267250ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize 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.page import Page class MessageList(ListResource): """ """ def __init__(self, version, service_sid, channel_sid): """ Initialize the MessageList :param Version version: Version that contains the resource :param service_sid: The service_sid :param channel_sid: The channel_sid :returns: twilio.rest.chat.v2.service.channel.message.MessageList :rtype: twilio.rest.chat.v2.service.channel.message.MessageList """ super(MessageList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'channel_sid': channel_sid,} self._uri = '/Services/{service_sid}/Channels/{channel_sid}/Messages'.format(**self._solution) def create(self, from_=values.unset, attributes=values.unset, date_created=values.unset, date_updated=values.unset, last_updated_by=values.unset, body=values.unset, media_sid=values.unset): """ Create a new MessageInstance :param unicode from_: The from :param unicode attributes: The attributes :param datetime date_created: The date_created :param datetime date_updated: The date_updated :param unicode last_updated_by: The last_updated_by :param unicode body: The body :param unicode media_sid: The media_sid :returns: Newly created MessageInstance :rtype: twilio.rest.chat.v2.service.channel.message.MessageInstance """ data = values.of({ 'From': from_, 'Attributes': attributes, 'DateCreated': serialize.iso8601_datetime(date_created), 'DateUpdated': serialize.iso8601_datetime(date_updated), 'LastUpdatedBy': last_updated_by, 'Body': body, 'MediaSid': media_sid, }) payload = self._version.create( 'POST', self._uri, data=data, ) return MessageInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], ) def stream(self, order=values.unset, limit=None, page_size=None): """ 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 MessageInstance.OrderType order: The order :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.channel.message.MessageInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(order=order, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, order=values.unset, limit=None, page_size=None): """ 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 MessageInstance.OrderType order: The order :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.channel.message.MessageInstance] """ return list(self.stream(order=order, limit=limit, page_size=page_size,)) def page(self, order=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of MessageInstance records from the API. Request is executed immediately :param MessageInstance.OrderType order: The order :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of MessageInstance :rtype: twilio.rest.chat.v2.service.channel.message.MessagePage """ params = values.of({ 'Order': order, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return MessagePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of MessageInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of MessageInstance :rtype: twilio.rest.chat.v2.service.channel.message.MessagePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return MessagePage(self._version, response, self._solution) def get(self, sid): """ Constructs a MessageContext :param sid: The sid :returns: twilio.rest.chat.v2.service.channel.message.MessageContext :rtype: twilio.rest.chat.v2.service.channel.message.MessageContext """ return MessageContext( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a MessageContext :param sid: The sid :returns: twilio.rest.chat.v2.service.channel.message.MessageContext :rtype: twilio.rest.chat.v2.service.channel.message.MessageContext """ return MessageContext( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class MessagePage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the MessagePage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :param channel_sid: The channel_sid :returns: twilio.rest.chat.v2.service.channel.message.MessagePage :rtype: twilio.rest.chat.v2.service.channel.message.MessagePage """ super(MessagePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of MessageInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v2.service.channel.message.MessageInstance :rtype: twilio.rest.chat.v2.service.channel.message.MessageInstance """ return MessageInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class MessageContext(InstanceContext): """ """ def __init__(self, version, service_sid, channel_sid, sid): """ Initialize the MessageContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param channel_sid: The channel_sid :param sid: The sid :returns: twilio.rest.chat.v2.service.channel.message.MessageContext :rtype: twilio.rest.chat.v2.service.channel.message.MessageContext """ super(MessageContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'channel_sid': channel_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Channels/{channel_sid}/Messages/{sid}'.format(**self._solution) def fetch(self): """ Fetch a MessageInstance :returns: Fetched MessageInstance :rtype: twilio.rest.chat.v2.service.channel.message.MessageInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return MessageInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the MessageInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, body=values.unset, attributes=values.unset, date_created=values.unset, date_updated=values.unset, last_updated_by=values.unset): """ Update the MessageInstance :param unicode body: The body :param unicode attributes: The attributes :param datetime date_created: The date_created :param datetime date_updated: The date_updated :param unicode last_updated_by: The last_updated_by :returns: Updated MessageInstance :rtype: twilio.rest.chat.v2.service.channel.message.MessageInstance """ data = values.of({ 'Body': body, 'Attributes': attributes, 'DateCreated': serialize.iso8601_datetime(date_created), 'DateUpdated': serialize.iso8601_datetime(date_updated), 'LastUpdatedBy': last_updated_by, }) payload = self._version.update( 'POST', self._uri, data=data, ) return MessageInstance( self._version, payload, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class MessageInstance(InstanceResource): """ """ class OrderType(object): ASC = "asc" DESC = "desc" def __init__(self, version, payload, service_sid, channel_sid, sid=None): """ Initialize the MessageInstance :returns: twilio.rest.chat.v2.service.channel.message.MessageInstance :rtype: twilio.rest.chat.v2.service.channel.message.MessageInstance """ super(MessageInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'attributes': payload['attributes'], 'service_sid': payload['service_sid'], 'to': payload['to'], 'channel_sid': payload['channel_sid'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'last_updated_by': payload['last_updated_by'], 'was_edited': payload['was_edited'], 'from_': payload['from'], 'body': payload['body'], 'index': deserialize.integer(payload['index']), 'type': payload['type'], 'media': payload['media'], 'url': payload['url'], } # Context self._context = None self._solution = { 'service_sid': service_sid, 'channel_sid': channel_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: MessageContext for this MessageInstance :rtype: twilio.rest.chat.v2.service.channel.message.MessageContext """ if self._context is None: self._context = MessageContext( self._version, service_sid=self._solution['service_sid'], channel_sid=self._solution['channel_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def attributes(self): """ :returns: The attributes :rtype: unicode """ return self._properties['attributes'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def to(self): """ :returns: The to :rtype: unicode """ return self._properties['to'] @property def channel_sid(self): """ :returns: The channel_sid :rtype: unicode """ return self._properties['channel_sid'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def last_updated_by(self): """ :returns: The last_updated_by :rtype: unicode """ return self._properties['last_updated_by'] @property def was_edited(self): """ :returns: The was_edited :rtype: bool """ return self._properties['was_edited'] @property def from_(self): """ :returns: The from :rtype: unicode """ return self._properties['from_'] @property def body(self): """ :returns: The body :rtype: unicode """ return self._properties['body'] @property def index(self): """ :returns: The index :rtype: unicode """ return self._properties['index'] @property def type(self): """ :returns: The type :rtype: unicode """ return self._properties['type'] @property def media(self): """ :returns: The media :rtype: dict """ return self._properties['media'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a MessageInstance :returns: Fetched MessageInstance :rtype: twilio.rest.chat.v2.service.channel.message.MessageInstance """ return self._proxy.fetch() def delete(self): """ Deletes the MessageInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, body=values.unset, attributes=values.unset, date_created=values.unset, date_updated=values.unset, last_updated_by=values.unset): """ Update the MessageInstance :param unicode body: The body :param unicode attributes: The attributes :param datetime date_created: The date_created :param datetime date_updated: The date_updated :param unicode last_updated_by: The last_updated_by :returns: Updated MessageInstance :rtype: twilio.rest.chat.v2.service.channel.message.MessageInstance """ return self._proxy.update( body=body, attributes=attributes, date_created=date_created, date_updated=date_updated, last_updated_by=last_updated_by, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/ip_messaging/v2/service/role.py000066400000000000000000000327661317472742600246430ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class RoleList(ListResource): """ """ def __init__(self, version, service_sid): """ Initialize the RoleList :param Version version: Version that contains the resource :param service_sid: The service_sid :returns: twilio.rest.chat.v2.service.role.RoleList :rtype: twilio.rest.chat.v2.service.role.RoleList """ super(RoleList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid,} self._uri = '/Services/{service_sid}/Roles'.format(**self._solution) def create(self, friendly_name, type, permission): """ Create a new RoleInstance :param unicode friendly_name: The friendly_name :param RoleInstance.RoleType type: The type :param unicode permission: The permission :returns: Newly created RoleInstance :rtype: twilio.rest.chat.v2.service.role.RoleInstance """ data = values.of({'FriendlyName': friendly_name, 'Type': type, 'Permission': permission,}) payload = self._version.create( 'POST', self._uri, data=data, ) return RoleInstance(self._version, payload, service_sid=self._solution['service_sid'],) def stream(self, limit=None, page_size=None): """ Streams RoleInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.role.RoleInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists RoleInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.role.RoleInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of RoleInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of RoleInstance :rtype: twilio.rest.chat.v2.service.role.RolePage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return RolePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of RoleInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of RoleInstance :rtype: twilio.rest.chat.v2.service.role.RolePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return RolePage(self._version, response, self._solution) def get(self, sid): """ Constructs a RoleContext :param sid: The sid :returns: twilio.rest.chat.v2.service.role.RoleContext :rtype: twilio.rest.chat.v2.service.role.RoleContext """ return RoleContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __call__(self, sid): """ Constructs a RoleContext :param sid: The sid :returns: twilio.rest.chat.v2.service.role.RoleContext :rtype: twilio.rest.chat.v2.service.role.RoleContext """ return RoleContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class RolePage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the RolePage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :returns: twilio.rest.chat.v2.service.role.RolePage :rtype: twilio.rest.chat.v2.service.role.RolePage """ super(RolePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of RoleInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v2.service.role.RoleInstance :rtype: twilio.rest.chat.v2.service.role.RoleInstance """ return RoleInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class RoleContext(InstanceContext): """ """ def __init__(self, version, service_sid, sid): """ Initialize the RoleContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param sid: The sid :returns: twilio.rest.chat.v2.service.role.RoleContext :rtype: twilio.rest.chat.v2.service.role.RoleContext """ super(RoleContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Roles/{sid}'.format(**self._solution) def fetch(self): """ Fetch a RoleInstance :returns: Fetched RoleInstance :rtype: twilio.rest.chat.v2.service.role.RoleInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return RoleInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the RoleInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, permission): """ Update the RoleInstance :param unicode permission: The permission :returns: Updated RoleInstance :rtype: twilio.rest.chat.v2.service.role.RoleInstance """ data = values.of({'Permission': permission,}) payload = self._version.update( 'POST', self._uri, data=data, ) return RoleInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class RoleInstance(InstanceResource): """ """ class RoleType(object): CHANNEL = "channel" DEPLOYMENT = "deployment" def __init__(self, version, payload, service_sid, sid=None): """ Initialize the RoleInstance :returns: twilio.rest.chat.v2.service.role.RoleInstance :rtype: twilio.rest.chat.v2.service.role.RoleInstance """ super(RoleInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'friendly_name': payload['friendly_name'], 'type': payload['type'], 'permissions': payload['permissions'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'url': payload['url'], } # Context self._context = None self._solution = {'service_sid': service_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: RoleContext for this RoleInstance :rtype: twilio.rest.chat.v2.service.role.RoleContext """ if self._context is None: self._context = RoleContext( self._version, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def type(self): """ :returns: The type :rtype: RoleInstance.RoleType """ return self._properties['type'] @property def permissions(self): """ :returns: The permissions :rtype: unicode """ return self._properties['permissions'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a RoleInstance :returns: Fetched RoleInstance :rtype: twilio.rest.chat.v2.service.role.RoleInstance """ return self._proxy.fetch() def delete(self): """ Deletes the RoleInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, permission): """ Update the RoleInstance :param unicode permission: The permission :returns: Updated RoleInstance :rtype: twilio.rest.chat.v2.service.role.RoleInstance """ return self._proxy.update(permission,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/ip_messaging/v2/service/user/000077500000000000000000000000001317472742600242705ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/ip_messaging/v2/service/user/__init__.py000066400000000000000000000420601317472742600264030ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.ip_messaging.v2.service.user.user_binding import UserBindingList from twilio.rest.ip_messaging.v2.service.user.user_channel import UserChannelList class UserList(ListResource): """ """ def __init__(self, version, service_sid): """ Initialize the UserList :param Version version: Version that contains the resource :param service_sid: The service_sid :returns: twilio.rest.chat.v2.service.user.UserList :rtype: twilio.rest.chat.v2.service.user.UserList """ super(UserList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid,} self._uri = '/Services/{service_sid}/Users'.format(**self._solution) def create(self, identity, role_sid=values.unset, attributes=values.unset, friendly_name=values.unset): """ Create a new UserInstance :param unicode identity: The identity :param unicode role_sid: The role_sid :param unicode attributes: The attributes :param unicode friendly_name: The friendly_name :returns: Newly created UserInstance :rtype: twilio.rest.chat.v2.service.user.UserInstance """ data = values.of({ 'Identity': identity, 'RoleSid': role_sid, 'Attributes': attributes, 'FriendlyName': friendly_name, }) payload = self._version.create( 'POST', self._uri, data=data, ) return UserInstance(self._version, payload, service_sid=self._solution['service_sid'],) def stream(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.user.UserInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.user.UserInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of UserInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of UserInstance :rtype: twilio.rest.chat.v2.service.user.UserPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return UserPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of UserInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of UserInstance :rtype: twilio.rest.chat.v2.service.user.UserPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return UserPage(self._version, response, self._solution) def get(self, sid): """ Constructs a UserContext :param sid: The sid :returns: twilio.rest.chat.v2.service.user.UserContext :rtype: twilio.rest.chat.v2.service.user.UserContext """ return UserContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __call__(self, sid): """ Constructs a UserContext :param sid: The sid :returns: twilio.rest.chat.v2.service.user.UserContext :rtype: twilio.rest.chat.v2.service.user.UserContext """ return UserContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class UserPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the UserPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :returns: twilio.rest.chat.v2.service.user.UserPage :rtype: twilio.rest.chat.v2.service.user.UserPage """ super(UserPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of UserInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v2.service.user.UserInstance :rtype: twilio.rest.chat.v2.service.user.UserInstance """ return UserInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class UserContext(InstanceContext): """ """ def __init__(self, version, service_sid, sid): """ Initialize the UserContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param sid: The sid :returns: twilio.rest.chat.v2.service.user.UserContext :rtype: twilio.rest.chat.v2.service.user.UserContext """ super(UserContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Users/{sid}'.format(**self._solution) # Dependents self._user_channels = None self._user_bindings = None def fetch(self): """ Fetch a UserInstance :returns: Fetched UserInstance :rtype: twilio.rest.chat.v2.service.user.UserInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return UserInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the UserInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, role_sid=values.unset, attributes=values.unset, friendly_name=values.unset): """ Update the UserInstance :param unicode role_sid: The role_sid :param unicode attributes: The attributes :param unicode friendly_name: The friendly_name :returns: Updated UserInstance :rtype: twilio.rest.chat.v2.service.user.UserInstance """ data = values.of({'RoleSid': role_sid, 'Attributes': attributes, 'FriendlyName': friendly_name,}) payload = self._version.update( 'POST', self._uri, data=data, ) return UserInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) @property def user_channels(self): """ Access the user_channels :returns: twilio.rest.chat.v2.service.user.user_channel.UserChannelList :rtype: twilio.rest.chat.v2.service.user.user_channel.UserChannelList """ if self._user_channels is None: self._user_channels = UserChannelList( self._version, service_sid=self._solution['service_sid'], user_sid=self._solution['sid'], ) return self._user_channels @property def user_bindings(self): """ Access the user_bindings :returns: twilio.rest.chat.v2.service.user.user_binding.UserBindingList :rtype: twilio.rest.chat.v2.service.user.user_binding.UserBindingList """ if self._user_bindings is None: self._user_bindings = UserBindingList( self._version, service_sid=self._solution['service_sid'], user_sid=self._solution['sid'], ) return self._user_bindings def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class UserInstance(InstanceResource): """ """ def __init__(self, version, payload, service_sid, sid=None): """ Initialize the UserInstance :returns: twilio.rest.chat.v2.service.user.UserInstance :rtype: twilio.rest.chat.v2.service.user.UserInstance """ super(UserInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'attributes': payload['attributes'], 'friendly_name': payload['friendly_name'], 'role_sid': payload['role_sid'], 'identity': payload['identity'], 'is_online': payload['is_online'], 'is_notifiable': payload['is_notifiable'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'joined_channels_count': deserialize.integer(payload['joined_channels_count']), 'links': payload['links'], 'url': payload['url'], } # Context self._context = None self._solution = {'service_sid': service_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.chat.v2.service.user.UserContext """ if self._context is None: self._context = UserContext( self._version, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def attributes(self): """ :returns: The attributes :rtype: unicode """ return self._properties['attributes'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def role_sid(self): """ :returns: The role_sid :rtype: unicode """ return self._properties['role_sid'] @property def identity(self): """ :returns: The identity :rtype: unicode """ return self._properties['identity'] @property def is_online(self): """ :returns: The is_online :rtype: bool """ return self._properties['is_online'] @property def is_notifiable(self): """ :returns: The is_notifiable :rtype: bool """ return self._properties['is_notifiable'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def joined_channels_count(self): """ :returns: The joined_channels_count :rtype: unicode """ return self._properties['joined_channels_count'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a UserInstance :returns: Fetched UserInstance :rtype: twilio.rest.chat.v2.service.user.UserInstance """ return self._proxy.fetch() def delete(self): """ Deletes the UserInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, role_sid=values.unset, attributes=values.unset, friendly_name=values.unset): """ Update the UserInstance :param unicode role_sid: The role_sid :param unicode attributes: The attributes :param unicode friendly_name: The friendly_name :returns: Updated UserInstance :rtype: twilio.rest.chat.v2.service.user.UserInstance """ return self._proxy.update(role_sid=role_sid, attributes=attributes, friendly_name=friendly_name,) @property def user_channels(self): """ Access the user_channels :returns: twilio.rest.chat.v2.service.user.user_channel.UserChannelList :rtype: twilio.rest.chat.v2.service.user.user_channel.UserChannelList """ return self._proxy.user_channels @property def user_bindings(self): """ Access the user_bindings :returns: twilio.rest.chat.v2.service.user.user_binding.UserBindingList :rtype: twilio.rest.chat.v2.service.user.user_binding.UserBindingList """ return self._proxy.user_bindings def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/ip_messaging/v2/service/user/user_binding.py000066400000000000000000000346461317472742600273270ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class UserBindingList(ListResource): """ """ def __init__(self, version, service_sid, user_sid): """ Initialize the UserBindingList :param Version version: Version that contains the resource :param service_sid: The service_sid :param user_sid: The user_sid :returns: twilio.rest.chat.v2.service.user.user_binding.UserBindingList :rtype: twilio.rest.chat.v2.service.user.user_binding.UserBindingList """ super(UserBindingList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'user_sid': user_sid,} self._uri = '/Services/{service_sid}/Users/{user_sid}/Bindings'.format(**self._solution) def stream(self, binding_type=values.unset, limit=None, page_size=None): """ Streams UserBindingInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param UserBindingInstance.BindingType binding_type: The binding_type :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.user.user_binding.UserBindingInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(binding_type=binding_type, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, binding_type=values.unset, limit=None, page_size=None): """ Lists UserBindingInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param UserBindingInstance.BindingType binding_type: The binding_type :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.user.user_binding.UserBindingInstance] """ return list(self.stream(binding_type=binding_type, limit=limit, page_size=page_size,)) def page(self, binding_type=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of UserBindingInstance records from the API. Request is executed immediately :param UserBindingInstance.BindingType binding_type: The binding_type :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of UserBindingInstance :rtype: twilio.rest.chat.v2.service.user.user_binding.UserBindingPage """ params = values.of({ 'BindingType': binding_type, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return UserBindingPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of UserBindingInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of UserBindingInstance :rtype: twilio.rest.chat.v2.service.user.user_binding.UserBindingPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return UserBindingPage(self._version, response, self._solution) def get(self, sid): """ Constructs a UserBindingContext :param sid: The sid :returns: twilio.rest.chat.v2.service.user.user_binding.UserBindingContext :rtype: twilio.rest.chat.v2.service.user.user_binding.UserBindingContext """ return UserBindingContext( self._version, service_sid=self._solution['service_sid'], user_sid=self._solution['user_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a UserBindingContext :param sid: The sid :returns: twilio.rest.chat.v2.service.user.user_binding.UserBindingContext :rtype: twilio.rest.chat.v2.service.user.user_binding.UserBindingContext """ return UserBindingContext( self._version, service_sid=self._solution['service_sid'], user_sid=self._solution['user_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class UserBindingPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the UserBindingPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :param user_sid: The user_sid :returns: twilio.rest.chat.v2.service.user.user_binding.UserBindingPage :rtype: twilio.rest.chat.v2.service.user.user_binding.UserBindingPage """ super(UserBindingPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of UserBindingInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v2.service.user.user_binding.UserBindingInstance :rtype: twilio.rest.chat.v2.service.user.user_binding.UserBindingInstance """ return UserBindingInstance( self._version, payload, service_sid=self._solution['service_sid'], user_sid=self._solution['user_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class UserBindingContext(InstanceContext): """ """ def __init__(self, version, service_sid, user_sid, sid): """ Initialize the UserBindingContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param user_sid: The user_sid :param sid: The sid :returns: twilio.rest.chat.v2.service.user.user_binding.UserBindingContext :rtype: twilio.rest.chat.v2.service.user.user_binding.UserBindingContext """ super(UserBindingContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'user_sid': user_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Users/{user_sid}/Bindings/{sid}'.format(**self._solution) def fetch(self): """ Fetch a UserBindingInstance :returns: Fetched UserBindingInstance :rtype: twilio.rest.chat.v2.service.user.user_binding.UserBindingInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return UserBindingInstance( self._version, payload, service_sid=self._solution['service_sid'], user_sid=self._solution['user_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the UserBindingInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class UserBindingInstance(InstanceResource): """ """ class BindingType(object): GCM = "gcm" APN = "apn" FCM = "fcm" def __init__(self, version, payload, service_sid, user_sid, sid=None): """ Initialize the UserBindingInstance :returns: twilio.rest.chat.v2.service.user.user_binding.UserBindingInstance :rtype: twilio.rest.chat.v2.service.user.user_binding.UserBindingInstance """ super(UserBindingInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'endpoint': payload['endpoint'], 'identity': payload['identity'], 'user_sid': payload['user_sid'], 'credential_sid': payload['credential_sid'], 'binding_type': payload['binding_type'], 'message_types': payload['message_types'], 'url': payload['url'], } # Context self._context = None self._solution = { 'service_sid': service_sid, 'user_sid': user_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: UserBindingContext for this UserBindingInstance :rtype: twilio.rest.chat.v2.service.user.user_binding.UserBindingContext """ if self._context is None: self._context = UserBindingContext( self._version, service_sid=self._solution['service_sid'], user_sid=self._solution['user_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def endpoint(self): """ :returns: The endpoint :rtype: unicode """ return self._properties['endpoint'] @property def identity(self): """ :returns: The identity :rtype: unicode """ return self._properties['identity'] @property def user_sid(self): """ :returns: The user_sid :rtype: unicode """ return self._properties['user_sid'] @property def credential_sid(self): """ :returns: The credential_sid :rtype: unicode """ return self._properties['credential_sid'] @property def binding_type(self): """ :returns: The binding_type :rtype: UserBindingInstance.BindingType """ return self._properties['binding_type'] @property def message_types(self): """ :returns: The message_types :rtype: unicode """ return self._properties['message_types'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a UserBindingInstance :returns: Fetched UserBindingInstance :rtype: twilio.rest.chat.v2.service.user.user_binding.UserBindingInstance """ return self._proxy.fetch() def delete(self): """ Deletes the UserBindingInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/ip_messaging/v2/service/user/user_channel.py000066400000000000000000000220741317472742600273150ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class UserChannelList(ListResource): """ """ def __init__(self, version, service_sid, user_sid): """ Initialize the UserChannelList :param Version version: Version that contains the resource :param service_sid: The service_sid :param user_sid: The sid :returns: twilio.rest.chat.v2.service.user.user_channel.UserChannelList :rtype: twilio.rest.chat.v2.service.user.user_channel.UserChannelList """ super(UserChannelList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'user_sid': user_sid,} self._uri = '/Services/{service_sid}/Users/{user_sid}/Channels'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams UserChannelInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.user.user_channel.UserChannelInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists UserChannelInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.chat.v2.service.user.user_channel.UserChannelInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of UserChannelInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of UserChannelInstance :rtype: twilio.rest.chat.v2.service.user.user_channel.UserChannelPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return UserChannelPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of UserChannelInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of UserChannelInstance :rtype: twilio.rest.chat.v2.service.user.user_channel.UserChannelPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return UserChannelPage(self._version, response, self._solution) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class UserChannelPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the UserChannelPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :param user_sid: The sid :returns: twilio.rest.chat.v2.service.user.user_channel.UserChannelPage :rtype: twilio.rest.chat.v2.service.user.user_channel.UserChannelPage """ super(UserChannelPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of UserChannelInstance :param dict payload: Payload response from the API :returns: twilio.rest.chat.v2.service.user.user_channel.UserChannelInstance :rtype: twilio.rest.chat.v2.service.user.user_channel.UserChannelInstance """ return UserChannelInstance( self._version, payload, service_sid=self._solution['service_sid'], user_sid=self._solution['user_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class UserChannelInstance(InstanceResource): """ """ class ChannelStatus(object): JOINED = "joined" INVITED = "invited" NOT_PARTICIPATING = "not_participating" def __init__(self, version, payload, service_sid, user_sid): """ Initialize the UserChannelInstance :returns: twilio.rest.chat.v2.service.user.user_channel.UserChannelInstance :rtype: twilio.rest.chat.v2.service.user.user_channel.UserChannelInstance """ super(UserChannelInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'channel_sid': payload['channel_sid'], 'member_sid': payload['member_sid'], 'status': payload['status'], 'last_consumed_message_index': deserialize.integer(payload['last_consumed_message_index']), 'unread_messages_count': deserialize.integer(payload['unread_messages_count']), 'links': payload['links'], } # Context self._context = None self._solution = {'service_sid': service_sid, 'user_sid': user_sid,} @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def channel_sid(self): """ :returns: The channel_sid :rtype: unicode """ return self._properties['channel_sid'] @property def member_sid(self): """ :returns: The member_sid :rtype: unicode """ return self._properties['member_sid'] @property def status(self): """ :returns: The status :rtype: UserChannelInstance.ChannelStatus """ return self._properties['status'] @property def last_consumed_message_index(self): """ :returns: The last_consumed_message_index :rtype: unicode """ return self._properties['last_consumed_message_index'] @property def unread_messages_count(self): """ :returns: The unread_messages_count :rtype: unicode """ return self._properties['unread_messages_count'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/lookups/000077500000000000000000000000001317472742600203525ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/lookups/__init__.py000066400000000000000000000021571317472742600224700ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.domain import Domain from twilio.rest.lookups.v1 import V1 class Lookups(Domain): def __init__(self, twilio): """ Initialize the Lookups Domain :returns: Domain for Lookups :rtype: twilio.rest.lookups.Lookups """ super(Lookups, self).__init__(twilio) self.base_url = 'https://lookups.twilio.com' # Versions self._v1 = None @property def v1(self): """ :returns: Version v1 of lookups :rtype: twilio.rest.lookups.v1.V1 """ if self._v1 is None: self._v1 = V1(self) return self._v1 @property def phone_numbers(self): """ :rtype: twilio.rest.lookups.v1.phone_number.PhoneNumberList """ return self.v1.phone_numbers def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/lookups/v1/000077500000000000000000000000001317472742600207005ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/lookups/v1/__init__.py000066400000000000000000000017531317472742600230170ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.version import Version from twilio.rest.lookups.v1.phone_number import PhoneNumberList class V1(Version): def __init__(self, domain): """ Initialize the V1 version of Lookups :returns: V1 version of Lookups :rtype: twilio.rest.lookups.v1.V1.V1 """ super(V1, self).__init__(domain) self.version = 'v1' self._phone_numbers = None @property def phone_numbers(self): """ :rtype: twilio.rest.lookups.v1.phone_number.PhoneNumberList """ if self._phone_numbers is None: self._phone_numbers = PhoneNumberList(self) return self._phone_numbers def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/lookups/v1/phone_number.py000066400000000000000000000205471317472742600237430ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import serialize 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.page import Page class PhoneNumberList(ListResource): """ """ def __init__(self, version): """ Initialize the PhoneNumberList :param Version version: Version that contains the resource :returns: twilio.rest.lookups.v1.phone_number.PhoneNumberList :rtype: twilio.rest.lookups.v1.phone_number.PhoneNumberList """ super(PhoneNumberList, self).__init__(version) # Path Solution self._solution = {} def get(self, phone_number): """ Constructs a PhoneNumberContext :param phone_number: The phone_number :returns: twilio.rest.lookups.v1.phone_number.PhoneNumberContext :rtype: twilio.rest.lookups.v1.phone_number.PhoneNumberContext """ return PhoneNumberContext(self._version, phone_number=phone_number,) def __call__(self, phone_number): """ Constructs a PhoneNumberContext :param phone_number: The phone_number :returns: twilio.rest.lookups.v1.phone_number.PhoneNumberContext :rtype: twilio.rest.lookups.v1.phone_number.PhoneNumberContext """ return PhoneNumberContext(self._version, phone_number=phone_number,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class PhoneNumberPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the PhoneNumberPage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.lookups.v1.phone_number.PhoneNumberPage :rtype: twilio.rest.lookups.v1.phone_number.PhoneNumberPage """ super(PhoneNumberPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of PhoneNumberInstance :param dict payload: Payload response from the API :returns: twilio.rest.lookups.v1.phone_number.PhoneNumberInstance :rtype: twilio.rest.lookups.v1.phone_number.PhoneNumberInstance """ return PhoneNumberInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class PhoneNumberContext(InstanceContext): """ """ def __init__(self, version, phone_number): """ Initialize the PhoneNumberContext :param Version version: Version that contains the resource :param phone_number: The phone_number :returns: twilio.rest.lookups.v1.phone_number.PhoneNumberContext :rtype: twilio.rest.lookups.v1.phone_number.PhoneNumberContext """ super(PhoneNumberContext, self).__init__(version) # Path Solution self._solution = {'phone_number': phone_number,} self._uri = '/PhoneNumbers/{phone_number}'.format(**self._solution) def fetch(self, country_code=values.unset, type=values.unset, add_ons=values.unset, add_ons_data=values.unset): """ Fetch a PhoneNumberInstance :param unicode country_code: The country_code :param unicode type: The type :param unicode add_ons: The add_ons :param dict add_ons_data: The add_ons_data :returns: Fetched PhoneNumberInstance :rtype: twilio.rest.lookups.v1.phone_number.PhoneNumberInstance """ params = values.of({'CountryCode': country_code, 'Type': type, 'AddOns': add_ons,}) params.update(serialize.prefixed_collapsible_map(add_ons_data, 'AddOns')) payload = self._version.fetch( 'GET', self._uri, params=params, ) return PhoneNumberInstance(self._version, payload, phone_number=self._solution['phone_number'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class PhoneNumberInstance(InstanceResource): """ """ class Type(object): LANDLINE = "landline" MOBILE = "mobile" VOIP = "voip" def __init__(self, version, payload, phone_number=None): """ Initialize the PhoneNumberInstance :returns: twilio.rest.lookups.v1.phone_number.PhoneNumberInstance :rtype: twilio.rest.lookups.v1.phone_number.PhoneNumberInstance """ super(PhoneNumberInstance, self).__init__(version) # Marshaled Properties self._properties = { 'caller_name': payload['caller_name'], 'country_code': payload['country_code'], 'phone_number': payload['phone_number'], 'national_format': payload['national_format'], 'carrier': payload['carrier'], 'add_ons': payload['add_ons'], 'url': payload['url'], } # Context self._context = None self._solution = {'phone_number': phone_number or self._properties['phone_number'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: PhoneNumberContext for this PhoneNumberInstance :rtype: twilio.rest.lookups.v1.phone_number.PhoneNumberContext """ if self._context is None: self._context = PhoneNumberContext(self._version, phone_number=self._solution['phone_number'],) return self._context @property def caller_name(self): """ :returns: The caller_name :rtype: unicode """ return self._properties['caller_name'] @property def country_code(self): """ :returns: The country_code :rtype: unicode """ return self._properties['country_code'] @property def phone_number(self): """ :returns: The phone_number :rtype: unicode """ return self._properties['phone_number'] @property def national_format(self): """ :returns: The national_format :rtype: unicode """ return self._properties['national_format'] @property def carrier(self): """ :returns: The carrier :rtype: unicode """ return self._properties['carrier'] @property def add_ons(self): """ :returns: The add_ons :rtype: dict """ return self._properties['add_ons'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self, country_code=values.unset, type=values.unset, add_ons=values.unset, add_ons_data=values.unset): """ Fetch a PhoneNumberInstance :param unicode country_code: The country_code :param unicode type: The type :param unicode add_ons: The add_ons :param dict add_ons_data: The add_ons_data :returns: Fetched PhoneNumberInstance :rtype: twilio.rest.lookups.v1.phone_number.PhoneNumberInstance """ return self._proxy.fetch( country_code=country_code, type=type, add_ons=add_ons, add_ons_data=add_ons_data, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/messaging/000077500000000000000000000000001317472742600206335ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/messaging/__init__.py000066400000000000000000000021641317472742600227470ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.domain import Domain from twilio.rest.messaging.v1 import V1 class Messaging(Domain): def __init__(self, twilio): """ Initialize the Messaging Domain :returns: Domain for Messaging :rtype: twilio.rest.messaging.Messaging """ super(Messaging, self).__init__(twilio) self.base_url = 'https://messaging.twilio.com' # Versions self._v1 = None @property def v1(self): """ :returns: Version v1 of messaging :rtype: twilio.rest.messaging.v1.V1 """ if self._v1 is None: self._v1 = V1(self) return self._v1 @property def services(self): """ :rtype: twilio.rest.messaging.v1.service.ServiceList """ return self.v1.services def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/messaging/v1/000077500000000000000000000000001317472742600211615ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/messaging/v1/__init__.py000066400000000000000000000017101317472742600232710ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.version import Version from twilio.rest.messaging.v1.service import ServiceList class V1(Version): def __init__(self, domain): """ Initialize the V1 version of Messaging :returns: V1 version of Messaging :rtype: twilio.rest.messaging.v1.V1.V1 """ super(V1, self).__init__(domain) self.version = 'v1' self._services = None @property def services(self): """ :rtype: twilio.rest.messaging.v1.service.ServiceList """ if self._services is None: self._services = ServiceList(self) return self._services def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/messaging/v1/service/000077500000000000000000000000001317472742600226215ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/messaging/v1/service/__init__.py000066400000000000000000000604061317472742600247400ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.messaging.v1.service.alpha_sender import AlphaSenderList from twilio.rest.messaging.v1.service.phone_number import PhoneNumberList from twilio.rest.messaging.v1.service.short_code import ShortCodeList class ServiceList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version): """ Initialize the ServiceList :param Version version: Version that contains the resource :returns: twilio.rest.messaging.v1.service.ServiceList :rtype: twilio.rest.messaging.v1.service.ServiceList """ super(ServiceList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/Services'.format(**self._solution) def create(self, friendly_name, inbound_request_url=values.unset, inbound_method=values.unset, fallback_url=values.unset, fallback_method=values.unset, status_callback=values.unset, sticky_sender=values.unset, mms_converter=values.unset, smart_encoding=values.unset, scan_message_content=values.unset, fallback_to_long_code=values.unset, area_code_geomatch=values.unset, validity_period=values.unset, synchronous_validation=values.unset): """ Create a new ServiceInstance :param unicode friendly_name: The friendly_name :param unicode inbound_request_url: The inbound_request_url :param unicode inbound_method: The inbound_method :param unicode fallback_url: The fallback_url :param unicode fallback_method: The fallback_method :param unicode status_callback: The status_callback :param bool sticky_sender: The sticky_sender :param bool mms_converter: The mms_converter :param bool smart_encoding: The smart_encoding :param ServiceInstance.ScanMessageContent scan_message_content: The scan_message_content :param bool fallback_to_long_code: The fallback_to_long_code :param bool area_code_geomatch: The area_code_geomatch :param unicode validity_period: The validity_period :param bool synchronous_validation: The synchronous_validation :returns: Newly created ServiceInstance :rtype: twilio.rest.messaging.v1.service.ServiceInstance """ data = values.of({ 'FriendlyName': friendly_name, 'InboundRequestUrl': inbound_request_url, 'InboundMethod': inbound_method, 'FallbackUrl': fallback_url, 'FallbackMethod': fallback_method, 'StatusCallback': status_callback, 'StickySender': sticky_sender, 'MmsConverter': mms_converter, 'SmartEncoding': smart_encoding, 'ScanMessageContent': scan_message_content, 'FallbackToLongCode': fallback_to_long_code, 'AreaCodeGeomatch': area_code_geomatch, 'ValidityPeriod': validity_period, 'SynchronousValidation': synchronous_validation, }) payload = self._version.create( 'POST', self._uri, data=data, ) return ServiceInstance(self._version, payload,) def stream(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.messaging.v1.service.ServiceInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.messaging.v1.service.ServiceInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of ServiceInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of ServiceInstance :rtype: twilio.rest.messaging.v1.service.ServicePage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return ServicePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of ServiceInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of ServiceInstance :rtype: twilio.rest.messaging.v1.service.ServicePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return ServicePage(self._version, response, self._solution) def get(self, sid): """ Constructs a ServiceContext :param sid: The sid :returns: twilio.rest.messaging.v1.service.ServiceContext :rtype: twilio.rest.messaging.v1.service.ServiceContext """ return ServiceContext(self._version, sid=sid,) def __call__(self, sid): """ Constructs a ServiceContext :param sid: The sid :returns: twilio.rest.messaging.v1.service.ServiceContext :rtype: twilio.rest.messaging.v1.service.ServiceContext """ return ServiceContext(self._version, sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ServicePage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the ServicePage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.messaging.v1.service.ServicePage :rtype: twilio.rest.messaging.v1.service.ServicePage """ super(ServicePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of ServiceInstance :param dict payload: Payload response from the API :returns: twilio.rest.messaging.v1.service.ServiceInstance :rtype: twilio.rest.messaging.v1.service.ServiceInstance """ return ServiceInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ServiceContext(InstanceContext): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, sid): """ Initialize the ServiceContext :param Version version: Version that contains the resource :param sid: The sid :returns: twilio.rest.messaging.v1.service.ServiceContext :rtype: twilio.rest.messaging.v1.service.ServiceContext """ super(ServiceContext, self).__init__(version) # Path Solution self._solution = {'sid': sid,} self._uri = '/Services/{sid}'.format(**self._solution) # Dependents self._phone_numbers = None self._short_codes = None self._alpha_senders = None def update(self, friendly_name=values.unset, inbound_request_url=values.unset, inbound_method=values.unset, fallback_url=values.unset, fallback_method=values.unset, status_callback=values.unset, sticky_sender=values.unset, mms_converter=values.unset, smart_encoding=values.unset, scan_message_content=values.unset, fallback_to_long_code=values.unset, area_code_geomatch=values.unset, validity_period=values.unset, synchronous_validation=values.unset): """ Update the ServiceInstance :param unicode friendly_name: The friendly_name :param unicode inbound_request_url: The inbound_request_url :param unicode inbound_method: The inbound_method :param unicode fallback_url: The fallback_url :param unicode fallback_method: The fallback_method :param unicode status_callback: The status_callback :param bool sticky_sender: The sticky_sender :param bool mms_converter: The mms_converter :param bool smart_encoding: The smart_encoding :param ServiceInstance.ScanMessageContent scan_message_content: The scan_message_content :param bool fallback_to_long_code: The fallback_to_long_code :param bool area_code_geomatch: The area_code_geomatch :param unicode validity_period: The validity_period :param bool synchronous_validation: The synchronous_validation :returns: Updated ServiceInstance :rtype: twilio.rest.messaging.v1.service.ServiceInstance """ data = values.of({ 'FriendlyName': friendly_name, 'InboundRequestUrl': inbound_request_url, 'InboundMethod': inbound_method, 'FallbackUrl': fallback_url, 'FallbackMethod': fallback_method, 'StatusCallback': status_callback, 'StickySender': sticky_sender, 'MmsConverter': mms_converter, 'SmartEncoding': smart_encoding, 'ScanMessageContent': scan_message_content, 'FallbackToLongCode': fallback_to_long_code, 'AreaCodeGeomatch': area_code_geomatch, 'ValidityPeriod': validity_period, 'SynchronousValidation': synchronous_validation, }) payload = self._version.update( 'POST', self._uri, data=data, ) return ServiceInstance(self._version, payload, sid=self._solution['sid'],) def fetch(self): """ Fetch a ServiceInstance :returns: Fetched ServiceInstance :rtype: twilio.rest.messaging.v1.service.ServiceInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return ServiceInstance(self._version, payload, sid=self._solution['sid'],) def delete(self): """ Deletes the ServiceInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) @property def phone_numbers(self): """ Access the phone_numbers :returns: twilio.rest.messaging.v1.service.phone_number.PhoneNumberList :rtype: twilio.rest.messaging.v1.service.phone_number.PhoneNumberList """ if self._phone_numbers is None: self._phone_numbers = PhoneNumberList(self._version, service_sid=self._solution['sid'],) return self._phone_numbers @property def short_codes(self): """ Access the short_codes :returns: twilio.rest.messaging.v1.service.short_code.ShortCodeList :rtype: twilio.rest.messaging.v1.service.short_code.ShortCodeList """ if self._short_codes is None: self._short_codes = ShortCodeList(self._version, service_sid=self._solution['sid'],) return self._short_codes @property def alpha_senders(self): """ Access the alpha_senders :returns: twilio.rest.messaging.v1.service.alpha_sender.AlphaSenderList :rtype: twilio.rest.messaging.v1.service.alpha_sender.AlphaSenderList """ if self._alpha_senders is None: self._alpha_senders = AlphaSenderList(self._version, service_sid=self._solution['sid'],) return self._alpha_senders def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class ServiceInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ class ScanMessageContent(object): INHERIT = "inherit" ENABLE = "enable" DISABLE = "disable" def __init__(self, version, payload, sid=None): """ Initialize the ServiceInstance :returns: twilio.rest.messaging.v1.service.ServiceInstance :rtype: twilio.rest.messaging.v1.service.ServiceInstance """ super(ServiceInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'friendly_name': payload['friendly_name'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'inbound_request_url': payload['inbound_request_url'], 'inbound_method': payload['inbound_method'], 'fallback_url': payload['fallback_url'], 'fallback_method': payload['fallback_method'], 'status_callback': payload['status_callback'], 'sticky_sender': payload['sticky_sender'], 'mms_converter': payload['mms_converter'], 'smart_encoding': payload['smart_encoding'], 'scan_message_content': payload['scan_message_content'], 'fallback_to_long_code': payload['fallback_to_long_code'], 'area_code_geomatch': payload['area_code_geomatch'], 'synchronous_validation': payload['synchronous_validation'], 'validity_period': deserialize.integer(payload['validity_period']), 'url': payload['url'], 'links': payload['links'], } # Context self._context = None self._solution = {'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.messaging.v1.service.ServiceContext """ if self._context is None: self._context = ServiceContext(self._version, sid=self._solution['sid'],) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def inbound_request_url(self): """ :returns: The inbound_request_url :rtype: unicode """ return self._properties['inbound_request_url'] @property def inbound_method(self): """ :returns: The inbound_method :rtype: unicode """ return self._properties['inbound_method'] @property def fallback_url(self): """ :returns: The fallback_url :rtype: unicode """ return self._properties['fallback_url'] @property def fallback_method(self): """ :returns: The fallback_method :rtype: unicode """ return self._properties['fallback_method'] @property def status_callback(self): """ :returns: The status_callback :rtype: unicode """ return self._properties['status_callback'] @property def sticky_sender(self): """ :returns: The sticky_sender :rtype: bool """ return self._properties['sticky_sender'] @property def mms_converter(self): """ :returns: The mms_converter :rtype: bool """ return self._properties['mms_converter'] @property def smart_encoding(self): """ :returns: The smart_encoding :rtype: bool """ return self._properties['smart_encoding'] @property def scan_message_content(self): """ :returns: The scan_message_content :rtype: ServiceInstance.ScanMessageContent """ return self._properties['scan_message_content'] @property def fallback_to_long_code(self): """ :returns: The fallback_to_long_code :rtype: bool """ return self._properties['fallback_to_long_code'] @property def area_code_geomatch(self): """ :returns: The area_code_geomatch :rtype: bool """ return self._properties['area_code_geomatch'] @property def synchronous_validation(self): """ :returns: The synchronous_validation :rtype: bool """ return self._properties['synchronous_validation'] @property def validity_period(self): """ :returns: The validity_period :rtype: unicode """ return self._properties['validity_period'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def update(self, friendly_name=values.unset, inbound_request_url=values.unset, inbound_method=values.unset, fallback_url=values.unset, fallback_method=values.unset, status_callback=values.unset, sticky_sender=values.unset, mms_converter=values.unset, smart_encoding=values.unset, scan_message_content=values.unset, fallback_to_long_code=values.unset, area_code_geomatch=values.unset, validity_period=values.unset, synchronous_validation=values.unset): """ Update the ServiceInstance :param unicode friendly_name: The friendly_name :param unicode inbound_request_url: The inbound_request_url :param unicode inbound_method: The inbound_method :param unicode fallback_url: The fallback_url :param unicode fallback_method: The fallback_method :param unicode status_callback: The status_callback :param bool sticky_sender: The sticky_sender :param bool mms_converter: The mms_converter :param bool smart_encoding: The smart_encoding :param ServiceInstance.ScanMessageContent scan_message_content: The scan_message_content :param bool fallback_to_long_code: The fallback_to_long_code :param bool area_code_geomatch: The area_code_geomatch :param unicode validity_period: The validity_period :param bool synchronous_validation: The synchronous_validation :returns: Updated ServiceInstance :rtype: twilio.rest.messaging.v1.service.ServiceInstance """ return self._proxy.update( friendly_name=friendly_name, inbound_request_url=inbound_request_url, inbound_method=inbound_method, fallback_url=fallback_url, fallback_method=fallback_method, status_callback=status_callback, sticky_sender=sticky_sender, mms_converter=mms_converter, smart_encoding=smart_encoding, scan_message_content=scan_message_content, fallback_to_long_code=fallback_to_long_code, area_code_geomatch=area_code_geomatch, validity_period=validity_period, synchronous_validation=synchronous_validation, ) def fetch(self): """ Fetch a ServiceInstance :returns: Fetched ServiceInstance :rtype: twilio.rest.messaging.v1.service.ServiceInstance """ return self._proxy.fetch() def delete(self): """ Deletes the ServiceInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() @property def phone_numbers(self): """ Access the phone_numbers :returns: twilio.rest.messaging.v1.service.phone_number.PhoneNumberList :rtype: twilio.rest.messaging.v1.service.phone_number.PhoneNumberList """ return self._proxy.phone_numbers @property def short_codes(self): """ Access the short_codes :returns: twilio.rest.messaging.v1.service.short_code.ShortCodeList :rtype: twilio.rest.messaging.v1.service.short_code.ShortCodeList """ return self._proxy.short_codes @property def alpha_senders(self): """ Access the alpha_senders :returns: twilio.rest.messaging.v1.service.alpha_sender.AlphaSenderList :rtype: twilio.rest.messaging.v1.service.alpha_sender.AlphaSenderList """ return self._proxy.alpha_senders def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/messaging/v1/service/alpha_sender.py000066400000000000000000000325011317472742600256210ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class AlphaSenderList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid): """ Initialize the AlphaSenderList :param Version version: Version that contains the resource :param service_sid: The service_sid :returns: twilio.rest.messaging.v1.service.alpha_sender.AlphaSenderList :rtype: twilio.rest.messaging.v1.service.alpha_sender.AlphaSenderList """ super(AlphaSenderList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid,} self._uri = '/Services/{service_sid}/AlphaSenders'.format(**self._solution) def create(self, alpha_sender): """ Create a new AlphaSenderInstance :param unicode alpha_sender: The alpha_sender :returns: Newly created AlphaSenderInstance :rtype: twilio.rest.messaging.v1.service.alpha_sender.AlphaSenderInstance """ data = values.of({'AlphaSender': alpha_sender,}) payload = self._version.create( 'POST', self._uri, data=data, ) return AlphaSenderInstance(self._version, payload, service_sid=self._solution['service_sid'],) def stream(self, limit=None, page_size=None): """ Streams AlphaSenderInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.messaging.v1.service.alpha_sender.AlphaSenderInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists AlphaSenderInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.messaging.v1.service.alpha_sender.AlphaSenderInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of AlphaSenderInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of AlphaSenderInstance :rtype: twilio.rest.messaging.v1.service.alpha_sender.AlphaSenderPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return AlphaSenderPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of AlphaSenderInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of AlphaSenderInstance :rtype: twilio.rest.messaging.v1.service.alpha_sender.AlphaSenderPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return AlphaSenderPage(self._version, response, self._solution) def get(self, sid): """ Constructs a AlphaSenderContext :param sid: The sid :returns: twilio.rest.messaging.v1.service.alpha_sender.AlphaSenderContext :rtype: twilio.rest.messaging.v1.service.alpha_sender.AlphaSenderContext """ return AlphaSenderContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __call__(self, sid): """ Constructs a AlphaSenderContext :param sid: The sid :returns: twilio.rest.messaging.v1.service.alpha_sender.AlphaSenderContext :rtype: twilio.rest.messaging.v1.service.alpha_sender.AlphaSenderContext """ return AlphaSenderContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class AlphaSenderPage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the AlphaSenderPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :returns: twilio.rest.messaging.v1.service.alpha_sender.AlphaSenderPage :rtype: twilio.rest.messaging.v1.service.alpha_sender.AlphaSenderPage """ super(AlphaSenderPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of AlphaSenderInstance :param dict payload: Payload response from the API :returns: twilio.rest.messaging.v1.service.alpha_sender.AlphaSenderInstance :rtype: twilio.rest.messaging.v1.service.alpha_sender.AlphaSenderInstance """ return AlphaSenderInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class AlphaSenderContext(InstanceContext): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid, sid): """ Initialize the AlphaSenderContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param sid: The sid :returns: twilio.rest.messaging.v1.service.alpha_sender.AlphaSenderContext :rtype: twilio.rest.messaging.v1.service.alpha_sender.AlphaSenderContext """ super(AlphaSenderContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/AlphaSenders/{sid}'.format(**self._solution) def fetch(self): """ Fetch a AlphaSenderInstance :returns: Fetched AlphaSenderInstance :rtype: twilio.rest.messaging.v1.service.alpha_sender.AlphaSenderInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return AlphaSenderInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the AlphaSenderInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class AlphaSenderInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, payload, service_sid, sid=None): """ Initialize the AlphaSenderInstance :returns: twilio.rest.messaging.v1.service.alpha_sender.AlphaSenderInstance :rtype: twilio.rest.messaging.v1.service.alpha_sender.AlphaSenderInstance """ super(AlphaSenderInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'alpha_sender': payload['alpha_sender'], 'capabilities': payload['capabilities'], 'url': payload['url'], } # Context self._context = None self._solution = {'service_sid': service_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: AlphaSenderContext for this AlphaSenderInstance :rtype: twilio.rest.messaging.v1.service.alpha_sender.AlphaSenderContext """ if self._context is None: self._context = AlphaSenderContext( self._version, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def alpha_sender(self): """ :returns: The alpha_sender :rtype: unicode """ return self._properties['alpha_sender'] @property def capabilities(self): """ :returns: The capabilities :rtype: dict """ return self._properties['capabilities'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a AlphaSenderInstance :returns: Fetched AlphaSenderInstance :rtype: twilio.rest.messaging.v1.service.alpha_sender.AlphaSenderInstance """ return self._proxy.fetch() def delete(self): """ Deletes the AlphaSenderInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/messaging/v1/service/phone_number.py000066400000000000000000000330721317472742600256610ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class PhoneNumberList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid): """ Initialize the PhoneNumberList :param Version version: Version that contains the resource :param service_sid: The service_sid :returns: twilio.rest.messaging.v1.service.phone_number.PhoneNumberList :rtype: twilio.rest.messaging.v1.service.phone_number.PhoneNumberList """ super(PhoneNumberList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid,} self._uri = '/Services/{service_sid}/PhoneNumbers'.format(**self._solution) def create(self, phone_number_sid): """ Create a new PhoneNumberInstance :param unicode phone_number_sid: The phone_number_sid :returns: Newly created PhoneNumberInstance :rtype: twilio.rest.messaging.v1.service.phone_number.PhoneNumberInstance """ data = values.of({'PhoneNumberSid': phone_number_sid,}) payload = self._version.create( 'POST', self._uri, data=data, ) return PhoneNumberInstance(self._version, payload, service_sid=self._solution['service_sid'],) def stream(self, limit=None, page_size=None): """ Streams PhoneNumberInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.messaging.v1.service.phone_number.PhoneNumberInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists PhoneNumberInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.messaging.v1.service.phone_number.PhoneNumberInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of PhoneNumberInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of PhoneNumberInstance :rtype: twilio.rest.messaging.v1.service.phone_number.PhoneNumberPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return PhoneNumberPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of PhoneNumberInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of PhoneNumberInstance :rtype: twilio.rest.messaging.v1.service.phone_number.PhoneNumberPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return PhoneNumberPage(self._version, response, self._solution) def get(self, sid): """ Constructs a PhoneNumberContext :param sid: The sid :returns: twilio.rest.messaging.v1.service.phone_number.PhoneNumberContext :rtype: twilio.rest.messaging.v1.service.phone_number.PhoneNumberContext """ return PhoneNumberContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __call__(self, sid): """ Constructs a PhoneNumberContext :param sid: The sid :returns: twilio.rest.messaging.v1.service.phone_number.PhoneNumberContext :rtype: twilio.rest.messaging.v1.service.phone_number.PhoneNumberContext """ return PhoneNumberContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class PhoneNumberPage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the PhoneNumberPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :returns: twilio.rest.messaging.v1.service.phone_number.PhoneNumberPage :rtype: twilio.rest.messaging.v1.service.phone_number.PhoneNumberPage """ super(PhoneNumberPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of PhoneNumberInstance :param dict payload: Payload response from the API :returns: twilio.rest.messaging.v1.service.phone_number.PhoneNumberInstance :rtype: twilio.rest.messaging.v1.service.phone_number.PhoneNumberInstance """ return PhoneNumberInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class PhoneNumberContext(InstanceContext): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid, sid): """ Initialize the PhoneNumberContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param sid: The sid :returns: twilio.rest.messaging.v1.service.phone_number.PhoneNumberContext :rtype: twilio.rest.messaging.v1.service.phone_number.PhoneNumberContext """ super(PhoneNumberContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/PhoneNumbers/{sid}'.format(**self._solution) def delete(self): """ Deletes the PhoneNumberInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def fetch(self): """ Fetch a PhoneNumberInstance :returns: Fetched PhoneNumberInstance :rtype: twilio.rest.messaging.v1.service.phone_number.PhoneNumberInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return PhoneNumberInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class PhoneNumberInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, payload, service_sid, sid=None): """ Initialize the PhoneNumberInstance :returns: twilio.rest.messaging.v1.service.phone_number.PhoneNumberInstance :rtype: twilio.rest.messaging.v1.service.phone_number.PhoneNumberInstance """ super(PhoneNumberInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'phone_number': payload['phone_number'], 'country_code': payload['country_code'], 'capabilities': payload['capabilities'], 'url': payload['url'], } # Context self._context = None self._solution = {'service_sid': service_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: PhoneNumberContext for this PhoneNumberInstance :rtype: twilio.rest.messaging.v1.service.phone_number.PhoneNumberContext """ if self._context is None: self._context = PhoneNumberContext( self._version, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def phone_number(self): """ :returns: The phone_number :rtype: unicode """ return self._properties['phone_number'] @property def country_code(self): """ :returns: The country_code :rtype: unicode """ return self._properties['country_code'] @property def capabilities(self): """ :returns: The capabilities :rtype: unicode """ return self._properties['capabilities'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def delete(self): """ Deletes the PhoneNumberInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def fetch(self): """ Fetch a PhoneNumberInstance :returns: Fetched PhoneNumberInstance :rtype: twilio.rest.messaging.v1.service.phone_number.PhoneNumberInstance """ return self._proxy.fetch() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/messaging/v1/service/short_code.py000066400000000000000000000325611317472742600253330ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class ShortCodeList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid): """ Initialize the ShortCodeList :param Version version: Version that contains the resource :param service_sid: The service_sid :returns: twilio.rest.messaging.v1.service.short_code.ShortCodeList :rtype: twilio.rest.messaging.v1.service.short_code.ShortCodeList """ super(ShortCodeList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid,} self._uri = '/Services/{service_sid}/ShortCodes'.format(**self._solution) def create(self, short_code_sid): """ Create a new ShortCodeInstance :param unicode short_code_sid: The short_code_sid :returns: Newly created ShortCodeInstance :rtype: twilio.rest.messaging.v1.service.short_code.ShortCodeInstance """ data = values.of({'ShortCodeSid': short_code_sid,}) payload = self._version.create( 'POST', self._uri, data=data, ) return ShortCodeInstance(self._version, payload, service_sid=self._solution['service_sid'],) def stream(self, limit=None, page_size=None): """ Streams ShortCodeInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.messaging.v1.service.short_code.ShortCodeInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists ShortCodeInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.messaging.v1.service.short_code.ShortCodeInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of ShortCodeInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of ShortCodeInstance :rtype: twilio.rest.messaging.v1.service.short_code.ShortCodePage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return ShortCodePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of ShortCodeInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of ShortCodeInstance :rtype: twilio.rest.messaging.v1.service.short_code.ShortCodePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return ShortCodePage(self._version, response, self._solution) def get(self, sid): """ Constructs a ShortCodeContext :param sid: The sid :returns: twilio.rest.messaging.v1.service.short_code.ShortCodeContext :rtype: twilio.rest.messaging.v1.service.short_code.ShortCodeContext """ return ShortCodeContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __call__(self, sid): """ Constructs a ShortCodeContext :param sid: The sid :returns: twilio.rest.messaging.v1.service.short_code.ShortCodeContext :rtype: twilio.rest.messaging.v1.service.short_code.ShortCodeContext """ return ShortCodeContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ShortCodePage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the ShortCodePage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :returns: twilio.rest.messaging.v1.service.short_code.ShortCodePage :rtype: twilio.rest.messaging.v1.service.short_code.ShortCodePage """ super(ShortCodePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of ShortCodeInstance :param dict payload: Payload response from the API :returns: twilio.rest.messaging.v1.service.short_code.ShortCodeInstance :rtype: twilio.rest.messaging.v1.service.short_code.ShortCodeInstance """ return ShortCodeInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ShortCodeContext(InstanceContext): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid, sid): """ Initialize the ShortCodeContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param sid: The sid :returns: twilio.rest.messaging.v1.service.short_code.ShortCodeContext :rtype: twilio.rest.messaging.v1.service.short_code.ShortCodeContext """ super(ShortCodeContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/ShortCodes/{sid}'.format(**self._solution) def delete(self): """ Deletes the ShortCodeInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def fetch(self): """ Fetch a ShortCodeInstance :returns: Fetched ShortCodeInstance :rtype: twilio.rest.messaging.v1.service.short_code.ShortCodeInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return ShortCodeInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class ShortCodeInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, payload, service_sid, sid=None): """ Initialize the ShortCodeInstance :returns: twilio.rest.messaging.v1.service.short_code.ShortCodeInstance :rtype: twilio.rest.messaging.v1.service.short_code.ShortCodeInstance """ super(ShortCodeInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'short_code': payload['short_code'], 'country_code': payload['country_code'], 'capabilities': payload['capabilities'], 'url': payload['url'], } # Context self._context = None self._solution = {'service_sid': service_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.messaging.v1.service.short_code.ShortCodeContext """ if self._context is None: self._context = ShortCodeContext( self._version, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def short_code(self): """ :returns: The short_code :rtype: unicode """ return self._properties['short_code'] @property def country_code(self): """ :returns: The country_code :rtype: unicode """ return self._properties['country_code'] @property def capabilities(self): """ :returns: The capabilities :rtype: dict """ return self._properties['capabilities'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def delete(self): """ Deletes the ShortCodeInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def fetch(self): """ Fetch a ShortCodeInstance :returns: Fetched ShortCodeInstance :rtype: twilio.rest.messaging.v1.service.short_code.ShortCodeInstance """ return self._proxy.fetch() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/monitor/000077500000000000000000000000001317472742600203455ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/monitor/__init__.py000066400000000000000000000023461317472742600224630ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.domain import Domain from twilio.rest.monitor.v1 import V1 class Monitor(Domain): def __init__(self, twilio): """ Initialize the Monitor Domain :returns: Domain for Monitor :rtype: twilio.rest.monitor.Monitor """ super(Monitor, self).__init__(twilio) self.base_url = 'https://monitor.twilio.com' # Versions self._v1 = None @property def v1(self): """ :returns: Version v1 of monitor :rtype: twilio.rest.monitor.v1.V1 """ if self._v1 is None: self._v1 = V1(self) return self._v1 @property def alerts(self): """ :rtype: twilio.rest.monitor.v1.alert.AlertList """ return self.v1.alerts @property def events(self): """ :rtype: twilio.rest.monitor.v1.event.EventList """ return self.v1.events def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/monitor/v1/000077500000000000000000000000001317472742600206735ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/monitor/v1/__init__.py000066400000000000000000000023231317472742600230040ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.version import Version from twilio.rest.monitor.v1.alert import AlertList from twilio.rest.monitor.v1.event import EventList class V1(Version): def __init__(self, domain): """ Initialize the V1 version of Monitor :returns: V1 version of Monitor :rtype: twilio.rest.monitor.v1.V1.V1 """ super(V1, self).__init__(domain) self.version = 'v1' self._alerts = None self._events = None @property def alerts(self): """ :rtype: twilio.rest.monitor.v1.alert.AlertList """ if self._alerts is None: self._alerts = AlertList(self) return self._alerts @property def events(self): """ :rtype: twilio.rest.monitor.v1.event.EventList """ if self._events is None: self._events = EventList(self) return self._events def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/monitor/v1/alert.py000066400000000000000000000342771317472742600223710ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize 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.page import Page class AlertList(ListResource): """ """ def __init__(self, version): """ Initialize the AlertList :param Version version: Version that contains the resource :returns: twilio.rest.monitor.v1.alert.AlertList :rtype: twilio.rest.monitor.v1.alert.AlertList """ super(AlertList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/Alerts'.format(**self._solution) def stream(self, log_level=values.unset, start_date=values.unset, end_date=values.unset, limit=None, page_size=None): """ Streams AlertInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param unicode log_level: The log_level :param date start_date: The start_date :param date end_date: The end_date :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.monitor.v1.alert.AlertInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( log_level=log_level, start_date=start_date, end_date=end_date, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, log_level=values.unset, start_date=values.unset, end_date=values.unset, limit=None, page_size=None): """ Lists AlertInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param unicode log_level: The log_level :param date start_date: The start_date :param date end_date: The end_date :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.monitor.v1.alert.AlertInstance] """ return list(self.stream( log_level=log_level, start_date=start_date, end_date=end_date, limit=limit, page_size=page_size, )) def page(self, log_level=values.unset, start_date=values.unset, end_date=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of AlertInstance records from the API. Request is executed immediately :param unicode log_level: The log_level :param date start_date: The start_date :param date end_date: The end_date :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of AlertInstance :rtype: twilio.rest.monitor.v1.alert.AlertPage """ params = values.of({ 'LogLevel': log_level, 'StartDate': serialize.iso8601_date(start_date), 'EndDate': serialize.iso8601_date(end_date), 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return AlertPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of AlertInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of AlertInstance :rtype: twilio.rest.monitor.v1.alert.AlertPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return AlertPage(self._version, response, self._solution) def get(self, sid): """ Constructs a AlertContext :param sid: The sid :returns: twilio.rest.monitor.v1.alert.AlertContext :rtype: twilio.rest.monitor.v1.alert.AlertContext """ return AlertContext(self._version, sid=sid,) def __call__(self, sid): """ Constructs a AlertContext :param sid: The sid :returns: twilio.rest.monitor.v1.alert.AlertContext :rtype: twilio.rest.monitor.v1.alert.AlertContext """ return AlertContext(self._version, sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class AlertPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the AlertPage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.monitor.v1.alert.AlertPage :rtype: twilio.rest.monitor.v1.alert.AlertPage """ super(AlertPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of AlertInstance :param dict payload: Payload response from the API :returns: twilio.rest.monitor.v1.alert.AlertInstance :rtype: twilio.rest.monitor.v1.alert.AlertInstance """ return AlertInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class AlertContext(InstanceContext): """ """ def __init__(self, version, sid): """ Initialize the AlertContext :param Version version: Version that contains the resource :param sid: The sid :returns: twilio.rest.monitor.v1.alert.AlertContext :rtype: twilio.rest.monitor.v1.alert.AlertContext """ super(AlertContext, self).__init__(version) # Path Solution self._solution = {'sid': sid,} self._uri = '/Alerts/{sid}'.format(**self._solution) def fetch(self): """ Fetch a AlertInstance :returns: Fetched AlertInstance :rtype: twilio.rest.monitor.v1.alert.AlertInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return AlertInstance(self._version, payload, sid=self._solution['sid'],) def delete(self): """ Deletes the AlertInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class AlertInstance(InstanceResource): """ """ def __init__(self, version, payload, sid=None): """ Initialize the AlertInstance :returns: twilio.rest.monitor.v1.alert.AlertInstance :rtype: twilio.rest.monitor.v1.alert.AlertInstance """ super(AlertInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'alert_text': payload['alert_text'], 'api_version': payload['api_version'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_generated': deserialize.iso8601_datetime(payload['date_generated']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'error_code': payload['error_code'], 'log_level': payload['log_level'], 'more_info': payload['more_info'], 'request_method': payload['request_method'], 'request_url': payload['request_url'], 'resource_sid': payload['resource_sid'], 'sid': payload['sid'], 'url': payload['url'], 'request_variables': payload.get('request_variables'), 'response_body': payload.get('response_body'), 'response_headers': payload.get('response_headers'), } # Context self._context = None self._solution = {'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: AlertContext for this AlertInstance :rtype: twilio.rest.monitor.v1.alert.AlertContext """ if self._context is None: self._context = AlertContext(self._version, sid=self._solution['sid'],) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def alert_text(self): """ :returns: The alert_text :rtype: unicode """ return self._properties['alert_text'] @property def api_version(self): """ :returns: The api_version :rtype: unicode """ return self._properties['api_version'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_generated(self): """ :returns: The date_generated :rtype: datetime """ return self._properties['date_generated'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def error_code(self): """ :returns: The error_code :rtype: unicode """ return self._properties['error_code'] @property def log_level(self): """ :returns: The log_level :rtype: unicode """ return self._properties['log_level'] @property def more_info(self): """ :returns: The more_info :rtype: unicode """ return self._properties['more_info'] @property def request_method(self): """ :returns: The request_method :rtype: unicode """ return self._properties['request_method'] @property def request_url(self): """ :returns: The request_url :rtype: unicode """ return self._properties['request_url'] @property def request_variables(self): """ :returns: The request_variables :rtype: unicode """ return self._properties['request_variables'] @property def resource_sid(self): """ :returns: The resource_sid :rtype: unicode """ return self._properties['resource_sid'] @property def response_body(self): """ :returns: The response_body :rtype: unicode """ return self._properties['response_body'] @property def response_headers(self): """ :returns: The response_headers :rtype: unicode """ return self._properties['response_headers'] @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a AlertInstance :returns: Fetched AlertInstance :rtype: twilio.rest.monitor.v1.alert.AlertInstance """ return self._proxy.fetch() def delete(self): """ Deletes the AlertInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/monitor/v1/event.py000066400000000000000000000341731317472742600223760ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize 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.page import Page class EventList(ListResource): """ """ def __init__(self, version): """ Initialize the EventList :param Version version: Version that contains the resource :returns: twilio.rest.monitor.v1.event.EventList :rtype: twilio.rest.monitor.v1.event.EventList """ super(EventList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/Events'.format(**self._solution) def stream(self, actor_sid=values.unset, event_type=values.unset, resource_sid=values.unset, source_ip_address=values.unset, start_date=values.unset, end_date=values.unset, limit=None, page_size=None): """ Streams EventInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param unicode actor_sid: The actor_sid :param unicode event_type: The event_type :param unicode resource_sid: The resource_sid :param unicode source_ip_address: The source_ip_address :param date start_date: The start_date :param date end_date: The end_date :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.monitor.v1.event.EventInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( actor_sid=actor_sid, event_type=event_type, resource_sid=resource_sid, source_ip_address=source_ip_address, start_date=start_date, end_date=end_date, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, actor_sid=values.unset, event_type=values.unset, resource_sid=values.unset, source_ip_address=values.unset, start_date=values.unset, end_date=values.unset, limit=None, page_size=None): """ Lists EventInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param unicode actor_sid: The actor_sid :param unicode event_type: The event_type :param unicode resource_sid: The resource_sid :param unicode source_ip_address: The source_ip_address :param date start_date: The start_date :param date end_date: The end_date :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.monitor.v1.event.EventInstance] """ return list(self.stream( actor_sid=actor_sid, event_type=event_type, resource_sid=resource_sid, source_ip_address=source_ip_address, start_date=start_date, end_date=end_date, limit=limit, page_size=page_size, )) def page(self, actor_sid=values.unset, event_type=values.unset, resource_sid=values.unset, source_ip_address=values.unset, start_date=values.unset, end_date=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of EventInstance records from the API. Request is executed immediately :param unicode actor_sid: The actor_sid :param unicode event_type: The event_type :param unicode resource_sid: The resource_sid :param unicode source_ip_address: The source_ip_address :param date start_date: The start_date :param date end_date: The end_date :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of EventInstance :rtype: twilio.rest.monitor.v1.event.EventPage """ params = values.of({ 'ActorSid': actor_sid, 'EventType': event_type, 'ResourceSid': resource_sid, 'SourceIpAddress': source_ip_address, 'StartDate': serialize.iso8601_date(start_date), 'EndDate': serialize.iso8601_date(end_date), 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return EventPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of EventInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of EventInstance :rtype: twilio.rest.monitor.v1.event.EventPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return EventPage(self._version, response, self._solution) def get(self, sid): """ Constructs a EventContext :param sid: The sid :returns: twilio.rest.monitor.v1.event.EventContext :rtype: twilio.rest.monitor.v1.event.EventContext """ return EventContext(self._version, sid=sid,) def __call__(self, sid): """ Constructs a EventContext :param sid: The sid :returns: twilio.rest.monitor.v1.event.EventContext :rtype: twilio.rest.monitor.v1.event.EventContext """ return EventContext(self._version, sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class EventPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the EventPage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.monitor.v1.event.EventPage :rtype: twilio.rest.monitor.v1.event.EventPage """ super(EventPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of EventInstance :param dict payload: Payload response from the API :returns: twilio.rest.monitor.v1.event.EventInstance :rtype: twilio.rest.monitor.v1.event.EventInstance """ return EventInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class EventContext(InstanceContext): """ """ def __init__(self, version, sid): """ Initialize the EventContext :param Version version: Version that contains the resource :param sid: The sid :returns: twilio.rest.monitor.v1.event.EventContext :rtype: twilio.rest.monitor.v1.event.EventContext """ super(EventContext, self).__init__(version) # Path Solution self._solution = {'sid': sid,} self._uri = '/Events/{sid}'.format(**self._solution) def fetch(self): """ Fetch a EventInstance :returns: Fetched EventInstance :rtype: twilio.rest.monitor.v1.event.EventInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return EventInstance(self._version, payload, sid=self._solution['sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class EventInstance(InstanceResource): """ """ def __init__(self, version, payload, sid=None): """ Initialize the EventInstance :returns: twilio.rest.monitor.v1.event.EventInstance :rtype: twilio.rest.monitor.v1.event.EventInstance """ super(EventInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'actor_sid': payload['actor_sid'], 'actor_type': payload['actor_type'], 'description': payload['description'], 'event_data': payload['event_data'], 'event_date': deserialize.iso8601_datetime(payload['event_date']), 'event_type': payload['event_type'], 'resource_sid': payload['resource_sid'], 'resource_type': payload['resource_type'], 'sid': payload['sid'], 'source': payload['source'], 'source_ip_address': payload['source_ip_address'], 'url': payload['url'], 'links': payload['links'], } # Context self._context = None self._solution = {'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: EventContext for this EventInstance :rtype: twilio.rest.monitor.v1.event.EventContext """ if self._context is None: self._context = EventContext(self._version, sid=self._solution['sid'],) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def actor_sid(self): """ :returns: The actor_sid :rtype: unicode """ return self._properties['actor_sid'] @property def actor_type(self): """ :returns: The actor_type :rtype: unicode """ return self._properties['actor_type'] @property def description(self): """ :returns: The description :rtype: unicode """ return self._properties['description'] @property def event_data(self): """ :returns: The event_data :rtype: dict """ return self._properties['event_data'] @property def event_date(self): """ :returns: The event_date :rtype: datetime """ return self._properties['event_date'] @property def event_type(self): """ :returns: The event_type :rtype: unicode """ return self._properties['event_type'] @property def resource_sid(self): """ :returns: The resource_sid :rtype: unicode """ return self._properties['resource_sid'] @property def resource_type(self): """ :returns: The resource_type :rtype: unicode """ return self._properties['resource_type'] @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def source(self): """ :returns: The source :rtype: unicode """ return self._properties['source'] @property def source_ip_address(self): """ :returns: The source_ip_address :rtype: unicode """ return self._properties['source_ip_address'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a EventInstance :returns: Fetched EventInstance :rtype: twilio.rest.monitor.v1.event.EventInstance """ return self._proxy.fetch() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/notify/000077500000000000000000000000001317472742600201665ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/notify/__init__.py000066400000000000000000000023651317472742600223050ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.domain import Domain from twilio.rest.notify.v1 import V1 class Notify(Domain): def __init__(self, twilio): """ Initialize the Notify Domain :returns: Domain for Notify :rtype: twilio.rest.notify.Notify """ super(Notify, self).__init__(twilio) self.base_url = 'https://notify.twilio.com' # Versions self._v1 = None @property def v1(self): """ :returns: Version v1 of notify :rtype: twilio.rest.notify.v1.V1 """ if self._v1 is None: self._v1 = V1(self) return self._v1 @property def credentials(self): """ :rtype: twilio.rest.notify.v1.credential.CredentialList """ return self.v1.credentials @property def services(self): """ :rtype: twilio.rest.notify.v1.service.ServiceList """ return self.v1.services def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/notify/v1/000077500000000000000000000000001317472742600205145ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/notify/v1/__init__.py000066400000000000000000000024211317472742600226240ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.version import Version from twilio.rest.notify.v1.credential import CredentialList from twilio.rest.notify.v1.service import ServiceList class V1(Version): def __init__(self, domain): """ Initialize the V1 version of Notify :returns: V1 version of Notify :rtype: twilio.rest.notify.v1.V1.V1 """ super(V1, self).__init__(domain) self.version = 'v1' self._credentials = None self._services = None @property def credentials(self): """ :rtype: twilio.rest.notify.v1.credential.CredentialList """ if self._credentials is None: self._credentials = CredentialList(self) return self._credentials @property def services(self): """ :rtype: twilio.rest.notify.v1.service.ServiceList """ if self._services is None: self._services = ServiceList(self) return self._services def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/notify/v1/credential.py000066400000000000000000000360021317472742600232010ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class CredentialList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version): """ Initialize the CredentialList :param Version version: Version that contains the resource :returns: twilio.rest.notify.v1.credential.CredentialList :rtype: twilio.rest.notify.v1.credential.CredentialList """ super(CredentialList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/Credentials'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams CredentialInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.notify.v1.credential.CredentialInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists CredentialInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.notify.v1.credential.CredentialInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of CredentialInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of CredentialInstance :rtype: twilio.rest.notify.v1.credential.CredentialPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return CredentialPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of CredentialInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of CredentialInstance :rtype: twilio.rest.notify.v1.credential.CredentialPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return CredentialPage(self._version, response, self._solution) def create(self, type, friendly_name=values.unset, certificate=values.unset, private_key=values.unset, sandbox=values.unset, api_key=values.unset, secret=values.unset): """ Create a new CredentialInstance :param CredentialInstance.PushService type: The type :param unicode friendly_name: The friendly_name :param unicode certificate: The certificate :param unicode private_key: The private_key :param bool sandbox: The sandbox :param unicode api_key: The api_key :param unicode secret: The secret :returns: Newly created CredentialInstance :rtype: twilio.rest.notify.v1.credential.CredentialInstance """ data = values.of({ 'Type': type, 'FriendlyName': friendly_name, 'Certificate': certificate, 'PrivateKey': private_key, 'Sandbox': sandbox, 'ApiKey': api_key, 'Secret': secret, }) payload = self._version.create( 'POST', self._uri, data=data, ) return CredentialInstance(self._version, payload,) def get(self, sid): """ Constructs a CredentialContext :param sid: The sid :returns: twilio.rest.notify.v1.credential.CredentialContext :rtype: twilio.rest.notify.v1.credential.CredentialContext """ return CredentialContext(self._version, sid=sid,) def __call__(self, sid): """ Constructs a CredentialContext :param sid: The sid :returns: twilio.rest.notify.v1.credential.CredentialContext :rtype: twilio.rest.notify.v1.credential.CredentialContext """ return CredentialContext(self._version, sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class CredentialPage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the CredentialPage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.notify.v1.credential.CredentialPage :rtype: twilio.rest.notify.v1.credential.CredentialPage """ super(CredentialPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of CredentialInstance :param dict payload: Payload response from the API :returns: twilio.rest.notify.v1.credential.CredentialInstance :rtype: twilio.rest.notify.v1.credential.CredentialInstance """ return CredentialInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class CredentialContext(InstanceContext): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, sid): """ Initialize the CredentialContext :param Version version: Version that contains the resource :param sid: The sid :returns: twilio.rest.notify.v1.credential.CredentialContext :rtype: twilio.rest.notify.v1.credential.CredentialContext """ super(CredentialContext, self).__init__(version) # Path Solution self._solution = {'sid': sid,} self._uri = '/Credentials/{sid}'.format(**self._solution) def fetch(self): """ Fetch a CredentialInstance :returns: Fetched CredentialInstance :rtype: twilio.rest.notify.v1.credential.CredentialInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return CredentialInstance(self._version, payload, sid=self._solution['sid'],) def update(self, friendly_name=values.unset, certificate=values.unset, private_key=values.unset, sandbox=values.unset, api_key=values.unset, secret=values.unset): """ Update the CredentialInstance :param unicode friendly_name: The friendly_name :param unicode certificate: The certificate :param unicode private_key: The private_key :param bool sandbox: The sandbox :param unicode api_key: The api_key :param unicode secret: The secret :returns: Updated CredentialInstance :rtype: twilio.rest.notify.v1.credential.CredentialInstance """ data = values.of({ 'FriendlyName': friendly_name, 'Certificate': certificate, 'PrivateKey': private_key, 'Sandbox': sandbox, 'ApiKey': api_key, 'Secret': secret, }) payload = self._version.update( 'POST', self._uri, data=data, ) return CredentialInstance(self._version, payload, sid=self._solution['sid'],) def delete(self): """ Deletes the CredentialInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class CredentialInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ class PushService(object): GCM = "gcm" APN = "apn" FCM = "fcm" def __init__(self, version, payload, sid=None): """ Initialize the CredentialInstance :returns: twilio.rest.notify.v1.credential.CredentialInstance :rtype: twilio.rest.notify.v1.credential.CredentialInstance """ super(CredentialInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'friendly_name': payload['friendly_name'], 'type': payload['type'], 'sandbox': payload['sandbox'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'url': payload['url'], } # Context self._context = None self._solution = {'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: CredentialContext for this CredentialInstance :rtype: twilio.rest.notify.v1.credential.CredentialContext """ if self._context is None: self._context = CredentialContext(self._version, sid=self._solution['sid'],) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def type(self): """ :returns: The type :rtype: CredentialInstance.PushService """ return self._properties['type'] @property def sandbox(self): """ :returns: The sandbox :rtype: unicode """ return self._properties['sandbox'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a CredentialInstance :returns: Fetched CredentialInstance :rtype: twilio.rest.notify.v1.credential.CredentialInstance """ return self._proxy.fetch() def update(self, friendly_name=values.unset, certificate=values.unset, private_key=values.unset, sandbox=values.unset, api_key=values.unset, secret=values.unset): """ Update the CredentialInstance :param unicode friendly_name: The friendly_name :param unicode certificate: The certificate :param unicode private_key: The private_key :param bool sandbox: The sandbox :param unicode api_key: The api_key :param unicode secret: The secret :returns: Updated CredentialInstance :rtype: twilio.rest.notify.v1.credential.CredentialInstance """ return self._proxy.update( friendly_name=friendly_name, certificate=certificate, private_key=private_key, sandbox=sandbox, api_key=api_key, secret=secret, ) def delete(self): """ Deletes the CredentialInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/notify/v1/service/000077500000000000000000000000001317472742600221545ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/notify/v1/service/__init__.py000066400000000000000000000635161317472742600243000ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.notify.v1.service.binding import BindingList from twilio.rest.notify.v1.service.notification import NotificationList from twilio.rest.notify.v1.service.segment import SegmentList from twilio.rest.notify.v1.service.user import UserList class ServiceList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version): """ Initialize the ServiceList :param Version version: Version that contains the resource :returns: twilio.rest.notify.v1.service.ServiceList :rtype: twilio.rest.notify.v1.service.ServiceList """ super(ServiceList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/Services'.format(**self._solution) def create(self, friendly_name=values.unset, apn_credential_sid=values.unset, gcm_credential_sid=values.unset, messaging_service_sid=values.unset, facebook_messenger_page_id=values.unset, default_apn_notification_protocol_version=values.unset, default_gcm_notification_protocol_version=values.unset, fcm_credential_sid=values.unset, default_fcm_notification_protocol_version=values.unset, log_enabled=values.unset, alexa_skill_id=values.unset, default_alexa_notification_protocol_version=values.unset): """ Create a new ServiceInstance :param unicode friendly_name: The friendly_name :param unicode apn_credential_sid: The apn_credential_sid :param unicode gcm_credential_sid: The gcm_credential_sid :param unicode messaging_service_sid: The messaging_service_sid :param unicode facebook_messenger_page_id: The facebook_messenger_page_id :param unicode default_apn_notification_protocol_version: The default_apn_notification_protocol_version :param unicode default_gcm_notification_protocol_version: The default_gcm_notification_protocol_version :param unicode fcm_credential_sid: The fcm_credential_sid :param unicode default_fcm_notification_protocol_version: The default_fcm_notification_protocol_version :param bool log_enabled: The log_enabled :param unicode alexa_skill_id: The alexa_skill_id :param unicode default_alexa_notification_protocol_version: The default_alexa_notification_protocol_version :returns: Newly created ServiceInstance :rtype: twilio.rest.notify.v1.service.ServiceInstance """ data = values.of({ 'FriendlyName': friendly_name, 'ApnCredentialSid': apn_credential_sid, 'GcmCredentialSid': gcm_credential_sid, 'MessagingServiceSid': messaging_service_sid, 'FacebookMessengerPageId': facebook_messenger_page_id, 'DefaultApnNotificationProtocolVersion': default_apn_notification_protocol_version, 'DefaultGcmNotificationProtocolVersion': default_gcm_notification_protocol_version, 'FcmCredentialSid': fcm_credential_sid, 'DefaultFcmNotificationProtocolVersion': default_fcm_notification_protocol_version, 'LogEnabled': log_enabled, 'AlexaSkillId': alexa_skill_id, 'DefaultAlexaNotificationProtocolVersion': default_alexa_notification_protocol_version, }) payload = self._version.create( 'POST', self._uri, data=data, ) return ServiceInstance(self._version, payload,) def stream(self, friendly_name=values.unset, limit=None, page_size=None): """ 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 unicode friendly_name: The friendly_name :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.notify.v1.service.ServiceInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(friendly_name=friendly_name, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, friendly_name=values.unset, limit=None, page_size=None): """ 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 unicode friendly_name: The friendly_name :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.notify.v1.service.ServiceInstance] """ return list(self.stream(friendly_name=friendly_name, limit=limit, page_size=page_size,)) def page(self, friendly_name=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of ServiceInstance records from the API. Request is executed immediately :param unicode friendly_name: The friendly_name :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of ServiceInstance :rtype: twilio.rest.notify.v1.service.ServicePage """ params = values.of({ 'FriendlyName': friendly_name, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return ServicePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of ServiceInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of ServiceInstance :rtype: twilio.rest.notify.v1.service.ServicePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return ServicePage(self._version, response, self._solution) def get(self, sid): """ Constructs a ServiceContext :param sid: The sid :returns: twilio.rest.notify.v1.service.ServiceContext :rtype: twilio.rest.notify.v1.service.ServiceContext """ return ServiceContext(self._version, sid=sid,) def __call__(self, sid): """ Constructs a ServiceContext :param sid: The sid :returns: twilio.rest.notify.v1.service.ServiceContext :rtype: twilio.rest.notify.v1.service.ServiceContext """ return ServiceContext(self._version, sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ServicePage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the ServicePage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.notify.v1.service.ServicePage :rtype: twilio.rest.notify.v1.service.ServicePage """ super(ServicePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of ServiceInstance :param dict payload: Payload response from the API :returns: twilio.rest.notify.v1.service.ServiceInstance :rtype: twilio.rest.notify.v1.service.ServiceInstance """ return ServiceInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ServiceContext(InstanceContext): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, sid): """ Initialize the ServiceContext :param Version version: Version that contains the resource :param sid: The sid :returns: twilio.rest.notify.v1.service.ServiceContext :rtype: twilio.rest.notify.v1.service.ServiceContext """ super(ServiceContext, self).__init__(version) # Path Solution self._solution = {'sid': sid,} self._uri = '/Services/{sid}'.format(**self._solution) # Dependents self._bindings = None self._notifications = None self._users = None self._segments = None def delete(self): """ Deletes the ServiceInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def fetch(self): """ Fetch a ServiceInstance :returns: Fetched ServiceInstance :rtype: twilio.rest.notify.v1.service.ServiceInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return ServiceInstance(self._version, payload, sid=self._solution['sid'],) def update(self, friendly_name=values.unset, apn_credential_sid=values.unset, gcm_credential_sid=values.unset, messaging_service_sid=values.unset, facebook_messenger_page_id=values.unset, default_apn_notification_protocol_version=values.unset, default_gcm_notification_protocol_version=values.unset, fcm_credential_sid=values.unset, default_fcm_notification_protocol_version=values.unset, log_enabled=values.unset, alexa_skill_id=values.unset, default_alexa_notification_protocol_version=values.unset): """ Update the ServiceInstance :param unicode friendly_name: The friendly_name :param unicode apn_credential_sid: The apn_credential_sid :param unicode gcm_credential_sid: The gcm_credential_sid :param unicode messaging_service_sid: The messaging_service_sid :param unicode facebook_messenger_page_id: The facebook_messenger_page_id :param unicode default_apn_notification_protocol_version: The default_apn_notification_protocol_version :param unicode default_gcm_notification_protocol_version: The default_gcm_notification_protocol_version :param unicode fcm_credential_sid: The fcm_credential_sid :param unicode default_fcm_notification_protocol_version: The default_fcm_notification_protocol_version :param bool log_enabled: The log_enabled :param unicode alexa_skill_id: The alexa_skill_id :param unicode default_alexa_notification_protocol_version: The default_alexa_notification_protocol_version :returns: Updated ServiceInstance :rtype: twilio.rest.notify.v1.service.ServiceInstance """ data = values.of({ 'FriendlyName': friendly_name, 'ApnCredentialSid': apn_credential_sid, 'GcmCredentialSid': gcm_credential_sid, 'MessagingServiceSid': messaging_service_sid, 'FacebookMessengerPageId': facebook_messenger_page_id, 'DefaultApnNotificationProtocolVersion': default_apn_notification_protocol_version, 'DefaultGcmNotificationProtocolVersion': default_gcm_notification_protocol_version, 'FcmCredentialSid': fcm_credential_sid, 'DefaultFcmNotificationProtocolVersion': default_fcm_notification_protocol_version, 'LogEnabled': log_enabled, 'AlexaSkillId': alexa_skill_id, 'DefaultAlexaNotificationProtocolVersion': default_alexa_notification_protocol_version, }) payload = self._version.update( 'POST', self._uri, data=data, ) return ServiceInstance(self._version, payload, sid=self._solution['sid'],) @property def bindings(self): """ Access the bindings :returns: twilio.rest.notify.v1.service.binding.BindingList :rtype: twilio.rest.notify.v1.service.binding.BindingList """ if self._bindings is None: self._bindings = BindingList(self._version, service_sid=self._solution['sid'],) return self._bindings @property def notifications(self): """ Access the notifications :returns: twilio.rest.notify.v1.service.notification.NotificationList :rtype: twilio.rest.notify.v1.service.notification.NotificationList """ if self._notifications is None: self._notifications = NotificationList(self._version, service_sid=self._solution['sid'],) return self._notifications @property def users(self): """ Access the users :returns: twilio.rest.notify.v1.service.user.UserList :rtype: twilio.rest.notify.v1.service.user.UserList """ if self._users is None: self._users = UserList(self._version, service_sid=self._solution['sid'],) return self._users @property def segments(self): """ Access the segments :returns: twilio.rest.notify.v1.service.segment.SegmentList :rtype: twilio.rest.notify.v1.service.segment.SegmentList """ if self._segments is None: self._segments = SegmentList(self._version, service_sid=self._solution['sid'],) return self._segments def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class ServiceInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, payload, sid=None): """ Initialize the ServiceInstance :returns: twilio.rest.notify.v1.service.ServiceInstance :rtype: twilio.rest.notify.v1.service.ServiceInstance """ super(ServiceInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'friendly_name': payload['friendly_name'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'apn_credential_sid': payload['apn_credential_sid'], 'gcm_credential_sid': payload['gcm_credential_sid'], 'fcm_credential_sid': payload['fcm_credential_sid'], 'messaging_service_sid': payload['messaging_service_sid'], 'facebook_messenger_page_id': payload['facebook_messenger_page_id'], 'default_apn_notification_protocol_version': payload['default_apn_notification_protocol_version'], 'default_gcm_notification_protocol_version': payload['default_gcm_notification_protocol_version'], 'default_fcm_notification_protocol_version': payload['default_fcm_notification_protocol_version'], 'log_enabled': payload['log_enabled'], 'url': payload['url'], 'links': payload['links'], 'alexa_skill_id': payload['alexa_skill_id'], 'default_alexa_notification_protocol_version': payload['default_alexa_notification_protocol_version'], } # Context self._context = None self._solution = {'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.notify.v1.service.ServiceContext """ if self._context is None: self._context = ServiceContext(self._version, sid=self._solution['sid'],) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def apn_credential_sid(self): """ :returns: The apn_credential_sid :rtype: unicode """ return self._properties['apn_credential_sid'] @property def gcm_credential_sid(self): """ :returns: The gcm_credential_sid :rtype: unicode """ return self._properties['gcm_credential_sid'] @property def fcm_credential_sid(self): """ :returns: The fcm_credential_sid :rtype: unicode """ return self._properties['fcm_credential_sid'] @property def messaging_service_sid(self): """ :returns: The messaging_service_sid :rtype: unicode """ return self._properties['messaging_service_sid'] @property def facebook_messenger_page_id(self): """ :returns: The facebook_messenger_page_id :rtype: unicode """ return self._properties['facebook_messenger_page_id'] @property def default_apn_notification_protocol_version(self): """ :returns: The default_apn_notification_protocol_version :rtype: unicode """ return self._properties['default_apn_notification_protocol_version'] @property def default_gcm_notification_protocol_version(self): """ :returns: The default_gcm_notification_protocol_version :rtype: unicode """ return self._properties['default_gcm_notification_protocol_version'] @property def default_fcm_notification_protocol_version(self): """ :returns: The default_fcm_notification_protocol_version :rtype: unicode """ return self._properties['default_fcm_notification_protocol_version'] @property def log_enabled(self): """ :returns: The log_enabled :rtype: bool """ return self._properties['log_enabled'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] @property def alexa_skill_id(self): """ :returns: The alexa_skill_id :rtype: unicode """ return self._properties['alexa_skill_id'] @property def default_alexa_notification_protocol_version(self): """ :returns: The default_alexa_notification_protocol_version :rtype: unicode """ return self._properties['default_alexa_notification_protocol_version'] def delete(self): """ Deletes the ServiceInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def fetch(self): """ Fetch a ServiceInstance :returns: Fetched ServiceInstance :rtype: twilio.rest.notify.v1.service.ServiceInstance """ return self._proxy.fetch() def update(self, friendly_name=values.unset, apn_credential_sid=values.unset, gcm_credential_sid=values.unset, messaging_service_sid=values.unset, facebook_messenger_page_id=values.unset, default_apn_notification_protocol_version=values.unset, default_gcm_notification_protocol_version=values.unset, fcm_credential_sid=values.unset, default_fcm_notification_protocol_version=values.unset, log_enabled=values.unset, alexa_skill_id=values.unset, default_alexa_notification_protocol_version=values.unset): """ Update the ServiceInstance :param unicode friendly_name: The friendly_name :param unicode apn_credential_sid: The apn_credential_sid :param unicode gcm_credential_sid: The gcm_credential_sid :param unicode messaging_service_sid: The messaging_service_sid :param unicode facebook_messenger_page_id: The facebook_messenger_page_id :param unicode default_apn_notification_protocol_version: The default_apn_notification_protocol_version :param unicode default_gcm_notification_protocol_version: The default_gcm_notification_protocol_version :param unicode fcm_credential_sid: The fcm_credential_sid :param unicode default_fcm_notification_protocol_version: The default_fcm_notification_protocol_version :param bool log_enabled: The log_enabled :param unicode alexa_skill_id: The alexa_skill_id :param unicode default_alexa_notification_protocol_version: The default_alexa_notification_protocol_version :returns: Updated ServiceInstance :rtype: twilio.rest.notify.v1.service.ServiceInstance """ return self._proxy.update( friendly_name=friendly_name, apn_credential_sid=apn_credential_sid, gcm_credential_sid=gcm_credential_sid, messaging_service_sid=messaging_service_sid, facebook_messenger_page_id=facebook_messenger_page_id, default_apn_notification_protocol_version=default_apn_notification_protocol_version, default_gcm_notification_protocol_version=default_gcm_notification_protocol_version, fcm_credential_sid=fcm_credential_sid, default_fcm_notification_protocol_version=default_fcm_notification_protocol_version, log_enabled=log_enabled, alexa_skill_id=alexa_skill_id, default_alexa_notification_protocol_version=default_alexa_notification_protocol_version, ) @property def bindings(self): """ Access the bindings :returns: twilio.rest.notify.v1.service.binding.BindingList :rtype: twilio.rest.notify.v1.service.binding.BindingList """ return self._proxy.bindings @property def notifications(self): """ Access the notifications :returns: twilio.rest.notify.v1.service.notification.NotificationList :rtype: twilio.rest.notify.v1.service.notification.NotificationList """ return self._proxy.notifications @property def users(self): """ Access the users :returns: twilio.rest.notify.v1.service.user.UserList :rtype: twilio.rest.notify.v1.service.user.UserList """ return self._proxy.users @property def segments(self): """ Access the segments :returns: twilio.rest.notify.v1.service.segment.SegmentList :rtype: twilio.rest.notify.v1.service.segment.SegmentList """ return self._proxy.segments def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/notify/v1/service/binding.py000066400000000000000000000406651317472742600241530ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize 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.page import Page class BindingList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid): """ Initialize the BindingList :param Version version: Version that contains the resource :param service_sid: The service_sid :returns: twilio.rest.notify.v1.service.binding.BindingList :rtype: twilio.rest.notify.v1.service.binding.BindingList """ super(BindingList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid,} self._uri = '/Services/{service_sid}/Bindings'.format(**self._solution) def create(self, identity, binding_type, address, tag=values.unset, notification_protocol_version=values.unset, credential_sid=values.unset, endpoint=values.unset): """ Create a new BindingInstance :param unicode identity: The identity :param BindingInstance.BindingType binding_type: The binding_type :param unicode address: The address :param unicode tag: The tag :param unicode notification_protocol_version: The notification_protocol_version :param unicode credential_sid: The credential_sid :param unicode endpoint: The endpoint :returns: Newly created BindingInstance :rtype: twilio.rest.notify.v1.service.binding.BindingInstance """ data = values.of({ 'Identity': identity, 'BindingType': binding_type, 'Address': address, 'Tag': tag, 'NotificationProtocolVersion': notification_protocol_version, 'CredentialSid': credential_sid, 'Endpoint': endpoint, }) payload = self._version.create( 'POST', self._uri, data=data, ) return BindingInstance(self._version, payload, service_sid=self._solution['service_sid'],) def stream(self, start_date=values.unset, end_date=values.unset, identity=values.unset, tag=values.unset, limit=None, page_size=None): """ Streams BindingInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param date start_date: The start_date :param date end_date: The end_date :param unicode identity: The identity :param unicode tag: The tag :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.notify.v1.service.binding.BindingInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( start_date=start_date, end_date=end_date, identity=identity, tag=tag, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, start_date=values.unset, end_date=values.unset, identity=values.unset, tag=values.unset, limit=None, page_size=None): """ Lists BindingInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param date start_date: The start_date :param date end_date: The end_date :param unicode identity: The identity :param unicode tag: The tag :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.notify.v1.service.binding.BindingInstance] """ return list(self.stream( start_date=start_date, end_date=end_date, identity=identity, tag=tag, limit=limit, page_size=page_size, )) def page(self, start_date=values.unset, end_date=values.unset, identity=values.unset, tag=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of BindingInstance records from the API. Request is executed immediately :param date start_date: The start_date :param date end_date: The end_date :param unicode identity: The identity :param unicode tag: The tag :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of BindingInstance :rtype: twilio.rest.notify.v1.service.binding.BindingPage """ params = values.of({ 'StartDate': serialize.iso8601_date(start_date), 'EndDate': serialize.iso8601_date(end_date), 'Identity': identity, 'Tag': tag, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return BindingPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of BindingInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of BindingInstance :rtype: twilio.rest.notify.v1.service.binding.BindingPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return BindingPage(self._version, response, self._solution) def get(self, sid): """ Constructs a BindingContext :param sid: The sid :returns: twilio.rest.notify.v1.service.binding.BindingContext :rtype: twilio.rest.notify.v1.service.binding.BindingContext """ return BindingContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __call__(self, sid): """ Constructs a BindingContext :param sid: The sid :returns: twilio.rest.notify.v1.service.binding.BindingContext :rtype: twilio.rest.notify.v1.service.binding.BindingContext """ return BindingContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class BindingPage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the BindingPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :returns: twilio.rest.notify.v1.service.binding.BindingPage :rtype: twilio.rest.notify.v1.service.binding.BindingPage """ super(BindingPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of BindingInstance :param dict payload: Payload response from the API :returns: twilio.rest.notify.v1.service.binding.BindingInstance :rtype: twilio.rest.notify.v1.service.binding.BindingInstance """ return BindingInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class BindingContext(InstanceContext): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid, sid): """ Initialize the BindingContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param sid: The sid :returns: twilio.rest.notify.v1.service.binding.BindingContext :rtype: twilio.rest.notify.v1.service.binding.BindingContext """ super(BindingContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Bindings/{sid}'.format(**self._solution) def fetch(self): """ Fetch a BindingInstance :returns: Fetched BindingInstance :rtype: twilio.rest.notify.v1.service.binding.BindingInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return BindingInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the BindingInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class BindingInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ class BindingType(object): APN = "apn" GCM = "gcm" SMS = "sms" FCM = "fcm" FACEBOOK_MESSENGER = "facebook-messenger" ALEXA = "alexa" def __init__(self, version, payload, service_sid, sid=None): """ Initialize the BindingInstance :returns: twilio.rest.notify.v1.service.binding.BindingInstance :rtype: twilio.rest.notify.v1.service.binding.BindingInstance """ super(BindingInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'credential_sid': payload['credential_sid'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'notification_protocol_version': payload['notification_protocol_version'], 'endpoint': payload['endpoint'], 'identity': payload['identity'], 'binding_type': payload['binding_type'], 'address': payload['address'], 'tags': payload['tags'], 'url': payload['url'], 'links': payload['links'], } # Context self._context = None self._solution = {'service_sid': service_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: BindingContext for this BindingInstance :rtype: twilio.rest.notify.v1.service.binding.BindingContext """ if self._context is None: self._context = BindingContext( self._version, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def credential_sid(self): """ :returns: The credential_sid :rtype: unicode """ return self._properties['credential_sid'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def notification_protocol_version(self): """ :returns: The notification_protocol_version :rtype: unicode """ return self._properties['notification_protocol_version'] @property def endpoint(self): """ :returns: The endpoint :rtype: unicode """ return self._properties['endpoint'] @property def identity(self): """ :returns: The identity :rtype: unicode """ return self._properties['identity'] @property def binding_type(self): """ :returns: The binding_type :rtype: unicode """ return self._properties['binding_type'] @property def address(self): """ :returns: The address :rtype: unicode """ return self._properties['address'] @property def tags(self): """ :returns: The tags :rtype: unicode """ return self._properties['tags'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a BindingInstance :returns: Fetched BindingInstance :rtype: twilio.rest.notify.v1.service.binding.BindingInstance """ return self._proxy.fetch() def delete(self): """ Deletes the BindingInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/notify/v1/service/notification.py000066400000000000000000000233571317472742600252260ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class NotificationList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid): """ Initialize the NotificationList :param Version version: Version that contains the resource :param service_sid: The service_sid :returns: twilio.rest.notify.v1.service.notification.NotificationList :rtype: twilio.rest.notify.v1.service.notification.NotificationList """ super(NotificationList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid,} self._uri = '/Services/{service_sid}/Notifications'.format(**self._solution) def create(self, body=values.unset, priority=values.unset, ttl=values.unset, title=values.unset, sound=values.unset, action=values.unset, data=values.unset, apn=values.unset, gcm=values.unset, sms=values.unset, facebook_messenger=values.unset, fcm=values.unset, segment=values.unset, alexa=values.unset, to_binding=values.unset, identity=values.unset, tag=values.unset): """ Create a new NotificationInstance :param unicode body: The body :param NotificationInstance.Priority priority: The priority :param unicode ttl: The ttl :param unicode title: The title :param unicode sound: The sound :param unicode action: The action :param dict data: The data :param dict apn: The apn :param dict gcm: The gcm :param dict sms: The sms :param dict facebook_messenger: The facebook_messenger :param dict fcm: The fcm :param unicode segment: The segment :param dict alexa: The alexa :param unicode to_binding: The to_binding :param unicode identity: The identity :param unicode tag: The tag :returns: Newly created NotificationInstance :rtype: twilio.rest.notify.v1.service.notification.NotificationInstance """ data = values.of({ 'Identity': identity, 'Tag': tag, 'Body': body, 'Priority': priority, 'Ttl': ttl, 'Title': title, 'Sound': sound, 'Action': action, 'Data': serialize.object(data), 'Apn': serialize.object(apn), 'Gcm': serialize.object(gcm), 'Sms': serialize.object(sms), 'FacebookMessenger': serialize.object(facebook_messenger), 'Fcm': serialize.object(fcm), 'Segment': segment, 'Alexa': serialize.object(alexa), 'ToBinding': to_binding, }) payload = self._version.create( 'POST', self._uri, data=data, ) return NotificationInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class NotificationPage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the NotificationPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :returns: twilio.rest.notify.v1.service.notification.NotificationPage :rtype: twilio.rest.notify.v1.service.notification.NotificationPage """ super(NotificationPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of NotificationInstance :param dict payload: Payload response from the API :returns: twilio.rest.notify.v1.service.notification.NotificationInstance :rtype: twilio.rest.notify.v1.service.notification.NotificationInstance """ return NotificationInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class NotificationInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ class Priority(object): HIGH = "high" LOW = "low" def __init__(self, version, payload, service_sid): """ Initialize the NotificationInstance :returns: twilio.rest.notify.v1.service.notification.NotificationInstance :rtype: twilio.rest.notify.v1.service.notification.NotificationInstance """ super(NotificationInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'identities': payload['identities'], 'tags': payload['tags'], 'segments': payload['segments'], 'priority': payload['priority'], 'ttl': deserialize.integer(payload['ttl']), 'title': payload['title'], 'body': payload['body'], 'sound': payload['sound'], 'action': payload['action'], 'data': payload['data'], 'apn': payload['apn'], 'gcm': payload['gcm'], 'fcm': payload['fcm'], 'sms': payload['sms'], 'facebook_messenger': payload['facebook_messenger'], 'alexa': payload['alexa'], } # Context self._context = None self._solution = {'service_sid': service_sid,} @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def identities(self): """ :returns: The identities :rtype: unicode """ return self._properties['identities'] @property def tags(self): """ :returns: The tags :rtype: unicode """ return self._properties['tags'] @property def segments(self): """ :returns: The segments :rtype: unicode """ return self._properties['segments'] @property def priority(self): """ :returns: The priority :rtype: NotificationInstance.Priority """ return self._properties['priority'] @property def ttl(self): """ :returns: The ttl :rtype: unicode """ return self._properties['ttl'] @property def title(self): """ :returns: The title :rtype: unicode """ return self._properties['title'] @property def body(self): """ :returns: The body :rtype: unicode """ return self._properties['body'] @property def sound(self): """ :returns: The sound :rtype: unicode """ return self._properties['sound'] @property def action(self): """ :returns: The action :rtype: unicode """ return self._properties['action'] @property def data(self): """ :returns: The data :rtype: dict """ return self._properties['data'] @property def apn(self): """ :returns: The apn :rtype: dict """ return self._properties['apn'] @property def gcm(self): """ :returns: The gcm :rtype: dict """ return self._properties['gcm'] @property def fcm(self): """ :returns: The fcm :rtype: dict """ return self._properties['fcm'] @property def sms(self): """ :returns: The sms :rtype: dict """ return self._properties['sms'] @property def facebook_messenger(self): """ :returns: The facebook_messenger :rtype: dict """ return self._properties['facebook_messenger'] @property def alexa(self): """ :returns: The alexa :rtype: dict """ return self._properties['alexa'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/notify/v1/service/segment.py000066400000000000000000000203401317472742600241670ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class SegmentList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid): """ Initialize the SegmentList :param Version version: Version that contains the resource :param service_sid: The service_sid :returns: twilio.rest.notify.v1.service.segment.SegmentList :rtype: twilio.rest.notify.v1.service.segment.SegmentList """ super(SegmentList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid,} self._uri = '/Services/{service_sid}/Segments'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams SegmentInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.notify.v1.service.segment.SegmentInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists SegmentInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.notify.v1.service.segment.SegmentInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of SegmentInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of SegmentInstance :rtype: twilio.rest.notify.v1.service.segment.SegmentPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return SegmentPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of SegmentInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of SegmentInstance :rtype: twilio.rest.notify.v1.service.segment.SegmentPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return SegmentPage(self._version, response, self._solution) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SegmentPage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the SegmentPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :returns: twilio.rest.notify.v1.service.segment.SegmentPage :rtype: twilio.rest.notify.v1.service.segment.SegmentPage """ super(SegmentPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of SegmentInstance :param dict payload: Payload response from the API :returns: twilio.rest.notify.v1.service.segment.SegmentInstance :rtype: twilio.rest.notify.v1.service.segment.SegmentInstance """ return SegmentInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SegmentInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, payload, service_sid): """ Initialize the SegmentInstance :returns: twilio.rest.notify.v1.service.segment.SegmentInstance :rtype: twilio.rest.notify.v1.service.segment.SegmentInstance """ super(SegmentInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'unique_name': payload['unique_name'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), } # Context self._context = None self._solution = {'service_sid': service_sid,} @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def unique_name(self): """ :returns: The unique_name :rtype: unicode """ return self._properties['unique_name'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/notify/v1/service/user/000077500000000000000000000000001317472742600231325ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/notify/v1/service/user/__init__.py000066400000000000000000000370461317472742600252550ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.notify.v1.service.user.segment_memberships import SegmentMembershipList from twilio.rest.notify.v1.service.user.user_binding import UserBindingList class UserList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid): """ Initialize the UserList :param Version version: Version that contains the resource :param service_sid: The service_sid :returns: twilio.rest.notify.v1.service.user.UserList :rtype: twilio.rest.notify.v1.service.user.UserList """ super(UserList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid,} self._uri = '/Services/{service_sid}/Users'.format(**self._solution) def create(self, identity, segment=values.unset): """ Create a new UserInstance :param unicode identity: The identity :param unicode segment: The segment :returns: Newly created UserInstance :rtype: twilio.rest.notify.v1.service.user.UserInstance """ data = values.of({'Identity': identity, 'Segment': segment,}) payload = self._version.create( 'POST', self._uri, data=data, ) return UserInstance(self._version, payload, service_sid=self._solution['service_sid'],) def stream(self, identity=values.unset, segment=values.unset, limit=None, page_size=None): """ 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 unicode identity: The identity :param unicode segment: The segment :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.notify.v1.service.user.UserInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(identity=identity, segment=segment, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, identity=values.unset, segment=values.unset, limit=None, page_size=None): """ 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 unicode identity: The identity :param unicode segment: The segment :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.notify.v1.service.user.UserInstance] """ return list(self.stream(identity=identity, segment=segment, limit=limit, page_size=page_size,)) def page(self, identity=values.unset, segment=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of UserInstance records from the API. Request is executed immediately :param unicode identity: The identity :param unicode segment: The segment :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of UserInstance :rtype: twilio.rest.notify.v1.service.user.UserPage """ params = values.of({ 'Identity': identity, 'Segment': segment, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return UserPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of UserInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of UserInstance :rtype: twilio.rest.notify.v1.service.user.UserPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return UserPage(self._version, response, self._solution) def get(self, identity): """ Constructs a UserContext :param identity: The identity :returns: twilio.rest.notify.v1.service.user.UserContext :rtype: twilio.rest.notify.v1.service.user.UserContext """ return UserContext(self._version, service_sid=self._solution['service_sid'], identity=identity,) def __call__(self, identity): """ Constructs a UserContext :param identity: The identity :returns: twilio.rest.notify.v1.service.user.UserContext :rtype: twilio.rest.notify.v1.service.user.UserContext """ return UserContext(self._version, service_sid=self._solution['service_sid'], identity=identity,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class UserPage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the UserPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :returns: twilio.rest.notify.v1.service.user.UserPage :rtype: twilio.rest.notify.v1.service.user.UserPage """ super(UserPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of UserInstance :param dict payload: Payload response from the API :returns: twilio.rest.notify.v1.service.user.UserInstance :rtype: twilio.rest.notify.v1.service.user.UserInstance """ return UserInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class UserContext(InstanceContext): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid, identity): """ Initialize the UserContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param identity: The identity :returns: twilio.rest.notify.v1.service.user.UserContext :rtype: twilio.rest.notify.v1.service.user.UserContext """ super(UserContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'identity': identity,} self._uri = '/Services/{service_sid}/Users/{identity}'.format(**self._solution) # Dependents self._bindings = None self._segment_memberships = None def delete(self): """ Deletes the UserInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def fetch(self): """ Fetch a UserInstance :returns: Fetched UserInstance :rtype: twilio.rest.notify.v1.service.user.UserInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return UserInstance( self._version, payload, service_sid=self._solution['service_sid'], identity=self._solution['identity'], ) @property def bindings(self): """ Access the bindings :returns: twilio.rest.notify.v1.service.user.user_binding.UserBindingList :rtype: twilio.rest.notify.v1.service.user.user_binding.UserBindingList """ if self._bindings is None: self._bindings = UserBindingList( self._version, service_sid=self._solution['service_sid'], identity=self._solution['identity'], ) return self._bindings @property def segment_memberships(self): """ Access the segment_memberships :returns: twilio.rest.notify.v1.service.user.segment_memberships.SegmentMembershipList :rtype: twilio.rest.notify.v1.service.user.segment_memberships.SegmentMembershipList """ if self._segment_memberships is None: self._segment_memberships = SegmentMembershipList( self._version, service_sid=self._solution['service_sid'], identity=self._solution['identity'], ) return self._segment_memberships def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class UserInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, payload, service_sid, identity=None): """ Initialize the UserInstance :returns: twilio.rest.notify.v1.service.user.UserInstance :rtype: twilio.rest.notify.v1.service.user.UserInstance """ super(UserInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'identity': payload['identity'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'segments': payload['segments'], 'url': payload['url'], 'links': payload['links'], } # Context self._context = None self._solution = {'service_sid': service_sid, 'identity': identity or self._properties['identity'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.notify.v1.service.user.UserContext """ if self._context is None: self._context = UserContext( self._version, service_sid=self._solution['service_sid'], identity=self._solution['identity'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def identity(self): """ :returns: The identity :rtype: unicode """ return self._properties['identity'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def segments(self): """ :returns: The segments :rtype: unicode """ return self._properties['segments'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def delete(self): """ Deletes the UserInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def fetch(self): """ Fetch a UserInstance :returns: Fetched UserInstance :rtype: twilio.rest.notify.v1.service.user.UserInstance """ return self._proxy.fetch() @property def bindings(self): """ Access the bindings :returns: twilio.rest.notify.v1.service.user.user_binding.UserBindingList :rtype: twilio.rest.notify.v1.service.user.user_binding.UserBindingList """ return self._proxy.bindings @property def segment_memberships(self): """ Access the segment_memberships :returns: twilio.rest.notify.v1.service.user.segment_memberships.SegmentMembershipList :rtype: twilio.rest.notify.v1.service.user.segment_memberships.SegmentMembershipList """ return self._proxy.segment_memberships def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/notify/v1/service/user/segment_memberships.py000066400000000000000000000243511317472742600275510ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ 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.page import Page class SegmentMembershipList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid, identity): """ Initialize the SegmentMembershipList :param Version version: Version that contains the resource :param service_sid: The service_sid :param identity: The identity :returns: twilio.rest.notify.v1.service.user.segment_memberships.SegmentMembershipList :rtype: twilio.rest.notify.v1.service.user.segment_memberships.SegmentMembershipList """ super(SegmentMembershipList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'identity': identity,} self._uri = '/Services/{service_sid}/Users/{identity}/SegmentMemberships'.format(**self._solution) def create(self, segment): """ Create a new SegmentMembershipInstance :param unicode segment: The segment :returns: Newly created SegmentMembershipInstance :rtype: twilio.rest.notify.v1.service.user.segment_memberships.SegmentMembershipInstance """ data = values.of({'Segment': segment,}) payload = self._version.create( 'POST', self._uri, data=data, ) return SegmentMembershipInstance( self._version, payload, service_sid=self._solution['service_sid'], identity=self._solution['identity'], ) def get(self, segment): """ Constructs a SegmentMembershipContext :param segment: The segment :returns: twilio.rest.notify.v1.service.user.segment_memberships.SegmentMembershipContext :rtype: twilio.rest.notify.v1.service.user.segment_memberships.SegmentMembershipContext """ return SegmentMembershipContext( self._version, service_sid=self._solution['service_sid'], identity=self._solution['identity'], segment=segment, ) def __call__(self, segment): """ Constructs a SegmentMembershipContext :param segment: The segment :returns: twilio.rest.notify.v1.service.user.segment_memberships.SegmentMembershipContext :rtype: twilio.rest.notify.v1.service.user.segment_memberships.SegmentMembershipContext """ return SegmentMembershipContext( self._version, service_sid=self._solution['service_sid'], identity=self._solution['identity'], segment=segment, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SegmentMembershipPage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the SegmentMembershipPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :param identity: The identity :returns: twilio.rest.notify.v1.service.user.segment_memberships.SegmentMembershipPage :rtype: twilio.rest.notify.v1.service.user.segment_memberships.SegmentMembershipPage """ super(SegmentMembershipPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of SegmentMembershipInstance :param dict payload: Payload response from the API :returns: twilio.rest.notify.v1.service.user.segment_memberships.SegmentMembershipInstance :rtype: twilio.rest.notify.v1.service.user.segment_memberships.SegmentMembershipInstance """ return SegmentMembershipInstance( self._version, payload, service_sid=self._solution['service_sid'], identity=self._solution['identity'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SegmentMembershipContext(InstanceContext): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid, identity, segment): """ Initialize the SegmentMembershipContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param identity: The identity :param segment: The segment :returns: twilio.rest.notify.v1.service.user.segment_memberships.SegmentMembershipContext :rtype: twilio.rest.notify.v1.service.user.segment_memberships.SegmentMembershipContext """ super(SegmentMembershipContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'identity': identity, 'segment': segment,} self._uri = '/Services/{service_sid}/Users/{identity}/SegmentMemberships/{segment}'.format(**self._solution) def delete(self): """ Deletes the SegmentMembershipInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def fetch(self): """ Fetch a SegmentMembershipInstance :returns: Fetched SegmentMembershipInstance :rtype: twilio.rest.notify.v1.service.user.segment_memberships.SegmentMembershipInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return SegmentMembershipInstance( self._version, payload, service_sid=self._solution['service_sid'], identity=self._solution['identity'], segment=self._solution['segment'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class SegmentMembershipInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, payload, service_sid, identity, segment=None): """ Initialize the SegmentMembershipInstance :returns: twilio.rest.notify.v1.service.user.segment_memberships.SegmentMembershipInstance :rtype: twilio.rest.notify.v1.service.user.segment_memberships.SegmentMembershipInstance """ super(SegmentMembershipInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'identity': payload['identity'], 'segment': payload['segment'], 'url': payload['url'], } # Context self._context = None self._solution = { 'service_sid': service_sid, 'identity': identity, 'segment': segment or self._properties['segment'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: SegmentMembershipContext for this SegmentMembershipInstance :rtype: twilio.rest.notify.v1.service.user.segment_memberships.SegmentMembershipContext """ if self._context is None: self._context = SegmentMembershipContext( self._version, service_sid=self._solution['service_sid'], identity=self._solution['identity'], segment=self._solution['segment'], ) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def identity(self): """ :returns: The identity :rtype: unicode """ return self._properties['identity'] @property def segment(self): """ :returns: The segment :rtype: unicode """ return self._properties['segment'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def delete(self): """ Deletes the SegmentMembershipInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def fetch(self): """ Fetch a SegmentMembershipInstance :returns: Fetched SegmentMembershipInstance :rtype: twilio.rest.notify.v1.service.user.segment_memberships.SegmentMembershipInstance """ return self._proxy.fetch() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/notify/v1/service/user/user_binding.py000066400000000000000000000423321317472742600261600ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize 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.page import Page class UserBindingList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid, identity): """ Initialize the UserBindingList :param Version version: Version that contains the resource :param service_sid: The service_sid :param identity: The identity :returns: twilio.rest.notify.v1.service.user.user_binding.UserBindingList :rtype: twilio.rest.notify.v1.service.user.user_binding.UserBindingList """ super(UserBindingList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'identity': identity,} self._uri = '/Services/{service_sid}/Users/{identity}/Bindings'.format(**self._solution) def create(self, binding_type, address, tag=values.unset, notification_protocol_version=values.unset, credential_sid=values.unset, endpoint=values.unset): """ Create a new UserBindingInstance :param UserBindingInstance.BindingType binding_type: The binding_type :param unicode address: The address :param unicode tag: The tag :param unicode notification_protocol_version: The notification_protocol_version :param unicode credential_sid: The credential_sid :param unicode endpoint: The endpoint :returns: Newly created UserBindingInstance :rtype: twilio.rest.notify.v1.service.user.user_binding.UserBindingInstance """ data = values.of({ 'BindingType': binding_type, 'Address': address, 'Tag': tag, 'NotificationProtocolVersion': notification_protocol_version, 'CredentialSid': credential_sid, 'Endpoint': endpoint, }) payload = self._version.create( 'POST', self._uri, data=data, ) return UserBindingInstance( self._version, payload, service_sid=self._solution['service_sid'], identity=self._solution['identity'], ) def stream(self, start_date=values.unset, end_date=values.unset, tag=values.unset, limit=None, page_size=None): """ Streams UserBindingInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param date start_date: The start_date :param date end_date: The end_date :param unicode tag: The tag :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.notify.v1.service.user.user_binding.UserBindingInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(start_date=start_date, end_date=end_date, tag=tag, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, start_date=values.unset, end_date=values.unset, tag=values.unset, limit=None, page_size=None): """ Lists UserBindingInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param date start_date: The start_date :param date end_date: The end_date :param unicode tag: The tag :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.notify.v1.service.user.user_binding.UserBindingInstance] """ return list(self.stream( start_date=start_date, end_date=end_date, tag=tag, limit=limit, page_size=page_size, )) def page(self, start_date=values.unset, end_date=values.unset, tag=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of UserBindingInstance records from the API. Request is executed immediately :param date start_date: The start_date :param date end_date: The end_date :param unicode tag: The tag :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of UserBindingInstance :rtype: twilio.rest.notify.v1.service.user.user_binding.UserBindingPage """ params = values.of({ 'StartDate': serialize.iso8601_date(start_date), 'EndDate': serialize.iso8601_date(end_date), 'Tag': tag, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return UserBindingPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of UserBindingInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of UserBindingInstance :rtype: twilio.rest.notify.v1.service.user.user_binding.UserBindingPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return UserBindingPage(self._version, response, self._solution) def get(self, sid): """ Constructs a UserBindingContext :param sid: The sid :returns: twilio.rest.notify.v1.service.user.user_binding.UserBindingContext :rtype: twilio.rest.notify.v1.service.user.user_binding.UserBindingContext """ return UserBindingContext( self._version, service_sid=self._solution['service_sid'], identity=self._solution['identity'], sid=sid, ) def __call__(self, sid): """ Constructs a UserBindingContext :param sid: The sid :returns: twilio.rest.notify.v1.service.user.user_binding.UserBindingContext :rtype: twilio.rest.notify.v1.service.user.user_binding.UserBindingContext """ return UserBindingContext( self._version, service_sid=self._solution['service_sid'], identity=self._solution['identity'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class UserBindingPage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the UserBindingPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :param identity: The identity :returns: twilio.rest.notify.v1.service.user.user_binding.UserBindingPage :rtype: twilio.rest.notify.v1.service.user.user_binding.UserBindingPage """ super(UserBindingPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of UserBindingInstance :param dict payload: Payload response from the API :returns: twilio.rest.notify.v1.service.user.user_binding.UserBindingInstance :rtype: twilio.rest.notify.v1.service.user.user_binding.UserBindingInstance """ return UserBindingInstance( self._version, payload, service_sid=self._solution['service_sid'], identity=self._solution['identity'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class UserBindingContext(InstanceContext): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid, identity, sid): """ Initialize the UserBindingContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param identity: The identity :param sid: The sid :returns: twilio.rest.notify.v1.service.user.user_binding.UserBindingContext :rtype: twilio.rest.notify.v1.service.user.user_binding.UserBindingContext """ super(UserBindingContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'identity': identity, 'sid': sid,} self._uri = '/Services/{service_sid}/Users/{identity}/Bindings/{sid}'.format(**self._solution) def fetch(self): """ Fetch a UserBindingInstance :returns: Fetched UserBindingInstance :rtype: twilio.rest.notify.v1.service.user.user_binding.UserBindingInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return UserBindingInstance( self._version, payload, service_sid=self._solution['service_sid'], identity=self._solution['identity'], sid=self._solution['sid'], ) def delete(self): """ Deletes the UserBindingInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class UserBindingInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ class BindingType(object): APN = "apn" GCM = "gcm" SMS = "sms" FCM = "fcm" FACEBOOK_MESSENGER = "facebook-messenger" ALEXA = "alexa" def __init__(self, version, payload, service_sid, identity, sid=None): """ Initialize the UserBindingInstance :returns: twilio.rest.notify.v1.service.user.user_binding.UserBindingInstance :rtype: twilio.rest.notify.v1.service.user.user_binding.UserBindingInstance """ super(UserBindingInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'credential_sid': payload['credential_sid'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'notification_protocol_version': payload['notification_protocol_version'], 'endpoint': payload['endpoint'], 'identity': payload['identity'], 'binding_type': payload['binding_type'], 'address': payload['address'], 'tags': payload['tags'], 'url': payload['url'], 'links': payload['links'], } # Context self._context = None self._solution = { 'service_sid': service_sid, 'identity': identity, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: UserBindingContext for this UserBindingInstance :rtype: twilio.rest.notify.v1.service.user.user_binding.UserBindingContext """ if self._context is None: self._context = UserBindingContext( self._version, service_sid=self._solution['service_sid'], identity=self._solution['identity'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def credential_sid(self): """ :returns: The credential_sid :rtype: unicode """ return self._properties['credential_sid'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def notification_protocol_version(self): """ :returns: The notification_protocol_version :rtype: unicode """ return self._properties['notification_protocol_version'] @property def endpoint(self): """ :returns: The endpoint :rtype: unicode """ return self._properties['endpoint'] @property def identity(self): """ :returns: The identity :rtype: unicode """ return self._properties['identity'] @property def binding_type(self): """ :returns: The binding_type :rtype: unicode """ return self._properties['binding_type'] @property def address(self): """ :returns: The address :rtype: unicode """ return self._properties['address'] @property def tags(self): """ :returns: The tags :rtype: unicode """ return self._properties['tags'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a UserBindingInstance :returns: Fetched UserBindingInstance :rtype: twilio.rest.notify.v1.service.user.user_binding.UserBindingInstance """ return self._proxy.fetch() def delete(self): """ Deletes the UserBindingInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/preview/000077500000000000000000000000001317472742600203375ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/preview/__init__.py000066400000000000000000000132051317472742600224510ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.domain import Domain from twilio.rest.preview.acc_security import AccSecurity from twilio.rest.preview.bulk_exports import BulkExports from twilio.rest.preview.deployed_devices import DeployedDevices from twilio.rest.preview.hosted_numbers import HostedNumbers from twilio.rest.preview.marketplace import Marketplace from twilio.rest.preview.proxy import Proxy from twilio.rest.preview.sync import Sync from twilio.rest.preview.wireless import Wireless class Preview(Domain): def __init__(self, twilio): """ Initialize the Preview Domain :returns: Domain for Preview :rtype: twilio.rest.preview.Preview """ super(Preview, self).__init__(twilio) self.base_url = 'https://preview.twilio.com' # Versions self._bulk_exports = None self._deployed_devices = None self._hosted_numbers = None self._marketplace = None self._proxy = None self._acc_security = None self._sync = None self._wireless = None @property def bulk_exports(self): """ :returns: Version bulk_exports of preview :rtype: twilio.rest.preview.bulk_exports.BulkExports """ if self._bulk_exports is None: self._bulk_exports = BulkExports(self) return self._bulk_exports @property def deployed_devices(self): """ :returns: Version deployed_devices of preview :rtype: twilio.rest.preview.deployed_devices.DeployedDevices """ if self._deployed_devices is None: self._deployed_devices = DeployedDevices(self) return self._deployed_devices @property def hosted_numbers(self): """ :returns: Version hosted_numbers of preview :rtype: twilio.rest.preview.hosted_numbers.HostedNumbers """ if self._hosted_numbers is None: self._hosted_numbers = HostedNumbers(self) return self._hosted_numbers @property def marketplace(self): """ :returns: Version marketplace of preview :rtype: twilio.rest.preview.marketplace.Marketplace """ if self._marketplace is None: self._marketplace = Marketplace(self) return self._marketplace @property def proxy(self): """ :returns: Version proxy of preview :rtype: twilio.rest.preview.proxy.Proxy """ if self._proxy is None: self._proxy = Proxy(self) return self._proxy @property def acc_security(self): """ :returns: Version acc_security of preview :rtype: twilio.rest.preview.acc_security.AccSecurity """ if self._acc_security is None: self._acc_security = AccSecurity(self) return self._acc_security @property def sync(self): """ :returns: Version sync of preview :rtype: twilio.rest.preview.sync.Sync """ if self._sync is None: self._sync = Sync(self) return self._sync @property def wireless(self): """ :returns: Version wireless of preview :rtype: twilio.rest.preview.wireless.Wireless """ if self._wireless is None: self._wireless = Wireless(self) return self._wireless @property def exports(self): """ :rtype: twilio.rest.preview.bulk_exports.export.ExportList """ return self.bulk_exports.exports @property def export_configuration(self): """ :rtype: twilio.rest.preview.bulk_exports.export_configuration.ExportConfigurationList """ return self.bulk_exports.export_configuration @property def fleets(self): """ :rtype: twilio.rest.preview.deployed_devices.fleet.FleetList """ return self.deployed_devices.fleets @property def authorization_documents(self): """ :rtype: twilio.rest.preview.hosted_numbers.authorization_document.AuthorizationDocumentList """ return self.hosted_numbers.authorization_documents @property def hosted_number_orders(self): """ :rtype: twilio.rest.preview.hosted_numbers.hosted_number_order.HostedNumberOrderList """ return self.hosted_numbers.hosted_number_orders @property def available_add_ons(self): """ :rtype: twilio.rest.preview.marketplace.available_add_on.AvailableAddOnList """ return self.marketplace.available_add_ons @property def installed_add_ons(self): """ :rtype: twilio.rest.preview.marketplace.installed_add_on.InstalledAddOnList """ return self.marketplace.installed_add_ons @property def services(self): """ :rtype: twilio.rest.preview.sync.service.ServiceList """ return self.sync.services @property def commands(self): """ :rtype: twilio.rest.preview.wireless.command.CommandList """ return self.wireless.commands @property def rate_plans(self): """ :rtype: twilio.rest.preview.wireless.rate_plan.RatePlanList """ return self.wireless.rate_plans @property def sims(self): """ :rtype: twilio.rest.preview.wireless.sim.SimList """ return self.wireless.sims def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/preview/acc_security/000077500000000000000000000000001317472742600230145ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/preview/acc_security/__init__.py000066400000000000000000000020431317472742600251240ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.version import Version from twilio.rest.preview.acc_security.service import ServiceList class AccSecurity(Version): def __init__(self, domain): """ Initialize the AccSecurity version of Preview :returns: AccSecurity version of Preview :rtype: twilio.rest.preview.acc_security.AccSecurity.AccSecurity """ super(AccSecurity, self).__init__(domain) self.version = 'Verification' self._services = None @property def services(self): """ :rtype: twilio.rest.preview.acc_security.service.ServiceList """ if self._services is None: self._services = ServiceList(self) return self._services def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/preview/acc_security/service/000077500000000000000000000000001317472742600244545ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/preview/acc_security/service/__init__.py000066400000000000000000000370041317472742600265710ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.preview.acc_security.service.verification import VerificationList from twilio.rest.preview.acc_security.service.verification_check import VerificationCheckList class ServiceList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version): """ Initialize the ServiceList :param Version version: Version that contains the resource :returns: twilio.rest.preview.acc_security.service.ServiceList :rtype: twilio.rest.preview.acc_security.service.ServiceList """ super(ServiceList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/Services'.format(**self._solution) def create(self, name, code_length=values.unset): """ Create a new ServiceInstance :param unicode name: Friendly name of the service :param unicode code_length: Length of verification code. Valid values are 4-10 :returns: Newly created ServiceInstance :rtype: twilio.rest.preview.acc_security.service.ServiceInstance """ data = values.of({'Name': name, 'CodeLength': code_length,}) payload = self._version.create( 'POST', self._uri, data=data, ) return ServiceInstance(self._version, payload,) def stream(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.acc_security.service.ServiceInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.acc_security.service.ServiceInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of ServiceInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of ServiceInstance :rtype: twilio.rest.preview.acc_security.service.ServicePage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return ServicePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of ServiceInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of ServiceInstance :rtype: twilio.rest.preview.acc_security.service.ServicePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return ServicePage(self._version, response, self._solution) def get(self, sid): """ Constructs a ServiceContext :param sid: Verification Service Instance SID. :returns: twilio.rest.preview.acc_security.service.ServiceContext :rtype: twilio.rest.preview.acc_security.service.ServiceContext """ return ServiceContext(self._version, sid=sid,) def __call__(self, sid): """ Constructs a ServiceContext :param sid: Verification Service Instance SID. :returns: twilio.rest.preview.acc_security.service.ServiceContext :rtype: twilio.rest.preview.acc_security.service.ServiceContext """ return ServiceContext(self._version, sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ServicePage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the ServicePage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.preview.acc_security.service.ServicePage :rtype: twilio.rest.preview.acc_security.service.ServicePage """ super(ServicePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of ServiceInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.acc_security.service.ServiceInstance :rtype: twilio.rest.preview.acc_security.service.ServiceInstance """ return ServiceInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ServiceContext(InstanceContext): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, sid): """ Initialize the ServiceContext :param Version version: Version that contains the resource :param sid: Verification Service Instance SID. :returns: twilio.rest.preview.acc_security.service.ServiceContext :rtype: twilio.rest.preview.acc_security.service.ServiceContext """ super(ServiceContext, self).__init__(version) # Path Solution self._solution = {'sid': sid,} self._uri = '/Services/{sid}'.format(**self._solution) # Dependents self._verifications = None self._verification_checks = None def fetch(self): """ Fetch a ServiceInstance :returns: Fetched ServiceInstance :rtype: twilio.rest.preview.acc_security.service.ServiceInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return ServiceInstance(self._version, payload, sid=self._solution['sid'],) def update(self, name=values.unset, code_length=values.unset): """ Update the ServiceInstance :param unicode name: Friendly name of the service :param unicode code_length: Length of verification code. Valid values are 4-10 :returns: Updated ServiceInstance :rtype: twilio.rest.preview.acc_security.service.ServiceInstance """ data = values.of({'Name': name, 'CodeLength': code_length,}) payload = self._version.update( 'POST', self._uri, data=data, ) return ServiceInstance(self._version, payload, sid=self._solution['sid'],) @property def verifications(self): """ Access the verifications :returns: twilio.rest.preview.acc_security.service.verification.VerificationList :rtype: twilio.rest.preview.acc_security.service.verification.VerificationList """ if self._verifications is None: self._verifications = VerificationList(self._version, service_sid=self._solution['sid'],) return self._verifications @property def verification_checks(self): """ Access the verification_checks :returns: twilio.rest.preview.acc_security.service.verification_check.VerificationCheckList :rtype: twilio.rest.preview.acc_security.service.verification_check.VerificationCheckList """ if self._verification_checks is None: self._verification_checks = VerificationCheckList(self._version, service_sid=self._solution['sid'],) return self._verification_checks def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class ServiceInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, payload, sid=None): """ Initialize the ServiceInstance :returns: twilio.rest.preview.acc_security.service.ServiceInstance :rtype: twilio.rest.preview.acc_security.service.ServiceInstance """ super(ServiceInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'name': payload['name'], 'code_length': deserialize.integer(payload['code_length']), 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'url': payload['url'], 'links': payload['links'], } # Context self._context = None self._solution = {'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.preview.acc_security.service.ServiceContext """ if self._context is None: self._context = ServiceContext(self._version, sid=self._solution['sid'],) return self._context @property def sid(self): """ :returns: A string that uniquely identifies this Service. :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: Account Sid. :rtype: unicode """ return self._properties['account_sid'] @property def name(self): """ :returns: Friendly name of the service :rtype: unicode """ return self._properties['name'] @property def code_length(self): """ :returns: Length of verification code. Valid values are 4-10 :rtype: unicode """ return self._properties['code_length'] @property def date_created(self): """ :returns: The date this Service was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this Service was updated :rtype: datetime """ return self._properties['date_updated'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a ServiceInstance :returns: Fetched ServiceInstance :rtype: twilio.rest.preview.acc_security.service.ServiceInstance """ return self._proxy.fetch() def update(self, name=values.unset, code_length=values.unset): """ Update the ServiceInstance :param unicode name: Friendly name of the service :param unicode code_length: Length of verification code. Valid values are 4-10 :returns: Updated ServiceInstance :rtype: twilio.rest.preview.acc_security.service.ServiceInstance """ return self._proxy.update(name=name, code_length=code_length,) @property def verifications(self): """ Access the verifications :returns: twilio.rest.preview.acc_security.service.verification.VerificationList :rtype: twilio.rest.preview.acc_security.service.verification.VerificationList """ return self._proxy.verifications @property def verification_checks(self): """ Access the verification_checks :returns: twilio.rest.preview.acc_security.service.verification_check.VerificationCheckList :rtype: twilio.rest.preview.acc_security.service.verification_check.VerificationCheckList """ return self._proxy.verification_checks def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/preview/acc_security/service/verification.py000066400000000000000000000153101317472742600275100ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class VerificationList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, service_sid): """ Initialize the VerificationList :param Version version: Version that contains the resource :param service_sid: Service Sid. :returns: twilio.rest.preview.acc_security.service.verification.VerificationList :rtype: twilio.rest.preview.acc_security.service.verification.VerificationList """ super(VerificationList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid,} self._uri = '/Services/{service_sid}/Verifications'.format(**self._solution) def create(self, to, channel, custom_message=values.unset): """ Create a new VerificationInstance :param unicode to: To phonenumber :param unicode channel: sms or call :param unicode custom_message: A custom message for this verification :returns: Newly created VerificationInstance :rtype: twilio.rest.preview.acc_security.service.verification.VerificationInstance """ data = values.of({'To': to, 'Channel': channel, 'CustomMessage': custom_message,}) payload = self._version.create( 'POST', self._uri, data=data, ) return VerificationInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class VerificationPage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the VerificationPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: Service Sid. :returns: twilio.rest.preview.acc_security.service.verification.VerificationPage :rtype: twilio.rest.preview.acc_security.service.verification.VerificationPage """ super(VerificationPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of VerificationInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.acc_security.service.verification.VerificationInstance :rtype: twilio.rest.preview.acc_security.service.verification.VerificationInstance """ return VerificationInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class VerificationInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ class Channel(object): SMS = "sms" CALL = "call" def __init__(self, version, payload, service_sid): """ Initialize the VerificationInstance :returns: twilio.rest.preview.acc_security.service.verification.VerificationInstance :rtype: twilio.rest.preview.acc_security.service.verification.VerificationInstance """ super(VerificationInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'service_sid': payload['service_sid'], 'account_sid': payload['account_sid'], 'to': payload['to'], 'channel': payload['channel'], 'status': payload['status'], 'valid': payload['valid'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), } # Context self._context = None self._solution = {'service_sid': service_sid,} @property def sid(self): """ :returns: A string that uniquely identifies this Verification. :rtype: unicode """ return self._properties['sid'] @property def service_sid(self): """ :returns: Service Sid. :rtype: unicode """ return self._properties['service_sid'] @property def account_sid(self): """ :returns: Account Sid. :rtype: unicode """ return self._properties['account_sid'] @property def to(self): """ :returns: To phonenumber :rtype: unicode """ return self._properties['to'] @property def channel(self): """ :returns: sms or call :rtype: VerificationInstance.Channel """ return self._properties['channel'] @property def status(self): """ :returns: pending, approved, denied or expired :rtype: unicode """ return self._properties['status'] @property def valid(self): """ :returns: successful verification :rtype: bool """ return self._properties['valid'] @property def date_created(self): """ :returns: The date this Verification was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this Verification was updated :rtype: datetime """ return self._properties['date_updated'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/preview/acc_security/service/verification_check.py000066400000000000000000000154341317472742600306540ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class VerificationCheckList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, service_sid): """ Initialize the VerificationCheckList :param Version version: Version that contains the resource :param service_sid: Service Sid. :returns: twilio.rest.preview.acc_security.service.verification_check.VerificationCheckList :rtype: twilio.rest.preview.acc_security.service.verification_check.VerificationCheckList """ super(VerificationCheckList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid,} self._uri = '/Services/{service_sid}/VerificationCheck'.format(**self._solution) def create(self, code, to=values.unset): """ Create a new VerificationCheckInstance :param unicode code: The verification string :param unicode to: To phonenumber :returns: Newly created VerificationCheckInstance :rtype: twilio.rest.preview.acc_security.service.verification_check.VerificationCheckInstance """ data = values.of({'Code': code, 'To': to,}) payload = self._version.create( 'POST', self._uri, data=data, ) return VerificationCheckInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class VerificationCheckPage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the VerificationCheckPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: Service Sid. :returns: twilio.rest.preview.acc_security.service.verification_check.VerificationCheckPage :rtype: twilio.rest.preview.acc_security.service.verification_check.VerificationCheckPage """ super(VerificationCheckPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of VerificationCheckInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.acc_security.service.verification_check.VerificationCheckInstance :rtype: twilio.rest.preview.acc_security.service.verification_check.VerificationCheckInstance """ return VerificationCheckInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class VerificationCheckInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ class Channel(object): SMS = "sms" CALL = "call" def __init__(self, version, payload, service_sid): """ Initialize the VerificationCheckInstance :returns: twilio.rest.preview.acc_security.service.verification_check.VerificationCheckInstance :rtype: twilio.rest.preview.acc_security.service.verification_check.VerificationCheckInstance """ super(VerificationCheckInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'service_sid': payload['service_sid'], 'account_sid': payload['account_sid'], 'to': payload['to'], 'channel': payload['channel'], 'status': payload['status'], 'valid': payload['valid'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), } # Context self._context = None self._solution = {'service_sid': service_sid,} @property def sid(self): """ :returns: A string that uniquely identifies this Verification Check. :rtype: unicode """ return self._properties['sid'] @property def service_sid(self): """ :returns: Service Sid. :rtype: unicode """ return self._properties['service_sid'] @property def account_sid(self): """ :returns: Account Sid. :rtype: unicode """ return self._properties['account_sid'] @property def to(self): """ :returns: To phonenumber :rtype: unicode """ return self._properties['to'] @property def channel(self): """ :returns: sms or call :rtype: VerificationCheckInstance.Channel """ return self._properties['channel'] @property def status(self): """ :returns: pending, approved, denied or expired :rtype: unicode """ return self._properties['status'] @property def valid(self): """ :returns: successful verification :rtype: bool """ return self._properties['valid'] @property def date_created(self): """ :returns: The date this Verification Check was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this Verification Check was updated :rtype: datetime """ return self._properties['date_updated'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/preview/bulk_exports/000077500000000000000000000000001317472742600230605ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/preview/bulk_exports/__init__.py000066400000000000000000000027451317472742600252010ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.version import Version from twilio.rest.preview.bulk_exports.export import ExportList from twilio.rest.preview.bulk_exports.export_configuration import ExportConfigurationList class BulkExports(Version): def __init__(self, domain): """ Initialize the BulkExports version of Preview :returns: BulkExports version of Preview :rtype: twilio.rest.preview.bulk_exports.BulkExports.BulkExports """ super(BulkExports, self).__init__(domain) self.version = 'BulkExports' self._exports = None self._export_configuration = None @property def exports(self): """ :rtype: twilio.rest.preview.bulk_exports.export.ExportList """ if self._exports is None: self._exports = ExportList(self) return self._exports @property def export_configuration(self): """ :rtype: twilio.rest.preview.bulk_exports.export_configuration.ExportConfigurationList """ if self._export_configuration is None: self._export_configuration = ExportConfigurationList(self) return self._export_configuration def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/preview/bulk_exports/export/000077500000000000000000000000001317472742600244015ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/preview/bulk_exports/export/__init__.py000066400000000000000000000176041317472742600265220ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ 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.page import Page from twilio.rest.preview.bulk_exports.export.day import DayList class ExportList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version): """ Initialize the ExportList :param Version version: Version that contains the resource :returns: twilio.rest.preview.bulk_exports.export.ExportList :rtype: twilio.rest.preview.bulk_exports.export.ExportList """ super(ExportList, self).__init__(version) # Path Solution self._solution = {} def get(self, resource_type): """ Constructs a ExportContext :param resource_type: The resource_type :returns: twilio.rest.preview.bulk_exports.export.ExportContext :rtype: twilio.rest.preview.bulk_exports.export.ExportContext """ return ExportContext(self._version, resource_type=resource_type,) def __call__(self, resource_type): """ Constructs a ExportContext :param resource_type: The resource_type :returns: twilio.rest.preview.bulk_exports.export.ExportContext :rtype: twilio.rest.preview.bulk_exports.export.ExportContext """ return ExportContext(self._version, resource_type=resource_type,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ExportPage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the ExportPage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.preview.bulk_exports.export.ExportPage :rtype: twilio.rest.preview.bulk_exports.export.ExportPage """ super(ExportPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of ExportInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.bulk_exports.export.ExportInstance :rtype: twilio.rest.preview.bulk_exports.export.ExportInstance """ return ExportInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ExportContext(InstanceContext): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, resource_type): """ Initialize the ExportContext :param Version version: Version that contains the resource :param resource_type: The resource_type :returns: twilio.rest.preview.bulk_exports.export.ExportContext :rtype: twilio.rest.preview.bulk_exports.export.ExportContext """ super(ExportContext, self).__init__(version) # Path Solution self._solution = {'resource_type': resource_type,} self._uri = '/Exports/{resource_type}'.format(**self._solution) # Dependents self._days = None def fetch(self): """ Fetch a ExportInstance :returns: Fetched ExportInstance :rtype: twilio.rest.preview.bulk_exports.export.ExportInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return ExportInstance(self._version, payload, resource_type=self._solution['resource_type'],) @property def days(self): """ Access the days :returns: twilio.rest.preview.bulk_exports.export.day.DayList :rtype: twilio.rest.preview.bulk_exports.export.day.DayList """ if self._days is None: self._days = DayList(self._version, resource_type=self._solution['resource_type'],) return self._days def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class ExportInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, payload, resource_type=None): """ Initialize the ExportInstance :returns: twilio.rest.preview.bulk_exports.export.ExportInstance :rtype: twilio.rest.preview.bulk_exports.export.ExportInstance """ super(ExportInstance, self).__init__(version) # Marshaled Properties self._properties = { 'resource_type': payload['resource_type'], 'url': payload['url'], 'links': payload['links'], } # Context self._context = None self._solution = {'resource_type': resource_type or self._properties['resource_type'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: ExportContext for this ExportInstance :rtype: twilio.rest.preview.bulk_exports.export.ExportContext """ if self._context is None: self._context = ExportContext(self._version, resource_type=self._solution['resource_type'],) return self._context @property def resource_type(self): """ :returns: The resource_type :rtype: unicode """ return self._properties['resource_type'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a ExportInstance :returns: Fetched ExportInstance :rtype: twilio.rest.preview.bulk_exports.export.ExportInstance """ return self._proxy.fetch() @property def days(self): """ Access the days :returns: twilio.rest.preview.bulk_exports.export.day.DayList :rtype: twilio.rest.preview.bulk_exports.export.day.DayList """ return self._proxy.days def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/preview/bulk_exports/export/day.py000066400000000000000000000177651317472742600255500ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class DayList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, resource_type): """ Initialize the DayList :param Version version: Version that contains the resource :param resource_type: The resource_type :returns: twilio.rest.preview.bulk_exports.export.day.DayList :rtype: twilio.rest.preview.bulk_exports.export.day.DayList """ super(DayList, self).__init__(version) # Path Solution self._solution = {'resource_type': resource_type,} self._uri = '/Exports/{resource_type}/Days'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams DayInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.bulk_exports.export.day.DayInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists DayInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.bulk_exports.export.day.DayInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of DayInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of DayInstance :rtype: twilio.rest.preview.bulk_exports.export.day.DayPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return DayPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of DayInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of DayInstance :rtype: twilio.rest.preview.bulk_exports.export.day.DayPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return DayPage(self._version, response, self._solution) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class DayPage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the DayPage :param Version version: Version that contains the resource :param Response response: Response from the API :param resource_type: The resource_type :returns: twilio.rest.preview.bulk_exports.export.day.DayPage :rtype: twilio.rest.preview.bulk_exports.export.day.DayPage """ super(DayPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of DayInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.bulk_exports.export.day.DayInstance :rtype: twilio.rest.preview.bulk_exports.export.day.DayInstance """ return DayInstance(self._version, payload, resource_type=self._solution['resource_type'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class DayInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, payload, resource_type): """ Initialize the DayInstance :returns: twilio.rest.preview.bulk_exports.export.day.DayInstance :rtype: twilio.rest.preview.bulk_exports.export.day.DayInstance """ super(DayInstance, self).__init__(version) # Marshaled Properties self._properties = { 'redirect_to': payload.get('redirect_to'), 'day': payload.get('day'), 'size': deserialize.integer(payload.get('size')), 'resource_type': payload.get('resource_type'), } # Context self._context = None self._solution = {'resource_type': resource_type,} @property def redirect_to(self): """ :returns: The redirect_to :rtype: unicode """ return self._properties['redirect_to'] @property def day(self): """ :returns: The day :rtype: unicode """ return self._properties['day'] @property def size(self): """ :returns: The size :rtype: unicode """ return self._properties['size'] @property def resource_type(self): """ :returns: The resource_type :rtype: unicode """ return self._properties['resource_type'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/preview/bulk_exports/export_configuration.py000066400000000000000000000237611317472742600277130ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ 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.page import Page class ExportConfigurationList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version): """ Initialize the ExportConfigurationList :param Version version: Version that contains the resource :returns: twilio.rest.preview.bulk_exports.export_configuration.ExportConfigurationList :rtype: twilio.rest.preview.bulk_exports.export_configuration.ExportConfigurationList """ super(ExportConfigurationList, self).__init__(version) # Path Solution self._solution = {} def get(self, resource_type): """ Constructs a ExportConfigurationContext :param resource_type: The resource_type :returns: twilio.rest.preview.bulk_exports.export_configuration.ExportConfigurationContext :rtype: twilio.rest.preview.bulk_exports.export_configuration.ExportConfigurationContext """ return ExportConfigurationContext(self._version, resource_type=resource_type,) def __call__(self, resource_type): """ Constructs a ExportConfigurationContext :param resource_type: The resource_type :returns: twilio.rest.preview.bulk_exports.export_configuration.ExportConfigurationContext :rtype: twilio.rest.preview.bulk_exports.export_configuration.ExportConfigurationContext """ return ExportConfigurationContext(self._version, resource_type=resource_type,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ExportConfigurationPage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the ExportConfigurationPage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.preview.bulk_exports.export_configuration.ExportConfigurationPage :rtype: twilio.rest.preview.bulk_exports.export_configuration.ExportConfigurationPage """ super(ExportConfigurationPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of ExportConfigurationInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.bulk_exports.export_configuration.ExportConfigurationInstance :rtype: twilio.rest.preview.bulk_exports.export_configuration.ExportConfigurationInstance """ return ExportConfigurationInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ExportConfigurationContext(InstanceContext): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, resource_type): """ Initialize the ExportConfigurationContext :param Version version: Version that contains the resource :param resource_type: The resource_type :returns: twilio.rest.preview.bulk_exports.export_configuration.ExportConfigurationContext :rtype: twilio.rest.preview.bulk_exports.export_configuration.ExportConfigurationContext """ super(ExportConfigurationContext, self).__init__(version) # Path Solution self._solution = {'resource_type': resource_type,} self._uri = '/Exports/{resource_type}/Configuration'.format(**self._solution) def fetch(self): """ Fetch a ExportConfigurationInstance :returns: Fetched ExportConfigurationInstance :rtype: twilio.rest.preview.bulk_exports.export_configuration.ExportConfigurationInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return ExportConfigurationInstance( self._version, payload, resource_type=self._solution['resource_type'], ) def update(self, enabled=values.unset, webhook_url=values.unset, webhook_method=values.unset): """ Update the ExportConfigurationInstance :param bool enabled: The enabled :param unicode webhook_url: The webhook_url :param unicode webhook_method: The webhook_method :returns: Updated ExportConfigurationInstance :rtype: twilio.rest.preview.bulk_exports.export_configuration.ExportConfigurationInstance """ data = values.of({'Enabled': enabled, 'WebhookUrl': webhook_url, 'WebhookMethod': webhook_method,}) payload = self._version.update( 'POST', self._uri, data=data, ) return ExportConfigurationInstance( self._version, payload, resource_type=self._solution['resource_type'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class ExportConfigurationInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, payload, resource_type=None): """ Initialize the ExportConfigurationInstance :returns: twilio.rest.preview.bulk_exports.export_configuration.ExportConfigurationInstance :rtype: twilio.rest.preview.bulk_exports.export_configuration.ExportConfigurationInstance """ super(ExportConfigurationInstance, self).__init__(version) # Marshaled Properties self._properties = { 'enabled': payload['enabled'], 'webhook_url': payload['webhook_url'], 'webhook_method': payload['webhook_method'], 'resource_type': payload['resource_type'], 'url': payload['url'], } # Context self._context = None self._solution = {'resource_type': resource_type or self._properties['resource_type'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: ExportConfigurationContext for this ExportConfigurationInstance :rtype: twilio.rest.preview.bulk_exports.export_configuration.ExportConfigurationContext """ if self._context is None: self._context = ExportConfigurationContext( self._version, resource_type=self._solution['resource_type'], ) return self._context @property def enabled(self): """ :returns: The enabled :rtype: bool """ return self._properties['enabled'] @property def webhook_url(self): """ :returns: The webhook_url :rtype: unicode """ return self._properties['webhook_url'] @property def webhook_method(self): """ :returns: The webhook_method :rtype: unicode """ return self._properties['webhook_method'] @property def resource_type(self): """ :returns: The resource_type :rtype: unicode """ return self._properties['resource_type'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a ExportConfigurationInstance :returns: Fetched ExportConfigurationInstance :rtype: twilio.rest.preview.bulk_exports.export_configuration.ExportConfigurationInstance """ return self._proxy.fetch() def update(self, enabled=values.unset, webhook_url=values.unset, webhook_method=values.unset): """ Update the ExportConfigurationInstance :param bool enabled: The enabled :param unicode webhook_url: The webhook_url :param unicode webhook_method: The webhook_method :returns: Updated ExportConfigurationInstance :rtype: twilio.rest.preview.bulk_exports.export_configuration.ExportConfigurationInstance """ return self._proxy.update(enabled=enabled, webhook_url=webhook_url, webhook_method=webhook_method,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/preview/deployed_devices/000077500000000000000000000000001317472742600236465ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/preview/deployed_devices/__init__.py000066400000000000000000000020721317472742600257600ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.version import Version from twilio.rest.preview.deployed_devices.fleet import FleetList class DeployedDevices(Version): def __init__(self, domain): """ Initialize the DeployedDevices version of Preview :returns: DeployedDevices version of Preview :rtype: twilio.rest.preview.deployed_devices.DeployedDevices.DeployedDevices """ super(DeployedDevices, self).__init__(domain) self.version = 'DeployedDevices' self._fleets = None @property def fleets(self): """ :rtype: twilio.rest.preview.deployed_devices.fleet.FleetList """ if self._fleets is None: self._fleets = FleetList(self) return self._fleets def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/preview/deployed_devices/fleet/000077500000000000000000000000001317472742600247455ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/preview/deployed_devices/fleet/__init__.py000066400000000000000000000432221317472742600270610ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.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 FleetList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version): """ Initialize the FleetList :param Version version: Version that contains the resource :returns: twilio.rest.preview.deployed_devices.fleet.FleetList :rtype: twilio.rest.preview.deployed_devices.fleet.FleetList """ super(FleetList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/Fleets'.format(**self._solution) def create(self, friendly_name=values.unset): """ Create a new FleetInstance :param unicode friendly_name: A human readable description for this Fleet. :returns: Newly created FleetInstance :rtype: twilio.rest.preview.deployed_devices.fleet.FleetInstance """ data = values.of({'FriendlyName': friendly_name,}) payload = self._version.create( 'POST', self._uri, data=data, ) return FleetInstance(self._version, payload,) def stream(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.deployed_devices.fleet.FleetInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.deployed_devices.fleet.FleetInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of FleetInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of FleetInstance :rtype: twilio.rest.preview.deployed_devices.fleet.FleetPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return FleetPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of FleetInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of FleetInstance :rtype: twilio.rest.preview.deployed_devices.fleet.FleetPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return FleetPage(self._version, response, self._solution) def get(self, sid): """ Constructs a FleetContext :param sid: A string that uniquely identifies the Fleet. :returns: twilio.rest.preview.deployed_devices.fleet.FleetContext :rtype: twilio.rest.preview.deployed_devices.fleet.FleetContext """ return FleetContext(self._version, sid=sid,) def __call__(self, sid): """ Constructs a FleetContext :param sid: A string that uniquely identifies the Fleet. :returns: twilio.rest.preview.deployed_devices.fleet.FleetContext :rtype: twilio.rest.preview.deployed_devices.fleet.FleetContext """ return FleetContext(self._version, sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class FleetPage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the FleetPage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.preview.deployed_devices.fleet.FleetPage :rtype: twilio.rest.preview.deployed_devices.fleet.FleetPage """ super(FleetPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of FleetInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.deployed_devices.fleet.FleetInstance :rtype: twilio.rest.preview.deployed_devices.fleet.FleetInstance """ return FleetInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class FleetContext(InstanceContext): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, sid): """ Initialize the FleetContext :param Version version: Version that contains the resource :param sid: A string that uniquely identifies the Fleet. :returns: twilio.rest.preview.deployed_devices.fleet.FleetContext :rtype: twilio.rest.preview.deployed_devices.fleet.FleetContext """ super(FleetContext, self).__init__(version) # Path Solution self._solution = {'sid': sid,} self._uri = '/Fleets/{sid}'.format(**self._solution) # Dependents self._devices = None self._deployments = None self._certificates = None self._keys = None def fetch(self): """ Fetch a FleetInstance :returns: Fetched FleetInstance :rtype: twilio.rest.preview.deployed_devices.fleet.FleetInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return FleetInstance(self._version, payload, sid=self._solution['sid'],) def delete(self): """ Deletes the FleetInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, friendly_name=values.unset, default_deployment_sid=values.unset): """ Update the FleetInstance :param unicode friendly_name: A human readable description for this Fleet. :param unicode default_deployment_sid: A default Deployment SID. :returns: Updated FleetInstance :rtype: twilio.rest.preview.deployed_devices.fleet.FleetInstance """ data = values.of({'FriendlyName': friendly_name, 'DefaultDeploymentSid': default_deployment_sid,}) payload = self._version.update( 'POST', self._uri, data=data, ) return FleetInstance(self._version, payload, sid=self._solution['sid'],) @property def devices(self): """ Access the devices :returns: twilio.rest.preview.deployed_devices.fleet.device.DeviceList :rtype: twilio.rest.preview.deployed_devices.fleet.device.DeviceList """ if self._devices is None: self._devices = DeviceList(self._version, fleet_sid=self._solution['sid'],) return self._devices @property def deployments(self): """ Access the deployments :returns: twilio.rest.preview.deployed_devices.fleet.deployment.DeploymentList :rtype: twilio.rest.preview.deployed_devices.fleet.deployment.DeploymentList """ if self._deployments is None: self._deployments = DeploymentList(self._version, fleet_sid=self._solution['sid'],) return self._deployments @property def certificates(self): """ Access the certificates :returns: twilio.rest.preview.deployed_devices.fleet.certificate.CertificateList :rtype: twilio.rest.preview.deployed_devices.fleet.certificate.CertificateList """ if self._certificates is None: self._certificates = CertificateList(self._version, fleet_sid=self._solution['sid'],) return self._certificates @property def keys(self): """ Access the keys :returns: twilio.rest.preview.deployed_devices.fleet.key.KeyList :rtype: twilio.rest.preview.deployed_devices.fleet.key.KeyList """ if self._keys is None: self._keys = KeyList(self._version, fleet_sid=self._solution['sid'],) return self._keys def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class FleetInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, payload, sid=None): """ Initialize the FleetInstance :returns: twilio.rest.preview.deployed_devices.fleet.FleetInstance :rtype: twilio.rest.preview.deployed_devices.fleet.FleetInstance """ super(FleetInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'url': payload['url'], 'unique_name': payload['unique_name'], 'friendly_name': payload['friendly_name'], 'account_sid': payload['account_sid'], 'default_deployment_sid': payload['default_deployment_sid'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'links': payload['links'], } # Context self._context = None self._solution = {'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.preview.deployed_devices.fleet.FleetContext """ if self._context is None: self._context = FleetContext(self._version, sid=self._solution['sid'],) return self._context @property def sid(self): """ :returns: A string that uniquely identifies this Fleet. :rtype: unicode """ return self._properties['sid'] @property def url(self): """ :returns: URL of this Fleet. :rtype: unicode """ return self._properties['url'] @property def unique_name(self): """ :returns: A unique, addressable name of this Fleet. :rtype: unicode """ return self._properties['unique_name'] @property def friendly_name(self): """ :returns: A human readable description for this Fleet. :rtype: unicode """ return self._properties['friendly_name'] @property def account_sid(self): """ :returns: The unique SID that identifies this Account. :rtype: unicode """ return self._properties['account_sid'] @property def default_deployment_sid(self): """ :returns: The unique SID that identifies this Fleet's default Deployment. :rtype: unicode """ return self._properties['default_deployment_sid'] @property def date_created(self): """ :returns: The date this Fleet was created. :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this Fleet was updated. :rtype: datetime """ return self._properties['date_updated'] @property def links(self): """ :returns: Nested resource URLs. :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a FleetInstance :returns: Fetched FleetInstance :rtype: twilio.rest.preview.deployed_devices.fleet.FleetInstance """ return self._proxy.fetch() def delete(self): """ Deletes the FleetInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, friendly_name=values.unset, default_deployment_sid=values.unset): """ Update the FleetInstance :param unicode friendly_name: A human readable description for this Fleet. :param unicode default_deployment_sid: A default Deployment SID. :returns: Updated FleetInstance :rtype: twilio.rest.preview.deployed_devices.fleet.FleetInstance """ return self._proxy.update(friendly_name=friendly_name, default_deployment_sid=default_deployment_sid,) @property def devices(self): """ Access the devices :returns: twilio.rest.preview.deployed_devices.fleet.device.DeviceList :rtype: twilio.rest.preview.deployed_devices.fleet.device.DeviceList """ return self._proxy.devices @property def deployments(self): """ Access the deployments :returns: twilio.rest.preview.deployed_devices.fleet.deployment.DeploymentList :rtype: twilio.rest.preview.deployed_devices.fleet.deployment.DeploymentList """ return self._proxy.deployments @property def certificates(self): """ Access the certificates :returns: twilio.rest.preview.deployed_devices.fleet.certificate.CertificateList :rtype: twilio.rest.preview.deployed_devices.fleet.certificate.CertificateList """ return self._proxy.certificates @property def keys(self): """ Access the keys :returns: twilio.rest.preview.deployed_devices.fleet.key.KeyList :rtype: twilio.rest.preview.deployed_devices.fleet.key.KeyList """ return self._proxy.keys def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/preview/deployed_devices/fleet/certificate.py000066400000000000000000000412271317472742600276070ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class CertificateList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, fleet_sid): """ Initialize the CertificateList :param Version version: Version that contains the resource :param fleet_sid: The unique identifier of the Fleet. :returns: twilio.rest.preview.deployed_devices.fleet.certificate.CertificateList :rtype: twilio.rest.preview.deployed_devices.fleet.certificate.CertificateList """ super(CertificateList, self).__init__(version) # Path Solution self._solution = {'fleet_sid': fleet_sid,} self._uri = '/Fleets/{fleet_sid}/Certificates'.format(**self._solution) def create(self, certificate_data, friendly_name=values.unset, device_sid=values.unset): """ Create a new CertificateInstance :param unicode certificate_data: The public certificate data. :param unicode friendly_name: The human readable description for this Certificate. :param unicode device_sid: The unique identifier of a Device to be authenticated. :returns: Newly created CertificateInstance :rtype: twilio.rest.preview.deployed_devices.fleet.certificate.CertificateInstance """ data = values.of({ 'CertificateData': certificate_data, 'FriendlyName': friendly_name, 'DeviceSid': device_sid, }) payload = self._version.create( 'POST', self._uri, data=data, ) return CertificateInstance(self._version, payload, fleet_sid=self._solution['fleet_sid'],) def stream(self, device_sid=values.unset, limit=None, page_size=None): """ 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 unicode device_sid: Find all Certificates authenticating specified Device. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.deployed_devices.fleet.certificate.CertificateInstance] """ 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'], limits['page_limit']) def list(self, device_sid=values.unset, limit=None, page_size=None): """ 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 unicode device_sid: Find all Certificates authenticating specified Device. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.deployed_devices.fleet.certificate.CertificateInstance] """ return list(self.stream(device_sid=device_sid, limit=limit, page_size=page_size,)) def page(self, device_sid=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of CertificateInstance records from the API. Request is executed immediately :param unicode device_sid: Find all Certificates authenticating specified Device. :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of CertificateInstance :rtype: twilio.rest.preview.deployed_devices.fleet.certificate.CertificatePage """ params = values.of({ 'DeviceSid': device_sid, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return CertificatePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of CertificateInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of CertificateInstance :rtype: twilio.rest.preview.deployed_devices.fleet.certificate.CertificatePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return CertificatePage(self._version, response, self._solution) def get(self, sid): """ Constructs a CertificateContext :param sid: A string that uniquely identifies the Certificate. :returns: twilio.rest.preview.deployed_devices.fleet.certificate.CertificateContext :rtype: twilio.rest.preview.deployed_devices.fleet.certificate.CertificateContext """ return CertificateContext(self._version, fleet_sid=self._solution['fleet_sid'], sid=sid,) def __call__(self, sid): """ Constructs a CertificateContext :param sid: A string that uniquely identifies the Certificate. :returns: twilio.rest.preview.deployed_devices.fleet.certificate.CertificateContext :rtype: twilio.rest.preview.deployed_devices.fleet.certificate.CertificateContext """ return CertificateContext(self._version, fleet_sid=self._solution['fleet_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class CertificatePage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the CertificatePage :param Version version: Version that contains the resource :param Response response: Response from the API :param fleet_sid: The unique identifier of the Fleet. :returns: twilio.rest.preview.deployed_devices.fleet.certificate.CertificatePage :rtype: twilio.rest.preview.deployed_devices.fleet.certificate.CertificatePage """ super(CertificatePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of CertificateInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.deployed_devices.fleet.certificate.CertificateInstance :rtype: twilio.rest.preview.deployed_devices.fleet.certificate.CertificateInstance """ return CertificateInstance(self._version, payload, fleet_sid=self._solution['fleet_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class CertificateContext(InstanceContext): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, fleet_sid, sid): """ Initialize the CertificateContext :param Version version: Version that contains the resource :param fleet_sid: The fleet_sid :param sid: A string that uniquely identifies the Certificate. :returns: twilio.rest.preview.deployed_devices.fleet.certificate.CertificateContext :rtype: twilio.rest.preview.deployed_devices.fleet.certificate.CertificateContext """ super(CertificateContext, self).__init__(version) # Path Solution self._solution = {'fleet_sid': fleet_sid, 'sid': sid,} self._uri = '/Fleets/{fleet_sid}/Certificates/{sid}'.format(**self._solution) def fetch(self): """ Fetch a CertificateInstance :returns: Fetched CertificateInstance :rtype: twilio.rest.preview.deployed_devices.fleet.certificate.CertificateInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return CertificateInstance( self._version, payload, fleet_sid=self._solution['fleet_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the CertificateInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, friendly_name=values.unset, device_sid=values.unset): """ Update the CertificateInstance :param unicode friendly_name: The human readable description for this Certificate. :param unicode device_sid: The unique identifier of a Device to be authenticated. :returns: Updated CertificateInstance :rtype: twilio.rest.preview.deployed_devices.fleet.certificate.CertificateInstance """ data = values.of({'FriendlyName': friendly_name, 'DeviceSid': device_sid,}) payload = self._version.update( 'POST', self._uri, data=data, ) return CertificateInstance( self._version, payload, fleet_sid=self._solution['fleet_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class CertificateInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, payload, fleet_sid, sid=None): """ Initialize the CertificateInstance :returns: twilio.rest.preview.deployed_devices.fleet.certificate.CertificateInstance :rtype: twilio.rest.preview.deployed_devices.fleet.certificate.CertificateInstance """ super(CertificateInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'url': payload['url'], 'friendly_name': payload['friendly_name'], 'fleet_sid': payload['fleet_sid'], 'account_sid': payload['account_sid'], 'device_sid': payload['device_sid'], 'thumbprint': payload['thumbprint'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), } # Context self._context = None self._solution = {'fleet_sid': fleet_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.preview.deployed_devices.fleet.certificate.CertificateContext """ if self._context is None: self._context = CertificateContext( self._version, fleet_sid=self._solution['fleet_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: A string that uniquely identifies this Certificate. :rtype: unicode """ return self._properties['sid'] @property def url(self): """ :returns: URL of this Certificate. :rtype: unicode """ return self._properties['url'] @property def friendly_name(self): """ :returns: A human readable description for this Certificate. :rtype: unicode """ return self._properties['friendly_name'] @property def fleet_sid(self): """ :returns: The unique identifier of the Fleet. :rtype: unicode """ return self._properties['fleet_sid'] @property def account_sid(self): """ :returns: The unique SID that identifies this Account. :rtype: unicode """ return self._properties['account_sid'] @property def device_sid(self): """ :returns: The unique identifier of a mapped Device. :rtype: unicode """ return self._properties['device_sid'] @property def thumbprint(self): """ :returns: A Certificate unique payload hash. :rtype: unicode """ return self._properties['thumbprint'] @property def date_created(self): """ :returns: The date this Certificate was created. :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this Certificate was updated. :rtype: datetime """ return self._properties['date_updated'] def fetch(self): """ Fetch a CertificateInstance :returns: Fetched CertificateInstance :rtype: twilio.rest.preview.deployed_devices.fleet.certificate.CertificateInstance """ return self._proxy.fetch() def delete(self): """ Deletes the CertificateInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, friendly_name=values.unset, device_sid=values.unset): """ Update the CertificateInstance :param unicode friendly_name: The human readable description for this Certificate. :param unicode device_sid: The unique identifier of a Device to be authenticated. :returns: Updated CertificateInstance :rtype: twilio.rest.preview.deployed_devices.fleet.certificate.CertificateInstance """ return self._proxy.update(friendly_name=friendly_name, device_sid=device_sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/preview/deployed_devices/fleet/deployment.py000066400000000000000000000374011317472742600275040ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class DeploymentList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, fleet_sid): """ Initialize the DeploymentList :param Version version: Version that contains the resource :param fleet_sid: The unique identifier of the Fleet. :returns: twilio.rest.preview.deployed_devices.fleet.deployment.DeploymentList :rtype: twilio.rest.preview.deployed_devices.fleet.deployment.DeploymentList """ super(DeploymentList, self).__init__(version) # Path Solution self._solution = {'fleet_sid': fleet_sid,} self._uri = '/Fleets/{fleet_sid}/Deployments'.format(**self._solution) def create(self, friendly_name=values.unset, sync_service_sid=values.unset): """ Create a new DeploymentInstance :param unicode friendly_name: A human readable description for this Deployment. :param unicode sync_service_sid: The unique identifier of the Sync service instance. :returns: Newly created DeploymentInstance :rtype: twilio.rest.preview.deployed_devices.fleet.deployment.DeploymentInstance """ data = values.of({'FriendlyName': friendly_name, 'SyncServiceSid': sync_service_sid,}) payload = self._version.create( 'POST', self._uri, data=data, ) return DeploymentInstance(self._version, payload, fleet_sid=self._solution['fleet_sid'],) def stream(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.deployed_devices.fleet.deployment.DeploymentInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.deployed_devices.fleet.deployment.DeploymentInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of DeploymentInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of DeploymentInstance :rtype: twilio.rest.preview.deployed_devices.fleet.deployment.DeploymentPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return DeploymentPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of DeploymentInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of DeploymentInstance :rtype: twilio.rest.preview.deployed_devices.fleet.deployment.DeploymentPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return DeploymentPage(self._version, response, self._solution) def get(self, sid): """ Constructs a DeploymentContext :param sid: A string that uniquely identifies the Deployment. :returns: twilio.rest.preview.deployed_devices.fleet.deployment.DeploymentContext :rtype: twilio.rest.preview.deployed_devices.fleet.deployment.DeploymentContext """ return DeploymentContext(self._version, fleet_sid=self._solution['fleet_sid'], sid=sid,) def __call__(self, sid): """ Constructs a DeploymentContext :param sid: A string that uniquely identifies the Deployment. :returns: twilio.rest.preview.deployed_devices.fleet.deployment.DeploymentContext :rtype: twilio.rest.preview.deployed_devices.fleet.deployment.DeploymentContext """ return DeploymentContext(self._version, fleet_sid=self._solution['fleet_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class DeploymentPage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the DeploymentPage :param Version version: Version that contains the resource :param Response response: Response from the API :param fleet_sid: The unique identifier of the Fleet. :returns: twilio.rest.preview.deployed_devices.fleet.deployment.DeploymentPage :rtype: twilio.rest.preview.deployed_devices.fleet.deployment.DeploymentPage """ super(DeploymentPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of DeploymentInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.deployed_devices.fleet.deployment.DeploymentInstance :rtype: twilio.rest.preview.deployed_devices.fleet.deployment.DeploymentInstance """ return DeploymentInstance(self._version, payload, fleet_sid=self._solution['fleet_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class DeploymentContext(InstanceContext): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, fleet_sid, sid): """ Initialize the DeploymentContext :param Version version: Version that contains the resource :param fleet_sid: The fleet_sid :param sid: A string that uniquely identifies the Deployment. :returns: twilio.rest.preview.deployed_devices.fleet.deployment.DeploymentContext :rtype: twilio.rest.preview.deployed_devices.fleet.deployment.DeploymentContext """ super(DeploymentContext, self).__init__(version) # Path Solution self._solution = {'fleet_sid': fleet_sid, 'sid': sid,} self._uri = '/Fleets/{fleet_sid}/Deployments/{sid}'.format(**self._solution) def fetch(self): """ Fetch a DeploymentInstance :returns: Fetched DeploymentInstance :rtype: twilio.rest.preview.deployed_devices.fleet.deployment.DeploymentInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return DeploymentInstance( self._version, payload, fleet_sid=self._solution['fleet_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the DeploymentInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, friendly_name=values.unset, sync_service_sid=values.unset): """ Update the DeploymentInstance :param unicode friendly_name: A human readable description for this Deployment. :param unicode sync_service_sid: The unique identifier of the Sync service instance. :returns: Updated DeploymentInstance :rtype: twilio.rest.preview.deployed_devices.fleet.deployment.DeploymentInstance """ data = values.of({'FriendlyName': friendly_name, 'SyncServiceSid': sync_service_sid,}) payload = self._version.update( 'POST', self._uri, data=data, ) return DeploymentInstance( self._version, payload, fleet_sid=self._solution['fleet_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class DeploymentInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, payload, fleet_sid, sid=None): """ Initialize the DeploymentInstance :returns: twilio.rest.preview.deployed_devices.fleet.deployment.DeploymentInstance :rtype: twilio.rest.preview.deployed_devices.fleet.deployment.DeploymentInstance """ super(DeploymentInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'url': payload['url'], 'friendly_name': payload['friendly_name'], 'fleet_sid': payload['fleet_sid'], 'account_sid': payload['account_sid'], 'sync_service_sid': payload['sync_service_sid'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), } # Context self._context = None self._solution = {'fleet_sid': fleet_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.preview.deployed_devices.fleet.deployment.DeploymentContext """ if self._context is None: self._context = DeploymentContext( self._version, fleet_sid=self._solution['fleet_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: A string that uniquely identifies this Deployment. :rtype: unicode """ return self._properties['sid'] @property def url(self): """ :returns: URL of this Deployment. :rtype: unicode """ return self._properties['url'] @property def friendly_name(self): """ :returns: A human readable description for this Deployment :rtype: unicode """ return self._properties['friendly_name'] @property def fleet_sid(self): """ :returns: The unique identifier of the Fleet. :rtype: unicode """ return self._properties['fleet_sid'] @property def account_sid(self): """ :returns: The unique SID that identifies this Account. :rtype: unicode """ return self._properties['account_sid'] @property def sync_service_sid(self): """ :returns: The unique identifier of the Sync service instance. :rtype: unicode """ return self._properties['sync_service_sid'] @property def date_created(self): """ :returns: The date this Deployment was created. :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this Deployment was updated. :rtype: datetime """ return self._properties['date_updated'] def fetch(self): """ Fetch a DeploymentInstance :returns: Fetched DeploymentInstance :rtype: twilio.rest.preview.deployed_devices.fleet.deployment.DeploymentInstance """ return self._proxy.fetch() def delete(self): """ Deletes the DeploymentInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, friendly_name=values.unset, sync_service_sid=values.unset): """ Update the DeploymentInstance :param unicode friendly_name: A human readable description for this Deployment. :param unicode sync_service_sid: The unique identifier of the Sync service instance. :returns: Updated DeploymentInstance :rtype: twilio.rest.preview.deployed_devices.fleet.deployment.DeploymentInstance """ return self._proxy.update(friendly_name=friendly_name, sync_service_sid=sync_service_sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/preview/deployed_devices/fleet/device.py000066400000000000000000000432521317472742600265640ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class DeviceList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, fleet_sid): """ Initialize the DeviceList :param Version version: Version that contains the resource :param fleet_sid: The unique identifier of the Fleet. :returns: twilio.rest.preview.deployed_devices.fleet.device.DeviceList :rtype: twilio.rest.preview.deployed_devices.fleet.device.DeviceList """ super(DeviceList, self).__init__(version) # Path Solution self._solution = {'fleet_sid': fleet_sid,} self._uri = '/Fleets/{fleet_sid}/Devices'.format(**self._solution) def create(self, unique_name=values.unset, friendly_name=values.unset, identity=values.unset, deployment_sid=values.unset, enabled=values.unset): """ Create a new DeviceInstance :param unicode unique_name: A unique, addressable name of this Device. :param unicode friendly_name: A human readable description for this Device. :param unicode identity: An identifier of the Device user. :param unicode deployment_sid: The unique SID of the Deployment group. :param bool enabled: The enabled :returns: Newly created DeviceInstance :rtype: twilio.rest.preview.deployed_devices.fleet.device.DeviceInstance """ data = values.of({ 'UniqueName': unique_name, 'FriendlyName': friendly_name, 'Identity': identity, 'DeploymentSid': deployment_sid, 'Enabled': enabled, }) payload = self._version.create( 'POST', self._uri, data=data, ) return DeviceInstance(self._version, payload, fleet_sid=self._solution['fleet_sid'],) def stream(self, deployment_sid=values.unset, limit=None, page_size=None): """ 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 unicode deployment_sid: Find all Devices grouped under the specified Deployment. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.deployed_devices.fleet.device.DeviceInstance] """ 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'], limits['page_limit']) def list(self, deployment_sid=values.unset, limit=None, page_size=None): """ 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 unicode deployment_sid: Find all Devices grouped under the specified Deployment. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.deployed_devices.fleet.device.DeviceInstance] """ return list(self.stream(deployment_sid=deployment_sid, limit=limit, page_size=page_size,)) def page(self, deployment_sid=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of DeviceInstance records from the API. Request is executed immediately :param unicode deployment_sid: Find all Devices grouped under the specified Deployment. :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of DeviceInstance :rtype: twilio.rest.preview.deployed_devices.fleet.device.DevicePage """ params = values.of({ 'DeploymentSid': deployment_sid, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return DevicePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of DeviceInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of DeviceInstance :rtype: twilio.rest.preview.deployed_devices.fleet.device.DevicePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return DevicePage(self._version, response, self._solution) def get(self, sid): """ Constructs a DeviceContext :param sid: A string that uniquely identifies the Device. :returns: twilio.rest.preview.deployed_devices.fleet.device.DeviceContext :rtype: twilio.rest.preview.deployed_devices.fleet.device.DeviceContext """ return DeviceContext(self._version, fleet_sid=self._solution['fleet_sid'], sid=sid,) def __call__(self, sid): """ Constructs a DeviceContext :param sid: A string that uniquely identifies the Device. :returns: twilio.rest.preview.deployed_devices.fleet.device.DeviceContext :rtype: twilio.rest.preview.deployed_devices.fleet.device.DeviceContext """ return DeviceContext(self._version, fleet_sid=self._solution['fleet_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class DevicePage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the DevicePage :param Version version: Version that contains the resource :param Response response: Response from the API :param fleet_sid: The unique identifier of the Fleet. :returns: twilio.rest.preview.deployed_devices.fleet.device.DevicePage :rtype: twilio.rest.preview.deployed_devices.fleet.device.DevicePage """ super(DevicePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of DeviceInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.deployed_devices.fleet.device.DeviceInstance :rtype: twilio.rest.preview.deployed_devices.fleet.device.DeviceInstance """ return DeviceInstance(self._version, payload, fleet_sid=self._solution['fleet_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class DeviceContext(InstanceContext): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, fleet_sid, sid): """ Initialize the DeviceContext :param Version version: Version that contains the resource :param fleet_sid: The fleet_sid :param sid: A string that uniquely identifies the Device. :returns: twilio.rest.preview.deployed_devices.fleet.device.DeviceContext :rtype: twilio.rest.preview.deployed_devices.fleet.device.DeviceContext """ super(DeviceContext, self).__init__(version) # Path Solution self._solution = {'fleet_sid': fleet_sid, 'sid': sid,} self._uri = '/Fleets/{fleet_sid}/Devices/{sid}'.format(**self._solution) def fetch(self): """ Fetch a DeviceInstance :returns: Fetched DeviceInstance :rtype: twilio.rest.preview.deployed_devices.fleet.device.DeviceInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return DeviceInstance( self._version, payload, fleet_sid=self._solution['fleet_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the DeviceInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, friendly_name=values.unset, identity=values.unset, deployment_sid=values.unset, enabled=values.unset): """ Update the DeviceInstance :param unicode friendly_name: A human readable description for this Device. :param unicode identity: An identifier of the Device user. :param unicode deployment_sid: The unique SID of the Deployment group. :param bool enabled: The enabled :returns: Updated DeviceInstance :rtype: twilio.rest.preview.deployed_devices.fleet.device.DeviceInstance """ data = values.of({ 'FriendlyName': friendly_name, 'Identity': identity, 'DeploymentSid': deployment_sid, 'Enabled': enabled, }) payload = self._version.update( 'POST', self._uri, data=data, ) return DeviceInstance( self._version, payload, fleet_sid=self._solution['fleet_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class DeviceInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, payload, fleet_sid, sid=None): """ Initialize the DeviceInstance :returns: twilio.rest.preview.deployed_devices.fleet.device.DeviceInstance :rtype: twilio.rest.preview.deployed_devices.fleet.device.DeviceInstance """ super(DeviceInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'url': payload['url'], 'unique_name': payload['unique_name'], 'friendly_name': payload['friendly_name'], 'fleet_sid': payload['fleet_sid'], 'enabled': payload['enabled'], 'account_sid': payload['account_sid'], 'identity': payload['identity'], 'deployment_sid': payload['deployment_sid'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'date_authenticated': deserialize.iso8601_datetime(payload['date_authenticated']), } # Context self._context = None self._solution = {'fleet_sid': fleet_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.preview.deployed_devices.fleet.device.DeviceContext """ if self._context is None: self._context = DeviceContext( self._version, fleet_sid=self._solution['fleet_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: A string that uniquely identifies this Device. :rtype: unicode """ return self._properties['sid'] @property def url(self): """ :returns: URL of this Device. :rtype: unicode """ return self._properties['url'] @property def unique_name(self): """ :returns: A unique, addressable name of this Device. :rtype: unicode """ return self._properties['unique_name'] @property def friendly_name(self): """ :returns: A human readable description for this Device :rtype: unicode """ return self._properties['friendly_name'] @property def fleet_sid(self): """ :returns: The unique identifier of the Fleet. :rtype: unicode """ return self._properties['fleet_sid'] @property def enabled(self): """ :returns: Device enabled flag. :rtype: bool """ return self._properties['enabled'] @property def account_sid(self): """ :returns: The unique SID that identifies this Account. :rtype: unicode """ return self._properties['account_sid'] @property def identity(self): """ :returns: An identifier of the Device user. :rtype: unicode """ return self._properties['identity'] @property def deployment_sid(self): """ :returns: The unique SID of the Deployment group. :rtype: unicode """ return self._properties['deployment_sid'] @property def date_created(self): """ :returns: The date this Device was created. :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this Device was updated. :rtype: datetime """ return self._properties['date_updated'] @property def date_authenticated(self): """ :returns: The date this Device was authenticated. :rtype: datetime """ return self._properties['date_authenticated'] def fetch(self): """ Fetch a DeviceInstance :returns: Fetched DeviceInstance :rtype: twilio.rest.preview.deployed_devices.fleet.device.DeviceInstance """ return self._proxy.fetch() def delete(self): """ Deletes the DeviceInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, friendly_name=values.unset, identity=values.unset, deployment_sid=values.unset, enabled=values.unset): """ Update the DeviceInstance :param unicode friendly_name: A human readable description for this Device. :param unicode identity: An identifier of the Device user. :param unicode deployment_sid: The unique SID of the Deployment group. :param bool enabled: The enabled :returns: Updated DeviceInstance :rtype: twilio.rest.preview.deployed_devices.fleet.device.DeviceInstance """ return self._proxy.update( friendly_name=friendly_name, identity=identity, deployment_sid=deployment_sid, enabled=enabled, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/preview/deployed_devices/fleet/key.py000066400000000000000000000371071317472742600261170ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class KeyList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, fleet_sid): """ Initialize the KeyList :param Version version: Version that contains the resource :param fleet_sid: The unique identifier of the Fleet. :returns: twilio.rest.preview.deployed_devices.fleet.key.KeyList :rtype: twilio.rest.preview.deployed_devices.fleet.key.KeyList """ super(KeyList, self).__init__(version) # Path Solution self._solution = {'fleet_sid': fleet_sid,} self._uri = '/Fleets/{fleet_sid}/Keys'.format(**self._solution) def create(self, friendly_name=values.unset, device_sid=values.unset): """ Create a new KeyInstance :param unicode friendly_name: The human readable description for this Key. :param unicode device_sid: The unique identifier of a Key to be authenticated. :returns: Newly created KeyInstance :rtype: twilio.rest.preview.deployed_devices.fleet.key.KeyInstance """ data = values.of({'FriendlyName': friendly_name, 'DeviceSid': device_sid,}) payload = self._version.create( 'POST', self._uri, data=data, ) return KeyInstance(self._version, payload, fleet_sid=self._solution['fleet_sid'],) def stream(self, device_sid=values.unset, limit=None, page_size=None): """ 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 unicode device_sid: Find all Keys authenticating specified Device. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.deployed_devices.fleet.key.KeyInstance] """ 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'], limits['page_limit']) def list(self, device_sid=values.unset, limit=None, page_size=None): """ 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 unicode device_sid: Find all Keys authenticating specified Device. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.deployed_devices.fleet.key.KeyInstance] """ return list(self.stream(device_sid=device_sid, limit=limit, page_size=page_size,)) def page(self, device_sid=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of KeyInstance records from the API. Request is executed immediately :param unicode device_sid: Find all Keys authenticating specified Device. :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of KeyInstance :rtype: twilio.rest.preview.deployed_devices.fleet.key.KeyPage """ params = values.of({ 'DeviceSid': device_sid, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return KeyPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of KeyInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of KeyInstance :rtype: twilio.rest.preview.deployed_devices.fleet.key.KeyPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return KeyPage(self._version, response, self._solution) def get(self, sid): """ Constructs a KeyContext :param sid: A string that uniquely identifies the Key. :returns: twilio.rest.preview.deployed_devices.fleet.key.KeyContext :rtype: twilio.rest.preview.deployed_devices.fleet.key.KeyContext """ return KeyContext(self._version, fleet_sid=self._solution['fleet_sid'], sid=sid,) def __call__(self, sid): """ Constructs a KeyContext :param sid: A string that uniquely identifies the Key. :returns: twilio.rest.preview.deployed_devices.fleet.key.KeyContext :rtype: twilio.rest.preview.deployed_devices.fleet.key.KeyContext """ return KeyContext(self._version, fleet_sid=self._solution['fleet_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class KeyPage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the KeyPage :param Version version: Version that contains the resource :param Response response: Response from the API :param fleet_sid: The unique identifier of the Fleet. :returns: twilio.rest.preview.deployed_devices.fleet.key.KeyPage :rtype: twilio.rest.preview.deployed_devices.fleet.key.KeyPage """ super(KeyPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of KeyInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.deployed_devices.fleet.key.KeyInstance :rtype: twilio.rest.preview.deployed_devices.fleet.key.KeyInstance """ return KeyInstance(self._version, payload, fleet_sid=self._solution['fleet_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class KeyContext(InstanceContext): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, fleet_sid, sid): """ Initialize the KeyContext :param Version version: Version that contains the resource :param fleet_sid: The fleet_sid :param sid: A string that uniquely identifies the Key. :returns: twilio.rest.preview.deployed_devices.fleet.key.KeyContext :rtype: twilio.rest.preview.deployed_devices.fleet.key.KeyContext """ super(KeyContext, self).__init__(version) # Path Solution self._solution = {'fleet_sid': fleet_sid, 'sid': sid,} self._uri = '/Fleets/{fleet_sid}/Keys/{sid}'.format(**self._solution) def fetch(self): """ Fetch a KeyInstance :returns: Fetched KeyInstance :rtype: twilio.rest.preview.deployed_devices.fleet.key.KeyInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return KeyInstance( self._version, payload, fleet_sid=self._solution['fleet_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the KeyInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, friendly_name=values.unset, device_sid=values.unset): """ Update the KeyInstance :param unicode friendly_name: The human readable description for this Key. :param unicode device_sid: The unique identifier of a Key to be authenticated. :returns: Updated KeyInstance :rtype: twilio.rest.preview.deployed_devices.fleet.key.KeyInstance """ data = values.of({'FriendlyName': friendly_name, 'DeviceSid': device_sid,}) payload = self._version.update( 'POST', self._uri, data=data, ) return KeyInstance( self._version, payload, fleet_sid=self._solution['fleet_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class KeyInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, payload, fleet_sid, sid=None): """ Initialize the KeyInstance :returns: twilio.rest.preview.deployed_devices.fleet.key.KeyInstance :rtype: twilio.rest.preview.deployed_devices.fleet.key.KeyInstance """ super(KeyInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'url': payload['url'], 'friendly_name': payload['friendly_name'], 'fleet_sid': payload['fleet_sid'], 'account_sid': payload['account_sid'], 'device_sid': payload['device_sid'], 'secret': payload['secret'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), } # Context self._context = None self._solution = {'fleet_sid': fleet_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.preview.deployed_devices.fleet.key.KeyContext """ if self._context is None: self._context = KeyContext( self._version, fleet_sid=self._solution['fleet_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: A string that uniquely identifies this Key. :rtype: unicode """ return self._properties['sid'] @property def url(self): """ :returns: URL of this Key. :rtype: unicode """ return self._properties['url'] @property def friendly_name(self): """ :returns: A human readable description for this Key. :rtype: unicode """ return self._properties['friendly_name'] @property def fleet_sid(self): """ :returns: The unique identifier of the Fleet. :rtype: unicode """ return self._properties['fleet_sid'] @property def account_sid(self): """ :returns: The unique SID that identifies this Account. :rtype: unicode """ return self._properties['account_sid'] @property def device_sid(self): """ :returns: The unique identifier of a mapped Device. :rtype: unicode """ return self._properties['device_sid'] @property def secret(self): """ :returns: The key secret. :rtype: unicode """ return self._properties['secret'] @property def date_created(self): """ :returns: The date this Key credential was created. :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this Key credential was updated. :rtype: datetime """ return self._properties['date_updated'] def fetch(self): """ Fetch a KeyInstance :returns: Fetched KeyInstance :rtype: twilio.rest.preview.deployed_devices.fleet.key.KeyInstance """ return self._proxy.fetch() def delete(self): """ Deletes the KeyInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, friendly_name=values.unset, device_sid=values.unset): """ Update the KeyInstance :param unicode friendly_name: The human readable description for this Key. :param unicode device_sid: The unique identifier of a Key to be authenticated. :returns: Updated KeyInstance :rtype: twilio.rest.preview.deployed_devices.fleet.key.KeyInstance """ return self._proxy.update(friendly_name=friendly_name, device_sid=device_sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/preview/hosted_numbers/000077500000000000000000000000001317472742600233605ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/preview/hosted_numbers/__init__.py000066400000000000000000000032241317472742600254720ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.version import Version from twilio.rest.preview.hosted_numbers.authorization_document import AuthorizationDocumentList from twilio.rest.preview.hosted_numbers.hosted_number_order import HostedNumberOrderList class HostedNumbers(Version): def __init__(self, domain): """ Initialize the HostedNumbers version of Preview :returns: HostedNumbers version of Preview :rtype: twilio.rest.preview.hosted_numbers.HostedNumbers.HostedNumbers """ super(HostedNumbers, self).__init__(domain) self.version = 'HostedNumbers' self._authorization_documents = None self._hosted_number_orders = None @property def authorization_documents(self): """ :rtype: twilio.rest.preview.hosted_numbers.authorization_document.AuthorizationDocumentList """ if self._authorization_documents is None: self._authorization_documents = AuthorizationDocumentList(self) return self._authorization_documents @property def hosted_number_orders(self): """ :rtype: twilio.rest.preview.hosted_numbers.hosted_number_order.HostedNumberOrderList """ if self._hosted_number_orders is None: self._hosted_number_orders = HostedNumberOrderList(self) return self._hosted_number_orders def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/preview/hosted_numbers/authorization_document.py000066400000000000000000000404551317472742600305400ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class AuthorizationDocumentList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version): """ Initialize the AuthorizationDocumentList :param Version version: Version that contains the resource :returns: twilio.rest.preview.hosted_numbers.authorization_document.AuthorizationDocumentList :rtype: twilio.rest.preview.hosted_numbers.authorization_document.AuthorizationDocumentList """ super(AuthorizationDocumentList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/AuthorizationDocuments'.format(**self._solution) def stream(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.hosted_numbers.authorization_document.AuthorizationDocumentInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.hosted_numbers.authorization_document.AuthorizationDocumentInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of AuthorizationDocumentInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of AuthorizationDocumentInstance :rtype: twilio.rest.preview.hosted_numbers.authorization_document.AuthorizationDocumentPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return AuthorizationDocumentPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of AuthorizationDocumentInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of AuthorizationDocumentInstance :rtype: twilio.rest.preview.hosted_numbers.authorization_document.AuthorizationDocumentPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return AuthorizationDocumentPage(self._version, response, self._solution) def create(self, hosted_number_order_sids, address_sid, email, cc_emails=values.unset): """ Create a new AuthorizationDocumentInstance :param unicode hosted_number_order_sids: A list of HostedNumberOrder sids. :param unicode address_sid: Address sid. :param unicode email: Email. :param unicode cc_emails: A list of emails. :returns: Newly created AuthorizationDocumentInstance :rtype: twilio.rest.preview.hosted_numbers.authorization_document.AuthorizationDocumentInstance """ data = values.of({ 'HostedNumberOrderSids': hosted_number_order_sids, 'AddressSid': address_sid, 'Email': email, 'CcEmails': cc_emails, }) payload = self._version.create( 'POST', self._uri, data=data, ) return AuthorizationDocumentInstance(self._version, payload,) def get(self, sid): """ Constructs a AuthorizationDocumentContext :param sid: AuthorizationDocument sid. :returns: twilio.rest.preview.hosted_numbers.authorization_document.AuthorizationDocumentContext :rtype: twilio.rest.preview.hosted_numbers.authorization_document.AuthorizationDocumentContext """ return AuthorizationDocumentContext(self._version, sid=sid,) def __call__(self, sid): """ Constructs a AuthorizationDocumentContext :param sid: AuthorizationDocument sid. :returns: twilio.rest.preview.hosted_numbers.authorization_document.AuthorizationDocumentContext :rtype: twilio.rest.preview.hosted_numbers.authorization_document.AuthorizationDocumentContext """ return AuthorizationDocumentContext(self._version, sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class AuthorizationDocumentPage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the AuthorizationDocumentPage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.preview.hosted_numbers.authorization_document.AuthorizationDocumentPage :rtype: twilio.rest.preview.hosted_numbers.authorization_document.AuthorizationDocumentPage """ super(AuthorizationDocumentPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of AuthorizationDocumentInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.hosted_numbers.authorization_document.AuthorizationDocumentInstance :rtype: twilio.rest.preview.hosted_numbers.authorization_document.AuthorizationDocumentInstance """ return AuthorizationDocumentInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class AuthorizationDocumentContext(InstanceContext): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, sid): """ Initialize the AuthorizationDocumentContext :param Version version: Version that contains the resource :param sid: AuthorizationDocument sid. :returns: twilio.rest.preview.hosted_numbers.authorization_document.AuthorizationDocumentContext :rtype: twilio.rest.preview.hosted_numbers.authorization_document.AuthorizationDocumentContext """ super(AuthorizationDocumentContext, self).__init__(version) # Path Solution self._solution = {'sid': sid,} self._uri = '/AuthorizationDocuments/{sid}'.format(**self._solution) def fetch(self): """ Fetch a AuthorizationDocumentInstance :returns: Fetched AuthorizationDocumentInstance :rtype: twilio.rest.preview.hosted_numbers.authorization_document.AuthorizationDocumentInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return AuthorizationDocumentInstance(self._version, payload, sid=self._solution['sid'],) def update(self, hosted_number_order_sids=values.unset, address_sid=values.unset, email=values.unset, cc_emails=values.unset, status=values.unset): """ Update the AuthorizationDocumentInstance :param unicode hosted_number_order_sids: A list of HostedNumberOrder sids. :param unicode address_sid: Address sid. :param unicode email: Email. :param unicode cc_emails: A list of emails. :param AuthorizationDocumentInstance.Status status: The Status of this AuthorizationDocument. :returns: Updated AuthorizationDocumentInstance :rtype: twilio.rest.preview.hosted_numbers.authorization_document.AuthorizationDocumentInstance """ data = values.of({ 'HostedNumberOrderSids': hosted_number_order_sids, 'AddressSid': address_sid, 'Email': email, 'CcEmails': cc_emails, 'Status': status, }) payload = self._version.update( 'POST', self._uri, data=data, ) return AuthorizationDocumentInstance(self._version, payload, sid=self._solution['sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class AuthorizationDocumentInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ class Status(object): OPENED = "opened" SIGNING = "signing" SIGNED = "signed" CANCELED = "canceled" FAILED = "failed" def __init__(self, version, payload, sid=None): """ Initialize the AuthorizationDocumentInstance :returns: twilio.rest.preview.hosted_numbers.authorization_document.AuthorizationDocumentInstance :rtype: twilio.rest.preview.hosted_numbers.authorization_document.AuthorizationDocumentInstance """ super(AuthorizationDocumentInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'address_sid': payload['address_sid'], 'status': payload['status'], 'email': payload['email'], 'cc_emails': payload['cc_emails'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'url': payload['url'], } # Context self._context = None self._solution = {'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.preview.hosted_numbers.authorization_document.AuthorizationDocumentContext """ if self._context is None: self._context = AuthorizationDocumentContext(self._version, sid=self._solution['sid'],) return self._context @property def sid(self): """ :returns: AuthorizationDocument sid. :rtype: unicode """ return self._properties['sid'] @property def address_sid(self): """ :returns: Address sid. :rtype: unicode """ return self._properties['address_sid'] @property def status(self): """ :returns: The Status of this AuthorizationDocument. :rtype: AuthorizationDocumentInstance.Status """ return self._properties['status'] @property def email(self): """ :returns: Email. :rtype: unicode """ return self._properties['email'] @property def cc_emails(self): """ :returns: A list of emails. :rtype: unicode """ return self._properties['cc_emails'] @property def date_created(self): """ :returns: The date this AuthorizationDocument was created. :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this AuthorizationDocument was updated. :rtype: datetime """ return self._properties['date_updated'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a AuthorizationDocumentInstance :returns: Fetched AuthorizationDocumentInstance :rtype: twilio.rest.preview.hosted_numbers.authorization_document.AuthorizationDocumentInstance """ return self._proxy.fetch() def update(self, hosted_number_order_sids=values.unset, address_sid=values.unset, email=values.unset, cc_emails=values.unset, status=values.unset): """ Update the AuthorizationDocumentInstance :param unicode hosted_number_order_sids: A list of HostedNumberOrder sids. :param unicode address_sid: Address sid. :param unicode email: Email. :param unicode cc_emails: A list of emails. :param AuthorizationDocumentInstance.Status status: The Status of this AuthorizationDocument. :returns: Updated AuthorizationDocumentInstance :rtype: twilio.rest.preview.hosted_numbers.authorization_document.AuthorizationDocumentInstance """ return self._proxy.update( hosted_number_order_sids=hosted_number_order_sids, address_sid=address_sid, email=email, cc_emails=cc_emails, status=status, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/preview/hosted_numbers/hosted_number_order.py000066400000000000000000000561101317472742600277660ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class HostedNumberOrderList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version): """ Initialize the HostedNumberOrderList :param Version version: Version that contains the resource :returns: twilio.rest.preview.hosted_numbers.hosted_number_order.HostedNumberOrderList :rtype: twilio.rest.preview.hosted_numbers.hosted_number_order.HostedNumberOrderList """ super(HostedNumberOrderList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/HostedNumberOrders'.format(**self._solution) def stream(self, status=values.unset, phone_number=values.unset, incoming_phone_number_sid=values.unset, friendly_name=values.unset, unique_name=values.unset, limit=None, page_size=None): """ 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. :param unicode phone_number: An E164 formatted phone number. :param unicode incoming_phone_number_sid: IncomingPhoneNumber sid. :param unicode friendly_name: A human readable description of this resource. :param unicode unique_name: A unique, developer assigned name of this HostedNumberOrder. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.hosted_numbers.hosted_number_order.HostedNumberOrderInstance] """ 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, unique_name=unique_name, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, status=values.unset, phone_number=values.unset, incoming_phone_number_sid=values.unset, friendly_name=values.unset, unique_name=values.unset, limit=None, page_size=None): """ 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. :param unicode phone_number: An E164 formatted phone number. :param unicode incoming_phone_number_sid: IncomingPhoneNumber sid. :param unicode friendly_name: A human readable description of this resource. :param unicode unique_name: A unique, developer assigned name of this HostedNumberOrder. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.hosted_numbers.hosted_number_order.HostedNumberOrderInstance] """ return list(self.stream( status=status, phone_number=phone_number, incoming_phone_number_sid=incoming_phone_number_sid, friendly_name=friendly_name, unique_name=unique_name, limit=limit, page_size=page_size, )) def page(self, status=values.unset, phone_number=values.unset, incoming_phone_number_sid=values.unset, friendly_name=values.unset, unique_name=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of HostedNumberOrderInstance records from the API. Request is executed immediately :param HostedNumberOrderInstance.Status status: The Status of this HostedNumberOrder. :param unicode phone_number: An E164 formatted phone number. :param unicode incoming_phone_number_sid: IncomingPhoneNumber sid. :param unicode friendly_name: A human readable description of this resource. :param unicode unique_name: A unique, developer assigned name of this HostedNumberOrder. :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of HostedNumberOrderInstance :rtype: twilio.rest.preview.hosted_numbers.hosted_number_order.HostedNumberOrderPage """ params = values.of({ 'Status': status, 'PhoneNumber': phone_number, 'IncomingPhoneNumberSid': incoming_phone_number_sid, 'FriendlyName': friendly_name, 'UniqueName': unique_name, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return HostedNumberOrderPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of HostedNumberOrderInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of HostedNumberOrderInstance :rtype: twilio.rest.preview.hosted_numbers.hosted_number_order.HostedNumberOrderPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return HostedNumberOrderPage(self._version, response, self._solution) def create(self, phone_number, iso_country, sms_capability, account_sid=values.unset, friendly_name=values.unset, unique_name=values.unset, cc_emails=values.unset, sms_url=values.unset, sms_method=values.unset, sms_fallback_url=values.unset, sms_fallback_method=values.unset, status_callback_url=values.unset, status_callback_method=values.unset, sms_application_sid=values.unset, address_sid=values.unset, email=values.unset): """ Create a new HostedNumberOrderInstance :param unicode phone_number: An E164 formatted phone number. :param unicode iso_country: ISO country code. :param bool sms_capability: Specify SMS capability to host. :param unicode account_sid: Account Sid. :param unicode friendly_name: A human readable description of this resource. :param unicode unique_name: A unique, developer assigned name of this HostedNumberOrder. :param unicode cc_emails: A list of emails. :param unicode sms_url: SMS URL. :param unicode sms_method: SMS Method. :param unicode sms_fallback_url: SMS Fallback URL. :param unicode sms_fallback_method: SMS Fallback Method. :param unicode status_callback_url: Status Callback URL. :param unicode status_callback_method: Status Callback Method. :param unicode sms_application_sid: SMS Application Sid. :param unicode address_sid: Address sid. :param unicode email: Email. :returns: Newly created HostedNumberOrderInstance :rtype: twilio.rest.preview.hosted_numbers.hosted_number_order.HostedNumberOrderInstance """ data = values.of({ 'PhoneNumber': phone_number, 'IsoCountry': iso_country, 'SmsCapability': sms_capability, 'AccountSid': account_sid, 'FriendlyName': friendly_name, 'UniqueName': unique_name, 'CcEmails': cc_emails, 'SmsUrl': sms_url, 'SmsMethod': sms_method, 'SmsFallbackUrl': sms_fallback_url, 'SmsFallbackMethod': sms_fallback_method, 'StatusCallbackUrl': status_callback_url, 'StatusCallbackMethod': status_callback_method, 'SmsApplicationSid': sms_application_sid, 'AddressSid': address_sid, 'Email': email, }) payload = self._version.create( 'POST', self._uri, data=data, ) return HostedNumberOrderInstance(self._version, payload,) def get(self, sid): """ Constructs a HostedNumberOrderContext :param sid: HostedNumberOrder sid. :returns: twilio.rest.preview.hosted_numbers.hosted_number_order.HostedNumberOrderContext :rtype: twilio.rest.preview.hosted_numbers.hosted_number_order.HostedNumberOrderContext """ return HostedNumberOrderContext(self._version, sid=sid,) def __call__(self, sid): """ Constructs a HostedNumberOrderContext :param sid: HostedNumberOrder sid. :returns: twilio.rest.preview.hosted_numbers.hosted_number_order.HostedNumberOrderContext :rtype: twilio.rest.preview.hosted_numbers.hosted_number_order.HostedNumberOrderContext """ return HostedNumberOrderContext(self._version, sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class HostedNumberOrderPage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the HostedNumberOrderPage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.preview.hosted_numbers.hosted_number_order.HostedNumberOrderPage :rtype: twilio.rest.preview.hosted_numbers.hosted_number_order.HostedNumberOrderPage """ super(HostedNumberOrderPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of HostedNumberOrderInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.hosted_numbers.hosted_number_order.HostedNumberOrderInstance :rtype: twilio.rest.preview.hosted_numbers.hosted_number_order.HostedNumberOrderInstance """ return HostedNumberOrderInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class HostedNumberOrderContext(InstanceContext): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, sid): """ Initialize the HostedNumberOrderContext :param Version version: Version that contains the resource :param sid: HostedNumberOrder sid. :returns: twilio.rest.preview.hosted_numbers.hosted_number_order.HostedNumberOrderContext :rtype: twilio.rest.preview.hosted_numbers.hosted_number_order.HostedNumberOrderContext """ super(HostedNumberOrderContext, self).__init__(version) # Path Solution self._solution = {'sid': sid,} self._uri = '/HostedNumberOrders/{sid}'.format(**self._solution) def fetch(self): """ Fetch a HostedNumberOrderInstance :returns: Fetched HostedNumberOrderInstance :rtype: twilio.rest.preview.hosted_numbers.hosted_number_order.HostedNumberOrderInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return HostedNumberOrderInstance(self._version, payload, sid=self._solution['sid'],) def delete(self): """ Deletes the HostedNumberOrderInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, friendly_name=values.unset, unique_name=values.unset, email=values.unset, cc_emails=values.unset, status=values.unset, verification_code=values.unset): """ Update the HostedNumberOrderInstance :param unicode friendly_name: A human readable description of this resource. :param unicode unique_name: A unique, developer assigned name of this HostedNumberOrder. :param unicode email: Email. :param unicode cc_emails: A list of emails. :param HostedNumberOrderInstance.Status status: The Status of this HostedNumberOrder. :param unicode verification_code: A verification code. :returns: Updated HostedNumberOrderInstance :rtype: twilio.rest.preview.hosted_numbers.hosted_number_order.HostedNumberOrderInstance """ data = values.of({ 'FriendlyName': friendly_name, 'UniqueName': unique_name, 'Email': email, 'CcEmails': cc_emails, 'Status': status, 'VerificationCode': verification_code, }) payload = self._version.update( 'POST', self._uri, data=data, ) return HostedNumberOrderInstance(self._version, payload, sid=self._solution['sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class HostedNumberOrderInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ class Status(object): 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" def __init__(self, version, payload, sid=None): """ Initialize the HostedNumberOrderInstance :returns: twilio.rest.preview.hosted_numbers.hosted_number_order.HostedNumberOrderInstance :rtype: twilio.rest.preview.hosted_numbers.hosted_number_order.HostedNumberOrderInstance """ super(HostedNumberOrderInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'incoming_phone_number_sid': payload['incoming_phone_number_sid'], 'address_sid': payload['address_sid'], 'signing_document_sid': payload['signing_document_sid'], 'phone_number': payload['phone_number'], 'capabilities': payload['capabilities'], 'friendly_name': payload['friendly_name'], 'unique_name': payload['unique_name'], 'status': payload['status'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'verification_attempts': deserialize.integer(payload['verification_attempts']), 'email': payload['email'], 'cc_emails': payload['cc_emails'], 'url': payload['url'], } # Context self._context = None self._solution = {'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.preview.hosted_numbers.hosted_number_order.HostedNumberOrderContext """ if self._context is None: self._context = HostedNumberOrderContext(self._version, sid=self._solution['sid'],) return self._context @property def sid(self): """ :returns: HostedNumberOrder sid. :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: Account Sid. :rtype: unicode """ return self._properties['account_sid'] @property def incoming_phone_number_sid(self): """ :returns: IncomingPhoneNumber sid. :rtype: unicode """ return self._properties['incoming_phone_number_sid'] @property def address_sid(self): """ :returns: Address sid. :rtype: unicode """ return self._properties['address_sid'] @property def signing_document_sid(self): """ :returns: LOA document sid. :rtype: unicode """ return self._properties['signing_document_sid'] @property def phone_number(self): """ :returns: An E164 formatted phone number. :rtype: unicode """ return self._properties['phone_number'] @property def capabilities(self): """ :returns: A mapping of phone number capabilities. :rtype: unicode """ return self._properties['capabilities'] @property def friendly_name(self): """ :returns: A human readable description of this resource. :rtype: unicode """ return self._properties['friendly_name'] @property def unique_name(self): """ :returns: A unique, developer assigned name of this HostedNumberOrder. :rtype: unicode """ return self._properties['unique_name'] @property def status(self): """ :returns: The Status of this HostedNumberOrder. :rtype: HostedNumberOrderInstance.Status """ return self._properties['status'] @property def date_created(self): """ :returns: The date this HostedNumberOrder was created. :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this HostedNumberOrder was updated. :rtype: datetime """ return self._properties['date_updated'] @property def verification_attempts(self): """ :returns: The number of verification attempts made to verify ownership of the phone number. :rtype: unicode """ return self._properties['verification_attempts'] @property def email(self): """ :returns: Email. :rtype: unicode """ return self._properties['email'] @property def cc_emails(self): """ :returns: A list of emails. :rtype: unicode """ return self._properties['cc_emails'] @property def url(self): """ :returns: The URL of this HostedNumberOrder. :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a HostedNumberOrderInstance :returns: Fetched HostedNumberOrderInstance :rtype: twilio.rest.preview.hosted_numbers.hosted_number_order.HostedNumberOrderInstance """ return self._proxy.fetch() def delete(self): """ Deletes the HostedNumberOrderInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, friendly_name=values.unset, unique_name=values.unset, email=values.unset, cc_emails=values.unset, status=values.unset, verification_code=values.unset): """ Update the HostedNumberOrderInstance :param unicode friendly_name: A human readable description of this resource. :param unicode unique_name: A unique, developer assigned name of this HostedNumberOrder. :param unicode email: Email. :param unicode cc_emails: A list of emails. :param HostedNumberOrderInstance.Status status: The Status of this HostedNumberOrder. :param unicode verification_code: A verification code. :returns: Updated HostedNumberOrderInstance :rtype: twilio.rest.preview.hosted_numbers.hosted_number_order.HostedNumberOrderInstance """ return self._proxy.update( friendly_name=friendly_name, unique_name=unique_name, email=email, cc_emails=cc_emails, status=status, verification_code=verification_code, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/preview/marketplace/000077500000000000000000000000001317472742600226275ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/preview/marketplace/__init__.py000066400000000000000000000030301317472742600247340ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.version import Version from twilio.rest.preview.marketplace.available_add_on import AvailableAddOnList from twilio.rest.preview.marketplace.installed_add_on import InstalledAddOnList class Marketplace(Version): def __init__(self, domain): """ Initialize the Marketplace version of Preview :returns: Marketplace version of Preview :rtype: twilio.rest.preview.marketplace.Marketplace.Marketplace """ super(Marketplace, self).__init__(domain) self.version = 'marketplace' self._available_add_ons = None self._installed_add_ons = None @property def available_add_ons(self): """ :rtype: twilio.rest.preview.marketplace.available_add_on.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): """ :rtype: twilio.rest.preview.marketplace.installed_add_on.InstalledAddOnList """ if self._installed_add_ons is None: self._installed_add_ons = InstalledAddOnList(self) return self._installed_add_ons def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/preview/marketplace/available_add_on/000077500000000000000000000000001317472742600260535ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/preview/marketplace/available_add_on/__init__.py000066400000000000000000000325521317472742600301730ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ 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.page import Page from twilio.rest.preview.marketplace.available_add_on.available_add_on_extension import AvailableAddOnExtensionList class AvailableAddOnList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version): """ Initialize the AvailableAddOnList :param Version version: Version that contains the resource :returns: twilio.rest.preview.marketplace.available_add_on.AvailableAddOnList :rtype: twilio.rest.preview.marketplace.available_add_on.AvailableAddOnList """ super(AvailableAddOnList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/AvailableAddOns'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams AvailableAddOnInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.marketplace.available_add_on.AvailableAddOnInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists AvailableAddOnInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.marketplace.available_add_on.AvailableAddOnInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of AvailableAddOnInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of AvailableAddOnInstance :rtype: twilio.rest.preview.marketplace.available_add_on.AvailableAddOnPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return AvailableAddOnPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of AvailableAddOnInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of AvailableAddOnInstance :rtype: twilio.rest.preview.marketplace.available_add_on.AvailableAddOnPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return AvailableAddOnPage(self._version, response, self._solution) def get(self, sid): """ Constructs a AvailableAddOnContext :param sid: The unique Available Add-on Sid :returns: twilio.rest.preview.marketplace.available_add_on.AvailableAddOnContext :rtype: twilio.rest.preview.marketplace.available_add_on.AvailableAddOnContext """ return AvailableAddOnContext(self._version, sid=sid,) def __call__(self, sid): """ Constructs a AvailableAddOnContext :param sid: The unique Available Add-on Sid :returns: twilio.rest.preview.marketplace.available_add_on.AvailableAddOnContext :rtype: twilio.rest.preview.marketplace.available_add_on.AvailableAddOnContext """ return AvailableAddOnContext(self._version, sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class AvailableAddOnPage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the AvailableAddOnPage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.preview.marketplace.available_add_on.AvailableAddOnPage :rtype: twilio.rest.preview.marketplace.available_add_on.AvailableAddOnPage """ super(AvailableAddOnPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of AvailableAddOnInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.marketplace.available_add_on.AvailableAddOnInstance :rtype: twilio.rest.preview.marketplace.available_add_on.AvailableAddOnInstance """ return AvailableAddOnInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class AvailableAddOnContext(InstanceContext): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, sid): """ Initialize the AvailableAddOnContext :param Version version: Version that contains the resource :param sid: The unique Available Add-on Sid :returns: twilio.rest.preview.marketplace.available_add_on.AvailableAddOnContext :rtype: twilio.rest.preview.marketplace.available_add_on.AvailableAddOnContext """ super(AvailableAddOnContext, self).__init__(version) # Path Solution self._solution = {'sid': sid,} self._uri = '/AvailableAddOns/{sid}'.format(**self._solution) # Dependents self._extensions = None def fetch(self): """ Fetch a AvailableAddOnInstance :returns: Fetched AvailableAddOnInstance :rtype: twilio.rest.preview.marketplace.available_add_on.AvailableAddOnInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return AvailableAddOnInstance(self._version, payload, sid=self._solution['sid'],) @property def extensions(self): """ Access the extensions :returns: twilio.rest.preview.marketplace.available_add_on.available_add_on_extension.AvailableAddOnExtensionList :rtype: twilio.rest.preview.marketplace.available_add_on.available_add_on_extension.AvailableAddOnExtensionList """ if self._extensions is None: self._extensions = AvailableAddOnExtensionList( self._version, available_add_on_sid=self._solution['sid'], ) return self._extensions def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class AvailableAddOnInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, payload, sid=None): """ Initialize the AvailableAddOnInstance :returns: twilio.rest.preview.marketplace.available_add_on.AvailableAddOnInstance :rtype: twilio.rest.preview.marketplace.available_add_on.AvailableAddOnInstance """ super(AvailableAddOnInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'friendly_name': payload['friendly_name'], 'description': payload['description'], 'pricing_type': payload['pricing_type'], 'configuration_schema': payload['configuration_schema'], 'url': payload['url'], 'links': payload['links'], } # Context self._context = None self._solution = {'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: AvailableAddOnContext for this AvailableAddOnInstance :rtype: twilio.rest.preview.marketplace.available_add_on.AvailableAddOnContext """ if self._context is None: self._context = AvailableAddOnContext(self._version, sid=self._solution['sid'],) return self._context @property def sid(self): """ :returns: A string that uniquely identifies this Add-on :rtype: unicode """ return self._properties['sid'] @property def friendly_name(self): """ :returns: A description of this Add-on :rtype: unicode """ return self._properties['friendly_name'] @property def description(self): """ :returns: A short description of the Add-on functionality :rtype: unicode """ return self._properties['description'] @property def pricing_type(self): """ :returns: The way customers are charged for using this Add-on :rtype: unicode """ return self._properties['pricing_type'] @property def configuration_schema(self): """ :returns: The JSON Schema describing the Add-on's configuration :rtype: dict """ return self._properties['configuration_schema'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a AvailableAddOnInstance :returns: Fetched AvailableAddOnInstance :rtype: twilio.rest.preview.marketplace.available_add_on.AvailableAddOnInstance """ return self._proxy.fetch() @property def extensions(self): """ Access the extensions :returns: twilio.rest.preview.marketplace.available_add_on.available_add_on_extension.AvailableAddOnExtensionList :rtype: twilio.rest.preview.marketplace.available_add_on.available_add_on_extension.AvailableAddOnExtensionList """ return self._proxy.extensions def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/preview/marketplace/available_add_on/available_add_on_extension.py000066400000000000000000000342411317472742600337510ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ 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.page import Page class AvailableAddOnExtensionList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, available_add_on_sid): """ Initialize the AvailableAddOnExtensionList :param Version version: Version that contains the resource :param available_add_on_sid: The available_add_on_sid :returns: twilio.rest.preview.marketplace.available_add_on.available_add_on_extension.AvailableAddOnExtensionList :rtype: twilio.rest.preview.marketplace.available_add_on.available_add_on_extension.AvailableAddOnExtensionList """ super(AvailableAddOnExtensionList, self).__init__(version) # Path Solution self._solution = {'available_add_on_sid': available_add_on_sid,} self._uri = '/AvailableAddOns/{available_add_on_sid}/Extensions'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams AvailableAddOnExtensionInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.marketplace.available_add_on.available_add_on_extension.AvailableAddOnExtensionInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists AvailableAddOnExtensionInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.marketplace.available_add_on.available_add_on_extension.AvailableAddOnExtensionInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of AvailableAddOnExtensionInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of AvailableAddOnExtensionInstance :rtype: twilio.rest.preview.marketplace.available_add_on.available_add_on_extension.AvailableAddOnExtensionPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return AvailableAddOnExtensionPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of AvailableAddOnExtensionInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of AvailableAddOnExtensionInstance :rtype: twilio.rest.preview.marketplace.available_add_on.available_add_on_extension.AvailableAddOnExtensionPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return AvailableAddOnExtensionPage(self._version, response, self._solution) def get(self, sid): """ Constructs a AvailableAddOnExtensionContext :param sid: The unique Extension Sid :returns: twilio.rest.preview.marketplace.available_add_on.available_add_on_extension.AvailableAddOnExtensionContext :rtype: twilio.rest.preview.marketplace.available_add_on.available_add_on_extension.AvailableAddOnExtensionContext """ return AvailableAddOnExtensionContext( self._version, available_add_on_sid=self._solution['available_add_on_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a AvailableAddOnExtensionContext :param sid: The unique Extension Sid :returns: twilio.rest.preview.marketplace.available_add_on.available_add_on_extension.AvailableAddOnExtensionContext :rtype: twilio.rest.preview.marketplace.available_add_on.available_add_on_extension.AvailableAddOnExtensionContext """ return AvailableAddOnExtensionContext( self._version, available_add_on_sid=self._solution['available_add_on_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class AvailableAddOnExtensionPage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the AvailableAddOnExtensionPage :param Version version: Version that contains the resource :param Response response: Response from the API :param available_add_on_sid: The available_add_on_sid :returns: twilio.rest.preview.marketplace.available_add_on.available_add_on_extension.AvailableAddOnExtensionPage :rtype: twilio.rest.preview.marketplace.available_add_on.available_add_on_extension.AvailableAddOnExtensionPage """ super(AvailableAddOnExtensionPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of AvailableAddOnExtensionInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.marketplace.available_add_on.available_add_on_extension.AvailableAddOnExtensionInstance :rtype: twilio.rest.preview.marketplace.available_add_on.available_add_on_extension.AvailableAddOnExtensionInstance """ return AvailableAddOnExtensionInstance( self._version, payload, available_add_on_sid=self._solution['available_add_on_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class AvailableAddOnExtensionContext(InstanceContext): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, available_add_on_sid, sid): """ Initialize the AvailableAddOnExtensionContext :param Version version: Version that contains the resource :param available_add_on_sid: The available_add_on_sid :param sid: The unique Extension Sid :returns: twilio.rest.preview.marketplace.available_add_on.available_add_on_extension.AvailableAddOnExtensionContext :rtype: twilio.rest.preview.marketplace.available_add_on.available_add_on_extension.AvailableAddOnExtensionContext """ super(AvailableAddOnExtensionContext, self).__init__(version) # Path Solution self._solution = {'available_add_on_sid': available_add_on_sid, 'sid': sid,} self._uri = '/AvailableAddOns/{available_add_on_sid}/Extensions/{sid}'.format(**self._solution) def fetch(self): """ Fetch a AvailableAddOnExtensionInstance :returns: Fetched AvailableAddOnExtensionInstance :rtype: twilio.rest.preview.marketplace.available_add_on.available_add_on_extension.AvailableAddOnExtensionInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return AvailableAddOnExtensionInstance( self._version, payload, available_add_on_sid=self._solution['available_add_on_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class AvailableAddOnExtensionInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, payload, available_add_on_sid, sid=None): """ Initialize the AvailableAddOnExtensionInstance :returns: twilio.rest.preview.marketplace.available_add_on.available_add_on_extension.AvailableAddOnExtensionInstance :rtype: twilio.rest.preview.marketplace.available_add_on.available_add_on_extension.AvailableAddOnExtensionInstance """ super(AvailableAddOnExtensionInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'available_add_on_sid': payload['available_add_on_sid'], 'friendly_name': payload['friendly_name'], 'product_name': payload['product_name'], 'unique_name': payload['unique_name'], 'url': payload['url'], } # Context self._context = None self._solution = { 'available_add_on_sid': available_add_on_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: AvailableAddOnExtensionContext for this AvailableAddOnExtensionInstance :rtype: twilio.rest.preview.marketplace.available_add_on.available_add_on_extension.AvailableAddOnExtensionContext """ if self._context is None: self._context = AvailableAddOnExtensionContext( self._version, available_add_on_sid=self._solution['available_add_on_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: A string that uniquely identifies this Extension :rtype: unicode """ return self._properties['sid'] @property def available_add_on_sid(self): """ :returns: The available_add_on_sid :rtype: unicode """ return self._properties['available_add_on_sid'] @property def friendly_name(self): """ :returns: A human-readable description of this Extension :rtype: unicode """ return self._properties['friendly_name'] @property def product_name(self): """ :returns: A human-readable description of the Extension's Product :rtype: unicode """ return self._properties['product_name'] @property def unique_name(self): """ :returns: The string that uniquely identifies this Extension :rtype: unicode """ return self._properties['unique_name'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a AvailableAddOnExtensionInstance :returns: Fetched AvailableAddOnExtensionInstance :rtype: twilio.rest.preview.marketplace.available_add_on.available_add_on_extension.AvailableAddOnExtensionInstance """ return self._proxy.fetch() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/preview/marketplace/installed_add_on/000077500000000000000000000000001317472742600261125ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/preview/marketplace/installed_add_on/__init__.py000066400000000000000000000421501317472742600302250ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize 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.page import Page from twilio.rest.preview.marketplace.installed_add_on.installed_add_on_extension import InstalledAddOnExtensionList class InstalledAddOnList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version): """ Initialize the InstalledAddOnList :param Version version: Version that contains the resource :returns: twilio.rest.preview.marketplace.installed_add_on.InstalledAddOnList :rtype: twilio.rest.preview.marketplace.installed_add_on.InstalledAddOnList """ super(InstalledAddOnList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/InstalledAddOns'.format(**self._solution) def create(self, available_add_on_sid, accept_terms_of_service, configuration=values.unset, unique_name=values.unset): """ Create a new InstalledAddOnInstance :param unicode available_add_on_sid: A string that uniquely identifies the Add-on to install :param bool accept_terms_of_service: A boolean reflecting your acceptance of the Terms of Service :param dict configuration: The JSON object representing the configuration :param unicode unique_name: The string that uniquely identifies this Add-on installation :returns: Newly created InstalledAddOnInstance :rtype: twilio.rest.preview.marketplace.installed_add_on.InstalledAddOnInstance """ data = values.of({ 'AvailableAddOnSid': available_add_on_sid, 'AcceptTermsOfService': accept_terms_of_service, 'Configuration': serialize.object(configuration), 'UniqueName': unique_name, }) payload = self._version.create( 'POST', self._uri, data=data, ) return InstalledAddOnInstance(self._version, payload,) def stream(self, limit=None, page_size=None): """ Streams InstalledAddOnInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.marketplace.installed_add_on.InstalledAddOnInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists InstalledAddOnInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.marketplace.installed_add_on.InstalledAddOnInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of InstalledAddOnInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of InstalledAddOnInstance :rtype: twilio.rest.preview.marketplace.installed_add_on.InstalledAddOnPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return InstalledAddOnPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of InstalledAddOnInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of InstalledAddOnInstance :rtype: twilio.rest.preview.marketplace.installed_add_on.InstalledAddOnPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return InstalledAddOnPage(self._version, response, self._solution) def get(self, sid): """ Constructs a InstalledAddOnContext :param sid: The unique Installed Add-on Sid :returns: twilio.rest.preview.marketplace.installed_add_on.InstalledAddOnContext :rtype: twilio.rest.preview.marketplace.installed_add_on.InstalledAddOnContext """ return InstalledAddOnContext(self._version, sid=sid,) def __call__(self, sid): """ Constructs a InstalledAddOnContext :param sid: The unique Installed Add-on Sid :returns: twilio.rest.preview.marketplace.installed_add_on.InstalledAddOnContext :rtype: twilio.rest.preview.marketplace.installed_add_on.InstalledAddOnContext """ return InstalledAddOnContext(self._version, sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class InstalledAddOnPage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the InstalledAddOnPage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.preview.marketplace.installed_add_on.InstalledAddOnPage :rtype: twilio.rest.preview.marketplace.installed_add_on.InstalledAddOnPage """ super(InstalledAddOnPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of InstalledAddOnInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.marketplace.installed_add_on.InstalledAddOnInstance :rtype: twilio.rest.preview.marketplace.installed_add_on.InstalledAddOnInstance """ return InstalledAddOnInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class InstalledAddOnContext(InstanceContext): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, sid): """ Initialize the InstalledAddOnContext :param Version version: Version that contains the resource :param sid: The unique Installed Add-on Sid :returns: twilio.rest.preview.marketplace.installed_add_on.InstalledAddOnContext :rtype: twilio.rest.preview.marketplace.installed_add_on.InstalledAddOnContext """ super(InstalledAddOnContext, self).__init__(version) # Path Solution self._solution = {'sid': sid,} self._uri = '/InstalledAddOns/{sid}'.format(**self._solution) # Dependents self._extensions = None def delete(self): """ Deletes the InstalledAddOnInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def fetch(self): """ Fetch a InstalledAddOnInstance :returns: Fetched InstalledAddOnInstance :rtype: twilio.rest.preview.marketplace.installed_add_on.InstalledAddOnInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return InstalledAddOnInstance(self._version, payload, sid=self._solution['sid'],) def update(self, configuration=values.unset, unique_name=values.unset): """ Update the InstalledAddOnInstance :param dict configuration: The JSON object representing the configuration :param unicode unique_name: The string that uniquely identifies this Add-on installation :returns: Updated InstalledAddOnInstance :rtype: twilio.rest.preview.marketplace.installed_add_on.InstalledAddOnInstance """ data = values.of({'Configuration': serialize.object(configuration), 'UniqueName': unique_name,}) payload = self._version.update( 'POST', self._uri, data=data, ) return InstalledAddOnInstance(self._version, payload, sid=self._solution['sid'],) @property def extensions(self): """ Access the extensions :returns: twilio.rest.preview.marketplace.installed_add_on.installed_add_on_extension.InstalledAddOnExtensionList :rtype: twilio.rest.preview.marketplace.installed_add_on.installed_add_on_extension.InstalledAddOnExtensionList """ if self._extensions is None: self._extensions = InstalledAddOnExtensionList( self._version, installed_add_on_sid=self._solution['sid'], ) return self._extensions def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class InstalledAddOnInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, payload, sid=None): """ Initialize the InstalledAddOnInstance :returns: twilio.rest.preview.marketplace.installed_add_on.InstalledAddOnInstance :rtype: twilio.rest.preview.marketplace.installed_add_on.InstalledAddOnInstance """ super(InstalledAddOnInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'friendly_name': payload['friendly_name'], 'description': payload['description'], 'configuration': payload['configuration'], 'unique_name': payload['unique_name'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'url': payload['url'], 'links': payload['links'], } # Context self._context = None self._solution = {'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: InstalledAddOnContext for this InstalledAddOnInstance :rtype: twilio.rest.preview.marketplace.installed_add_on.InstalledAddOnContext """ if self._context is None: self._context = InstalledAddOnContext(self._version, sid=self._solution['sid'],) return self._context @property def sid(self): """ :returns: A string that uniquely identifies this Add-on installation :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The Account id that has installed this Add-on :rtype: unicode """ return self._properties['account_sid'] @property def friendly_name(self): """ :returns: A description of this Add-on installation :rtype: unicode """ return self._properties['friendly_name'] @property def description(self): """ :returns: A short description of the Add-on functionality :rtype: unicode """ return self._properties['description'] @property def configuration(self): """ :returns: The JSON object representing the current configuration :rtype: dict """ return self._properties['configuration'] @property def unique_name(self): """ :returns: The string that uniquely identifies this Add-on installation :rtype: unicode """ return self._properties['unique_name'] @property def date_created(self): """ :returns: The date this Add-on installation was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this Add-on installation was last updated :rtype: datetime """ return self._properties['date_updated'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def delete(self): """ Deletes the InstalledAddOnInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def fetch(self): """ Fetch a InstalledAddOnInstance :returns: Fetched InstalledAddOnInstance :rtype: twilio.rest.preview.marketplace.installed_add_on.InstalledAddOnInstance """ return self._proxy.fetch() def update(self, configuration=values.unset, unique_name=values.unset): """ Update the InstalledAddOnInstance :param dict configuration: The JSON object representing the configuration :param unicode unique_name: The string that uniquely identifies this Add-on installation :returns: Updated InstalledAddOnInstance :rtype: twilio.rest.preview.marketplace.installed_add_on.InstalledAddOnInstance """ return self._proxy.update(configuration=configuration, unique_name=unique_name,) @property def extensions(self): """ Access the extensions :returns: twilio.rest.preview.marketplace.installed_add_on.installed_add_on_extension.InstalledAddOnExtensionList :rtype: twilio.rest.preview.marketplace.installed_add_on.installed_add_on_extension.InstalledAddOnExtensionList """ return self._proxy.extensions def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/preview/marketplace/installed_add_on/installed_add_on_extension.py000066400000000000000000000370521317472742600340520ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ 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.page import Page class InstalledAddOnExtensionList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, installed_add_on_sid): """ Initialize the InstalledAddOnExtensionList :param Version version: Version that contains the resource :param installed_add_on_sid: The installed_add_on_sid :returns: twilio.rest.preview.marketplace.installed_add_on.installed_add_on_extension.InstalledAddOnExtensionList :rtype: twilio.rest.preview.marketplace.installed_add_on.installed_add_on_extension.InstalledAddOnExtensionList """ super(InstalledAddOnExtensionList, self).__init__(version) # Path Solution self._solution = {'installed_add_on_sid': installed_add_on_sid,} self._uri = '/InstalledAddOns/{installed_add_on_sid}/Extensions'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams InstalledAddOnExtensionInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.marketplace.installed_add_on.installed_add_on_extension.InstalledAddOnExtensionInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists InstalledAddOnExtensionInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.marketplace.installed_add_on.installed_add_on_extension.InstalledAddOnExtensionInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of InstalledAddOnExtensionInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of InstalledAddOnExtensionInstance :rtype: twilio.rest.preview.marketplace.installed_add_on.installed_add_on_extension.InstalledAddOnExtensionPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return InstalledAddOnExtensionPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of InstalledAddOnExtensionInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of InstalledAddOnExtensionInstance :rtype: twilio.rest.preview.marketplace.installed_add_on.installed_add_on_extension.InstalledAddOnExtensionPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return InstalledAddOnExtensionPage(self._version, response, self._solution) def get(self, sid): """ Constructs a InstalledAddOnExtensionContext :param sid: The unique Extension Sid :returns: twilio.rest.preview.marketplace.installed_add_on.installed_add_on_extension.InstalledAddOnExtensionContext :rtype: twilio.rest.preview.marketplace.installed_add_on.installed_add_on_extension.InstalledAddOnExtensionContext """ return InstalledAddOnExtensionContext( self._version, installed_add_on_sid=self._solution['installed_add_on_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a InstalledAddOnExtensionContext :param sid: The unique Extension Sid :returns: twilio.rest.preview.marketplace.installed_add_on.installed_add_on_extension.InstalledAddOnExtensionContext :rtype: twilio.rest.preview.marketplace.installed_add_on.installed_add_on_extension.InstalledAddOnExtensionContext """ return InstalledAddOnExtensionContext( self._version, installed_add_on_sid=self._solution['installed_add_on_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class InstalledAddOnExtensionPage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the InstalledAddOnExtensionPage :param Version version: Version that contains the resource :param Response response: Response from the API :param installed_add_on_sid: The installed_add_on_sid :returns: twilio.rest.preview.marketplace.installed_add_on.installed_add_on_extension.InstalledAddOnExtensionPage :rtype: twilio.rest.preview.marketplace.installed_add_on.installed_add_on_extension.InstalledAddOnExtensionPage """ super(InstalledAddOnExtensionPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of InstalledAddOnExtensionInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.marketplace.installed_add_on.installed_add_on_extension.InstalledAddOnExtensionInstance :rtype: twilio.rest.preview.marketplace.installed_add_on.installed_add_on_extension.InstalledAddOnExtensionInstance """ return InstalledAddOnExtensionInstance( self._version, payload, installed_add_on_sid=self._solution['installed_add_on_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class InstalledAddOnExtensionContext(InstanceContext): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, installed_add_on_sid, sid): """ Initialize the InstalledAddOnExtensionContext :param Version version: Version that contains the resource :param installed_add_on_sid: The installed_add_on_sid :param sid: The unique Extension Sid :returns: twilio.rest.preview.marketplace.installed_add_on.installed_add_on_extension.InstalledAddOnExtensionContext :rtype: twilio.rest.preview.marketplace.installed_add_on.installed_add_on_extension.InstalledAddOnExtensionContext """ super(InstalledAddOnExtensionContext, self).__init__(version) # Path Solution self._solution = {'installed_add_on_sid': installed_add_on_sid, 'sid': sid,} self._uri = '/InstalledAddOns/{installed_add_on_sid}/Extensions/{sid}'.format(**self._solution) def fetch(self): """ Fetch a InstalledAddOnExtensionInstance :returns: Fetched InstalledAddOnExtensionInstance :rtype: twilio.rest.preview.marketplace.installed_add_on.installed_add_on_extension.InstalledAddOnExtensionInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return InstalledAddOnExtensionInstance( self._version, payload, installed_add_on_sid=self._solution['installed_add_on_sid'], sid=self._solution['sid'], ) def update(self, enabled): """ Update the InstalledAddOnExtensionInstance :param bool enabled: A Boolean indicating if the Extension will be invoked :returns: Updated InstalledAddOnExtensionInstance :rtype: twilio.rest.preview.marketplace.installed_add_on.installed_add_on_extension.InstalledAddOnExtensionInstance """ data = values.of({'Enabled': enabled,}) payload = self._version.update( 'POST', self._uri, data=data, ) return InstalledAddOnExtensionInstance( self._version, payload, installed_add_on_sid=self._solution['installed_add_on_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class InstalledAddOnExtensionInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, payload, installed_add_on_sid, sid=None): """ Initialize the InstalledAddOnExtensionInstance :returns: twilio.rest.preview.marketplace.installed_add_on.installed_add_on_extension.InstalledAddOnExtensionInstance :rtype: twilio.rest.preview.marketplace.installed_add_on.installed_add_on_extension.InstalledAddOnExtensionInstance """ super(InstalledAddOnExtensionInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'installed_add_on_sid': payload['installed_add_on_sid'], 'friendly_name': payload['friendly_name'], 'product_name': payload['product_name'], 'unique_name': payload['unique_name'], 'enabled': payload['enabled'], 'url': payload['url'], } # Context self._context = None self._solution = { 'installed_add_on_sid': installed_add_on_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: InstalledAddOnExtensionContext for this InstalledAddOnExtensionInstance :rtype: twilio.rest.preview.marketplace.installed_add_on.installed_add_on_extension.InstalledAddOnExtensionContext """ if self._context is None: self._context = InstalledAddOnExtensionContext( self._version, installed_add_on_sid=self._solution['installed_add_on_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: A string that uniquely identifies this Extension :rtype: unicode """ return self._properties['sid'] @property def installed_add_on_sid(self): """ :returns: The installed_add_on_sid :rtype: unicode """ return self._properties['installed_add_on_sid'] @property def friendly_name(self): """ :returns: A human-readable description of this Extension :rtype: unicode """ return self._properties['friendly_name'] @property def product_name(self): """ :returns: A human-readable description of the Extension's Product :rtype: unicode """ return self._properties['product_name'] @property def unique_name(self): """ :returns: The string that uniquely identifies this Extension :rtype: unicode """ return self._properties['unique_name'] @property def enabled(self): """ :returns: A Boolean indicating if the Extension will be invoked :rtype: bool """ return self._properties['enabled'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a InstalledAddOnExtensionInstance :returns: Fetched InstalledAddOnExtensionInstance :rtype: twilio.rest.preview.marketplace.installed_add_on.installed_add_on_extension.InstalledAddOnExtensionInstance """ return self._proxy.fetch() def update(self, enabled): """ Update the InstalledAddOnExtensionInstance :param bool enabled: A Boolean indicating if the Extension will be invoked :returns: Updated InstalledAddOnExtensionInstance :rtype: twilio.rest.preview.marketplace.installed_add_on.installed_add_on_extension.InstalledAddOnExtensionInstance """ return self._proxy.update(enabled,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/preview/proxy/000077500000000000000000000000001317472742600215205ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/preview/proxy/__init__.py000066400000000000000000000017351317472742600236370ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.version import Version from twilio.rest.preview.proxy.service import ServiceList class Proxy(Version): def __init__(self, domain): """ Initialize the Proxy version of Preview :returns: Proxy version of Preview :rtype: twilio.rest.preview.proxy.Proxy.Proxy """ super(Proxy, self).__init__(domain) self.version = 'Proxy' self._services = None @property def services(self): """ :rtype: twilio.rest.preview.proxy.service.ServiceList """ if self._services is None: self._services = ServiceList(self) return self._services def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/preview/proxy/service/000077500000000000000000000000001317472742600231605ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/preview/proxy/service/__init__.py000066400000000000000000000425031317472742600252750ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.preview.proxy.service.phone_number import PhoneNumberList from twilio.rest.preview.proxy.service.session import SessionList from twilio.rest.preview.proxy.service.short_code import ShortCodeList class ServiceList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version): """ Initialize the ServiceList :param Version version: Version that contains the resource :returns: twilio.rest.preview.proxy.service.ServiceList :rtype: twilio.rest.preview.proxy.service.ServiceList """ super(ServiceList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/Services'.format(**self._solution) def stream(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.proxy.service.ServiceInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.proxy.service.ServiceInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of ServiceInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of ServiceInstance :rtype: twilio.rest.preview.proxy.service.ServicePage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return ServicePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of ServiceInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of ServiceInstance :rtype: twilio.rest.preview.proxy.service.ServicePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return ServicePage(self._version, response, self._solution) def create(self, friendly_name=values.unset, auto_create=values.unset, callback_url=values.unset): """ Create a new ServiceInstance :param unicode friendly_name: A human readable description of this resource :param bool auto_create: Boolean flag specifying whether to auto-create threads. :param unicode callback_url: URL Twilio will request for callbacks. :returns: Newly created ServiceInstance :rtype: twilio.rest.preview.proxy.service.ServiceInstance """ data = values.of({ 'FriendlyName': friendly_name, 'AutoCreate': auto_create, 'CallbackUrl': callback_url, }) payload = self._version.create( 'POST', self._uri, data=data, ) return ServiceInstance(self._version, payload,) def get(self, sid): """ Constructs a ServiceContext :param sid: A string that uniquely identifies this Service. :returns: twilio.rest.preview.proxy.service.ServiceContext :rtype: twilio.rest.preview.proxy.service.ServiceContext """ return ServiceContext(self._version, sid=sid,) def __call__(self, sid): """ Constructs a ServiceContext :param sid: A string that uniquely identifies this Service. :returns: twilio.rest.preview.proxy.service.ServiceContext :rtype: twilio.rest.preview.proxy.service.ServiceContext """ return ServiceContext(self._version, sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ServicePage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the ServicePage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.preview.proxy.service.ServicePage :rtype: twilio.rest.preview.proxy.service.ServicePage """ super(ServicePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of ServiceInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.proxy.service.ServiceInstance :rtype: twilio.rest.preview.proxy.service.ServiceInstance """ return ServiceInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ServiceContext(InstanceContext): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, sid): """ Initialize the ServiceContext :param Version version: Version that contains the resource :param sid: A string that uniquely identifies this Service. :returns: twilio.rest.preview.proxy.service.ServiceContext :rtype: twilio.rest.preview.proxy.service.ServiceContext """ super(ServiceContext, self).__init__(version) # Path Solution self._solution = {'sid': sid,} self._uri = '/Services/{sid}'.format(**self._solution) # Dependents self._sessions = None self._phone_numbers = None self._short_codes = None def fetch(self): """ Fetch a ServiceInstance :returns: Fetched ServiceInstance :rtype: twilio.rest.preview.proxy.service.ServiceInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return ServiceInstance(self._version, payload, sid=self._solution['sid'],) def delete(self): """ Deletes the ServiceInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, friendly_name=values.unset, auto_create=values.unset, callback_url=values.unset): """ Update the ServiceInstance :param unicode friendly_name: A human readable description of this resource :param bool auto_create: Boolean flag specifying whether to auto-create threads. :param unicode callback_url: URL Twilio will request for callbacks. :returns: Updated ServiceInstance :rtype: twilio.rest.preview.proxy.service.ServiceInstance """ data = values.of({ 'FriendlyName': friendly_name, 'AutoCreate': auto_create, 'CallbackUrl': callback_url, }) payload = self._version.update( 'POST', self._uri, data=data, ) return ServiceInstance(self._version, payload, sid=self._solution['sid'],) @property def sessions(self): """ Access the sessions :returns: twilio.rest.preview.proxy.service.session.SessionList :rtype: twilio.rest.preview.proxy.service.session.SessionList """ if self._sessions is None: self._sessions = SessionList(self._version, service_sid=self._solution['sid'],) return self._sessions @property def phone_numbers(self): """ Access the phone_numbers :returns: twilio.rest.preview.proxy.service.phone_number.PhoneNumberList :rtype: twilio.rest.preview.proxy.service.phone_number.PhoneNumberList """ if self._phone_numbers is None: self._phone_numbers = PhoneNumberList(self._version, service_sid=self._solution['sid'],) return self._phone_numbers @property def short_codes(self): """ Access the short_codes :returns: twilio.rest.preview.proxy.service.short_code.ShortCodeList :rtype: twilio.rest.preview.proxy.service.short_code.ShortCodeList """ if self._short_codes is None: self._short_codes = ShortCodeList(self._version, service_sid=self._solution['sid'],) return self._short_codes def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class ServiceInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, payload, sid=None): """ Initialize the ServiceInstance :returns: twilio.rest.preview.proxy.service.ServiceInstance :rtype: twilio.rest.preview.proxy.service.ServiceInstance """ super(ServiceInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'friendly_name': payload['friendly_name'], 'account_sid': payload['account_sid'], 'auto_create': payload['auto_create'], 'callback_url': payload['callback_url'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'url': payload['url'], 'links': payload['links'], } # Context self._context = None self._solution = {'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.preview.proxy.service.ServiceContext """ if self._context is None: self._context = ServiceContext(self._version, sid=self._solution['sid'],) return self._context @property def sid(self): """ :returns: A string that uniquely identifies this Service. :rtype: unicode """ return self._properties['sid'] @property def friendly_name(self): """ :returns: A human readable description of this resource :rtype: unicode """ return self._properties['friendly_name'] @property def account_sid(self): """ :returns: Account Sid. :rtype: unicode """ return self._properties['account_sid'] @property def auto_create(self): """ :returns: Boolean flag specifying whether to auto-create threads. :rtype: bool """ return self._properties['auto_create'] @property def callback_url(self): """ :returns: URL Twilio will request for callbacks. :rtype: unicode """ return self._properties['callback_url'] @property def date_created(self): """ :returns: The date this Service was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this Service was updated :rtype: datetime """ return self._properties['date_updated'] @property def url(self): """ :returns: The URL of this resource. :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: Nested resource URLs. :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a ServiceInstance :returns: Fetched ServiceInstance :rtype: twilio.rest.preview.proxy.service.ServiceInstance """ return self._proxy.fetch() def delete(self): """ Deletes the ServiceInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, friendly_name=values.unset, auto_create=values.unset, callback_url=values.unset): """ Update the ServiceInstance :param unicode friendly_name: A human readable description of this resource :param bool auto_create: Boolean flag specifying whether to auto-create threads. :param unicode callback_url: URL Twilio will request for callbacks. :returns: Updated ServiceInstance :rtype: twilio.rest.preview.proxy.service.ServiceInstance """ return self._proxy.update( friendly_name=friendly_name, auto_create=auto_create, callback_url=callback_url, ) @property def sessions(self): """ Access the sessions :returns: twilio.rest.preview.proxy.service.session.SessionList :rtype: twilio.rest.preview.proxy.service.session.SessionList """ return self._proxy.sessions @property def phone_numbers(self): """ Access the phone_numbers :returns: twilio.rest.preview.proxy.service.phone_number.PhoneNumberList :rtype: twilio.rest.preview.proxy.service.phone_number.PhoneNumberList """ return self._proxy.phone_numbers @property def short_codes(self): """ Access the short_codes :returns: twilio.rest.preview.proxy.service.short_code.ShortCodeList :rtype: twilio.rest.preview.proxy.service.short_code.ShortCodeList """ return self._proxy.short_codes def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/preview/proxy/service/phone_number.py000066400000000000000000000341751317472742600262250ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class PhoneNumberList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, service_sid): """ Initialize the PhoneNumberList :param Version version: Version that contains the resource :param service_sid: Service Sid. :returns: twilio.rest.preview.proxy.service.phone_number.PhoneNumberList :rtype: twilio.rest.preview.proxy.service.phone_number.PhoneNumberList """ super(PhoneNumberList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid,} self._uri = '/Services/{service_sid}/PhoneNumbers'.format(**self._solution) def create(self, sid): """ Create a new PhoneNumberInstance :param unicode sid: Delete by unique phone-number Sid :returns: Newly created PhoneNumberInstance :rtype: twilio.rest.preview.proxy.service.phone_number.PhoneNumberInstance """ data = values.of({'Sid': sid,}) payload = self._version.create( 'POST', self._uri, data=data, ) return PhoneNumberInstance(self._version, payload, service_sid=self._solution['service_sid'],) def stream(self, limit=None, page_size=None): """ Streams PhoneNumberInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.proxy.service.phone_number.PhoneNumberInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists PhoneNumberInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.proxy.service.phone_number.PhoneNumberInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of PhoneNumberInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of PhoneNumberInstance :rtype: twilio.rest.preview.proxy.service.phone_number.PhoneNumberPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return PhoneNumberPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of PhoneNumberInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of PhoneNumberInstance :rtype: twilio.rest.preview.proxy.service.phone_number.PhoneNumberPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return PhoneNumberPage(self._version, response, self._solution) def get(self, sid): """ Constructs a PhoneNumberContext :param sid: Fetch by unique phone-number Sid :returns: twilio.rest.preview.proxy.service.phone_number.PhoneNumberContext :rtype: twilio.rest.preview.proxy.service.phone_number.PhoneNumberContext """ return PhoneNumberContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __call__(self, sid): """ Constructs a PhoneNumberContext :param sid: Fetch by unique phone-number Sid :returns: twilio.rest.preview.proxy.service.phone_number.PhoneNumberContext :rtype: twilio.rest.preview.proxy.service.phone_number.PhoneNumberContext """ return PhoneNumberContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class PhoneNumberPage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the PhoneNumberPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: Service Sid. :returns: twilio.rest.preview.proxy.service.phone_number.PhoneNumberPage :rtype: twilio.rest.preview.proxy.service.phone_number.PhoneNumberPage """ super(PhoneNumberPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of PhoneNumberInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.proxy.service.phone_number.PhoneNumberInstance :rtype: twilio.rest.preview.proxy.service.phone_number.PhoneNumberInstance """ return PhoneNumberInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class PhoneNumberContext(InstanceContext): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, service_sid, sid): """ Initialize the PhoneNumberContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param sid: Fetch by unique phone-number Sid :returns: twilio.rest.preview.proxy.service.phone_number.PhoneNumberContext :rtype: twilio.rest.preview.proxy.service.phone_number.PhoneNumberContext """ super(PhoneNumberContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/PhoneNumbers/{sid}'.format(**self._solution) def delete(self): """ Deletes the PhoneNumberInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def fetch(self): """ Fetch a PhoneNumberInstance :returns: Fetched PhoneNumberInstance :rtype: twilio.rest.preview.proxy.service.phone_number.PhoneNumberInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return PhoneNumberInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class PhoneNumberInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, payload, service_sid, sid=None): """ Initialize the PhoneNumberInstance :returns: twilio.rest.preview.proxy.service.phone_number.PhoneNumberInstance :rtype: twilio.rest.preview.proxy.service.phone_number.PhoneNumberInstance """ super(PhoneNumberInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'phone_number': payload['phone_number'], 'country_code': payload['country_code'], 'capabilities': payload['capabilities'], 'url': payload['url'], } # Context self._context = None self._solution = {'service_sid': service_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: PhoneNumberContext for this PhoneNumberInstance :rtype: twilio.rest.preview.proxy.service.phone_number.PhoneNumberContext """ if self._context is None: self._context = PhoneNumberContext( self._version, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: A string that uniquely identifies this resource :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: Account Sid. :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: Service Sid. :rtype: unicode """ return self._properties['service_sid'] @property def date_created(self): """ :returns: The date this resource was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this resource was last updated :rtype: datetime """ return self._properties['date_updated'] @property def phone_number(self): """ :returns: The phone number :rtype: unicode """ return self._properties['phone_number'] @property def country_code(self): """ :returns: The ISO 3166-1 alpha-2 country code :rtype: unicode """ return self._properties['country_code'] @property def capabilities(self): """ :returns: Indicate if a phone can receive calls or messages :rtype: unicode """ return self._properties['capabilities'] @property def url(self): """ :returns: The URL of this resource. :rtype: unicode """ return self._properties['url'] def delete(self): """ Deletes the PhoneNumberInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def fetch(self): """ Fetch a PhoneNumberInstance :returns: Fetched PhoneNumberInstance :rtype: twilio.rest.preview.proxy.service.phone_number.PhoneNumberInstance """ return self._proxy.fetch() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/preview/proxy/service/session/000077500000000000000000000000001317472742600246435ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/preview/proxy/service/session/__init__.py000066400000000000000000000470731317472742600267670ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.preview.proxy.service.session.interaction import InteractionList from twilio.rest.preview.proxy.service.session.participant import ParticipantList class SessionList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, service_sid): """ Initialize the SessionList :param Version version: Version that contains the resource :param service_sid: Service Sid. :returns: twilio.rest.preview.proxy.service.session.SessionList :rtype: twilio.rest.preview.proxy.service.session.SessionList """ super(SessionList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid,} self._uri = '/Services/{service_sid}/Sessions'.format(**self._solution) def stream(self, unique_name=values.unset, status=values.unset, limit=None, page_size=None): """ 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 unicode unique_name: A unique, developer assigned name of this Session. :param SessionInstance.Status status: The Status of this Session :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.proxy.service.session.SessionInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(unique_name=unique_name, status=status, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, unique_name=values.unset, status=values.unset, limit=None, page_size=None): """ 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 unicode unique_name: A unique, developer assigned name of this Session. :param SessionInstance.Status status: The Status of this Session :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.proxy.service.session.SessionInstance] """ return list(self.stream(unique_name=unique_name, status=status, limit=limit, page_size=page_size,)) def page(self, unique_name=values.unset, status=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of SessionInstance records from the API. Request is executed immediately :param unicode unique_name: A unique, developer assigned name of this Session. :param SessionInstance.Status status: The Status of this Session :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of SessionInstance :rtype: twilio.rest.preview.proxy.service.session.SessionPage """ params = values.of({ 'UniqueName': unique_name, 'Status': status, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return SessionPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of SessionInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of SessionInstance :rtype: twilio.rest.preview.proxy.service.session.SessionPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return SessionPage(self._version, response, self._solution) def create(self, unique_name=values.unset, ttl=values.unset, status=values.unset, participants=values.unset): """ Create a new SessionInstance :param unicode unique_name: A unique, developer assigned name of this Session. :param unicode ttl: How long will this session stay open, in seconds. :param SessionInstance.Status status: The Status of this Session :param unicode participants: The participants :returns: Newly created SessionInstance :rtype: twilio.rest.preview.proxy.service.session.SessionInstance """ data = values.of({ 'UniqueName': unique_name, 'Ttl': ttl, 'Status': status, 'Participants': participants, }) payload = self._version.create( 'POST', self._uri, data=data, ) return SessionInstance(self._version, payload, service_sid=self._solution['service_sid'],) def get(self, sid): """ Constructs a SessionContext :param sid: A string that uniquely identifies this Session. :returns: twilio.rest.preview.proxy.service.session.SessionContext :rtype: twilio.rest.preview.proxy.service.session.SessionContext """ return SessionContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __call__(self, sid): """ Constructs a SessionContext :param sid: A string that uniquely identifies this Session. :returns: twilio.rest.preview.proxy.service.session.SessionContext :rtype: twilio.rest.preview.proxy.service.session.SessionContext """ return SessionContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SessionPage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the SessionPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: Service Sid. :returns: twilio.rest.preview.proxy.service.session.SessionPage :rtype: twilio.rest.preview.proxy.service.session.SessionPage """ super(SessionPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of SessionInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.proxy.service.session.SessionInstance :rtype: twilio.rest.preview.proxy.service.session.SessionInstance """ return SessionInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SessionContext(InstanceContext): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, service_sid, sid): """ Initialize the SessionContext :param Version version: Version that contains the resource :param service_sid: Service Sid. :param sid: A string that uniquely identifies this Session. :returns: twilio.rest.preview.proxy.service.session.SessionContext :rtype: twilio.rest.preview.proxy.service.session.SessionContext """ super(SessionContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Sessions/{sid}'.format(**self._solution) # Dependents self._interactions = None self._participants = None def fetch(self): """ Fetch a SessionInstance :returns: Fetched SessionInstance :rtype: twilio.rest.preview.proxy.service.session.SessionInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return SessionInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the SessionInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, unique_name=values.unset, ttl=values.unset, status=values.unset, participants=values.unset): """ Update the SessionInstance :param unicode unique_name: A unique, developer assigned name of this Session. :param unicode ttl: How long will this session stay open, in seconds. :param SessionInstance.Status status: The Status of this Session :param unicode participants: The participants :returns: Updated SessionInstance :rtype: twilio.rest.preview.proxy.service.session.SessionInstance """ data = values.of({ 'UniqueName': unique_name, 'Ttl': ttl, 'Status': status, 'Participants': participants, }) payload = self._version.update( 'POST', self._uri, data=data, ) return SessionInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) @property def interactions(self): """ Access the interactions :returns: twilio.rest.preview.proxy.service.session.interaction.InteractionList :rtype: twilio.rest.preview.proxy.service.session.interaction.InteractionList """ if self._interactions is None: self._interactions = InteractionList( self._version, service_sid=self._solution['service_sid'], session_sid=self._solution['sid'], ) return self._interactions @property def participants(self): """ Access the participants :returns: twilio.rest.preview.proxy.service.session.participant.ParticipantList :rtype: twilio.rest.preview.proxy.service.session.participant.ParticipantList """ if self._participants is None: self._participants = ParticipantList( self._version, service_sid=self._solution['service_sid'], session_sid=self._solution['sid'], ) return self._participants def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class SessionInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ class Status(object): IN_PROGESS = "in-progess" COMPLETED = "completed" def __init__(self, version, payload, service_sid, sid=None): """ Initialize the SessionInstance :returns: twilio.rest.preview.proxy.service.session.SessionInstance :rtype: twilio.rest.preview.proxy.service.session.SessionInstance """ super(SessionInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'service_sid': payload['service_sid'], 'account_sid': payload['account_sid'], 'unique_name': payload['unique_name'], 'ttl': deserialize.integer(payload['ttl']), 'status': payload['status'], 'start_time': deserialize.iso8601_datetime(payload['start_time']), 'end_time': deserialize.iso8601_datetime(payload['end_time']), 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'url': payload['url'], 'links': payload['links'], } # Context self._context = None self._solution = {'service_sid': service_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.preview.proxy.service.session.SessionContext """ if self._context is None: self._context = SessionContext( self._version, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: A string that uniquely identifies this Session. :rtype: unicode """ return self._properties['sid'] @property def service_sid(self): """ :returns: Service Sid. :rtype: unicode """ return self._properties['service_sid'] @property def account_sid(self): """ :returns: Account Sid. :rtype: unicode """ return self._properties['account_sid'] @property def unique_name(self): """ :returns: A unique, developer assigned name of this Session. :rtype: unicode """ return self._properties['unique_name'] @property def ttl(self): """ :returns: How long will this session stay open, in seconds. :rtype: unicode """ return self._properties['ttl'] @property def status(self): """ :returns: The Status of this Session :rtype: SessionInstance.Status """ return self._properties['status'] @property def start_time(self): """ :returns: The date this Session was started :rtype: datetime """ return self._properties['start_time'] @property def end_time(self): """ :returns: The date this Session was ended :rtype: datetime """ return self._properties['end_time'] @property def date_created(self): """ :returns: The date this Session was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this Session was updated :rtype: datetime """ return self._properties['date_updated'] @property def url(self): """ :returns: The URL of this Session. :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: Nested resource URLs. :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a SessionInstance :returns: Fetched SessionInstance :rtype: twilio.rest.preview.proxy.service.session.SessionInstance """ return self._proxy.fetch() def delete(self): """ Deletes the SessionInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, unique_name=values.unset, ttl=values.unset, status=values.unset, participants=values.unset): """ Update the SessionInstance :param unicode unique_name: A unique, developer assigned name of this Session. :param unicode ttl: How long will this session stay open, in seconds. :param SessionInstance.Status status: The Status of this Session :param unicode participants: The participants :returns: Updated SessionInstance :rtype: twilio.rest.preview.proxy.service.session.SessionInstance """ return self._proxy.update(unique_name=unique_name, ttl=ttl, status=status, participants=participants,) @property def interactions(self): """ Access the interactions :returns: twilio.rest.preview.proxy.service.session.interaction.InteractionList :rtype: twilio.rest.preview.proxy.service.session.interaction.InteractionList """ return self._proxy.interactions @property def participants(self): """ Access the participants :returns: twilio.rest.preview.proxy.service.session.participant.ParticipantList :rtype: twilio.rest.preview.proxy.service.session.participant.ParticipantList """ return self._proxy.participants def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/preview/proxy/service/session/interaction.py000066400000000000000000000454441317472742600275470ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class InteractionList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, service_sid, session_sid): """ Initialize the InteractionList :param Version version: Version that contains the resource :param service_sid: Service Sid. :param session_sid: Session Sid. :returns: twilio.rest.preview.proxy.service.session.interaction.InteractionList :rtype: twilio.rest.preview.proxy.service.session.interaction.InteractionList """ super(InteractionList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'session_sid': session_sid,} self._uri = '/Services/{service_sid}/Sessions/{session_sid}/Interactions'.format(**self._solution) def stream(self, inbound_participant_status=values.unset, outbound_participant_status=values.unset, limit=None, page_size=None): """ Streams InteractionInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param InteractionInstance.ResourceStatus inbound_participant_status: The Inbound Participant Status of this Interaction :param InteractionInstance.ResourceStatus outbound_participant_status: The Outbound Participant Status of this Interaction :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.proxy.service.session.interaction.InteractionInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( inbound_participant_status=inbound_participant_status, outbound_participant_status=outbound_participant_status, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, inbound_participant_status=values.unset, outbound_participant_status=values.unset, limit=None, page_size=None): """ Lists InteractionInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param InteractionInstance.ResourceStatus inbound_participant_status: The Inbound Participant Status of this Interaction :param InteractionInstance.ResourceStatus outbound_participant_status: The Outbound Participant Status of this Interaction :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.proxy.service.session.interaction.InteractionInstance] """ return list(self.stream( inbound_participant_status=inbound_participant_status, outbound_participant_status=outbound_participant_status, limit=limit, page_size=page_size, )) def page(self, inbound_participant_status=values.unset, outbound_participant_status=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of InteractionInstance records from the API. Request is executed immediately :param InteractionInstance.ResourceStatus inbound_participant_status: The Inbound Participant Status of this Interaction :param InteractionInstance.ResourceStatus outbound_participant_status: The Outbound Participant Status of this Interaction :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of InteractionInstance :rtype: twilio.rest.preview.proxy.service.session.interaction.InteractionPage """ params = values.of({ 'InboundParticipantStatus': inbound_participant_status, 'OutboundParticipantStatus': outbound_participant_status, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return InteractionPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of InteractionInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of InteractionInstance :rtype: twilio.rest.preview.proxy.service.session.interaction.InteractionPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return InteractionPage(self._version, response, self._solution) def get(self, sid): """ Constructs a InteractionContext :param sid: A string that uniquely identifies this Interaction. :returns: twilio.rest.preview.proxy.service.session.interaction.InteractionContext :rtype: twilio.rest.preview.proxy.service.session.interaction.InteractionContext """ return InteractionContext( self._version, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a InteractionContext :param sid: A string that uniquely identifies this Interaction. :returns: twilio.rest.preview.proxy.service.session.interaction.InteractionContext :rtype: twilio.rest.preview.proxy.service.session.interaction.InteractionContext """ return InteractionContext( self._version, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class InteractionPage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the InteractionPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: Service Sid. :param session_sid: Session Sid. :returns: twilio.rest.preview.proxy.service.session.interaction.InteractionPage :rtype: twilio.rest.preview.proxy.service.session.interaction.InteractionPage """ super(InteractionPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of InteractionInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.proxy.service.session.interaction.InteractionInstance :rtype: twilio.rest.preview.proxy.service.session.interaction.InteractionInstance """ return InteractionInstance( self._version, payload, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class InteractionContext(InstanceContext): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, service_sid, session_sid, sid): """ Initialize the InteractionContext :param Version version: Version that contains the resource :param service_sid: Service Sid. :param session_sid: Session Sid. :param sid: A string that uniquely identifies this Interaction. :returns: twilio.rest.preview.proxy.service.session.interaction.InteractionContext :rtype: twilio.rest.preview.proxy.service.session.interaction.InteractionContext """ super(InteractionContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'session_sid': session_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Sessions/{session_sid}/Interactions/{sid}'.format(**self._solution) def fetch(self): """ Fetch a InteractionInstance :returns: Fetched InteractionInstance :rtype: twilio.rest.preview.proxy.service.session.interaction.InteractionInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return InteractionInstance( self._version, payload, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class InteractionInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ class Status(object): COMPLETED = "completed" IN_PROGRESS = "in-progress" FAILED = "failed" class ResourceStatus(object): QUEUED = "queued" SENDING = "sending" SENT = "sent" FAILED = "failed" DELIVERED = "delivered" UNDELIVERED = "undelivered" def __init__(self, version, payload, service_sid, session_sid, sid=None): """ Initialize the InteractionInstance :returns: twilio.rest.preview.proxy.service.session.interaction.InteractionInstance :rtype: twilio.rest.preview.proxy.service.session.interaction.InteractionInstance """ super(InteractionInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'session_sid': payload['session_sid'], 'service_sid': payload['service_sid'], 'account_sid': payload['account_sid'], 'data': payload['data'], 'status': payload['status'], 'inbound_participant_sid': payload['inbound_participant_sid'], 'inbound_resource_sid': payload['inbound_resource_sid'], 'inbound_resource_status': payload['inbound_resource_status'], 'inbound_resource_type': payload['inbound_resource_type'], 'inbound_resource_url': payload['inbound_resource_url'], 'outbound_participant_sid': payload['outbound_participant_sid'], 'outbound_resource_sid': payload['outbound_resource_sid'], 'outbound_resource_status': payload['outbound_resource_status'], 'outbound_resource_type': payload['outbound_resource_type'], 'outbound_resource_url': payload['outbound_resource_url'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'url': payload['url'], } # Context self._context = None self._solution = { 'service_sid': service_sid, 'session_sid': session_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: InteractionContext for this InteractionInstance :rtype: twilio.rest.preview.proxy.service.session.interaction.InteractionContext """ if self._context is None: self._context = InteractionContext( self._version, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: A string that uniquely identifies this Interaction. :rtype: unicode """ return self._properties['sid'] @property def session_sid(self): """ :returns: Session Sid. :rtype: unicode """ return self._properties['session_sid'] @property def service_sid(self): """ :returns: Service Sid. :rtype: unicode """ return self._properties['service_sid'] @property def account_sid(self): """ :returns: Account Sid. :rtype: unicode """ return self._properties['account_sid'] @property def data(self): """ :returns: What happened in this Interaction. :rtype: unicode """ return self._properties['data'] @property def status(self): """ :returns: The Status of this Interaction :rtype: InteractionInstance.Status """ return self._properties['status'] @property def inbound_participant_sid(self): """ :returns: The inbound_participant_sid :rtype: unicode """ return self._properties['inbound_participant_sid'] @property def inbound_resource_sid(self): """ :returns: The SID of the inbound resource. :rtype: unicode """ return self._properties['inbound_resource_sid'] @property def inbound_resource_status(self): """ :returns: The Inbound Resource Status of this Interaction :rtype: InteractionInstance.ResourceStatus """ return self._properties['inbound_resource_status'] @property def inbound_resource_type(self): """ :returns: The Twilio object type of the inbound resource. :rtype: unicode """ return self._properties['inbound_resource_type'] @property def inbound_resource_url(self): """ :returns: The URL of the inbound resource. :rtype: unicode """ return self._properties['inbound_resource_url'] @property def outbound_participant_sid(self): """ :returns: The outbound_participant_sid :rtype: unicode """ return self._properties['outbound_participant_sid'] @property def outbound_resource_sid(self): """ :returns: The SID of the outbound resource. :rtype: unicode """ return self._properties['outbound_resource_sid'] @property def outbound_resource_status(self): """ :returns: The Outbound Resource Status of this Interaction :rtype: InteractionInstance.ResourceStatus """ return self._properties['outbound_resource_status'] @property def outbound_resource_type(self): """ :returns: The Twilio object type of the outbound resource. :rtype: unicode """ return self._properties['outbound_resource_type'] @property def outbound_resource_url(self): """ :returns: The URL of the outbound resource. :rtype: unicode """ return self._properties['outbound_resource_url'] @property def date_created(self): """ :returns: The date this Interaction was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this Interaction was updated :rtype: datetime """ return self._properties['date_updated'] @property def url(self): """ :returns: The URL of this Interaction. :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a InteractionInstance :returns: Fetched InteractionInstance :rtype: twilio.rest.preview.proxy.service.session.interaction.InteractionInstance """ return self._proxy.fetch() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/preview/proxy/service/session/participant/000077500000000000000000000000001317472742600271615ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/preview/proxy/service/session/participant/__init__.py000066400000000000000000000513011317472742600312720ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.preview.proxy.service.session.participant.message_interaction import MessageInteractionList class ParticipantList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, service_sid, session_sid): """ Initialize the ParticipantList :param Version version: Version that contains the resource :param service_sid: Service Sid. :param session_sid: Session Sid. :returns: twilio.rest.preview.proxy.service.session.participant.ParticipantList :rtype: twilio.rest.preview.proxy.service.session.participant.ParticipantList """ super(ParticipantList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'session_sid': session_sid,} self._uri = '/Services/{service_sid}/Sessions/{session_sid}/Participants'.format(**self._solution) def stream(self, identifier=values.unset, participant_type=values.unset, limit=None, page_size=None): """ Streams ParticipantInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param unicode identifier: The Participant's contact identifier, normally a phone number. :param ParticipantInstance.ParticipantType participant_type: The Type of this Participant :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.proxy.service.session.participant.ParticipantInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( identifier=identifier, participant_type=participant_type, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, identifier=values.unset, participant_type=values.unset, limit=None, page_size=None): """ Lists ParticipantInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param unicode identifier: The Participant's contact identifier, normally a phone number. :param ParticipantInstance.ParticipantType participant_type: The Type of this Participant :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.proxy.service.session.participant.ParticipantInstance] """ return list(self.stream( identifier=identifier, participant_type=participant_type, limit=limit, page_size=page_size, )) def page(self, identifier=values.unset, participant_type=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of ParticipantInstance records from the API. Request is executed immediately :param unicode identifier: The Participant's contact identifier, normally a phone number. :param ParticipantInstance.ParticipantType participant_type: The Type of this Participant :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of ParticipantInstance :rtype: twilio.rest.preview.proxy.service.session.participant.ParticipantPage """ params = values.of({ 'Identifier': identifier, 'ParticipantType': participant_type, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return ParticipantPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of ParticipantInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of ParticipantInstance :rtype: twilio.rest.preview.proxy.service.session.participant.ParticipantPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return ParticipantPage(self._version, response, self._solution) def create(self, identifier, friendly_name=values.unset, participant_type=values.unset): """ Create a new ParticipantInstance :param unicode identifier: The Participant's contact identifier, normally a phone number. :param unicode friendly_name: A human readable description of this resource :param ParticipantInstance.ParticipantType participant_type: The Type of this Participant :returns: Newly created ParticipantInstance :rtype: twilio.rest.preview.proxy.service.session.participant.ParticipantInstance """ data = values.of({ 'Identifier': identifier, 'FriendlyName': friendly_name, 'ParticipantType': participant_type, }) payload = self._version.create( 'POST', self._uri, data=data, ) return ParticipantInstance( self._version, payload, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], ) def get(self, sid): """ Constructs a ParticipantContext :param sid: A string that uniquely identifies this Participant. :returns: twilio.rest.preview.proxy.service.session.participant.ParticipantContext :rtype: twilio.rest.preview.proxy.service.session.participant.ParticipantContext """ return ParticipantContext( self._version, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a ParticipantContext :param sid: A string that uniquely identifies this Participant. :returns: twilio.rest.preview.proxy.service.session.participant.ParticipantContext :rtype: twilio.rest.preview.proxy.service.session.participant.ParticipantContext """ return ParticipantContext( self._version, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ParticipantPage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the ParticipantPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: Service Sid. :param session_sid: Session Sid. :returns: twilio.rest.preview.proxy.service.session.participant.ParticipantPage :rtype: twilio.rest.preview.proxy.service.session.participant.ParticipantPage """ super(ParticipantPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of ParticipantInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.proxy.service.session.participant.ParticipantInstance :rtype: twilio.rest.preview.proxy.service.session.participant.ParticipantInstance """ return ParticipantInstance( self._version, payload, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ParticipantContext(InstanceContext): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, service_sid, session_sid, sid): """ Initialize the ParticipantContext :param Version version: Version that contains the resource :param service_sid: Service Sid. :param session_sid: Session Sid. :param sid: A string that uniquely identifies this Participant. :returns: twilio.rest.preview.proxy.service.session.participant.ParticipantContext :rtype: twilio.rest.preview.proxy.service.session.participant.ParticipantContext """ super(ParticipantContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'session_sid': session_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Sessions/{session_sid}/Participants/{sid}'.format(**self._solution) # Dependents self._message_interactions = None def fetch(self): """ Fetch a ParticipantInstance :returns: Fetched ParticipantInstance :rtype: twilio.rest.preview.proxy.service.session.participant.ParticipantInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return ParticipantInstance( self._version, payload, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the ParticipantInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, participant_type=values.unset, identifier=values.unset, friendly_name=values.unset): """ Update the ParticipantInstance :param ParticipantInstance.ParticipantType participant_type: The Type of this Participant :param unicode identifier: The Participant's contact identifier, normally a phone number. :param unicode friendly_name: A human readable description of this resource :returns: Updated ParticipantInstance :rtype: twilio.rest.preview.proxy.service.session.participant.ParticipantInstance """ data = values.of({ 'ParticipantType': participant_type, 'Identifier': identifier, 'FriendlyName': friendly_name, }) payload = self._version.update( 'POST', self._uri, data=data, ) return ParticipantInstance( self._version, payload, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], sid=self._solution['sid'], ) @property def message_interactions(self): """ Access the message_interactions :returns: twilio.rest.preview.proxy.service.session.participant.message_interaction.MessageInteractionList :rtype: twilio.rest.preview.proxy.service.session.participant.message_interaction.MessageInteractionList """ if self._message_interactions is None: self._message_interactions = MessageInteractionList( self._version, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], participant_sid=self._solution['sid'], ) return self._message_interactions def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class ParticipantInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ class ParticipantType(object): SMS = "sms" VOICE = "voice" PHONE = "phone" def __init__(self, version, payload, service_sid, session_sid, sid=None): """ Initialize the ParticipantInstance :returns: twilio.rest.preview.proxy.service.session.participant.ParticipantInstance :rtype: twilio.rest.preview.proxy.service.session.participant.ParticipantInstance """ super(ParticipantInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'session_sid': payload['session_sid'], 'service_sid': payload['service_sid'], 'account_sid': payload['account_sid'], 'friendly_name': payload['friendly_name'], 'participant_type': payload['participant_type'], 'identifier': payload['identifier'], 'proxy_identifier': payload['proxy_identifier'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'url': payload['url'], 'links': payload['links'], } # Context self._context = None self._solution = { 'service_sid': service_sid, 'session_sid': session_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: ParticipantContext for this ParticipantInstance :rtype: twilio.rest.preview.proxy.service.session.participant.ParticipantContext """ if self._context is None: self._context = ParticipantContext( self._version, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: A string that uniquely identifies this Participant. :rtype: unicode """ return self._properties['sid'] @property def session_sid(self): """ :returns: Session Sid. :rtype: unicode """ return self._properties['session_sid'] @property def service_sid(self): """ :returns: Service Sid. :rtype: unicode """ return self._properties['service_sid'] @property def account_sid(self): """ :returns: Account Sid. :rtype: unicode """ return self._properties['account_sid'] @property def friendly_name(self): """ :returns: A human readable description of this resource :rtype: unicode """ return self._properties['friendly_name'] @property def participant_type(self): """ :returns: The Type of this Participant :rtype: ParticipantInstance.ParticipantType """ return self._properties['participant_type'] @property def identifier(self): """ :returns: The Participant's contact identifier, normally a phone number. :rtype: unicode """ return self._properties['identifier'] @property def proxy_identifier(self): """ :returns: What this Participant communicates with, normally a phone number. :rtype: unicode """ return self._properties['proxy_identifier'] @property def date_created(self): """ :returns: The date this Participant was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this Participant was updated :rtype: datetime """ return self._properties['date_updated'] @property def url(self): """ :returns: The URL of this resource. :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: Nested resource URLs. :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a ParticipantInstance :returns: Fetched ParticipantInstance :rtype: twilio.rest.preview.proxy.service.session.participant.ParticipantInstance """ return self._proxy.fetch() def delete(self): """ Deletes the ParticipantInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, participant_type=values.unset, identifier=values.unset, friendly_name=values.unset): """ Update the ParticipantInstance :param ParticipantInstance.ParticipantType participant_type: The Type of this Participant :param unicode identifier: The Participant's contact identifier, normally a phone number. :param unicode friendly_name: A human readable description of this resource :returns: Updated ParticipantInstance :rtype: twilio.rest.preview.proxy.service.session.participant.ParticipantInstance """ return self._proxy.update( participant_type=participant_type, identifier=identifier, friendly_name=friendly_name, ) @property def message_interactions(self): """ Access the message_interactions :returns: twilio.rest.preview.proxy.service.session.participant.message_interaction.MessageInteractionList :rtype: twilio.rest.preview.proxy.service.session.participant.message_interaction.MessageInteractionList """ return self._proxy.message_interactions def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/preview/proxy/service/session/participant/message_interaction.py000066400000000000000000000500161317472742600335600ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class MessageInteractionList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, service_sid, session_sid, participant_sid): """ Initialize the MessageInteractionList :param Version version: Version that contains the resource :param service_sid: Service Sid. :param session_sid: Session Sid. :param participant_sid: The participant_sid :returns: twilio.rest.preview.proxy.service.session.participant.message_interaction.MessageInteractionList :rtype: twilio.rest.preview.proxy.service.session.participant.message_interaction.MessageInteractionList """ super(MessageInteractionList, self).__init__(version) # Path Solution self._solution = { 'service_sid': service_sid, 'session_sid': session_sid, 'participant_sid': participant_sid, } self._uri = '/Services/{service_sid}/Sessions/{session_sid}/Participants/{participant_sid}/MessageInteractions'.format(**self._solution) def create(self, body=values.unset, media_url=values.unset): """ Create a new MessageInteractionInstance :param unicode body: The body of the message. Up to 1600 characters long. :param unicode media_url: The url of an image or video. :returns: Newly created MessageInteractionInstance :rtype: twilio.rest.preview.proxy.service.session.participant.message_interaction.MessageInteractionInstance """ data = values.of({'Body': body, 'MediaUrl': media_url,}) payload = self._version.create( 'POST', self._uri, data=data, ) return MessageInteractionInstance( self._version, payload, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], participant_sid=self._solution['participant_sid'], ) def stream(self, limit=None, page_size=None): """ Streams MessageInteractionInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.proxy.service.session.participant.message_interaction.MessageInteractionInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists MessageInteractionInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.proxy.service.session.participant.message_interaction.MessageInteractionInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of MessageInteractionInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of MessageInteractionInstance :rtype: twilio.rest.preview.proxy.service.session.participant.message_interaction.MessageInteractionPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return MessageInteractionPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of MessageInteractionInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of MessageInteractionInstance :rtype: twilio.rest.preview.proxy.service.session.participant.message_interaction.MessageInteractionPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return MessageInteractionPage(self._version, response, self._solution) def get(self, sid): """ Constructs a MessageInteractionContext :param sid: A string that uniquely identifies this Interaction. :returns: twilio.rest.preview.proxy.service.session.participant.message_interaction.MessageInteractionContext :rtype: twilio.rest.preview.proxy.service.session.participant.message_interaction.MessageInteractionContext """ return MessageInteractionContext( self._version, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], participant_sid=self._solution['participant_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a MessageInteractionContext :param sid: A string that uniquely identifies this Interaction. :returns: twilio.rest.preview.proxy.service.session.participant.message_interaction.MessageInteractionContext :rtype: twilio.rest.preview.proxy.service.session.participant.message_interaction.MessageInteractionContext """ return MessageInteractionContext( self._version, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], participant_sid=self._solution['participant_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class MessageInteractionPage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the MessageInteractionPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: Service Sid. :param session_sid: Session Sid. :param participant_sid: The participant_sid :returns: twilio.rest.preview.proxy.service.session.participant.message_interaction.MessageInteractionPage :rtype: twilio.rest.preview.proxy.service.session.participant.message_interaction.MessageInteractionPage """ super(MessageInteractionPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of MessageInteractionInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.proxy.service.session.participant.message_interaction.MessageInteractionInstance :rtype: twilio.rest.preview.proxy.service.session.participant.message_interaction.MessageInteractionInstance """ return MessageInteractionInstance( self._version, payload, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], participant_sid=self._solution['participant_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class MessageInteractionContext(InstanceContext): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, service_sid, session_sid, participant_sid, sid): """ Initialize the MessageInteractionContext :param Version version: Version that contains the resource :param service_sid: Service Sid. :param session_sid: Session Sid. :param participant_sid: Participant Sid. :param sid: A string that uniquely identifies this Interaction. :returns: twilio.rest.preview.proxy.service.session.participant.message_interaction.MessageInteractionContext :rtype: twilio.rest.preview.proxy.service.session.participant.message_interaction.MessageInteractionContext """ super(MessageInteractionContext, self).__init__(version) # Path Solution self._solution = { 'service_sid': service_sid, 'session_sid': session_sid, 'participant_sid': participant_sid, 'sid': sid, } self._uri = '/Services/{service_sid}/Sessions/{session_sid}/Participants/{participant_sid}/MessageInteractions/{sid}'.format(**self._solution) def fetch(self): """ Fetch a MessageInteractionInstance :returns: Fetched MessageInteractionInstance :rtype: twilio.rest.preview.proxy.service.session.participant.message_interaction.MessageInteractionInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return MessageInteractionInstance( self._version, payload, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], participant_sid=self._solution['participant_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class MessageInteractionInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ class Status(object): COMPLETED = "completed" IN_PROGRESS = "in-progress" FAILED = "failed" class ResourceStatus(object): QUEUED = "queued" SENDING = "sending" SENT = "sent" FAILED = "failed" DELIVERED = "delivered" UNDELIVERED = "undelivered" def __init__(self, version, payload, service_sid, session_sid, participant_sid, sid=None): """ Initialize the MessageInteractionInstance :returns: twilio.rest.preview.proxy.service.session.participant.message_interaction.MessageInteractionInstance :rtype: twilio.rest.preview.proxy.service.session.participant.message_interaction.MessageInteractionInstance """ super(MessageInteractionInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'session_sid': payload['session_sid'], 'service_sid': payload['service_sid'], 'account_sid': payload['account_sid'], 'data': payload['data'], 'status': payload['status'], 'participant_sid': payload['participant_sid'], 'inbound_participant_sid': payload['inbound_participant_sid'], 'inbound_resource_sid': payload['inbound_resource_sid'], 'inbound_resource_status': payload['inbound_resource_status'], 'inbound_resource_type': payload['inbound_resource_type'], 'inbound_resource_url': payload['inbound_resource_url'], 'outbound_participant_sid': payload['outbound_participant_sid'], 'outbound_resource_sid': payload['outbound_resource_sid'], 'outbound_resource_status': payload['outbound_resource_status'], 'outbound_resource_type': payload['outbound_resource_type'], 'outbound_resource_url': payload['outbound_resource_url'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'url': payload['url'], } # Context self._context = None self._solution = { 'service_sid': service_sid, 'session_sid': session_sid, 'participant_sid': participant_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: MessageInteractionContext for this MessageInteractionInstance :rtype: twilio.rest.preview.proxy.service.session.participant.message_interaction.MessageInteractionContext """ if self._context is None: self._context = MessageInteractionContext( self._version, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], participant_sid=self._solution['participant_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: A string that uniquely identifies this Interaction. :rtype: unicode """ return self._properties['sid'] @property def session_sid(self): """ :returns: Session Sid. :rtype: unicode """ return self._properties['session_sid'] @property def service_sid(self): """ :returns: Service Sid. :rtype: unicode """ return self._properties['service_sid'] @property def account_sid(self): """ :returns: Account Sid. :rtype: unicode """ return self._properties['account_sid'] @property def data(self): """ :returns: What happened in this Interaction. :rtype: unicode """ return self._properties['data'] @property def status(self): """ :returns: The Status of this Interaction :rtype: MessageInteractionInstance.Status """ return self._properties['status'] @property def participant_sid(self): """ :returns: The participant_sid :rtype: unicode """ return self._properties['participant_sid'] @property def inbound_participant_sid(self): """ :returns: The inbound_participant_sid :rtype: unicode """ return self._properties['inbound_participant_sid'] @property def inbound_resource_sid(self): """ :returns: The SID of the inbound resource. :rtype: unicode """ return self._properties['inbound_resource_sid'] @property def inbound_resource_status(self): """ :returns: The Inbound Resource Status of this Interaction :rtype: MessageInteractionInstance.ResourceStatus """ return self._properties['inbound_resource_status'] @property def inbound_resource_type(self): """ :returns: The Twilio object type of the inbound resource. :rtype: unicode """ return self._properties['inbound_resource_type'] @property def inbound_resource_url(self): """ :returns: The URL of the inbound resource. :rtype: unicode """ return self._properties['inbound_resource_url'] @property def outbound_participant_sid(self): """ :returns: The outbound_participant_sid :rtype: unicode """ return self._properties['outbound_participant_sid'] @property def outbound_resource_sid(self): """ :returns: The SID of the outbound resource. :rtype: unicode """ return self._properties['outbound_resource_sid'] @property def outbound_resource_status(self): """ :returns: The Outbound Resource Status of this Interaction :rtype: MessageInteractionInstance.ResourceStatus """ return self._properties['outbound_resource_status'] @property def outbound_resource_type(self): """ :returns: The Twilio object type of the outbound resource. :rtype: unicode """ return self._properties['outbound_resource_type'] @property def outbound_resource_url(self): """ :returns: The URL of the outbound resource. :rtype: unicode """ return self._properties['outbound_resource_url'] @property def date_created(self): """ :returns: The date this Interaction was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this Interaction was updated :rtype: datetime """ return self._properties['date_updated'] @property def url(self): """ :returns: The URL of this Interaction. :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a MessageInteractionInstance :returns: Fetched MessageInteractionInstance :rtype: twilio.rest.preview.proxy.service.session.participant.message_interaction.MessageInteractionInstance """ return self._proxy.fetch() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/preview/proxy/service/short_code.py000066400000000000000000000336741317472742600257000ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class ShortCodeList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, service_sid): """ Initialize the ShortCodeList :param Version version: Version that contains the resource :param service_sid: Service Sid. :returns: twilio.rest.preview.proxy.service.short_code.ShortCodeList :rtype: twilio.rest.preview.proxy.service.short_code.ShortCodeList """ super(ShortCodeList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid,} self._uri = '/Services/{service_sid}/ShortCodes'.format(**self._solution) def create(self, sid): """ Create a new ShortCodeInstance :param unicode sid: Delete by unique shortcode Sid :returns: Newly created ShortCodeInstance :rtype: twilio.rest.preview.proxy.service.short_code.ShortCodeInstance """ data = values.of({'Sid': sid,}) payload = self._version.create( 'POST', self._uri, data=data, ) return ShortCodeInstance(self._version, payload, service_sid=self._solution['service_sid'],) def stream(self, limit=None, page_size=None): """ Streams ShortCodeInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.proxy.service.short_code.ShortCodeInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists ShortCodeInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.proxy.service.short_code.ShortCodeInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of ShortCodeInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of ShortCodeInstance :rtype: twilio.rest.preview.proxy.service.short_code.ShortCodePage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return ShortCodePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of ShortCodeInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of ShortCodeInstance :rtype: twilio.rest.preview.proxy.service.short_code.ShortCodePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return ShortCodePage(self._version, response, self._solution) def get(self, sid): """ Constructs a ShortCodeContext :param sid: Fetch by unique shortcode Sid :returns: twilio.rest.preview.proxy.service.short_code.ShortCodeContext :rtype: twilio.rest.preview.proxy.service.short_code.ShortCodeContext """ return ShortCodeContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __call__(self, sid): """ Constructs a ShortCodeContext :param sid: Fetch by unique shortcode Sid :returns: twilio.rest.preview.proxy.service.short_code.ShortCodeContext :rtype: twilio.rest.preview.proxy.service.short_code.ShortCodeContext """ return ShortCodeContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ShortCodePage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the ShortCodePage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: Service Sid. :returns: twilio.rest.preview.proxy.service.short_code.ShortCodePage :rtype: twilio.rest.preview.proxy.service.short_code.ShortCodePage """ super(ShortCodePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of ShortCodeInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.proxy.service.short_code.ShortCodeInstance :rtype: twilio.rest.preview.proxy.service.short_code.ShortCodeInstance """ return ShortCodeInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ShortCodeContext(InstanceContext): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, service_sid, sid): """ Initialize the ShortCodeContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param sid: Fetch by unique shortcode Sid :returns: twilio.rest.preview.proxy.service.short_code.ShortCodeContext :rtype: twilio.rest.preview.proxy.service.short_code.ShortCodeContext """ super(ShortCodeContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/ShortCodes/{sid}'.format(**self._solution) def delete(self): """ Deletes the ShortCodeInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def fetch(self): """ Fetch a ShortCodeInstance :returns: Fetched ShortCodeInstance :rtype: twilio.rest.preview.proxy.service.short_code.ShortCodeInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return ShortCodeInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class ShortCodeInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, payload, service_sid, sid=None): """ Initialize the ShortCodeInstance :returns: twilio.rest.preview.proxy.service.short_code.ShortCodeInstance :rtype: twilio.rest.preview.proxy.service.short_code.ShortCodeInstance """ super(ShortCodeInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'short_code': payload['short_code'], 'country_code': payload['country_code'], 'capabilities': payload['capabilities'], 'url': payload['url'], } # Context self._context = None self._solution = {'service_sid': service_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.preview.proxy.service.short_code.ShortCodeContext """ if self._context is None: self._context = ShortCodeContext( self._version, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: A string that uniquely identifies this resource :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: Account Sid. :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: Service Sid. :rtype: unicode """ return self._properties['service_sid'] @property def date_created(self): """ :returns: The date this resource was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this resource was last updated :rtype: datetime """ return self._properties['date_updated'] @property def short_code(self): """ :returns: The short code. e.g., 894546. :rtype: unicode """ return self._properties['short_code'] @property def country_code(self): """ :returns: The ISO 3166-1 alpha-2 country code :rtype: unicode """ return self._properties['country_code'] @property def capabilities(self): """ :returns: Indicate if a shortcode can receive messages :rtype: dict """ return self._properties['capabilities'] @property def url(self): """ :returns: The URL of this resource. :rtype: unicode """ return self._properties['url'] def delete(self): """ Deletes the ShortCodeInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def fetch(self): """ Fetch a ShortCodeInstance :returns: Fetched ShortCodeInstance :rtype: twilio.rest.preview.proxy.service.short_code.ShortCodeInstance """ return self._proxy.fetch() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/preview/sync/000077500000000000000000000000001317472742600213135ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/preview/sync/__init__.py000066400000000000000000000017221317472742600234260ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.version import Version from twilio.rest.preview.sync.service import ServiceList class Sync(Version): def __init__(self, domain): """ Initialize the Sync version of Preview :returns: Sync version of Preview :rtype: twilio.rest.preview.sync.Sync.Sync """ super(Sync, self).__init__(domain) self.version = 'Sync' self._services = None @property def services(self): """ :rtype: twilio.rest.preview.sync.service.ServiceList """ if self._services is None: self._services = ServiceList(self) return self._services def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/preview/sync/service/000077500000000000000000000000001317472742600227535ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/preview/sync/service/__init__.py000066400000000000000000000430611317472742600250700ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.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 ServiceList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version): """ Initialize the ServiceList :param Version version: Version that contains the resource :returns: twilio.rest.preview.sync.service.ServiceList :rtype: twilio.rest.preview.sync.service.ServiceList """ super(ServiceList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/Services'.format(**self._solution) def create(self, friendly_name=values.unset, webhook_url=values.unset, reachability_webhooks_enabled=values.unset, acl_enabled=values.unset): """ Create a new ServiceInstance :param unicode friendly_name: The friendly_name :param unicode webhook_url: The webhook_url :param bool reachability_webhooks_enabled: The reachability_webhooks_enabled :param bool acl_enabled: The acl_enabled :returns: Newly created ServiceInstance :rtype: twilio.rest.preview.sync.service.ServiceInstance """ data = values.of({ 'FriendlyName': friendly_name, 'WebhookUrl': webhook_url, 'ReachabilityWebhooksEnabled': reachability_webhooks_enabled, 'AclEnabled': acl_enabled, }) payload = self._version.create( 'POST', self._uri, data=data, ) return ServiceInstance(self._version, payload,) def stream(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.sync.service.ServiceInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.sync.service.ServiceInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of ServiceInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of ServiceInstance :rtype: twilio.rest.preview.sync.service.ServicePage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return ServicePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of ServiceInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of ServiceInstance :rtype: twilio.rest.preview.sync.service.ServicePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return ServicePage(self._version, response, self._solution) def get(self, sid): """ Constructs a ServiceContext :param sid: The sid :returns: twilio.rest.preview.sync.service.ServiceContext :rtype: twilio.rest.preview.sync.service.ServiceContext """ return ServiceContext(self._version, sid=sid,) def __call__(self, sid): """ Constructs a ServiceContext :param sid: The sid :returns: twilio.rest.preview.sync.service.ServiceContext :rtype: twilio.rest.preview.sync.service.ServiceContext """ return ServiceContext(self._version, sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ServicePage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the ServicePage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.preview.sync.service.ServicePage :rtype: twilio.rest.preview.sync.service.ServicePage """ super(ServicePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of ServiceInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.sync.service.ServiceInstance :rtype: twilio.rest.preview.sync.service.ServiceInstance """ return ServiceInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ServiceContext(InstanceContext): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, sid): """ Initialize the ServiceContext :param Version version: Version that contains the resource :param sid: The sid :returns: twilio.rest.preview.sync.service.ServiceContext :rtype: twilio.rest.preview.sync.service.ServiceContext """ super(ServiceContext, self).__init__(version) # Path Solution self._solution = {'sid': sid,} self._uri = '/Services/{sid}'.format(**self._solution) # Dependents self._documents = None self._sync_lists = None self._sync_maps = None def fetch(self): """ Fetch a ServiceInstance :returns: Fetched ServiceInstance :rtype: twilio.rest.preview.sync.service.ServiceInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return ServiceInstance(self._version, payload, sid=self._solution['sid'],) def delete(self): """ Deletes the ServiceInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, webhook_url=values.unset, friendly_name=values.unset, reachability_webhooks_enabled=values.unset, acl_enabled=values.unset): """ Update the ServiceInstance :param unicode webhook_url: The webhook_url :param unicode friendly_name: The friendly_name :param bool reachability_webhooks_enabled: The reachability_webhooks_enabled :param bool acl_enabled: The acl_enabled :returns: Updated ServiceInstance :rtype: twilio.rest.preview.sync.service.ServiceInstance """ data = values.of({ 'WebhookUrl': webhook_url, 'FriendlyName': friendly_name, 'ReachabilityWebhooksEnabled': reachability_webhooks_enabled, 'AclEnabled': acl_enabled, }) payload = self._version.update( 'POST', self._uri, data=data, ) return ServiceInstance(self._version, payload, sid=self._solution['sid'],) @property def documents(self): """ Access the documents :returns: twilio.rest.preview.sync.service.document.DocumentList :rtype: twilio.rest.preview.sync.service.document.DocumentList """ if self._documents is None: self._documents = DocumentList(self._version, service_sid=self._solution['sid'],) return self._documents @property def sync_lists(self): """ Access the sync_lists :returns: twilio.rest.preview.sync.service.sync_list.SyncListList :rtype: twilio.rest.preview.sync.service.sync_list.SyncListList """ if self._sync_lists is None: self._sync_lists = SyncListList(self._version, service_sid=self._solution['sid'],) return self._sync_lists @property def sync_maps(self): """ Access the sync_maps :returns: twilio.rest.preview.sync.service.sync_map.SyncMapList :rtype: twilio.rest.preview.sync.service.sync_map.SyncMapList """ if self._sync_maps is None: self._sync_maps = SyncMapList(self._version, service_sid=self._solution['sid'],) return self._sync_maps def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class ServiceInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, payload, sid=None): """ Initialize the ServiceInstance :returns: twilio.rest.preview.sync.service.ServiceInstance :rtype: twilio.rest.preview.sync.service.ServiceInstance """ super(ServiceInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'friendly_name': payload['friendly_name'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'url': payload['url'], 'webhook_url': payload['webhook_url'], 'reachability_webhooks_enabled': payload['reachability_webhooks_enabled'], 'acl_enabled': payload['acl_enabled'], 'links': payload['links'], } # Context self._context = None self._solution = {'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.preview.sync.service.ServiceContext """ if self._context is None: self._context = ServiceContext(self._version, sid=self._solution['sid'],) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def webhook_url(self): """ :returns: The webhook_url :rtype: unicode """ return self._properties['webhook_url'] @property def reachability_webhooks_enabled(self): """ :returns: The reachability_webhooks_enabled :rtype: bool """ return self._properties['reachability_webhooks_enabled'] @property def acl_enabled(self): """ :returns: The acl_enabled :rtype: bool """ return self._properties['acl_enabled'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a ServiceInstance :returns: Fetched ServiceInstance :rtype: twilio.rest.preview.sync.service.ServiceInstance """ return self._proxy.fetch() def delete(self): """ Deletes the ServiceInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, webhook_url=values.unset, friendly_name=values.unset, reachability_webhooks_enabled=values.unset, acl_enabled=values.unset): """ Update the ServiceInstance :param unicode webhook_url: The webhook_url :param unicode friendly_name: The friendly_name :param bool reachability_webhooks_enabled: The reachability_webhooks_enabled :param bool acl_enabled: The acl_enabled :returns: Updated ServiceInstance :rtype: twilio.rest.preview.sync.service.ServiceInstance """ return self._proxy.update( webhook_url=webhook_url, friendly_name=friendly_name, reachability_webhooks_enabled=reachability_webhooks_enabled, acl_enabled=acl_enabled, ) @property def documents(self): """ Access the documents :returns: twilio.rest.preview.sync.service.document.DocumentList :rtype: twilio.rest.preview.sync.service.document.DocumentList """ return self._proxy.documents @property def sync_lists(self): """ Access the sync_lists :returns: twilio.rest.preview.sync.service.sync_list.SyncListList :rtype: twilio.rest.preview.sync.service.sync_list.SyncListList """ return self._proxy.sync_lists @property def sync_maps(self): """ Access the sync_maps :returns: twilio.rest.preview.sync.service.sync_map.SyncMapList :rtype: twilio.rest.preview.sync.service.sync_map.SyncMapList """ return self._proxy.sync_maps def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/preview/sync/service/document/000077500000000000000000000000001317472742600245715ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/preview/sync/service/document/__init__.py000066400000000000000000000401261317472742600267050ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize 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.page import Page from twilio.rest.preview.sync.service.document.document_permission import DocumentPermissionList class DocumentList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, service_sid): """ Initialize the DocumentList :param Version version: Version that contains the resource :param service_sid: The service_sid :returns: twilio.rest.preview.sync.service.document.DocumentList :rtype: twilio.rest.preview.sync.service.document.DocumentList """ super(DocumentList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid,} self._uri = '/Services/{service_sid}/Documents'.format(**self._solution) def create(self, unique_name=values.unset, data=values.unset): """ Create a new DocumentInstance :param unicode unique_name: The unique_name :param dict data: The data :returns: Newly created DocumentInstance :rtype: twilio.rest.preview.sync.service.document.DocumentInstance """ data = values.of({'UniqueName': unique_name, 'Data': serialize.object(data),}) payload = self._version.create( 'POST', self._uri, data=data, ) return DocumentInstance(self._version, payload, service_sid=self._solution['service_sid'],) def stream(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.sync.service.document.DocumentInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.sync.service.document.DocumentInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of DocumentInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of DocumentInstance :rtype: twilio.rest.preview.sync.service.document.DocumentPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return DocumentPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of DocumentInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of DocumentInstance :rtype: twilio.rest.preview.sync.service.document.DocumentPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return DocumentPage(self._version, response, self._solution) def get(self, sid): """ Constructs a DocumentContext :param sid: The sid :returns: twilio.rest.preview.sync.service.document.DocumentContext :rtype: twilio.rest.preview.sync.service.document.DocumentContext """ return DocumentContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __call__(self, sid): """ Constructs a DocumentContext :param sid: The sid :returns: twilio.rest.preview.sync.service.document.DocumentContext :rtype: twilio.rest.preview.sync.service.document.DocumentContext """ return DocumentContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class DocumentPage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the DocumentPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :returns: twilio.rest.preview.sync.service.document.DocumentPage :rtype: twilio.rest.preview.sync.service.document.DocumentPage """ super(DocumentPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of DocumentInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.sync.service.document.DocumentInstance :rtype: twilio.rest.preview.sync.service.document.DocumentInstance """ return DocumentInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class DocumentContext(InstanceContext): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, service_sid, sid): """ Initialize the DocumentContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param sid: The sid :returns: twilio.rest.preview.sync.service.document.DocumentContext :rtype: twilio.rest.preview.sync.service.document.DocumentContext """ super(DocumentContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Documents/{sid}'.format(**self._solution) # Dependents self._document_permissions = None def fetch(self): """ Fetch a DocumentInstance :returns: Fetched DocumentInstance :rtype: twilio.rest.preview.sync.service.document.DocumentInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return DocumentInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the DocumentInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, data): """ Update the DocumentInstance :param dict data: The data :returns: Updated DocumentInstance :rtype: twilio.rest.preview.sync.service.document.DocumentInstance """ data = values.of({'Data': serialize.object(data),}) payload = self._version.update( 'POST', self._uri, data=data, ) return DocumentInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) @property def document_permissions(self): """ Access the document_permissions :returns: twilio.rest.preview.sync.service.document.document_permission.DocumentPermissionList :rtype: twilio.rest.preview.sync.service.document.document_permission.DocumentPermissionList """ if self._document_permissions is None: self._document_permissions = DocumentPermissionList( self._version, service_sid=self._solution['service_sid'], document_sid=self._solution['sid'], ) return self._document_permissions def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class DocumentInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, payload, service_sid, sid=None): """ Initialize the DocumentInstance :returns: twilio.rest.preview.sync.service.document.DocumentInstance :rtype: twilio.rest.preview.sync.service.document.DocumentInstance """ super(DocumentInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'unique_name': payload['unique_name'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'url': payload['url'], 'links': payload['links'], 'revision': payload['revision'], 'data': payload['data'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'created_by': payload['created_by'], } # Context self._context = None self._solution = {'service_sid': service_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.preview.sync.service.document.DocumentContext """ if self._context is None: self._context = DocumentContext( self._version, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def unique_name(self): """ :returns: The unique_name :rtype: unicode """ return self._properties['unique_name'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] @property def revision(self): """ :returns: The revision :rtype: unicode """ return self._properties['revision'] @property def data(self): """ :returns: The data :rtype: dict """ return self._properties['data'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def created_by(self): """ :returns: The created_by :rtype: unicode """ return self._properties['created_by'] def fetch(self): """ Fetch a DocumentInstance :returns: Fetched DocumentInstance :rtype: twilio.rest.preview.sync.service.document.DocumentInstance """ return self._proxy.fetch() def delete(self): """ Deletes the DocumentInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, data): """ Update the DocumentInstance :param dict data: The data :returns: Updated DocumentInstance :rtype: twilio.rest.preview.sync.service.document.DocumentInstance """ return self._proxy.update(data,) @property def document_permissions(self): """ Access the document_permissions :returns: twilio.rest.preview.sync.service.document.document_permission.DocumentPermissionList :rtype: twilio.rest.preview.sync.service.document.document_permission.DocumentPermissionList """ return self._proxy.document_permissions def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/preview/sync/service/document/document_permission.py000066400000000000000000000402511317472742600312330ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ 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.page import Page class DocumentPermissionList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, service_sid, document_sid): """ Initialize the DocumentPermissionList :param Version version: Version that contains the resource :param service_sid: Sync Service Instance SID. :param document_sid: Sync Document SID. :returns: twilio.rest.preview.sync.service.document.document_permission.DocumentPermissionList :rtype: twilio.rest.preview.sync.service.document.document_permission.DocumentPermissionList """ super(DocumentPermissionList, self).__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=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.sync.service.document.document_permission.DocumentPermissionInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.sync.service.document.document_permission.DocumentPermissionInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of DocumentPermissionInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of DocumentPermissionInstance :rtype: twilio.rest.preview.sync.service.document.document_permission.DocumentPermissionPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return DocumentPermissionPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of DocumentPermissionInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of DocumentPermissionInstance :rtype: twilio.rest.preview.sync.service.document.document_permission.DocumentPermissionPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return DocumentPermissionPage(self._version, response, self._solution) def get(self, identity): """ Constructs a DocumentPermissionContext :param identity: Identity of the user to whom the Sync Document Permission applies. :returns: twilio.rest.preview.sync.service.document.document_permission.DocumentPermissionContext :rtype: twilio.rest.preview.sync.service.document.document_permission.DocumentPermissionContext """ return DocumentPermissionContext( self._version, service_sid=self._solution['service_sid'], document_sid=self._solution['document_sid'], identity=identity, ) def __call__(self, identity): """ Constructs a DocumentPermissionContext :param identity: Identity of the user to whom the Sync Document Permission applies. :returns: twilio.rest.preview.sync.service.document.document_permission.DocumentPermissionContext :rtype: twilio.rest.preview.sync.service.document.document_permission.DocumentPermissionContext """ return DocumentPermissionContext( self._version, service_sid=self._solution['service_sid'], document_sid=self._solution['document_sid'], identity=identity, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class DocumentPermissionPage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the DocumentPermissionPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: Sync Service Instance SID. :param document_sid: Sync Document SID. :returns: twilio.rest.preview.sync.service.document.document_permission.DocumentPermissionPage :rtype: twilio.rest.preview.sync.service.document.document_permission.DocumentPermissionPage """ super(DocumentPermissionPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of DocumentPermissionInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.sync.service.document.document_permission.DocumentPermissionInstance :rtype: twilio.rest.preview.sync.service.document.document_permission.DocumentPermissionInstance """ return DocumentPermissionInstance( self._version, payload, service_sid=self._solution['service_sid'], document_sid=self._solution['document_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class DocumentPermissionContext(InstanceContext): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, service_sid, document_sid, identity): """ Initialize the DocumentPermissionContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param document_sid: Sync Document SID or unique name. :param identity: Identity of the user to whom the Sync Document Permission applies. :returns: twilio.rest.preview.sync.service.document.document_permission.DocumentPermissionContext :rtype: twilio.rest.preview.sync.service.document.document_permission.DocumentPermissionContext """ super(DocumentPermissionContext, self).__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 fetch(self): """ Fetch a DocumentPermissionInstance :returns: Fetched DocumentPermissionInstance :rtype: twilio.rest.preview.sync.service.document.document_permission.DocumentPermissionInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return DocumentPermissionInstance( self._version, payload, service_sid=self._solution['service_sid'], document_sid=self._solution['document_sid'], identity=self._solution['identity'], ) def delete(self): """ Deletes the DocumentPermissionInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, read, write, manage): """ Update the DocumentPermissionInstance :param bool read: Read access. :param bool write: Write access. :param bool manage: Manage access. :returns: Updated DocumentPermissionInstance :rtype: twilio.rest.preview.sync.service.document.document_permission.DocumentPermissionInstance """ data = values.of({'Read': read, 'Write': write, 'Manage': manage,}) payload = self._version.update( 'POST', 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): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class DocumentPermissionInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, payload, service_sid, document_sid, identity=None): """ Initialize the DocumentPermissionInstance :returns: twilio.rest.preview.sync.service.document.document_permission.DocumentPermissionInstance :rtype: twilio.rest.preview.sync.service.document.document_permission.DocumentPermissionInstance """ super(DocumentPermissionInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'document_sid': payload['document_sid'], 'identity': payload['identity'], 'read': payload['read'], 'write': payload['write'], 'manage': payload['manage'], 'url': payload['url'], } # Context self._context = None self._solution = { 'service_sid': service_sid, 'document_sid': document_sid, 'identity': identity or self._properties['identity'], } @property def _proxy(self): """ 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 :rtype: twilio.rest.preview.sync.service.document.document_permission.DocumentPermissionContext """ 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 @property def account_sid(self): """ :returns: Twilio Account SID. :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: Sync Service Instance SID. :rtype: unicode """ return self._properties['service_sid'] @property def document_sid(self): """ :returns: Sync Document SID. :rtype: unicode """ return self._properties['document_sid'] @property def identity(self): """ :returns: Identity of the user to whom the Sync Document Permission applies. :rtype: unicode """ return self._properties['identity'] @property def read(self): """ :returns: Read access. :rtype: bool """ return self._properties['read'] @property def write(self): """ :returns: Write access. :rtype: bool """ return self._properties['write'] @property def manage(self): """ :returns: Manage access. :rtype: bool """ return self._properties['manage'] @property def url(self): """ :returns: URL of this Sync Document Permission. :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a DocumentPermissionInstance :returns: Fetched DocumentPermissionInstance :rtype: twilio.rest.preview.sync.service.document.document_permission.DocumentPermissionInstance """ return self._proxy.fetch() def delete(self): """ Deletes the DocumentPermissionInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, read, write, manage): """ Update the DocumentPermissionInstance :param bool read: Read access. :param bool write: Write access. :param bool manage: Manage access. :returns: Updated DocumentPermissionInstance :rtype: twilio.rest.preview.sync.service.document.document_permission.DocumentPermissionInstance """ return self._proxy.update(read, write, manage,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/preview/sync/service/sync_list/000077500000000000000000000000001317472742600247625ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/preview/sync/service/sync_list/__init__.py000066400000000000000000000377171317472742600271120ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.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 SyncListList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, service_sid): """ Initialize the SyncListList :param Version version: Version that contains the resource :param service_sid: The service_sid :returns: twilio.rest.preview.sync.service.sync_list.SyncListList :rtype: twilio.rest.preview.sync.service.sync_list.SyncListList """ super(SyncListList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid,} self._uri = '/Services/{service_sid}/Lists'.format(**self._solution) def create(self, unique_name=values.unset): """ Create a new SyncListInstance :param unicode unique_name: The unique_name :returns: Newly created SyncListInstance :rtype: twilio.rest.preview.sync.service.sync_list.SyncListInstance """ data = values.of({'UniqueName': unique_name,}) payload = self._version.create( 'POST', self._uri, data=data, ) return SyncListInstance(self._version, payload, service_sid=self._solution['service_sid'],) def stream(self, limit=None, page_size=None): """ Streams SyncListInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.sync.service.sync_list.SyncListInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists SyncListInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.sync.service.sync_list.SyncListInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of SyncListInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of SyncListInstance :rtype: twilio.rest.preview.sync.service.sync_list.SyncListPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return SyncListPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of SyncListInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of SyncListInstance :rtype: twilio.rest.preview.sync.service.sync_list.SyncListPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return SyncListPage(self._version, response, self._solution) def get(self, sid): """ Constructs a SyncListContext :param sid: The sid :returns: twilio.rest.preview.sync.service.sync_list.SyncListContext :rtype: twilio.rest.preview.sync.service.sync_list.SyncListContext """ return SyncListContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __call__(self, sid): """ Constructs a SyncListContext :param sid: The sid :returns: twilio.rest.preview.sync.service.sync_list.SyncListContext :rtype: twilio.rest.preview.sync.service.sync_list.SyncListContext """ return SyncListContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SyncListPage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the SyncListPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :returns: twilio.rest.preview.sync.service.sync_list.SyncListPage :rtype: twilio.rest.preview.sync.service.sync_list.SyncListPage """ super(SyncListPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of SyncListInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.sync.service.sync_list.SyncListInstance :rtype: twilio.rest.preview.sync.service.sync_list.SyncListInstance """ return SyncListInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SyncListContext(InstanceContext): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, service_sid, sid): """ Initialize the SyncListContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param sid: The sid :returns: twilio.rest.preview.sync.service.sync_list.SyncListContext :rtype: twilio.rest.preview.sync.service.sync_list.SyncListContext """ super(SyncListContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Lists/{sid}'.format(**self._solution) # Dependents self._sync_list_items = None self._sync_list_permissions = None def fetch(self): """ Fetch a SyncListInstance :returns: Fetched SyncListInstance :rtype: twilio.rest.preview.sync.service.sync_list.SyncListInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return SyncListInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the SyncListInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) @property def sync_list_items(self): """ Access the sync_list_items :returns: twilio.rest.preview.sync.service.sync_list.sync_list_item.SyncListItemList :rtype: twilio.rest.preview.sync.service.sync_list.sync_list_item.SyncListItemList """ if self._sync_list_items is None: self._sync_list_items = SyncListItemList( self._version, service_sid=self._solution['service_sid'], list_sid=self._solution['sid'], ) return self._sync_list_items @property def sync_list_permissions(self): """ Access the sync_list_permissions :returns: twilio.rest.preview.sync.service.sync_list.sync_list_permission.SyncListPermissionList :rtype: twilio.rest.preview.sync.service.sync_list.sync_list_permission.SyncListPermissionList """ if self._sync_list_permissions is None: self._sync_list_permissions = SyncListPermissionList( self._version, service_sid=self._solution['service_sid'], list_sid=self._solution['sid'], ) return self._sync_list_permissions def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class SyncListInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, payload, service_sid, sid=None): """ Initialize the SyncListInstance :returns: twilio.rest.preview.sync.service.sync_list.SyncListInstance :rtype: twilio.rest.preview.sync.service.sync_list.SyncListInstance """ super(SyncListInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'unique_name': payload['unique_name'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'url': payload['url'], 'links': payload['links'], 'revision': payload['revision'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'created_by': payload['created_by'], } # Context self._context = None self._solution = {'service_sid': service_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.preview.sync.service.sync_list.SyncListContext """ if self._context is None: self._context = SyncListContext( self._version, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def unique_name(self): """ :returns: The unique_name :rtype: unicode """ return self._properties['unique_name'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] @property def revision(self): """ :returns: The revision :rtype: unicode """ return self._properties['revision'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def created_by(self): """ :returns: The created_by :rtype: unicode """ return self._properties['created_by'] def fetch(self): """ Fetch a SyncListInstance :returns: Fetched SyncListInstance :rtype: twilio.rest.preview.sync.service.sync_list.SyncListInstance """ return self._proxy.fetch() def delete(self): """ Deletes the SyncListInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() @property def sync_list_items(self): """ Access the sync_list_items :returns: twilio.rest.preview.sync.service.sync_list.sync_list_item.SyncListItemList :rtype: twilio.rest.preview.sync.service.sync_list.sync_list_item.SyncListItemList """ return self._proxy.sync_list_items @property def sync_list_permissions(self): """ Access the sync_list_permissions :returns: twilio.rest.preview.sync.service.sync_list.sync_list_permission.SyncListPermissionList :rtype: twilio.rest.preview.sync.service.sync_list.sync_list_permission.SyncListPermissionList """ return self._proxy.sync_list_permissions def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/preview/sync/service/sync_list/sync_list_item.py000066400000000000000000000424721317472742600303720ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize 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.page import Page class SyncListItemList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, service_sid, list_sid): """ Initialize the SyncListItemList :param Version version: Version that contains the resource :param service_sid: The service_sid :param list_sid: The list_sid :returns: twilio.rest.preview.sync.service.sync_list.sync_list_item.SyncListItemList :rtype: twilio.rest.preview.sync.service.sync_list.sync_list_item.SyncListItemList """ super(SyncListItemList, self).__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): """ Create a new SyncListItemInstance :param dict data: The data :returns: Newly created SyncListItemInstance :rtype: twilio.rest.preview.sync.service.sync_list.sync_list_item.SyncListItemInstance """ data = values.of({'Data': serialize.object(data),}) payload = self._version.create( 'POST', 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=values.unset, from_=values.unset, bounds=values.unset, limit=None, page_size=None): """ 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: The order :param unicode from_: The from :param SyncListItemInstance.QueryFromBoundType bounds: The bounds :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.sync.service.sync_list.sync_list_item.SyncListItemInstance] """ 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'], limits['page_limit']) def list(self, order=values.unset, from_=values.unset, bounds=values.unset, limit=None, page_size=None): """ 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: The order :param unicode from_: The from :param SyncListItemInstance.QueryFromBoundType bounds: The bounds :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.sync.service.sync_list.sync_list_item.SyncListItemInstance] """ return list(self.stream(order=order, from_=from_, bounds=bounds, limit=limit, page_size=page_size,)) def page(self, order=values.unset, from_=values.unset, bounds=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of SyncListItemInstance records from the API. Request is executed immediately :param SyncListItemInstance.QueryResultOrder order: The order :param unicode from_: The from :param SyncListItemInstance.QueryFromBoundType bounds: The bounds :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of SyncListItemInstance :rtype: twilio.rest.preview.sync.service.sync_list.sync_list_item.SyncListItemPage """ params = values.of({ 'Order': order, 'From': from_, 'Bounds': bounds, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return SyncListItemPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of SyncListItemInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of SyncListItemInstance :rtype: twilio.rest.preview.sync.service.sync_list.sync_list_item.SyncListItemPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return SyncListItemPage(self._version, response, self._solution) def get(self, index): """ Constructs a SyncListItemContext :param index: The index :returns: twilio.rest.preview.sync.service.sync_list.sync_list_item.SyncListItemContext :rtype: twilio.rest.preview.sync.service.sync_list.sync_list_item.SyncListItemContext """ return SyncListItemContext( self._version, service_sid=self._solution['service_sid'], list_sid=self._solution['list_sid'], index=index, ) def __call__(self, index): """ Constructs a SyncListItemContext :param index: The index :returns: twilio.rest.preview.sync.service.sync_list.sync_list_item.SyncListItemContext :rtype: twilio.rest.preview.sync.service.sync_list.sync_list_item.SyncListItemContext """ return SyncListItemContext( self._version, service_sid=self._solution['service_sid'], list_sid=self._solution['list_sid'], index=index, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SyncListItemPage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the SyncListItemPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :param list_sid: The list_sid :returns: twilio.rest.preview.sync.service.sync_list.sync_list_item.SyncListItemPage :rtype: twilio.rest.preview.sync.service.sync_list.sync_list_item.SyncListItemPage """ super(SyncListItemPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of SyncListItemInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.sync.service.sync_list.sync_list_item.SyncListItemInstance :rtype: twilio.rest.preview.sync.service.sync_list.sync_list_item.SyncListItemInstance """ return SyncListItemInstance( self._version, payload, service_sid=self._solution['service_sid'], list_sid=self._solution['list_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SyncListItemContext(InstanceContext): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, service_sid, list_sid, index): """ Initialize the SyncListItemContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param list_sid: The list_sid :param index: The index :returns: twilio.rest.preview.sync.service.sync_list.sync_list_item.SyncListItemContext :rtype: twilio.rest.preview.sync.service.sync_list.sync_list_item.SyncListItemContext """ super(SyncListItemContext, self).__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 fetch(self): """ Fetch a SyncListItemInstance :returns: Fetched SyncListItemInstance :rtype: twilio.rest.preview.sync.service.sync_list.sync_list_item.SyncListItemInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return SyncListItemInstance( self._version, payload, service_sid=self._solution['service_sid'], list_sid=self._solution['list_sid'], index=self._solution['index'], ) def delete(self): """ Deletes the SyncListItemInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, data): """ Update the SyncListItemInstance :param dict data: The data :returns: Updated SyncListItemInstance :rtype: twilio.rest.preview.sync.service.sync_list.sync_list_item.SyncListItemInstance """ data = values.of({'Data': serialize.object(data),}) payload = self._version.update( 'POST', self._uri, data=data, ) return SyncListItemInstance( self._version, payload, service_sid=self._solution['service_sid'], list_sid=self._solution['list_sid'], index=self._solution['index'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class SyncListItemInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ class QueryResultOrder(object): ASC = "asc" DESC = "desc" class QueryFromBoundType(object): INCLUSIVE = "inclusive" EXCLUSIVE = "exclusive" def __init__(self, version, payload, service_sid, list_sid, index=None): """ Initialize the SyncListItemInstance :returns: twilio.rest.preview.sync.service.sync_list.sync_list_item.SyncListItemInstance :rtype: twilio.rest.preview.sync.service.sync_list.sync_list_item.SyncListItemInstance """ super(SyncListItemInstance, self).__init__(version) # Marshaled Properties self._properties = { 'index': deserialize.integer(payload['index']), 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'list_sid': payload['list_sid'], 'url': payload['url'], 'revision': payload['revision'], 'data': payload['data'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'created_by': payload['created_by'], } # Context self._context = None self._solution = { 'service_sid': service_sid, 'list_sid': list_sid, 'index': index or self._properties['index'], } @property def _proxy(self): """ 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 :rtype: twilio.rest.preview.sync.service.sync_list.sync_list_item.SyncListItemContext """ 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 @property def index(self): """ :returns: The index :rtype: unicode """ return self._properties['index'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def list_sid(self): """ :returns: The list_sid :rtype: unicode """ return self._properties['list_sid'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def revision(self): """ :returns: The revision :rtype: unicode """ return self._properties['revision'] @property def data(self): """ :returns: The data :rtype: dict """ return self._properties['data'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def created_by(self): """ :returns: The created_by :rtype: unicode """ return self._properties['created_by'] def fetch(self): """ Fetch a SyncListItemInstance :returns: Fetched SyncListItemInstance :rtype: twilio.rest.preview.sync.service.sync_list.sync_list_item.SyncListItemInstance """ return self._proxy.fetch() def delete(self): """ Deletes the SyncListItemInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, data): """ Update the SyncListItemInstance :param dict data: The data :returns: Updated SyncListItemInstance :rtype: twilio.rest.preview.sync.service.sync_list.sync_list_item.SyncListItemInstance """ return self._proxy.update(data,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/preview/sync/service/sync_list/sync_list_permission.py000066400000000000000000000400631317472742600316160ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ 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.page import Page class SyncListPermissionList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, service_sid, list_sid): """ Initialize the SyncListPermissionList :param Version version: Version that contains the resource :param service_sid: Sync Service Instance SID. :param list_sid: Sync List SID. :returns: twilio.rest.preview.sync.service.sync_list.sync_list_permission.SyncListPermissionList :rtype: twilio.rest.preview.sync.service.sync_list.sync_list_permission.SyncListPermissionList """ super(SyncListPermissionList, self).__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=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.sync.service.sync_list.sync_list_permission.SyncListPermissionInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.sync.service.sync_list.sync_list_permission.SyncListPermissionInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of SyncListPermissionInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of SyncListPermissionInstance :rtype: twilio.rest.preview.sync.service.sync_list.sync_list_permission.SyncListPermissionPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return SyncListPermissionPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of SyncListPermissionInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of SyncListPermissionInstance :rtype: twilio.rest.preview.sync.service.sync_list.sync_list_permission.SyncListPermissionPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return SyncListPermissionPage(self._version, response, self._solution) def get(self, identity): """ Constructs a SyncListPermissionContext :param identity: Identity of the user to whom the Sync List Permission applies. :returns: twilio.rest.preview.sync.service.sync_list.sync_list_permission.SyncListPermissionContext :rtype: twilio.rest.preview.sync.service.sync_list.sync_list_permission.SyncListPermissionContext """ return SyncListPermissionContext( self._version, service_sid=self._solution['service_sid'], list_sid=self._solution['list_sid'], identity=identity, ) def __call__(self, identity): """ Constructs a SyncListPermissionContext :param identity: Identity of the user to whom the Sync List Permission applies. :returns: twilio.rest.preview.sync.service.sync_list.sync_list_permission.SyncListPermissionContext :rtype: twilio.rest.preview.sync.service.sync_list.sync_list_permission.SyncListPermissionContext """ return SyncListPermissionContext( self._version, service_sid=self._solution['service_sid'], list_sid=self._solution['list_sid'], identity=identity, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SyncListPermissionPage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the SyncListPermissionPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: Sync Service Instance SID. :param list_sid: Sync List SID. :returns: twilio.rest.preview.sync.service.sync_list.sync_list_permission.SyncListPermissionPage :rtype: twilio.rest.preview.sync.service.sync_list.sync_list_permission.SyncListPermissionPage """ super(SyncListPermissionPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of SyncListPermissionInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.sync.service.sync_list.sync_list_permission.SyncListPermissionInstance :rtype: twilio.rest.preview.sync.service.sync_list.sync_list_permission.SyncListPermissionInstance """ return SyncListPermissionInstance( self._version, payload, service_sid=self._solution['service_sid'], list_sid=self._solution['list_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SyncListPermissionContext(InstanceContext): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, service_sid, list_sid, identity): """ Initialize the SyncListPermissionContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param list_sid: Sync List SID or unique name. :param identity: Identity of the user to whom the Sync List Permission applies. :returns: twilio.rest.preview.sync.service.sync_list.sync_list_permission.SyncListPermissionContext :rtype: twilio.rest.preview.sync.service.sync_list.sync_list_permission.SyncListPermissionContext """ super(SyncListPermissionContext, self).__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 fetch(self): """ Fetch a SyncListPermissionInstance :returns: Fetched SyncListPermissionInstance :rtype: twilio.rest.preview.sync.service.sync_list.sync_list_permission.SyncListPermissionInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return SyncListPermissionInstance( self._version, payload, service_sid=self._solution['service_sid'], list_sid=self._solution['list_sid'], identity=self._solution['identity'], ) def delete(self): """ Deletes the SyncListPermissionInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, read, write, manage): """ Update the SyncListPermissionInstance :param bool read: Read access. :param bool write: Write access. :param bool manage: Manage access. :returns: Updated SyncListPermissionInstance :rtype: twilio.rest.preview.sync.service.sync_list.sync_list_permission.SyncListPermissionInstance """ data = values.of({'Read': read, 'Write': write, 'Manage': manage,}) payload = self._version.update( 'POST', 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): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class SyncListPermissionInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, payload, service_sid, list_sid, identity=None): """ Initialize the SyncListPermissionInstance :returns: twilio.rest.preview.sync.service.sync_list.sync_list_permission.SyncListPermissionInstance :rtype: twilio.rest.preview.sync.service.sync_list.sync_list_permission.SyncListPermissionInstance """ super(SyncListPermissionInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'list_sid': payload['list_sid'], 'identity': payload['identity'], 'read': payload['read'], 'write': payload['write'], 'manage': payload['manage'], 'url': payload['url'], } # Context self._context = None self._solution = { 'service_sid': service_sid, 'list_sid': list_sid, 'identity': identity or self._properties['identity'], } @property def _proxy(self): """ 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 :rtype: twilio.rest.preview.sync.service.sync_list.sync_list_permission.SyncListPermissionContext """ 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 @property def account_sid(self): """ :returns: Twilio Account SID. :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: Sync Service Instance SID. :rtype: unicode """ return self._properties['service_sid'] @property def list_sid(self): """ :returns: Sync List SID. :rtype: unicode """ return self._properties['list_sid'] @property def identity(self): """ :returns: Identity of the user to whom the Sync List Permission applies. :rtype: unicode """ return self._properties['identity'] @property def read(self): """ :returns: Read access. :rtype: bool """ return self._properties['read'] @property def write(self): """ :returns: Write access. :rtype: bool """ return self._properties['write'] @property def manage(self): """ :returns: Manage access. :rtype: bool """ return self._properties['manage'] @property def url(self): """ :returns: URL of this Sync List Permission. :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a SyncListPermissionInstance :returns: Fetched SyncListPermissionInstance :rtype: twilio.rest.preview.sync.service.sync_list.sync_list_permission.SyncListPermissionInstance """ return self._proxy.fetch() def delete(self): """ Deletes the SyncListPermissionInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, read, write, manage): """ Update the SyncListPermissionInstance :param bool read: Read access. :param bool write: Write access. :param bool manage: Manage access. :returns: Updated SyncListPermissionInstance :rtype: twilio.rest.preview.sync.service.sync_list.sync_list_permission.SyncListPermissionInstance """ return self._proxy.update(read, write, manage,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/preview/sync/service/sync_map/000077500000000000000000000000001317472742600245645ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/preview/sync/service/sync_map/__init__.py000066400000000000000000000375021317472742600267040ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.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 SyncMapList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, service_sid): """ Initialize the SyncMapList :param Version version: Version that contains the resource :param service_sid: The service_sid :returns: twilio.rest.preview.sync.service.sync_map.SyncMapList :rtype: twilio.rest.preview.sync.service.sync_map.SyncMapList """ super(SyncMapList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid,} self._uri = '/Services/{service_sid}/Maps'.format(**self._solution) def create(self, unique_name=values.unset): """ Create a new SyncMapInstance :param unicode unique_name: The unique_name :returns: Newly created SyncMapInstance :rtype: twilio.rest.preview.sync.service.sync_map.SyncMapInstance """ data = values.of({'UniqueName': unique_name,}) payload = self._version.create( 'POST', self._uri, data=data, ) return SyncMapInstance(self._version, payload, service_sid=self._solution['service_sid'],) def stream(self, limit=None, page_size=None): """ Streams SyncMapInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.sync.service.sync_map.SyncMapInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists SyncMapInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.sync.service.sync_map.SyncMapInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of SyncMapInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of SyncMapInstance :rtype: twilio.rest.preview.sync.service.sync_map.SyncMapPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return SyncMapPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of SyncMapInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of SyncMapInstance :rtype: twilio.rest.preview.sync.service.sync_map.SyncMapPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return SyncMapPage(self._version, response, self._solution) def get(self, sid): """ Constructs a SyncMapContext :param sid: The sid :returns: twilio.rest.preview.sync.service.sync_map.SyncMapContext :rtype: twilio.rest.preview.sync.service.sync_map.SyncMapContext """ return SyncMapContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __call__(self, sid): """ Constructs a SyncMapContext :param sid: The sid :returns: twilio.rest.preview.sync.service.sync_map.SyncMapContext :rtype: twilio.rest.preview.sync.service.sync_map.SyncMapContext """ return SyncMapContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SyncMapPage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the SyncMapPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :returns: twilio.rest.preview.sync.service.sync_map.SyncMapPage :rtype: twilio.rest.preview.sync.service.sync_map.SyncMapPage """ super(SyncMapPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of SyncMapInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.sync.service.sync_map.SyncMapInstance :rtype: twilio.rest.preview.sync.service.sync_map.SyncMapInstance """ return SyncMapInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SyncMapContext(InstanceContext): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, service_sid, sid): """ Initialize the SyncMapContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param sid: The sid :returns: twilio.rest.preview.sync.service.sync_map.SyncMapContext :rtype: twilio.rest.preview.sync.service.sync_map.SyncMapContext """ super(SyncMapContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Maps/{sid}'.format(**self._solution) # Dependents self._sync_map_items = None self._sync_map_permissions = None def fetch(self): """ Fetch a SyncMapInstance :returns: Fetched SyncMapInstance :rtype: twilio.rest.preview.sync.service.sync_map.SyncMapInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return SyncMapInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the SyncMapInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) @property def sync_map_items(self): """ Access the sync_map_items :returns: twilio.rest.preview.sync.service.sync_map.sync_map_item.SyncMapItemList :rtype: twilio.rest.preview.sync.service.sync_map.sync_map_item.SyncMapItemList """ if self._sync_map_items is None: self._sync_map_items = SyncMapItemList( self._version, service_sid=self._solution['service_sid'], map_sid=self._solution['sid'], ) return self._sync_map_items @property def sync_map_permissions(self): """ Access the sync_map_permissions :returns: twilio.rest.preview.sync.service.sync_map.sync_map_permission.SyncMapPermissionList :rtype: twilio.rest.preview.sync.service.sync_map.sync_map_permission.SyncMapPermissionList """ if self._sync_map_permissions is None: self._sync_map_permissions = SyncMapPermissionList( self._version, service_sid=self._solution['service_sid'], map_sid=self._solution['sid'], ) return self._sync_map_permissions def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class SyncMapInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, payload, service_sid, sid=None): """ Initialize the SyncMapInstance :returns: twilio.rest.preview.sync.service.sync_map.SyncMapInstance :rtype: twilio.rest.preview.sync.service.sync_map.SyncMapInstance """ super(SyncMapInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'unique_name': payload['unique_name'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'url': payload['url'], 'links': payload['links'], 'revision': payload['revision'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'created_by': payload['created_by'], } # Context self._context = None self._solution = {'service_sid': service_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.preview.sync.service.sync_map.SyncMapContext """ if self._context is None: self._context = SyncMapContext( self._version, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def unique_name(self): """ :returns: The unique_name :rtype: unicode """ return self._properties['unique_name'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] @property def revision(self): """ :returns: The revision :rtype: unicode """ return self._properties['revision'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def created_by(self): """ :returns: The created_by :rtype: unicode """ return self._properties['created_by'] def fetch(self): """ Fetch a SyncMapInstance :returns: Fetched SyncMapInstance :rtype: twilio.rest.preview.sync.service.sync_map.SyncMapInstance """ return self._proxy.fetch() def delete(self): """ Deletes the SyncMapInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() @property def sync_map_items(self): """ Access the sync_map_items :returns: twilio.rest.preview.sync.service.sync_map.sync_map_item.SyncMapItemList :rtype: twilio.rest.preview.sync.service.sync_map.sync_map_item.SyncMapItemList """ return self._proxy.sync_map_items @property def sync_map_permissions(self): """ Access the sync_map_permissions :returns: twilio.rest.preview.sync.service.sync_map.sync_map_permission.SyncMapPermissionList :rtype: twilio.rest.preview.sync.service.sync_map.sync_map_permission.SyncMapPermissionList """ return self._proxy.sync_map_permissions def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/preview/sync/service/sync_map/sync_map_item.py000066400000000000000000000421701317472742600277710ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize 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.page import Page class SyncMapItemList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, service_sid, map_sid): """ Initialize the SyncMapItemList :param Version version: Version that contains the resource :param service_sid: The service_sid :param map_sid: The map_sid :returns: twilio.rest.preview.sync.service.sync_map.sync_map_item.SyncMapItemList :rtype: twilio.rest.preview.sync.service.sync_map.sync_map_item.SyncMapItemList """ super(SyncMapItemList, self).__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, data): """ Create a new SyncMapItemInstance :param unicode key: The key :param dict data: The data :returns: Newly created SyncMapItemInstance :rtype: twilio.rest.preview.sync.service.sync_map.sync_map_item.SyncMapItemInstance """ data = values.of({'Key': key, 'Data': serialize.object(data),}) payload = self._version.create( 'POST', 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=values.unset, from_=values.unset, bounds=values.unset, limit=None, page_size=None): """ 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: The order :param unicode from_: The from :param SyncMapItemInstance.QueryFromBoundType bounds: The bounds :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.sync.service.sync_map.sync_map_item.SyncMapItemInstance] """ 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'], limits['page_limit']) def list(self, order=values.unset, from_=values.unset, bounds=values.unset, limit=None, page_size=None): """ 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: The order :param unicode from_: The from :param SyncMapItemInstance.QueryFromBoundType bounds: The bounds :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.sync.service.sync_map.sync_map_item.SyncMapItemInstance] """ return list(self.stream(order=order, from_=from_, bounds=bounds, limit=limit, page_size=page_size,)) def page(self, order=values.unset, from_=values.unset, bounds=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of SyncMapItemInstance records from the API. Request is executed immediately :param SyncMapItemInstance.QueryResultOrder order: The order :param unicode from_: The from :param SyncMapItemInstance.QueryFromBoundType bounds: The bounds :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of SyncMapItemInstance :rtype: twilio.rest.preview.sync.service.sync_map.sync_map_item.SyncMapItemPage """ params = values.of({ 'Order': order, 'From': from_, 'Bounds': bounds, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return SyncMapItemPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of SyncMapItemInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of SyncMapItemInstance :rtype: twilio.rest.preview.sync.service.sync_map.sync_map_item.SyncMapItemPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return SyncMapItemPage(self._version, response, self._solution) def get(self, key): """ Constructs a SyncMapItemContext :param key: The key :returns: twilio.rest.preview.sync.service.sync_map.sync_map_item.SyncMapItemContext :rtype: twilio.rest.preview.sync.service.sync_map.sync_map_item.SyncMapItemContext """ return SyncMapItemContext( self._version, service_sid=self._solution['service_sid'], map_sid=self._solution['map_sid'], key=key, ) def __call__(self, key): """ Constructs a SyncMapItemContext :param key: The key :returns: twilio.rest.preview.sync.service.sync_map.sync_map_item.SyncMapItemContext :rtype: twilio.rest.preview.sync.service.sync_map.sync_map_item.SyncMapItemContext """ return SyncMapItemContext( self._version, service_sid=self._solution['service_sid'], map_sid=self._solution['map_sid'], key=key, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SyncMapItemPage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the SyncMapItemPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :param map_sid: The map_sid :returns: twilio.rest.preview.sync.service.sync_map.sync_map_item.SyncMapItemPage :rtype: twilio.rest.preview.sync.service.sync_map.sync_map_item.SyncMapItemPage """ super(SyncMapItemPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of SyncMapItemInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.sync.service.sync_map.sync_map_item.SyncMapItemInstance :rtype: twilio.rest.preview.sync.service.sync_map.sync_map_item.SyncMapItemInstance """ return SyncMapItemInstance( self._version, payload, service_sid=self._solution['service_sid'], map_sid=self._solution['map_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SyncMapItemContext(InstanceContext): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, service_sid, map_sid, key): """ Initialize the SyncMapItemContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param map_sid: The map_sid :param key: The key :returns: twilio.rest.preview.sync.service.sync_map.sync_map_item.SyncMapItemContext :rtype: twilio.rest.preview.sync.service.sync_map.sync_map_item.SyncMapItemContext """ super(SyncMapItemContext, self).__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 fetch(self): """ Fetch a SyncMapItemInstance :returns: Fetched SyncMapItemInstance :rtype: twilio.rest.preview.sync.service.sync_map.sync_map_item.SyncMapItemInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return SyncMapItemInstance( self._version, payload, service_sid=self._solution['service_sid'], map_sid=self._solution['map_sid'], key=self._solution['key'], ) def delete(self): """ Deletes the SyncMapItemInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, data): """ Update the SyncMapItemInstance :param dict data: The data :returns: Updated SyncMapItemInstance :rtype: twilio.rest.preview.sync.service.sync_map.sync_map_item.SyncMapItemInstance """ data = values.of({'Data': serialize.object(data),}) payload = self._version.update( 'POST', self._uri, data=data, ) return SyncMapItemInstance( self._version, payload, service_sid=self._solution['service_sid'], map_sid=self._solution['map_sid'], key=self._solution['key'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class SyncMapItemInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ class QueryResultOrder(object): ASC = "asc" DESC = "desc" class QueryFromBoundType(object): INCLUSIVE = "inclusive" EXCLUSIVE = "exclusive" def __init__(self, version, payload, service_sid, map_sid, key=None): """ Initialize the SyncMapItemInstance :returns: twilio.rest.preview.sync.service.sync_map.sync_map_item.SyncMapItemInstance :rtype: twilio.rest.preview.sync.service.sync_map.sync_map_item.SyncMapItemInstance """ super(SyncMapItemInstance, self).__init__(version) # Marshaled Properties self._properties = { 'key': payload['key'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'map_sid': payload['map_sid'], 'url': payload['url'], 'revision': payload['revision'], 'data': payload['data'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'created_by': payload['created_by'], } # Context self._context = None self._solution = { 'service_sid': service_sid, 'map_sid': map_sid, 'key': key or self._properties['key'], } @property def _proxy(self): """ 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 :rtype: twilio.rest.preview.sync.service.sync_map.sync_map_item.SyncMapItemContext """ 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 @property def key(self): """ :returns: The key :rtype: unicode """ return self._properties['key'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def map_sid(self): """ :returns: The map_sid :rtype: unicode """ return self._properties['map_sid'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def revision(self): """ :returns: The revision :rtype: unicode """ return self._properties['revision'] @property def data(self): """ :returns: The data :rtype: dict """ return self._properties['data'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def created_by(self): """ :returns: The created_by :rtype: unicode """ return self._properties['created_by'] def fetch(self): """ Fetch a SyncMapItemInstance :returns: Fetched SyncMapItemInstance :rtype: twilio.rest.preview.sync.service.sync_map.sync_map_item.SyncMapItemInstance """ return self._proxy.fetch() def delete(self): """ Deletes the SyncMapItemInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, data): """ Update the SyncMapItemInstance :param dict data: The data :returns: Updated SyncMapItemInstance :rtype: twilio.rest.preview.sync.service.sync_map.sync_map_item.SyncMapItemInstance """ return self._proxy.update(data,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/preview/sync/service/sync_map/sync_map_permission.py000066400000000000000000000376301317472742600312300ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ 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.page import Page class SyncMapPermissionList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, service_sid, map_sid): """ Initialize the SyncMapPermissionList :param Version version: Version that contains the resource :param service_sid: Sync Service Instance SID. :param map_sid: Sync Map SID. :returns: twilio.rest.preview.sync.service.sync_map.sync_map_permission.SyncMapPermissionList :rtype: twilio.rest.preview.sync.service.sync_map.sync_map_permission.SyncMapPermissionList """ super(SyncMapPermissionList, self).__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=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.sync.service.sync_map.sync_map_permission.SyncMapPermissionInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.sync.service.sync_map.sync_map_permission.SyncMapPermissionInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of SyncMapPermissionInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of SyncMapPermissionInstance :rtype: twilio.rest.preview.sync.service.sync_map.sync_map_permission.SyncMapPermissionPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return SyncMapPermissionPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of SyncMapPermissionInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of SyncMapPermissionInstance :rtype: twilio.rest.preview.sync.service.sync_map.sync_map_permission.SyncMapPermissionPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return SyncMapPermissionPage(self._version, response, self._solution) def get(self, identity): """ Constructs a SyncMapPermissionContext :param identity: Identity of the user to whom the Sync Map Permission applies. :returns: twilio.rest.preview.sync.service.sync_map.sync_map_permission.SyncMapPermissionContext :rtype: twilio.rest.preview.sync.service.sync_map.sync_map_permission.SyncMapPermissionContext """ return SyncMapPermissionContext( self._version, service_sid=self._solution['service_sid'], map_sid=self._solution['map_sid'], identity=identity, ) def __call__(self, identity): """ Constructs a SyncMapPermissionContext :param identity: Identity of the user to whom the Sync Map Permission applies. :returns: twilio.rest.preview.sync.service.sync_map.sync_map_permission.SyncMapPermissionContext :rtype: twilio.rest.preview.sync.service.sync_map.sync_map_permission.SyncMapPermissionContext """ return SyncMapPermissionContext( self._version, service_sid=self._solution['service_sid'], map_sid=self._solution['map_sid'], identity=identity, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SyncMapPermissionPage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the SyncMapPermissionPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: Sync Service Instance SID. :param map_sid: Sync Map SID. :returns: twilio.rest.preview.sync.service.sync_map.sync_map_permission.SyncMapPermissionPage :rtype: twilio.rest.preview.sync.service.sync_map.sync_map_permission.SyncMapPermissionPage """ super(SyncMapPermissionPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of SyncMapPermissionInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.sync.service.sync_map.sync_map_permission.SyncMapPermissionInstance :rtype: twilio.rest.preview.sync.service.sync_map.sync_map_permission.SyncMapPermissionInstance """ return SyncMapPermissionInstance( self._version, payload, service_sid=self._solution['service_sid'], map_sid=self._solution['map_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SyncMapPermissionContext(InstanceContext): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, service_sid, map_sid, identity): """ Initialize the SyncMapPermissionContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param map_sid: Sync Map SID or unique name. :param identity: Identity of the user to whom the Sync Map Permission applies. :returns: twilio.rest.preview.sync.service.sync_map.sync_map_permission.SyncMapPermissionContext :rtype: twilio.rest.preview.sync.service.sync_map.sync_map_permission.SyncMapPermissionContext """ super(SyncMapPermissionContext, self).__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 fetch(self): """ Fetch a SyncMapPermissionInstance :returns: Fetched SyncMapPermissionInstance :rtype: twilio.rest.preview.sync.service.sync_map.sync_map_permission.SyncMapPermissionInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return SyncMapPermissionInstance( self._version, payload, service_sid=self._solution['service_sid'], map_sid=self._solution['map_sid'], identity=self._solution['identity'], ) def delete(self): """ Deletes the SyncMapPermissionInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, read, write, manage): """ Update the SyncMapPermissionInstance :param bool read: Read access. :param bool write: Write access. :param bool manage: Manage access. :returns: Updated SyncMapPermissionInstance :rtype: twilio.rest.preview.sync.service.sync_map.sync_map_permission.SyncMapPermissionInstance """ data = values.of({'Read': read, 'Write': write, 'Manage': manage,}) payload = self._version.update( 'POST', 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): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class SyncMapPermissionInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, payload, service_sid, map_sid, identity=None): """ Initialize the SyncMapPermissionInstance :returns: twilio.rest.preview.sync.service.sync_map.sync_map_permission.SyncMapPermissionInstance :rtype: twilio.rest.preview.sync.service.sync_map.sync_map_permission.SyncMapPermissionInstance """ super(SyncMapPermissionInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'map_sid': payload['map_sid'], 'identity': payload['identity'], 'read': payload['read'], 'write': payload['write'], 'manage': payload['manage'], 'url': payload['url'], } # Context self._context = None self._solution = { 'service_sid': service_sid, 'map_sid': map_sid, 'identity': identity or self._properties['identity'], } @property def _proxy(self): """ 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 :rtype: twilio.rest.preview.sync.service.sync_map.sync_map_permission.SyncMapPermissionContext """ 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 @property def account_sid(self): """ :returns: Twilio Account SID. :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: Sync Service Instance SID. :rtype: unicode """ return self._properties['service_sid'] @property def map_sid(self): """ :returns: Sync Map SID. :rtype: unicode """ return self._properties['map_sid'] @property def identity(self): """ :returns: Identity of the user to whom the Sync Map Permission applies. :rtype: unicode """ return self._properties['identity'] @property def read(self): """ :returns: Read access. :rtype: bool """ return self._properties['read'] @property def write(self): """ :returns: Write access. :rtype: bool """ return self._properties['write'] @property def manage(self): """ :returns: Manage access. :rtype: bool """ return self._properties['manage'] @property def url(self): """ :returns: URL of this Sync Map Permission. :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a SyncMapPermissionInstance :returns: Fetched SyncMapPermissionInstance :rtype: twilio.rest.preview.sync.service.sync_map.sync_map_permission.SyncMapPermissionInstance """ return self._proxy.fetch() def delete(self): """ Deletes the SyncMapPermissionInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, read, write, manage): """ Update the SyncMapPermissionInstance :param bool read: Read access. :param bool write: Write access. :param bool manage: Manage access. :returns: Updated SyncMapPermissionInstance :rtype: twilio.rest.preview.sync.service.sync_map.sync_map_permission.SyncMapPermissionInstance """ return self._proxy.update(read, write, manage,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/preview/wireless/000077500000000000000000000000001317472742600221745ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/preview/wireless/__init__.py000066400000000000000000000031751317472742600243130ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.version import Version 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 Wireless(Version): def __init__(self, domain): """ Initialize the Wireless version of Preview :returns: Wireless version of Preview :rtype: twilio.rest.preview.wireless.Wireless.Wireless """ super(Wireless, self).__init__(domain) self.version = 'wireless' self._commands = None self._rate_plans = None self._sims = None @property def commands(self): """ :rtype: twilio.rest.preview.wireless.command.CommandList """ if self._commands is None: self._commands = CommandList(self) return self._commands @property def rate_plans(self): """ :rtype: twilio.rest.preview.wireless.rate_plan.RatePlanList """ if self._rate_plans is None: self._rate_plans = RatePlanList(self) return self._rate_plans @property def sims(self): """ :rtype: twilio.rest.preview.wireless.sim.SimList """ if self._sims is None: self._sims = SimList(self) return self._sims def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/preview/wireless/command.py000066400000000000000000000352001317472742600241640ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class CommandList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version): """ Initialize the CommandList :param Version version: Version that contains the resource :returns: twilio.rest.preview.wireless.command.CommandList :rtype: twilio.rest.preview.wireless.command.CommandList """ super(CommandList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/Commands'.format(**self._solution) def stream(self, device=values.unset, sim=values.unset, status=values.unset, direction=values.unset, limit=None, page_size=None): """ Streams CommandInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param unicode device: The device :param unicode sim: The sim :param unicode status: The status :param unicode direction: The direction :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.wireless.command.CommandInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( device=device, sim=sim, status=status, direction=direction, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, device=values.unset, sim=values.unset, status=values.unset, direction=values.unset, limit=None, page_size=None): """ Lists CommandInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param unicode device: The device :param unicode sim: The sim :param unicode status: The status :param unicode direction: The direction :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.wireless.command.CommandInstance] """ return list(self.stream( device=device, sim=sim, status=status, direction=direction, limit=limit, page_size=page_size, )) def page(self, device=values.unset, sim=values.unset, status=values.unset, direction=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of CommandInstance records from the API. Request is executed immediately :param unicode device: The device :param unicode sim: The sim :param unicode status: The status :param unicode direction: The direction :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of CommandInstance :rtype: twilio.rest.preview.wireless.command.CommandPage """ params = values.of({ 'Device': device, 'Sim': sim, 'Status': status, 'Direction': direction, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return CommandPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of CommandInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of CommandInstance :rtype: twilio.rest.preview.wireless.command.CommandPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return CommandPage(self._version, response, self._solution) def create(self, command, device=values.unset, sim=values.unset, callback_method=values.unset, callback_url=values.unset, command_mode=values.unset, include_sid=values.unset): """ Create a new CommandInstance :param unicode command: The command :param unicode device: The device :param unicode sim: The sim :param unicode callback_method: The callback_method :param unicode callback_url: The callback_url :param unicode command_mode: The command_mode :param unicode include_sid: The include_sid :returns: Newly created CommandInstance :rtype: twilio.rest.preview.wireless.command.CommandInstance """ data = values.of({ 'Command': command, 'Device': device, 'Sim': sim, 'CallbackMethod': callback_method, 'CallbackUrl': callback_url, 'CommandMode': command_mode, 'IncludeSid': include_sid, }) payload = self._version.create( 'POST', self._uri, data=data, ) return CommandInstance(self._version, payload,) def get(self, sid): """ Constructs a CommandContext :param sid: The sid :returns: twilio.rest.preview.wireless.command.CommandContext :rtype: twilio.rest.preview.wireless.command.CommandContext """ return CommandContext(self._version, sid=sid,) def __call__(self, sid): """ Constructs a CommandContext :param sid: The sid :returns: twilio.rest.preview.wireless.command.CommandContext :rtype: twilio.rest.preview.wireless.command.CommandContext """ return CommandContext(self._version, sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class CommandPage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the CommandPage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.preview.wireless.command.CommandPage :rtype: twilio.rest.preview.wireless.command.CommandPage """ super(CommandPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of CommandInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.wireless.command.CommandInstance :rtype: twilio.rest.preview.wireless.command.CommandInstance """ return CommandInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class CommandContext(InstanceContext): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, sid): """ Initialize the CommandContext :param Version version: Version that contains the resource :param sid: The sid :returns: twilio.rest.preview.wireless.command.CommandContext :rtype: twilio.rest.preview.wireless.command.CommandContext """ super(CommandContext, self).__init__(version) # Path Solution self._solution = {'sid': sid,} self._uri = '/Commands/{sid}'.format(**self._solution) def fetch(self): """ Fetch a CommandInstance :returns: Fetched CommandInstance :rtype: twilio.rest.preview.wireless.command.CommandInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return CommandInstance(self._version, payload, sid=self._solution['sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class CommandInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, payload, sid=None): """ Initialize the CommandInstance :returns: twilio.rest.preview.wireless.command.CommandInstance :rtype: twilio.rest.preview.wireless.command.CommandInstance """ super(CommandInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'device_sid': payload['device_sid'], 'sim_sid': payload['sim_sid'], 'command': payload['command'], 'command_mode': payload['command_mode'], 'status': payload['status'], 'direction': payload['direction'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'url': payload['url'], } # Context self._context = None self._solution = {'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: CommandContext for this CommandInstance :rtype: twilio.rest.preview.wireless.command.CommandContext """ if self._context is None: self._context = CommandContext(self._version, sid=self._solution['sid'],) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def device_sid(self): """ :returns: The device_sid :rtype: unicode """ return self._properties['device_sid'] @property def sim_sid(self): """ :returns: The sim_sid :rtype: unicode """ return self._properties['sim_sid'] @property def command(self): """ :returns: The command :rtype: unicode """ return self._properties['command'] @property def command_mode(self): """ :returns: The command_mode :rtype: unicode """ return self._properties['command_mode'] @property def status(self): """ :returns: The status :rtype: unicode """ return self._properties['status'] @property def direction(self): """ :returns: The direction :rtype: unicode """ return self._properties['direction'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a CommandInstance :returns: Fetched CommandInstance :rtype: twilio.rest.preview.wireless.command.CommandInstance """ return self._proxy.fetch() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/preview/wireless/rate_plan.py000066400000000000000000000410601317472742600245140ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class RatePlanList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version): """ Initialize the RatePlanList :param Version version: Version that contains the resource :returns: twilio.rest.preview.wireless.rate_plan.RatePlanList :rtype: twilio.rest.preview.wireless.rate_plan.RatePlanList """ super(RatePlanList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/RatePlans'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams RatePlanInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.wireless.rate_plan.RatePlanInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists RatePlanInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.wireless.rate_plan.RatePlanInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of RatePlanInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of RatePlanInstance :rtype: twilio.rest.preview.wireless.rate_plan.RatePlanPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return RatePlanPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of RatePlanInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of RatePlanInstance :rtype: twilio.rest.preview.wireless.rate_plan.RatePlanPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return RatePlanPage(self._version, response, self._solution) def create(self, unique_name=values.unset, friendly_name=values.unset, data_enabled=values.unset, data_limit=values.unset, data_metering=values.unset, messaging_enabled=values.unset, voice_enabled=values.unset, commands_enabled=values.unset, national_roaming_enabled=values.unset, international_roaming=values.unset): """ Create a new RatePlanInstance :param unicode unique_name: The unique_name :param unicode friendly_name: The friendly_name :param bool data_enabled: The data_enabled :param unicode data_limit: The data_limit :param unicode data_metering: The data_metering :param bool messaging_enabled: The messaging_enabled :param bool voice_enabled: The voice_enabled :param bool commands_enabled: The commands_enabled :param bool national_roaming_enabled: The national_roaming_enabled :param unicode international_roaming: The international_roaming :returns: Newly created RatePlanInstance :rtype: twilio.rest.preview.wireless.rate_plan.RatePlanInstance """ data = values.of({ 'UniqueName': unique_name, 'FriendlyName': friendly_name, 'DataEnabled': data_enabled, 'DataLimit': data_limit, 'DataMetering': data_metering, 'MessagingEnabled': messaging_enabled, 'VoiceEnabled': voice_enabled, 'CommandsEnabled': commands_enabled, 'NationalRoamingEnabled': national_roaming_enabled, 'InternationalRoaming': international_roaming, }) payload = self._version.create( 'POST', self._uri, data=data, ) return RatePlanInstance(self._version, payload,) def get(self, sid): """ Constructs a RatePlanContext :param sid: The sid :returns: twilio.rest.preview.wireless.rate_plan.RatePlanContext :rtype: twilio.rest.preview.wireless.rate_plan.RatePlanContext """ return RatePlanContext(self._version, sid=sid,) def __call__(self, sid): """ Constructs a RatePlanContext :param sid: The sid :returns: twilio.rest.preview.wireless.rate_plan.RatePlanContext :rtype: twilio.rest.preview.wireless.rate_plan.RatePlanContext """ return RatePlanContext(self._version, sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class RatePlanPage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the RatePlanPage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.preview.wireless.rate_plan.RatePlanPage :rtype: twilio.rest.preview.wireless.rate_plan.RatePlanPage """ super(RatePlanPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of RatePlanInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.wireless.rate_plan.RatePlanInstance :rtype: twilio.rest.preview.wireless.rate_plan.RatePlanInstance """ return RatePlanInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class RatePlanContext(InstanceContext): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, sid): """ Initialize the RatePlanContext :param Version version: Version that contains the resource :param sid: The sid :returns: twilio.rest.preview.wireless.rate_plan.RatePlanContext :rtype: twilio.rest.preview.wireless.rate_plan.RatePlanContext """ super(RatePlanContext, self).__init__(version) # Path Solution self._solution = {'sid': sid,} self._uri = '/RatePlans/{sid}'.format(**self._solution) def fetch(self): """ Fetch a RatePlanInstance :returns: Fetched RatePlanInstance :rtype: twilio.rest.preview.wireless.rate_plan.RatePlanInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return RatePlanInstance(self._version, payload, sid=self._solution['sid'],) def update(self, unique_name=values.unset, friendly_name=values.unset): """ Update the RatePlanInstance :param unicode unique_name: The unique_name :param unicode friendly_name: The friendly_name :returns: Updated RatePlanInstance :rtype: twilio.rest.preview.wireless.rate_plan.RatePlanInstance """ data = values.of({'UniqueName': unique_name, 'FriendlyName': friendly_name,}) payload = self._version.update( 'POST', self._uri, data=data, ) return RatePlanInstance(self._version, payload, sid=self._solution['sid'],) def delete(self): """ Deletes the RatePlanInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class RatePlanInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, payload, sid=None): """ Initialize the RatePlanInstance :returns: twilio.rest.preview.wireless.rate_plan.RatePlanInstance :rtype: twilio.rest.preview.wireless.rate_plan.RatePlanInstance """ super(RatePlanInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'unique_name': payload['unique_name'], 'account_sid': payload['account_sid'], 'friendly_name': payload['friendly_name'], 'data_enabled': payload['data_enabled'], 'data_metering': payload['data_metering'], 'data_limit': deserialize.integer(payload['data_limit']), 'messaging_enabled': payload['messaging_enabled'], 'voice_enabled': payload['voice_enabled'], 'national_roaming_enabled': payload['national_roaming_enabled'], 'international_roaming': payload['international_roaming'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'url': payload['url'], } # Context self._context = None self._solution = {'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: RatePlanContext for this RatePlanInstance :rtype: twilio.rest.preview.wireless.rate_plan.RatePlanContext """ if self._context is None: self._context = RatePlanContext(self._version, sid=self._solution['sid'],) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def unique_name(self): """ :returns: The unique_name :rtype: unicode """ return self._properties['unique_name'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def data_enabled(self): """ :returns: The data_enabled :rtype: bool """ return self._properties['data_enabled'] @property def data_metering(self): """ :returns: The data_metering :rtype: unicode """ return self._properties['data_metering'] @property def data_limit(self): """ :returns: The data_limit :rtype: unicode """ return self._properties['data_limit'] @property def messaging_enabled(self): """ :returns: The messaging_enabled :rtype: bool """ return self._properties['messaging_enabled'] @property def voice_enabled(self): """ :returns: The voice_enabled :rtype: bool """ return self._properties['voice_enabled'] @property def national_roaming_enabled(self): """ :returns: The national_roaming_enabled :rtype: bool """ return self._properties['national_roaming_enabled'] @property def international_roaming(self): """ :returns: The international_roaming :rtype: unicode """ return self._properties['international_roaming'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a RatePlanInstance :returns: Fetched RatePlanInstance :rtype: twilio.rest.preview.wireless.rate_plan.RatePlanInstance """ return self._proxy.fetch() def update(self, unique_name=values.unset, friendly_name=values.unset): """ Update the RatePlanInstance :param unicode unique_name: The unique_name :param unicode friendly_name: The friendly_name :returns: Updated RatePlanInstance :rtype: twilio.rest.preview.wireless.rate_plan.RatePlanInstance """ return self._proxy.update(unique_name=unique_name, friendly_name=friendly_name,) def delete(self): """ Deletes the RatePlanInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/preview/wireless/sim/000077500000000000000000000000001317472742600227645ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/preview/wireless/sim/__init__.py000066400000000000000000000536141317472742600251060ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.preview.wireless.sim.usage import UsageList class SimList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version): """ Initialize the SimList :param Version version: Version that contains the resource :returns: twilio.rest.preview.wireless.sim.SimList :rtype: twilio.rest.preview.wireless.sim.SimList """ super(SimList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/Sims'.format(**self._solution) def stream(self, status=values.unset, iccid=values.unset, rate_plan=values.unset, e_id=values.unset, sim_registration_code=values.unset, limit=None, page_size=None): """ Streams SimInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param unicode status: The status :param unicode iccid: The iccid :param unicode rate_plan: The rate_plan :param unicode e_id: The e_id :param unicode sim_registration_code: The sim_registration_code :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.wireless.sim.SimInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( status=status, iccid=iccid, rate_plan=rate_plan, e_id=e_id, sim_registration_code=sim_registration_code, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, status=values.unset, iccid=values.unset, rate_plan=values.unset, e_id=values.unset, sim_registration_code=values.unset, limit=None, page_size=None): """ Lists SimInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param unicode status: The status :param unicode iccid: The iccid :param unicode rate_plan: The rate_plan :param unicode e_id: The e_id :param unicode sim_registration_code: The sim_registration_code :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.preview.wireless.sim.SimInstance] """ return list(self.stream( status=status, iccid=iccid, rate_plan=rate_plan, e_id=e_id, sim_registration_code=sim_registration_code, limit=limit, page_size=page_size, )) def page(self, status=values.unset, iccid=values.unset, rate_plan=values.unset, e_id=values.unset, sim_registration_code=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of SimInstance records from the API. Request is executed immediately :param unicode status: The status :param unicode iccid: The iccid :param unicode rate_plan: The rate_plan :param unicode e_id: The e_id :param unicode sim_registration_code: The sim_registration_code :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of SimInstance :rtype: twilio.rest.preview.wireless.sim.SimPage """ params = values.of({ 'Status': status, 'Iccid': iccid, 'RatePlan': rate_plan, 'EId': e_id, 'SimRegistrationCode': sim_registration_code, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return SimPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of SimInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of SimInstance :rtype: twilio.rest.preview.wireless.sim.SimPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return SimPage(self._version, response, self._solution) def get(self, sid): """ Constructs a SimContext :param sid: The sid :returns: twilio.rest.preview.wireless.sim.SimContext :rtype: twilio.rest.preview.wireless.sim.SimContext """ return SimContext(self._version, sid=sid,) def __call__(self, sid): """ Constructs a SimContext :param sid: The sid :returns: twilio.rest.preview.wireless.sim.SimContext :rtype: twilio.rest.preview.wireless.sim.SimContext """ return SimContext(self._version, sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SimPage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the SimPage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.preview.wireless.sim.SimPage :rtype: twilio.rest.preview.wireless.sim.SimPage """ super(SimPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of SimInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.wireless.sim.SimInstance :rtype: twilio.rest.preview.wireless.sim.SimInstance """ return SimInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SimContext(InstanceContext): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, sid): """ Initialize the SimContext :param Version version: Version that contains the resource :param sid: The sid :returns: twilio.rest.preview.wireless.sim.SimContext :rtype: twilio.rest.preview.wireless.sim.SimContext """ super(SimContext, self).__init__(version) # Path Solution self._solution = {'sid': sid,} self._uri = '/Sims/{sid}'.format(**self._solution) # Dependents self._usage = None def fetch(self): """ Fetch a SimInstance :returns: Fetched SimInstance :rtype: twilio.rest.preview.wireless.sim.SimInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return SimInstance(self._version, payload, sid=self._solution['sid'],) def update(self, unique_name=values.unset, callback_method=values.unset, callback_url=values.unset, friendly_name=values.unset, rate_plan=values.unset, status=values.unset, commands_callback_method=values.unset, commands_callback_url=values.unset, sms_fallback_method=values.unset, sms_fallback_url=values.unset, sms_method=values.unset, sms_url=values.unset, voice_fallback_method=values.unset, voice_fallback_url=values.unset, voice_method=values.unset, voice_url=values.unset): """ Update the SimInstance :param unicode unique_name: The unique_name :param unicode callback_method: The callback_method :param unicode callback_url: The callback_url :param unicode friendly_name: The friendly_name :param unicode rate_plan: The rate_plan :param unicode status: The status :param unicode commands_callback_method: The commands_callback_method :param unicode commands_callback_url: The commands_callback_url :param unicode sms_fallback_method: The sms_fallback_method :param unicode sms_fallback_url: The sms_fallback_url :param unicode sms_method: The sms_method :param unicode sms_url: The sms_url :param unicode voice_fallback_method: The voice_fallback_method :param unicode voice_fallback_url: The voice_fallback_url :param unicode voice_method: The voice_method :param unicode voice_url: The voice_url :returns: Updated SimInstance :rtype: twilio.rest.preview.wireless.sim.SimInstance """ data = values.of({ 'UniqueName': unique_name, 'CallbackMethod': callback_method, 'CallbackUrl': callback_url, 'FriendlyName': friendly_name, 'RatePlan': rate_plan, 'Status': status, 'CommandsCallbackMethod': commands_callback_method, 'CommandsCallbackUrl': commands_callback_url, 'SmsFallbackMethod': sms_fallback_method, 'SmsFallbackUrl': sms_fallback_url, 'SmsMethod': sms_method, 'SmsUrl': sms_url, 'VoiceFallbackMethod': voice_fallback_method, 'VoiceFallbackUrl': voice_fallback_url, 'VoiceMethod': voice_method, 'VoiceUrl': voice_url, }) payload = self._version.update( 'POST', self._uri, data=data, ) return SimInstance(self._version, payload, sid=self._solution['sid'],) @property def usage(self): """ Access the usage :returns: twilio.rest.preview.wireless.sim.usage.UsageList :rtype: twilio.rest.preview.wireless.sim.usage.UsageList """ if self._usage is None: self._usage = UsageList(self._version, sim_sid=self._solution['sid'],) return self._usage def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class SimInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, payload, sid=None): """ Initialize the SimInstance :returns: twilio.rest.preview.wireless.sim.SimInstance :rtype: twilio.rest.preview.wireless.sim.SimInstance """ super(SimInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'unique_name': payload['unique_name'], 'account_sid': payload['account_sid'], 'rate_plan_sid': payload['rate_plan_sid'], 'friendly_name': payload['friendly_name'], 'iccid': payload['iccid'], 'e_id': payload['e_id'], 'status': payload['status'], 'commands_callback_url': payload['commands_callback_url'], 'commands_callback_method': payload['commands_callback_method'], 'sms_fallback_method': payload['sms_fallback_method'], 'sms_fallback_url': payload['sms_fallback_url'], 'sms_method': payload['sms_method'], 'sms_url': payload['sms_url'], 'voice_fallback_method': payload['voice_fallback_method'], 'voice_fallback_url': payload['voice_fallback_url'], 'voice_method': payload['voice_method'], 'voice_url': payload['voice_url'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'url': payload['url'], 'links': payload['links'], } # Context self._context = None self._solution = {'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: SimContext for this SimInstance :rtype: twilio.rest.preview.wireless.sim.SimContext """ if self._context is None: self._context = SimContext(self._version, sid=self._solution['sid'],) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def unique_name(self): """ :returns: The unique_name :rtype: unicode """ return self._properties['unique_name'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def rate_plan_sid(self): """ :returns: The rate_plan_sid :rtype: unicode """ return self._properties['rate_plan_sid'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def iccid(self): """ :returns: The iccid :rtype: unicode """ return self._properties['iccid'] @property def e_id(self): """ :returns: The e_id :rtype: unicode """ return self._properties['e_id'] @property def status(self): """ :returns: The status :rtype: unicode """ return self._properties['status'] @property def commands_callback_url(self): """ :returns: The commands_callback_url :rtype: unicode """ return self._properties['commands_callback_url'] @property def commands_callback_method(self): """ :returns: The commands_callback_method :rtype: unicode """ return self._properties['commands_callback_method'] @property def sms_fallback_method(self): """ :returns: The sms_fallback_method :rtype: unicode """ return self._properties['sms_fallback_method'] @property def sms_fallback_url(self): """ :returns: The sms_fallback_url :rtype: unicode """ return self._properties['sms_fallback_url'] @property def sms_method(self): """ :returns: The sms_method :rtype: unicode """ return self._properties['sms_method'] @property def sms_url(self): """ :returns: The sms_url :rtype: unicode """ return self._properties['sms_url'] @property def voice_fallback_method(self): """ :returns: The voice_fallback_method :rtype: unicode """ return self._properties['voice_fallback_method'] @property def voice_fallback_url(self): """ :returns: The voice_fallback_url :rtype: unicode """ return self._properties['voice_fallback_url'] @property def voice_method(self): """ :returns: The voice_method :rtype: unicode """ return self._properties['voice_method'] @property def voice_url(self): """ :returns: The voice_url :rtype: unicode """ return self._properties['voice_url'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a SimInstance :returns: Fetched SimInstance :rtype: twilio.rest.preview.wireless.sim.SimInstance """ return self._proxy.fetch() def update(self, unique_name=values.unset, callback_method=values.unset, callback_url=values.unset, friendly_name=values.unset, rate_plan=values.unset, status=values.unset, commands_callback_method=values.unset, commands_callback_url=values.unset, sms_fallback_method=values.unset, sms_fallback_url=values.unset, sms_method=values.unset, sms_url=values.unset, voice_fallback_method=values.unset, voice_fallback_url=values.unset, voice_method=values.unset, voice_url=values.unset): """ Update the SimInstance :param unicode unique_name: The unique_name :param unicode callback_method: The callback_method :param unicode callback_url: The callback_url :param unicode friendly_name: The friendly_name :param unicode rate_plan: The rate_plan :param unicode status: The status :param unicode commands_callback_method: The commands_callback_method :param unicode commands_callback_url: The commands_callback_url :param unicode sms_fallback_method: The sms_fallback_method :param unicode sms_fallback_url: The sms_fallback_url :param unicode sms_method: The sms_method :param unicode sms_url: The sms_url :param unicode voice_fallback_method: The voice_fallback_method :param unicode voice_fallback_url: The voice_fallback_url :param unicode voice_method: The voice_method :param unicode voice_url: The voice_url :returns: Updated SimInstance :rtype: twilio.rest.preview.wireless.sim.SimInstance """ return self._proxy.update( unique_name=unique_name, callback_method=callback_method, callback_url=callback_url, friendly_name=friendly_name, rate_plan=rate_plan, status=status, commands_callback_method=commands_callback_method, commands_callback_url=commands_callback_url, sms_fallback_method=sms_fallback_method, sms_fallback_url=sms_fallback_url, sms_method=sms_method, sms_url=sms_url, voice_fallback_method=voice_fallback_method, voice_fallback_url=voice_fallback_url, voice_method=voice_method, voice_url=voice_url, ) @property def usage(self): """ Access the usage :returns: twilio.rest.preview.wireless.sim.usage.UsageList :rtype: twilio.rest.preview.wireless.sim.usage.UsageList """ return self._proxy.usage def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/preview/wireless/sim/usage.py000066400000000000000000000210731317472742600244450ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ 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.page import Page class UsageList(ListResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, sim_sid): """ Initialize the UsageList :param Version version: Version that contains the resource :param sim_sid: The sim_sid :returns: twilio.rest.preview.wireless.sim.usage.UsageList :rtype: twilio.rest.preview.wireless.sim.usage.UsageList """ super(UsageList, self).__init__(version) # Path Solution self._solution = {'sim_sid': sim_sid,} def get(self): """ Constructs a UsageContext :returns: twilio.rest.preview.wireless.sim.usage.UsageContext :rtype: twilio.rest.preview.wireless.sim.usage.UsageContext """ return UsageContext(self._version, sim_sid=self._solution['sim_sid'],) def __call__(self): """ Constructs a UsageContext :returns: twilio.rest.preview.wireless.sim.usage.UsageContext :rtype: twilio.rest.preview.wireless.sim.usage.UsageContext """ return UsageContext(self._version, sim_sid=self._solution['sim_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class UsagePage(Page): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, response, solution): """ Initialize the UsagePage :param Version version: Version that contains the resource :param Response response: Response from the API :param sim_sid: The sim_sid :returns: twilio.rest.preview.wireless.sim.usage.UsagePage :rtype: twilio.rest.preview.wireless.sim.usage.UsagePage """ super(UsagePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of UsageInstance :param dict payload: Payload response from the API :returns: twilio.rest.preview.wireless.sim.usage.UsageInstance :rtype: twilio.rest.preview.wireless.sim.usage.UsageInstance """ return UsageInstance(self._version, payload, sim_sid=self._solution['sim_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class UsageContext(InstanceContext): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, sim_sid): """ Initialize the UsageContext :param Version version: Version that contains the resource :param sim_sid: The sim_sid :returns: twilio.rest.preview.wireless.sim.usage.UsageContext :rtype: twilio.rest.preview.wireless.sim.usage.UsageContext """ super(UsageContext, self).__init__(version) # Path Solution self._solution = {'sim_sid': sim_sid,} self._uri = '/Sims/{sim_sid}/Usage'.format(**self._solution) def fetch(self, end=values.unset, start=values.unset): """ Fetch a UsageInstance :param unicode end: The end :param unicode start: The start :returns: Fetched UsageInstance :rtype: twilio.rest.preview.wireless.sim.usage.UsageInstance """ params = values.of({'End': end, 'Start': start,}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return UsageInstance(self._version, payload, sim_sid=self._solution['sim_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class UsageInstance(InstanceResource): """ PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. """ def __init__(self, version, payload, sim_sid): """ Initialize the UsageInstance :returns: twilio.rest.preview.wireless.sim.usage.UsageInstance :rtype: twilio.rest.preview.wireless.sim.usage.UsageInstance """ super(UsageInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sim_sid': payload['sim_sid'], 'sim_unique_name': payload['sim_unique_name'], 'account_sid': payload['account_sid'], 'period': payload['period'], 'commands_usage': payload['commands_usage'], 'commands_costs': payload['commands_costs'], 'data_usage': payload['data_usage'], 'data_costs': payload['data_costs'], 'url': payload['url'], } # Context self._context = None self._solution = {'sim_sid': sim_sid,} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: UsageContext for this UsageInstance :rtype: twilio.rest.preview.wireless.sim.usage.UsageContext """ if self._context is None: self._context = UsageContext(self._version, sim_sid=self._solution['sim_sid'],) return self._context @property def sim_sid(self): """ :returns: The sim_sid :rtype: unicode """ return self._properties['sim_sid'] @property def sim_unique_name(self): """ :returns: The sim_unique_name :rtype: unicode """ return self._properties['sim_unique_name'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def period(self): """ :returns: The period :rtype: dict """ return self._properties['period'] @property def commands_usage(self): """ :returns: The commands_usage :rtype: dict """ return self._properties['commands_usage'] @property def commands_costs(self): """ :returns: The commands_costs :rtype: dict """ return self._properties['commands_costs'] @property def data_usage(self): """ :returns: The data_usage :rtype: dict """ return self._properties['data_usage'] @property def data_costs(self): """ :returns: The data_costs :rtype: dict """ return self._properties['data_costs'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self, end=values.unset, start=values.unset): """ Fetch a UsageInstance :param unicode end: The end :param unicode start: The start :returns: Fetched UsageInstance :rtype: twilio.rest.preview.wireless.sim.usage.UsageInstance """ return self._proxy.fetch(end=end, start=start,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/pricing/000077500000000000000000000000001317472742600203115ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/pricing/__init__.py000066400000000000000000000026371317472742600224320ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.domain import Domain from twilio.rest.pricing.v1 import V1 class Pricing(Domain): def __init__(self, twilio): """ Initialize the Pricing Domain :returns: Domain for Pricing :rtype: twilio.rest.pricing.Pricing """ super(Pricing, self).__init__(twilio) self.base_url = 'https://pricing.twilio.com' # Versions self._v1 = None @property def v1(self): """ :returns: Version v1 of pricing :rtype: twilio.rest.pricing.v1.V1 """ if self._v1 is None: self._v1 = V1(self) return self._v1 @property def messaging(self): """ :rtype: twilio.rest.pricing.v1.messaging.MessagingList """ return self.v1.messaging @property def phone_numbers(self): """ :rtype: twilio.rest.pricing.v1.phone_number.PhoneNumberList """ return self.v1.phone_numbers @property def voice(self): """ :rtype: twilio.rest.pricing.v1.voice.VoiceList """ return self.v1.voice def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/pricing/v1/000077500000000000000000000000001317472742600206375ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/pricing/v1/__init__.py000066400000000000000000000031371317472742600227540ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.version import Version from twilio.rest.pricing.v1.messaging import MessagingList from twilio.rest.pricing.v1.phone_number import PhoneNumberList from twilio.rest.pricing.v1.voice import VoiceList class V1(Version): def __init__(self, domain): """ Initialize the V1 version of Pricing :returns: V1 version of Pricing :rtype: twilio.rest.pricing.v1.V1.V1 """ super(V1, self).__init__(domain) self.version = 'v1' self._messaging = None self._phone_numbers = None self._voice = None @property def messaging(self): """ :rtype: twilio.rest.pricing.v1.messaging.MessagingList """ if self._messaging is None: self._messaging = MessagingList(self) return self._messaging @property def phone_numbers(self): """ :rtype: twilio.rest.pricing.v1.phone_number.PhoneNumberList """ if self._phone_numbers is None: self._phone_numbers = PhoneNumberList(self) return self._phone_numbers @property def voice(self): """ :rtype: twilio.rest.pricing.v1.voice.VoiceList """ if self._voice is None: self._voice = VoiceList(self) return self._voice def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/pricing/v1/messaging/000077500000000000000000000000001317472742600226145ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/pricing/v1/messaging/__init__.py000066400000000000000000000072461317472742600247360ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page from twilio.rest.pricing.v1.messaging.country import CountryList class MessagingList(ListResource): """ """ def __init__(self, version): """ Initialize the MessagingList :param Version version: Version that contains the resource :returns: twilio.rest.pricing.v1.messaging.MessagingList :rtype: twilio.rest.pricing.v1.messaging.MessagingList """ super(MessagingList, self).__init__(version) # Path Solution self._solution = {} # Components self._countries = None @property def countries(self): """ Access the countries :returns: twilio.rest.pricing.v1.messaging.country.CountryList :rtype: twilio.rest.pricing.v1.messaging.country.CountryList """ if self._countries is None: self._countries = CountryList(self._version,) return self._countries def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class MessagingPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the MessagingPage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.pricing.v1.messaging.MessagingPage :rtype: twilio.rest.pricing.v1.messaging.MessagingPage """ super(MessagingPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of MessagingInstance :param dict payload: Payload response from the API :returns: twilio.rest.pricing.v1.messaging.MessagingInstance :rtype: twilio.rest.pricing.v1.messaging.MessagingInstance """ return MessagingInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class MessagingInstance(InstanceResource): """ """ def __init__(self, version, payload): """ Initialize the MessagingInstance :returns: twilio.rest.pricing.v1.messaging.MessagingInstance :rtype: twilio.rest.pricing.v1.messaging.MessagingInstance """ super(MessagingInstance, self).__init__(version) # Marshaled Properties self._properties = {'name': payload['name'], 'url': payload['url'], 'links': payload['links'],} # Context self._context = None self._solution = {} @property def name(self): """ :returns: The name :rtype: unicode """ return self._properties['name'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/pricing/v1/messaging/country.py000066400000000000000000000253431317472742600247000ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ 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.page import Page class CountryList(ListResource): """ """ def __init__(self, version): """ Initialize the CountryList :param Version version: Version that contains the resource :returns: twilio.rest.pricing.v1.messaging.country.CountryList :rtype: twilio.rest.pricing.v1.messaging.country.CountryList """ super(CountryList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/Messaging/Countries'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams CountryInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.pricing.v1.messaging.country.CountryInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists CountryInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.pricing.v1.messaging.country.CountryInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of CountryInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of CountryInstance :rtype: twilio.rest.pricing.v1.messaging.country.CountryPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return CountryPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of CountryInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of CountryInstance :rtype: twilio.rest.pricing.v1.messaging.country.CountryPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return CountryPage(self._version, response, self._solution) def get(self, iso_country): """ Constructs a CountryContext :param iso_country: The iso_country :returns: twilio.rest.pricing.v1.messaging.country.CountryContext :rtype: twilio.rest.pricing.v1.messaging.country.CountryContext """ return CountryContext(self._version, iso_country=iso_country,) def __call__(self, iso_country): """ Constructs a CountryContext :param iso_country: The iso_country :returns: twilio.rest.pricing.v1.messaging.country.CountryContext :rtype: twilio.rest.pricing.v1.messaging.country.CountryContext """ return CountryContext(self._version, iso_country=iso_country,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class CountryPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the CountryPage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.pricing.v1.messaging.country.CountryPage :rtype: twilio.rest.pricing.v1.messaging.country.CountryPage """ super(CountryPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of CountryInstance :param dict payload: Payload response from the API :returns: twilio.rest.pricing.v1.messaging.country.CountryInstance :rtype: twilio.rest.pricing.v1.messaging.country.CountryInstance """ return CountryInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class CountryContext(InstanceContext): """ """ def __init__(self, version, iso_country): """ Initialize the CountryContext :param Version version: Version that contains the resource :param iso_country: The iso_country :returns: twilio.rest.pricing.v1.messaging.country.CountryContext :rtype: twilio.rest.pricing.v1.messaging.country.CountryContext """ super(CountryContext, self).__init__(version) # Path Solution self._solution = {'iso_country': iso_country,} self._uri = '/Messaging/Countries/{iso_country}'.format(**self._solution) def fetch(self): """ Fetch a CountryInstance :returns: Fetched CountryInstance :rtype: twilio.rest.pricing.v1.messaging.country.CountryInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return CountryInstance(self._version, payload, iso_country=self._solution['iso_country'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class CountryInstance(InstanceResource): """ """ def __init__(self, version, payload, iso_country=None): """ Initialize the CountryInstance :returns: twilio.rest.pricing.v1.messaging.country.CountryInstance :rtype: twilio.rest.pricing.v1.messaging.country.CountryInstance """ super(CountryInstance, self).__init__(version) # Marshaled Properties self._properties = { 'country': payload['country'], 'iso_country': payload['iso_country'], 'url': payload['url'], 'outbound_sms_prices': payload.get('outbound_sms_prices'), 'inbound_sms_prices': payload.get('inbound_sms_prices'), 'price_unit': payload.get('price_unit'), } # Context self._context = None self._solution = {'iso_country': iso_country or self._properties['iso_country'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: CountryContext for this CountryInstance :rtype: twilio.rest.pricing.v1.messaging.country.CountryContext """ if self._context is None: self._context = CountryContext(self._version, iso_country=self._solution['iso_country'],) return self._context @property def country(self): """ :returns: The country :rtype: unicode """ return self._properties['country'] @property def iso_country(self): """ :returns: The iso_country :rtype: unicode """ return self._properties['iso_country'] @property def outbound_sms_prices(self): """ :returns: The outbound_sms_prices :rtype: unicode """ return self._properties['outbound_sms_prices'] @property def inbound_sms_prices(self): """ :returns: The inbound_sms_prices :rtype: unicode """ return self._properties['inbound_sms_prices'] @property def price_unit(self): """ :returns: The price_unit :rtype: unicode """ return self._properties['price_unit'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a CountryInstance :returns: Fetched CountryInstance :rtype: twilio.rest.pricing.v1.messaging.country.CountryInstance """ return self._proxy.fetch() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/pricing/v1/phone_number/000077500000000000000000000000001317472742600233205ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/pricing/v1/phone_number/__init__.py000066400000000000000000000073631317472742600254420ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page from twilio.rest.pricing.v1.phone_number.country import CountryList class PhoneNumberList(ListResource): """ """ def __init__(self, version): """ Initialize the PhoneNumberList :param Version version: Version that contains the resource :returns: twilio.rest.pricing.v1.phone_number.PhoneNumberList :rtype: twilio.rest.pricing.v1.phone_number.PhoneNumberList """ super(PhoneNumberList, self).__init__(version) # Path Solution self._solution = {} # Components self._countries = None @property def countries(self): """ Access the countries :returns: twilio.rest.pricing.v1.phone_number.country.CountryList :rtype: twilio.rest.pricing.v1.phone_number.country.CountryList """ if self._countries is None: self._countries = CountryList(self._version,) return self._countries def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class PhoneNumberPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the PhoneNumberPage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.pricing.v1.phone_number.PhoneNumberPage :rtype: twilio.rest.pricing.v1.phone_number.PhoneNumberPage """ super(PhoneNumberPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of PhoneNumberInstance :param dict payload: Payload response from the API :returns: twilio.rest.pricing.v1.phone_number.PhoneNumberInstance :rtype: twilio.rest.pricing.v1.phone_number.PhoneNumberInstance """ return PhoneNumberInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class PhoneNumberInstance(InstanceResource): """ """ def __init__(self, version, payload): """ Initialize the PhoneNumberInstance :returns: twilio.rest.pricing.v1.phone_number.PhoneNumberInstance :rtype: twilio.rest.pricing.v1.phone_number.PhoneNumberInstance """ super(PhoneNumberInstance, self).__init__(version) # Marshaled Properties self._properties = {'name': payload['name'], 'url': payload['url'], 'links': payload['links'],} # Context self._context = None self._solution = {} @property def name(self): """ :returns: The name :rtype: unicode """ return self._properties['name'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/pricing/v1/phone_number/country.py000066400000000000000000000250431317472742600254010ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ 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.page import Page class CountryList(ListResource): """ """ def __init__(self, version): """ Initialize the CountryList :param Version version: Version that contains the resource :returns: twilio.rest.pricing.v1.phone_number.country.CountryList :rtype: twilio.rest.pricing.v1.phone_number.country.CountryList """ super(CountryList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/PhoneNumbers/Countries'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams CountryInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.pricing.v1.phone_number.country.CountryInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists CountryInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.pricing.v1.phone_number.country.CountryInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of CountryInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of CountryInstance :rtype: twilio.rest.pricing.v1.phone_number.country.CountryPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return CountryPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of CountryInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of CountryInstance :rtype: twilio.rest.pricing.v1.phone_number.country.CountryPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return CountryPage(self._version, response, self._solution) def get(self, iso_country): """ Constructs a CountryContext :param iso_country: The iso_country :returns: twilio.rest.pricing.v1.phone_number.country.CountryContext :rtype: twilio.rest.pricing.v1.phone_number.country.CountryContext """ return CountryContext(self._version, iso_country=iso_country,) def __call__(self, iso_country): """ Constructs a CountryContext :param iso_country: The iso_country :returns: twilio.rest.pricing.v1.phone_number.country.CountryContext :rtype: twilio.rest.pricing.v1.phone_number.country.CountryContext """ return CountryContext(self._version, iso_country=iso_country,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class CountryPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the CountryPage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.pricing.v1.phone_number.country.CountryPage :rtype: twilio.rest.pricing.v1.phone_number.country.CountryPage """ super(CountryPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of CountryInstance :param dict payload: Payload response from the API :returns: twilio.rest.pricing.v1.phone_number.country.CountryInstance :rtype: twilio.rest.pricing.v1.phone_number.country.CountryInstance """ return CountryInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class CountryContext(InstanceContext): """ """ def __init__(self, version, iso_country): """ Initialize the CountryContext :param Version version: Version that contains the resource :param iso_country: The iso_country :returns: twilio.rest.pricing.v1.phone_number.country.CountryContext :rtype: twilio.rest.pricing.v1.phone_number.country.CountryContext """ super(CountryContext, self).__init__(version) # Path Solution self._solution = {'iso_country': iso_country,} self._uri = '/PhoneNumbers/Countries/{iso_country}'.format(**self._solution) def fetch(self): """ Fetch a CountryInstance :returns: Fetched CountryInstance :rtype: twilio.rest.pricing.v1.phone_number.country.CountryInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return CountryInstance(self._version, payload, iso_country=self._solution['iso_country'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class CountryInstance(InstanceResource): """ """ def __init__(self, version, payload, iso_country=None): """ Initialize the CountryInstance :returns: twilio.rest.pricing.v1.phone_number.country.CountryInstance :rtype: twilio.rest.pricing.v1.phone_number.country.CountryInstance """ super(CountryInstance, self).__init__(version) # Marshaled Properties self._properties = { 'country': payload['country'], 'iso_country': payload['iso_country'], 'url': payload['url'], 'phone_number_prices': payload.get('phone_number_prices'), 'price_unit': payload.get('price_unit'), } # Context self._context = None self._solution = {'iso_country': iso_country or self._properties['iso_country'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: CountryContext for this CountryInstance :rtype: twilio.rest.pricing.v1.phone_number.country.CountryContext """ if self._context is None: self._context = CountryContext(self._version, iso_country=self._solution['iso_country'],) return self._context @property def country(self): """ :returns: The country :rtype: unicode """ return self._properties['country'] @property def iso_country(self): """ :returns: The iso_country :rtype: unicode """ return self._properties['iso_country'] @property def phone_number_prices(self): """ :returns: The phone_number_prices :rtype: unicode """ return self._properties['phone_number_prices'] @property def price_unit(self): """ :returns: The price_unit :rtype: unicode """ return self._properties['price_unit'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a CountryInstance :returns: Fetched CountryInstance :rtype: twilio.rest.pricing.v1.phone_number.country.CountryInstance """ return self._proxy.fetch() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/pricing/v1/voice/000077500000000000000000000000001317472742600217445ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/pricing/v1/voice/__init__.py000066400000000000000000000077121317472742600240640ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page from twilio.rest.pricing.v1.voice.country import CountryList from twilio.rest.pricing.v1.voice.number import NumberList class VoiceList(ListResource): """ """ def __init__(self, version): """ Initialize the VoiceList :param Version version: Version that contains the resource :returns: twilio.rest.pricing.v1.voice.VoiceList :rtype: twilio.rest.pricing.v1.voice.VoiceList """ super(VoiceList, self).__init__(version) # Path Solution self._solution = {} # Components self._numbers = None self._countries = None @property def numbers(self): """ Access the numbers :returns: twilio.rest.pricing.v1.voice.number.NumberList :rtype: twilio.rest.pricing.v1.voice.number.NumberList """ if self._numbers is None: self._numbers = NumberList(self._version,) return self._numbers @property def countries(self): """ Access the countries :returns: twilio.rest.pricing.v1.voice.country.CountryList :rtype: twilio.rest.pricing.v1.voice.country.CountryList """ if self._countries is None: self._countries = CountryList(self._version,) return self._countries def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class VoicePage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the VoicePage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.pricing.v1.voice.VoicePage :rtype: twilio.rest.pricing.v1.voice.VoicePage """ super(VoicePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of VoiceInstance :param dict payload: Payload response from the API :returns: twilio.rest.pricing.v1.voice.VoiceInstance :rtype: twilio.rest.pricing.v1.voice.VoiceInstance """ return VoiceInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class VoiceInstance(InstanceResource): """ """ def __init__(self, version, payload): """ Initialize the VoiceInstance :returns: twilio.rest.pricing.v1.voice.VoiceInstance :rtype: twilio.rest.pricing.v1.voice.VoiceInstance """ super(VoiceInstance, self).__init__(version) # Marshaled Properties self._properties = {'name': payload['name'], 'url': payload['url'], 'links': payload['links'],} # Context self._context = None self._solution = {} @property def name(self): """ :returns: The name :rtype: unicode """ return self._properties['name'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/pricing/v1/voice/country.py000066400000000000000000000252331317472742600240260ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ 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.page import Page class CountryList(ListResource): """ """ def __init__(self, version): """ Initialize the CountryList :param Version version: Version that contains the resource :returns: twilio.rest.pricing.v1.voice.country.CountryList :rtype: twilio.rest.pricing.v1.voice.country.CountryList """ super(CountryList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/Voice/Countries'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams CountryInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.pricing.v1.voice.country.CountryInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists CountryInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.pricing.v1.voice.country.CountryInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of CountryInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of CountryInstance :rtype: twilio.rest.pricing.v1.voice.country.CountryPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return CountryPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of CountryInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of CountryInstance :rtype: twilio.rest.pricing.v1.voice.country.CountryPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return CountryPage(self._version, response, self._solution) def get(self, iso_country): """ Constructs a CountryContext :param iso_country: The iso_country :returns: twilio.rest.pricing.v1.voice.country.CountryContext :rtype: twilio.rest.pricing.v1.voice.country.CountryContext """ return CountryContext(self._version, iso_country=iso_country,) def __call__(self, iso_country): """ Constructs a CountryContext :param iso_country: The iso_country :returns: twilio.rest.pricing.v1.voice.country.CountryContext :rtype: twilio.rest.pricing.v1.voice.country.CountryContext """ return CountryContext(self._version, iso_country=iso_country,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class CountryPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the CountryPage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.pricing.v1.voice.country.CountryPage :rtype: twilio.rest.pricing.v1.voice.country.CountryPage """ super(CountryPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of CountryInstance :param dict payload: Payload response from the API :returns: twilio.rest.pricing.v1.voice.country.CountryInstance :rtype: twilio.rest.pricing.v1.voice.country.CountryInstance """ return CountryInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class CountryContext(InstanceContext): """ """ def __init__(self, version, iso_country): """ Initialize the CountryContext :param Version version: Version that contains the resource :param iso_country: The iso_country :returns: twilio.rest.pricing.v1.voice.country.CountryContext :rtype: twilio.rest.pricing.v1.voice.country.CountryContext """ super(CountryContext, self).__init__(version) # Path Solution self._solution = {'iso_country': iso_country,} self._uri = '/Voice/Countries/{iso_country}'.format(**self._solution) def fetch(self): """ Fetch a CountryInstance :returns: Fetched CountryInstance :rtype: twilio.rest.pricing.v1.voice.country.CountryInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return CountryInstance(self._version, payload, iso_country=self._solution['iso_country'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class CountryInstance(InstanceResource): """ """ def __init__(self, version, payload, iso_country=None): """ Initialize the CountryInstance :returns: twilio.rest.pricing.v1.voice.country.CountryInstance :rtype: twilio.rest.pricing.v1.voice.country.CountryInstance """ super(CountryInstance, self).__init__(version) # Marshaled Properties self._properties = { 'country': payload['country'], 'iso_country': payload['iso_country'], 'url': payload['url'], 'outbound_prefix_prices': payload.get('outbound_prefix_prices'), 'inbound_call_prices': payload.get('inbound_call_prices'), 'price_unit': payload.get('price_unit'), } # Context self._context = None self._solution = {'iso_country': iso_country or self._properties['iso_country'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: CountryContext for this CountryInstance :rtype: twilio.rest.pricing.v1.voice.country.CountryContext """ if self._context is None: self._context = CountryContext(self._version, iso_country=self._solution['iso_country'],) return self._context @property def country(self): """ :returns: The country :rtype: unicode """ return self._properties['country'] @property def iso_country(self): """ :returns: The iso_country :rtype: unicode """ return self._properties['iso_country'] @property def outbound_prefix_prices(self): """ :returns: The outbound_prefix_prices :rtype: unicode """ return self._properties['outbound_prefix_prices'] @property def inbound_call_prices(self): """ :returns: The inbound_call_prices :rtype: unicode """ return self._properties['inbound_call_prices'] @property def price_unit(self): """ :returns: The price_unit :rtype: unicode """ return self._properties['price_unit'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a CountryInstance :returns: Fetched CountryInstance :rtype: twilio.rest.pricing.v1.voice.country.CountryInstance """ return self._proxy.fetch() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/pricing/v1/voice/number.py000066400000000000000000000160361317472742600236140ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ 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.page import Page class NumberList(ListResource): """ """ def __init__(self, version): """ Initialize the NumberList :param Version version: Version that contains the resource :returns: twilio.rest.pricing.v1.voice.number.NumberList :rtype: twilio.rest.pricing.v1.voice.number.NumberList """ super(NumberList, self).__init__(version) # Path Solution self._solution = {} def get(self, number): """ Constructs a NumberContext :param number: The number :returns: twilio.rest.pricing.v1.voice.number.NumberContext :rtype: twilio.rest.pricing.v1.voice.number.NumberContext """ return NumberContext(self._version, number=number,) def __call__(self, number): """ Constructs a NumberContext :param number: The number :returns: twilio.rest.pricing.v1.voice.number.NumberContext :rtype: twilio.rest.pricing.v1.voice.number.NumberContext """ return NumberContext(self._version, number=number,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class NumberPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the NumberPage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.pricing.v1.voice.number.NumberPage :rtype: twilio.rest.pricing.v1.voice.number.NumberPage """ super(NumberPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of NumberInstance :param dict payload: Payload response from the API :returns: twilio.rest.pricing.v1.voice.number.NumberInstance :rtype: twilio.rest.pricing.v1.voice.number.NumberInstance """ return NumberInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class NumberContext(InstanceContext): """ """ def __init__(self, version, number): """ Initialize the NumberContext :param Version version: Version that contains the resource :param number: The number :returns: twilio.rest.pricing.v1.voice.number.NumberContext :rtype: twilio.rest.pricing.v1.voice.number.NumberContext """ super(NumberContext, self).__init__(version) # Path Solution self._solution = {'number': number,} self._uri = '/Voice/Numbers/{number}'.format(**self._solution) def fetch(self): """ Fetch a NumberInstance :returns: Fetched NumberInstance :rtype: twilio.rest.pricing.v1.voice.number.NumberInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return NumberInstance(self._version, payload, number=self._solution['number'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class NumberInstance(InstanceResource): """ """ def __init__(self, version, payload, number=None): """ Initialize the NumberInstance :returns: twilio.rest.pricing.v1.voice.number.NumberInstance :rtype: twilio.rest.pricing.v1.voice.number.NumberInstance """ super(NumberInstance, self).__init__(version) # Marshaled Properties self._properties = { 'number': payload['number'], 'country': payload['country'], 'iso_country': payload['iso_country'], 'outbound_call_price': payload['outbound_call_price'], 'inbound_call_price': payload['inbound_call_price'], 'price_unit': payload['price_unit'], 'url': payload['url'], } # Context self._context = None self._solution = {'number': number or self._properties['number'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: NumberContext for this NumberInstance :rtype: twilio.rest.pricing.v1.voice.number.NumberContext """ if self._context is None: self._context = NumberContext(self._version, number=self._solution['number'],) return self._context @property def number(self): """ :returns: The number :rtype: unicode """ return self._properties['number'] @property def country(self): """ :returns: The country :rtype: unicode """ return self._properties['country'] @property def iso_country(self): """ :returns: The iso_country :rtype: unicode """ return self._properties['iso_country'] @property def outbound_call_price(self): """ :returns: The outbound_call_price :rtype: unicode """ return self._properties['outbound_call_price'] @property def inbound_call_price(self): """ :returns: The inbound_call_price :rtype: unicode """ return self._properties['inbound_call_price'] @property def price_unit(self): """ :returns: The price_unit :rtype: unicode """ return self._properties['price_unit'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a NumberInstance :returns: Fetched NumberInstance :rtype: twilio.rest.pricing.v1.voice.number.NumberInstance """ return self._proxy.fetch() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/proxy/000077500000000000000000000000001317472742600200375ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/proxy/__init__.py000066400000000000000000000021041317472742600221450ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.domain import Domain from twilio.rest.proxy.v1 import V1 class Proxy(Domain): def __init__(self, twilio): """ Initialize the Proxy Domain :returns: Domain for Proxy :rtype: twilio.rest.proxy.Proxy """ super(Proxy, self).__init__(twilio) self.base_url = 'https://proxy.twilio.com' # Versions self._v1 = None @property def v1(self): """ :returns: Version v1 of proxy :rtype: twilio.rest.proxy.v1.V1 """ if self._v1 is None: self._v1 = V1(self) return self._v1 @property def services(self): """ :rtype: twilio.rest.proxy.v1.service.ServiceList """ return self.v1.services def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/proxy/v1/000077500000000000000000000000001317472742600203655ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/proxy/v1/__init__.py000066400000000000000000000016601317472742600225010ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.version import Version from twilio.rest.proxy.v1.service import ServiceList class V1(Version): def __init__(self, domain): """ Initialize the V1 version of Proxy :returns: V1 version of Proxy :rtype: twilio.rest.proxy.v1.V1.V1 """ super(V1, self).__init__(domain) self.version = 'v1' self._services = None @property def services(self): """ :rtype: twilio.rest.proxy.v1.service.ServiceList """ if self._services is None: self._services = ServiceList(self) return self._services def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/proxy/v1/service/000077500000000000000000000000001317472742600220255ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/proxy/v1/service/__init__.py000066400000000000000000000413011317472742600241350ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.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 ServiceList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version): """ Initialize the ServiceList :param Version version: Version that contains the resource :returns: twilio.rest.proxy.v1.service.ServiceList :rtype: twilio.rest.proxy.v1.service.ServiceList """ super(ServiceList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/Services'.format(**self._solution) def stream(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.proxy.v1.service.ServiceInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.proxy.v1.service.ServiceInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of ServiceInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of ServiceInstance :rtype: twilio.rest.proxy.v1.service.ServicePage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return ServicePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of ServiceInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of ServiceInstance :rtype: twilio.rest.proxy.v1.service.ServicePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return ServicePage(self._version, response, self._solution) def create(self, friendly_name=values.unset, default_ttl=values.unset, callback_url=values.unset): """ Create a new ServiceInstance :param unicode friendly_name: A human readable description of this resource. :param unicode default_ttl: Default TTL for a Session, in seconds. :param unicode callback_url: URL Twilio will send callbacks to :returns: Newly created ServiceInstance :rtype: twilio.rest.proxy.v1.service.ServiceInstance """ data = values.of({ 'FriendlyName': friendly_name, 'DefaultTtl': default_ttl, 'CallbackUrl': callback_url, }) payload = self._version.create( 'POST', self._uri, data=data, ) return ServiceInstance(self._version, payload,) def get(self, sid): """ Constructs a ServiceContext :param sid: A string that uniquely identifies this Service. :returns: twilio.rest.proxy.v1.service.ServiceContext :rtype: twilio.rest.proxy.v1.service.ServiceContext """ return ServiceContext(self._version, sid=sid,) def __call__(self, sid): """ Constructs a ServiceContext :param sid: A string that uniquely identifies this Service. :returns: twilio.rest.proxy.v1.service.ServiceContext :rtype: twilio.rest.proxy.v1.service.ServiceContext """ return ServiceContext(self._version, sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ServicePage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the ServicePage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.proxy.v1.service.ServicePage :rtype: twilio.rest.proxy.v1.service.ServicePage """ super(ServicePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of ServiceInstance :param dict payload: Payload response from the API :returns: twilio.rest.proxy.v1.service.ServiceInstance :rtype: twilio.rest.proxy.v1.service.ServiceInstance """ return ServiceInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ServiceContext(InstanceContext): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, sid): """ Initialize the ServiceContext :param Version version: Version that contains the resource :param sid: A string that uniquely identifies this Service. :returns: twilio.rest.proxy.v1.service.ServiceContext :rtype: twilio.rest.proxy.v1.service.ServiceContext """ super(ServiceContext, self).__init__(version) # Path Solution self._solution = {'sid': sid,} self._uri = '/Services/{sid}'.format(**self._solution) # Dependents self._sessions = None self._phone_numbers = None self._short_codes = None def fetch(self): """ Fetch a ServiceInstance :returns: Fetched ServiceInstance :rtype: twilio.rest.proxy.v1.service.ServiceInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return ServiceInstance(self._version, payload, sid=self._solution['sid'],) def delete(self): """ Deletes the ServiceInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, friendly_name=values.unset, default_ttl=values.unset, callback_url=values.unset): """ Update the ServiceInstance :param unicode friendly_name: A human readable description of this resource. :param unicode default_ttl: Default TTL for a Session, in seconds. :param unicode callback_url: URL Twilio will send callbacks to :returns: Updated ServiceInstance :rtype: twilio.rest.proxy.v1.service.ServiceInstance """ data = values.of({ 'FriendlyName': friendly_name, 'DefaultTtl': default_ttl, 'CallbackUrl': callback_url, }) payload = self._version.update( 'POST', self._uri, data=data, ) return ServiceInstance(self._version, payload, sid=self._solution['sid'],) @property def sessions(self): """ Access the sessions :returns: twilio.rest.proxy.v1.service.session.SessionList :rtype: twilio.rest.proxy.v1.service.session.SessionList """ if self._sessions is None: self._sessions = SessionList(self._version, service_sid=self._solution['sid'],) return self._sessions @property def phone_numbers(self): """ Access the phone_numbers :returns: twilio.rest.proxy.v1.service.phone_number.PhoneNumberList :rtype: twilio.rest.proxy.v1.service.phone_number.PhoneNumberList """ if self._phone_numbers is None: self._phone_numbers = PhoneNumberList(self._version, service_sid=self._solution['sid'],) return self._phone_numbers @property def short_codes(self): """ Access the short_codes :returns: twilio.rest.proxy.v1.service.short_code.ShortCodeList :rtype: twilio.rest.proxy.v1.service.short_code.ShortCodeList """ if self._short_codes is None: self._short_codes = ShortCodeList(self._version, service_sid=self._solution['sid'],) return self._short_codes def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class ServiceInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, payload, sid=None): """ Initialize the ServiceInstance :returns: twilio.rest.proxy.v1.service.ServiceInstance :rtype: twilio.rest.proxy.v1.service.ServiceInstance """ super(ServiceInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'friendly_name': payload['friendly_name'], 'account_sid': payload['account_sid'], 'callback_url': payload['callback_url'], 'default_ttl': deserialize.integer(payload['default_ttl']), 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'url': payload['url'], 'links': payload['links'], } # Context self._context = None self._solution = {'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.proxy.v1.service.ServiceContext """ if self._context is None: self._context = ServiceContext(self._version, sid=self._solution['sid'],) return self._context @property def sid(self): """ :returns: A string that uniquely identifies this Service. :rtype: unicode """ return self._properties['sid'] @property def friendly_name(self): """ :returns: A human readable description of this resource. :rtype: unicode """ return self._properties['friendly_name'] @property def account_sid(self): """ :returns: Account Sid. :rtype: unicode """ return self._properties['account_sid'] @property def callback_url(self): """ :returns: URL Twilio will send callbacks to :rtype: unicode """ return self._properties['callback_url'] @property def default_ttl(self): """ :returns: Default TTL for a Session, in seconds. :rtype: unicode """ return self._properties['default_ttl'] @property def date_created(self): """ :returns: The date this Service was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this Service was updated :rtype: datetime """ return self._properties['date_updated'] @property def url(self): """ :returns: The URL of this resource. :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: Nested resource URLs. :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a ServiceInstance :returns: Fetched ServiceInstance :rtype: twilio.rest.proxy.v1.service.ServiceInstance """ return self._proxy.fetch() def delete(self): """ Deletes the ServiceInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, friendly_name=values.unset, default_ttl=values.unset, callback_url=values.unset): """ Update the ServiceInstance :param unicode friendly_name: A human readable description of this resource. :param unicode default_ttl: Default TTL for a Session, in seconds. :param unicode callback_url: URL Twilio will send callbacks to :returns: Updated ServiceInstance :rtype: twilio.rest.proxy.v1.service.ServiceInstance """ return self._proxy.update( friendly_name=friendly_name, default_ttl=default_ttl, callback_url=callback_url, ) @property def sessions(self): """ Access the sessions :returns: twilio.rest.proxy.v1.service.session.SessionList :rtype: twilio.rest.proxy.v1.service.session.SessionList """ return self._proxy.sessions @property def phone_numbers(self): """ Access the phone_numbers :returns: twilio.rest.proxy.v1.service.phone_number.PhoneNumberList :rtype: twilio.rest.proxy.v1.service.phone_number.PhoneNumberList """ return self._proxy.phone_numbers @property def short_codes(self): """ Access the short_codes :returns: twilio.rest.proxy.v1.service.short_code.ShortCodeList :rtype: twilio.rest.proxy.v1.service.short_code.ShortCodeList """ return self._proxy.short_codes def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/proxy/v1/service/phone_number.py000066400000000000000000000336551317472742600250740ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class PhoneNumberList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid): """ Initialize the PhoneNumberList :param Version version: Version that contains the resource :param service_sid: Service Sid. :returns: twilio.rest.proxy.v1.service.phone_number.PhoneNumberList :rtype: twilio.rest.proxy.v1.service.phone_number.PhoneNumberList """ super(PhoneNumberList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid,} self._uri = '/Services/{service_sid}/PhoneNumbers'.format(**self._solution) def create(self, sid): """ Create a new PhoneNumberInstance :param unicode sid: A string that uniquely identifies this Phone Number. :returns: Newly created PhoneNumberInstance :rtype: twilio.rest.proxy.v1.service.phone_number.PhoneNumberInstance """ data = values.of({'Sid': sid,}) payload = self._version.create( 'POST', self._uri, data=data, ) return PhoneNumberInstance(self._version, payload, service_sid=self._solution['service_sid'],) def stream(self, limit=None, page_size=None): """ Streams PhoneNumberInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.proxy.v1.service.phone_number.PhoneNumberInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists PhoneNumberInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.proxy.v1.service.phone_number.PhoneNumberInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of PhoneNumberInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of PhoneNumberInstance :rtype: twilio.rest.proxy.v1.service.phone_number.PhoneNumberPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return PhoneNumberPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of PhoneNumberInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of PhoneNumberInstance :rtype: twilio.rest.proxy.v1.service.phone_number.PhoneNumberPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return PhoneNumberPage(self._version, response, self._solution) def get(self, sid): """ Constructs a PhoneNumberContext :param sid: A string that uniquely identifies this Phone Number. :returns: twilio.rest.proxy.v1.service.phone_number.PhoneNumberContext :rtype: twilio.rest.proxy.v1.service.phone_number.PhoneNumberContext """ return PhoneNumberContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __call__(self, sid): """ Constructs a PhoneNumberContext :param sid: A string that uniquely identifies this Phone Number. :returns: twilio.rest.proxy.v1.service.phone_number.PhoneNumberContext :rtype: twilio.rest.proxy.v1.service.phone_number.PhoneNumberContext """ return PhoneNumberContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class PhoneNumberPage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the PhoneNumberPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: Service Sid. :returns: twilio.rest.proxy.v1.service.phone_number.PhoneNumberPage :rtype: twilio.rest.proxy.v1.service.phone_number.PhoneNumberPage """ super(PhoneNumberPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of PhoneNumberInstance :param dict payload: Payload response from the API :returns: twilio.rest.proxy.v1.service.phone_number.PhoneNumberInstance :rtype: twilio.rest.proxy.v1.service.phone_number.PhoneNumberInstance """ return PhoneNumberInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class PhoneNumberContext(InstanceContext): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid, sid): """ Initialize the PhoneNumberContext :param Version version: Version that contains the resource :param service_sid: Service Sid. :param sid: A string that uniquely identifies this Phone Number. :returns: twilio.rest.proxy.v1.service.phone_number.PhoneNumberContext :rtype: twilio.rest.proxy.v1.service.phone_number.PhoneNumberContext """ super(PhoneNumberContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/PhoneNumbers/{sid}'.format(**self._solution) def delete(self): """ Deletes the PhoneNumberInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def fetch(self): """ Fetch a PhoneNumberInstance :returns: Fetched PhoneNumberInstance :rtype: twilio.rest.proxy.v1.service.phone_number.PhoneNumberInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return PhoneNumberInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class PhoneNumberInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, payload, service_sid, sid=None): """ Initialize the PhoneNumberInstance :returns: twilio.rest.proxy.v1.service.phone_number.PhoneNumberInstance :rtype: twilio.rest.proxy.v1.service.phone_number.PhoneNumberInstance """ super(PhoneNumberInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'phone_number': payload['phone_number'], 'friendly_name': payload['friendly_name'], 'iso_country': payload['iso_country'], 'capabilities': payload['capabilities'], 'url': payload['url'], } # Context self._context = None self._solution = {'service_sid': service_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: PhoneNumberContext for this PhoneNumberInstance :rtype: twilio.rest.proxy.v1.service.phone_number.PhoneNumberContext """ if self._context is None: self._context = PhoneNumberContext( self._version, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: A string that uniquely identifies this Phone Number. :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: Account Sid. :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: Service Sid. :rtype: unicode """ return self._properties['service_sid'] @property def date_created(self): """ :returns: The date this Phone Number was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this Phone Number was updated :rtype: datetime """ return self._properties['date_updated'] @property def phone_number(self): """ :returns: The phone number. :rtype: unicode """ return self._properties['phone_number'] @property def friendly_name(self): """ :returns: A human readable description of this resource. :rtype: unicode """ return self._properties['friendly_name'] @property def iso_country(self): """ :returns: ISO Country Code, :rtype: unicode """ return self._properties['iso_country'] @property def capabilities(self): """ :returns: A list of capabilities. :rtype: unicode """ return self._properties['capabilities'] @property def url(self): """ :returns: The URL of this resource. :rtype: unicode """ return self._properties['url'] def delete(self): """ Deletes the PhoneNumberInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def fetch(self): """ Fetch a PhoneNumberInstance :returns: Fetched PhoneNumberInstance :rtype: twilio.rest.proxy.v1.service.phone_number.PhoneNumberInstance """ return self._proxy.fetch() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/proxy/v1/service/session/000077500000000000000000000000001317472742600235105ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/proxy/v1/service/session/__init__.py000066400000000000000000000507231317472742600256300ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize 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.page import Page from twilio.rest.proxy.v1.service.session.interaction import InteractionList from twilio.rest.proxy.v1.service.session.participant import ParticipantList class SessionList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid): """ Initialize the SessionList :param Version version: Version that contains the resource :param service_sid: Service Sid. :returns: twilio.rest.proxy.v1.service.session.SessionList :rtype: twilio.rest.proxy.v1.service.session.SessionList """ super(SessionList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid,} self._uri = '/Services/{service_sid}/Sessions'.format(**self._solution) def stream(self, unique_name=values.unset, status=values.unset, limit=None, page_size=None): """ 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 unicode unique_name: A unique, developer assigned name of this Session. :param SessionInstance.Status status: The Status of this Session :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.proxy.v1.service.session.SessionInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(unique_name=unique_name, status=status, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, unique_name=values.unset, status=values.unset, limit=None, page_size=None): """ 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 unicode unique_name: A unique, developer assigned name of this Session. :param SessionInstance.Status status: The Status of this Session :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.proxy.v1.service.session.SessionInstance] """ return list(self.stream(unique_name=unique_name, status=status, limit=limit, page_size=page_size,)) def page(self, unique_name=values.unset, status=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of SessionInstance records from the API. Request is executed immediately :param unicode unique_name: A unique, developer assigned name of this Session. :param SessionInstance.Status status: The Status of this Session :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of SessionInstance :rtype: twilio.rest.proxy.v1.service.session.SessionPage """ params = values.of({ 'UniqueName': unique_name, 'Status': status, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return SessionPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of SessionInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of SessionInstance :rtype: twilio.rest.proxy.v1.service.session.SessionPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return SessionPage(self._version, response, self._solution) def create(self, unique_name=values.unset, date_expiry=values.unset, ttl=values.unset, status=values.unset, participants=values.unset): """ Create a new SessionInstance :param unicode unique_name: A unique, developer assigned name of this Session. :param datetime date_expiry: The date this Session was expiry :param unicode ttl: TTL for a Session, in seconds. :param SessionInstance.Status status: The Status of this Session :param unicode participants: A list of phone numbers to add to this Session. :returns: Newly created SessionInstance :rtype: twilio.rest.proxy.v1.service.session.SessionInstance """ data = values.of({ 'UniqueName': unique_name, 'DateExpiry': serialize.iso8601_datetime(date_expiry), 'Ttl': ttl, 'Status': status, 'Participants': participants, }) payload = self._version.create( 'POST', self._uri, data=data, ) return SessionInstance(self._version, payload, service_sid=self._solution['service_sid'],) def get(self, sid): """ Constructs a SessionContext :param sid: A string that uniquely identifies this Session. :returns: twilio.rest.proxy.v1.service.session.SessionContext :rtype: twilio.rest.proxy.v1.service.session.SessionContext """ return SessionContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __call__(self, sid): """ Constructs a SessionContext :param sid: A string that uniquely identifies this Session. :returns: twilio.rest.proxy.v1.service.session.SessionContext :rtype: twilio.rest.proxy.v1.service.session.SessionContext """ return SessionContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SessionPage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the SessionPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: Service Sid. :returns: twilio.rest.proxy.v1.service.session.SessionPage :rtype: twilio.rest.proxy.v1.service.session.SessionPage """ super(SessionPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of SessionInstance :param dict payload: Payload response from the API :returns: twilio.rest.proxy.v1.service.session.SessionInstance :rtype: twilio.rest.proxy.v1.service.session.SessionInstance """ return SessionInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SessionContext(InstanceContext): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid, sid): """ Initialize the SessionContext :param Version version: Version that contains the resource :param service_sid: Service Sid. :param sid: A string that uniquely identifies this Session. :returns: twilio.rest.proxy.v1.service.session.SessionContext :rtype: twilio.rest.proxy.v1.service.session.SessionContext """ super(SessionContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Sessions/{sid}'.format(**self._solution) # Dependents self._interactions = None self._participants = None def fetch(self): """ Fetch a SessionInstance :returns: Fetched SessionInstance :rtype: twilio.rest.proxy.v1.service.session.SessionInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return SessionInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the SessionInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, unique_name=values.unset, date_expiry=values.unset, ttl=values.unset, status=values.unset, participants=values.unset): """ Update the SessionInstance :param unicode unique_name: A unique, developer assigned name of this Session. :param datetime date_expiry: The date this Session was expiry :param unicode ttl: TTL for a Session, in seconds. :param SessionInstance.Status status: The Status of this Session :param unicode participants: A list of phone numbers to add to this Session. :returns: Updated SessionInstance :rtype: twilio.rest.proxy.v1.service.session.SessionInstance """ data = values.of({ 'UniqueName': unique_name, 'DateExpiry': serialize.iso8601_datetime(date_expiry), 'Ttl': ttl, 'Status': status, 'Participants': participants, }) payload = self._version.update( 'POST', self._uri, data=data, ) return SessionInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) @property def interactions(self): """ Access the interactions :returns: twilio.rest.proxy.v1.service.session.interaction.InteractionList :rtype: twilio.rest.proxy.v1.service.session.interaction.InteractionList """ if self._interactions is None: self._interactions = InteractionList( self._version, service_sid=self._solution['service_sid'], session_sid=self._solution['sid'], ) return self._interactions @property def participants(self): """ Access the participants :returns: twilio.rest.proxy.v1.service.session.participant.ParticipantList :rtype: twilio.rest.proxy.v1.service.session.participant.ParticipantList """ if self._participants is None: self._participants = ParticipantList( self._version, service_sid=self._solution['service_sid'], session_sid=self._solution['sid'], ) return self._participants def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class SessionInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ class Status(object): IN_PROGESS = "in-progess" CLOSED = "closed" FAILED = "failed" UNKNOWN = "unknown" COMPLETED = "completed" def __init__(self, version, payload, service_sid, sid=None): """ Initialize the SessionInstance :returns: twilio.rest.proxy.v1.service.session.SessionInstance :rtype: twilio.rest.proxy.v1.service.session.SessionInstance """ super(SessionInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'service_sid': payload['service_sid'], 'account_sid': payload['account_sid'], 'date_started': deserialize.iso8601_datetime(payload['date_started']), 'date_ended': deserialize.iso8601_datetime(payload['date_ended']), 'date_last_interaction': deserialize.iso8601_datetime(payload['date_last_interaction']), 'date_expiry': deserialize.iso8601_datetime(payload['date_expiry']), 'unique_name': payload['unique_name'], 'status': payload['status'], 'closed_reason': payload['closed_reason'], 'ttl': deserialize.integer(payload['ttl']), 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'url': payload['url'], 'links': payload['links'], } # Context self._context = None self._solution = {'service_sid': service_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.proxy.v1.service.session.SessionContext """ if self._context is None: self._context = SessionContext( self._version, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: A string that uniquely identifies this Session. :rtype: unicode """ return self._properties['sid'] @property def service_sid(self): """ :returns: Service Sid. :rtype: unicode """ return self._properties['service_sid'] @property def account_sid(self): """ :returns: Account Sid. :rtype: unicode """ return self._properties['account_sid'] @property def date_started(self): """ :returns: The date this Session was started :rtype: datetime """ return self._properties['date_started'] @property def date_ended(self): """ :returns: The date this Session was ended :rtype: datetime """ return self._properties['date_ended'] @property def date_last_interaction(self): """ :returns: The date this Session was interaction :rtype: datetime """ return self._properties['date_last_interaction'] @property def date_expiry(self): """ :returns: The date this Session was expiry :rtype: datetime """ return self._properties['date_expiry'] @property def unique_name(self): """ :returns: A unique, developer assigned name of this Session. :rtype: unicode """ return self._properties['unique_name'] @property def status(self): """ :returns: The Status of this Session :rtype: SessionInstance.Status """ return self._properties['status'] @property def closed_reason(self): """ :returns: Reason Session ended. :rtype: unicode """ return self._properties['closed_reason'] @property def ttl(self): """ :returns: TTL for a Session, in seconds. :rtype: unicode """ return self._properties['ttl'] @property def date_created(self): """ :returns: The date this Session was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this Session was updated :rtype: datetime """ return self._properties['date_updated'] @property def url(self): """ :returns: The URL of this resource. :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: Nested resource URLs. :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a SessionInstance :returns: Fetched SessionInstance :rtype: twilio.rest.proxy.v1.service.session.SessionInstance """ return self._proxy.fetch() def delete(self): """ Deletes the SessionInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, unique_name=values.unset, date_expiry=values.unset, ttl=values.unset, status=values.unset, participants=values.unset): """ Update the SessionInstance :param unicode unique_name: A unique, developer assigned name of this Session. :param datetime date_expiry: The date this Session was expiry :param unicode ttl: TTL for a Session, in seconds. :param SessionInstance.Status status: The Status of this Session :param unicode participants: A list of phone numbers to add to this Session. :returns: Updated SessionInstance :rtype: twilio.rest.proxy.v1.service.session.SessionInstance """ return self._proxy.update( unique_name=unique_name, date_expiry=date_expiry, ttl=ttl, status=status, participants=participants, ) @property def interactions(self): """ Access the interactions :returns: twilio.rest.proxy.v1.service.session.interaction.InteractionList :rtype: twilio.rest.proxy.v1.service.session.interaction.InteractionList """ return self._proxy.interactions @property def participants(self): """ Access the participants :returns: twilio.rest.proxy.v1.service.session.participant.ParticipantList :rtype: twilio.rest.proxy.v1.service.session.participant.ParticipantList """ return self._proxy.participants def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/proxy/v1/service/session/interaction.py000066400000000000000000000453161317472742600264120ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class InteractionList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid, session_sid): """ Initialize the InteractionList :param Version version: Version that contains the resource :param service_sid: Service Sid. :param session_sid: Session Sid. :returns: twilio.rest.proxy.v1.service.session.interaction.InteractionList :rtype: twilio.rest.proxy.v1.service.session.interaction.InteractionList """ super(InteractionList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'session_sid': session_sid,} self._uri = '/Services/{service_sid}/Sessions/{session_sid}/Interactions'.format(**self._solution) def stream(self, inbound_participant_status=values.unset, outbound_participant_status=values.unset, limit=None, page_size=None): """ Streams InteractionInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param InteractionInstance.ResourceStatus inbound_participant_status: The Inbound Participant Status of this Interaction :param InteractionInstance.ResourceStatus outbound_participant_status: The Outbound Participant Status of this Interaction :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.proxy.v1.service.session.interaction.InteractionInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( inbound_participant_status=inbound_participant_status, outbound_participant_status=outbound_participant_status, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, inbound_participant_status=values.unset, outbound_participant_status=values.unset, limit=None, page_size=None): """ Lists InteractionInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param InteractionInstance.ResourceStatus inbound_participant_status: The Inbound Participant Status of this Interaction :param InteractionInstance.ResourceStatus outbound_participant_status: The Outbound Participant Status of this Interaction :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.proxy.v1.service.session.interaction.InteractionInstance] """ return list(self.stream( inbound_participant_status=inbound_participant_status, outbound_participant_status=outbound_participant_status, limit=limit, page_size=page_size, )) def page(self, inbound_participant_status=values.unset, outbound_participant_status=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of InteractionInstance records from the API. Request is executed immediately :param InteractionInstance.ResourceStatus inbound_participant_status: The Inbound Participant Status of this Interaction :param InteractionInstance.ResourceStatus outbound_participant_status: The Outbound Participant Status of this Interaction :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of InteractionInstance :rtype: twilio.rest.proxy.v1.service.session.interaction.InteractionPage """ params = values.of({ 'InboundParticipantStatus': inbound_participant_status, 'OutboundParticipantStatus': outbound_participant_status, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return InteractionPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of InteractionInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of InteractionInstance :rtype: twilio.rest.proxy.v1.service.session.interaction.InteractionPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return InteractionPage(self._version, response, self._solution) def get(self, sid): """ Constructs a InteractionContext :param sid: A string that uniquely identifies this Interaction. :returns: twilio.rest.proxy.v1.service.session.interaction.InteractionContext :rtype: twilio.rest.proxy.v1.service.session.interaction.InteractionContext """ return InteractionContext( self._version, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a InteractionContext :param sid: A string that uniquely identifies this Interaction. :returns: twilio.rest.proxy.v1.service.session.interaction.InteractionContext :rtype: twilio.rest.proxy.v1.service.session.interaction.InteractionContext """ return InteractionContext( self._version, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class InteractionPage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the InteractionPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: Service Sid. :param session_sid: Session Sid. :returns: twilio.rest.proxy.v1.service.session.interaction.InteractionPage :rtype: twilio.rest.proxy.v1.service.session.interaction.InteractionPage """ super(InteractionPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of InteractionInstance :param dict payload: Payload response from the API :returns: twilio.rest.proxy.v1.service.session.interaction.InteractionInstance :rtype: twilio.rest.proxy.v1.service.session.interaction.InteractionInstance """ return InteractionInstance( self._version, payload, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class InteractionContext(InstanceContext): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid, session_sid, sid): """ Initialize the InteractionContext :param Version version: Version that contains the resource :param service_sid: Service Sid. :param session_sid: Session Sid. :param sid: A string that uniquely identifies this Interaction. :returns: twilio.rest.proxy.v1.service.session.interaction.InteractionContext :rtype: twilio.rest.proxy.v1.service.session.interaction.InteractionContext """ super(InteractionContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'session_sid': session_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Sessions/{session_sid}/Interactions/{sid}'.format(**self._solution) def fetch(self): """ Fetch a InteractionInstance :returns: Fetched InteractionInstance :rtype: twilio.rest.proxy.v1.service.session.interaction.InteractionInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return InteractionInstance( self._version, payload, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class InteractionInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ class Type(object): MESSAGE = "message" VOICE = "voice" UNKNOWN = "unknown" class ResourceStatus(object): ACCEPTED = "accepted" ANSWERED = "answered" BUSY = "busy" CANCELED = "canceled" COMPLETED = "completed" DELETED = "deleted" DELIVERED = "delivered" DELIVERY_UNKNOWN = "delivery-unknown" FAILED = "failed" IN_PROGRESS = "in-progress" INITIATED = "initiated" NO_ANSWER = "no-answer" QUEUED = "queued" RECEIVED = "received" RECEIVING = "receiving" RINGING = "ringing" SCHEDULED = "scheduled" SENDING = "sending" SENT = "sent" UNDELIVERED = "undelivered" UNKNOWN = "unknown" def __init__(self, version, payload, service_sid, session_sid, sid=None): """ Initialize the InteractionInstance :returns: twilio.rest.proxy.v1.service.session.interaction.InteractionInstance :rtype: twilio.rest.proxy.v1.service.session.interaction.InteractionInstance """ super(InteractionInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'session_sid': payload['session_sid'], 'service_sid': payload['service_sid'], 'account_sid': payload['account_sid'], 'data': payload['data'], 'type': payload['type'], 'inbound_participant_sid': payload['inbound_participant_sid'], 'inbound_resource_sid': payload['inbound_resource_sid'], 'inbound_resource_status': payload['inbound_resource_status'], 'inbound_resource_type': payload['inbound_resource_type'], 'inbound_resource_url': payload['inbound_resource_url'], 'outbound_participant_sid': payload['outbound_participant_sid'], 'outbound_resource_sid': payload['outbound_resource_sid'], 'outbound_resource_status': payload['outbound_resource_status'], 'outbound_resource_type': payload['outbound_resource_type'], 'outbound_resource_url': payload['outbound_resource_url'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'url': payload['url'], } # Context self._context = None self._solution = { 'service_sid': service_sid, 'session_sid': session_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: InteractionContext for this InteractionInstance :rtype: twilio.rest.proxy.v1.service.session.interaction.InteractionContext """ if self._context is None: self._context = InteractionContext( self._version, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: A string that uniquely identifies this Interaction. :rtype: unicode """ return self._properties['sid'] @property def session_sid(self): """ :returns: Session Sid. :rtype: unicode """ return self._properties['session_sid'] @property def service_sid(self): """ :returns: Service Sid. :rtype: unicode """ return self._properties['service_sid'] @property def account_sid(self): """ :returns: Account Sid. :rtype: unicode """ return self._properties['account_sid'] @property def data(self): """ :returns: Further details about an interaction. :rtype: unicode """ return self._properties['data'] @property def type(self): """ :returns: The Type of this Interaction :rtype: InteractionInstance.Type """ return self._properties['type'] @property def inbound_participant_sid(self): """ :returns: Inbound Participant Sid. :rtype: unicode """ return self._properties['inbound_participant_sid'] @property def inbound_resource_sid(self): """ :returns: Inbound Resource Sid. :rtype: unicode """ return self._properties['inbound_resource_sid'] @property def inbound_resource_status(self): """ :returns: The Inbound Resource Status of this Interaction :rtype: InteractionInstance.ResourceStatus """ return self._properties['inbound_resource_status'] @property def inbound_resource_type(self): """ :returns: The type of the Inbound Resource, Call or Message. :rtype: unicode """ return self._properties['inbound_resource_type'] @property def inbound_resource_url(self): """ :returns: The URL of the Twilio resource. :rtype: unicode """ return self._properties['inbound_resource_url'] @property def outbound_participant_sid(self): """ :returns: Outbound Participant Sid. :rtype: unicode """ return self._properties['outbound_participant_sid'] @property def outbound_resource_sid(self): """ :returns: Outbound Resource Sid. :rtype: unicode """ return self._properties['outbound_resource_sid'] @property def outbound_resource_status(self): """ :returns: The Outbound Resource Status of this Interaction :rtype: InteractionInstance.ResourceStatus """ return self._properties['outbound_resource_status'] @property def outbound_resource_type(self): """ :returns: The type of the Outbound Resource, Call or Message. :rtype: unicode """ return self._properties['outbound_resource_type'] @property def outbound_resource_url(self): """ :returns: The URL of the Twilio resource. :rtype: unicode """ return self._properties['outbound_resource_url'] @property def date_created(self): """ :returns: The date this Interaction was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this Interaction was updated :rtype: datetime """ return self._properties['date_updated'] @property def url(self): """ :returns: The URL of this resource. :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a InteractionInstance :returns: Fetched InteractionInstance :rtype: twilio.rest.proxy.v1.service.session.interaction.InteractionInstance """ return self._proxy.fetch() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/proxy/v1/service/session/participant/000077500000000000000000000000001317472742600260265ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/proxy/v1/service/session/participant/__init__.py000066400000000000000000000530001317472742600301350ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.proxy.v1.service.session.participant.message_interaction import MessageInteractionList class ParticipantList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid, session_sid): """ Initialize the ParticipantList :param Version version: Version that contains the resource :param service_sid: Service Sid. :param session_sid: Session Sid. :returns: twilio.rest.proxy.v1.service.session.participant.ParticipantList :rtype: twilio.rest.proxy.v1.service.session.participant.ParticipantList """ super(ParticipantList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'session_sid': session_sid,} self._uri = '/Services/{service_sid}/Sessions/{session_sid}/Participants'.format(**self._solution) def stream(self, participant_type=values.unset, identifier=values.unset, limit=None, page_size=None): """ Streams ParticipantInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param ParticipantInstance.ParticipantType participant_type: The participant_type :param unicode identifier: The identifier :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.proxy.v1.service.session.participant.ParticipantInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( participant_type=participant_type, identifier=identifier, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, participant_type=values.unset, identifier=values.unset, limit=None, page_size=None): """ Lists ParticipantInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param ParticipantInstance.ParticipantType participant_type: The participant_type :param unicode identifier: The identifier :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.proxy.v1.service.session.participant.ParticipantInstance] """ return list(self.stream( participant_type=participant_type, identifier=identifier, limit=limit, page_size=page_size, )) def page(self, participant_type=values.unset, identifier=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of ParticipantInstance records from the API. Request is executed immediately :param ParticipantInstance.ParticipantType participant_type: The participant_type :param unicode identifier: The identifier :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of ParticipantInstance :rtype: twilio.rest.proxy.v1.service.session.participant.ParticipantPage """ params = values.of({ 'ParticipantType': participant_type, 'Identifier': identifier, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return ParticipantPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of ParticipantInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of ParticipantInstance :rtype: twilio.rest.proxy.v1.service.session.participant.ParticipantPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return ParticipantPage(self._version, response, self._solution) def create(self, identifier, friendly_name=values.unset, participant_type=values.unset, proxy_identifier=values.unset, proxy_identifier_sid=values.unset): """ Create a new ParticipantInstance :param unicode identifier: The phone number of this Participant. :param unicode friendly_name: A human readable description of this resource. :param ParticipantInstance.ParticipantType participant_type: The Participant Type of this Participant :param unicode proxy_identifier: The proxy phone number for this Participant. :param unicode proxy_identifier_sid: Proxy Identifier Sid. :returns: Newly created ParticipantInstance :rtype: twilio.rest.proxy.v1.service.session.participant.ParticipantInstance """ data = values.of({ 'Identifier': identifier, 'FriendlyName': friendly_name, 'ParticipantType': participant_type, 'ProxyIdentifier': proxy_identifier, 'ProxyIdentifierSid': proxy_identifier_sid, }) payload = self._version.create( 'POST', self._uri, data=data, ) return ParticipantInstance( self._version, payload, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], ) def get(self, sid): """ Constructs a ParticipantContext :param sid: A string that uniquely identifies this Participant. :returns: twilio.rest.proxy.v1.service.session.participant.ParticipantContext :rtype: twilio.rest.proxy.v1.service.session.participant.ParticipantContext """ return ParticipantContext( self._version, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a ParticipantContext :param sid: A string that uniquely identifies this Participant. :returns: twilio.rest.proxy.v1.service.session.participant.ParticipantContext :rtype: twilio.rest.proxy.v1.service.session.participant.ParticipantContext """ return ParticipantContext( self._version, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ParticipantPage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the ParticipantPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: Service Sid. :param session_sid: Session Sid. :returns: twilio.rest.proxy.v1.service.session.participant.ParticipantPage :rtype: twilio.rest.proxy.v1.service.session.participant.ParticipantPage """ super(ParticipantPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of ParticipantInstance :param dict payload: Payload response from the API :returns: twilio.rest.proxy.v1.service.session.participant.ParticipantInstance :rtype: twilio.rest.proxy.v1.service.session.participant.ParticipantInstance """ return ParticipantInstance( self._version, payload, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ParticipantContext(InstanceContext): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid, session_sid, sid): """ Initialize the ParticipantContext :param Version version: Version that contains the resource :param service_sid: Service Sid. :param session_sid: Session Sid. :param sid: A string that uniquely identifies this Participant. :returns: twilio.rest.proxy.v1.service.session.participant.ParticipantContext :rtype: twilio.rest.proxy.v1.service.session.participant.ParticipantContext """ super(ParticipantContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'session_sid': session_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Sessions/{session_sid}/Participants/{sid}'.format(**self._solution) # Dependents self._message_interactions = None def fetch(self): """ Fetch a ParticipantInstance :returns: Fetched ParticipantInstance :rtype: twilio.rest.proxy.v1.service.session.participant.ParticipantInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return ParticipantInstance( self._version, payload, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the ParticipantInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, participant_type=values.unset, identifier=values.unset, friendly_name=values.unset, proxy_identifier=values.unset, proxy_identifier_sid=values.unset): """ Update the ParticipantInstance :param ParticipantInstance.ParticipantType participant_type: The Participant Type of this Participant :param unicode identifier: The phone number of this Participant. :param unicode friendly_name: A human readable description of this resource. :param unicode proxy_identifier: The proxy phone number for this Participant. :param unicode proxy_identifier_sid: Proxy Identifier Sid. :returns: Updated ParticipantInstance :rtype: twilio.rest.proxy.v1.service.session.participant.ParticipantInstance """ data = values.of({ 'ParticipantType': participant_type, 'Identifier': identifier, 'FriendlyName': friendly_name, 'ProxyIdentifier': proxy_identifier, 'ProxyIdentifierSid': proxy_identifier_sid, }) payload = self._version.update( 'POST', self._uri, data=data, ) return ParticipantInstance( self._version, payload, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], sid=self._solution['sid'], ) @property def message_interactions(self): """ Access the message_interactions :returns: twilio.rest.proxy.v1.service.session.participant.message_interaction.MessageInteractionList :rtype: twilio.rest.proxy.v1.service.session.participant.message_interaction.MessageInteractionList """ if self._message_interactions is None: self._message_interactions = MessageInteractionList( self._version, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], participant_sid=self._solution['sid'], ) return self._message_interactions def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class ParticipantInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ class ParticipantType(object): MESSAGE_ONLY = "message-only" VOICE_ONLY = "voice-only" VOICE_AND_MESSAGE = "voice-and-message" def __init__(self, version, payload, service_sid, session_sid, sid=None): """ Initialize the ParticipantInstance :returns: twilio.rest.proxy.v1.service.session.participant.ParticipantInstance :rtype: twilio.rest.proxy.v1.service.session.participant.ParticipantInstance """ super(ParticipantInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'session_sid': payload['session_sid'], 'service_sid': payload['service_sid'], 'account_sid': payload['account_sid'], 'friendly_name': payload['friendly_name'], 'participant_type': payload['participant_type'], 'identifier': payload['identifier'], 'proxy_identifier': payload['proxy_identifier'], 'proxy_identifier_sid': payload['proxy_identifier_sid'], 'date_deleted': deserialize.iso8601_datetime(payload['date_deleted']), 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'url': payload['url'], 'links': payload['links'], } # Context self._context = None self._solution = { 'service_sid': service_sid, 'session_sid': session_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: ParticipantContext for this ParticipantInstance :rtype: twilio.rest.proxy.v1.service.session.participant.ParticipantContext """ if self._context is None: self._context = ParticipantContext( self._version, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: A string that uniquely identifies this Participant. :rtype: unicode """ return self._properties['sid'] @property def session_sid(self): """ :returns: Session Sid. :rtype: unicode """ return self._properties['session_sid'] @property def service_sid(self): """ :returns: Service Sid. :rtype: unicode """ return self._properties['service_sid'] @property def account_sid(self): """ :returns: Account Sid. :rtype: unicode """ return self._properties['account_sid'] @property def friendly_name(self): """ :returns: A human readable description of this resource. :rtype: unicode """ return self._properties['friendly_name'] @property def participant_type(self): """ :returns: The Participant Type of this Participant :rtype: ParticipantInstance.ParticipantType """ return self._properties['participant_type'] @property def identifier(self): """ :returns: The phone number of this Participant. :rtype: unicode """ return self._properties['identifier'] @property def proxy_identifier(self): """ :returns: The proxy phone number for this Participant. :rtype: unicode """ return self._properties['proxy_identifier'] @property def proxy_identifier_sid(self): """ :returns: Proxy Identifier Sid. :rtype: unicode """ return self._properties['proxy_identifier_sid'] @property def date_deleted(self): """ :returns: The date this Participant was deleted :rtype: datetime """ return self._properties['date_deleted'] @property def date_created(self): """ :returns: The date this Participant was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this Participant was updated :rtype: datetime """ return self._properties['date_updated'] @property def url(self): """ :returns: The URL of this resource. :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: Nested resource URLs. :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a ParticipantInstance :returns: Fetched ParticipantInstance :rtype: twilio.rest.proxy.v1.service.session.participant.ParticipantInstance """ return self._proxy.fetch() def delete(self): """ Deletes the ParticipantInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, participant_type=values.unset, identifier=values.unset, friendly_name=values.unset, proxy_identifier=values.unset, proxy_identifier_sid=values.unset): """ Update the ParticipantInstance :param ParticipantInstance.ParticipantType participant_type: The Participant Type of this Participant :param unicode identifier: The phone number of this Participant. :param unicode friendly_name: A human readable description of this resource. :param unicode proxy_identifier: The proxy phone number for this Participant. :param unicode proxy_identifier_sid: Proxy Identifier Sid. :returns: Updated ParticipantInstance :rtype: twilio.rest.proxy.v1.service.session.participant.ParticipantInstance """ return self._proxy.update( participant_type=participant_type, identifier=identifier, friendly_name=friendly_name, proxy_identifier=proxy_identifier, proxy_identifier_sid=proxy_identifier_sid, ) @property def message_interactions(self): """ Access the message_interactions :returns: twilio.rest.proxy.v1.service.session.participant.message_interaction.MessageInteractionList :rtype: twilio.rest.proxy.v1.service.session.participant.message_interaction.MessageInteractionList """ return self._proxy.message_interactions def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/proxy/v1/service/session/participant/message_interaction.py000066400000000000000000000476661317472742600324460ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class MessageInteractionList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid, session_sid, participant_sid): """ Initialize the MessageInteractionList :param Version version: Version that contains the resource :param service_sid: Service Sid. :param session_sid: Session Sid. :param participant_sid: Participant Sid. :returns: twilio.rest.proxy.v1.service.session.participant.message_interaction.MessageInteractionList :rtype: twilio.rest.proxy.v1.service.session.participant.message_interaction.MessageInteractionList """ super(MessageInteractionList, self).__init__(version) # Path Solution self._solution = { 'service_sid': service_sid, 'session_sid': session_sid, 'participant_sid': participant_sid, } self._uri = '/Services/{service_sid}/Sessions/{session_sid}/Participants/{participant_sid}/MessageInteractions'.format(**self._solution) def create(self, body=values.unset, media_url=values.unset): """ Create a new MessageInteractionInstance :param unicode body: The body :param unicode media_url: The media_url :returns: Newly created MessageInteractionInstance :rtype: twilio.rest.proxy.v1.service.session.participant.message_interaction.MessageInteractionInstance """ data = values.of({'Body': body, 'MediaUrl': media_url,}) payload = self._version.create( 'POST', self._uri, data=data, ) return MessageInteractionInstance( self._version, payload, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], participant_sid=self._solution['participant_sid'], ) def stream(self, limit=None, page_size=None): """ Streams MessageInteractionInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.proxy.v1.service.session.participant.message_interaction.MessageInteractionInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists MessageInteractionInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.proxy.v1.service.session.participant.message_interaction.MessageInteractionInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of MessageInteractionInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of MessageInteractionInstance :rtype: twilio.rest.proxy.v1.service.session.participant.message_interaction.MessageInteractionPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return MessageInteractionPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of MessageInteractionInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of MessageInteractionInstance :rtype: twilio.rest.proxy.v1.service.session.participant.message_interaction.MessageInteractionPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return MessageInteractionPage(self._version, response, self._solution) def get(self, sid): """ Constructs a MessageInteractionContext :param sid: A string that uniquely identifies this Message Interaction. :returns: twilio.rest.proxy.v1.service.session.participant.message_interaction.MessageInteractionContext :rtype: twilio.rest.proxy.v1.service.session.participant.message_interaction.MessageInteractionContext """ return MessageInteractionContext( self._version, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], participant_sid=self._solution['participant_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a MessageInteractionContext :param sid: A string that uniquely identifies this Message Interaction. :returns: twilio.rest.proxy.v1.service.session.participant.message_interaction.MessageInteractionContext :rtype: twilio.rest.proxy.v1.service.session.participant.message_interaction.MessageInteractionContext """ return MessageInteractionContext( self._version, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], participant_sid=self._solution['participant_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class MessageInteractionPage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the MessageInteractionPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: Service Sid. :param session_sid: Session Sid. :param participant_sid: Participant Sid. :returns: twilio.rest.proxy.v1.service.session.participant.message_interaction.MessageInteractionPage :rtype: twilio.rest.proxy.v1.service.session.participant.message_interaction.MessageInteractionPage """ super(MessageInteractionPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of MessageInteractionInstance :param dict payload: Payload response from the API :returns: twilio.rest.proxy.v1.service.session.participant.message_interaction.MessageInteractionInstance :rtype: twilio.rest.proxy.v1.service.session.participant.message_interaction.MessageInteractionInstance """ return MessageInteractionInstance( self._version, payload, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], participant_sid=self._solution['participant_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class MessageInteractionContext(InstanceContext): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid, session_sid, participant_sid, sid): """ Initialize the MessageInteractionContext :param Version version: Version that contains the resource :param service_sid: Service Sid. :param session_sid: Session Sid. :param participant_sid: Participant Sid. :param sid: A string that uniquely identifies this Message Interaction. :returns: twilio.rest.proxy.v1.service.session.participant.message_interaction.MessageInteractionContext :rtype: twilio.rest.proxy.v1.service.session.participant.message_interaction.MessageInteractionContext """ super(MessageInteractionContext, self).__init__(version) # Path Solution self._solution = { 'service_sid': service_sid, 'session_sid': session_sid, 'participant_sid': participant_sid, 'sid': sid, } self._uri = '/Services/{service_sid}/Sessions/{session_sid}/Participants/{participant_sid}/MessageInteractions/{sid}'.format(**self._solution) def fetch(self): """ Fetch a MessageInteractionInstance :returns: Fetched MessageInteractionInstance :rtype: twilio.rest.proxy.v1.service.session.participant.message_interaction.MessageInteractionInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return MessageInteractionInstance( self._version, payload, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], participant_sid=self._solution['participant_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class MessageInteractionInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ class Type(object): MESSAGE = "message" VOICE = "voice" UNKNOWN = "unknown" class ResourceStatus(object): ACCEPTED = "accepted" ANSWERED = "answered" BUSY = "busy" CANCELED = "canceled" COMPLETED = "completed" DELETED = "deleted" DELIVERED = "delivered" DELIVERY_UNKNOWN = "delivery-unknown" FAILED = "failed" IN_PROGRESS = "in-progress" INITIATED = "initiated" NO_ANSWER = "no-answer" QUEUED = "queued" RECEIVED = "received" RECEIVING = "receiving" RINGING = "ringing" SCHEDULED = "scheduled" SENDING = "sending" SENT = "sent" UNDELIVERED = "undelivered" UNKNOWN = "unknown" def __init__(self, version, payload, service_sid, session_sid, participant_sid, sid=None): """ Initialize the MessageInteractionInstance :returns: twilio.rest.proxy.v1.service.session.participant.message_interaction.MessageInteractionInstance :rtype: twilio.rest.proxy.v1.service.session.participant.message_interaction.MessageInteractionInstance """ super(MessageInteractionInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'session_sid': payload['session_sid'], 'service_sid': payload['service_sid'], 'account_sid': payload['account_sid'], 'data': payload['data'], 'type': payload['type'], 'participant_sid': payload['participant_sid'], 'inbound_participant_sid': payload['inbound_participant_sid'], 'inbound_resource_sid': payload['inbound_resource_sid'], 'inbound_resource_status': payload['inbound_resource_status'], 'inbound_resource_type': payload['inbound_resource_type'], 'inbound_resource_url': payload['inbound_resource_url'], 'outbound_participant_sid': payload['outbound_participant_sid'], 'outbound_resource_sid': payload['outbound_resource_sid'], 'outbound_resource_status': payload['outbound_resource_status'], 'outbound_resource_type': payload['outbound_resource_type'], 'outbound_resource_url': payload['outbound_resource_url'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'url': payload['url'], } # Context self._context = None self._solution = { 'service_sid': service_sid, 'session_sid': session_sid, 'participant_sid': participant_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: MessageInteractionContext for this MessageInteractionInstance :rtype: twilio.rest.proxy.v1.service.session.participant.message_interaction.MessageInteractionContext """ if self._context is None: self._context = MessageInteractionContext( self._version, service_sid=self._solution['service_sid'], session_sid=self._solution['session_sid'], participant_sid=self._solution['participant_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: A string that uniquely identifies this Message Interaction. :rtype: unicode """ return self._properties['sid'] @property def session_sid(self): """ :returns: Session Sid. :rtype: unicode """ return self._properties['session_sid'] @property def service_sid(self): """ :returns: Service Sid. :rtype: unicode """ return self._properties['service_sid'] @property def account_sid(self): """ :returns: Account Sid. :rtype: unicode """ return self._properties['account_sid'] @property def data(self): """ :returns: Further details about an interaction. :rtype: unicode """ return self._properties['data'] @property def type(self): """ :returns: The Type of this Message Interaction :rtype: MessageInteractionInstance.Type """ return self._properties['type'] @property def participant_sid(self): """ :returns: Participant Sid. :rtype: unicode """ return self._properties['participant_sid'] @property def inbound_participant_sid(self): """ :returns: Inbound Participant Sid. :rtype: unicode """ return self._properties['inbound_participant_sid'] @property def inbound_resource_sid(self): """ :returns: Inbound Resource Sid. :rtype: unicode """ return self._properties['inbound_resource_sid'] @property def inbound_resource_status(self): """ :returns: The Inbound Resource Status of this Message Interaction :rtype: MessageInteractionInstance.ResourceStatus """ return self._properties['inbound_resource_status'] @property def inbound_resource_type(self): """ :returns: The type of the Inbound Resource, Call or Message. :rtype: unicode """ return self._properties['inbound_resource_type'] @property def inbound_resource_url(self): """ :returns: The URL of the Twilio resource. :rtype: unicode """ return self._properties['inbound_resource_url'] @property def outbound_participant_sid(self): """ :returns: Outbound Participant Sid. :rtype: unicode """ return self._properties['outbound_participant_sid'] @property def outbound_resource_sid(self): """ :returns: Outbound Resource Sid. :rtype: unicode """ return self._properties['outbound_resource_sid'] @property def outbound_resource_status(self): """ :returns: The Outbound Resource Status of this Message Interaction :rtype: MessageInteractionInstance.ResourceStatus """ return self._properties['outbound_resource_status'] @property def outbound_resource_type(self): """ :returns: The type of the Outbound Resource, Call or Message. :rtype: unicode """ return self._properties['outbound_resource_type'] @property def outbound_resource_url(self): """ :returns: The URL of the Twilio resource. :rtype: unicode """ return self._properties['outbound_resource_url'] @property def date_created(self): """ :returns: The date this Message Interaction was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this Message Interaction was updated :rtype: datetime """ return self._properties['date_updated'] @property def url(self): """ :returns: The URL of this resource. :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a MessageInteractionInstance :returns: Fetched MessageInteractionInstance :rtype: twilio.rest.proxy.v1.service.session.participant.message_interaction.MessageInteractionInstance """ return self._proxy.fetch() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/proxy/v1/service/short_code.py000066400000000000000000000327241317472742600245400ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class ShortCodeList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid): """ Initialize the ShortCodeList :param Version version: Version that contains the resource :param service_sid: Service Sid. :returns: twilio.rest.proxy.v1.service.short_code.ShortCodeList :rtype: twilio.rest.proxy.v1.service.short_code.ShortCodeList """ super(ShortCodeList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid,} self._uri = '/Services/{service_sid}/ShortCodes'.format(**self._solution) def create(self, sid): """ Create a new ShortCodeInstance :param unicode sid: A string that uniquely identifies this Short Code. :returns: Newly created ShortCodeInstance :rtype: twilio.rest.proxy.v1.service.short_code.ShortCodeInstance """ data = values.of({'Sid': sid,}) payload = self._version.create( 'POST', self._uri, data=data, ) return ShortCodeInstance(self._version, payload, service_sid=self._solution['service_sid'],) def stream(self, limit=None, page_size=None): """ Streams ShortCodeInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.proxy.v1.service.short_code.ShortCodeInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists ShortCodeInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.proxy.v1.service.short_code.ShortCodeInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of ShortCodeInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of ShortCodeInstance :rtype: twilio.rest.proxy.v1.service.short_code.ShortCodePage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return ShortCodePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of ShortCodeInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of ShortCodeInstance :rtype: twilio.rest.proxy.v1.service.short_code.ShortCodePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return ShortCodePage(self._version, response, self._solution) def get(self, sid): """ Constructs a ShortCodeContext :param sid: A string that uniquely identifies this Short Code. :returns: twilio.rest.proxy.v1.service.short_code.ShortCodeContext :rtype: twilio.rest.proxy.v1.service.short_code.ShortCodeContext """ return ShortCodeContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __call__(self, sid): """ Constructs a ShortCodeContext :param sid: A string that uniquely identifies this Short Code. :returns: twilio.rest.proxy.v1.service.short_code.ShortCodeContext :rtype: twilio.rest.proxy.v1.service.short_code.ShortCodeContext """ return ShortCodeContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ShortCodePage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the ShortCodePage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: Service Sid. :returns: twilio.rest.proxy.v1.service.short_code.ShortCodePage :rtype: twilio.rest.proxy.v1.service.short_code.ShortCodePage """ super(ShortCodePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of ShortCodeInstance :param dict payload: Payload response from the API :returns: twilio.rest.proxy.v1.service.short_code.ShortCodeInstance :rtype: twilio.rest.proxy.v1.service.short_code.ShortCodeInstance """ return ShortCodeInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ShortCodeContext(InstanceContext): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid, sid): """ Initialize the ShortCodeContext :param Version version: Version that contains the resource :param service_sid: Service Sid. :param sid: A string that uniquely identifies this Short Code. :returns: twilio.rest.proxy.v1.service.short_code.ShortCodeContext :rtype: twilio.rest.proxy.v1.service.short_code.ShortCodeContext """ super(ShortCodeContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/ShortCodes/{sid}'.format(**self._solution) def delete(self): """ Deletes the ShortCodeInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def fetch(self): """ Fetch a ShortCodeInstance :returns: Fetched ShortCodeInstance :rtype: twilio.rest.proxy.v1.service.short_code.ShortCodeInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return ShortCodeInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class ShortCodeInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, payload, service_sid, sid=None): """ Initialize the ShortCodeInstance :returns: twilio.rest.proxy.v1.service.short_code.ShortCodeInstance :rtype: twilio.rest.proxy.v1.service.short_code.ShortCodeInstance """ super(ShortCodeInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'short_code': payload['short_code'], 'iso_country': payload['iso_country'], 'capabilities': payload['capabilities'], 'url': payload['url'], } # Context self._context = None self._solution = {'service_sid': service_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.proxy.v1.service.short_code.ShortCodeContext """ if self._context is None: self._context = ShortCodeContext( self._version, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: A string that uniquely identifies this Short Code. :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: Account Sid. :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: Service Sid. :rtype: unicode """ return self._properties['service_sid'] @property def date_created(self): """ :returns: The date this Short Code was created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this Short Code was updated :rtype: datetime """ return self._properties['date_updated'] @property def short_code(self): """ :returns: Shortcode. :rtype: unicode """ return self._properties['short_code'] @property def iso_country(self): """ :returns: ISO Country Code, :rtype: unicode """ return self._properties['iso_country'] @property def capabilities(self): """ :returns: Nested resource URLs. :rtype: dict """ return self._properties['capabilities'] @property def url(self): """ :returns: The URL of this resource. :rtype: unicode """ return self._properties['url'] def delete(self): """ Deletes the ShortCodeInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def fetch(self): """ Fetch a ShortCodeInstance :returns: Fetched ShortCodeInstance :rtype: twilio.rest.proxy.v1.service.short_code.ShortCodeInstance """ return self._proxy.fetch() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/sync/000077500000000000000000000000001317472742600176325ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/sync/__init__.py000066400000000000000000000020701317472742600217420ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.domain import Domain from twilio.rest.sync.v1 import V1 class Sync(Domain): def __init__(self, twilio): """ Initialize the Sync Domain :returns: Domain for Sync :rtype: twilio.rest.sync.Sync """ super(Sync, self).__init__(twilio) self.base_url = 'https://sync.twilio.com' # Versions self._v1 = None @property def v1(self): """ :returns: Version v1 of sync :rtype: twilio.rest.sync.v1.V1 """ if self._v1 is None: self._v1 = V1(self) return self._v1 @property def services(self): """ :rtype: twilio.rest.sync.v1.service.ServiceList """ return self.v1.services def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/sync/v1/000077500000000000000000000000001317472742600201605ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/sync/v1/__init__.py000066400000000000000000000016521317472742600222750ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.version import Version from twilio.rest.sync.v1.service import ServiceList class V1(Version): def __init__(self, domain): """ Initialize the V1 version of Sync :returns: V1 version of Sync :rtype: twilio.rest.sync.v1.V1.V1 """ super(V1, self).__init__(domain) self.version = 'v1' self._services = None @property def services(self): """ :rtype: twilio.rest.sync.v1.service.ServiceList """ if self._services is None: self._services = ServiceList(self) return self._services def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/sync/v1/service/000077500000000000000000000000001317472742600216205ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/sync/v1/service/__init__.py000066400000000000000000000437411317472742600237420ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.sync.v1.service.document import DocumentList from twilio.rest.sync.v1.service.sync_list import SyncListList from twilio.rest.sync.v1.service.sync_map import SyncMapList from twilio.rest.sync.v1.service.sync_stream import SyncStreamList class ServiceList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version): """ Initialize the ServiceList :param Version version: Version that contains the resource :returns: twilio.rest.sync.v1.service.ServiceList :rtype: twilio.rest.sync.v1.service.ServiceList """ super(ServiceList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/Services'.format(**self._solution) def create(self, friendly_name=values.unset, webhook_url=values.unset, reachability_webhooks_enabled=values.unset, acl_enabled=values.unset): """ Create a new ServiceInstance :param unicode friendly_name: The friendly_name :param unicode webhook_url: The webhook_url :param bool reachability_webhooks_enabled: The reachability_webhooks_enabled :param bool acl_enabled: The acl_enabled :returns: Newly created ServiceInstance :rtype: twilio.rest.sync.v1.service.ServiceInstance """ data = values.of({ 'FriendlyName': friendly_name, 'WebhookUrl': webhook_url, 'ReachabilityWebhooksEnabled': reachability_webhooks_enabled, 'AclEnabled': acl_enabled, }) payload = self._version.create( 'POST', self._uri, data=data, ) return ServiceInstance(self._version, payload,) def stream(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.sync.v1.service.ServiceInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.sync.v1.service.ServiceInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of ServiceInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of ServiceInstance :rtype: twilio.rest.sync.v1.service.ServicePage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return ServicePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of ServiceInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of ServiceInstance :rtype: twilio.rest.sync.v1.service.ServicePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return ServicePage(self._version, response, self._solution) def get(self, sid): """ Constructs a ServiceContext :param sid: The sid :returns: twilio.rest.sync.v1.service.ServiceContext :rtype: twilio.rest.sync.v1.service.ServiceContext """ return ServiceContext(self._version, sid=sid,) def __call__(self, sid): """ Constructs a ServiceContext :param sid: The sid :returns: twilio.rest.sync.v1.service.ServiceContext :rtype: twilio.rest.sync.v1.service.ServiceContext """ return ServiceContext(self._version, sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ServicePage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the ServicePage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.sync.v1.service.ServicePage :rtype: twilio.rest.sync.v1.service.ServicePage """ super(ServicePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of ServiceInstance :param dict payload: Payload response from the API :returns: twilio.rest.sync.v1.service.ServiceInstance :rtype: twilio.rest.sync.v1.service.ServiceInstance """ return ServiceInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ServiceContext(InstanceContext): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, sid): """ Initialize the ServiceContext :param Version version: Version that contains the resource :param sid: The sid :returns: twilio.rest.sync.v1.service.ServiceContext :rtype: twilio.rest.sync.v1.service.ServiceContext """ super(ServiceContext, self).__init__(version) # Path Solution self._solution = {'sid': sid,} self._uri = '/Services/{sid}'.format(**self._solution) # Dependents self._documents = None self._sync_lists = None self._sync_maps = None self._sync_streams = None def fetch(self): """ Fetch a ServiceInstance :returns: Fetched ServiceInstance :rtype: twilio.rest.sync.v1.service.ServiceInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return ServiceInstance(self._version, payload, sid=self._solution['sid'],) def delete(self): """ Deletes the ServiceInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, webhook_url=values.unset, friendly_name=values.unset, reachability_webhooks_enabled=values.unset, acl_enabled=values.unset): """ Update the ServiceInstance :param unicode webhook_url: The webhook_url :param unicode friendly_name: The friendly_name :param bool reachability_webhooks_enabled: The reachability_webhooks_enabled :param bool acl_enabled: The acl_enabled :returns: Updated ServiceInstance :rtype: twilio.rest.sync.v1.service.ServiceInstance """ data = values.of({ 'WebhookUrl': webhook_url, 'FriendlyName': friendly_name, 'ReachabilityWebhooksEnabled': reachability_webhooks_enabled, 'AclEnabled': acl_enabled, }) payload = self._version.update( 'POST', self._uri, data=data, ) return ServiceInstance(self._version, payload, sid=self._solution['sid'],) @property def documents(self): """ Access the documents :returns: twilio.rest.sync.v1.service.document.DocumentList :rtype: twilio.rest.sync.v1.service.document.DocumentList """ if self._documents is None: self._documents = DocumentList(self._version, service_sid=self._solution['sid'],) return self._documents @property def sync_lists(self): """ Access the sync_lists :returns: twilio.rest.sync.v1.service.sync_list.SyncListList :rtype: twilio.rest.sync.v1.service.sync_list.SyncListList """ if self._sync_lists is None: self._sync_lists = SyncListList(self._version, service_sid=self._solution['sid'],) return self._sync_lists @property def sync_maps(self): """ Access the sync_maps :returns: twilio.rest.sync.v1.service.sync_map.SyncMapList :rtype: twilio.rest.sync.v1.service.sync_map.SyncMapList """ if self._sync_maps is None: self._sync_maps = SyncMapList(self._version, service_sid=self._solution['sid'],) return self._sync_maps @property def sync_streams(self): """ Access the sync_streams :returns: twilio.rest.sync.v1.service.sync_stream.SyncStreamList :rtype: twilio.rest.sync.v1.service.sync_stream.SyncStreamList """ if self._sync_streams is None: self._sync_streams = SyncStreamList(self._version, service_sid=self._solution['sid'],) return self._sync_streams def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class ServiceInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, payload, sid=None): """ Initialize the ServiceInstance :returns: twilio.rest.sync.v1.service.ServiceInstance :rtype: twilio.rest.sync.v1.service.ServiceInstance """ super(ServiceInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'unique_name': payload['unique_name'], 'account_sid': payload['account_sid'], 'friendly_name': payload['friendly_name'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'url': payload['url'], 'webhook_url': payload['webhook_url'], 'reachability_webhooks_enabled': payload['reachability_webhooks_enabled'], 'acl_enabled': payload['acl_enabled'], 'links': payload['links'], } # Context self._context = None self._solution = {'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.sync.v1.service.ServiceContext """ if self._context is None: self._context = ServiceContext(self._version, sid=self._solution['sid'],) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def unique_name(self): """ :returns: The unique_name :rtype: unicode """ return self._properties['unique_name'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def webhook_url(self): """ :returns: The webhook_url :rtype: unicode """ return self._properties['webhook_url'] @property def reachability_webhooks_enabled(self): """ :returns: The reachability_webhooks_enabled :rtype: bool """ return self._properties['reachability_webhooks_enabled'] @property def acl_enabled(self): """ :returns: The acl_enabled :rtype: bool """ return self._properties['acl_enabled'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a ServiceInstance :returns: Fetched ServiceInstance :rtype: twilio.rest.sync.v1.service.ServiceInstance """ return self._proxy.fetch() def delete(self): """ Deletes the ServiceInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, webhook_url=values.unset, friendly_name=values.unset, reachability_webhooks_enabled=values.unset, acl_enabled=values.unset): """ Update the ServiceInstance :param unicode webhook_url: The webhook_url :param unicode friendly_name: The friendly_name :param bool reachability_webhooks_enabled: The reachability_webhooks_enabled :param bool acl_enabled: The acl_enabled :returns: Updated ServiceInstance :rtype: twilio.rest.sync.v1.service.ServiceInstance """ return self._proxy.update( webhook_url=webhook_url, friendly_name=friendly_name, reachability_webhooks_enabled=reachability_webhooks_enabled, acl_enabled=acl_enabled, ) @property def documents(self): """ Access the documents :returns: twilio.rest.sync.v1.service.document.DocumentList :rtype: twilio.rest.sync.v1.service.document.DocumentList """ return self._proxy.documents @property def sync_lists(self): """ Access the sync_lists :returns: twilio.rest.sync.v1.service.sync_list.SyncListList :rtype: twilio.rest.sync.v1.service.sync_list.SyncListList """ return self._proxy.sync_lists @property def sync_maps(self): """ Access the sync_maps :returns: twilio.rest.sync.v1.service.sync_map.SyncMapList :rtype: twilio.rest.sync.v1.service.sync_map.SyncMapList """ return self._proxy.sync_maps @property def sync_streams(self): """ Access the sync_streams :returns: twilio.rest.sync.v1.service.sync_stream.SyncStreamList :rtype: twilio.rest.sync.v1.service.sync_stream.SyncStreamList """ return self._proxy.sync_streams def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/sync/v1/service/document/000077500000000000000000000000001317472742600234365ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/sync/v1/service/document/__init__.py000066400000000000000000000370711317472742600255570ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize 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.page import Page from twilio.rest.sync.v1.service.document.document_permission import DocumentPermissionList class DocumentList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid): """ Initialize the DocumentList :param Version version: Version that contains the resource :param service_sid: The service_sid :returns: twilio.rest.sync.v1.service.document.DocumentList :rtype: twilio.rest.sync.v1.service.document.DocumentList """ super(DocumentList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid,} self._uri = '/Services/{service_sid}/Documents'.format(**self._solution) def create(self, unique_name=values.unset, data=values.unset): """ Create a new DocumentInstance :param unicode unique_name: The unique_name :param dict data: The data :returns: Newly created DocumentInstance :rtype: twilio.rest.sync.v1.service.document.DocumentInstance """ data = values.of({'UniqueName': unique_name, 'Data': serialize.object(data),}) payload = self._version.create( 'POST', self._uri, data=data, ) return DocumentInstance(self._version, payload, service_sid=self._solution['service_sid'],) def stream(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.sync.v1.service.document.DocumentInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.sync.v1.service.document.DocumentInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of DocumentInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of DocumentInstance :rtype: twilio.rest.sync.v1.service.document.DocumentPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return DocumentPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of DocumentInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of DocumentInstance :rtype: twilio.rest.sync.v1.service.document.DocumentPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return DocumentPage(self._version, response, self._solution) def get(self, sid): """ Constructs a DocumentContext :param sid: The sid :returns: twilio.rest.sync.v1.service.document.DocumentContext :rtype: twilio.rest.sync.v1.service.document.DocumentContext """ return DocumentContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __call__(self, sid): """ Constructs a DocumentContext :param sid: The sid :returns: twilio.rest.sync.v1.service.document.DocumentContext :rtype: twilio.rest.sync.v1.service.document.DocumentContext """ return DocumentContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class DocumentPage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the DocumentPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :returns: twilio.rest.sync.v1.service.document.DocumentPage :rtype: twilio.rest.sync.v1.service.document.DocumentPage """ super(DocumentPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of DocumentInstance :param dict payload: Payload response from the API :returns: twilio.rest.sync.v1.service.document.DocumentInstance :rtype: twilio.rest.sync.v1.service.document.DocumentInstance """ return DocumentInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class DocumentContext(InstanceContext): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid, sid): """ Initialize the DocumentContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param sid: The sid :returns: twilio.rest.sync.v1.service.document.DocumentContext :rtype: twilio.rest.sync.v1.service.document.DocumentContext """ super(DocumentContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Documents/{sid}'.format(**self._solution) # Dependents self._document_permissions = None def fetch(self): """ Fetch a DocumentInstance :returns: Fetched DocumentInstance :rtype: twilio.rest.sync.v1.service.document.DocumentInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return DocumentInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the DocumentInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, data): """ Update the DocumentInstance :param dict data: The data :returns: Updated DocumentInstance :rtype: twilio.rest.sync.v1.service.document.DocumentInstance """ data = values.of({'Data': serialize.object(data),}) payload = self._version.update( 'POST', self._uri, data=data, ) return DocumentInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) @property def document_permissions(self): """ Access the document_permissions :returns: twilio.rest.sync.v1.service.document.document_permission.DocumentPermissionList :rtype: twilio.rest.sync.v1.service.document.document_permission.DocumentPermissionList """ if self._document_permissions is None: self._document_permissions = DocumentPermissionList( self._version, service_sid=self._solution['service_sid'], document_sid=self._solution['sid'], ) return self._document_permissions def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class DocumentInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, payload, service_sid, sid=None): """ Initialize the DocumentInstance :returns: twilio.rest.sync.v1.service.document.DocumentInstance :rtype: twilio.rest.sync.v1.service.document.DocumentInstance """ super(DocumentInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'unique_name': payload['unique_name'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'url': payload['url'], 'links': payload['links'], 'revision': payload['revision'], 'data': payload['data'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'created_by': payload['created_by'], } # Context self._context = None self._solution = {'service_sid': service_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.sync.v1.service.document.DocumentContext """ if self._context is None: self._context = DocumentContext( self._version, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def unique_name(self): """ :returns: The unique_name :rtype: unicode """ return self._properties['unique_name'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] @property def revision(self): """ :returns: The revision :rtype: unicode """ return self._properties['revision'] @property def data(self): """ :returns: The data :rtype: dict """ return self._properties['data'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def created_by(self): """ :returns: The created_by :rtype: unicode """ return self._properties['created_by'] def fetch(self): """ Fetch a DocumentInstance :returns: Fetched DocumentInstance :rtype: twilio.rest.sync.v1.service.document.DocumentInstance """ return self._proxy.fetch() def delete(self): """ Deletes the DocumentInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, data): """ Update the DocumentInstance :param dict data: The data :returns: Updated DocumentInstance :rtype: twilio.rest.sync.v1.service.document.DocumentInstance """ return self._proxy.update(data,) @property def document_permissions(self): """ Access the document_permissions :returns: twilio.rest.sync.v1.service.document.document_permission.DocumentPermissionList :rtype: twilio.rest.sync.v1.service.document.document_permission.DocumentPermissionList """ return self._proxy.document_permissions def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/sync/v1/service/document/document_permission.py000066400000000000000000000372521317472742600301070ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ 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.page import Page class DocumentPermissionList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid, document_sid): """ Initialize the DocumentPermissionList :param Version version: Version that contains the resource :param service_sid: Sync Service Instance SID. :param document_sid: Sync Document SID. :returns: twilio.rest.sync.v1.service.document.document_permission.DocumentPermissionList :rtype: twilio.rest.sync.v1.service.document.document_permission.DocumentPermissionList """ super(DocumentPermissionList, self).__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=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.sync.v1.service.document.document_permission.DocumentPermissionInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.sync.v1.service.document.document_permission.DocumentPermissionInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of DocumentPermissionInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of DocumentPermissionInstance :rtype: twilio.rest.sync.v1.service.document.document_permission.DocumentPermissionPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return DocumentPermissionPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of DocumentPermissionInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of DocumentPermissionInstance :rtype: twilio.rest.sync.v1.service.document.document_permission.DocumentPermissionPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return DocumentPermissionPage(self._version, response, self._solution) def get(self, identity): """ Constructs a DocumentPermissionContext :param identity: Identity of the user to whom the Sync Document Permission applies. :returns: twilio.rest.sync.v1.service.document.document_permission.DocumentPermissionContext :rtype: twilio.rest.sync.v1.service.document.document_permission.DocumentPermissionContext """ return DocumentPermissionContext( self._version, service_sid=self._solution['service_sid'], document_sid=self._solution['document_sid'], identity=identity, ) def __call__(self, identity): """ Constructs a DocumentPermissionContext :param identity: Identity of the user to whom the Sync Document Permission applies. :returns: twilio.rest.sync.v1.service.document.document_permission.DocumentPermissionContext :rtype: twilio.rest.sync.v1.service.document.document_permission.DocumentPermissionContext """ return DocumentPermissionContext( self._version, service_sid=self._solution['service_sid'], document_sid=self._solution['document_sid'], identity=identity, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class DocumentPermissionPage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the DocumentPermissionPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: Sync Service Instance SID. :param document_sid: Sync Document SID. :returns: twilio.rest.sync.v1.service.document.document_permission.DocumentPermissionPage :rtype: twilio.rest.sync.v1.service.document.document_permission.DocumentPermissionPage """ super(DocumentPermissionPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of DocumentPermissionInstance :param dict payload: Payload response from the API :returns: twilio.rest.sync.v1.service.document.document_permission.DocumentPermissionInstance :rtype: twilio.rest.sync.v1.service.document.document_permission.DocumentPermissionInstance """ return DocumentPermissionInstance( self._version, payload, service_sid=self._solution['service_sid'], document_sid=self._solution['document_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class DocumentPermissionContext(InstanceContext): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid, document_sid, identity): """ Initialize the DocumentPermissionContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param document_sid: Sync Document SID or unique name. :param identity: Identity of the user to whom the Sync Document Permission applies. :returns: twilio.rest.sync.v1.service.document.document_permission.DocumentPermissionContext :rtype: twilio.rest.sync.v1.service.document.document_permission.DocumentPermissionContext """ super(DocumentPermissionContext, self).__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 fetch(self): """ Fetch a DocumentPermissionInstance :returns: Fetched DocumentPermissionInstance :rtype: twilio.rest.sync.v1.service.document.document_permission.DocumentPermissionInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return DocumentPermissionInstance( self._version, payload, service_sid=self._solution['service_sid'], document_sid=self._solution['document_sid'], identity=self._solution['identity'], ) def delete(self): """ Deletes the DocumentPermissionInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, read, write, manage): """ Update the DocumentPermissionInstance :param bool read: Read access. :param bool write: Write access. :param bool manage: Manage access. :returns: Updated DocumentPermissionInstance :rtype: twilio.rest.sync.v1.service.document.document_permission.DocumentPermissionInstance """ data = values.of({'Read': read, 'Write': write, 'Manage': manage,}) payload = self._version.update( 'POST', 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): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class DocumentPermissionInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, payload, service_sid, document_sid, identity=None): """ Initialize the DocumentPermissionInstance :returns: twilio.rest.sync.v1.service.document.document_permission.DocumentPermissionInstance :rtype: twilio.rest.sync.v1.service.document.document_permission.DocumentPermissionInstance """ super(DocumentPermissionInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'document_sid': payload['document_sid'], 'identity': payload['identity'], 'read': payload['read'], 'write': payload['write'], 'manage': payload['manage'], 'url': payload['url'], } # Context self._context = None self._solution = { 'service_sid': service_sid, 'document_sid': document_sid, 'identity': identity or self._properties['identity'], } @property def _proxy(self): """ 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 :rtype: twilio.rest.sync.v1.service.document.document_permission.DocumentPermissionContext """ 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 @property def account_sid(self): """ :returns: Twilio Account SID. :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: Sync Service Instance SID. :rtype: unicode """ return self._properties['service_sid'] @property def document_sid(self): """ :returns: Sync Document SID. :rtype: unicode """ return self._properties['document_sid'] @property def identity(self): """ :returns: Identity of the user to whom the Sync Document Permission applies. :rtype: unicode """ return self._properties['identity'] @property def read(self): """ :returns: Read access. :rtype: bool """ return self._properties['read'] @property def write(self): """ :returns: Write access. :rtype: bool """ return self._properties['write'] @property def manage(self): """ :returns: Manage access. :rtype: bool """ return self._properties['manage'] @property def url(self): """ :returns: URL of this Sync Document Permission. :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a DocumentPermissionInstance :returns: Fetched DocumentPermissionInstance :rtype: twilio.rest.sync.v1.service.document.document_permission.DocumentPermissionInstance """ return self._proxy.fetch() def delete(self): """ Deletes the DocumentPermissionInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, read, write, manage): """ Update the DocumentPermissionInstance :param bool read: Read access. :param bool write: Write access. :param bool manage: Manage access. :returns: Updated DocumentPermissionInstance :rtype: twilio.rest.sync.v1.service.document.document_permission.DocumentPermissionInstance """ return self._proxy.update(read, write, manage,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/sync/v1/service/sync_list/000077500000000000000000000000001317472742600236275ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/sync/v1/service/sync_list/__init__.py000066400000000000000000000366431317472742600257540ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.sync.v1.service.sync_list.sync_list_item import SyncListItemList from twilio.rest.sync.v1.service.sync_list.sync_list_permission import SyncListPermissionList class SyncListList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid): """ Initialize the SyncListList :param Version version: Version that contains the resource :param service_sid: The service_sid :returns: twilio.rest.sync.v1.service.sync_list.SyncListList :rtype: twilio.rest.sync.v1.service.sync_list.SyncListList """ super(SyncListList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid,} self._uri = '/Services/{service_sid}/Lists'.format(**self._solution) def create(self, unique_name=values.unset): """ Create a new SyncListInstance :param unicode unique_name: The unique_name :returns: Newly created SyncListInstance :rtype: twilio.rest.sync.v1.service.sync_list.SyncListInstance """ data = values.of({'UniqueName': unique_name,}) payload = self._version.create( 'POST', self._uri, data=data, ) return SyncListInstance(self._version, payload, service_sid=self._solution['service_sid'],) def stream(self, limit=None, page_size=None): """ Streams SyncListInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.sync.v1.service.sync_list.SyncListInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists SyncListInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.sync.v1.service.sync_list.SyncListInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of SyncListInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of SyncListInstance :rtype: twilio.rest.sync.v1.service.sync_list.SyncListPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return SyncListPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of SyncListInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of SyncListInstance :rtype: twilio.rest.sync.v1.service.sync_list.SyncListPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return SyncListPage(self._version, response, self._solution) def get(self, sid): """ Constructs a SyncListContext :param sid: The sid :returns: twilio.rest.sync.v1.service.sync_list.SyncListContext :rtype: twilio.rest.sync.v1.service.sync_list.SyncListContext """ return SyncListContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __call__(self, sid): """ Constructs a SyncListContext :param sid: The sid :returns: twilio.rest.sync.v1.service.sync_list.SyncListContext :rtype: twilio.rest.sync.v1.service.sync_list.SyncListContext """ return SyncListContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SyncListPage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the SyncListPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :returns: twilio.rest.sync.v1.service.sync_list.SyncListPage :rtype: twilio.rest.sync.v1.service.sync_list.SyncListPage """ super(SyncListPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of SyncListInstance :param dict payload: Payload response from the API :returns: twilio.rest.sync.v1.service.sync_list.SyncListInstance :rtype: twilio.rest.sync.v1.service.sync_list.SyncListInstance """ return SyncListInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SyncListContext(InstanceContext): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid, sid): """ Initialize the SyncListContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param sid: The sid :returns: twilio.rest.sync.v1.service.sync_list.SyncListContext :rtype: twilio.rest.sync.v1.service.sync_list.SyncListContext """ super(SyncListContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Lists/{sid}'.format(**self._solution) # Dependents self._sync_list_items = None self._sync_list_permissions = None def fetch(self): """ Fetch a SyncListInstance :returns: Fetched SyncListInstance :rtype: twilio.rest.sync.v1.service.sync_list.SyncListInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return SyncListInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the SyncListInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) @property def sync_list_items(self): """ Access the sync_list_items :returns: twilio.rest.sync.v1.service.sync_list.sync_list_item.SyncListItemList :rtype: twilio.rest.sync.v1.service.sync_list.sync_list_item.SyncListItemList """ if self._sync_list_items is None: self._sync_list_items = SyncListItemList( self._version, service_sid=self._solution['service_sid'], list_sid=self._solution['sid'], ) return self._sync_list_items @property def sync_list_permissions(self): """ Access the sync_list_permissions :returns: twilio.rest.sync.v1.service.sync_list.sync_list_permission.SyncListPermissionList :rtype: twilio.rest.sync.v1.service.sync_list.sync_list_permission.SyncListPermissionList """ if self._sync_list_permissions is None: self._sync_list_permissions = SyncListPermissionList( self._version, service_sid=self._solution['service_sid'], list_sid=self._solution['sid'], ) return self._sync_list_permissions def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class SyncListInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, payload, service_sid, sid=None): """ Initialize the SyncListInstance :returns: twilio.rest.sync.v1.service.sync_list.SyncListInstance :rtype: twilio.rest.sync.v1.service.sync_list.SyncListInstance """ super(SyncListInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'unique_name': payload['unique_name'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'url': payload['url'], 'links': payload['links'], 'revision': payload['revision'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'created_by': payload['created_by'], } # Context self._context = None self._solution = {'service_sid': service_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.sync.v1.service.sync_list.SyncListContext """ if self._context is None: self._context = SyncListContext( self._version, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def unique_name(self): """ :returns: The unique_name :rtype: unicode """ return self._properties['unique_name'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] @property def revision(self): """ :returns: The revision :rtype: unicode """ return self._properties['revision'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def created_by(self): """ :returns: The created_by :rtype: unicode """ return self._properties['created_by'] def fetch(self): """ Fetch a SyncListInstance :returns: Fetched SyncListInstance :rtype: twilio.rest.sync.v1.service.sync_list.SyncListInstance """ return self._proxy.fetch() def delete(self): """ Deletes the SyncListInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() @property def sync_list_items(self): """ Access the sync_list_items :returns: twilio.rest.sync.v1.service.sync_list.sync_list_item.SyncListItemList :rtype: twilio.rest.sync.v1.service.sync_list.sync_list_item.SyncListItemList """ return self._proxy.sync_list_items @property def sync_list_permissions(self): """ Access the sync_list_permissions :returns: twilio.rest.sync.v1.service.sync_list.sync_list_permission.SyncListPermissionList :rtype: twilio.rest.sync.v1.service.sync_list.sync_list_permission.SyncListPermissionList """ return self._proxy.sync_list_permissions def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/sync/v1/service/sync_list/sync_list_item.py000066400000000000000000000414661317472742600272410ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize 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.page import Page class SyncListItemList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid, list_sid): """ Initialize the SyncListItemList :param Version version: Version that contains the resource :param service_sid: The service_sid :param list_sid: The list_sid :returns: twilio.rest.sync.v1.service.sync_list.sync_list_item.SyncListItemList :rtype: twilio.rest.sync.v1.service.sync_list.sync_list_item.SyncListItemList """ super(SyncListItemList, self).__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): """ Create a new SyncListItemInstance :param dict data: The data :returns: Newly created SyncListItemInstance :rtype: twilio.rest.sync.v1.service.sync_list.sync_list_item.SyncListItemInstance """ data = values.of({'Data': serialize.object(data),}) payload = self._version.create( 'POST', 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=values.unset, from_=values.unset, bounds=values.unset, limit=None, page_size=None): """ 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: The order :param unicode from_: The from :param SyncListItemInstance.QueryFromBoundType bounds: The bounds :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.sync.v1.service.sync_list.sync_list_item.SyncListItemInstance] """ 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'], limits['page_limit']) def list(self, order=values.unset, from_=values.unset, bounds=values.unset, limit=None, page_size=None): """ 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: The order :param unicode from_: The from :param SyncListItemInstance.QueryFromBoundType bounds: The bounds :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.sync.v1.service.sync_list.sync_list_item.SyncListItemInstance] """ return list(self.stream(order=order, from_=from_, bounds=bounds, limit=limit, page_size=page_size,)) def page(self, order=values.unset, from_=values.unset, bounds=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of SyncListItemInstance records from the API. Request is executed immediately :param SyncListItemInstance.QueryResultOrder order: The order :param unicode from_: The from :param SyncListItemInstance.QueryFromBoundType bounds: The bounds :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of SyncListItemInstance :rtype: twilio.rest.sync.v1.service.sync_list.sync_list_item.SyncListItemPage """ params = values.of({ 'Order': order, 'From': from_, 'Bounds': bounds, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return SyncListItemPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of SyncListItemInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of SyncListItemInstance :rtype: twilio.rest.sync.v1.service.sync_list.sync_list_item.SyncListItemPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return SyncListItemPage(self._version, response, self._solution) def get(self, index): """ Constructs a SyncListItemContext :param index: The index :returns: twilio.rest.sync.v1.service.sync_list.sync_list_item.SyncListItemContext :rtype: twilio.rest.sync.v1.service.sync_list.sync_list_item.SyncListItemContext """ return SyncListItemContext( self._version, service_sid=self._solution['service_sid'], list_sid=self._solution['list_sid'], index=index, ) def __call__(self, index): """ Constructs a SyncListItemContext :param index: The index :returns: twilio.rest.sync.v1.service.sync_list.sync_list_item.SyncListItemContext :rtype: twilio.rest.sync.v1.service.sync_list.sync_list_item.SyncListItemContext """ return SyncListItemContext( self._version, service_sid=self._solution['service_sid'], list_sid=self._solution['list_sid'], index=index, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SyncListItemPage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the SyncListItemPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :param list_sid: The list_sid :returns: twilio.rest.sync.v1.service.sync_list.sync_list_item.SyncListItemPage :rtype: twilio.rest.sync.v1.service.sync_list.sync_list_item.SyncListItemPage """ super(SyncListItemPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of SyncListItemInstance :param dict payload: Payload response from the API :returns: twilio.rest.sync.v1.service.sync_list.sync_list_item.SyncListItemInstance :rtype: twilio.rest.sync.v1.service.sync_list.sync_list_item.SyncListItemInstance """ return SyncListItemInstance( self._version, payload, service_sid=self._solution['service_sid'], list_sid=self._solution['list_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SyncListItemContext(InstanceContext): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid, list_sid, index): """ Initialize the SyncListItemContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param list_sid: The list_sid :param index: The index :returns: twilio.rest.sync.v1.service.sync_list.sync_list_item.SyncListItemContext :rtype: twilio.rest.sync.v1.service.sync_list.sync_list_item.SyncListItemContext """ super(SyncListItemContext, self).__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 fetch(self): """ Fetch a SyncListItemInstance :returns: Fetched SyncListItemInstance :rtype: twilio.rest.sync.v1.service.sync_list.sync_list_item.SyncListItemInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return SyncListItemInstance( self._version, payload, service_sid=self._solution['service_sid'], list_sid=self._solution['list_sid'], index=self._solution['index'], ) def delete(self): """ Deletes the SyncListItemInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, data): """ Update the SyncListItemInstance :param dict data: The data :returns: Updated SyncListItemInstance :rtype: twilio.rest.sync.v1.service.sync_list.sync_list_item.SyncListItemInstance """ data = values.of({'Data': serialize.object(data),}) payload = self._version.update( 'POST', self._uri, data=data, ) return SyncListItemInstance( self._version, payload, service_sid=self._solution['service_sid'], list_sid=self._solution['list_sid'], index=self._solution['index'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class SyncListItemInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ class QueryResultOrder(object): ASC = "asc" DESC = "desc" class QueryFromBoundType(object): INCLUSIVE = "inclusive" EXCLUSIVE = "exclusive" def __init__(self, version, payload, service_sid, list_sid, index=None): """ Initialize the SyncListItemInstance :returns: twilio.rest.sync.v1.service.sync_list.sync_list_item.SyncListItemInstance :rtype: twilio.rest.sync.v1.service.sync_list.sync_list_item.SyncListItemInstance """ super(SyncListItemInstance, self).__init__(version) # Marshaled Properties self._properties = { 'index': deserialize.integer(payload['index']), 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'list_sid': payload['list_sid'], 'url': payload['url'], 'revision': payload['revision'], 'data': payload['data'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'created_by': payload['created_by'], } # Context self._context = None self._solution = { 'service_sid': service_sid, 'list_sid': list_sid, 'index': index or self._properties['index'], } @property def _proxy(self): """ 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 :rtype: twilio.rest.sync.v1.service.sync_list.sync_list_item.SyncListItemContext """ 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 @property def index(self): """ :returns: The index :rtype: unicode """ return self._properties['index'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def list_sid(self): """ :returns: The list_sid :rtype: unicode """ return self._properties['list_sid'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def revision(self): """ :returns: The revision :rtype: unicode """ return self._properties['revision'] @property def data(self): """ :returns: The data :rtype: dict """ return self._properties['data'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def created_by(self): """ :returns: The created_by :rtype: unicode """ return self._properties['created_by'] def fetch(self): """ Fetch a SyncListItemInstance :returns: Fetched SyncListItemInstance :rtype: twilio.rest.sync.v1.service.sync_list.sync_list_item.SyncListItemInstance """ return self._proxy.fetch() def delete(self): """ Deletes the SyncListItemInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, data): """ Update the SyncListItemInstance :param dict data: The data :returns: Updated SyncListItemInstance :rtype: twilio.rest.sync.v1.service.sync_list.sync_list_item.SyncListItemInstance """ return self._proxy.update(data,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/sync/v1/service/sync_list/sync_list_permission.py000066400000000000000000000370641317472742600304720ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ 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.page import Page class SyncListPermissionList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid, list_sid): """ Initialize the SyncListPermissionList :param Version version: Version that contains the resource :param service_sid: Sync Service Instance SID. :param list_sid: Sync List SID. :returns: twilio.rest.sync.v1.service.sync_list.sync_list_permission.SyncListPermissionList :rtype: twilio.rest.sync.v1.service.sync_list.sync_list_permission.SyncListPermissionList """ super(SyncListPermissionList, self).__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=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.sync.v1.service.sync_list.sync_list_permission.SyncListPermissionInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.sync.v1.service.sync_list.sync_list_permission.SyncListPermissionInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of SyncListPermissionInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of SyncListPermissionInstance :rtype: twilio.rest.sync.v1.service.sync_list.sync_list_permission.SyncListPermissionPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return SyncListPermissionPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of SyncListPermissionInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of SyncListPermissionInstance :rtype: twilio.rest.sync.v1.service.sync_list.sync_list_permission.SyncListPermissionPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return SyncListPermissionPage(self._version, response, self._solution) def get(self, identity): """ Constructs a SyncListPermissionContext :param identity: Identity of the user to whom the Sync List Permission applies. :returns: twilio.rest.sync.v1.service.sync_list.sync_list_permission.SyncListPermissionContext :rtype: twilio.rest.sync.v1.service.sync_list.sync_list_permission.SyncListPermissionContext """ return SyncListPermissionContext( self._version, service_sid=self._solution['service_sid'], list_sid=self._solution['list_sid'], identity=identity, ) def __call__(self, identity): """ Constructs a SyncListPermissionContext :param identity: Identity of the user to whom the Sync List Permission applies. :returns: twilio.rest.sync.v1.service.sync_list.sync_list_permission.SyncListPermissionContext :rtype: twilio.rest.sync.v1.service.sync_list.sync_list_permission.SyncListPermissionContext """ return SyncListPermissionContext( self._version, service_sid=self._solution['service_sid'], list_sid=self._solution['list_sid'], identity=identity, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SyncListPermissionPage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the SyncListPermissionPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: Sync Service Instance SID. :param list_sid: Sync List SID. :returns: twilio.rest.sync.v1.service.sync_list.sync_list_permission.SyncListPermissionPage :rtype: twilio.rest.sync.v1.service.sync_list.sync_list_permission.SyncListPermissionPage """ super(SyncListPermissionPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of SyncListPermissionInstance :param dict payload: Payload response from the API :returns: twilio.rest.sync.v1.service.sync_list.sync_list_permission.SyncListPermissionInstance :rtype: twilio.rest.sync.v1.service.sync_list.sync_list_permission.SyncListPermissionInstance """ return SyncListPermissionInstance( self._version, payload, service_sid=self._solution['service_sid'], list_sid=self._solution['list_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SyncListPermissionContext(InstanceContext): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid, list_sid, identity): """ Initialize the SyncListPermissionContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param list_sid: Sync List SID or unique name. :param identity: Identity of the user to whom the Sync List Permission applies. :returns: twilio.rest.sync.v1.service.sync_list.sync_list_permission.SyncListPermissionContext :rtype: twilio.rest.sync.v1.service.sync_list.sync_list_permission.SyncListPermissionContext """ super(SyncListPermissionContext, self).__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 fetch(self): """ Fetch a SyncListPermissionInstance :returns: Fetched SyncListPermissionInstance :rtype: twilio.rest.sync.v1.service.sync_list.sync_list_permission.SyncListPermissionInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return SyncListPermissionInstance( self._version, payload, service_sid=self._solution['service_sid'], list_sid=self._solution['list_sid'], identity=self._solution['identity'], ) def delete(self): """ Deletes the SyncListPermissionInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, read, write, manage): """ Update the SyncListPermissionInstance :param bool read: Read access. :param bool write: Write access. :param bool manage: Manage access. :returns: Updated SyncListPermissionInstance :rtype: twilio.rest.sync.v1.service.sync_list.sync_list_permission.SyncListPermissionInstance """ data = values.of({'Read': read, 'Write': write, 'Manage': manage,}) payload = self._version.update( 'POST', 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): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class SyncListPermissionInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, payload, service_sid, list_sid, identity=None): """ Initialize the SyncListPermissionInstance :returns: twilio.rest.sync.v1.service.sync_list.sync_list_permission.SyncListPermissionInstance :rtype: twilio.rest.sync.v1.service.sync_list.sync_list_permission.SyncListPermissionInstance """ super(SyncListPermissionInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'list_sid': payload['list_sid'], 'identity': payload['identity'], 'read': payload['read'], 'write': payload['write'], 'manage': payload['manage'], 'url': payload['url'], } # Context self._context = None self._solution = { 'service_sid': service_sid, 'list_sid': list_sid, 'identity': identity or self._properties['identity'], } @property def _proxy(self): """ 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 :rtype: twilio.rest.sync.v1.service.sync_list.sync_list_permission.SyncListPermissionContext """ 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 @property def account_sid(self): """ :returns: Twilio Account SID. :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: Sync Service Instance SID. :rtype: unicode """ return self._properties['service_sid'] @property def list_sid(self): """ :returns: Sync List SID. :rtype: unicode """ return self._properties['list_sid'] @property def identity(self): """ :returns: Identity of the user to whom the Sync List Permission applies. :rtype: unicode """ return self._properties['identity'] @property def read(self): """ :returns: Read access. :rtype: bool """ return self._properties['read'] @property def write(self): """ :returns: Write access. :rtype: bool """ return self._properties['write'] @property def manage(self): """ :returns: Manage access. :rtype: bool """ return self._properties['manage'] @property def url(self): """ :returns: URL of this Sync List Permission. :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a SyncListPermissionInstance :returns: Fetched SyncListPermissionInstance :rtype: twilio.rest.sync.v1.service.sync_list.sync_list_permission.SyncListPermissionInstance """ return self._proxy.fetch() def delete(self): """ Deletes the SyncListPermissionInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, read, write, manage): """ Update the SyncListPermissionInstance :param bool read: Read access. :param bool write: Write access. :param bool manage: Manage access. :returns: Updated SyncListPermissionInstance :rtype: twilio.rest.sync.v1.service.sync_list.sync_list_permission.SyncListPermissionInstance """ return self._proxy.update(read, write, manage,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/sync/v1/service/sync_map/000077500000000000000000000000001317472742600234315ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/sync/v1/service/sync_map/__init__.py000066400000000000000000000364261317472742600255550ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.sync.v1.service.sync_map.sync_map_item import SyncMapItemList from twilio.rest.sync.v1.service.sync_map.sync_map_permission import SyncMapPermissionList class SyncMapList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid): """ Initialize the SyncMapList :param Version version: Version that contains the resource :param service_sid: The service_sid :returns: twilio.rest.sync.v1.service.sync_map.SyncMapList :rtype: twilio.rest.sync.v1.service.sync_map.SyncMapList """ super(SyncMapList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid,} self._uri = '/Services/{service_sid}/Maps'.format(**self._solution) def create(self, unique_name=values.unset): """ Create a new SyncMapInstance :param unicode unique_name: The unique_name :returns: Newly created SyncMapInstance :rtype: twilio.rest.sync.v1.service.sync_map.SyncMapInstance """ data = values.of({'UniqueName': unique_name,}) payload = self._version.create( 'POST', self._uri, data=data, ) return SyncMapInstance(self._version, payload, service_sid=self._solution['service_sid'],) def stream(self, limit=None, page_size=None): """ Streams SyncMapInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.sync.v1.service.sync_map.SyncMapInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists SyncMapInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.sync.v1.service.sync_map.SyncMapInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of SyncMapInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of SyncMapInstance :rtype: twilio.rest.sync.v1.service.sync_map.SyncMapPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return SyncMapPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of SyncMapInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of SyncMapInstance :rtype: twilio.rest.sync.v1.service.sync_map.SyncMapPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return SyncMapPage(self._version, response, self._solution) def get(self, sid): """ Constructs a SyncMapContext :param sid: The sid :returns: twilio.rest.sync.v1.service.sync_map.SyncMapContext :rtype: twilio.rest.sync.v1.service.sync_map.SyncMapContext """ return SyncMapContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __call__(self, sid): """ Constructs a SyncMapContext :param sid: The sid :returns: twilio.rest.sync.v1.service.sync_map.SyncMapContext :rtype: twilio.rest.sync.v1.service.sync_map.SyncMapContext """ return SyncMapContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SyncMapPage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the SyncMapPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :returns: twilio.rest.sync.v1.service.sync_map.SyncMapPage :rtype: twilio.rest.sync.v1.service.sync_map.SyncMapPage """ super(SyncMapPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of SyncMapInstance :param dict payload: Payload response from the API :returns: twilio.rest.sync.v1.service.sync_map.SyncMapInstance :rtype: twilio.rest.sync.v1.service.sync_map.SyncMapInstance """ return SyncMapInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SyncMapContext(InstanceContext): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid, sid): """ Initialize the SyncMapContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param sid: The sid :returns: twilio.rest.sync.v1.service.sync_map.SyncMapContext :rtype: twilio.rest.sync.v1.service.sync_map.SyncMapContext """ super(SyncMapContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Maps/{sid}'.format(**self._solution) # Dependents self._sync_map_items = None self._sync_map_permissions = None def fetch(self): """ Fetch a SyncMapInstance :returns: Fetched SyncMapInstance :rtype: twilio.rest.sync.v1.service.sync_map.SyncMapInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return SyncMapInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the SyncMapInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) @property def sync_map_items(self): """ Access the sync_map_items :returns: twilio.rest.sync.v1.service.sync_map.sync_map_item.SyncMapItemList :rtype: twilio.rest.sync.v1.service.sync_map.sync_map_item.SyncMapItemList """ if self._sync_map_items is None: self._sync_map_items = SyncMapItemList( self._version, service_sid=self._solution['service_sid'], map_sid=self._solution['sid'], ) return self._sync_map_items @property def sync_map_permissions(self): """ Access the sync_map_permissions :returns: twilio.rest.sync.v1.service.sync_map.sync_map_permission.SyncMapPermissionList :rtype: twilio.rest.sync.v1.service.sync_map.sync_map_permission.SyncMapPermissionList """ if self._sync_map_permissions is None: self._sync_map_permissions = SyncMapPermissionList( self._version, service_sid=self._solution['service_sid'], map_sid=self._solution['sid'], ) return self._sync_map_permissions def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class SyncMapInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, payload, service_sid, sid=None): """ Initialize the SyncMapInstance :returns: twilio.rest.sync.v1.service.sync_map.SyncMapInstance :rtype: twilio.rest.sync.v1.service.sync_map.SyncMapInstance """ super(SyncMapInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'unique_name': payload['unique_name'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'url': payload['url'], 'links': payload['links'], 'revision': payload['revision'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'created_by': payload['created_by'], } # Context self._context = None self._solution = {'service_sid': service_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.sync.v1.service.sync_map.SyncMapContext """ if self._context is None: self._context = SyncMapContext( self._version, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def unique_name(self): """ :returns: The unique_name :rtype: unicode """ return self._properties['unique_name'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] @property def revision(self): """ :returns: The revision :rtype: unicode """ return self._properties['revision'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def created_by(self): """ :returns: The created_by :rtype: unicode """ return self._properties['created_by'] def fetch(self): """ Fetch a SyncMapInstance :returns: Fetched SyncMapInstance :rtype: twilio.rest.sync.v1.service.sync_map.SyncMapInstance """ return self._proxy.fetch() def delete(self): """ Deletes the SyncMapInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() @property def sync_map_items(self): """ Access the sync_map_items :returns: twilio.rest.sync.v1.service.sync_map.sync_map_item.SyncMapItemList :rtype: twilio.rest.sync.v1.service.sync_map.sync_map_item.SyncMapItemList """ return self._proxy.sync_map_items @property def sync_map_permissions(self): """ Access the sync_map_permissions :returns: twilio.rest.sync.v1.service.sync_map.sync_map_permission.SyncMapPermissionList :rtype: twilio.rest.sync.v1.service.sync_map.sync_map_permission.SyncMapPermissionList """ return self._proxy.sync_map_permissions def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/sync/v1/service/sync_map/sync_map_item.py000066400000000000000000000411641317472742600266400ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize 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.page import Page class SyncMapItemList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid, map_sid): """ Initialize the SyncMapItemList :param Version version: Version that contains the resource :param service_sid: The service_sid :param map_sid: The map_sid :returns: twilio.rest.sync.v1.service.sync_map.sync_map_item.SyncMapItemList :rtype: twilio.rest.sync.v1.service.sync_map.sync_map_item.SyncMapItemList """ super(SyncMapItemList, self).__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, data): """ Create a new SyncMapItemInstance :param unicode key: The key :param dict data: The data :returns: Newly created SyncMapItemInstance :rtype: twilio.rest.sync.v1.service.sync_map.sync_map_item.SyncMapItemInstance """ data = values.of({'Key': key, 'Data': serialize.object(data),}) payload = self._version.create( 'POST', 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=values.unset, from_=values.unset, bounds=values.unset, limit=None, page_size=None): """ 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: The order :param unicode from_: The from :param SyncMapItemInstance.QueryFromBoundType bounds: The bounds :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.sync.v1.service.sync_map.sync_map_item.SyncMapItemInstance] """ 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'], limits['page_limit']) def list(self, order=values.unset, from_=values.unset, bounds=values.unset, limit=None, page_size=None): """ 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: The order :param unicode from_: The from :param SyncMapItemInstance.QueryFromBoundType bounds: The bounds :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.sync.v1.service.sync_map.sync_map_item.SyncMapItemInstance] """ return list(self.stream(order=order, from_=from_, bounds=bounds, limit=limit, page_size=page_size,)) def page(self, order=values.unset, from_=values.unset, bounds=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of SyncMapItemInstance records from the API. Request is executed immediately :param SyncMapItemInstance.QueryResultOrder order: The order :param unicode from_: The from :param SyncMapItemInstance.QueryFromBoundType bounds: The bounds :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of SyncMapItemInstance :rtype: twilio.rest.sync.v1.service.sync_map.sync_map_item.SyncMapItemPage """ params = values.of({ 'Order': order, 'From': from_, 'Bounds': bounds, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return SyncMapItemPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of SyncMapItemInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of SyncMapItemInstance :rtype: twilio.rest.sync.v1.service.sync_map.sync_map_item.SyncMapItemPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return SyncMapItemPage(self._version, response, self._solution) def get(self, key): """ Constructs a SyncMapItemContext :param key: The key :returns: twilio.rest.sync.v1.service.sync_map.sync_map_item.SyncMapItemContext :rtype: twilio.rest.sync.v1.service.sync_map.sync_map_item.SyncMapItemContext """ return SyncMapItemContext( self._version, service_sid=self._solution['service_sid'], map_sid=self._solution['map_sid'], key=key, ) def __call__(self, key): """ Constructs a SyncMapItemContext :param key: The key :returns: twilio.rest.sync.v1.service.sync_map.sync_map_item.SyncMapItemContext :rtype: twilio.rest.sync.v1.service.sync_map.sync_map_item.SyncMapItemContext """ return SyncMapItemContext( self._version, service_sid=self._solution['service_sid'], map_sid=self._solution['map_sid'], key=key, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SyncMapItemPage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the SyncMapItemPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: The service_sid :param map_sid: The map_sid :returns: twilio.rest.sync.v1.service.sync_map.sync_map_item.SyncMapItemPage :rtype: twilio.rest.sync.v1.service.sync_map.sync_map_item.SyncMapItemPage """ super(SyncMapItemPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of SyncMapItemInstance :param dict payload: Payload response from the API :returns: twilio.rest.sync.v1.service.sync_map.sync_map_item.SyncMapItemInstance :rtype: twilio.rest.sync.v1.service.sync_map.sync_map_item.SyncMapItemInstance """ return SyncMapItemInstance( self._version, payload, service_sid=self._solution['service_sid'], map_sid=self._solution['map_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SyncMapItemContext(InstanceContext): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid, map_sid, key): """ Initialize the SyncMapItemContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param map_sid: The map_sid :param key: The key :returns: twilio.rest.sync.v1.service.sync_map.sync_map_item.SyncMapItemContext :rtype: twilio.rest.sync.v1.service.sync_map.sync_map_item.SyncMapItemContext """ super(SyncMapItemContext, self).__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 fetch(self): """ Fetch a SyncMapItemInstance :returns: Fetched SyncMapItemInstance :rtype: twilio.rest.sync.v1.service.sync_map.sync_map_item.SyncMapItemInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return SyncMapItemInstance( self._version, payload, service_sid=self._solution['service_sid'], map_sid=self._solution['map_sid'], key=self._solution['key'], ) def delete(self): """ Deletes the SyncMapItemInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, data): """ Update the SyncMapItemInstance :param dict data: The data :returns: Updated SyncMapItemInstance :rtype: twilio.rest.sync.v1.service.sync_map.sync_map_item.SyncMapItemInstance """ data = values.of({'Data': serialize.object(data),}) payload = self._version.update( 'POST', self._uri, data=data, ) return SyncMapItemInstance( self._version, payload, service_sid=self._solution['service_sid'], map_sid=self._solution['map_sid'], key=self._solution['key'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class SyncMapItemInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ class QueryResultOrder(object): ASC = "asc" DESC = "desc" class QueryFromBoundType(object): INCLUSIVE = "inclusive" EXCLUSIVE = "exclusive" def __init__(self, version, payload, service_sid, map_sid, key=None): """ Initialize the SyncMapItemInstance :returns: twilio.rest.sync.v1.service.sync_map.sync_map_item.SyncMapItemInstance :rtype: twilio.rest.sync.v1.service.sync_map.sync_map_item.SyncMapItemInstance """ super(SyncMapItemInstance, self).__init__(version) # Marshaled Properties self._properties = { 'key': payload['key'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'map_sid': payload['map_sid'], 'url': payload['url'], 'revision': payload['revision'], 'data': payload['data'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'created_by': payload['created_by'], } # Context self._context = None self._solution = { 'service_sid': service_sid, 'map_sid': map_sid, 'key': key or self._properties['key'], } @property def _proxy(self): """ 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 :rtype: twilio.rest.sync.v1.service.sync_map.sync_map_item.SyncMapItemContext """ 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 @property def key(self): """ :returns: The key :rtype: unicode """ return self._properties['key'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: The service_sid :rtype: unicode """ return self._properties['service_sid'] @property def map_sid(self): """ :returns: The map_sid :rtype: unicode """ return self._properties['map_sid'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def revision(self): """ :returns: The revision :rtype: unicode """ return self._properties['revision'] @property def data(self): """ :returns: The data :rtype: dict """ return self._properties['data'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def created_by(self): """ :returns: The created_by :rtype: unicode """ return self._properties['created_by'] def fetch(self): """ Fetch a SyncMapItemInstance :returns: Fetched SyncMapItemInstance :rtype: twilio.rest.sync.v1.service.sync_map.sync_map_item.SyncMapItemInstance """ return self._proxy.fetch() def delete(self): """ Deletes the SyncMapItemInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, data): """ Update the SyncMapItemInstance :param dict data: The data :returns: Updated SyncMapItemInstance :rtype: twilio.rest.sync.v1.service.sync_map.sync_map_item.SyncMapItemInstance """ return self._proxy.update(data,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/sync/v1/service/sync_map/sync_map_permission.py000066400000000000000000000366311317472742600300750ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ 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.page import Page class SyncMapPermissionList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid, map_sid): """ Initialize the SyncMapPermissionList :param Version version: Version that contains the resource :param service_sid: Sync Service Instance SID. :param map_sid: Sync Map SID. :returns: twilio.rest.sync.v1.service.sync_map.sync_map_permission.SyncMapPermissionList :rtype: twilio.rest.sync.v1.service.sync_map.sync_map_permission.SyncMapPermissionList """ super(SyncMapPermissionList, self).__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=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.sync.v1.service.sync_map.sync_map_permission.SyncMapPermissionInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ 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 int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.sync.v1.service.sync_map.sync_map_permission.SyncMapPermissionInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of SyncMapPermissionInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of SyncMapPermissionInstance :rtype: twilio.rest.sync.v1.service.sync_map.sync_map_permission.SyncMapPermissionPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return SyncMapPermissionPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of SyncMapPermissionInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of SyncMapPermissionInstance :rtype: twilio.rest.sync.v1.service.sync_map.sync_map_permission.SyncMapPermissionPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return SyncMapPermissionPage(self._version, response, self._solution) def get(self, identity): """ Constructs a SyncMapPermissionContext :param identity: Identity of the user to whom the Sync Map Permission applies. :returns: twilio.rest.sync.v1.service.sync_map.sync_map_permission.SyncMapPermissionContext :rtype: twilio.rest.sync.v1.service.sync_map.sync_map_permission.SyncMapPermissionContext """ return SyncMapPermissionContext( self._version, service_sid=self._solution['service_sid'], map_sid=self._solution['map_sid'], identity=identity, ) def __call__(self, identity): """ Constructs a SyncMapPermissionContext :param identity: Identity of the user to whom the Sync Map Permission applies. :returns: twilio.rest.sync.v1.service.sync_map.sync_map_permission.SyncMapPermissionContext :rtype: twilio.rest.sync.v1.service.sync_map.sync_map_permission.SyncMapPermissionContext """ return SyncMapPermissionContext( self._version, service_sid=self._solution['service_sid'], map_sid=self._solution['map_sid'], identity=identity, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SyncMapPermissionPage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the SyncMapPermissionPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: Sync Service Instance SID. :param map_sid: Sync Map SID. :returns: twilio.rest.sync.v1.service.sync_map.sync_map_permission.SyncMapPermissionPage :rtype: twilio.rest.sync.v1.service.sync_map.sync_map_permission.SyncMapPermissionPage """ super(SyncMapPermissionPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of SyncMapPermissionInstance :param dict payload: Payload response from the API :returns: twilio.rest.sync.v1.service.sync_map.sync_map_permission.SyncMapPermissionInstance :rtype: twilio.rest.sync.v1.service.sync_map.sync_map_permission.SyncMapPermissionInstance """ return SyncMapPermissionInstance( self._version, payload, service_sid=self._solution['service_sid'], map_sid=self._solution['map_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SyncMapPermissionContext(InstanceContext): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid, map_sid, identity): """ Initialize the SyncMapPermissionContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param map_sid: Sync Map SID or unique name. :param identity: Identity of the user to whom the Sync Map Permission applies. :returns: twilio.rest.sync.v1.service.sync_map.sync_map_permission.SyncMapPermissionContext :rtype: twilio.rest.sync.v1.service.sync_map.sync_map_permission.SyncMapPermissionContext """ super(SyncMapPermissionContext, self).__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 fetch(self): """ Fetch a SyncMapPermissionInstance :returns: Fetched SyncMapPermissionInstance :rtype: twilio.rest.sync.v1.service.sync_map.sync_map_permission.SyncMapPermissionInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return SyncMapPermissionInstance( self._version, payload, service_sid=self._solution['service_sid'], map_sid=self._solution['map_sid'], identity=self._solution['identity'], ) def delete(self): """ Deletes the SyncMapPermissionInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, read, write, manage): """ Update the SyncMapPermissionInstance :param bool read: Read access. :param bool write: Write access. :param bool manage: Manage access. :returns: Updated SyncMapPermissionInstance :rtype: twilio.rest.sync.v1.service.sync_map.sync_map_permission.SyncMapPermissionInstance """ data = values.of({'Read': read, 'Write': write, 'Manage': manage,}) payload = self._version.update( 'POST', 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): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class SyncMapPermissionInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, payload, service_sid, map_sid, identity=None): """ Initialize the SyncMapPermissionInstance :returns: twilio.rest.sync.v1.service.sync_map.sync_map_permission.SyncMapPermissionInstance :rtype: twilio.rest.sync.v1.service.sync_map.sync_map_permission.SyncMapPermissionInstance """ super(SyncMapPermissionInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'map_sid': payload['map_sid'], 'identity': payload['identity'], 'read': payload['read'], 'write': payload['write'], 'manage': payload['manage'], 'url': payload['url'], } # Context self._context = None self._solution = { 'service_sid': service_sid, 'map_sid': map_sid, 'identity': identity or self._properties['identity'], } @property def _proxy(self): """ 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 :rtype: twilio.rest.sync.v1.service.sync_map.sync_map_permission.SyncMapPermissionContext """ 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 @property def account_sid(self): """ :returns: Twilio Account SID. :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: Sync Service Instance SID. :rtype: unicode """ return self._properties['service_sid'] @property def map_sid(self): """ :returns: Sync Map SID. :rtype: unicode """ return self._properties['map_sid'] @property def identity(self): """ :returns: Identity of the user to whom the Sync Map Permission applies. :rtype: unicode """ return self._properties['identity'] @property def read(self): """ :returns: Read access. :rtype: bool """ return self._properties['read'] @property def write(self): """ :returns: Write access. :rtype: bool """ return self._properties['write'] @property def manage(self): """ :returns: Manage access. :rtype: bool """ return self._properties['manage'] @property def url(self): """ :returns: URL of this Sync Map Permission. :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a SyncMapPermissionInstance :returns: Fetched SyncMapPermissionInstance :rtype: twilio.rest.sync.v1.service.sync_map.sync_map_permission.SyncMapPermissionInstance """ return self._proxy.fetch() def delete(self): """ Deletes the SyncMapPermissionInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, read, write, manage): """ Update the SyncMapPermissionInstance :param bool read: Read access. :param bool write: Write access. :param bool manage: Manage access. :returns: Updated SyncMapPermissionInstance :rtype: twilio.rest.sync.v1.service.sync_map.sync_map_permission.SyncMapPermissionInstance """ return self._proxy.update(read, write, manage,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/sync/v1/service/sync_stream/000077500000000000000000000000001317472742600241475ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/sync/v1/service/sync_stream/__init__.py000066400000000000000000000347271317472742600262750ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.sync.v1.service.sync_stream.stream_message import StreamMessageList class SyncStreamList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid): """ Initialize the SyncStreamList :param Version version: Version that contains the resource :param service_sid: Service Instance SID. :returns: twilio.rest.sync.v1.service.sync_stream.SyncStreamList :rtype: twilio.rest.sync.v1.service.sync_stream.SyncStreamList """ super(SyncStreamList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid,} self._uri = '/Services/{service_sid}/Streams'.format(**self._solution) def create(self, unique_name=values.unset): """ Create a new SyncStreamInstance :param unicode unique_name: Stream unique name. :returns: Newly created SyncStreamInstance :rtype: twilio.rest.sync.v1.service.sync_stream.SyncStreamInstance """ data = values.of({'UniqueName': unique_name,}) payload = self._version.create( 'POST', self._uri, data=data, ) return SyncStreamInstance(self._version, payload, service_sid=self._solution['service_sid'],) def stream(self, limit=None, page_size=None): """ Streams SyncStreamInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.sync.v1.service.sync_stream.SyncStreamInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists SyncStreamInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.sync.v1.service.sync_stream.SyncStreamInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of SyncStreamInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of SyncStreamInstance :rtype: twilio.rest.sync.v1.service.sync_stream.SyncStreamPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return SyncStreamPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of SyncStreamInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of SyncStreamInstance :rtype: twilio.rest.sync.v1.service.sync_stream.SyncStreamPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return SyncStreamPage(self._version, response, self._solution) def get(self, sid): """ Constructs a SyncStreamContext :param sid: Stream SID or unique name. :returns: twilio.rest.sync.v1.service.sync_stream.SyncStreamContext :rtype: twilio.rest.sync.v1.service.sync_stream.SyncStreamContext """ return SyncStreamContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __call__(self, sid): """ Constructs a SyncStreamContext :param sid: Stream SID or unique name. :returns: twilio.rest.sync.v1.service.sync_stream.SyncStreamContext :rtype: twilio.rest.sync.v1.service.sync_stream.SyncStreamContext """ return SyncStreamContext(self._version, service_sid=self._solution['service_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SyncStreamPage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the SyncStreamPage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: Service Instance SID. :returns: twilio.rest.sync.v1.service.sync_stream.SyncStreamPage :rtype: twilio.rest.sync.v1.service.sync_stream.SyncStreamPage """ super(SyncStreamPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of SyncStreamInstance :param dict payload: Payload response from the API :returns: twilio.rest.sync.v1.service.sync_stream.SyncStreamInstance :rtype: twilio.rest.sync.v1.service.sync_stream.SyncStreamInstance """ return SyncStreamInstance(self._version, payload, service_sid=self._solution['service_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SyncStreamContext(InstanceContext): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid, sid): """ Initialize the SyncStreamContext :param Version version: Version that contains the resource :param service_sid: The service_sid :param sid: Stream SID or unique name. :returns: twilio.rest.sync.v1.service.sync_stream.SyncStreamContext :rtype: twilio.rest.sync.v1.service.sync_stream.SyncStreamContext """ super(SyncStreamContext, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'sid': sid,} self._uri = '/Services/{service_sid}/Streams/{sid}'.format(**self._solution) # Dependents self._stream_messages = None def fetch(self): """ Fetch a SyncStreamInstance :returns: Fetched SyncStreamInstance :rtype: twilio.rest.sync.v1.service.sync_stream.SyncStreamInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return SyncStreamInstance( self._version, payload, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the SyncStreamInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) @property def stream_messages(self): """ Access the stream_messages :returns: twilio.rest.sync.v1.service.sync_stream.stream_message.StreamMessageList :rtype: twilio.rest.sync.v1.service.sync_stream.stream_message.StreamMessageList """ if self._stream_messages is None: self._stream_messages = StreamMessageList( self._version, service_sid=self._solution['service_sid'], stream_sid=self._solution['sid'], ) return self._stream_messages def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class SyncStreamInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, payload, service_sid, sid=None): """ Initialize the SyncStreamInstance :returns: twilio.rest.sync.v1.service.sync_stream.SyncStreamInstance :rtype: twilio.rest.sync.v1.service.sync_stream.SyncStreamInstance """ super(SyncStreamInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'unique_name': payload['unique_name'], 'account_sid': payload['account_sid'], 'service_sid': payload['service_sid'], 'url': payload['url'], 'links': payload['links'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'created_by': payload['created_by'], } # Context self._context = None self._solution = {'service_sid': service_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: SyncStreamContext for this SyncStreamInstance :rtype: twilio.rest.sync.v1.service.sync_stream.SyncStreamContext """ if self._context is None: self._context = SyncStreamContext( self._version, service_sid=self._solution['service_sid'], sid=self._solution['sid'], ) return self._context @property def sid(self): """ :returns: Stream SID. :rtype: unicode """ return self._properties['sid'] @property def unique_name(self): """ :returns: Stream unique name. :rtype: unicode """ return self._properties['unique_name'] @property def account_sid(self): """ :returns: Twilio Account SID. :rtype: unicode """ return self._properties['account_sid'] @property def service_sid(self): """ :returns: Service Instance SID. :rtype: unicode """ return self._properties['service_sid'] @property def url(self): """ :returns: URL of this Stream. :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: Nested resource URLs. :rtype: unicode """ return self._properties['links'] @property def date_created(self): """ :returns: The date this Stream was created. :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date this Stream was updated. :rtype: datetime """ return self._properties['date_updated'] @property def created_by(self): """ :returns: Identity of the Stream creator. :rtype: unicode """ return self._properties['created_by'] def fetch(self): """ Fetch a SyncStreamInstance :returns: Fetched SyncStreamInstance :rtype: twilio.rest.sync.v1.service.sync_stream.SyncStreamInstance """ return self._proxy.fetch() def delete(self): """ Deletes the SyncStreamInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() @property def stream_messages(self): """ Access the stream_messages :returns: twilio.rest.sync.v1.service.sync_stream.stream_message.StreamMessageList :rtype: twilio.rest.sync.v1.service.sync_stream.stream_message.StreamMessageList """ return self._proxy.stream_messages def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/sync/v1/service/sync_stream/stream_message.py000066400000000000000000000116101317472742600275170ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import serialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class StreamMessageList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, service_sid, stream_sid): """ Initialize the StreamMessageList :param Version version: Version that contains the resource :param service_sid: Service Instance SID. :param stream_sid: Stream SID. :returns: twilio.rest.sync.v1.service.sync_stream.stream_message.StreamMessageList :rtype: twilio.rest.sync.v1.service.sync_stream.stream_message.StreamMessageList """ super(StreamMessageList, self).__init__(version) # Path Solution self._solution = {'service_sid': service_sid, 'stream_sid': stream_sid,} self._uri = '/Services/{service_sid}/Streams/{stream_sid}/Messages'.format(**self._solution) def create(self, data): """ Create a new StreamMessageInstance :param dict data: Stream Message body. :returns: Newly created StreamMessageInstance :rtype: twilio.rest.sync.v1.service.sync_stream.stream_message.StreamMessageInstance """ data = values.of({'Data': serialize.object(data),}) payload = self._version.create( 'POST', self._uri, data=data, ) return StreamMessageInstance( self._version, payload, service_sid=self._solution['service_sid'], stream_sid=self._solution['stream_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class StreamMessagePage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the StreamMessagePage :param Version version: Version that contains the resource :param Response response: Response from the API :param service_sid: Service Instance SID. :param stream_sid: Stream SID. :returns: twilio.rest.sync.v1.service.sync_stream.stream_message.StreamMessagePage :rtype: twilio.rest.sync.v1.service.sync_stream.stream_message.StreamMessagePage """ super(StreamMessagePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of StreamMessageInstance :param dict payload: Payload response from the API :returns: twilio.rest.sync.v1.service.sync_stream.stream_message.StreamMessageInstance :rtype: twilio.rest.sync.v1.service.sync_stream.stream_message.StreamMessageInstance """ return StreamMessageInstance( self._version, payload, service_sid=self._solution['service_sid'], stream_sid=self._solution['stream_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class StreamMessageInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, payload, service_sid, stream_sid): """ Initialize the StreamMessageInstance :returns: twilio.rest.sync.v1.service.sync_stream.stream_message.StreamMessageInstance :rtype: twilio.rest.sync.v1.service.sync_stream.stream_message.StreamMessageInstance """ super(StreamMessageInstance, self).__init__(version) # Marshaled Properties self._properties = {'sid': payload['sid'], 'data': payload['data'],} # Context self._context = None self._solution = {'service_sid': service_sid, 'stream_sid': stream_sid,} @property def sid(self): """ :returns: Stream Message SID. :rtype: unicode """ return self._properties['sid'] @property def data(self): """ :returns: Stream Message body. :rtype: dict """ return self._properties['data'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/taskrouter/000077500000000000000000000000001317472742600210615ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/taskrouter/__init__.py000066400000000000000000000022101317472742600231650ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.domain import Domain from twilio.rest.taskrouter.v1 import V1 class Taskrouter(Domain): def __init__(self, twilio): """ Initialize the Taskrouter Domain :returns: Domain for Taskrouter :rtype: twilio.rest.taskrouter.Taskrouter """ super(Taskrouter, self).__init__(twilio) self.base_url = 'https://taskrouter.twilio.com' # Versions self._v1 = None @property def v1(self): """ :returns: Version v1 of taskrouter :rtype: twilio.rest.taskrouter.v1.V1 """ if self._v1 is None: self._v1 = V1(self) return self._v1 @property def workspaces(self): """ :rtype: twilio.rest.taskrouter.v1.workspace.WorkspaceList """ return self.v1.workspaces def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/taskrouter/v1/000077500000000000000000000000001317472742600214075ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/taskrouter/v1/__init__.py000066400000000000000000000017421317472742600235240ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.version import Version from twilio.rest.taskrouter.v1.workspace import WorkspaceList class V1(Version): def __init__(self, domain): """ Initialize the V1 version of Taskrouter :returns: V1 version of Taskrouter :rtype: twilio.rest.taskrouter.v1.V1.V1 """ super(V1, self).__init__(domain) self.version = 'v1' self._workspaces = None @property def workspaces(self): """ :rtype: twilio.rest.taskrouter.v1.workspace.WorkspaceList """ if self._workspaces is None: self._workspaces = WorkspaceList(self) return self._workspaces def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/taskrouter/v1/workspace/000077500000000000000000000000001317472742600234055ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/taskrouter/v1/workspace/__init__.py000066400000000000000000000645521317472742600255320ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.taskrouter.v1.workspace.activity import ActivityList from twilio.rest.taskrouter.v1.workspace.event import EventList from twilio.rest.taskrouter.v1.workspace.task import TaskList from twilio.rest.taskrouter.v1.workspace.task_channel import TaskChannelList from twilio.rest.taskrouter.v1.workspace.task_queue import TaskQueueList from twilio.rest.taskrouter.v1.workspace.worker import WorkerList from twilio.rest.taskrouter.v1.workspace.workflow import WorkflowList from twilio.rest.taskrouter.v1.workspace.workspace_cumulative_statistics import WorkspaceCumulativeStatisticsList from twilio.rest.taskrouter.v1.workspace.workspace_real_time_statistics import WorkspaceRealTimeStatisticsList from twilio.rest.taskrouter.v1.workspace.workspace_statistics import WorkspaceStatisticsList class WorkspaceList(ListResource): """ """ def __init__(self, version): """ Initialize the WorkspaceList :param Version version: Version that contains the resource :returns: twilio.rest.taskrouter.v1.workspace.WorkspaceList :rtype: twilio.rest.taskrouter.v1.workspace.WorkspaceList """ super(WorkspaceList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/Workspaces'.format(**self._solution) def stream(self, friendly_name=values.unset, limit=None, page_size=None): """ Streams WorkspaceInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param unicode friendly_name: The friendly_name :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.taskrouter.v1.workspace.WorkspaceInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(friendly_name=friendly_name, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, friendly_name=values.unset, limit=None, page_size=None): """ Lists WorkspaceInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param unicode friendly_name: The friendly_name :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.taskrouter.v1.workspace.WorkspaceInstance] """ return list(self.stream(friendly_name=friendly_name, limit=limit, page_size=page_size,)) def page(self, friendly_name=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of WorkspaceInstance records from the API. Request is executed immediately :param unicode friendly_name: The friendly_name :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of WorkspaceInstance :rtype: twilio.rest.taskrouter.v1.workspace.WorkspacePage """ params = values.of({ 'FriendlyName': friendly_name, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return WorkspacePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of WorkspaceInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of WorkspaceInstance :rtype: twilio.rest.taskrouter.v1.workspace.WorkspacePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return WorkspacePage(self._version, response, self._solution) def create(self, friendly_name, event_callback_url=values.unset, events_filter=values.unset, multi_task_enabled=values.unset, template=values.unset, prioritize_queue_order=values.unset): """ Create a new WorkspaceInstance :param unicode friendly_name: The friendly_name :param unicode event_callback_url: The event_callback_url :param unicode events_filter: The events_filter :param bool multi_task_enabled: The multi_task_enabled :param unicode template: The template :param WorkspaceInstance.QueueOrder prioritize_queue_order: The prioritize_queue_order :returns: Newly created WorkspaceInstance :rtype: twilio.rest.taskrouter.v1.workspace.WorkspaceInstance """ data = values.of({ 'FriendlyName': friendly_name, 'EventCallbackUrl': event_callback_url, 'EventsFilter': events_filter, 'MultiTaskEnabled': multi_task_enabled, 'Template': template, 'PrioritizeQueueOrder': prioritize_queue_order, }) payload = self._version.create( 'POST', self._uri, data=data, ) return WorkspaceInstance(self._version, payload,) def get(self, sid): """ Constructs a WorkspaceContext :param sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.WorkspaceContext :rtype: twilio.rest.taskrouter.v1.workspace.WorkspaceContext """ return WorkspaceContext(self._version, sid=sid,) def __call__(self, sid): """ Constructs a WorkspaceContext :param sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.WorkspaceContext :rtype: twilio.rest.taskrouter.v1.workspace.WorkspaceContext """ return WorkspaceContext(self._version, sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class WorkspacePage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the WorkspacePage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.taskrouter.v1.workspace.WorkspacePage :rtype: twilio.rest.taskrouter.v1.workspace.WorkspacePage """ super(WorkspacePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of WorkspaceInstance :param dict payload: Payload response from the API :returns: twilio.rest.taskrouter.v1.workspace.WorkspaceInstance :rtype: twilio.rest.taskrouter.v1.workspace.WorkspaceInstance """ return WorkspaceInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class WorkspaceContext(InstanceContext): """ """ def __init__(self, version, sid): """ Initialize the WorkspaceContext :param Version version: Version that contains the resource :param sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.WorkspaceContext :rtype: twilio.rest.taskrouter.v1.workspace.WorkspaceContext """ super(WorkspaceContext, self).__init__(version) # Path Solution self._solution = {'sid': sid,} self._uri = '/Workspaces/{sid}'.format(**self._solution) # Dependents self._activities = None self._events = None self._tasks = None self._task_queues = None self._workers = None self._workflows = None self._statistics = None self._real_time_statistics = None self._cumulative_statistics = None self._task_channels = None def fetch(self): """ Fetch a WorkspaceInstance :returns: Fetched WorkspaceInstance :rtype: twilio.rest.taskrouter.v1.workspace.WorkspaceInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return WorkspaceInstance(self._version, payload, sid=self._solution['sid'],) def update(self, default_activity_sid=values.unset, event_callback_url=values.unset, events_filter=values.unset, friendly_name=values.unset, multi_task_enabled=values.unset, timeout_activity_sid=values.unset, prioritize_queue_order=values.unset): """ Update the WorkspaceInstance :param unicode default_activity_sid: The default_activity_sid :param unicode event_callback_url: The event_callback_url :param unicode events_filter: The events_filter :param unicode friendly_name: The friendly_name :param bool multi_task_enabled: The multi_task_enabled :param unicode timeout_activity_sid: The timeout_activity_sid :param WorkspaceInstance.QueueOrder prioritize_queue_order: The prioritize_queue_order :returns: Updated WorkspaceInstance :rtype: twilio.rest.taskrouter.v1.workspace.WorkspaceInstance """ data = values.of({ 'DefaultActivitySid': default_activity_sid, 'EventCallbackUrl': event_callback_url, 'EventsFilter': events_filter, 'FriendlyName': friendly_name, 'MultiTaskEnabled': multi_task_enabled, 'TimeoutActivitySid': timeout_activity_sid, 'PrioritizeQueueOrder': prioritize_queue_order, }) payload = self._version.update( 'POST', self._uri, data=data, ) return WorkspaceInstance(self._version, payload, sid=self._solution['sid'],) def delete(self): """ Deletes the WorkspaceInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) @property def activities(self): """ Access the activities :returns: twilio.rest.taskrouter.v1.workspace.activity.ActivityList :rtype: twilio.rest.taskrouter.v1.workspace.activity.ActivityList """ if self._activities is None: self._activities = ActivityList(self._version, workspace_sid=self._solution['sid'],) return self._activities @property def events(self): """ Access the events :returns: twilio.rest.taskrouter.v1.workspace.event.EventList :rtype: twilio.rest.taskrouter.v1.workspace.event.EventList """ if self._events is None: self._events = EventList(self._version, workspace_sid=self._solution['sid'],) return self._events @property def tasks(self): """ Access the tasks :returns: twilio.rest.taskrouter.v1.workspace.task.TaskList :rtype: twilio.rest.taskrouter.v1.workspace.task.TaskList """ if self._tasks is None: self._tasks = TaskList(self._version, workspace_sid=self._solution['sid'],) return self._tasks @property def task_queues(self): """ Access the task_queues :returns: twilio.rest.taskrouter.v1.workspace.task_queue.TaskQueueList :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.TaskQueueList """ if self._task_queues is None: self._task_queues = TaskQueueList(self._version, workspace_sid=self._solution['sid'],) return self._task_queues @property def workers(self): """ Access the workers :returns: twilio.rest.taskrouter.v1.workspace.worker.WorkerList :rtype: twilio.rest.taskrouter.v1.workspace.worker.WorkerList """ if self._workers is None: self._workers = WorkerList(self._version, workspace_sid=self._solution['sid'],) return self._workers @property def workflows(self): """ Access the workflows :returns: twilio.rest.taskrouter.v1.workspace.workflow.WorkflowList :rtype: twilio.rest.taskrouter.v1.workspace.workflow.WorkflowList """ if self._workflows is None: self._workflows = WorkflowList(self._version, workspace_sid=self._solution['sid'],) return self._workflows @property def statistics(self): """ Access the statistics :returns: twilio.rest.taskrouter.v1.workspace.workspace_statistics.WorkspaceStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.workspace_statistics.WorkspaceStatisticsList """ if self._statistics is None: self._statistics = WorkspaceStatisticsList(self._version, workspace_sid=self._solution['sid'],) return self._statistics @property def real_time_statistics(self): """ Access the real_time_statistics :returns: twilio.rest.taskrouter.v1.workspace.workspace_real_time_statistics.WorkspaceRealTimeStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.workspace_real_time_statistics.WorkspaceRealTimeStatisticsList """ if self._real_time_statistics is None: self._real_time_statistics = WorkspaceRealTimeStatisticsList( self._version, workspace_sid=self._solution['sid'], ) return self._real_time_statistics @property def cumulative_statistics(self): """ Access the cumulative_statistics :returns: twilio.rest.taskrouter.v1.workspace.workspace_cumulative_statistics.WorkspaceCumulativeStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.workspace_cumulative_statistics.WorkspaceCumulativeStatisticsList """ if self._cumulative_statistics is None: self._cumulative_statistics = WorkspaceCumulativeStatisticsList( self._version, workspace_sid=self._solution['sid'], ) return self._cumulative_statistics @property def task_channels(self): """ Access the task_channels :returns: twilio.rest.taskrouter.v1.workspace.task_channel.TaskChannelList :rtype: twilio.rest.taskrouter.v1.workspace.task_channel.TaskChannelList """ if self._task_channels is None: self._task_channels = TaskChannelList(self._version, workspace_sid=self._solution['sid'],) return self._task_channels def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class WorkspaceInstance(InstanceResource): """ """ class QueueOrder(object): FIFO = "FIFO" LIFO = "LIFO" def __init__(self, version, payload, sid=None): """ Initialize the WorkspaceInstance :returns: twilio.rest.taskrouter.v1.workspace.WorkspaceInstance :rtype: twilio.rest.taskrouter.v1.workspace.WorkspaceInstance """ super(WorkspaceInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'default_activity_name': payload['default_activity_name'], 'default_activity_sid': payload['default_activity_sid'], 'event_callback_url': payload['event_callback_url'], 'events_filter': payload['events_filter'], 'friendly_name': payload['friendly_name'], 'multi_task_enabled': payload['multi_task_enabled'], 'sid': payload['sid'], 'timeout_activity_name': payload['timeout_activity_name'], 'timeout_activity_sid': payload['timeout_activity_sid'], 'prioritize_queue_order': payload['prioritize_queue_order'], 'url': payload['url'], 'links': payload['links'], } # Context self._context = None self._solution = {'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: WorkspaceContext for this WorkspaceInstance :rtype: twilio.rest.taskrouter.v1.workspace.WorkspaceContext """ if self._context is None: self._context = WorkspaceContext(self._version, sid=self._solution['sid'],) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def default_activity_name(self): """ :returns: The default_activity_name :rtype: unicode """ return self._properties['default_activity_name'] @property def default_activity_sid(self): """ :returns: The default_activity_sid :rtype: unicode """ return self._properties['default_activity_sid'] @property def event_callback_url(self): """ :returns: The event_callback_url :rtype: unicode """ return self._properties['event_callback_url'] @property def events_filter(self): """ :returns: The events_filter :rtype: unicode """ return self._properties['events_filter'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def multi_task_enabled(self): """ :returns: The multi_task_enabled :rtype: bool """ return self._properties['multi_task_enabled'] @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def timeout_activity_name(self): """ :returns: The timeout_activity_name :rtype: unicode """ return self._properties['timeout_activity_name'] @property def timeout_activity_sid(self): """ :returns: The timeout_activity_sid :rtype: unicode """ return self._properties['timeout_activity_sid'] @property def prioritize_queue_order(self): """ :returns: The prioritize_queue_order :rtype: WorkspaceInstance.QueueOrder """ return self._properties['prioritize_queue_order'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a WorkspaceInstance :returns: Fetched WorkspaceInstance :rtype: twilio.rest.taskrouter.v1.workspace.WorkspaceInstance """ return self._proxy.fetch() def update(self, default_activity_sid=values.unset, event_callback_url=values.unset, events_filter=values.unset, friendly_name=values.unset, multi_task_enabled=values.unset, timeout_activity_sid=values.unset, prioritize_queue_order=values.unset): """ Update the WorkspaceInstance :param unicode default_activity_sid: The default_activity_sid :param unicode event_callback_url: The event_callback_url :param unicode events_filter: The events_filter :param unicode friendly_name: The friendly_name :param bool multi_task_enabled: The multi_task_enabled :param unicode timeout_activity_sid: The timeout_activity_sid :param WorkspaceInstance.QueueOrder prioritize_queue_order: The prioritize_queue_order :returns: Updated WorkspaceInstance :rtype: twilio.rest.taskrouter.v1.workspace.WorkspaceInstance """ return self._proxy.update( default_activity_sid=default_activity_sid, event_callback_url=event_callback_url, events_filter=events_filter, friendly_name=friendly_name, multi_task_enabled=multi_task_enabled, timeout_activity_sid=timeout_activity_sid, prioritize_queue_order=prioritize_queue_order, ) def delete(self): """ Deletes the WorkspaceInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() @property def activities(self): """ Access the activities :returns: twilio.rest.taskrouter.v1.workspace.activity.ActivityList :rtype: twilio.rest.taskrouter.v1.workspace.activity.ActivityList """ return self._proxy.activities @property def events(self): """ Access the events :returns: twilio.rest.taskrouter.v1.workspace.event.EventList :rtype: twilio.rest.taskrouter.v1.workspace.event.EventList """ return self._proxy.events @property def tasks(self): """ Access the tasks :returns: twilio.rest.taskrouter.v1.workspace.task.TaskList :rtype: twilio.rest.taskrouter.v1.workspace.task.TaskList """ return self._proxy.tasks @property def task_queues(self): """ Access the task_queues :returns: twilio.rest.taskrouter.v1.workspace.task_queue.TaskQueueList :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.TaskQueueList """ return self._proxy.task_queues @property def workers(self): """ Access the workers :returns: twilio.rest.taskrouter.v1.workspace.worker.WorkerList :rtype: twilio.rest.taskrouter.v1.workspace.worker.WorkerList """ return self._proxy.workers @property def workflows(self): """ Access the workflows :returns: twilio.rest.taskrouter.v1.workspace.workflow.WorkflowList :rtype: twilio.rest.taskrouter.v1.workspace.workflow.WorkflowList """ return self._proxy.workflows @property def statistics(self): """ Access the statistics :returns: twilio.rest.taskrouter.v1.workspace.workspace_statistics.WorkspaceStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.workspace_statistics.WorkspaceStatisticsList """ return self._proxy.statistics @property def real_time_statistics(self): """ Access the real_time_statistics :returns: twilio.rest.taskrouter.v1.workspace.workspace_real_time_statistics.WorkspaceRealTimeStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.workspace_real_time_statistics.WorkspaceRealTimeStatisticsList """ return self._proxy.real_time_statistics @property def cumulative_statistics(self): """ Access the cumulative_statistics :returns: twilio.rest.taskrouter.v1.workspace.workspace_cumulative_statistics.WorkspaceCumulativeStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.workspace_cumulative_statistics.WorkspaceCumulativeStatisticsList """ return self._proxy.cumulative_statistics @property def task_channels(self): """ Access the task_channels :returns: twilio.rest.taskrouter.v1.workspace.task_channel.TaskChannelList :rtype: twilio.rest.taskrouter.v1.workspace.task_channel.TaskChannelList """ return self._proxy.task_channels def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/taskrouter/v1/workspace/activity.py000066400000000000000000000351561317472742600256250ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class ActivityList(ListResource): """ """ def __init__(self, version, workspace_sid): """ Initialize the ActivityList :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :returns: twilio.rest.taskrouter.v1.workspace.activity.ActivityList :rtype: twilio.rest.taskrouter.v1.workspace.activity.ActivityList """ super(ActivityList, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid,} self._uri = '/Workspaces/{workspace_sid}/Activities'.format(**self._solution) def stream(self, friendly_name=values.unset, available=values.unset, limit=None, page_size=None): """ Streams ActivityInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param unicode friendly_name: The friendly_name :param unicode available: The available :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.taskrouter.v1.workspace.activity.ActivityInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(friendly_name=friendly_name, available=available, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, friendly_name=values.unset, available=values.unset, limit=None, page_size=None): """ Lists ActivityInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param unicode friendly_name: The friendly_name :param unicode available: The available :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.taskrouter.v1.workspace.activity.ActivityInstance] """ return list(self.stream( friendly_name=friendly_name, available=available, limit=limit, page_size=page_size, )) def page(self, friendly_name=values.unset, available=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of ActivityInstance records from the API. Request is executed immediately :param unicode friendly_name: The friendly_name :param unicode available: The available :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of ActivityInstance :rtype: twilio.rest.taskrouter.v1.workspace.activity.ActivityPage """ params = values.of({ 'FriendlyName': friendly_name, 'Available': available, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return ActivityPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of ActivityInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of ActivityInstance :rtype: twilio.rest.taskrouter.v1.workspace.activity.ActivityPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return ActivityPage(self._version, response, self._solution) def create(self, friendly_name, available=values.unset): """ Create a new ActivityInstance :param unicode friendly_name: The friendly_name :param bool available: The available :returns: Newly created ActivityInstance :rtype: twilio.rest.taskrouter.v1.workspace.activity.ActivityInstance """ data = values.of({'FriendlyName': friendly_name, 'Available': available,}) payload = self._version.create( 'POST', self._uri, data=data, ) return ActivityInstance(self._version, payload, workspace_sid=self._solution['workspace_sid'],) def get(self, sid): """ Constructs a ActivityContext :param sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.activity.ActivityContext :rtype: twilio.rest.taskrouter.v1.workspace.activity.ActivityContext """ return ActivityContext(self._version, workspace_sid=self._solution['workspace_sid'], sid=sid,) def __call__(self, sid): """ Constructs a ActivityContext :param sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.activity.ActivityContext :rtype: twilio.rest.taskrouter.v1.workspace.activity.ActivityContext """ return ActivityContext(self._version, workspace_sid=self._solution['workspace_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ActivityPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the ActivityPage :param Version version: Version that contains the resource :param Response response: Response from the API :param workspace_sid: The workspace_sid :returns: twilio.rest.taskrouter.v1.workspace.activity.ActivityPage :rtype: twilio.rest.taskrouter.v1.workspace.activity.ActivityPage """ super(ActivityPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of ActivityInstance :param dict payload: Payload response from the API :returns: twilio.rest.taskrouter.v1.workspace.activity.ActivityInstance :rtype: twilio.rest.taskrouter.v1.workspace.activity.ActivityInstance """ return ActivityInstance(self._version, payload, workspace_sid=self._solution['workspace_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ActivityContext(InstanceContext): """ """ def __init__(self, version, workspace_sid, sid): """ Initialize the ActivityContext :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :param sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.activity.ActivityContext :rtype: twilio.rest.taskrouter.v1.workspace.activity.ActivityContext """ super(ActivityContext, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid, 'sid': sid,} self._uri = '/Workspaces/{workspace_sid}/Activities/{sid}'.format(**self._solution) def fetch(self): """ Fetch a ActivityInstance :returns: Fetched ActivityInstance :rtype: twilio.rest.taskrouter.v1.workspace.activity.ActivityInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return ActivityInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], sid=self._solution['sid'], ) def update(self, friendly_name=values.unset): """ Update the ActivityInstance :param unicode friendly_name: The friendly_name :returns: Updated ActivityInstance :rtype: twilio.rest.taskrouter.v1.workspace.activity.ActivityInstance """ data = values.of({'FriendlyName': friendly_name,}) payload = self._version.update( 'POST', self._uri, data=data, ) return ActivityInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the ActivityInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class ActivityInstance(InstanceResource): """ """ def __init__(self, version, payload, workspace_sid, sid=None): """ Initialize the ActivityInstance :returns: twilio.rest.taskrouter.v1.workspace.activity.ActivityInstance :rtype: twilio.rest.taskrouter.v1.workspace.activity.ActivityInstance """ super(ActivityInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'available': payload['available'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'friendly_name': payload['friendly_name'], 'sid': payload['sid'], 'workspace_sid': payload['workspace_sid'], 'url': payload['url'], } # Context self._context = None self._solution = {'workspace_sid': workspace_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: ActivityContext for this ActivityInstance :rtype: twilio.rest.taskrouter.v1.workspace.activity.ActivityContext """ if self._context is None: self._context = ActivityContext( self._version, workspace_sid=self._solution['workspace_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def available(self): """ :returns: The available :rtype: bool """ return self._properties['available'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def workspace_sid(self): """ :returns: The workspace_sid :rtype: unicode """ return self._properties['workspace_sid'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a ActivityInstance :returns: Fetched ActivityInstance :rtype: twilio.rest.taskrouter.v1.workspace.activity.ActivityInstance """ return self._proxy.fetch() def update(self, friendly_name=values.unset): """ Update the ActivityInstance :param unicode friendly_name: The friendly_name :returns: Updated ActivityInstance :rtype: twilio.rest.taskrouter.v1.workspace.activity.ActivityInstance """ return self._proxy.update(friendly_name=friendly_name,) def delete(self): """ Deletes the ActivityInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/taskrouter/v1/workspace/event.py000066400000000000000000000405031317472742600251020ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize 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.page import Page class EventList(ListResource): """ """ def __init__(self, version, workspace_sid): """ Initialize the EventList :param Version version: Version that contains the resource :param workspace_sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.event.EventList :rtype: twilio.rest.taskrouter.v1.workspace.event.EventList """ super(EventList, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid,} self._uri = '/Workspaces/{workspace_sid}/Events'.format(**self._solution) def stream(self, end_date=values.unset, event_type=values.unset, minutes=values.unset, reservation_sid=values.unset, start_date=values.unset, task_queue_sid=values.unset, task_sid=values.unset, worker_sid=values.unset, workflow_sid=values.unset, limit=None, page_size=None): """ Streams EventInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param datetime end_date: The end_date :param unicode event_type: The event_type :param unicode minutes: The minutes :param unicode reservation_sid: The reservation_sid :param datetime start_date: The start_date :param unicode task_queue_sid: The task_queue_sid :param unicode task_sid: The task_sid :param unicode worker_sid: The worker_sid :param unicode workflow_sid: The workflow_sid :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.taskrouter.v1.workspace.event.EventInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( end_date=end_date, event_type=event_type, minutes=minutes, reservation_sid=reservation_sid, start_date=start_date, task_queue_sid=task_queue_sid, task_sid=task_sid, worker_sid=worker_sid, workflow_sid=workflow_sid, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, end_date=values.unset, event_type=values.unset, minutes=values.unset, reservation_sid=values.unset, start_date=values.unset, task_queue_sid=values.unset, task_sid=values.unset, worker_sid=values.unset, workflow_sid=values.unset, limit=None, page_size=None): """ Lists EventInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param datetime end_date: The end_date :param unicode event_type: The event_type :param unicode minutes: The minutes :param unicode reservation_sid: The reservation_sid :param datetime start_date: The start_date :param unicode task_queue_sid: The task_queue_sid :param unicode task_sid: The task_sid :param unicode worker_sid: The worker_sid :param unicode workflow_sid: The workflow_sid :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.taskrouter.v1.workspace.event.EventInstance] """ return list(self.stream( end_date=end_date, event_type=event_type, minutes=minutes, reservation_sid=reservation_sid, start_date=start_date, task_queue_sid=task_queue_sid, task_sid=task_sid, worker_sid=worker_sid, workflow_sid=workflow_sid, limit=limit, page_size=page_size, )) def page(self, end_date=values.unset, event_type=values.unset, minutes=values.unset, reservation_sid=values.unset, start_date=values.unset, task_queue_sid=values.unset, task_sid=values.unset, worker_sid=values.unset, workflow_sid=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of EventInstance records from the API. Request is executed immediately :param datetime end_date: The end_date :param unicode event_type: The event_type :param unicode minutes: The minutes :param unicode reservation_sid: The reservation_sid :param datetime start_date: The start_date :param unicode task_queue_sid: The task_queue_sid :param unicode task_sid: The task_sid :param unicode worker_sid: The worker_sid :param unicode workflow_sid: The workflow_sid :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of EventInstance :rtype: twilio.rest.taskrouter.v1.workspace.event.EventPage """ params = values.of({ 'EndDate': serialize.iso8601_datetime(end_date), 'EventType': event_type, 'Minutes': minutes, 'ReservationSid': reservation_sid, 'StartDate': serialize.iso8601_datetime(start_date), 'TaskQueueSid': task_queue_sid, 'TaskSid': task_sid, 'WorkerSid': worker_sid, 'WorkflowSid': workflow_sid, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return EventPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of EventInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of EventInstance :rtype: twilio.rest.taskrouter.v1.workspace.event.EventPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return EventPage(self._version, response, self._solution) def get(self, sid): """ Constructs a EventContext :param sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.event.EventContext :rtype: twilio.rest.taskrouter.v1.workspace.event.EventContext """ return EventContext(self._version, workspace_sid=self._solution['workspace_sid'], sid=sid,) def __call__(self, sid): """ Constructs a EventContext :param sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.event.EventContext :rtype: twilio.rest.taskrouter.v1.workspace.event.EventContext """ return EventContext(self._version, workspace_sid=self._solution['workspace_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class EventPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the EventPage :param Version version: Version that contains the resource :param Response response: Response from the API :param workspace_sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.event.EventPage :rtype: twilio.rest.taskrouter.v1.workspace.event.EventPage """ super(EventPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of EventInstance :param dict payload: Payload response from the API :returns: twilio.rest.taskrouter.v1.workspace.event.EventInstance :rtype: twilio.rest.taskrouter.v1.workspace.event.EventInstance """ return EventInstance(self._version, payload, workspace_sid=self._solution['workspace_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class EventContext(InstanceContext): """ """ def __init__(self, version, workspace_sid, sid): """ Initialize the EventContext :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :param sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.event.EventContext :rtype: twilio.rest.taskrouter.v1.workspace.event.EventContext """ super(EventContext, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid, 'sid': sid,} self._uri = '/Workspaces/{workspace_sid}/Events/{sid}'.format(**self._solution) def fetch(self): """ Fetch a EventInstance :returns: Fetched EventInstance :rtype: twilio.rest.taskrouter.v1.workspace.event.EventInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return EventInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class EventInstance(InstanceResource): """ """ def __init__(self, version, payload, workspace_sid, sid=None): """ Initialize the EventInstance :returns: twilio.rest.taskrouter.v1.workspace.event.EventInstance :rtype: twilio.rest.taskrouter.v1.workspace.event.EventInstance """ super(EventInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'actor_sid': payload['actor_sid'], 'actor_type': payload['actor_type'], 'actor_url': payload['actor_url'], 'description': payload['description'], 'event_data': payload['event_data'], 'event_date': deserialize.iso8601_datetime(payload['event_date']), 'event_type': payload['event_type'], 'resource_sid': payload['resource_sid'], 'resource_type': payload['resource_type'], 'resource_url': payload['resource_url'], 'sid': payload['sid'], 'source': payload['source'], 'source_ip_address': payload['source_ip_address'], 'url': payload['url'], } # Context self._context = None self._solution = {'workspace_sid': workspace_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: EventContext for this EventInstance :rtype: twilio.rest.taskrouter.v1.workspace.event.EventContext """ if self._context is None: self._context = EventContext( self._version, workspace_sid=self._solution['workspace_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def actor_sid(self): """ :returns: The actor_sid :rtype: unicode """ return self._properties['actor_sid'] @property def actor_type(self): """ :returns: The actor_type :rtype: unicode """ return self._properties['actor_type'] @property def actor_url(self): """ :returns: The actor_url :rtype: unicode """ return self._properties['actor_url'] @property def description(self): """ :returns: The description :rtype: unicode """ return self._properties['description'] @property def event_data(self): """ :returns: The event_data :rtype: unicode """ return self._properties['event_data'] @property def event_date(self): """ :returns: The event_date :rtype: datetime """ return self._properties['event_date'] @property def event_type(self): """ :returns: The event_type :rtype: unicode """ return self._properties['event_type'] @property def resource_sid(self): """ :returns: The resource_sid :rtype: unicode """ return self._properties['resource_sid'] @property def resource_type(self): """ :returns: The resource_type :rtype: unicode """ return self._properties['resource_type'] @property def resource_url(self): """ :returns: The resource_url :rtype: unicode """ return self._properties['resource_url'] @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def source(self): """ :returns: The source :rtype: unicode """ return self._properties['source'] @property def source_ip_address(self): """ :returns: The source_ip_address :rtype: unicode """ return self._properties['source_ip_address'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a EventInstance :returns: Fetched EventInstance :rtype: twilio.rest.taskrouter.v1.workspace.event.EventInstance """ return self._proxy.fetch() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/taskrouter/v1/workspace/task/000077500000000000000000000000001317472742600243475ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/taskrouter/v1/workspace/task/__init__.py000066400000000000000000000546501317472742600264720ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.taskrouter.v1.workspace.task.reservation import ReservationList class TaskList(ListResource): """ """ def __init__(self, version, workspace_sid): """ Initialize the TaskList :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :returns: twilio.rest.taskrouter.v1.workspace.task.TaskList :rtype: twilio.rest.taskrouter.v1.workspace.task.TaskList """ super(TaskList, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid,} self._uri = '/Workspaces/{workspace_sid}/Tasks'.format(**self._solution) def stream(self, priority=values.unset, assignment_status=values.unset, workflow_sid=values.unset, workflow_name=values.unset, task_queue_sid=values.unset, task_queue_name=values.unset, evaluate_task_attributes=values.unset, ordering=values.unset, has_addons=values.unset, limit=None, page_size=None): """ 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 unicode priority: The priority :param unicode assignment_status: The assignment_status :param unicode workflow_sid: The workflow_sid :param unicode workflow_name: The workflow_name :param unicode task_queue_sid: The task_queue_sid :param unicode task_queue_name: The task_queue_name :param unicode evaluate_task_attributes: The evaluate_task_attributes :param unicode ordering: The ordering :param bool has_addons: The has_addons :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.taskrouter.v1.workspace.task.TaskInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( priority=priority, assignment_status=assignment_status, workflow_sid=workflow_sid, workflow_name=workflow_name, task_queue_sid=task_queue_sid, task_queue_name=task_queue_name, evaluate_task_attributes=evaluate_task_attributes, ordering=ordering, has_addons=has_addons, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, priority=values.unset, assignment_status=values.unset, workflow_sid=values.unset, workflow_name=values.unset, task_queue_sid=values.unset, task_queue_name=values.unset, evaluate_task_attributes=values.unset, ordering=values.unset, has_addons=values.unset, limit=None, page_size=None): """ 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 unicode priority: The priority :param unicode assignment_status: The assignment_status :param unicode workflow_sid: The workflow_sid :param unicode workflow_name: The workflow_name :param unicode task_queue_sid: The task_queue_sid :param unicode task_queue_name: The task_queue_name :param unicode evaluate_task_attributes: The evaluate_task_attributes :param unicode ordering: The ordering :param bool has_addons: The has_addons :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.taskrouter.v1.workspace.task.TaskInstance] """ return list(self.stream( priority=priority, assignment_status=assignment_status, workflow_sid=workflow_sid, workflow_name=workflow_name, task_queue_sid=task_queue_sid, task_queue_name=task_queue_name, evaluate_task_attributes=evaluate_task_attributes, ordering=ordering, has_addons=has_addons, limit=limit, page_size=page_size, )) def page(self, priority=values.unset, assignment_status=values.unset, workflow_sid=values.unset, workflow_name=values.unset, task_queue_sid=values.unset, task_queue_name=values.unset, evaluate_task_attributes=values.unset, ordering=values.unset, has_addons=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of TaskInstance records from the API. Request is executed immediately :param unicode priority: The priority :param unicode assignment_status: The assignment_status :param unicode workflow_sid: The workflow_sid :param unicode workflow_name: The workflow_name :param unicode task_queue_sid: The task_queue_sid :param unicode task_queue_name: The task_queue_name :param unicode evaluate_task_attributes: The evaluate_task_attributes :param unicode ordering: The ordering :param bool has_addons: The has_addons :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of TaskInstance :rtype: twilio.rest.taskrouter.v1.workspace.task.TaskPage """ params = values.of({ 'Priority': priority, 'AssignmentStatus': assignment_status, 'WorkflowSid': workflow_sid, 'WorkflowName': workflow_name, 'TaskQueueSid': task_queue_sid, 'TaskQueueName': task_queue_name, 'EvaluateTaskAttributes': evaluate_task_attributes, 'Ordering': ordering, 'HasAddons': has_addons, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return TaskPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of TaskInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of TaskInstance :rtype: twilio.rest.taskrouter.v1.workspace.task.TaskPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return TaskPage(self._version, response, self._solution) def create(self, timeout=values.unset, priority=values.unset, task_channel=values.unset, workflow_sid=values.unset, attributes=values.unset): """ Create a new TaskInstance :param unicode timeout: The timeout :param unicode priority: The priority :param unicode task_channel: The task_channel :param unicode workflow_sid: The workflow_sid :param unicode attributes: The attributes :returns: Newly created TaskInstance :rtype: twilio.rest.taskrouter.v1.workspace.task.TaskInstance """ data = values.of({ 'Timeout': timeout, 'Priority': priority, 'TaskChannel': task_channel, 'WorkflowSid': workflow_sid, 'Attributes': attributes, }) payload = self._version.create( 'POST', self._uri, data=data, ) return TaskInstance(self._version, payload, workspace_sid=self._solution['workspace_sid'],) def get(self, sid): """ Constructs a TaskContext :param sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.task.TaskContext :rtype: twilio.rest.taskrouter.v1.workspace.task.TaskContext """ return TaskContext(self._version, workspace_sid=self._solution['workspace_sid'], sid=sid,) def __call__(self, sid): """ Constructs a TaskContext :param sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.task.TaskContext :rtype: twilio.rest.taskrouter.v1.workspace.task.TaskContext """ return TaskContext(self._version, workspace_sid=self._solution['workspace_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class TaskPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the TaskPage :param Version version: Version that contains the resource :param Response response: Response from the API :param workspace_sid: The workspace_sid :returns: twilio.rest.taskrouter.v1.workspace.task.TaskPage :rtype: twilio.rest.taskrouter.v1.workspace.task.TaskPage """ super(TaskPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of TaskInstance :param dict payload: Payload response from the API :returns: twilio.rest.taskrouter.v1.workspace.task.TaskInstance :rtype: twilio.rest.taskrouter.v1.workspace.task.TaskInstance """ return TaskInstance(self._version, payload, workspace_sid=self._solution['workspace_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class TaskContext(InstanceContext): """ """ def __init__(self, version, workspace_sid, sid): """ Initialize the TaskContext :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :param sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.task.TaskContext :rtype: twilio.rest.taskrouter.v1.workspace.task.TaskContext """ super(TaskContext, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid, 'sid': sid,} self._uri = '/Workspaces/{workspace_sid}/Tasks/{sid}'.format(**self._solution) # Dependents self._reservations = None def fetch(self): """ Fetch a TaskInstance :returns: Fetched TaskInstance :rtype: twilio.rest.taskrouter.v1.workspace.task.TaskInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return TaskInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], sid=self._solution['sid'], ) def update(self, attributes=values.unset, assignment_status=values.unset, reason=values.unset, priority=values.unset, task_channel=values.unset): """ Update the TaskInstance :param unicode attributes: The attributes :param TaskInstance.Status assignment_status: The assignment_status :param unicode reason: The reason :param unicode priority: The priority :param unicode task_channel: The task_channel :returns: Updated TaskInstance :rtype: twilio.rest.taskrouter.v1.workspace.task.TaskInstance """ data = values.of({ 'Attributes': attributes, 'AssignmentStatus': assignment_status, 'Reason': reason, 'Priority': priority, 'TaskChannel': task_channel, }) payload = self._version.update( 'POST', self._uri, data=data, ) return TaskInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the TaskInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) @property def reservations(self): """ Access the reservations :returns: twilio.rest.taskrouter.v1.workspace.task.reservation.ReservationList :rtype: twilio.rest.taskrouter.v1.workspace.task.reservation.ReservationList """ if self._reservations is None: self._reservations = ReservationList( self._version, workspace_sid=self._solution['workspace_sid'], task_sid=self._solution['sid'], ) return self._reservations def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class TaskInstance(InstanceResource): """ """ class Status(object): PENDING = "pending" RESERVED = "reserved" ASSIGNED = "assigned" CANCELED = "canceled" COMPLETED = "completed" WRAPPING = "wrapping" def __init__(self, version, payload, workspace_sid, sid=None): """ Initialize the TaskInstance :returns: twilio.rest.taskrouter.v1.workspace.task.TaskInstance :rtype: twilio.rest.taskrouter.v1.workspace.task.TaskInstance """ super(TaskInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'age': deserialize.integer(payload['age']), 'assignment_status': payload['assignment_status'], 'attributes': payload['attributes'], 'addons': payload['addons'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'priority': deserialize.integer(payload['priority']), 'reason': payload['reason'], 'sid': payload['sid'], 'task_queue_sid': payload['task_queue_sid'], 'task_queue_friendly_name': payload['task_queue_friendly_name'], 'task_channel_sid': payload['task_channel_sid'], 'task_channel_unique_name': payload['task_channel_unique_name'], 'timeout': deserialize.integer(payload['timeout']), 'workflow_sid': payload['workflow_sid'], 'workflow_friendly_name': payload['workflow_friendly_name'], 'workspace_sid': payload['workspace_sid'], 'url': payload['url'], 'links': payload['links'], } # Context self._context = None self._solution = {'workspace_sid': workspace_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ 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 :rtype: twilio.rest.taskrouter.v1.workspace.task.TaskContext """ if self._context is None: self._context = TaskContext( self._version, workspace_sid=self._solution['workspace_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def age(self): """ :returns: The age :rtype: unicode """ return self._properties['age'] @property def assignment_status(self): """ :returns: The assignment_status :rtype: TaskInstance.Status """ return self._properties['assignment_status'] @property def attributes(self): """ :returns: The attributes :rtype: unicode """ return self._properties['attributes'] @property def addons(self): """ :returns: The addons :rtype: unicode """ return self._properties['addons'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def priority(self): """ :returns: The priority :rtype: unicode """ return self._properties['priority'] @property def reason(self): """ :returns: The reason :rtype: unicode """ return self._properties['reason'] @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def task_queue_sid(self): """ :returns: The task_queue_sid :rtype: unicode """ return self._properties['task_queue_sid'] @property def task_queue_friendly_name(self): """ :returns: The task_queue_friendly_name :rtype: unicode """ return self._properties['task_queue_friendly_name'] @property def task_channel_sid(self): """ :returns: The task_channel_sid :rtype: unicode """ return self._properties['task_channel_sid'] @property def task_channel_unique_name(self): """ :returns: The task_channel_unique_name :rtype: unicode """ return self._properties['task_channel_unique_name'] @property def timeout(self): """ :returns: The timeout :rtype: unicode """ return self._properties['timeout'] @property def workflow_sid(self): """ :returns: The workflow_sid :rtype: unicode """ return self._properties['workflow_sid'] @property def workflow_friendly_name(self): """ :returns: The workflow_friendly_name :rtype: unicode """ return self._properties['workflow_friendly_name'] @property def workspace_sid(self): """ :returns: The workspace_sid :rtype: unicode """ return self._properties['workspace_sid'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a TaskInstance :returns: Fetched TaskInstance :rtype: twilio.rest.taskrouter.v1.workspace.task.TaskInstance """ return self._proxy.fetch() def update(self, attributes=values.unset, assignment_status=values.unset, reason=values.unset, priority=values.unset, task_channel=values.unset): """ Update the TaskInstance :param unicode attributes: The attributes :param TaskInstance.Status assignment_status: The assignment_status :param unicode reason: The reason :param unicode priority: The priority :param unicode task_channel: The task_channel :returns: Updated TaskInstance :rtype: twilio.rest.taskrouter.v1.workspace.task.TaskInstance """ return self._proxy.update( attributes=attributes, assignment_status=assignment_status, reason=reason, priority=priority, task_channel=task_channel, ) def delete(self): """ Deletes the TaskInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() @property def reservations(self): """ Access the reservations :returns: twilio.rest.taskrouter.v1.workspace.task.reservation.ReservationList :rtype: twilio.rest.taskrouter.v1.workspace.task.reservation.ReservationList """ return self._proxy.reservations def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/taskrouter/v1/workspace/task/reservation.py000066400000000000000000000744231317472742600272740ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class ReservationList(ListResource): """ """ def __init__(self, version, workspace_sid, task_sid): """ Initialize the ReservationList :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :param task_sid: The task_sid :returns: twilio.rest.taskrouter.v1.workspace.task.reservation.ReservationList :rtype: twilio.rest.taskrouter.v1.workspace.task.reservation.ReservationList """ super(ReservationList, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid, 'task_sid': task_sid,} self._uri = '/Workspaces/{workspace_sid}/Tasks/{task_sid}/Reservations'.format(**self._solution) def stream(self, reservation_status=values.unset, limit=None, page_size=None): """ Streams ReservationInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param ReservationInstance.Status reservation_status: The reservation_status :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.taskrouter.v1.workspace.task.reservation.ReservationInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(reservation_status=reservation_status, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, reservation_status=values.unset, limit=None, page_size=None): """ Lists ReservationInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param ReservationInstance.Status reservation_status: The reservation_status :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.taskrouter.v1.workspace.task.reservation.ReservationInstance] """ return list(self.stream(reservation_status=reservation_status, limit=limit, page_size=page_size,)) def page(self, reservation_status=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of ReservationInstance records from the API. Request is executed immediately :param ReservationInstance.Status reservation_status: The reservation_status :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of ReservationInstance :rtype: twilio.rest.taskrouter.v1.workspace.task.reservation.ReservationPage """ params = values.of({ 'ReservationStatus': reservation_status, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return ReservationPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of ReservationInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of ReservationInstance :rtype: twilio.rest.taskrouter.v1.workspace.task.reservation.ReservationPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return ReservationPage(self._version, response, self._solution) def get(self, sid): """ Constructs a ReservationContext :param sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.task.reservation.ReservationContext :rtype: twilio.rest.taskrouter.v1.workspace.task.reservation.ReservationContext """ return ReservationContext( self._version, workspace_sid=self._solution['workspace_sid'], task_sid=self._solution['task_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a ReservationContext :param sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.task.reservation.ReservationContext :rtype: twilio.rest.taskrouter.v1.workspace.task.reservation.ReservationContext """ return ReservationContext( self._version, workspace_sid=self._solution['workspace_sid'], task_sid=self._solution['task_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ReservationPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the ReservationPage :param Version version: Version that contains the resource :param Response response: Response from the API :param workspace_sid: The workspace_sid :param task_sid: The task_sid :returns: twilio.rest.taskrouter.v1.workspace.task.reservation.ReservationPage :rtype: twilio.rest.taskrouter.v1.workspace.task.reservation.ReservationPage """ super(ReservationPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of ReservationInstance :param dict payload: Payload response from the API :returns: twilio.rest.taskrouter.v1.workspace.task.reservation.ReservationInstance :rtype: twilio.rest.taskrouter.v1.workspace.task.reservation.ReservationInstance """ return ReservationInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], task_sid=self._solution['task_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ReservationContext(InstanceContext): """ """ def __init__(self, version, workspace_sid, task_sid, sid): """ Initialize the ReservationContext :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :param task_sid: The task_sid :param sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.task.reservation.ReservationContext :rtype: twilio.rest.taskrouter.v1.workspace.task.reservation.ReservationContext """ super(ReservationContext, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid, 'task_sid': task_sid, 'sid': sid,} self._uri = '/Workspaces/{workspace_sid}/Tasks/{task_sid}/Reservations/{sid}'.format(**self._solution) def fetch(self): """ Fetch a ReservationInstance :returns: Fetched ReservationInstance :rtype: twilio.rest.taskrouter.v1.workspace.task.reservation.ReservationInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return ReservationInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], task_sid=self._solution['task_sid'], sid=self._solution['sid'], ) def update(self, reservation_status=values.unset, worker_activity_sid=values.unset, instruction=values.unset, dequeue_post_work_activity_sid=values.unset, dequeue_from=values.unset, dequeue_record=values.unset, dequeue_timeout=values.unset, dequeue_to=values.unset, dequeue_status_callback_url=values.unset, call_from=values.unset, call_record=values.unset, call_timeout=values.unset, call_to=values.unset, call_url=values.unset, call_status_callback_url=values.unset, call_accept=values.unset, redirect_call_sid=values.unset, redirect_accept=values.unset, redirect_url=values.unset, to=values.unset, from_=values.unset, status_callback=values.unset, status_callback_method=values.unset, status_callback_event=values.unset, timeout=values.unset, record=values.unset, muted=values.unset, beep=values.unset, start_conference_on_enter=values.unset, end_conference_on_exit=values.unset, wait_url=values.unset, wait_method=values.unset, early_media=values.unset, max_participants=values.unset, conference_status_callback=values.unset, conference_status_callback_method=values.unset, conference_status_callback_event=values.unset, conference_record=values.unset, conference_trim=values.unset, recording_channels=values.unset, recording_status_callback=values.unset, recording_status_callback_method=values.unset, conference_recording_status_callback=values.unset, conference_recording_status_callback_method=values.unset, region=values.unset, sip_auth_username=values.unset, sip_auth_password=values.unset, dequeue_status_callback_event=values.unset, post_work_activity_sid=values.unset): """ Update the ReservationInstance :param ReservationInstance.Status reservation_status: The reservation_status :param unicode worker_activity_sid: The worker_activity_sid :param unicode instruction: The instruction :param unicode dequeue_post_work_activity_sid: The dequeue_post_work_activity_sid :param unicode dequeue_from: The dequeue_from :param unicode dequeue_record: The dequeue_record :param unicode dequeue_timeout: The dequeue_timeout :param unicode dequeue_to: The dequeue_to :param unicode dequeue_status_callback_url: The dequeue_status_callback_url :param unicode call_from: The call_from :param unicode call_record: The call_record :param unicode call_timeout: The call_timeout :param unicode call_to: The call_to :param unicode call_url: The call_url :param unicode call_status_callback_url: The call_status_callback_url :param bool call_accept: The call_accept :param unicode redirect_call_sid: The redirect_call_sid :param bool redirect_accept: The redirect_accept :param unicode redirect_url: The redirect_url :param unicode to: The to :param unicode from_: The from :param unicode status_callback: The status_callback :param unicode status_callback_method: The status_callback_method :param ReservationInstance.CallStatus status_callback_event: The status_callback_event :param unicode timeout: The timeout :param bool record: The record :param bool muted: The muted :param unicode beep: The beep :param bool start_conference_on_enter: The start_conference_on_enter :param bool end_conference_on_exit: The end_conference_on_exit :param unicode wait_url: The wait_url :param unicode wait_method: The wait_method :param bool early_media: The early_media :param unicode max_participants: The max_participants :param unicode conference_status_callback: The conference_status_callback :param unicode conference_status_callback_method: The conference_status_callback_method :param ReservationInstance.ConferenceEvent conference_status_callback_event: The conference_status_callback_event :param unicode conference_record: The conference_record :param unicode conference_trim: The conference_trim :param unicode recording_channels: The recording_channels :param unicode recording_status_callback: The recording_status_callback :param unicode recording_status_callback_method: The recording_status_callback_method :param unicode conference_recording_status_callback: The conference_recording_status_callback :param unicode conference_recording_status_callback_method: The conference_recording_status_callback_method :param unicode region: The region :param unicode sip_auth_username: The sip_auth_username :param unicode sip_auth_password: The sip_auth_password :param unicode dequeue_status_callback_event: The dequeue_status_callback_event :param unicode post_work_activity_sid: The post_work_activity_sid :returns: Updated ReservationInstance :rtype: twilio.rest.taskrouter.v1.workspace.task.reservation.ReservationInstance """ data = values.of({ 'ReservationStatus': reservation_status, 'WorkerActivitySid': worker_activity_sid, 'Instruction': instruction, 'DequeuePostWorkActivitySid': dequeue_post_work_activity_sid, 'DequeueFrom': dequeue_from, 'DequeueRecord': dequeue_record, 'DequeueTimeout': dequeue_timeout, 'DequeueTo': dequeue_to, 'DequeueStatusCallbackUrl': dequeue_status_callback_url, 'CallFrom': call_from, 'CallRecord': call_record, 'CallTimeout': call_timeout, 'CallTo': call_to, 'CallUrl': call_url, 'CallStatusCallbackUrl': call_status_callback_url, 'CallAccept': call_accept, 'RedirectCallSid': redirect_call_sid, 'RedirectAccept': redirect_accept, 'RedirectUrl': redirect_url, 'To': to, 'From': from_, 'StatusCallback': status_callback, 'StatusCallbackMethod': status_callback_method, 'StatusCallbackEvent': status_callback_event, 'Timeout': timeout, 'Record': record, 'Muted': muted, 'Beep': beep, 'StartConferenceOnEnter': start_conference_on_enter, 'EndConferenceOnExit': end_conference_on_exit, 'WaitUrl': wait_url, 'WaitMethod': wait_method, 'EarlyMedia': early_media, 'MaxParticipants': max_participants, 'ConferenceStatusCallback': conference_status_callback, 'ConferenceStatusCallbackMethod': conference_status_callback_method, 'ConferenceStatusCallbackEvent': conference_status_callback_event, 'ConferenceRecord': conference_record, 'ConferenceTrim': conference_trim, 'RecordingChannels': recording_channels, 'RecordingStatusCallback': recording_status_callback, 'RecordingStatusCallbackMethod': recording_status_callback_method, 'ConferenceRecordingStatusCallback': conference_recording_status_callback, 'ConferenceRecordingStatusCallbackMethod': conference_recording_status_callback_method, 'Region': region, 'SipAuthUsername': sip_auth_username, 'SipAuthPassword': sip_auth_password, 'DequeueStatusCallbackEvent': dequeue_status_callback_event, 'PostWorkActivitySid': post_work_activity_sid, }) payload = self._version.update( 'POST', self._uri, data=data, ) return ReservationInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], task_sid=self._solution['task_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class ReservationInstance(InstanceResource): """ """ class Status(object): PENDING = "pending" ACCEPTED = "accepted" REJECTED = "rejected" TIMEOUT = "timeout" CANCELED = "canceled" RESCINDED = "rescinded" class CallStatus(object): INITIATED = "initiated" RINGING = "ringing" ANSWERED = "answered" COMPLETED = "completed" class ConferenceEvent(object): START = "start" END = "end" JOIN = "join" LEAVE = "leave" MUTE = "mute" HOLD = "hold" SPEAKER = "speaker" def __init__(self, version, payload, workspace_sid, task_sid, sid=None): """ Initialize the ReservationInstance :returns: twilio.rest.taskrouter.v1.workspace.task.reservation.ReservationInstance :rtype: twilio.rest.taskrouter.v1.workspace.task.reservation.ReservationInstance """ super(ReservationInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'reservation_status': payload['reservation_status'], 'sid': payload['sid'], 'task_sid': payload['task_sid'], 'worker_name': payload['worker_name'], 'worker_sid': payload['worker_sid'], 'workspace_sid': payload['workspace_sid'], 'url': payload['url'], 'links': payload['links'], } # Context self._context = None self._solution = { 'workspace_sid': workspace_sid, 'task_sid': task_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: ReservationContext for this ReservationInstance :rtype: twilio.rest.taskrouter.v1.workspace.task.reservation.ReservationContext """ if self._context is None: self._context = ReservationContext( self._version, workspace_sid=self._solution['workspace_sid'], task_sid=self._solution['task_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def reservation_status(self): """ :returns: The reservation_status :rtype: ReservationInstance.Status """ return self._properties['reservation_status'] @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def task_sid(self): """ :returns: The task_sid :rtype: unicode """ return self._properties['task_sid'] @property def worker_name(self): """ :returns: The worker_name :rtype: unicode """ return self._properties['worker_name'] @property def worker_sid(self): """ :returns: The worker_sid :rtype: unicode """ return self._properties['worker_sid'] @property def workspace_sid(self): """ :returns: The workspace_sid :rtype: unicode """ return self._properties['workspace_sid'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a ReservationInstance :returns: Fetched ReservationInstance :rtype: twilio.rest.taskrouter.v1.workspace.task.reservation.ReservationInstance """ return self._proxy.fetch() def update(self, reservation_status=values.unset, worker_activity_sid=values.unset, instruction=values.unset, dequeue_post_work_activity_sid=values.unset, dequeue_from=values.unset, dequeue_record=values.unset, dequeue_timeout=values.unset, dequeue_to=values.unset, dequeue_status_callback_url=values.unset, call_from=values.unset, call_record=values.unset, call_timeout=values.unset, call_to=values.unset, call_url=values.unset, call_status_callback_url=values.unset, call_accept=values.unset, redirect_call_sid=values.unset, redirect_accept=values.unset, redirect_url=values.unset, to=values.unset, from_=values.unset, status_callback=values.unset, status_callback_method=values.unset, status_callback_event=values.unset, timeout=values.unset, record=values.unset, muted=values.unset, beep=values.unset, start_conference_on_enter=values.unset, end_conference_on_exit=values.unset, wait_url=values.unset, wait_method=values.unset, early_media=values.unset, max_participants=values.unset, conference_status_callback=values.unset, conference_status_callback_method=values.unset, conference_status_callback_event=values.unset, conference_record=values.unset, conference_trim=values.unset, recording_channels=values.unset, recording_status_callback=values.unset, recording_status_callback_method=values.unset, conference_recording_status_callback=values.unset, conference_recording_status_callback_method=values.unset, region=values.unset, sip_auth_username=values.unset, sip_auth_password=values.unset, dequeue_status_callback_event=values.unset, post_work_activity_sid=values.unset): """ Update the ReservationInstance :param ReservationInstance.Status reservation_status: The reservation_status :param unicode worker_activity_sid: The worker_activity_sid :param unicode instruction: The instruction :param unicode dequeue_post_work_activity_sid: The dequeue_post_work_activity_sid :param unicode dequeue_from: The dequeue_from :param unicode dequeue_record: The dequeue_record :param unicode dequeue_timeout: The dequeue_timeout :param unicode dequeue_to: The dequeue_to :param unicode dequeue_status_callback_url: The dequeue_status_callback_url :param unicode call_from: The call_from :param unicode call_record: The call_record :param unicode call_timeout: The call_timeout :param unicode call_to: The call_to :param unicode call_url: The call_url :param unicode call_status_callback_url: The call_status_callback_url :param bool call_accept: The call_accept :param unicode redirect_call_sid: The redirect_call_sid :param bool redirect_accept: The redirect_accept :param unicode redirect_url: The redirect_url :param unicode to: The to :param unicode from_: The from :param unicode status_callback: The status_callback :param unicode status_callback_method: The status_callback_method :param ReservationInstance.CallStatus status_callback_event: The status_callback_event :param unicode timeout: The timeout :param bool record: The record :param bool muted: The muted :param unicode beep: The beep :param bool start_conference_on_enter: The start_conference_on_enter :param bool end_conference_on_exit: The end_conference_on_exit :param unicode wait_url: The wait_url :param unicode wait_method: The wait_method :param bool early_media: The early_media :param unicode max_participants: The max_participants :param unicode conference_status_callback: The conference_status_callback :param unicode conference_status_callback_method: The conference_status_callback_method :param ReservationInstance.ConferenceEvent conference_status_callback_event: The conference_status_callback_event :param unicode conference_record: The conference_record :param unicode conference_trim: The conference_trim :param unicode recording_channels: The recording_channels :param unicode recording_status_callback: The recording_status_callback :param unicode recording_status_callback_method: The recording_status_callback_method :param unicode conference_recording_status_callback: The conference_recording_status_callback :param unicode conference_recording_status_callback_method: The conference_recording_status_callback_method :param unicode region: The region :param unicode sip_auth_username: The sip_auth_username :param unicode sip_auth_password: The sip_auth_password :param unicode dequeue_status_callback_event: The dequeue_status_callback_event :param unicode post_work_activity_sid: The post_work_activity_sid :returns: Updated ReservationInstance :rtype: twilio.rest.taskrouter.v1.workspace.task.reservation.ReservationInstance """ return self._proxy.update( reservation_status=reservation_status, worker_activity_sid=worker_activity_sid, instruction=instruction, dequeue_post_work_activity_sid=dequeue_post_work_activity_sid, dequeue_from=dequeue_from, dequeue_record=dequeue_record, dequeue_timeout=dequeue_timeout, dequeue_to=dequeue_to, dequeue_status_callback_url=dequeue_status_callback_url, call_from=call_from, call_record=call_record, call_timeout=call_timeout, call_to=call_to, call_url=call_url, call_status_callback_url=call_status_callback_url, call_accept=call_accept, redirect_call_sid=redirect_call_sid, redirect_accept=redirect_accept, redirect_url=redirect_url, to=to, from_=from_, status_callback=status_callback, status_callback_method=status_callback_method, status_callback_event=status_callback_event, timeout=timeout, record=record, muted=muted, beep=beep, start_conference_on_enter=start_conference_on_enter, end_conference_on_exit=end_conference_on_exit, wait_url=wait_url, wait_method=wait_method, early_media=early_media, max_participants=max_participants, conference_status_callback=conference_status_callback, conference_status_callback_method=conference_status_callback_method, conference_status_callback_event=conference_status_callback_event, conference_record=conference_record, conference_trim=conference_trim, recording_channels=recording_channels, recording_status_callback=recording_status_callback, recording_status_callback_method=recording_status_callback_method, conference_recording_status_callback=conference_recording_status_callback, conference_recording_status_callback_method=conference_recording_status_callback_method, region=region, sip_auth_username=sip_auth_username, sip_auth_password=sip_auth_password, dequeue_status_callback_event=dequeue_status_callback_event, post_work_activity_sid=post_work_activity_sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/taskrouter/v1/workspace/task_channel.py000066400000000000000000000301001317472742600264030ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class TaskChannelList(ListResource): """ """ def __init__(self, version, workspace_sid): """ Initialize the TaskChannelList :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :returns: twilio.rest.taskrouter.v1.workspace.task_channel.TaskChannelList :rtype: twilio.rest.taskrouter.v1.workspace.task_channel.TaskChannelList """ super(TaskChannelList, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid,} self._uri = '/Workspaces/{workspace_sid}/TaskChannels'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams TaskChannelInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.taskrouter.v1.workspace.task_channel.TaskChannelInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists TaskChannelInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.taskrouter.v1.workspace.task_channel.TaskChannelInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of TaskChannelInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of TaskChannelInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_channel.TaskChannelPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return TaskChannelPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of TaskChannelInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of TaskChannelInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_channel.TaskChannelPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return TaskChannelPage(self._version, response, self._solution) def get(self, sid): """ Constructs a TaskChannelContext :param sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.task_channel.TaskChannelContext :rtype: twilio.rest.taskrouter.v1.workspace.task_channel.TaskChannelContext """ return TaskChannelContext(self._version, workspace_sid=self._solution['workspace_sid'], sid=sid,) def __call__(self, sid): """ Constructs a TaskChannelContext :param sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.task_channel.TaskChannelContext :rtype: twilio.rest.taskrouter.v1.workspace.task_channel.TaskChannelContext """ return TaskChannelContext(self._version, workspace_sid=self._solution['workspace_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class TaskChannelPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the TaskChannelPage :param Version version: Version that contains the resource :param Response response: Response from the API :param workspace_sid: The workspace_sid :returns: twilio.rest.taskrouter.v1.workspace.task_channel.TaskChannelPage :rtype: twilio.rest.taskrouter.v1.workspace.task_channel.TaskChannelPage """ super(TaskChannelPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of TaskChannelInstance :param dict payload: Payload response from the API :returns: twilio.rest.taskrouter.v1.workspace.task_channel.TaskChannelInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_channel.TaskChannelInstance """ return TaskChannelInstance(self._version, payload, workspace_sid=self._solution['workspace_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class TaskChannelContext(InstanceContext): """ """ def __init__(self, version, workspace_sid, sid): """ Initialize the TaskChannelContext :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :param sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.task_channel.TaskChannelContext :rtype: twilio.rest.taskrouter.v1.workspace.task_channel.TaskChannelContext """ super(TaskChannelContext, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid, 'sid': sid,} self._uri = '/Workspaces/{workspace_sid}/TaskChannels/{sid}'.format(**self._solution) def fetch(self): """ Fetch a TaskChannelInstance :returns: Fetched TaskChannelInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_channel.TaskChannelInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return TaskChannelInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class TaskChannelInstance(InstanceResource): """ """ def __init__(self, version, payload, workspace_sid, sid=None): """ Initialize the TaskChannelInstance :returns: twilio.rest.taskrouter.v1.workspace.task_channel.TaskChannelInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_channel.TaskChannelInstance """ super(TaskChannelInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'friendly_name': payload['friendly_name'], 'sid': payload['sid'], 'unique_name': payload['unique_name'], 'workspace_sid': payload['workspace_sid'], 'url': payload['url'], } # Context self._context = None self._solution = {'workspace_sid': workspace_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: TaskChannelContext for this TaskChannelInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_channel.TaskChannelContext """ if self._context is None: self._context = TaskChannelContext( self._version, workspace_sid=self._solution['workspace_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def unique_name(self): """ :returns: The unique_name :rtype: unicode """ return self._properties['unique_name'] @property def workspace_sid(self): """ :returns: The workspace_sid :rtype: unicode """ return self._properties['workspace_sid'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a TaskChannelInstance :returns: Fetched TaskChannelInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_channel.TaskChannelInstance """ return self._proxy.fetch() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/taskrouter/v1/workspace/task_queue/000077500000000000000000000000001317472742600255535ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/taskrouter/v1/workspace/task_queue/__init__.py000066400000000000000000000577401317472742600277010ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_cumulative_statistics import TaskQueueCumulativeStatisticsList from twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_real_time_statistics import TaskQueueRealTimeStatisticsList from twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_statistics import TaskQueueStatisticsList from twilio.rest.taskrouter.v1.workspace.task_queue.task_queues_statistics import TaskQueuesStatisticsList class TaskQueueList(ListResource): """ """ def __init__(self, version, workspace_sid): """ Initialize the TaskQueueList :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :returns: twilio.rest.taskrouter.v1.workspace.task_queue.TaskQueueList :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.TaskQueueList """ super(TaskQueueList, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid,} self._uri = '/Workspaces/{workspace_sid}/TaskQueues'.format(**self._solution) # Components self._statistics = None def stream(self, friendly_name=values.unset, evaluate_worker_attributes=values.unset, worker_sid=values.unset, limit=None, page_size=None): """ Streams TaskQueueInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param unicode friendly_name: The friendly_name :param unicode evaluate_worker_attributes: The evaluate_worker_attributes :param unicode worker_sid: The worker_sid :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.taskrouter.v1.workspace.task_queue.TaskQueueInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( friendly_name=friendly_name, evaluate_worker_attributes=evaluate_worker_attributes, worker_sid=worker_sid, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, friendly_name=values.unset, evaluate_worker_attributes=values.unset, worker_sid=values.unset, limit=None, page_size=None): """ Lists TaskQueueInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param unicode friendly_name: The friendly_name :param unicode evaluate_worker_attributes: The evaluate_worker_attributes :param unicode worker_sid: The worker_sid :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.taskrouter.v1.workspace.task_queue.TaskQueueInstance] """ return list(self.stream( friendly_name=friendly_name, evaluate_worker_attributes=evaluate_worker_attributes, worker_sid=worker_sid, limit=limit, page_size=page_size, )) def page(self, friendly_name=values.unset, evaluate_worker_attributes=values.unset, worker_sid=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of TaskQueueInstance records from the API. Request is executed immediately :param unicode friendly_name: The friendly_name :param unicode evaluate_worker_attributes: The evaluate_worker_attributes :param unicode worker_sid: The worker_sid :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of TaskQueueInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.TaskQueuePage """ params = values.of({ 'FriendlyName': friendly_name, 'EvaluateWorkerAttributes': evaluate_worker_attributes, 'WorkerSid': worker_sid, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return TaskQueuePage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of TaskQueueInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of TaskQueueInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.TaskQueuePage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return TaskQueuePage(self._version, response, self._solution) def create(self, friendly_name, reservation_activity_sid, assignment_activity_sid, target_workers=values.unset, max_reserved_workers=values.unset, task_order=values.unset): """ Create a new TaskQueueInstance :param unicode friendly_name: The friendly_name :param unicode reservation_activity_sid: The reservation_activity_sid :param unicode assignment_activity_sid: The assignment_activity_sid :param unicode target_workers: The target_workers :param unicode max_reserved_workers: The max_reserved_workers :param TaskQueueInstance.TaskOrder task_order: The task_order :returns: Newly created TaskQueueInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.TaskQueueInstance """ data = values.of({ 'FriendlyName': friendly_name, 'ReservationActivitySid': reservation_activity_sid, 'AssignmentActivitySid': assignment_activity_sid, 'TargetWorkers': target_workers, 'MaxReservedWorkers': max_reserved_workers, 'TaskOrder': task_order, }) payload = self._version.create( 'POST', self._uri, data=data, ) return TaskQueueInstance(self._version, payload, workspace_sid=self._solution['workspace_sid'],) @property def statistics(self): """ Access the statistics :returns: twilio.rest.taskrouter.v1.workspace.task_queue.task_queues_statistics.TaskQueuesStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queues_statistics.TaskQueuesStatisticsList """ if self._statistics is None: self._statistics = TaskQueuesStatisticsList( self._version, workspace_sid=self._solution['workspace_sid'], ) return self._statistics def get(self, sid): """ Constructs a TaskQueueContext :param sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.task_queue.TaskQueueContext :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.TaskQueueContext """ return TaskQueueContext(self._version, workspace_sid=self._solution['workspace_sid'], sid=sid,) def __call__(self, sid): """ Constructs a TaskQueueContext :param sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.task_queue.TaskQueueContext :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.TaskQueueContext """ return TaskQueueContext(self._version, workspace_sid=self._solution['workspace_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class TaskQueuePage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the TaskQueuePage :param Version version: Version that contains the resource :param Response response: Response from the API :param workspace_sid: The workspace_sid :returns: twilio.rest.taskrouter.v1.workspace.task_queue.TaskQueuePage :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.TaskQueuePage """ super(TaskQueuePage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of TaskQueueInstance :param dict payload: Payload response from the API :returns: twilio.rest.taskrouter.v1.workspace.task_queue.TaskQueueInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.TaskQueueInstance """ return TaskQueueInstance(self._version, payload, workspace_sid=self._solution['workspace_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class TaskQueueContext(InstanceContext): """ """ def __init__(self, version, workspace_sid, sid): """ Initialize the TaskQueueContext :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :param sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.task_queue.TaskQueueContext :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.TaskQueueContext """ super(TaskQueueContext, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid, 'sid': sid,} self._uri = '/Workspaces/{workspace_sid}/TaskQueues/{sid}'.format(**self._solution) # Dependents self._statistics = None self._real_time_statistics = None self._cumulative_statistics = None def fetch(self): """ Fetch a TaskQueueInstance :returns: Fetched TaskQueueInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.TaskQueueInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return TaskQueueInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], sid=self._solution['sid'], ) def update(self, friendly_name=values.unset, target_workers=values.unset, reservation_activity_sid=values.unset, assignment_activity_sid=values.unset, max_reserved_workers=values.unset, task_order=values.unset): """ Update the TaskQueueInstance :param unicode friendly_name: The friendly_name :param unicode target_workers: The target_workers :param unicode reservation_activity_sid: The reservation_activity_sid :param unicode assignment_activity_sid: The assignment_activity_sid :param unicode max_reserved_workers: The max_reserved_workers :param TaskQueueInstance.TaskOrder task_order: The task_order :returns: Updated TaskQueueInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.TaskQueueInstance """ data = values.of({ 'FriendlyName': friendly_name, 'TargetWorkers': target_workers, 'ReservationActivitySid': reservation_activity_sid, 'AssignmentActivitySid': assignment_activity_sid, 'MaxReservedWorkers': max_reserved_workers, 'TaskOrder': task_order, }) payload = self._version.update( 'POST', self._uri, data=data, ) return TaskQueueInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the TaskQueueInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) @property def statistics(self): """ Access the statistics :returns: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_statistics.TaskQueueStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_statistics.TaskQueueStatisticsList """ if self._statistics is None: self._statistics = TaskQueueStatisticsList( self._version, workspace_sid=self._solution['workspace_sid'], task_queue_sid=self._solution['sid'], ) return self._statistics @property def real_time_statistics(self): """ Access the real_time_statistics :returns: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_real_time_statistics.TaskQueueRealTimeStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_real_time_statistics.TaskQueueRealTimeStatisticsList """ if self._real_time_statistics is None: self._real_time_statistics = TaskQueueRealTimeStatisticsList( self._version, workspace_sid=self._solution['workspace_sid'], task_queue_sid=self._solution['sid'], ) return self._real_time_statistics @property def cumulative_statistics(self): """ Access the cumulative_statistics :returns: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_cumulative_statistics.TaskQueueCumulativeStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_cumulative_statistics.TaskQueueCumulativeStatisticsList """ if self._cumulative_statistics is None: self._cumulative_statistics = TaskQueueCumulativeStatisticsList( self._version, workspace_sid=self._solution['workspace_sid'], task_queue_sid=self._solution['sid'], ) return self._cumulative_statistics def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class TaskQueueInstance(InstanceResource): """ """ class TaskOrder(object): FIFO = "FIFO" LIFO = "LIFO" def __init__(self, version, payload, workspace_sid, sid=None): """ Initialize the TaskQueueInstance :returns: twilio.rest.taskrouter.v1.workspace.task_queue.TaskQueueInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.TaskQueueInstance """ super(TaskQueueInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'assignment_activity_sid': payload['assignment_activity_sid'], 'assignment_activity_name': payload['assignment_activity_name'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'friendly_name': payload['friendly_name'], 'max_reserved_workers': deserialize.integer(payload['max_reserved_workers']), 'reservation_activity_sid': payload['reservation_activity_sid'], 'reservation_activity_name': payload['reservation_activity_name'], 'sid': payload['sid'], 'target_workers': payload['target_workers'], 'task_order': payload['task_order'], 'url': payload['url'], 'workspace_sid': payload['workspace_sid'], 'links': payload['links'], } # Context self._context = None self._solution = {'workspace_sid': workspace_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: TaskQueueContext for this TaskQueueInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.TaskQueueContext """ if self._context is None: self._context = TaskQueueContext( self._version, workspace_sid=self._solution['workspace_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def assignment_activity_sid(self): """ :returns: The assignment_activity_sid :rtype: unicode """ return self._properties['assignment_activity_sid'] @property def assignment_activity_name(self): """ :returns: The assignment_activity_name :rtype: unicode """ return self._properties['assignment_activity_name'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def max_reserved_workers(self): """ :returns: The max_reserved_workers :rtype: unicode """ return self._properties['max_reserved_workers'] @property def reservation_activity_sid(self): """ :returns: The reservation_activity_sid :rtype: unicode """ return self._properties['reservation_activity_sid'] @property def reservation_activity_name(self): """ :returns: The reservation_activity_name :rtype: unicode """ return self._properties['reservation_activity_name'] @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def target_workers(self): """ :returns: The target_workers :rtype: unicode """ return self._properties['target_workers'] @property def task_order(self): """ :returns: The task_order :rtype: TaskQueueInstance.TaskOrder """ return self._properties['task_order'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def workspace_sid(self): """ :returns: The workspace_sid :rtype: unicode """ return self._properties['workspace_sid'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a TaskQueueInstance :returns: Fetched TaskQueueInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.TaskQueueInstance """ return self._proxy.fetch() def update(self, friendly_name=values.unset, target_workers=values.unset, reservation_activity_sid=values.unset, assignment_activity_sid=values.unset, max_reserved_workers=values.unset, task_order=values.unset): """ Update the TaskQueueInstance :param unicode friendly_name: The friendly_name :param unicode target_workers: The target_workers :param unicode reservation_activity_sid: The reservation_activity_sid :param unicode assignment_activity_sid: The assignment_activity_sid :param unicode max_reserved_workers: The max_reserved_workers :param TaskQueueInstance.TaskOrder task_order: The task_order :returns: Updated TaskQueueInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.TaskQueueInstance """ return self._proxy.update( friendly_name=friendly_name, target_workers=target_workers, reservation_activity_sid=reservation_activity_sid, assignment_activity_sid=assignment_activity_sid, max_reserved_workers=max_reserved_workers, task_order=task_order, ) def delete(self): """ Deletes the TaskQueueInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() @property def statistics(self): """ Access the statistics :returns: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_statistics.TaskQueueStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_statistics.TaskQueueStatisticsList """ return self._proxy.statistics @property def real_time_statistics(self): """ Access the real_time_statistics :returns: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_real_time_statistics.TaskQueueRealTimeStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_real_time_statistics.TaskQueueRealTimeStatisticsList """ return self._proxy.real_time_statistics @property def cumulative_statistics(self): """ Access the cumulative_statistics :returns: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_cumulative_statistics.TaskQueueCumulativeStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_cumulative_statistics.TaskQueueCumulativeStatisticsList """ return self._proxy.cumulative_statistics def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) task_queue_cumulative_statistics.py000066400000000000000000000362271317472742600347360ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/taskrouter/v1/workspace/task_queue# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize 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.page import Page class TaskQueueCumulativeStatisticsList(ListResource): """ """ def __init__(self, version, workspace_sid, task_queue_sid): """ Initialize the TaskQueueCumulativeStatisticsList :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :param task_queue_sid: The task_queue_sid :returns: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_cumulative_statistics.TaskQueueCumulativeStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_cumulative_statistics.TaskQueueCumulativeStatisticsList """ super(TaskQueueCumulativeStatisticsList, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid, 'task_queue_sid': task_queue_sid,} def get(self): """ Constructs a TaskQueueCumulativeStatisticsContext :returns: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_cumulative_statistics.TaskQueueCumulativeStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_cumulative_statistics.TaskQueueCumulativeStatisticsContext """ return TaskQueueCumulativeStatisticsContext( self._version, workspace_sid=self._solution['workspace_sid'], task_queue_sid=self._solution['task_queue_sid'], ) def __call__(self): """ Constructs a TaskQueueCumulativeStatisticsContext :returns: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_cumulative_statistics.TaskQueueCumulativeStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_cumulative_statistics.TaskQueueCumulativeStatisticsContext """ return TaskQueueCumulativeStatisticsContext( self._version, workspace_sid=self._solution['workspace_sid'], task_queue_sid=self._solution['task_queue_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class TaskQueueCumulativeStatisticsPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the TaskQueueCumulativeStatisticsPage :param Version version: Version that contains the resource :param Response response: Response from the API :param workspace_sid: The workspace_sid :param task_queue_sid: The task_queue_sid :returns: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_cumulative_statistics.TaskQueueCumulativeStatisticsPage :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_cumulative_statistics.TaskQueueCumulativeStatisticsPage """ super(TaskQueueCumulativeStatisticsPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of TaskQueueCumulativeStatisticsInstance :param dict payload: Payload response from the API :returns: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_cumulative_statistics.TaskQueueCumulativeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_cumulative_statistics.TaskQueueCumulativeStatisticsInstance """ return TaskQueueCumulativeStatisticsInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], task_queue_sid=self._solution['task_queue_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class TaskQueueCumulativeStatisticsContext(InstanceContext): """ """ def __init__(self, version, workspace_sid, task_queue_sid): """ Initialize the TaskQueueCumulativeStatisticsContext :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :param task_queue_sid: The task_queue_sid :returns: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_cumulative_statistics.TaskQueueCumulativeStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_cumulative_statistics.TaskQueueCumulativeStatisticsContext """ super(TaskQueueCumulativeStatisticsContext, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid, 'task_queue_sid': task_queue_sid,} self._uri = '/Workspaces/{workspace_sid}/TaskQueues/{task_queue_sid}/CumulativeStatistics'.format(**self._solution) def fetch(self, end_date=values.unset, minutes=values.unset, start_date=values.unset, task_channel=values.unset, split_by_wait_time=values.unset): """ Fetch a TaskQueueCumulativeStatisticsInstance :param datetime end_date: The end_date :param unicode minutes: The minutes :param datetime start_date: The start_date :param unicode task_channel: The task_channel :param unicode split_by_wait_time: The split_by_wait_time :returns: Fetched TaskQueueCumulativeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_cumulative_statistics.TaskQueueCumulativeStatisticsInstance """ params = values.of({ 'EndDate': serialize.iso8601_datetime(end_date), 'Minutes': minutes, 'StartDate': serialize.iso8601_datetime(start_date), 'TaskChannel': task_channel, 'SplitByWaitTime': split_by_wait_time, }) payload = self._version.fetch( 'GET', self._uri, params=params, ) return TaskQueueCumulativeStatisticsInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], task_queue_sid=self._solution['task_queue_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class TaskQueueCumulativeStatisticsInstance(InstanceResource): """ """ def __init__(self, version, payload, workspace_sid, task_queue_sid): """ Initialize the TaskQueueCumulativeStatisticsInstance :returns: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_cumulative_statistics.TaskQueueCumulativeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_cumulative_statistics.TaskQueueCumulativeStatisticsInstance """ super(TaskQueueCumulativeStatisticsInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'avg_task_acceptance_time': deserialize.integer(payload['avg_task_acceptance_time']), 'start_time': deserialize.iso8601_datetime(payload['start_time']), 'end_time': deserialize.iso8601_datetime(payload['end_time']), 'reservations_created': deserialize.integer(payload['reservations_created']), 'reservations_accepted': deserialize.integer(payload['reservations_accepted']), 'reservations_rejected': deserialize.integer(payload['reservations_rejected']), 'reservations_timed_out': deserialize.integer(payload['reservations_timed_out']), 'reservations_canceled': deserialize.integer(payload['reservations_canceled']), 'reservations_rescinded': deserialize.integer(payload['reservations_rescinded']), 'split_by_wait_time': payload['split_by_wait_time'], 'task_queue_sid': payload['task_queue_sid'], 'wait_duration_until_accepted': payload['wait_duration_until_accepted'], 'wait_duration_until_canceled': payload['wait_duration_until_canceled'], 'tasks_canceled': deserialize.integer(payload['tasks_canceled']), 'tasks_completed': deserialize.integer(payload['tasks_completed']), 'tasks_deleted': deserialize.integer(payload['tasks_deleted']), 'tasks_entered': deserialize.integer(payload['tasks_entered']), 'tasks_moved': deserialize.integer(payload['tasks_moved']), 'workspace_sid': payload['workspace_sid'], 'url': payload['url'], } # Context self._context = None self._solution = {'workspace_sid': workspace_sid, 'task_queue_sid': task_queue_sid,} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: TaskQueueCumulativeStatisticsContext for this TaskQueueCumulativeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_cumulative_statistics.TaskQueueCumulativeStatisticsContext """ if self._context is None: self._context = TaskQueueCumulativeStatisticsContext( self._version, workspace_sid=self._solution['workspace_sid'], task_queue_sid=self._solution['task_queue_sid'], ) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def avg_task_acceptance_time(self): """ :returns: The avg_task_acceptance_time :rtype: unicode """ return self._properties['avg_task_acceptance_time'] @property def start_time(self): """ :returns: The start_time :rtype: datetime """ return self._properties['start_time'] @property def end_time(self): """ :returns: The end_time :rtype: datetime """ return self._properties['end_time'] @property def reservations_created(self): """ :returns: The reservations_created :rtype: unicode """ return self._properties['reservations_created'] @property def reservations_accepted(self): """ :returns: The reservations_accepted :rtype: unicode """ return self._properties['reservations_accepted'] @property def reservations_rejected(self): """ :returns: The reservations_rejected :rtype: unicode """ return self._properties['reservations_rejected'] @property def reservations_timed_out(self): """ :returns: The reservations_timed_out :rtype: unicode """ return self._properties['reservations_timed_out'] @property def reservations_canceled(self): """ :returns: The reservations_canceled :rtype: unicode """ return self._properties['reservations_canceled'] @property def reservations_rescinded(self): """ :returns: The reservations_rescinded :rtype: unicode """ return self._properties['reservations_rescinded'] @property def split_by_wait_time(self): """ :returns: The split_by_wait_time :rtype: dict """ return self._properties['split_by_wait_time'] @property def task_queue_sid(self): """ :returns: The task_queue_sid :rtype: unicode """ return self._properties['task_queue_sid'] @property def wait_duration_until_accepted(self): """ :returns: The wait_duration_until_accepted :rtype: dict """ return self._properties['wait_duration_until_accepted'] @property def wait_duration_until_canceled(self): """ :returns: The wait_duration_until_canceled :rtype: dict """ return self._properties['wait_duration_until_canceled'] @property def tasks_canceled(self): """ :returns: The tasks_canceled :rtype: unicode """ return self._properties['tasks_canceled'] @property def tasks_completed(self): """ :returns: The tasks_completed :rtype: unicode """ return self._properties['tasks_completed'] @property def tasks_deleted(self): """ :returns: The tasks_deleted :rtype: unicode """ return self._properties['tasks_deleted'] @property def tasks_entered(self): """ :returns: The tasks_entered :rtype: unicode """ return self._properties['tasks_entered'] @property def tasks_moved(self): """ :returns: The tasks_moved :rtype: unicode """ return self._properties['tasks_moved'] @property def workspace_sid(self): """ :returns: The workspace_sid :rtype: unicode """ return self._properties['workspace_sid'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self, end_date=values.unset, minutes=values.unset, start_date=values.unset, task_channel=values.unset, split_by_wait_time=values.unset): """ Fetch a TaskQueueCumulativeStatisticsInstance :param datetime end_date: The end_date :param unicode minutes: The minutes :param datetime start_date: The start_date :param unicode task_channel: The task_channel :param unicode split_by_wait_time: The split_by_wait_time :returns: Fetched TaskQueueCumulativeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_cumulative_statistics.TaskQueueCumulativeStatisticsInstance """ return self._proxy.fetch( end_date=end_date, minutes=minutes, start_date=start_date, task_channel=task_channel, split_by_wait_time=split_by_wait_time, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) task_queue_real_time_statistics.py000066400000000000000000000263511317472742600345160ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/taskrouter/v1/workspace/task_queue# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class TaskQueueRealTimeStatisticsList(ListResource): """ """ def __init__(self, version, workspace_sid, task_queue_sid): """ Initialize the TaskQueueRealTimeStatisticsList :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :param task_queue_sid: The task_queue_sid :returns: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_real_time_statistics.TaskQueueRealTimeStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_real_time_statistics.TaskQueueRealTimeStatisticsList """ super(TaskQueueRealTimeStatisticsList, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid, 'task_queue_sid': task_queue_sid,} def get(self): """ Constructs a TaskQueueRealTimeStatisticsContext :returns: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_real_time_statistics.TaskQueueRealTimeStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_real_time_statistics.TaskQueueRealTimeStatisticsContext """ return TaskQueueRealTimeStatisticsContext( self._version, workspace_sid=self._solution['workspace_sid'], task_queue_sid=self._solution['task_queue_sid'], ) def __call__(self): """ Constructs a TaskQueueRealTimeStatisticsContext :returns: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_real_time_statistics.TaskQueueRealTimeStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_real_time_statistics.TaskQueueRealTimeStatisticsContext """ return TaskQueueRealTimeStatisticsContext( self._version, workspace_sid=self._solution['workspace_sid'], task_queue_sid=self._solution['task_queue_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class TaskQueueRealTimeStatisticsPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the TaskQueueRealTimeStatisticsPage :param Version version: Version that contains the resource :param Response response: Response from the API :param workspace_sid: The workspace_sid :param task_queue_sid: The task_queue_sid :returns: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_real_time_statistics.TaskQueueRealTimeStatisticsPage :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_real_time_statistics.TaskQueueRealTimeStatisticsPage """ super(TaskQueueRealTimeStatisticsPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of TaskQueueRealTimeStatisticsInstance :param dict payload: Payload response from the API :returns: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_real_time_statistics.TaskQueueRealTimeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_real_time_statistics.TaskQueueRealTimeStatisticsInstance """ return TaskQueueRealTimeStatisticsInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], task_queue_sid=self._solution['task_queue_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class TaskQueueRealTimeStatisticsContext(InstanceContext): """ """ def __init__(self, version, workspace_sid, task_queue_sid): """ Initialize the TaskQueueRealTimeStatisticsContext :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :param task_queue_sid: The task_queue_sid :returns: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_real_time_statistics.TaskQueueRealTimeStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_real_time_statistics.TaskQueueRealTimeStatisticsContext """ super(TaskQueueRealTimeStatisticsContext, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid, 'task_queue_sid': task_queue_sid,} self._uri = '/Workspaces/{workspace_sid}/TaskQueues/{task_queue_sid}/RealTimeStatistics'.format(**self._solution) def fetch(self, task_channel=values.unset): """ Fetch a TaskQueueRealTimeStatisticsInstance :param unicode task_channel: The task_channel :returns: Fetched TaskQueueRealTimeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_real_time_statistics.TaskQueueRealTimeStatisticsInstance """ params = values.of({'TaskChannel': task_channel,}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return TaskQueueRealTimeStatisticsInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], task_queue_sid=self._solution['task_queue_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class TaskQueueRealTimeStatisticsInstance(InstanceResource): """ """ def __init__(self, version, payload, workspace_sid, task_queue_sid): """ Initialize the TaskQueueRealTimeStatisticsInstance :returns: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_real_time_statistics.TaskQueueRealTimeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_real_time_statistics.TaskQueueRealTimeStatisticsInstance """ super(TaskQueueRealTimeStatisticsInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'activity_statistics': payload['activity_statistics'], 'longest_task_waiting_age': deserialize.integer(payload['longest_task_waiting_age']), 'task_queue_sid': payload['task_queue_sid'], 'tasks_by_priority': payload['tasks_by_priority'], 'tasks_by_status': payload['tasks_by_status'], 'total_available_workers': deserialize.integer(payload['total_available_workers']), 'total_eligible_workers': deserialize.integer(payload['total_eligible_workers']), 'total_tasks': deserialize.integer(payload['total_tasks']), 'workspace_sid': payload['workspace_sid'], 'url': payload['url'], } # Context self._context = None self._solution = {'workspace_sid': workspace_sid, 'task_queue_sid': task_queue_sid,} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: TaskQueueRealTimeStatisticsContext for this TaskQueueRealTimeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_real_time_statistics.TaskQueueRealTimeStatisticsContext """ if self._context is None: self._context = TaskQueueRealTimeStatisticsContext( self._version, workspace_sid=self._solution['workspace_sid'], task_queue_sid=self._solution['task_queue_sid'], ) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def activity_statistics(self): """ :returns: The activity_statistics :rtype: dict """ return self._properties['activity_statistics'] @property def longest_task_waiting_age(self): """ :returns: The longest_task_waiting_age :rtype: unicode """ return self._properties['longest_task_waiting_age'] @property def task_queue_sid(self): """ :returns: The task_queue_sid :rtype: unicode """ return self._properties['task_queue_sid'] @property def tasks_by_priority(self): """ :returns: The tasks_by_priority :rtype: dict """ return self._properties['tasks_by_priority'] @property def tasks_by_status(self): """ :returns: The tasks_by_status :rtype: dict """ return self._properties['tasks_by_status'] @property def total_available_workers(self): """ :returns: The total_available_workers :rtype: unicode """ return self._properties['total_available_workers'] @property def total_eligible_workers(self): """ :returns: The total_eligible_workers :rtype: unicode """ return self._properties['total_eligible_workers'] @property def total_tasks(self): """ :returns: The total_tasks :rtype: unicode """ return self._properties['total_tasks'] @property def workspace_sid(self): """ :returns: The workspace_sid :rtype: unicode """ return self._properties['workspace_sid'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self, task_channel=values.unset): """ Fetch a TaskQueueRealTimeStatisticsInstance :param unicode task_channel: The task_channel :returns: Fetched TaskQueueRealTimeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_real_time_statistics.TaskQueueRealTimeStatisticsInstance """ return self._proxy.fetch(task_channel=task_channel,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/taskrouter/v1/workspace/task_queue/task_queue_statistics.py000066400000000000000000000244511317472742600325530ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import serialize 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.page import Page class TaskQueueStatisticsList(ListResource): """ """ def __init__(self, version, workspace_sid, task_queue_sid): """ Initialize the TaskQueueStatisticsList :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :param task_queue_sid: The task_queue_sid :returns: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_statistics.TaskQueueStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_statistics.TaskQueueStatisticsList """ super(TaskQueueStatisticsList, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid, 'task_queue_sid': task_queue_sid,} def get(self): """ Constructs a TaskQueueStatisticsContext :returns: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_statistics.TaskQueueStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_statistics.TaskQueueStatisticsContext """ return TaskQueueStatisticsContext( self._version, workspace_sid=self._solution['workspace_sid'], task_queue_sid=self._solution['task_queue_sid'], ) def __call__(self): """ Constructs a TaskQueueStatisticsContext :returns: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_statistics.TaskQueueStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_statistics.TaskQueueStatisticsContext """ return TaskQueueStatisticsContext( self._version, workspace_sid=self._solution['workspace_sid'], task_queue_sid=self._solution['task_queue_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class TaskQueueStatisticsPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the TaskQueueStatisticsPage :param Version version: Version that contains the resource :param Response response: Response from the API :param workspace_sid: The workspace_sid :param task_queue_sid: The task_queue_sid :returns: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_statistics.TaskQueueStatisticsPage :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_statistics.TaskQueueStatisticsPage """ super(TaskQueueStatisticsPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of TaskQueueStatisticsInstance :param dict payload: Payload response from the API :returns: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_statistics.TaskQueueStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_statistics.TaskQueueStatisticsInstance """ return TaskQueueStatisticsInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], task_queue_sid=self._solution['task_queue_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class TaskQueueStatisticsContext(InstanceContext): """ """ def __init__(self, version, workspace_sid, task_queue_sid): """ Initialize the TaskQueueStatisticsContext :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :param task_queue_sid: The task_queue_sid :returns: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_statistics.TaskQueueStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_statistics.TaskQueueStatisticsContext """ super(TaskQueueStatisticsContext, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid, 'task_queue_sid': task_queue_sid,} self._uri = '/Workspaces/{workspace_sid}/TaskQueues/{task_queue_sid}/Statistics'.format(**self._solution) def fetch(self, end_date=values.unset, minutes=values.unset, start_date=values.unset, task_channel=values.unset, split_by_wait_time=values.unset): """ Fetch a TaskQueueStatisticsInstance :param datetime end_date: The end_date :param unicode minutes: The minutes :param datetime start_date: The start_date :param unicode task_channel: The task_channel :param unicode split_by_wait_time: The split_by_wait_time :returns: Fetched TaskQueueStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_statistics.TaskQueueStatisticsInstance """ params = values.of({ 'EndDate': serialize.iso8601_datetime(end_date), 'Minutes': minutes, 'StartDate': serialize.iso8601_datetime(start_date), 'TaskChannel': task_channel, 'SplitByWaitTime': split_by_wait_time, }) payload = self._version.fetch( 'GET', self._uri, params=params, ) return TaskQueueStatisticsInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], task_queue_sid=self._solution['task_queue_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class TaskQueueStatisticsInstance(InstanceResource): """ """ def __init__(self, version, payload, workspace_sid, task_queue_sid): """ Initialize the TaskQueueStatisticsInstance :returns: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_statistics.TaskQueueStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_statistics.TaskQueueStatisticsInstance """ super(TaskQueueStatisticsInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'cumulative': payload['cumulative'], 'realtime': payload['realtime'], 'task_queue_sid': payload['task_queue_sid'], 'workspace_sid': payload['workspace_sid'], 'url': payload['url'], } # Context self._context = None self._solution = {'workspace_sid': workspace_sid, 'task_queue_sid': task_queue_sid,} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: TaskQueueStatisticsContext for this TaskQueueStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_statistics.TaskQueueStatisticsContext """ if self._context is None: self._context = TaskQueueStatisticsContext( self._version, workspace_sid=self._solution['workspace_sid'], task_queue_sid=self._solution['task_queue_sid'], ) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def cumulative(self): """ :returns: The cumulative :rtype: dict """ return self._properties['cumulative'] @property def realtime(self): """ :returns: The realtime :rtype: dict """ return self._properties['realtime'] @property def task_queue_sid(self): """ :returns: The task_queue_sid :rtype: unicode """ return self._properties['task_queue_sid'] @property def workspace_sid(self): """ :returns: The workspace_sid :rtype: unicode """ return self._properties['workspace_sid'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self, end_date=values.unset, minutes=values.unset, start_date=values.unset, task_channel=values.unset, split_by_wait_time=values.unset): """ Fetch a TaskQueueStatisticsInstance :param datetime end_date: The end_date :param unicode minutes: The minutes :param datetime start_date: The start_date :param unicode task_channel: The task_channel :param unicode split_by_wait_time: The split_by_wait_time :returns: Fetched TaskQueueStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queue_statistics.TaskQueueStatisticsInstance """ return self._proxy.fetch( end_date=end_date, minutes=minutes, start_date=start_date, task_channel=task_channel, split_by_wait_time=split_by_wait_time, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/taskrouter/v1/workspace/task_queue/task_queues_statistics.py000066400000000000000000000256371317472742600327450ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import serialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class TaskQueuesStatisticsList(ListResource): """ """ def __init__(self, version, workspace_sid): """ Initialize the TaskQueuesStatisticsList :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :returns: twilio.rest.taskrouter.v1.workspace.task_queue.task_queues_statistics.TaskQueuesStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queues_statistics.TaskQueuesStatisticsList """ super(TaskQueuesStatisticsList, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid,} self._uri = '/Workspaces/{workspace_sid}/TaskQueues/Statistics'.format(**self._solution) def stream(self, end_date=values.unset, friendly_name=values.unset, minutes=values.unset, start_date=values.unset, task_channel=values.unset, split_by_wait_time=values.unset, limit=None, page_size=None): """ Streams TaskQueuesStatisticsInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param datetime end_date: The end_date :param unicode friendly_name: The friendly_name :param unicode minutes: The minutes :param datetime start_date: The start_date :param unicode task_channel: The task_channel :param unicode split_by_wait_time: The split_by_wait_time :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.taskrouter.v1.workspace.task_queue.task_queues_statistics.TaskQueuesStatisticsInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( end_date=end_date, friendly_name=friendly_name, minutes=minutes, start_date=start_date, task_channel=task_channel, split_by_wait_time=split_by_wait_time, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, end_date=values.unset, friendly_name=values.unset, minutes=values.unset, start_date=values.unset, task_channel=values.unset, split_by_wait_time=values.unset, limit=None, page_size=None): """ Lists TaskQueuesStatisticsInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param datetime end_date: The end_date :param unicode friendly_name: The friendly_name :param unicode minutes: The minutes :param datetime start_date: The start_date :param unicode task_channel: The task_channel :param unicode split_by_wait_time: The split_by_wait_time :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.taskrouter.v1.workspace.task_queue.task_queues_statistics.TaskQueuesStatisticsInstance] """ return list(self.stream( end_date=end_date, friendly_name=friendly_name, minutes=minutes, start_date=start_date, task_channel=task_channel, split_by_wait_time=split_by_wait_time, limit=limit, page_size=page_size, )) def page(self, end_date=values.unset, friendly_name=values.unset, minutes=values.unset, start_date=values.unset, task_channel=values.unset, split_by_wait_time=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of TaskQueuesStatisticsInstance records from the API. Request is executed immediately :param datetime end_date: The end_date :param unicode friendly_name: The friendly_name :param unicode minutes: The minutes :param datetime start_date: The start_date :param unicode task_channel: The task_channel :param unicode split_by_wait_time: The split_by_wait_time :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of TaskQueuesStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queues_statistics.TaskQueuesStatisticsPage """ params = values.of({ 'EndDate': serialize.iso8601_datetime(end_date), 'FriendlyName': friendly_name, 'Minutes': minutes, 'StartDate': serialize.iso8601_datetime(start_date), 'TaskChannel': task_channel, 'SplitByWaitTime': split_by_wait_time, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return TaskQueuesStatisticsPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of TaskQueuesStatisticsInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of TaskQueuesStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queues_statistics.TaskQueuesStatisticsPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return TaskQueuesStatisticsPage(self._version, response, self._solution) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class TaskQueuesStatisticsPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the TaskQueuesStatisticsPage :param Version version: Version that contains the resource :param Response response: Response from the API :param workspace_sid: The workspace_sid :returns: twilio.rest.taskrouter.v1.workspace.task_queue.task_queues_statistics.TaskQueuesStatisticsPage :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queues_statistics.TaskQueuesStatisticsPage """ super(TaskQueuesStatisticsPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of TaskQueuesStatisticsInstance :param dict payload: Payload response from the API :returns: twilio.rest.taskrouter.v1.workspace.task_queue.task_queues_statistics.TaskQueuesStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queues_statistics.TaskQueuesStatisticsInstance """ return TaskQueuesStatisticsInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class TaskQueuesStatisticsInstance(InstanceResource): """ """ def __init__(self, version, payload, workspace_sid): """ Initialize the TaskQueuesStatisticsInstance :returns: twilio.rest.taskrouter.v1.workspace.task_queue.task_queues_statistics.TaskQueuesStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_queue.task_queues_statistics.TaskQueuesStatisticsInstance """ super(TaskQueuesStatisticsInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'cumulative': payload['cumulative'], 'realtime': payload['realtime'], 'task_queue_sid': payload['task_queue_sid'], 'workspace_sid': payload['workspace_sid'], } # Context self._context = None self._solution = {'workspace_sid': workspace_sid,} @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def cumulative(self): """ :returns: The cumulative :rtype: dict """ return self._properties['cumulative'] @property def realtime(self): """ :returns: The realtime :rtype: dict """ return self._properties['realtime'] @property def task_queue_sid(self): """ :returns: The task_queue_sid :rtype: unicode """ return self._properties['task_queue_sid'] @property def workspace_sid(self): """ :returns: The workspace_sid :rtype: unicode """ return self._properties['workspace_sid'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/taskrouter/v1/workspace/worker/000077500000000000000000000000001317472742600247165ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/taskrouter/v1/workspace/worker/__init__.py000066400000000000000000000606661317472742600270450ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.taskrouter.v1.workspace.worker.reservation import ReservationList from twilio.rest.taskrouter.v1.workspace.worker.worker_channel import WorkerChannelList from twilio.rest.taskrouter.v1.workspace.worker.worker_statistics import WorkerStatisticsList from twilio.rest.taskrouter.v1.workspace.worker.workers_cumulative_statistics import WorkersCumulativeStatisticsList from twilio.rest.taskrouter.v1.workspace.worker.workers_real_time_statistics import WorkersRealTimeStatisticsList from twilio.rest.taskrouter.v1.workspace.worker.workers_statistics import WorkersStatisticsList class WorkerList(ListResource): """ """ def __init__(self, version, workspace_sid): """ Initialize the WorkerList :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :returns: twilio.rest.taskrouter.v1.workspace.worker.WorkerList :rtype: twilio.rest.taskrouter.v1.workspace.worker.WorkerList """ super(WorkerList, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid,} self._uri = '/Workspaces/{workspace_sid}/Workers'.format(**self._solution) # Components self._statistics = None def stream(self, activity_name=values.unset, activity_sid=values.unset, available=values.unset, friendly_name=values.unset, target_workers_expression=values.unset, task_queue_name=values.unset, task_queue_sid=values.unset, limit=None, page_size=None): """ Streams WorkerInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param unicode activity_name: The activity_name :param unicode activity_sid: The activity_sid :param unicode available: The available :param unicode friendly_name: The friendly_name :param unicode target_workers_expression: The target_workers_expression :param unicode task_queue_name: The task_queue_name :param unicode task_queue_sid: The task_queue_sid :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.taskrouter.v1.workspace.worker.WorkerInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( activity_name=activity_name, activity_sid=activity_sid, available=available, friendly_name=friendly_name, target_workers_expression=target_workers_expression, task_queue_name=task_queue_name, task_queue_sid=task_queue_sid, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, activity_name=values.unset, activity_sid=values.unset, available=values.unset, friendly_name=values.unset, target_workers_expression=values.unset, task_queue_name=values.unset, task_queue_sid=values.unset, limit=None, page_size=None): """ Lists WorkerInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param unicode activity_name: The activity_name :param unicode activity_sid: The activity_sid :param unicode available: The available :param unicode friendly_name: The friendly_name :param unicode target_workers_expression: The target_workers_expression :param unicode task_queue_name: The task_queue_name :param unicode task_queue_sid: The task_queue_sid :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.taskrouter.v1.workspace.worker.WorkerInstance] """ return list(self.stream( activity_name=activity_name, activity_sid=activity_sid, available=available, friendly_name=friendly_name, target_workers_expression=target_workers_expression, task_queue_name=task_queue_name, task_queue_sid=task_queue_sid, limit=limit, page_size=page_size, )) def page(self, activity_name=values.unset, activity_sid=values.unset, available=values.unset, friendly_name=values.unset, target_workers_expression=values.unset, task_queue_name=values.unset, task_queue_sid=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of WorkerInstance records from the API. Request is executed immediately :param unicode activity_name: The activity_name :param unicode activity_sid: The activity_sid :param unicode available: The available :param unicode friendly_name: The friendly_name :param unicode target_workers_expression: The target_workers_expression :param unicode task_queue_name: The task_queue_name :param unicode task_queue_sid: The task_queue_sid :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of WorkerInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.WorkerPage """ params = values.of({ 'ActivityName': activity_name, 'ActivitySid': activity_sid, 'Available': available, 'FriendlyName': friendly_name, 'TargetWorkersExpression': target_workers_expression, 'TaskQueueName': task_queue_name, 'TaskQueueSid': task_queue_sid, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return WorkerPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of WorkerInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of WorkerInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.WorkerPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return WorkerPage(self._version, response, self._solution) def create(self, friendly_name, activity_sid=values.unset, attributes=values.unset): """ Create a new WorkerInstance :param unicode friendly_name: The friendly_name :param unicode activity_sid: The activity_sid :param unicode attributes: The attributes :returns: Newly created WorkerInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.WorkerInstance """ data = values.of({ 'FriendlyName': friendly_name, 'ActivitySid': activity_sid, 'Attributes': attributes, }) payload = self._version.create( 'POST', self._uri, data=data, ) return WorkerInstance(self._version, payload, workspace_sid=self._solution['workspace_sid'],) @property def statistics(self): """ Access the statistics :returns: twilio.rest.taskrouter.v1.workspace.worker.workers_statistics.WorkersStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.worker.workers_statistics.WorkersStatisticsList """ if self._statistics is None: self._statistics = WorkersStatisticsList( self._version, workspace_sid=self._solution['workspace_sid'], ) return self._statistics def get(self, sid): """ Constructs a WorkerContext :param sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.worker.WorkerContext :rtype: twilio.rest.taskrouter.v1.workspace.worker.WorkerContext """ return WorkerContext(self._version, workspace_sid=self._solution['workspace_sid'], sid=sid,) def __call__(self, sid): """ Constructs a WorkerContext :param sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.worker.WorkerContext :rtype: twilio.rest.taskrouter.v1.workspace.worker.WorkerContext """ return WorkerContext(self._version, workspace_sid=self._solution['workspace_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class WorkerPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the WorkerPage :param Version version: Version that contains the resource :param Response response: Response from the API :param workspace_sid: The workspace_sid :returns: twilio.rest.taskrouter.v1.workspace.worker.WorkerPage :rtype: twilio.rest.taskrouter.v1.workspace.worker.WorkerPage """ super(WorkerPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of WorkerInstance :param dict payload: Payload response from the API :returns: twilio.rest.taskrouter.v1.workspace.worker.WorkerInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.WorkerInstance """ return WorkerInstance(self._version, payload, workspace_sid=self._solution['workspace_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class WorkerContext(InstanceContext): """ """ def __init__(self, version, workspace_sid, sid): """ Initialize the WorkerContext :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :param sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.worker.WorkerContext :rtype: twilio.rest.taskrouter.v1.workspace.worker.WorkerContext """ super(WorkerContext, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid, 'sid': sid,} self._uri = '/Workspaces/{workspace_sid}/Workers/{sid}'.format(**self._solution) # Dependents self._real_time_statistics = None self._cumulative_statistics = None self._statistics = None self._reservations = None self._worker_channels = None def fetch(self): """ Fetch a WorkerInstance :returns: Fetched WorkerInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.WorkerInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return WorkerInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], sid=self._solution['sid'], ) def update(self, activity_sid=values.unset, attributes=values.unset, friendly_name=values.unset): """ Update the WorkerInstance :param unicode activity_sid: The activity_sid :param unicode attributes: The attributes :param unicode friendly_name: The friendly_name :returns: Updated WorkerInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.WorkerInstance """ data = values.of({ 'ActivitySid': activity_sid, 'Attributes': attributes, 'FriendlyName': friendly_name, }) payload = self._version.update( 'POST', self._uri, data=data, ) return WorkerInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the WorkerInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) @property def real_time_statistics(self): """ Access the real_time_statistics :returns: twilio.rest.taskrouter.v1.workspace.worker.workers_real_time_statistics.WorkersRealTimeStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.worker.workers_real_time_statistics.WorkersRealTimeStatisticsList """ if self._real_time_statistics is None: self._real_time_statistics = WorkersRealTimeStatisticsList( self._version, workspace_sid=self._solution['workspace_sid'], ) return self._real_time_statistics @property def cumulative_statistics(self): """ Access the cumulative_statistics :returns: twilio.rest.taskrouter.v1.workspace.worker.workers_cumulative_statistics.WorkersCumulativeStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.worker.workers_cumulative_statistics.WorkersCumulativeStatisticsList """ if self._cumulative_statistics is None: self._cumulative_statistics = WorkersCumulativeStatisticsList( self._version, workspace_sid=self._solution['workspace_sid'], ) return self._cumulative_statistics @property def statistics(self): """ Access the statistics :returns: twilio.rest.taskrouter.v1.workspace.worker.worker_statistics.WorkerStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.worker.worker_statistics.WorkerStatisticsList """ if self._statistics is None: self._statistics = WorkerStatisticsList( self._version, workspace_sid=self._solution['workspace_sid'], worker_sid=self._solution['sid'], ) return self._statistics @property def reservations(self): """ Access the reservations :returns: twilio.rest.taskrouter.v1.workspace.worker.reservation.ReservationList :rtype: twilio.rest.taskrouter.v1.workspace.worker.reservation.ReservationList """ if self._reservations is None: self._reservations = ReservationList( self._version, workspace_sid=self._solution['workspace_sid'], worker_sid=self._solution['sid'], ) return self._reservations @property def worker_channels(self): """ Access the worker_channels :returns: twilio.rest.taskrouter.v1.workspace.worker.worker_channel.WorkerChannelList :rtype: twilio.rest.taskrouter.v1.workspace.worker.worker_channel.WorkerChannelList """ if self._worker_channels is None: self._worker_channels = WorkerChannelList( self._version, workspace_sid=self._solution['workspace_sid'], worker_sid=self._solution['sid'], ) return self._worker_channels def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class WorkerInstance(InstanceResource): """ """ def __init__(self, version, payload, workspace_sid, sid=None): """ Initialize the WorkerInstance :returns: twilio.rest.taskrouter.v1.workspace.worker.WorkerInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.WorkerInstance """ super(WorkerInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'activity_name': payload['activity_name'], 'activity_sid': payload['activity_sid'], 'attributes': payload['attributes'], 'available': payload['available'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_status_changed': deserialize.iso8601_datetime(payload['date_status_changed']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'friendly_name': payload['friendly_name'], 'sid': payload['sid'], 'workspace_sid': payload['workspace_sid'], 'url': payload['url'], 'links': payload['links'], } # Context self._context = None self._solution = {'workspace_sid': workspace_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: WorkerContext for this WorkerInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.WorkerContext """ if self._context is None: self._context = WorkerContext( self._version, workspace_sid=self._solution['workspace_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def activity_name(self): """ :returns: The activity_name :rtype: unicode """ return self._properties['activity_name'] @property def activity_sid(self): """ :returns: The activity_sid :rtype: unicode """ return self._properties['activity_sid'] @property def attributes(self): """ :returns: The attributes :rtype: unicode """ return self._properties['attributes'] @property def available(self): """ :returns: The available :rtype: bool """ return self._properties['available'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_status_changed(self): """ :returns: The date_status_changed :rtype: datetime """ return self._properties['date_status_changed'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def workspace_sid(self): """ :returns: The workspace_sid :rtype: unicode """ return self._properties['workspace_sid'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a WorkerInstance :returns: Fetched WorkerInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.WorkerInstance """ return self._proxy.fetch() def update(self, activity_sid=values.unset, attributes=values.unset, friendly_name=values.unset): """ Update the WorkerInstance :param unicode activity_sid: The activity_sid :param unicode attributes: The attributes :param unicode friendly_name: The friendly_name :returns: Updated WorkerInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.WorkerInstance """ return self._proxy.update( activity_sid=activity_sid, attributes=attributes, friendly_name=friendly_name, ) def delete(self): """ Deletes the WorkerInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() @property def real_time_statistics(self): """ Access the real_time_statistics :returns: twilio.rest.taskrouter.v1.workspace.worker.workers_real_time_statistics.WorkersRealTimeStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.worker.workers_real_time_statistics.WorkersRealTimeStatisticsList """ return self._proxy.real_time_statistics @property def cumulative_statistics(self): """ Access the cumulative_statistics :returns: twilio.rest.taskrouter.v1.workspace.worker.workers_cumulative_statistics.WorkersCumulativeStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.worker.workers_cumulative_statistics.WorkersCumulativeStatisticsList """ return self._proxy.cumulative_statistics @property def statistics(self): """ Access the statistics :returns: twilio.rest.taskrouter.v1.workspace.worker.worker_statistics.WorkerStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.worker.worker_statistics.WorkerStatisticsList """ return self._proxy.statistics @property def reservations(self): """ Access the reservations :returns: twilio.rest.taskrouter.v1.workspace.worker.reservation.ReservationList :rtype: twilio.rest.taskrouter.v1.workspace.worker.reservation.ReservationList """ return self._proxy.reservations @property def worker_channels(self): """ Access the worker_channels :returns: twilio.rest.taskrouter.v1.workspace.worker.worker_channel.WorkerChannelList :rtype: twilio.rest.taskrouter.v1.workspace.worker.worker_channel.WorkerChannelList """ return self._proxy.worker_channels def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/taskrouter/v1/workspace/worker/reservation.py000066400000000000000000000745771317472742600276550ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class ReservationList(ListResource): """ """ def __init__(self, version, workspace_sid, worker_sid): """ Initialize the ReservationList :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :param worker_sid: The worker_sid :returns: twilio.rest.taskrouter.v1.workspace.worker.reservation.ReservationList :rtype: twilio.rest.taskrouter.v1.workspace.worker.reservation.ReservationList """ super(ReservationList, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid, 'worker_sid': worker_sid,} self._uri = '/Workspaces/{workspace_sid}/Workers/{worker_sid}/Reservations'.format(**self._solution) def stream(self, reservation_status=values.unset, limit=None, page_size=None): """ Streams ReservationInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param ReservationInstance.Status reservation_status: The reservation_status :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.taskrouter.v1.workspace.worker.reservation.ReservationInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(reservation_status=reservation_status, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, reservation_status=values.unset, limit=None, page_size=None): """ Lists ReservationInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param ReservationInstance.Status reservation_status: The reservation_status :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.taskrouter.v1.workspace.worker.reservation.ReservationInstance] """ return list(self.stream(reservation_status=reservation_status, limit=limit, page_size=page_size,)) def page(self, reservation_status=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of ReservationInstance records from the API. Request is executed immediately :param ReservationInstance.Status reservation_status: The reservation_status :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of ReservationInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.reservation.ReservationPage """ params = values.of({ 'ReservationStatus': reservation_status, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return ReservationPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of ReservationInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of ReservationInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.reservation.ReservationPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return ReservationPage(self._version, response, self._solution) def get(self, sid): """ Constructs a ReservationContext :param sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.worker.reservation.ReservationContext :rtype: twilio.rest.taskrouter.v1.workspace.worker.reservation.ReservationContext """ return ReservationContext( self._version, workspace_sid=self._solution['workspace_sid'], worker_sid=self._solution['worker_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a ReservationContext :param sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.worker.reservation.ReservationContext :rtype: twilio.rest.taskrouter.v1.workspace.worker.reservation.ReservationContext """ return ReservationContext( self._version, workspace_sid=self._solution['workspace_sid'], worker_sid=self._solution['worker_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ReservationPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the ReservationPage :param Version version: Version that contains the resource :param Response response: Response from the API :param workspace_sid: The workspace_sid :param worker_sid: The worker_sid :returns: twilio.rest.taskrouter.v1.workspace.worker.reservation.ReservationPage :rtype: twilio.rest.taskrouter.v1.workspace.worker.reservation.ReservationPage """ super(ReservationPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of ReservationInstance :param dict payload: Payload response from the API :returns: twilio.rest.taskrouter.v1.workspace.worker.reservation.ReservationInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.reservation.ReservationInstance """ return ReservationInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], worker_sid=self._solution['worker_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class ReservationContext(InstanceContext): """ """ def __init__(self, version, workspace_sid, worker_sid, sid): """ Initialize the ReservationContext :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :param worker_sid: The worker_sid :param sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.worker.reservation.ReservationContext :rtype: twilio.rest.taskrouter.v1.workspace.worker.reservation.ReservationContext """ super(ReservationContext, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid, 'worker_sid': worker_sid, 'sid': sid,} self._uri = '/Workspaces/{workspace_sid}/Workers/{worker_sid}/Reservations/{sid}'.format(**self._solution) def fetch(self): """ Fetch a ReservationInstance :returns: Fetched ReservationInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.reservation.ReservationInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return ReservationInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], worker_sid=self._solution['worker_sid'], sid=self._solution['sid'], ) def update(self, reservation_status=values.unset, worker_activity_sid=values.unset, instruction=values.unset, dequeue_post_work_activity_sid=values.unset, dequeue_from=values.unset, dequeue_record=values.unset, dequeue_timeout=values.unset, dequeue_to=values.unset, dequeue_status_callback_url=values.unset, call_from=values.unset, call_record=values.unset, call_timeout=values.unset, call_to=values.unset, call_url=values.unset, call_status_callback_url=values.unset, call_accept=values.unset, redirect_call_sid=values.unset, redirect_accept=values.unset, redirect_url=values.unset, to=values.unset, from_=values.unset, status_callback=values.unset, status_callback_method=values.unset, status_callback_event=values.unset, timeout=values.unset, record=values.unset, muted=values.unset, beep=values.unset, start_conference_on_enter=values.unset, end_conference_on_exit=values.unset, wait_url=values.unset, wait_method=values.unset, early_media=values.unset, max_participants=values.unset, conference_status_callback=values.unset, conference_status_callback_method=values.unset, conference_status_callback_event=values.unset, conference_record=values.unset, conference_trim=values.unset, recording_channels=values.unset, recording_status_callback=values.unset, recording_status_callback_method=values.unset, conference_recording_status_callback=values.unset, conference_recording_status_callback_method=values.unset, region=values.unset, sip_auth_username=values.unset, sip_auth_password=values.unset, dequeue_status_callback_event=values.unset, post_work_activity_sid=values.unset): """ Update the ReservationInstance :param ReservationInstance.Status reservation_status: The reservation_status :param unicode worker_activity_sid: The worker_activity_sid :param unicode instruction: The instruction :param unicode dequeue_post_work_activity_sid: The dequeue_post_work_activity_sid :param unicode dequeue_from: The dequeue_from :param unicode dequeue_record: The dequeue_record :param unicode dequeue_timeout: The dequeue_timeout :param unicode dequeue_to: The dequeue_to :param unicode dequeue_status_callback_url: The dequeue_status_callback_url :param unicode call_from: The call_from :param unicode call_record: The call_record :param unicode call_timeout: The call_timeout :param unicode call_to: The call_to :param unicode call_url: The call_url :param unicode call_status_callback_url: The call_status_callback_url :param bool call_accept: The call_accept :param unicode redirect_call_sid: The redirect_call_sid :param bool redirect_accept: The redirect_accept :param unicode redirect_url: The redirect_url :param unicode to: The to :param unicode from_: The from :param unicode status_callback: The status_callback :param unicode status_callback_method: The status_callback_method :param ReservationInstance.CallStatus status_callback_event: The status_callback_event :param unicode timeout: The timeout :param bool record: The record :param bool muted: The muted :param unicode beep: The beep :param bool start_conference_on_enter: The start_conference_on_enter :param bool end_conference_on_exit: The end_conference_on_exit :param unicode wait_url: The wait_url :param unicode wait_method: The wait_method :param bool early_media: The early_media :param unicode max_participants: The max_participants :param unicode conference_status_callback: The conference_status_callback :param unicode conference_status_callback_method: The conference_status_callback_method :param ReservationInstance.ConferenceEvent conference_status_callback_event: The conference_status_callback_event :param unicode conference_record: The conference_record :param unicode conference_trim: The conference_trim :param unicode recording_channels: The recording_channels :param unicode recording_status_callback: The recording_status_callback :param unicode recording_status_callback_method: The recording_status_callback_method :param unicode conference_recording_status_callback: The conference_recording_status_callback :param unicode conference_recording_status_callback_method: The conference_recording_status_callback_method :param unicode region: The region :param unicode sip_auth_username: The sip_auth_username :param unicode sip_auth_password: The sip_auth_password :param unicode dequeue_status_callback_event: The dequeue_status_callback_event :param unicode post_work_activity_sid: The post_work_activity_sid :returns: Updated ReservationInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.reservation.ReservationInstance """ data = values.of({ 'ReservationStatus': reservation_status, 'WorkerActivitySid': worker_activity_sid, 'Instruction': instruction, 'DequeuePostWorkActivitySid': dequeue_post_work_activity_sid, 'DequeueFrom': dequeue_from, 'DequeueRecord': dequeue_record, 'DequeueTimeout': dequeue_timeout, 'DequeueTo': dequeue_to, 'DequeueStatusCallbackUrl': dequeue_status_callback_url, 'CallFrom': call_from, 'CallRecord': call_record, 'CallTimeout': call_timeout, 'CallTo': call_to, 'CallUrl': call_url, 'CallStatusCallbackUrl': call_status_callback_url, 'CallAccept': call_accept, 'RedirectCallSid': redirect_call_sid, 'RedirectAccept': redirect_accept, 'RedirectUrl': redirect_url, 'To': to, 'From': from_, 'StatusCallback': status_callback, 'StatusCallbackMethod': status_callback_method, 'StatusCallbackEvent': status_callback_event, 'Timeout': timeout, 'Record': record, 'Muted': muted, 'Beep': beep, 'StartConferenceOnEnter': start_conference_on_enter, 'EndConferenceOnExit': end_conference_on_exit, 'WaitUrl': wait_url, 'WaitMethod': wait_method, 'EarlyMedia': early_media, 'MaxParticipants': max_participants, 'ConferenceStatusCallback': conference_status_callback, 'ConferenceStatusCallbackMethod': conference_status_callback_method, 'ConferenceStatusCallbackEvent': conference_status_callback_event, 'ConferenceRecord': conference_record, 'ConferenceTrim': conference_trim, 'RecordingChannels': recording_channels, 'RecordingStatusCallback': recording_status_callback, 'RecordingStatusCallbackMethod': recording_status_callback_method, 'ConferenceRecordingStatusCallback': conference_recording_status_callback, 'ConferenceRecordingStatusCallbackMethod': conference_recording_status_callback_method, 'Region': region, 'SipAuthUsername': sip_auth_username, 'SipAuthPassword': sip_auth_password, 'DequeueStatusCallbackEvent': dequeue_status_callback_event, 'PostWorkActivitySid': post_work_activity_sid, }) payload = self._version.update( 'POST', self._uri, data=data, ) return ReservationInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], worker_sid=self._solution['worker_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class ReservationInstance(InstanceResource): """ """ class Status(object): PENDING = "pending" ACCEPTED = "accepted" REJECTED = "rejected" TIMEOUT = "timeout" CANCELED = "canceled" RESCINDED = "rescinded" class CallStatus(object): INITIATED = "initiated" RINGING = "ringing" ANSWERED = "answered" COMPLETED = "completed" class ConferenceEvent(object): START = "start" END = "end" JOIN = "join" LEAVE = "leave" MUTE = "mute" HOLD = "hold" SPEAKER = "speaker" def __init__(self, version, payload, workspace_sid, worker_sid, sid=None): """ Initialize the ReservationInstance :returns: twilio.rest.taskrouter.v1.workspace.worker.reservation.ReservationInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.reservation.ReservationInstance """ super(ReservationInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'reservation_status': payload['reservation_status'], 'sid': payload['sid'], 'task_sid': payload['task_sid'], 'worker_name': payload['worker_name'], 'worker_sid': payload['worker_sid'], 'workspace_sid': payload['workspace_sid'], 'url': payload['url'], 'links': payload['links'], } # Context self._context = None self._solution = { 'workspace_sid': workspace_sid, 'worker_sid': worker_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: ReservationContext for this ReservationInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.reservation.ReservationContext """ if self._context is None: self._context = ReservationContext( self._version, workspace_sid=self._solution['workspace_sid'], worker_sid=self._solution['worker_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def reservation_status(self): """ :returns: The reservation_status :rtype: ReservationInstance.Status """ return self._properties['reservation_status'] @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def task_sid(self): """ :returns: The task_sid :rtype: unicode """ return self._properties['task_sid'] @property def worker_name(self): """ :returns: The worker_name :rtype: unicode """ return self._properties['worker_name'] @property def worker_sid(self): """ :returns: The worker_sid :rtype: unicode """ return self._properties['worker_sid'] @property def workspace_sid(self): """ :returns: The workspace_sid :rtype: unicode """ return self._properties['workspace_sid'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a ReservationInstance :returns: Fetched ReservationInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.reservation.ReservationInstance """ return self._proxy.fetch() def update(self, reservation_status=values.unset, worker_activity_sid=values.unset, instruction=values.unset, dequeue_post_work_activity_sid=values.unset, dequeue_from=values.unset, dequeue_record=values.unset, dequeue_timeout=values.unset, dequeue_to=values.unset, dequeue_status_callback_url=values.unset, call_from=values.unset, call_record=values.unset, call_timeout=values.unset, call_to=values.unset, call_url=values.unset, call_status_callback_url=values.unset, call_accept=values.unset, redirect_call_sid=values.unset, redirect_accept=values.unset, redirect_url=values.unset, to=values.unset, from_=values.unset, status_callback=values.unset, status_callback_method=values.unset, status_callback_event=values.unset, timeout=values.unset, record=values.unset, muted=values.unset, beep=values.unset, start_conference_on_enter=values.unset, end_conference_on_exit=values.unset, wait_url=values.unset, wait_method=values.unset, early_media=values.unset, max_participants=values.unset, conference_status_callback=values.unset, conference_status_callback_method=values.unset, conference_status_callback_event=values.unset, conference_record=values.unset, conference_trim=values.unset, recording_channels=values.unset, recording_status_callback=values.unset, recording_status_callback_method=values.unset, conference_recording_status_callback=values.unset, conference_recording_status_callback_method=values.unset, region=values.unset, sip_auth_username=values.unset, sip_auth_password=values.unset, dequeue_status_callback_event=values.unset, post_work_activity_sid=values.unset): """ Update the ReservationInstance :param ReservationInstance.Status reservation_status: The reservation_status :param unicode worker_activity_sid: The worker_activity_sid :param unicode instruction: The instruction :param unicode dequeue_post_work_activity_sid: The dequeue_post_work_activity_sid :param unicode dequeue_from: The dequeue_from :param unicode dequeue_record: The dequeue_record :param unicode dequeue_timeout: The dequeue_timeout :param unicode dequeue_to: The dequeue_to :param unicode dequeue_status_callback_url: The dequeue_status_callback_url :param unicode call_from: The call_from :param unicode call_record: The call_record :param unicode call_timeout: The call_timeout :param unicode call_to: The call_to :param unicode call_url: The call_url :param unicode call_status_callback_url: The call_status_callback_url :param bool call_accept: The call_accept :param unicode redirect_call_sid: The redirect_call_sid :param bool redirect_accept: The redirect_accept :param unicode redirect_url: The redirect_url :param unicode to: The to :param unicode from_: The from :param unicode status_callback: The status_callback :param unicode status_callback_method: The status_callback_method :param ReservationInstance.CallStatus status_callback_event: The status_callback_event :param unicode timeout: The timeout :param bool record: The record :param bool muted: The muted :param unicode beep: The beep :param bool start_conference_on_enter: The start_conference_on_enter :param bool end_conference_on_exit: The end_conference_on_exit :param unicode wait_url: The wait_url :param unicode wait_method: The wait_method :param bool early_media: The early_media :param unicode max_participants: The max_participants :param unicode conference_status_callback: The conference_status_callback :param unicode conference_status_callback_method: The conference_status_callback_method :param ReservationInstance.ConferenceEvent conference_status_callback_event: The conference_status_callback_event :param unicode conference_record: The conference_record :param unicode conference_trim: The conference_trim :param unicode recording_channels: The recording_channels :param unicode recording_status_callback: The recording_status_callback :param unicode recording_status_callback_method: The recording_status_callback_method :param unicode conference_recording_status_callback: The conference_recording_status_callback :param unicode conference_recording_status_callback_method: The conference_recording_status_callback_method :param unicode region: The region :param unicode sip_auth_username: The sip_auth_username :param unicode sip_auth_password: The sip_auth_password :param unicode dequeue_status_callback_event: The dequeue_status_callback_event :param unicode post_work_activity_sid: The post_work_activity_sid :returns: Updated ReservationInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.reservation.ReservationInstance """ return self._proxy.update( reservation_status=reservation_status, worker_activity_sid=worker_activity_sid, instruction=instruction, dequeue_post_work_activity_sid=dequeue_post_work_activity_sid, dequeue_from=dequeue_from, dequeue_record=dequeue_record, dequeue_timeout=dequeue_timeout, dequeue_to=dequeue_to, dequeue_status_callback_url=dequeue_status_callback_url, call_from=call_from, call_record=call_record, call_timeout=call_timeout, call_to=call_to, call_url=call_url, call_status_callback_url=call_status_callback_url, call_accept=call_accept, redirect_call_sid=redirect_call_sid, redirect_accept=redirect_accept, redirect_url=redirect_url, to=to, from_=from_, status_callback=status_callback, status_callback_method=status_callback_method, status_callback_event=status_callback_event, timeout=timeout, record=record, muted=muted, beep=beep, start_conference_on_enter=start_conference_on_enter, end_conference_on_exit=end_conference_on_exit, wait_url=wait_url, wait_method=wait_method, early_media=early_media, max_participants=max_participants, conference_status_callback=conference_status_callback, conference_status_callback_method=conference_status_callback_method, conference_status_callback_event=conference_status_callback_event, conference_record=conference_record, conference_trim=conference_trim, recording_channels=recording_channels, recording_status_callback=recording_status_callback, recording_status_callback_method=recording_status_callback_method, conference_recording_status_callback=conference_recording_status_callback, conference_recording_status_callback_method=conference_recording_status_callback_method, region=region, sip_auth_username=sip_auth_username, sip_auth_password=sip_auth_password, dequeue_status_callback_event=dequeue_status_callback_event, post_work_activity_sid=post_work_activity_sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/taskrouter/v1/workspace/worker/worker_channel.py000066400000000000000000000375301317472742600303010ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class WorkerChannelList(ListResource): """ """ def __init__(self, version, workspace_sid, worker_sid): """ Initialize the WorkerChannelList :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :param worker_sid: The worker_sid :returns: twilio.rest.taskrouter.v1.workspace.worker.worker_channel.WorkerChannelList :rtype: twilio.rest.taskrouter.v1.workspace.worker.worker_channel.WorkerChannelList """ super(WorkerChannelList, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid, 'worker_sid': worker_sid,} self._uri = '/Workspaces/{workspace_sid}/Workers/{worker_sid}/Channels'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams WorkerChannelInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.taskrouter.v1.workspace.worker.worker_channel.WorkerChannelInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists WorkerChannelInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.taskrouter.v1.workspace.worker.worker_channel.WorkerChannelInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of WorkerChannelInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of WorkerChannelInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.worker_channel.WorkerChannelPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return WorkerChannelPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of WorkerChannelInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of WorkerChannelInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.worker_channel.WorkerChannelPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return WorkerChannelPage(self._version, response, self._solution) def get(self, sid): """ Constructs a WorkerChannelContext :param sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.worker.worker_channel.WorkerChannelContext :rtype: twilio.rest.taskrouter.v1.workspace.worker.worker_channel.WorkerChannelContext """ return WorkerChannelContext( self._version, workspace_sid=self._solution['workspace_sid'], worker_sid=self._solution['worker_sid'], sid=sid, ) def __call__(self, sid): """ Constructs a WorkerChannelContext :param sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.worker.worker_channel.WorkerChannelContext :rtype: twilio.rest.taskrouter.v1.workspace.worker.worker_channel.WorkerChannelContext """ return WorkerChannelContext( self._version, workspace_sid=self._solution['workspace_sid'], worker_sid=self._solution['worker_sid'], sid=sid, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class WorkerChannelPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the WorkerChannelPage :param Version version: Version that contains the resource :param Response response: Response from the API :param workspace_sid: The workspace_sid :param worker_sid: The worker_sid :returns: twilio.rest.taskrouter.v1.workspace.worker.worker_channel.WorkerChannelPage :rtype: twilio.rest.taskrouter.v1.workspace.worker.worker_channel.WorkerChannelPage """ super(WorkerChannelPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of WorkerChannelInstance :param dict payload: Payload response from the API :returns: twilio.rest.taskrouter.v1.workspace.worker.worker_channel.WorkerChannelInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.worker_channel.WorkerChannelInstance """ return WorkerChannelInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], worker_sid=self._solution['worker_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class WorkerChannelContext(InstanceContext): """ """ def __init__(self, version, workspace_sid, worker_sid, sid): """ Initialize the WorkerChannelContext :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :param worker_sid: The worker_sid :param sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.worker.worker_channel.WorkerChannelContext :rtype: twilio.rest.taskrouter.v1.workspace.worker.worker_channel.WorkerChannelContext """ super(WorkerChannelContext, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid, 'worker_sid': worker_sid, 'sid': sid,} self._uri = '/Workspaces/{workspace_sid}/Workers/{worker_sid}/Channels/{sid}'.format(**self._solution) def fetch(self): """ Fetch a WorkerChannelInstance :returns: Fetched WorkerChannelInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.worker_channel.WorkerChannelInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return WorkerChannelInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], worker_sid=self._solution['worker_sid'], sid=self._solution['sid'], ) def update(self, capacity=values.unset, available=values.unset): """ Update the WorkerChannelInstance :param unicode capacity: The capacity :param bool available: The available :returns: Updated WorkerChannelInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.worker_channel.WorkerChannelInstance """ data = values.of({'Capacity': capacity, 'Available': available,}) payload = self._version.update( 'POST', self._uri, data=data, ) return WorkerChannelInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], worker_sid=self._solution['worker_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class WorkerChannelInstance(InstanceResource): """ """ def __init__(self, version, payload, workspace_sid, worker_sid, sid=None): """ Initialize the WorkerChannelInstance :returns: twilio.rest.taskrouter.v1.workspace.worker.worker_channel.WorkerChannelInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.worker_channel.WorkerChannelInstance """ super(WorkerChannelInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'assigned_tasks': deserialize.integer(payload['assigned_tasks']), 'available': payload['available'], 'available_capacity_percentage': deserialize.integer(payload['available_capacity_percentage']), 'configured_capacity': deserialize.integer(payload['configured_capacity']), 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'sid': payload['sid'], 'task_channel_sid': payload['task_channel_sid'], 'task_channel_unique_name': payload['task_channel_unique_name'], 'worker_sid': payload['worker_sid'], 'workspace_sid': payload['workspace_sid'], 'links': payload['links'], 'url': payload['url'], } # Context self._context = None self._solution = { 'workspace_sid': workspace_sid, 'worker_sid': worker_sid, 'sid': sid or self._properties['sid'], } @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: WorkerChannelContext for this WorkerChannelInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.worker_channel.WorkerChannelContext """ if self._context is None: self._context = WorkerChannelContext( self._version, workspace_sid=self._solution['workspace_sid'], worker_sid=self._solution['worker_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def assigned_tasks(self): """ :returns: The assigned_tasks :rtype: unicode """ return self._properties['assigned_tasks'] @property def available(self): """ :returns: The available :rtype: bool """ return self._properties['available'] @property def available_capacity_percentage(self): """ :returns: The available_capacity_percentage :rtype: unicode """ return self._properties['available_capacity_percentage'] @property def configured_capacity(self): """ :returns: The configured_capacity :rtype: unicode """ return self._properties['configured_capacity'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def task_channel_sid(self): """ :returns: The task_channel_sid :rtype: unicode """ return self._properties['task_channel_sid'] @property def task_channel_unique_name(self): """ :returns: The task_channel_unique_name :rtype: unicode """ return self._properties['task_channel_unique_name'] @property def worker_sid(self): """ :returns: The worker_sid :rtype: unicode """ return self._properties['worker_sid'] @property def workspace_sid(self): """ :returns: The workspace_sid :rtype: unicode """ return self._properties['workspace_sid'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a WorkerChannelInstance :returns: Fetched WorkerChannelInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.worker_channel.WorkerChannelInstance """ return self._proxy.fetch() def update(self, capacity=values.unset, available=values.unset): """ Update the WorkerChannelInstance :param unicode capacity: The capacity :param bool available: The available :returns: Updated WorkerChannelInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.worker_channel.WorkerChannelInstance """ return self._proxy.update(capacity=capacity, available=available,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/taskrouter/v1/workspace/worker/worker_statistics.py000066400000000000000000000226011317472742600310540ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import serialize 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.page import Page class WorkerStatisticsList(ListResource): """ """ def __init__(self, version, workspace_sid, worker_sid): """ Initialize the WorkerStatisticsList :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :param worker_sid: The worker_sid :returns: twilio.rest.taskrouter.v1.workspace.worker.worker_statistics.WorkerStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.worker.worker_statistics.WorkerStatisticsList """ super(WorkerStatisticsList, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid, 'worker_sid': worker_sid,} def get(self): """ Constructs a WorkerStatisticsContext :returns: twilio.rest.taskrouter.v1.workspace.worker.worker_statistics.WorkerStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.worker.worker_statistics.WorkerStatisticsContext """ return WorkerStatisticsContext( self._version, workspace_sid=self._solution['workspace_sid'], worker_sid=self._solution['worker_sid'], ) def __call__(self): """ Constructs a WorkerStatisticsContext :returns: twilio.rest.taskrouter.v1.workspace.worker.worker_statistics.WorkerStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.worker.worker_statistics.WorkerStatisticsContext """ return WorkerStatisticsContext( self._version, workspace_sid=self._solution['workspace_sid'], worker_sid=self._solution['worker_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class WorkerStatisticsPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the WorkerStatisticsPage :param Version version: Version that contains the resource :param Response response: Response from the API :param workspace_sid: The workspace_sid :param worker_sid: The worker_sid :returns: twilio.rest.taskrouter.v1.workspace.worker.worker_statistics.WorkerStatisticsPage :rtype: twilio.rest.taskrouter.v1.workspace.worker.worker_statistics.WorkerStatisticsPage """ super(WorkerStatisticsPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of WorkerStatisticsInstance :param dict payload: Payload response from the API :returns: twilio.rest.taskrouter.v1.workspace.worker.worker_statistics.WorkerStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.worker_statistics.WorkerStatisticsInstance """ return WorkerStatisticsInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], worker_sid=self._solution['worker_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class WorkerStatisticsContext(InstanceContext): """ """ def __init__(self, version, workspace_sid, worker_sid): """ Initialize the WorkerStatisticsContext :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :param worker_sid: The worker_sid :returns: twilio.rest.taskrouter.v1.workspace.worker.worker_statistics.WorkerStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.worker.worker_statistics.WorkerStatisticsContext """ super(WorkerStatisticsContext, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid, 'worker_sid': worker_sid,} self._uri = '/Workspaces/{workspace_sid}/Workers/{worker_sid}/Statistics'.format(**self._solution) def fetch(self, minutes=values.unset, start_date=values.unset, end_date=values.unset, task_channel=values.unset): """ Fetch a WorkerStatisticsInstance :param unicode minutes: The minutes :param datetime start_date: The start_date :param datetime end_date: The end_date :param unicode task_channel: The task_channel :returns: Fetched WorkerStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.worker_statistics.WorkerStatisticsInstance """ params = values.of({ 'Minutes': minutes, 'StartDate': serialize.iso8601_datetime(start_date), 'EndDate': serialize.iso8601_datetime(end_date), 'TaskChannel': task_channel, }) payload = self._version.fetch( 'GET', self._uri, params=params, ) return WorkerStatisticsInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], worker_sid=self._solution['worker_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class WorkerStatisticsInstance(InstanceResource): """ """ def __init__(self, version, payload, workspace_sid, worker_sid): """ Initialize the WorkerStatisticsInstance :returns: twilio.rest.taskrouter.v1.workspace.worker.worker_statistics.WorkerStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.worker_statistics.WorkerStatisticsInstance """ super(WorkerStatisticsInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'cumulative': payload['cumulative'], 'worker_sid': payload['worker_sid'], 'workspace_sid': payload['workspace_sid'], 'url': payload['url'], } # Context self._context = None self._solution = {'workspace_sid': workspace_sid, 'worker_sid': worker_sid,} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: WorkerStatisticsContext for this WorkerStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.worker_statistics.WorkerStatisticsContext """ if self._context is None: self._context = WorkerStatisticsContext( self._version, workspace_sid=self._solution['workspace_sid'], worker_sid=self._solution['worker_sid'], ) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def cumulative(self): """ :returns: The cumulative :rtype: dict """ return self._properties['cumulative'] @property def worker_sid(self): """ :returns: The worker_sid :rtype: unicode """ return self._properties['worker_sid'] @property def workspace_sid(self): """ :returns: The workspace_sid :rtype: unicode """ return self._properties['workspace_sid'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self, minutes=values.unset, start_date=values.unset, end_date=values.unset, task_channel=values.unset): """ Fetch a WorkerStatisticsInstance :param unicode minutes: The minutes :param datetime start_date: The start_date :param datetime end_date: The end_date :param unicode task_channel: The task_channel :returns: Fetched WorkerStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.worker_statistics.WorkerStatisticsInstance """ return self._proxy.fetch( minutes=minutes, start_date=start_date, end_date=end_date, task_channel=task_channel, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/taskrouter/v1/workspace/worker/workers_cumulative_statistics.py000066400000000000000000000272161317472742600335040ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize 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.page import Page class WorkersCumulativeStatisticsList(ListResource): """ """ def __init__(self, version, workspace_sid): """ Initialize the WorkersCumulativeStatisticsList :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :returns: twilio.rest.taskrouter.v1.workspace.worker.workers_cumulative_statistics.WorkersCumulativeStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.worker.workers_cumulative_statistics.WorkersCumulativeStatisticsList """ super(WorkersCumulativeStatisticsList, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid,} def get(self): """ Constructs a WorkersCumulativeStatisticsContext :returns: twilio.rest.taskrouter.v1.workspace.worker.workers_cumulative_statistics.WorkersCumulativeStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.worker.workers_cumulative_statistics.WorkersCumulativeStatisticsContext """ return WorkersCumulativeStatisticsContext( self._version, workspace_sid=self._solution['workspace_sid'], ) def __call__(self): """ Constructs a WorkersCumulativeStatisticsContext :returns: twilio.rest.taskrouter.v1.workspace.worker.workers_cumulative_statistics.WorkersCumulativeStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.worker.workers_cumulative_statistics.WorkersCumulativeStatisticsContext """ return WorkersCumulativeStatisticsContext( self._version, workspace_sid=self._solution['workspace_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class WorkersCumulativeStatisticsPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the WorkersCumulativeStatisticsPage :param Version version: Version that contains the resource :param Response response: Response from the API :param workspace_sid: The workspace_sid :returns: twilio.rest.taskrouter.v1.workspace.worker.workers_cumulative_statistics.WorkersCumulativeStatisticsPage :rtype: twilio.rest.taskrouter.v1.workspace.worker.workers_cumulative_statistics.WorkersCumulativeStatisticsPage """ super(WorkersCumulativeStatisticsPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of WorkersCumulativeStatisticsInstance :param dict payload: Payload response from the API :returns: twilio.rest.taskrouter.v1.workspace.worker.workers_cumulative_statistics.WorkersCumulativeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.workers_cumulative_statistics.WorkersCumulativeStatisticsInstance """ return WorkersCumulativeStatisticsInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class WorkersCumulativeStatisticsContext(InstanceContext): """ """ def __init__(self, version, workspace_sid): """ Initialize the WorkersCumulativeStatisticsContext :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :returns: twilio.rest.taskrouter.v1.workspace.worker.workers_cumulative_statistics.WorkersCumulativeStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.worker.workers_cumulative_statistics.WorkersCumulativeStatisticsContext """ super(WorkersCumulativeStatisticsContext, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid,} self._uri = '/Workspaces/{workspace_sid}/Workers/CumulativeStatistics'.format(**self._solution) def fetch(self, end_date=values.unset, minutes=values.unset, start_date=values.unset, task_channel=values.unset): """ Fetch a WorkersCumulativeStatisticsInstance :param datetime end_date: The end_date :param unicode minutes: The minutes :param datetime start_date: The start_date :param unicode task_channel: The task_channel :returns: Fetched WorkersCumulativeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.workers_cumulative_statistics.WorkersCumulativeStatisticsInstance """ params = values.of({ 'EndDate': serialize.iso8601_datetime(end_date), 'Minutes': minutes, 'StartDate': serialize.iso8601_datetime(start_date), 'TaskChannel': task_channel, }) payload = self._version.fetch( 'GET', self._uri, params=params, ) return WorkersCumulativeStatisticsInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class WorkersCumulativeStatisticsInstance(InstanceResource): """ """ def __init__(self, version, payload, workspace_sid): """ Initialize the WorkersCumulativeStatisticsInstance :returns: twilio.rest.taskrouter.v1.workspace.worker.workers_cumulative_statistics.WorkersCumulativeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.workers_cumulative_statistics.WorkersCumulativeStatisticsInstance """ super(WorkersCumulativeStatisticsInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'start_time': deserialize.iso8601_datetime(payload['start_time']), 'end_time': deserialize.iso8601_datetime(payload['end_time']), 'activity_durations': payload['activity_durations'], 'reservations_created': deserialize.integer(payload['reservations_created']), 'reservations_accepted': deserialize.integer(payload['reservations_accepted']), 'reservations_rejected': deserialize.integer(payload['reservations_rejected']), 'reservations_timed_out': deserialize.integer(payload['reservations_timed_out']), 'reservations_canceled': deserialize.integer(payload['reservations_canceled']), 'reservations_rescinded': deserialize.integer(payload['reservations_rescinded']), 'workspace_sid': payload['workspace_sid'], 'url': payload['url'], } # Context self._context = None self._solution = {'workspace_sid': workspace_sid,} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: WorkersCumulativeStatisticsContext for this WorkersCumulativeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.workers_cumulative_statistics.WorkersCumulativeStatisticsContext """ if self._context is None: self._context = WorkersCumulativeStatisticsContext( self._version, workspace_sid=self._solution['workspace_sid'], ) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def start_time(self): """ :returns: The start_time :rtype: datetime """ return self._properties['start_time'] @property def end_time(self): """ :returns: The end_time :rtype: datetime """ return self._properties['end_time'] @property def activity_durations(self): """ :returns: The activity_durations :rtype: dict """ return self._properties['activity_durations'] @property def reservations_created(self): """ :returns: The reservations_created :rtype: unicode """ return self._properties['reservations_created'] @property def reservations_accepted(self): """ :returns: The reservations_accepted :rtype: unicode """ return self._properties['reservations_accepted'] @property def reservations_rejected(self): """ :returns: The reservations_rejected :rtype: unicode """ return self._properties['reservations_rejected'] @property def reservations_timed_out(self): """ :returns: The reservations_timed_out :rtype: unicode """ return self._properties['reservations_timed_out'] @property def reservations_canceled(self): """ :returns: The reservations_canceled :rtype: unicode """ return self._properties['reservations_canceled'] @property def reservations_rescinded(self): """ :returns: The reservations_rescinded :rtype: unicode """ return self._properties['reservations_rescinded'] @property def workspace_sid(self): """ :returns: The workspace_sid :rtype: unicode """ return self._properties['workspace_sid'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self, end_date=values.unset, minutes=values.unset, start_date=values.unset, task_channel=values.unset): """ Fetch a WorkersCumulativeStatisticsInstance :param datetime end_date: The end_date :param unicode minutes: The minutes :param datetime start_date: The start_date :param unicode task_channel: The task_channel :returns: Fetched WorkersCumulativeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.workers_cumulative_statistics.WorkersCumulativeStatisticsInstance """ return self._proxy.fetch( end_date=end_date, minutes=minutes, start_date=start_date, task_channel=task_channel, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/taskrouter/v1/workspace/worker/workers_real_time_statistics.py000066400000000000000000000214031317472742600332570ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class WorkersRealTimeStatisticsList(ListResource): """ """ def __init__(self, version, workspace_sid): """ Initialize the WorkersRealTimeStatisticsList :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :returns: twilio.rest.taskrouter.v1.workspace.worker.workers_real_time_statistics.WorkersRealTimeStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.worker.workers_real_time_statistics.WorkersRealTimeStatisticsList """ super(WorkersRealTimeStatisticsList, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid,} def get(self): """ Constructs a WorkersRealTimeStatisticsContext :returns: twilio.rest.taskrouter.v1.workspace.worker.workers_real_time_statistics.WorkersRealTimeStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.worker.workers_real_time_statistics.WorkersRealTimeStatisticsContext """ return WorkersRealTimeStatisticsContext(self._version, workspace_sid=self._solution['workspace_sid'],) def __call__(self): """ Constructs a WorkersRealTimeStatisticsContext :returns: twilio.rest.taskrouter.v1.workspace.worker.workers_real_time_statistics.WorkersRealTimeStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.worker.workers_real_time_statistics.WorkersRealTimeStatisticsContext """ return WorkersRealTimeStatisticsContext(self._version, workspace_sid=self._solution['workspace_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class WorkersRealTimeStatisticsPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the WorkersRealTimeStatisticsPage :param Version version: Version that contains the resource :param Response response: Response from the API :param workspace_sid: The workspace_sid :returns: twilio.rest.taskrouter.v1.workspace.worker.workers_real_time_statistics.WorkersRealTimeStatisticsPage :rtype: twilio.rest.taskrouter.v1.workspace.worker.workers_real_time_statistics.WorkersRealTimeStatisticsPage """ super(WorkersRealTimeStatisticsPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of WorkersRealTimeStatisticsInstance :param dict payload: Payload response from the API :returns: twilio.rest.taskrouter.v1.workspace.worker.workers_real_time_statistics.WorkersRealTimeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.workers_real_time_statistics.WorkersRealTimeStatisticsInstance """ return WorkersRealTimeStatisticsInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class WorkersRealTimeStatisticsContext(InstanceContext): """ """ def __init__(self, version, workspace_sid): """ Initialize the WorkersRealTimeStatisticsContext :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :returns: twilio.rest.taskrouter.v1.workspace.worker.workers_real_time_statistics.WorkersRealTimeStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.worker.workers_real_time_statistics.WorkersRealTimeStatisticsContext """ super(WorkersRealTimeStatisticsContext, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid,} self._uri = '/Workspaces/{workspace_sid}/Workers/RealTimeStatistics'.format(**self._solution) def fetch(self, task_channel=values.unset): """ Fetch a WorkersRealTimeStatisticsInstance :param unicode task_channel: The task_channel :returns: Fetched WorkersRealTimeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.workers_real_time_statistics.WorkersRealTimeStatisticsInstance """ params = values.of({'TaskChannel': task_channel,}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return WorkersRealTimeStatisticsInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class WorkersRealTimeStatisticsInstance(InstanceResource): """ """ def __init__(self, version, payload, workspace_sid): """ Initialize the WorkersRealTimeStatisticsInstance :returns: twilio.rest.taskrouter.v1.workspace.worker.workers_real_time_statistics.WorkersRealTimeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.workers_real_time_statistics.WorkersRealTimeStatisticsInstance """ super(WorkersRealTimeStatisticsInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'activity_statistics': payload['activity_statistics'], 'total_workers': deserialize.integer(payload['total_workers']), 'workspace_sid': payload['workspace_sid'], 'url': payload['url'], } # Context self._context = None self._solution = {'workspace_sid': workspace_sid,} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: WorkersRealTimeStatisticsContext for this WorkersRealTimeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.workers_real_time_statistics.WorkersRealTimeStatisticsContext """ if self._context is None: self._context = WorkersRealTimeStatisticsContext( self._version, workspace_sid=self._solution['workspace_sid'], ) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def activity_statistics(self): """ :returns: The activity_statistics :rtype: dict """ return self._properties['activity_statistics'] @property def total_workers(self): """ :returns: The total_workers :rtype: unicode """ return self._properties['total_workers'] @property def workspace_sid(self): """ :returns: The workspace_sid :rtype: unicode """ return self._properties['workspace_sid'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self, task_channel=values.unset): """ Fetch a WorkersRealTimeStatisticsInstance :param unicode task_channel: The task_channel :returns: Fetched WorkersRealTimeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.workers_real_time_statistics.WorkersRealTimeStatisticsInstance """ return self._proxy.fetch(task_channel=task_channel,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/taskrouter/v1/workspace/worker/workers_statistics.py000066400000000000000000000232561317472742600312460ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import serialize 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.page import Page class WorkersStatisticsList(ListResource): """ """ def __init__(self, version, workspace_sid): """ Initialize the WorkersStatisticsList :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :returns: twilio.rest.taskrouter.v1.workspace.worker.workers_statistics.WorkersStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.worker.workers_statistics.WorkersStatisticsList """ super(WorkersStatisticsList, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid,} def get(self): """ Constructs a WorkersStatisticsContext :returns: twilio.rest.taskrouter.v1.workspace.worker.workers_statistics.WorkersStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.worker.workers_statistics.WorkersStatisticsContext """ return WorkersStatisticsContext(self._version, workspace_sid=self._solution['workspace_sid'],) def __call__(self): """ Constructs a WorkersStatisticsContext :returns: twilio.rest.taskrouter.v1.workspace.worker.workers_statistics.WorkersStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.worker.workers_statistics.WorkersStatisticsContext """ return WorkersStatisticsContext(self._version, workspace_sid=self._solution['workspace_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class WorkersStatisticsPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the WorkersStatisticsPage :param Version version: Version that contains the resource :param Response response: Response from the API :param workspace_sid: The workspace_sid :returns: twilio.rest.taskrouter.v1.workspace.worker.workers_statistics.WorkersStatisticsPage :rtype: twilio.rest.taskrouter.v1.workspace.worker.workers_statistics.WorkersStatisticsPage """ super(WorkersStatisticsPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of WorkersStatisticsInstance :param dict payload: Payload response from the API :returns: twilio.rest.taskrouter.v1.workspace.worker.workers_statistics.WorkersStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.workers_statistics.WorkersStatisticsInstance """ return WorkersStatisticsInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class WorkersStatisticsContext(InstanceContext): """ """ def __init__(self, version, workspace_sid): """ Initialize the WorkersStatisticsContext :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :returns: twilio.rest.taskrouter.v1.workspace.worker.workers_statistics.WorkersStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.worker.workers_statistics.WorkersStatisticsContext """ super(WorkersStatisticsContext, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid,} self._uri = '/Workspaces/{workspace_sid}/Workers/Statistics'.format(**self._solution) def fetch(self, minutes=values.unset, start_date=values.unset, end_date=values.unset, task_queue_sid=values.unset, task_queue_name=values.unset, friendly_name=values.unset, task_channel=values.unset): """ Fetch a WorkersStatisticsInstance :param unicode minutes: The minutes :param datetime start_date: The start_date :param datetime end_date: The end_date :param unicode task_queue_sid: The task_queue_sid :param unicode task_queue_name: The task_queue_name :param unicode friendly_name: The friendly_name :param unicode task_channel: The task_channel :returns: Fetched WorkersStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.workers_statistics.WorkersStatisticsInstance """ params = values.of({ 'Minutes': minutes, 'StartDate': serialize.iso8601_datetime(start_date), 'EndDate': serialize.iso8601_datetime(end_date), 'TaskQueueSid': task_queue_sid, 'TaskQueueName': task_queue_name, 'FriendlyName': friendly_name, 'TaskChannel': task_channel, }) payload = self._version.fetch( 'GET', self._uri, params=params, ) return WorkersStatisticsInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class WorkersStatisticsInstance(InstanceResource): """ """ def __init__(self, version, payload, workspace_sid): """ Initialize the WorkersStatisticsInstance :returns: twilio.rest.taskrouter.v1.workspace.worker.workers_statistics.WorkersStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.workers_statistics.WorkersStatisticsInstance """ super(WorkersStatisticsInstance, self).__init__(version) # Marshaled Properties self._properties = { 'realtime': payload['realtime'], 'cumulative': payload['cumulative'], 'account_sid': payload['account_sid'], 'workspace_sid': payload['workspace_sid'], 'url': payload['url'], } # Context self._context = None self._solution = {'workspace_sid': workspace_sid,} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: WorkersStatisticsContext for this WorkersStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.workers_statistics.WorkersStatisticsContext """ if self._context is None: self._context = WorkersStatisticsContext( self._version, workspace_sid=self._solution['workspace_sid'], ) return self._context @property def realtime(self): """ :returns: The realtime :rtype: dict """ return self._properties['realtime'] @property def cumulative(self): """ :returns: The cumulative :rtype: dict """ return self._properties['cumulative'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def workspace_sid(self): """ :returns: The workspace_sid :rtype: unicode """ return self._properties['workspace_sid'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self, minutes=values.unset, start_date=values.unset, end_date=values.unset, task_queue_sid=values.unset, task_queue_name=values.unset, friendly_name=values.unset, task_channel=values.unset): """ Fetch a WorkersStatisticsInstance :param unicode minutes: The minutes :param datetime start_date: The start_date :param datetime end_date: The end_date :param unicode task_queue_sid: The task_queue_sid :param unicode task_queue_name: The task_queue_name :param unicode friendly_name: The friendly_name :param unicode task_channel: The task_channel :returns: Fetched WorkersStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.worker.workers_statistics.WorkersStatisticsInstance """ return self._proxy.fetch( minutes=minutes, start_date=start_date, end_date=end_date, task_queue_sid=task_queue_sid, task_queue_name=task_queue_name, friendly_name=friendly_name, task_channel=task_channel, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/taskrouter/v1/workspace/workflow/000077500000000000000000000000001317472742600252575ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/taskrouter/v1/workspace/workflow/__init__.py000066400000000000000000000524421317472742600273770ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.taskrouter.v1.workspace.workflow.workflow_cumulative_statistics import WorkflowCumulativeStatisticsList from twilio.rest.taskrouter.v1.workspace.workflow.workflow_real_time_statistics import WorkflowRealTimeStatisticsList from twilio.rest.taskrouter.v1.workspace.workflow.workflow_statistics import WorkflowStatisticsList class WorkflowList(ListResource): """ """ def __init__(self, version, workspace_sid): """ Initialize the WorkflowList :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :returns: twilio.rest.taskrouter.v1.workspace.workflow.WorkflowList :rtype: twilio.rest.taskrouter.v1.workspace.workflow.WorkflowList """ super(WorkflowList, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid,} self._uri = '/Workspaces/{workspace_sid}/Workflows'.format(**self._solution) def stream(self, friendly_name=values.unset, limit=None, page_size=None): """ Streams WorkflowInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param unicode friendly_name: The friendly_name :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.taskrouter.v1.workspace.workflow.WorkflowInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(friendly_name=friendly_name, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, friendly_name=values.unset, limit=None, page_size=None): """ Lists WorkflowInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param unicode friendly_name: The friendly_name :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.taskrouter.v1.workspace.workflow.WorkflowInstance] """ return list(self.stream(friendly_name=friendly_name, limit=limit, page_size=page_size,)) def page(self, friendly_name=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of WorkflowInstance records from the API. Request is executed immediately :param unicode friendly_name: The friendly_name :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of WorkflowInstance :rtype: twilio.rest.taskrouter.v1.workspace.workflow.WorkflowPage """ params = values.of({ 'FriendlyName': friendly_name, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return WorkflowPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of WorkflowInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of WorkflowInstance :rtype: twilio.rest.taskrouter.v1.workspace.workflow.WorkflowPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return WorkflowPage(self._version, response, self._solution) def create(self, friendly_name, configuration, assignment_callback_url=values.unset, fallback_assignment_callback_url=values.unset, task_reservation_timeout=values.unset): """ Create a new WorkflowInstance :param unicode friendly_name: The friendly_name :param unicode configuration: The configuration :param unicode assignment_callback_url: The assignment_callback_url :param unicode fallback_assignment_callback_url: The fallback_assignment_callback_url :param unicode task_reservation_timeout: The task_reservation_timeout :returns: Newly created WorkflowInstance :rtype: twilio.rest.taskrouter.v1.workspace.workflow.WorkflowInstance """ data = values.of({ 'FriendlyName': friendly_name, 'Configuration': configuration, 'AssignmentCallbackUrl': assignment_callback_url, 'FallbackAssignmentCallbackUrl': fallback_assignment_callback_url, 'TaskReservationTimeout': task_reservation_timeout, }) payload = self._version.create( 'POST', self._uri, data=data, ) return WorkflowInstance(self._version, payload, workspace_sid=self._solution['workspace_sid'],) def get(self, sid): """ Constructs a WorkflowContext :param sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.workflow.WorkflowContext :rtype: twilio.rest.taskrouter.v1.workspace.workflow.WorkflowContext """ return WorkflowContext(self._version, workspace_sid=self._solution['workspace_sid'], sid=sid,) def __call__(self, sid): """ Constructs a WorkflowContext :param sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.workflow.WorkflowContext :rtype: twilio.rest.taskrouter.v1.workspace.workflow.WorkflowContext """ return WorkflowContext(self._version, workspace_sid=self._solution['workspace_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class WorkflowPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the WorkflowPage :param Version version: Version that contains the resource :param Response response: Response from the API :param workspace_sid: The workspace_sid :returns: twilio.rest.taskrouter.v1.workspace.workflow.WorkflowPage :rtype: twilio.rest.taskrouter.v1.workspace.workflow.WorkflowPage """ super(WorkflowPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of WorkflowInstance :param dict payload: Payload response from the API :returns: twilio.rest.taskrouter.v1.workspace.workflow.WorkflowInstance :rtype: twilio.rest.taskrouter.v1.workspace.workflow.WorkflowInstance """ return WorkflowInstance(self._version, payload, workspace_sid=self._solution['workspace_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class WorkflowContext(InstanceContext): """ """ def __init__(self, version, workspace_sid, sid): """ Initialize the WorkflowContext :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :param sid: The sid :returns: twilio.rest.taskrouter.v1.workspace.workflow.WorkflowContext :rtype: twilio.rest.taskrouter.v1.workspace.workflow.WorkflowContext """ super(WorkflowContext, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid, 'sid': sid,} self._uri = '/Workspaces/{workspace_sid}/Workflows/{sid}'.format(**self._solution) # Dependents self._statistics = None self._real_time_statistics = None self._cumulative_statistics = None def fetch(self): """ Fetch a WorkflowInstance :returns: Fetched WorkflowInstance :rtype: twilio.rest.taskrouter.v1.workspace.workflow.WorkflowInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return WorkflowInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], sid=self._solution['sid'], ) def update(self, friendly_name=values.unset, assignment_callback_url=values.unset, fallback_assignment_callback_url=values.unset, configuration=values.unset, task_reservation_timeout=values.unset): """ Update the WorkflowInstance :param unicode friendly_name: The friendly_name :param unicode assignment_callback_url: The assignment_callback_url :param unicode fallback_assignment_callback_url: The fallback_assignment_callback_url :param unicode configuration: The configuration :param unicode task_reservation_timeout: The task_reservation_timeout :returns: Updated WorkflowInstance :rtype: twilio.rest.taskrouter.v1.workspace.workflow.WorkflowInstance """ data = values.of({ 'FriendlyName': friendly_name, 'AssignmentCallbackUrl': assignment_callback_url, 'FallbackAssignmentCallbackUrl': fallback_assignment_callback_url, 'Configuration': configuration, 'TaskReservationTimeout': task_reservation_timeout, }) payload = self._version.update( 'POST', self._uri, data=data, ) return WorkflowInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the WorkflowInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) @property def statistics(self): """ Access the statistics :returns: twilio.rest.taskrouter.v1.workspace.workflow.workflow_statistics.WorkflowStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.workflow.workflow_statistics.WorkflowStatisticsList """ if self._statistics is None: self._statistics = WorkflowStatisticsList( self._version, workspace_sid=self._solution['workspace_sid'], workflow_sid=self._solution['sid'], ) return self._statistics @property def real_time_statistics(self): """ Access the real_time_statistics :returns: twilio.rest.taskrouter.v1.workspace.workflow.workflow_real_time_statistics.WorkflowRealTimeStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.workflow.workflow_real_time_statistics.WorkflowRealTimeStatisticsList """ if self._real_time_statistics is None: self._real_time_statistics = WorkflowRealTimeStatisticsList( self._version, workspace_sid=self._solution['workspace_sid'], workflow_sid=self._solution['sid'], ) return self._real_time_statistics @property def cumulative_statistics(self): """ Access the cumulative_statistics :returns: twilio.rest.taskrouter.v1.workspace.workflow.workflow_cumulative_statistics.WorkflowCumulativeStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.workflow.workflow_cumulative_statistics.WorkflowCumulativeStatisticsList """ if self._cumulative_statistics is None: self._cumulative_statistics = WorkflowCumulativeStatisticsList( self._version, workspace_sid=self._solution['workspace_sid'], workflow_sid=self._solution['sid'], ) return self._cumulative_statistics def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class WorkflowInstance(InstanceResource): """ """ def __init__(self, version, payload, workspace_sid, sid=None): """ Initialize the WorkflowInstance :returns: twilio.rest.taskrouter.v1.workspace.workflow.WorkflowInstance :rtype: twilio.rest.taskrouter.v1.workspace.workflow.WorkflowInstance """ super(WorkflowInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'assignment_callback_url': payload['assignment_callback_url'], 'configuration': payload['configuration'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'document_content_type': payload['document_content_type'], 'fallback_assignment_callback_url': payload['fallback_assignment_callback_url'], 'friendly_name': payload['friendly_name'], 'sid': payload['sid'], 'task_reservation_timeout': deserialize.integer(payload['task_reservation_timeout']), 'workspace_sid': payload['workspace_sid'], 'url': payload['url'], 'links': payload['links'], } # Context self._context = None self._solution = {'workspace_sid': workspace_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: WorkflowContext for this WorkflowInstance :rtype: twilio.rest.taskrouter.v1.workspace.workflow.WorkflowContext """ if self._context is None: self._context = WorkflowContext( self._version, workspace_sid=self._solution['workspace_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def assignment_callback_url(self): """ :returns: The assignment_callback_url :rtype: unicode """ return self._properties['assignment_callback_url'] @property def configuration(self): """ :returns: The configuration :rtype: unicode """ return self._properties['configuration'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def document_content_type(self): """ :returns: The document_content_type :rtype: unicode """ return self._properties['document_content_type'] @property def fallback_assignment_callback_url(self): """ :returns: The fallback_assignment_callback_url :rtype: unicode """ return self._properties['fallback_assignment_callback_url'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def task_reservation_timeout(self): """ :returns: The task_reservation_timeout :rtype: unicode """ return self._properties['task_reservation_timeout'] @property def workspace_sid(self): """ :returns: The workspace_sid :rtype: unicode """ return self._properties['workspace_sid'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a WorkflowInstance :returns: Fetched WorkflowInstance :rtype: twilio.rest.taskrouter.v1.workspace.workflow.WorkflowInstance """ return self._proxy.fetch() def update(self, friendly_name=values.unset, assignment_callback_url=values.unset, fallback_assignment_callback_url=values.unset, configuration=values.unset, task_reservation_timeout=values.unset): """ Update the WorkflowInstance :param unicode friendly_name: The friendly_name :param unicode assignment_callback_url: The assignment_callback_url :param unicode fallback_assignment_callback_url: The fallback_assignment_callback_url :param unicode configuration: The configuration :param unicode task_reservation_timeout: The task_reservation_timeout :returns: Updated WorkflowInstance :rtype: twilio.rest.taskrouter.v1.workspace.workflow.WorkflowInstance """ return self._proxy.update( friendly_name=friendly_name, assignment_callback_url=assignment_callback_url, fallback_assignment_callback_url=fallback_assignment_callback_url, configuration=configuration, task_reservation_timeout=task_reservation_timeout, ) def delete(self): """ Deletes the WorkflowInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() @property def statistics(self): """ Access the statistics :returns: twilio.rest.taskrouter.v1.workspace.workflow.workflow_statistics.WorkflowStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.workflow.workflow_statistics.WorkflowStatisticsList """ return self._proxy.statistics @property def real_time_statistics(self): """ Access the real_time_statistics :returns: twilio.rest.taskrouter.v1.workspace.workflow.workflow_real_time_statistics.WorkflowRealTimeStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.workflow.workflow_real_time_statistics.WorkflowRealTimeStatisticsList """ return self._proxy.real_time_statistics @property def cumulative_statistics(self): """ Access the cumulative_statistics :returns: twilio.rest.taskrouter.v1.workspace.workflow.workflow_cumulative_statistics.WorkflowCumulativeStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.workflow.workflow_cumulative_statistics.WorkflowCumulativeStatisticsList """ return self._proxy.cumulative_statistics def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/taskrouter/v1/workspace/workflow/workflow_cumulative_statistics.py000066400000000000000000000364501317472742600342230ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize 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.page import Page class WorkflowCumulativeStatisticsList(ListResource): """ """ def __init__(self, version, workspace_sid, workflow_sid): """ Initialize the WorkflowCumulativeStatisticsList :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :param workflow_sid: The workflow_sid :returns: twilio.rest.taskrouter.v1.workspace.workflow.workflow_cumulative_statistics.WorkflowCumulativeStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.workflow.workflow_cumulative_statistics.WorkflowCumulativeStatisticsList """ super(WorkflowCumulativeStatisticsList, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid, 'workflow_sid': workflow_sid,} def get(self): """ Constructs a WorkflowCumulativeStatisticsContext :returns: twilio.rest.taskrouter.v1.workspace.workflow.workflow_cumulative_statistics.WorkflowCumulativeStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.workflow.workflow_cumulative_statistics.WorkflowCumulativeStatisticsContext """ return WorkflowCumulativeStatisticsContext( self._version, workspace_sid=self._solution['workspace_sid'], workflow_sid=self._solution['workflow_sid'], ) def __call__(self): """ Constructs a WorkflowCumulativeStatisticsContext :returns: twilio.rest.taskrouter.v1.workspace.workflow.workflow_cumulative_statistics.WorkflowCumulativeStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.workflow.workflow_cumulative_statistics.WorkflowCumulativeStatisticsContext """ return WorkflowCumulativeStatisticsContext( self._version, workspace_sid=self._solution['workspace_sid'], workflow_sid=self._solution['workflow_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class WorkflowCumulativeStatisticsPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the WorkflowCumulativeStatisticsPage :param Version version: Version that contains the resource :param Response response: Response from the API :param workspace_sid: The workspace_sid :param workflow_sid: The workflow_sid :returns: twilio.rest.taskrouter.v1.workspace.workflow.workflow_cumulative_statistics.WorkflowCumulativeStatisticsPage :rtype: twilio.rest.taskrouter.v1.workspace.workflow.workflow_cumulative_statistics.WorkflowCumulativeStatisticsPage """ super(WorkflowCumulativeStatisticsPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of WorkflowCumulativeStatisticsInstance :param dict payload: Payload response from the API :returns: twilio.rest.taskrouter.v1.workspace.workflow.workflow_cumulative_statistics.WorkflowCumulativeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.workflow.workflow_cumulative_statistics.WorkflowCumulativeStatisticsInstance """ return WorkflowCumulativeStatisticsInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], workflow_sid=self._solution['workflow_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class WorkflowCumulativeStatisticsContext(InstanceContext): """ """ def __init__(self, version, workspace_sid, workflow_sid): """ Initialize the WorkflowCumulativeStatisticsContext :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :param workflow_sid: The workflow_sid :returns: twilio.rest.taskrouter.v1.workspace.workflow.workflow_cumulative_statistics.WorkflowCumulativeStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.workflow.workflow_cumulative_statistics.WorkflowCumulativeStatisticsContext """ super(WorkflowCumulativeStatisticsContext, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid, 'workflow_sid': workflow_sid,} self._uri = '/Workspaces/{workspace_sid}/Workflows/{workflow_sid}/CumulativeStatistics'.format(**self._solution) def fetch(self, end_date=values.unset, minutes=values.unset, start_date=values.unset, task_channel=values.unset, split_by_wait_time=values.unset): """ Fetch a WorkflowCumulativeStatisticsInstance :param datetime end_date: The end_date :param unicode minutes: The minutes :param datetime start_date: The start_date :param unicode task_channel: The task_channel :param unicode split_by_wait_time: The split_by_wait_time :returns: Fetched WorkflowCumulativeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.workflow.workflow_cumulative_statistics.WorkflowCumulativeStatisticsInstance """ params = values.of({ 'EndDate': serialize.iso8601_datetime(end_date), 'Minutes': minutes, 'StartDate': serialize.iso8601_datetime(start_date), 'TaskChannel': task_channel, 'SplitByWaitTime': split_by_wait_time, }) payload = self._version.fetch( 'GET', self._uri, params=params, ) return WorkflowCumulativeStatisticsInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], workflow_sid=self._solution['workflow_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class WorkflowCumulativeStatisticsInstance(InstanceResource): """ """ def __init__(self, version, payload, workspace_sid, workflow_sid): """ Initialize the WorkflowCumulativeStatisticsInstance :returns: twilio.rest.taskrouter.v1.workspace.workflow.workflow_cumulative_statistics.WorkflowCumulativeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.workflow.workflow_cumulative_statistics.WorkflowCumulativeStatisticsInstance """ super(WorkflowCumulativeStatisticsInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'avg_task_acceptance_time': deserialize.integer(payload['avg_task_acceptance_time']), 'start_time': deserialize.iso8601_datetime(payload['start_time']), 'end_time': deserialize.iso8601_datetime(payload['end_time']), 'reservations_created': deserialize.integer(payload['reservations_created']), 'reservations_accepted': deserialize.integer(payload['reservations_accepted']), 'reservations_rejected': deserialize.integer(payload['reservations_rejected']), 'reservations_timed_out': deserialize.integer(payload['reservations_timed_out']), 'reservations_canceled': deserialize.integer(payload['reservations_canceled']), 'reservations_rescinded': deserialize.integer(payload['reservations_rescinded']), 'split_by_wait_time': payload['split_by_wait_time'], 'wait_duration_until_accepted': payload['wait_duration_until_accepted'], 'wait_duration_until_canceled': payload['wait_duration_until_canceled'], 'tasks_canceled': deserialize.integer(payload['tasks_canceled']), 'tasks_completed': deserialize.integer(payload['tasks_completed']), 'tasks_entered': deserialize.integer(payload['tasks_entered']), 'tasks_deleted': deserialize.integer(payload['tasks_deleted']), 'tasks_moved': deserialize.integer(payload['tasks_moved']), 'tasks_timed_out_in_workflow': deserialize.integer(payload['tasks_timed_out_in_workflow']), 'workflow_sid': payload['workflow_sid'], 'workspace_sid': payload['workspace_sid'], 'url': payload['url'], } # Context self._context = None self._solution = {'workspace_sid': workspace_sid, 'workflow_sid': workflow_sid,} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: WorkflowCumulativeStatisticsContext for this WorkflowCumulativeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.workflow.workflow_cumulative_statistics.WorkflowCumulativeStatisticsContext """ if self._context is None: self._context = WorkflowCumulativeStatisticsContext( self._version, workspace_sid=self._solution['workspace_sid'], workflow_sid=self._solution['workflow_sid'], ) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def avg_task_acceptance_time(self): """ :returns: The avg_task_acceptance_time :rtype: unicode """ return self._properties['avg_task_acceptance_time'] @property def start_time(self): """ :returns: The start_time :rtype: datetime """ return self._properties['start_time'] @property def end_time(self): """ :returns: The end_time :rtype: datetime """ return self._properties['end_time'] @property def reservations_created(self): """ :returns: The reservations_created :rtype: unicode """ return self._properties['reservations_created'] @property def reservations_accepted(self): """ :returns: The reservations_accepted :rtype: unicode """ return self._properties['reservations_accepted'] @property def reservations_rejected(self): """ :returns: The reservations_rejected :rtype: unicode """ return self._properties['reservations_rejected'] @property def reservations_timed_out(self): """ :returns: The reservations_timed_out :rtype: unicode """ return self._properties['reservations_timed_out'] @property def reservations_canceled(self): """ :returns: The reservations_canceled :rtype: unicode """ return self._properties['reservations_canceled'] @property def reservations_rescinded(self): """ :returns: The reservations_rescinded :rtype: unicode """ return self._properties['reservations_rescinded'] @property def split_by_wait_time(self): """ :returns: The split_by_wait_time :rtype: dict """ return self._properties['split_by_wait_time'] @property def wait_duration_until_accepted(self): """ :returns: The wait_duration_until_accepted :rtype: dict """ return self._properties['wait_duration_until_accepted'] @property def wait_duration_until_canceled(self): """ :returns: The wait_duration_until_canceled :rtype: dict """ return self._properties['wait_duration_until_canceled'] @property def tasks_canceled(self): """ :returns: The tasks_canceled :rtype: unicode """ return self._properties['tasks_canceled'] @property def tasks_completed(self): """ :returns: The tasks_completed :rtype: unicode """ return self._properties['tasks_completed'] @property def tasks_entered(self): """ :returns: The tasks_entered :rtype: unicode """ return self._properties['tasks_entered'] @property def tasks_deleted(self): """ :returns: The tasks_deleted :rtype: unicode """ return self._properties['tasks_deleted'] @property def tasks_moved(self): """ :returns: The tasks_moved :rtype: unicode """ return self._properties['tasks_moved'] @property def tasks_timed_out_in_workflow(self): """ :returns: The tasks_timed_out_in_workflow :rtype: unicode """ return self._properties['tasks_timed_out_in_workflow'] @property def workflow_sid(self): """ :returns: The workflow_sid :rtype: unicode """ return self._properties['workflow_sid'] @property def workspace_sid(self): """ :returns: The workspace_sid :rtype: unicode """ return self._properties['workspace_sid'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self, end_date=values.unset, minutes=values.unset, start_date=values.unset, task_channel=values.unset, split_by_wait_time=values.unset): """ Fetch a WorkflowCumulativeStatisticsInstance :param datetime end_date: The end_date :param unicode minutes: The minutes :param datetime start_date: The start_date :param unicode task_channel: The task_channel :param unicode split_by_wait_time: The split_by_wait_time :returns: Fetched WorkflowCumulativeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.workflow.workflow_cumulative_statistics.WorkflowCumulativeStatisticsInstance """ return self._proxy.fetch( end_date=end_date, minutes=minutes, start_date=start_date, task_channel=task_channel, split_by_wait_time=split_by_wait_time, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/taskrouter/v1/workspace/workflow/workflow_real_time_statistics.py000066400000000000000000000243331317472742600340030ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class WorkflowRealTimeStatisticsList(ListResource): """ """ def __init__(self, version, workspace_sid, workflow_sid): """ Initialize the WorkflowRealTimeStatisticsList :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :param workflow_sid: The workflow_sid :returns: twilio.rest.taskrouter.v1.workspace.workflow.workflow_real_time_statistics.WorkflowRealTimeStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.workflow.workflow_real_time_statistics.WorkflowRealTimeStatisticsList """ super(WorkflowRealTimeStatisticsList, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid, 'workflow_sid': workflow_sid,} def get(self): """ Constructs a WorkflowRealTimeStatisticsContext :returns: twilio.rest.taskrouter.v1.workspace.workflow.workflow_real_time_statistics.WorkflowRealTimeStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.workflow.workflow_real_time_statistics.WorkflowRealTimeStatisticsContext """ return WorkflowRealTimeStatisticsContext( self._version, workspace_sid=self._solution['workspace_sid'], workflow_sid=self._solution['workflow_sid'], ) def __call__(self): """ Constructs a WorkflowRealTimeStatisticsContext :returns: twilio.rest.taskrouter.v1.workspace.workflow.workflow_real_time_statistics.WorkflowRealTimeStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.workflow.workflow_real_time_statistics.WorkflowRealTimeStatisticsContext """ return WorkflowRealTimeStatisticsContext( self._version, workspace_sid=self._solution['workspace_sid'], workflow_sid=self._solution['workflow_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class WorkflowRealTimeStatisticsPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the WorkflowRealTimeStatisticsPage :param Version version: Version that contains the resource :param Response response: Response from the API :param workspace_sid: The workspace_sid :param workflow_sid: The workflow_sid :returns: twilio.rest.taskrouter.v1.workspace.workflow.workflow_real_time_statistics.WorkflowRealTimeStatisticsPage :rtype: twilio.rest.taskrouter.v1.workspace.workflow.workflow_real_time_statistics.WorkflowRealTimeStatisticsPage """ super(WorkflowRealTimeStatisticsPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of WorkflowRealTimeStatisticsInstance :param dict payload: Payload response from the API :returns: twilio.rest.taskrouter.v1.workspace.workflow.workflow_real_time_statistics.WorkflowRealTimeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.workflow.workflow_real_time_statistics.WorkflowRealTimeStatisticsInstance """ return WorkflowRealTimeStatisticsInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], workflow_sid=self._solution['workflow_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class WorkflowRealTimeStatisticsContext(InstanceContext): """ """ def __init__(self, version, workspace_sid, workflow_sid): """ Initialize the WorkflowRealTimeStatisticsContext :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :param workflow_sid: The workflow_sid :returns: twilio.rest.taskrouter.v1.workspace.workflow.workflow_real_time_statistics.WorkflowRealTimeStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.workflow.workflow_real_time_statistics.WorkflowRealTimeStatisticsContext """ super(WorkflowRealTimeStatisticsContext, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid, 'workflow_sid': workflow_sid,} self._uri = '/Workspaces/{workspace_sid}/Workflows/{workflow_sid}/RealTimeStatistics'.format(**self._solution) def fetch(self, task_channel=values.unset): """ Fetch a WorkflowRealTimeStatisticsInstance :param unicode task_channel: The task_channel :returns: Fetched WorkflowRealTimeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.workflow.workflow_real_time_statistics.WorkflowRealTimeStatisticsInstance """ params = values.of({'TaskChannel': task_channel,}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return WorkflowRealTimeStatisticsInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], workflow_sid=self._solution['workflow_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class WorkflowRealTimeStatisticsInstance(InstanceResource): """ """ def __init__(self, version, payload, workspace_sid, workflow_sid): """ Initialize the WorkflowRealTimeStatisticsInstance :returns: twilio.rest.taskrouter.v1.workspace.workflow.workflow_real_time_statistics.WorkflowRealTimeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.workflow.workflow_real_time_statistics.WorkflowRealTimeStatisticsInstance """ super(WorkflowRealTimeStatisticsInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'longest_task_waiting_age': deserialize.integer(payload['longest_task_waiting_age']), 'tasks_by_priority': payload['tasks_by_priority'], 'tasks_by_status': payload['tasks_by_status'], 'total_tasks': deserialize.integer(payload['total_tasks']), 'workflow_sid': payload['workflow_sid'], 'workspace_sid': payload['workspace_sid'], 'url': payload['url'], } # Context self._context = None self._solution = {'workspace_sid': workspace_sid, 'workflow_sid': workflow_sid,} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: WorkflowRealTimeStatisticsContext for this WorkflowRealTimeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.workflow.workflow_real_time_statistics.WorkflowRealTimeStatisticsContext """ if self._context is None: self._context = WorkflowRealTimeStatisticsContext( self._version, workspace_sid=self._solution['workspace_sid'], workflow_sid=self._solution['workflow_sid'], ) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def longest_task_waiting_age(self): """ :returns: The longest_task_waiting_age :rtype: unicode """ return self._properties['longest_task_waiting_age'] @property def tasks_by_priority(self): """ :returns: The tasks_by_priority :rtype: dict """ return self._properties['tasks_by_priority'] @property def tasks_by_status(self): """ :returns: The tasks_by_status :rtype: dict """ return self._properties['tasks_by_status'] @property def total_tasks(self): """ :returns: The total_tasks :rtype: unicode """ return self._properties['total_tasks'] @property def workflow_sid(self): """ :returns: The workflow_sid :rtype: unicode """ return self._properties['workflow_sid'] @property def workspace_sid(self): """ :returns: The workspace_sid :rtype: unicode """ return self._properties['workspace_sid'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self, task_channel=values.unset): """ Fetch a WorkflowRealTimeStatisticsInstance :param unicode task_channel: The task_channel :returns: Fetched WorkflowRealTimeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.workflow.workflow_real_time_statistics.WorkflowRealTimeStatisticsInstance """ return self._proxy.fetch(task_channel=task_channel,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/taskrouter/v1/workspace/workflow/workflow_statistics.py000066400000000000000000000241671317472742600317670ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import serialize 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.page import Page class WorkflowStatisticsList(ListResource): """ """ def __init__(self, version, workspace_sid, workflow_sid): """ Initialize the WorkflowStatisticsList :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :param workflow_sid: The workflow_sid :returns: twilio.rest.taskrouter.v1.workspace.workflow.workflow_statistics.WorkflowStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.workflow.workflow_statistics.WorkflowStatisticsList """ super(WorkflowStatisticsList, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid, 'workflow_sid': workflow_sid,} def get(self): """ Constructs a WorkflowStatisticsContext :returns: twilio.rest.taskrouter.v1.workspace.workflow.workflow_statistics.WorkflowStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.workflow.workflow_statistics.WorkflowStatisticsContext """ return WorkflowStatisticsContext( self._version, workspace_sid=self._solution['workspace_sid'], workflow_sid=self._solution['workflow_sid'], ) def __call__(self): """ Constructs a WorkflowStatisticsContext :returns: twilio.rest.taskrouter.v1.workspace.workflow.workflow_statistics.WorkflowStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.workflow.workflow_statistics.WorkflowStatisticsContext """ return WorkflowStatisticsContext( self._version, workspace_sid=self._solution['workspace_sid'], workflow_sid=self._solution['workflow_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class WorkflowStatisticsPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the WorkflowStatisticsPage :param Version version: Version that contains the resource :param Response response: Response from the API :param workspace_sid: The workspace_sid :param workflow_sid: The workflow_sid :returns: twilio.rest.taskrouter.v1.workspace.workflow.workflow_statistics.WorkflowStatisticsPage :rtype: twilio.rest.taskrouter.v1.workspace.workflow.workflow_statistics.WorkflowStatisticsPage """ super(WorkflowStatisticsPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of WorkflowStatisticsInstance :param dict payload: Payload response from the API :returns: twilio.rest.taskrouter.v1.workspace.workflow.workflow_statistics.WorkflowStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.workflow.workflow_statistics.WorkflowStatisticsInstance """ return WorkflowStatisticsInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], workflow_sid=self._solution['workflow_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class WorkflowStatisticsContext(InstanceContext): """ """ def __init__(self, version, workspace_sid, workflow_sid): """ Initialize the WorkflowStatisticsContext :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :param workflow_sid: The workflow_sid :returns: twilio.rest.taskrouter.v1.workspace.workflow.workflow_statistics.WorkflowStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.workflow.workflow_statistics.WorkflowStatisticsContext """ super(WorkflowStatisticsContext, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid, 'workflow_sid': workflow_sid,} self._uri = '/Workspaces/{workspace_sid}/Workflows/{workflow_sid}/Statistics'.format(**self._solution) def fetch(self, minutes=values.unset, start_date=values.unset, end_date=values.unset, task_channel=values.unset, split_by_wait_time=values.unset): """ Fetch a WorkflowStatisticsInstance :param unicode minutes: The minutes :param datetime start_date: The start_date :param datetime end_date: The end_date :param unicode task_channel: The task_channel :param unicode split_by_wait_time: The split_by_wait_time :returns: Fetched WorkflowStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.workflow.workflow_statistics.WorkflowStatisticsInstance """ params = values.of({ 'Minutes': minutes, 'StartDate': serialize.iso8601_datetime(start_date), 'EndDate': serialize.iso8601_datetime(end_date), 'TaskChannel': task_channel, 'SplitByWaitTime': split_by_wait_time, }) payload = self._version.fetch( 'GET', self._uri, params=params, ) return WorkflowStatisticsInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], workflow_sid=self._solution['workflow_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class WorkflowStatisticsInstance(InstanceResource): """ """ def __init__(self, version, payload, workspace_sid, workflow_sid): """ Initialize the WorkflowStatisticsInstance :returns: twilio.rest.taskrouter.v1.workspace.workflow.workflow_statistics.WorkflowStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.workflow.workflow_statistics.WorkflowStatisticsInstance """ super(WorkflowStatisticsInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'cumulative': payload['cumulative'], 'realtime': payload['realtime'], 'workflow_sid': payload['workflow_sid'], 'workspace_sid': payload['workspace_sid'], 'url': payload['url'], } # Context self._context = None self._solution = {'workspace_sid': workspace_sid, 'workflow_sid': workflow_sid,} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: WorkflowStatisticsContext for this WorkflowStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.workflow.workflow_statistics.WorkflowStatisticsContext """ if self._context is None: self._context = WorkflowStatisticsContext( self._version, workspace_sid=self._solution['workspace_sid'], workflow_sid=self._solution['workflow_sid'], ) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def cumulative(self): """ :returns: The cumulative :rtype: dict """ return self._properties['cumulative'] @property def realtime(self): """ :returns: The realtime :rtype: dict """ return self._properties['realtime'] @property def workflow_sid(self): """ :returns: The workflow_sid :rtype: unicode """ return self._properties['workflow_sid'] @property def workspace_sid(self): """ :returns: The workspace_sid :rtype: unicode """ return self._properties['workspace_sid'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self, minutes=values.unset, start_date=values.unset, end_date=values.unset, task_channel=values.unset, split_by_wait_time=values.unset): """ Fetch a WorkflowStatisticsInstance :param unicode minutes: The minutes :param datetime start_date: The start_date :param datetime end_date: The end_date :param unicode task_channel: The task_channel :param unicode split_by_wait_time: The split_by_wait_time :returns: Fetched WorkflowStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.workflow.workflow_statistics.WorkflowStatisticsInstance """ return self._proxy.fetch( minutes=minutes, start_date=start_date, end_date=end_date, task_channel=task_channel, split_by_wait_time=split_by_wait_time, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/taskrouter/v1/workspace/workspace_cumulative_statistics.py000066400000000000000000000346441317472742600325000ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize 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.page import Page class WorkspaceCumulativeStatisticsList(ListResource): """ """ def __init__(self, version, workspace_sid): """ Initialize the WorkspaceCumulativeStatisticsList :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :returns: twilio.rest.taskrouter.v1.workspace.workspace_cumulative_statistics.WorkspaceCumulativeStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.workspace_cumulative_statistics.WorkspaceCumulativeStatisticsList """ super(WorkspaceCumulativeStatisticsList, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid,} def get(self): """ Constructs a WorkspaceCumulativeStatisticsContext :returns: twilio.rest.taskrouter.v1.workspace.workspace_cumulative_statistics.WorkspaceCumulativeStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.workspace_cumulative_statistics.WorkspaceCumulativeStatisticsContext """ return WorkspaceCumulativeStatisticsContext( self._version, workspace_sid=self._solution['workspace_sid'], ) def __call__(self): """ Constructs a WorkspaceCumulativeStatisticsContext :returns: twilio.rest.taskrouter.v1.workspace.workspace_cumulative_statistics.WorkspaceCumulativeStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.workspace_cumulative_statistics.WorkspaceCumulativeStatisticsContext """ return WorkspaceCumulativeStatisticsContext( self._version, workspace_sid=self._solution['workspace_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class WorkspaceCumulativeStatisticsPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the WorkspaceCumulativeStatisticsPage :param Version version: Version that contains the resource :param Response response: Response from the API :param workspace_sid: The workspace_sid :returns: twilio.rest.taskrouter.v1.workspace.workspace_cumulative_statistics.WorkspaceCumulativeStatisticsPage :rtype: twilio.rest.taskrouter.v1.workspace.workspace_cumulative_statistics.WorkspaceCumulativeStatisticsPage """ super(WorkspaceCumulativeStatisticsPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of WorkspaceCumulativeStatisticsInstance :param dict payload: Payload response from the API :returns: twilio.rest.taskrouter.v1.workspace.workspace_cumulative_statistics.WorkspaceCumulativeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.workspace_cumulative_statistics.WorkspaceCumulativeStatisticsInstance """ return WorkspaceCumulativeStatisticsInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class WorkspaceCumulativeStatisticsContext(InstanceContext): """ """ def __init__(self, version, workspace_sid): """ Initialize the WorkspaceCumulativeStatisticsContext :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :returns: twilio.rest.taskrouter.v1.workspace.workspace_cumulative_statistics.WorkspaceCumulativeStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.workspace_cumulative_statistics.WorkspaceCumulativeStatisticsContext """ super(WorkspaceCumulativeStatisticsContext, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid,} self._uri = '/Workspaces/{workspace_sid}/CumulativeStatistics'.format(**self._solution) def fetch(self, end_date=values.unset, minutes=values.unset, start_date=values.unset, task_channel=values.unset, split_by_wait_time=values.unset): """ Fetch a WorkspaceCumulativeStatisticsInstance :param datetime end_date: The end_date :param unicode minutes: The minutes :param datetime start_date: The start_date :param unicode task_channel: The task_channel :param unicode split_by_wait_time: The split_by_wait_time :returns: Fetched WorkspaceCumulativeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.workspace_cumulative_statistics.WorkspaceCumulativeStatisticsInstance """ params = values.of({ 'EndDate': serialize.iso8601_datetime(end_date), 'Minutes': minutes, 'StartDate': serialize.iso8601_datetime(start_date), 'TaskChannel': task_channel, 'SplitByWaitTime': split_by_wait_time, }) payload = self._version.fetch( 'GET', self._uri, params=params, ) return WorkspaceCumulativeStatisticsInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class WorkspaceCumulativeStatisticsInstance(InstanceResource): """ """ def __init__(self, version, payload, workspace_sid): """ Initialize the WorkspaceCumulativeStatisticsInstance :returns: twilio.rest.taskrouter.v1.workspace.workspace_cumulative_statistics.WorkspaceCumulativeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.workspace_cumulative_statistics.WorkspaceCumulativeStatisticsInstance """ super(WorkspaceCumulativeStatisticsInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'avg_task_acceptance_time': deserialize.integer(payload['avg_task_acceptance_time']), 'start_time': deserialize.iso8601_datetime(payload['start_time']), 'end_time': deserialize.iso8601_datetime(payload['end_time']), 'reservations_created': deserialize.integer(payload['reservations_created']), 'reservations_accepted': deserialize.integer(payload['reservations_accepted']), 'reservations_rejected': deserialize.integer(payload['reservations_rejected']), 'reservations_timed_out': deserialize.integer(payload['reservations_timed_out']), 'reservations_canceled': deserialize.integer(payload['reservations_canceled']), 'reservations_rescinded': deserialize.integer(payload['reservations_rescinded']), 'split_by_wait_time': payload['split_by_wait_time'], 'wait_duration_until_accepted': payload['wait_duration_until_accepted'], 'wait_duration_until_canceled': payload['wait_duration_until_canceled'], 'tasks_canceled': deserialize.integer(payload['tasks_canceled']), 'tasks_completed': deserialize.integer(payload['tasks_completed']), 'tasks_created': deserialize.integer(payload['tasks_created']), 'tasks_deleted': deserialize.integer(payload['tasks_deleted']), 'tasks_moved': deserialize.integer(payload['tasks_moved']), 'tasks_timed_out_in_workflow': deserialize.integer(payload['tasks_timed_out_in_workflow']), 'workspace_sid': payload['workspace_sid'], 'url': payload['url'], } # Context self._context = None self._solution = {'workspace_sid': workspace_sid,} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: WorkspaceCumulativeStatisticsContext for this WorkspaceCumulativeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.workspace_cumulative_statistics.WorkspaceCumulativeStatisticsContext """ if self._context is None: self._context = WorkspaceCumulativeStatisticsContext( self._version, workspace_sid=self._solution['workspace_sid'], ) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def avg_task_acceptance_time(self): """ :returns: The avg_task_acceptance_time :rtype: unicode """ return self._properties['avg_task_acceptance_time'] @property def start_time(self): """ :returns: The start_time :rtype: datetime """ return self._properties['start_time'] @property def end_time(self): """ :returns: The end_time :rtype: datetime """ return self._properties['end_time'] @property def reservations_created(self): """ :returns: The reservations_created :rtype: unicode """ return self._properties['reservations_created'] @property def reservations_accepted(self): """ :returns: The reservations_accepted :rtype: unicode """ return self._properties['reservations_accepted'] @property def reservations_rejected(self): """ :returns: The reservations_rejected :rtype: unicode """ return self._properties['reservations_rejected'] @property def reservations_timed_out(self): """ :returns: The reservations_timed_out :rtype: unicode """ return self._properties['reservations_timed_out'] @property def reservations_canceled(self): """ :returns: The reservations_canceled :rtype: unicode """ return self._properties['reservations_canceled'] @property def reservations_rescinded(self): """ :returns: The reservations_rescinded :rtype: unicode """ return self._properties['reservations_rescinded'] @property def split_by_wait_time(self): """ :returns: The split_by_wait_time :rtype: dict """ return self._properties['split_by_wait_time'] @property def wait_duration_until_accepted(self): """ :returns: The wait_duration_until_accepted :rtype: dict """ return self._properties['wait_duration_until_accepted'] @property def wait_duration_until_canceled(self): """ :returns: The wait_duration_until_canceled :rtype: dict """ return self._properties['wait_duration_until_canceled'] @property def tasks_canceled(self): """ :returns: The tasks_canceled :rtype: unicode """ return self._properties['tasks_canceled'] @property def tasks_completed(self): """ :returns: The tasks_completed :rtype: unicode """ return self._properties['tasks_completed'] @property def tasks_created(self): """ :returns: The tasks_created :rtype: unicode """ return self._properties['tasks_created'] @property def tasks_deleted(self): """ :returns: The tasks_deleted :rtype: unicode """ return self._properties['tasks_deleted'] @property def tasks_moved(self): """ :returns: The tasks_moved :rtype: unicode """ return self._properties['tasks_moved'] @property def tasks_timed_out_in_workflow(self): """ :returns: The tasks_timed_out_in_workflow :rtype: unicode """ return self._properties['tasks_timed_out_in_workflow'] @property def workspace_sid(self): """ :returns: The workspace_sid :rtype: unicode """ return self._properties['workspace_sid'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self, end_date=values.unset, minutes=values.unset, start_date=values.unset, task_channel=values.unset, split_by_wait_time=values.unset): """ Fetch a WorkspaceCumulativeStatisticsInstance :param datetime end_date: The end_date :param unicode minutes: The minutes :param datetime start_date: The start_date :param unicode task_channel: The task_channel :param unicode split_by_wait_time: The split_by_wait_time :returns: Fetched WorkspaceCumulativeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.workspace_cumulative_statistics.WorkspaceCumulativeStatisticsInstance """ return self._proxy.fetch( end_date=end_date, minutes=minutes, start_date=start_date, task_channel=task_channel, split_by_wait_time=split_by_wait_time, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/taskrouter/v1/workspace/workspace_real_time_statistics.py000066400000000000000000000235271317472742600322610ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class WorkspaceRealTimeStatisticsList(ListResource): """ """ def __init__(self, version, workspace_sid): """ Initialize the WorkspaceRealTimeStatisticsList :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :returns: twilio.rest.taskrouter.v1.workspace.workspace_real_time_statistics.WorkspaceRealTimeStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.workspace_real_time_statistics.WorkspaceRealTimeStatisticsList """ super(WorkspaceRealTimeStatisticsList, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid,} def get(self): """ Constructs a WorkspaceRealTimeStatisticsContext :returns: twilio.rest.taskrouter.v1.workspace.workspace_real_time_statistics.WorkspaceRealTimeStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.workspace_real_time_statistics.WorkspaceRealTimeStatisticsContext """ return WorkspaceRealTimeStatisticsContext( self._version, workspace_sid=self._solution['workspace_sid'], ) def __call__(self): """ Constructs a WorkspaceRealTimeStatisticsContext :returns: twilio.rest.taskrouter.v1.workspace.workspace_real_time_statistics.WorkspaceRealTimeStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.workspace_real_time_statistics.WorkspaceRealTimeStatisticsContext """ return WorkspaceRealTimeStatisticsContext( self._version, workspace_sid=self._solution['workspace_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class WorkspaceRealTimeStatisticsPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the WorkspaceRealTimeStatisticsPage :param Version version: Version that contains the resource :param Response response: Response from the API :param workspace_sid: The workspace_sid :returns: twilio.rest.taskrouter.v1.workspace.workspace_real_time_statistics.WorkspaceRealTimeStatisticsPage :rtype: twilio.rest.taskrouter.v1.workspace.workspace_real_time_statistics.WorkspaceRealTimeStatisticsPage """ super(WorkspaceRealTimeStatisticsPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of WorkspaceRealTimeStatisticsInstance :param dict payload: Payload response from the API :returns: twilio.rest.taskrouter.v1.workspace.workspace_real_time_statistics.WorkspaceRealTimeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.workspace_real_time_statistics.WorkspaceRealTimeStatisticsInstance """ return WorkspaceRealTimeStatisticsInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class WorkspaceRealTimeStatisticsContext(InstanceContext): """ """ def __init__(self, version, workspace_sid): """ Initialize the WorkspaceRealTimeStatisticsContext :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :returns: twilio.rest.taskrouter.v1.workspace.workspace_real_time_statistics.WorkspaceRealTimeStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.workspace_real_time_statistics.WorkspaceRealTimeStatisticsContext """ super(WorkspaceRealTimeStatisticsContext, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid,} self._uri = '/Workspaces/{workspace_sid}/RealTimeStatistics'.format(**self._solution) def fetch(self, task_channel=values.unset): """ Fetch a WorkspaceRealTimeStatisticsInstance :param unicode task_channel: The task_channel :returns: Fetched WorkspaceRealTimeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.workspace_real_time_statistics.WorkspaceRealTimeStatisticsInstance """ params = values.of({'TaskChannel': task_channel,}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return WorkspaceRealTimeStatisticsInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class WorkspaceRealTimeStatisticsInstance(InstanceResource): """ """ def __init__(self, version, payload, workspace_sid): """ Initialize the WorkspaceRealTimeStatisticsInstance :returns: twilio.rest.taskrouter.v1.workspace.workspace_real_time_statistics.WorkspaceRealTimeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.workspace_real_time_statistics.WorkspaceRealTimeStatisticsInstance """ super(WorkspaceRealTimeStatisticsInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'activity_statistics': payload['activity_statistics'], 'longest_task_waiting_age': deserialize.integer(payload['longest_task_waiting_age']), 'tasks_by_priority': payload['tasks_by_priority'], 'tasks_by_status': payload['tasks_by_status'], 'total_tasks': deserialize.integer(payload['total_tasks']), 'total_workers': deserialize.integer(payload['total_workers']), 'workspace_sid': payload['workspace_sid'], 'url': payload['url'], } # Context self._context = None self._solution = {'workspace_sid': workspace_sid,} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: WorkspaceRealTimeStatisticsContext for this WorkspaceRealTimeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.workspace_real_time_statistics.WorkspaceRealTimeStatisticsContext """ if self._context is None: self._context = WorkspaceRealTimeStatisticsContext( self._version, workspace_sid=self._solution['workspace_sid'], ) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def activity_statistics(self): """ :returns: The activity_statistics :rtype: dict """ return self._properties['activity_statistics'] @property def longest_task_waiting_age(self): """ :returns: The longest_task_waiting_age :rtype: unicode """ return self._properties['longest_task_waiting_age'] @property def tasks_by_priority(self): """ :returns: The tasks_by_priority :rtype: dict """ return self._properties['tasks_by_priority'] @property def tasks_by_status(self): """ :returns: The tasks_by_status :rtype: dict """ return self._properties['tasks_by_status'] @property def total_tasks(self): """ :returns: The total_tasks :rtype: unicode """ return self._properties['total_tasks'] @property def total_workers(self): """ :returns: The total_workers :rtype: unicode """ return self._properties['total_workers'] @property def workspace_sid(self): """ :returns: The workspace_sid :rtype: unicode """ return self._properties['workspace_sid'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self, task_channel=values.unset): """ Fetch a WorkspaceRealTimeStatisticsInstance :param unicode task_channel: The task_channel :returns: Fetched WorkspaceRealTimeStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.workspace_real_time_statistics.WorkspaceRealTimeStatisticsInstance """ return self._proxy.fetch(task_channel=task_channel,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/taskrouter/v1/workspace/workspace_statistics.py000066400000000000000000000222571317472742600302370ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import serialize 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.page import Page class WorkspaceStatisticsList(ListResource): """ """ def __init__(self, version, workspace_sid): """ Initialize the WorkspaceStatisticsList :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :returns: twilio.rest.taskrouter.v1.workspace.workspace_statistics.WorkspaceStatisticsList :rtype: twilio.rest.taskrouter.v1.workspace.workspace_statistics.WorkspaceStatisticsList """ super(WorkspaceStatisticsList, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid,} def get(self): """ Constructs a WorkspaceStatisticsContext :returns: twilio.rest.taskrouter.v1.workspace.workspace_statistics.WorkspaceStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.workspace_statistics.WorkspaceStatisticsContext """ return WorkspaceStatisticsContext(self._version, workspace_sid=self._solution['workspace_sid'],) def __call__(self): """ Constructs a WorkspaceStatisticsContext :returns: twilio.rest.taskrouter.v1.workspace.workspace_statistics.WorkspaceStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.workspace_statistics.WorkspaceStatisticsContext """ return WorkspaceStatisticsContext(self._version, workspace_sid=self._solution['workspace_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class WorkspaceStatisticsPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the WorkspaceStatisticsPage :param Version version: Version that contains the resource :param Response response: Response from the API :param workspace_sid: The workspace_sid :returns: twilio.rest.taskrouter.v1.workspace.workspace_statistics.WorkspaceStatisticsPage :rtype: twilio.rest.taskrouter.v1.workspace.workspace_statistics.WorkspaceStatisticsPage """ super(WorkspaceStatisticsPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of WorkspaceStatisticsInstance :param dict payload: Payload response from the API :returns: twilio.rest.taskrouter.v1.workspace.workspace_statistics.WorkspaceStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.workspace_statistics.WorkspaceStatisticsInstance """ return WorkspaceStatisticsInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class WorkspaceStatisticsContext(InstanceContext): """ """ def __init__(self, version, workspace_sid): """ Initialize the WorkspaceStatisticsContext :param Version version: Version that contains the resource :param workspace_sid: The workspace_sid :returns: twilio.rest.taskrouter.v1.workspace.workspace_statistics.WorkspaceStatisticsContext :rtype: twilio.rest.taskrouter.v1.workspace.workspace_statistics.WorkspaceStatisticsContext """ super(WorkspaceStatisticsContext, self).__init__(version) # Path Solution self._solution = {'workspace_sid': workspace_sid,} self._uri = '/Workspaces/{workspace_sid}/Statistics'.format(**self._solution) def fetch(self, minutes=values.unset, start_date=values.unset, end_date=values.unset, task_channel=values.unset, split_by_wait_time=values.unset): """ Fetch a WorkspaceStatisticsInstance :param unicode minutes: The minutes :param datetime start_date: The start_date :param datetime end_date: The end_date :param unicode task_channel: The task_channel :param unicode split_by_wait_time: The split_by_wait_time :returns: Fetched WorkspaceStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.workspace_statistics.WorkspaceStatisticsInstance """ params = values.of({ 'Minutes': minutes, 'StartDate': serialize.iso8601_datetime(start_date), 'EndDate': serialize.iso8601_datetime(end_date), 'TaskChannel': task_channel, 'SplitByWaitTime': split_by_wait_time, }) payload = self._version.fetch( 'GET', self._uri, params=params, ) return WorkspaceStatisticsInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class WorkspaceStatisticsInstance(InstanceResource): """ """ def __init__(self, version, payload, workspace_sid): """ Initialize the WorkspaceStatisticsInstance :returns: twilio.rest.taskrouter.v1.workspace.workspace_statistics.WorkspaceStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.workspace_statistics.WorkspaceStatisticsInstance """ super(WorkspaceStatisticsInstance, self).__init__(version) # Marshaled Properties self._properties = { 'realtime': payload['realtime'], 'cumulative': payload['cumulative'], 'account_sid': payload['account_sid'], 'workspace_sid': payload['workspace_sid'], 'url': payload['url'], } # Context self._context = None self._solution = {'workspace_sid': workspace_sid,} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: WorkspaceStatisticsContext for this WorkspaceStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.workspace_statistics.WorkspaceStatisticsContext """ if self._context is None: self._context = WorkspaceStatisticsContext( self._version, workspace_sid=self._solution['workspace_sid'], ) return self._context @property def realtime(self): """ :returns: The realtime :rtype: dict """ return self._properties['realtime'] @property def cumulative(self): """ :returns: The cumulative :rtype: dict """ return self._properties['cumulative'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def workspace_sid(self): """ :returns: The workspace_sid :rtype: unicode """ return self._properties['workspace_sid'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self, minutes=values.unset, start_date=values.unset, end_date=values.unset, task_channel=values.unset, split_by_wait_time=values.unset): """ Fetch a WorkspaceStatisticsInstance :param unicode minutes: The minutes :param datetime start_date: The start_date :param datetime end_date: The end_date :param unicode task_channel: The task_channel :param unicode split_by_wait_time: The split_by_wait_time :returns: Fetched WorkspaceStatisticsInstance :rtype: twilio.rest.taskrouter.v1.workspace.workspace_statistics.WorkspaceStatisticsInstance """ return self._proxy.fetch( minutes=minutes, start_date=start_date, end_date=end_date, task_channel=task_channel, split_by_wait_time=split_by_wait_time, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/trunking/000077500000000000000000000000001317472742600205175ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/trunking/__init__.py000066400000000000000000000021401317472742600226250ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.domain import Domain from twilio.rest.trunking.v1 import V1 class Trunking(Domain): def __init__(self, twilio): """ Initialize the Trunking Domain :returns: Domain for Trunking :rtype: twilio.rest.trunking.Trunking """ super(Trunking, self).__init__(twilio) self.base_url = 'https://trunking.twilio.com' # Versions self._v1 = None @property def v1(self): """ :returns: Version v1 of trunking :rtype: twilio.rest.trunking.v1.V1 """ if self._v1 is None: self._v1 = V1(self) return self._v1 @property def trunks(self): """ :rtype: twilio.rest.trunking.v1.trunk.TrunkList """ return self.v1.trunks def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/trunking/v1/000077500000000000000000000000001317472742600210455ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/trunking/v1/__init__.py000066400000000000000000000016561317472742600231660ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.version import Version from twilio.rest.trunking.v1.trunk import TrunkList class V1(Version): def __init__(self, domain): """ Initialize the V1 version of Trunking :returns: V1 version of Trunking :rtype: twilio.rest.trunking.v1.V1.V1 """ super(V1, self).__init__(domain) self.version = 'v1' self._trunks = None @property def trunks(self): """ :rtype: twilio.rest.trunking.v1.trunk.TrunkList """ if self._trunks is None: self._trunks = TrunkList(self) return self._trunks def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/trunking/v1/trunk/000077500000000000000000000000001317472742600222105ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/trunking/v1/trunk/__init__.py000066400000000000000000000467021317472742600243320ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.trunking.v1.trunk.credential_list import CredentialListList from twilio.rest.trunking.v1.trunk.ip_access_control_list import IpAccessControlListList from twilio.rest.trunking.v1.trunk.origination_url import OriginationUrlList from twilio.rest.trunking.v1.trunk.phone_number import PhoneNumberList class TrunkList(ListResource): """ """ def __init__(self, version): """ Initialize the TrunkList :param Version version: Version that contains the resource :returns: twilio.rest.trunking.v1.trunk.TrunkList :rtype: twilio.rest.trunking.v1.trunk.TrunkList """ super(TrunkList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/Trunks'.format(**self._solution) def create(self, friendly_name=values.unset, domain_name=values.unset, disaster_recovery_url=values.unset, disaster_recovery_method=values.unset, recording=values.unset, secure=values.unset): """ Create a new TrunkInstance :param unicode friendly_name: The friendly_name :param unicode domain_name: The domain_name :param unicode disaster_recovery_url: The disaster_recovery_url :param unicode disaster_recovery_method: The disaster_recovery_method :param unicode recording: The recording :param bool secure: The secure :returns: Newly created TrunkInstance :rtype: twilio.rest.trunking.v1.trunk.TrunkInstance """ data = values.of({ 'FriendlyName': friendly_name, 'DomainName': domain_name, 'DisasterRecoveryUrl': disaster_recovery_url, 'DisasterRecoveryMethod': disaster_recovery_method, 'Recording': recording, 'Secure': secure, }) payload = self._version.create( 'POST', self._uri, data=data, ) return TrunkInstance(self._version, payload,) def stream(self, limit=None, page_size=None): """ Streams TrunkInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.trunking.v1.trunk.TrunkInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists TrunkInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.trunking.v1.trunk.TrunkInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of TrunkInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of TrunkInstance :rtype: twilio.rest.trunking.v1.trunk.TrunkPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return TrunkPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of TrunkInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of TrunkInstance :rtype: twilio.rest.trunking.v1.trunk.TrunkPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return TrunkPage(self._version, response, self._solution) def get(self, sid): """ Constructs a TrunkContext :param sid: The sid :returns: twilio.rest.trunking.v1.trunk.TrunkContext :rtype: twilio.rest.trunking.v1.trunk.TrunkContext """ return TrunkContext(self._version, sid=sid,) def __call__(self, sid): """ Constructs a TrunkContext :param sid: The sid :returns: twilio.rest.trunking.v1.trunk.TrunkContext :rtype: twilio.rest.trunking.v1.trunk.TrunkContext """ return TrunkContext(self._version, sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class TrunkPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the TrunkPage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.trunking.v1.trunk.TrunkPage :rtype: twilio.rest.trunking.v1.trunk.TrunkPage """ super(TrunkPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of TrunkInstance :param dict payload: Payload response from the API :returns: twilio.rest.trunking.v1.trunk.TrunkInstance :rtype: twilio.rest.trunking.v1.trunk.TrunkInstance """ return TrunkInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class TrunkContext(InstanceContext): """ """ def __init__(self, version, sid): """ Initialize the TrunkContext :param Version version: Version that contains the resource :param sid: The sid :returns: twilio.rest.trunking.v1.trunk.TrunkContext :rtype: twilio.rest.trunking.v1.trunk.TrunkContext """ super(TrunkContext, self).__init__(version) # Path Solution self._solution = {'sid': sid,} self._uri = '/Trunks/{sid}'.format(**self._solution) # Dependents self._origination_urls = None self._credentials_lists = None self._ip_access_control_lists = None self._phone_numbers = None def fetch(self): """ Fetch a TrunkInstance :returns: Fetched TrunkInstance :rtype: twilio.rest.trunking.v1.trunk.TrunkInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return TrunkInstance(self._version, payload, sid=self._solution['sid'],) def delete(self): """ Deletes the TrunkInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, friendly_name=values.unset, domain_name=values.unset, disaster_recovery_url=values.unset, disaster_recovery_method=values.unset, recording=values.unset, secure=values.unset): """ Update the TrunkInstance :param unicode friendly_name: The friendly_name :param unicode domain_name: The domain_name :param unicode disaster_recovery_url: The disaster_recovery_url :param unicode disaster_recovery_method: The disaster_recovery_method :param unicode recording: The recording :param bool secure: The secure :returns: Updated TrunkInstance :rtype: twilio.rest.trunking.v1.trunk.TrunkInstance """ data = values.of({ 'FriendlyName': friendly_name, 'DomainName': domain_name, 'DisasterRecoveryUrl': disaster_recovery_url, 'DisasterRecoveryMethod': disaster_recovery_method, 'Recording': recording, 'Secure': secure, }) payload = self._version.update( 'POST', self._uri, data=data, ) return TrunkInstance(self._version, payload, sid=self._solution['sid'],) @property def origination_urls(self): """ Access the origination_urls :returns: twilio.rest.trunking.v1.trunk.origination_url.OriginationUrlList :rtype: twilio.rest.trunking.v1.trunk.origination_url.OriginationUrlList """ if self._origination_urls is None: self._origination_urls = OriginationUrlList(self._version, trunk_sid=self._solution['sid'],) return self._origination_urls @property def credentials_lists(self): """ Access the credentials_lists :returns: twilio.rest.trunking.v1.trunk.credential_list.CredentialListList :rtype: twilio.rest.trunking.v1.trunk.credential_list.CredentialListList """ if self._credentials_lists is None: self._credentials_lists = CredentialListList(self._version, trunk_sid=self._solution['sid'],) return self._credentials_lists @property def ip_access_control_lists(self): """ Access the ip_access_control_lists :returns: twilio.rest.trunking.v1.trunk.ip_access_control_list.IpAccessControlListList :rtype: twilio.rest.trunking.v1.trunk.ip_access_control_list.IpAccessControlListList """ if self._ip_access_control_lists is None: self._ip_access_control_lists = IpAccessControlListList( self._version, trunk_sid=self._solution['sid'], ) return self._ip_access_control_lists @property def phone_numbers(self): """ Access the phone_numbers :returns: twilio.rest.trunking.v1.trunk.phone_number.PhoneNumberList :rtype: twilio.rest.trunking.v1.trunk.phone_number.PhoneNumberList """ if self._phone_numbers is None: self._phone_numbers = PhoneNumberList(self._version, trunk_sid=self._solution['sid'],) return self._phone_numbers def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class TrunkInstance(InstanceResource): """ """ def __init__(self, version, payload, sid=None): """ Initialize the TrunkInstance :returns: twilio.rest.trunking.v1.trunk.TrunkInstance :rtype: twilio.rest.trunking.v1.trunk.TrunkInstance """ super(TrunkInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'domain_name': payload['domain_name'], 'disaster_recovery_method': payload['disaster_recovery_method'], 'disaster_recovery_url': payload['disaster_recovery_url'], 'friendly_name': payload['friendly_name'], 'secure': payload['secure'], 'recording': payload['recording'], 'auth_type': payload['auth_type'], 'auth_type_set': payload['auth_type_set'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'sid': payload['sid'], 'url': payload['url'], 'links': payload['links'], } # Context self._context = None self._solution = {'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: TrunkContext for this TrunkInstance :rtype: twilio.rest.trunking.v1.trunk.TrunkContext """ if self._context is None: self._context = TrunkContext(self._version, sid=self._solution['sid'],) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def domain_name(self): """ :returns: The domain_name :rtype: unicode """ return self._properties['domain_name'] @property def disaster_recovery_method(self): """ :returns: The disaster_recovery_method :rtype: unicode """ return self._properties['disaster_recovery_method'] @property def disaster_recovery_url(self): """ :returns: The disaster_recovery_url :rtype: unicode """ return self._properties['disaster_recovery_url'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def secure(self): """ :returns: The secure :rtype: bool """ return self._properties['secure'] @property def recording(self): """ :returns: The recording :rtype: dict """ return self._properties['recording'] @property def auth_type(self): """ :returns: The auth_type :rtype: unicode """ return self._properties['auth_type'] @property def auth_type_set(self): """ :returns: The auth_type_set :rtype: unicode """ return self._properties['auth_type_set'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a TrunkInstance :returns: Fetched TrunkInstance :rtype: twilio.rest.trunking.v1.trunk.TrunkInstance """ return self._proxy.fetch() def delete(self): """ Deletes the TrunkInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, friendly_name=values.unset, domain_name=values.unset, disaster_recovery_url=values.unset, disaster_recovery_method=values.unset, recording=values.unset, secure=values.unset): """ Update the TrunkInstance :param unicode friendly_name: The friendly_name :param unicode domain_name: The domain_name :param unicode disaster_recovery_url: The disaster_recovery_url :param unicode disaster_recovery_method: The disaster_recovery_method :param unicode recording: The recording :param bool secure: The secure :returns: Updated TrunkInstance :rtype: twilio.rest.trunking.v1.trunk.TrunkInstance """ return self._proxy.update( friendly_name=friendly_name, domain_name=domain_name, disaster_recovery_url=disaster_recovery_url, disaster_recovery_method=disaster_recovery_method, recording=recording, secure=secure, ) @property def origination_urls(self): """ Access the origination_urls :returns: twilio.rest.trunking.v1.trunk.origination_url.OriginationUrlList :rtype: twilio.rest.trunking.v1.trunk.origination_url.OriginationUrlList """ return self._proxy.origination_urls @property def credentials_lists(self): """ Access the credentials_lists :returns: twilio.rest.trunking.v1.trunk.credential_list.CredentialListList :rtype: twilio.rest.trunking.v1.trunk.credential_list.CredentialListList """ return self._proxy.credentials_lists @property def ip_access_control_lists(self): """ Access the ip_access_control_lists :returns: twilio.rest.trunking.v1.trunk.ip_access_control_list.IpAccessControlListList :rtype: twilio.rest.trunking.v1.trunk.ip_access_control_list.IpAccessControlListList """ return self._proxy.ip_access_control_lists @property def phone_numbers(self): """ Access the phone_numbers :returns: twilio.rest.trunking.v1.trunk.phone_number.PhoneNumberList :rtype: twilio.rest.trunking.v1.trunk.phone_number.PhoneNumberList """ return self._proxy.phone_numbers def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/trunking/v1/trunk/credential_list.py000066400000000000000000000315411317472742600257330ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class CredentialListList(ListResource): """ """ def __init__(self, version, trunk_sid): """ Initialize the CredentialListList :param Version version: Version that contains the resource :param trunk_sid: The trunk_sid :returns: twilio.rest.trunking.v1.trunk.credential_list.CredentialListList :rtype: twilio.rest.trunking.v1.trunk.credential_list.CredentialListList """ super(CredentialListList, self).__init__(version) # Path Solution self._solution = {'trunk_sid': trunk_sid,} self._uri = '/Trunks/{trunk_sid}/CredentialLists'.format(**self._solution) def create(self, credential_list_sid): """ Create a new CredentialListInstance :param unicode credential_list_sid: The credential_list_sid :returns: Newly created CredentialListInstance :rtype: twilio.rest.trunking.v1.trunk.credential_list.CredentialListInstance """ data = values.of({'CredentialListSid': credential_list_sid,}) payload = self._version.create( 'POST', self._uri, data=data, ) return CredentialListInstance(self._version, payload, trunk_sid=self._solution['trunk_sid'],) def stream(self, limit=None, page_size=None): """ Streams CredentialListInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.trunking.v1.trunk.credential_list.CredentialListInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists CredentialListInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.trunking.v1.trunk.credential_list.CredentialListInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of CredentialListInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of CredentialListInstance :rtype: twilio.rest.trunking.v1.trunk.credential_list.CredentialListPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return CredentialListPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of CredentialListInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of CredentialListInstance :rtype: twilio.rest.trunking.v1.trunk.credential_list.CredentialListPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return CredentialListPage(self._version, response, self._solution) def get(self, sid): """ Constructs a CredentialListContext :param sid: The sid :returns: twilio.rest.trunking.v1.trunk.credential_list.CredentialListContext :rtype: twilio.rest.trunking.v1.trunk.credential_list.CredentialListContext """ return CredentialListContext(self._version, trunk_sid=self._solution['trunk_sid'], sid=sid,) def __call__(self, sid): """ Constructs a CredentialListContext :param sid: The sid :returns: twilio.rest.trunking.v1.trunk.credential_list.CredentialListContext :rtype: twilio.rest.trunking.v1.trunk.credential_list.CredentialListContext """ return CredentialListContext(self._version, trunk_sid=self._solution['trunk_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class CredentialListPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the CredentialListPage :param Version version: Version that contains the resource :param Response response: Response from the API :param trunk_sid: The trunk_sid :returns: twilio.rest.trunking.v1.trunk.credential_list.CredentialListPage :rtype: twilio.rest.trunking.v1.trunk.credential_list.CredentialListPage """ super(CredentialListPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of CredentialListInstance :param dict payload: Payload response from the API :returns: twilio.rest.trunking.v1.trunk.credential_list.CredentialListInstance :rtype: twilio.rest.trunking.v1.trunk.credential_list.CredentialListInstance """ return CredentialListInstance(self._version, payload, trunk_sid=self._solution['trunk_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class CredentialListContext(InstanceContext): """ """ def __init__(self, version, trunk_sid, sid): """ Initialize the CredentialListContext :param Version version: Version that contains the resource :param trunk_sid: The trunk_sid :param sid: The sid :returns: twilio.rest.trunking.v1.trunk.credential_list.CredentialListContext :rtype: twilio.rest.trunking.v1.trunk.credential_list.CredentialListContext """ super(CredentialListContext, self).__init__(version) # Path Solution self._solution = {'trunk_sid': trunk_sid, 'sid': sid,} self._uri = '/Trunks/{trunk_sid}/CredentialLists/{sid}'.format(**self._solution) def fetch(self): """ Fetch a CredentialListInstance :returns: Fetched CredentialListInstance :rtype: twilio.rest.trunking.v1.trunk.credential_list.CredentialListInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return CredentialListInstance( self._version, payload, trunk_sid=self._solution['trunk_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the CredentialListInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class CredentialListInstance(InstanceResource): """ """ def __init__(self, version, payload, trunk_sid, sid=None): """ Initialize the CredentialListInstance :returns: twilio.rest.trunking.v1.trunk.credential_list.CredentialListInstance :rtype: twilio.rest.trunking.v1.trunk.credential_list.CredentialListInstance """ super(CredentialListInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'sid': payload['sid'], 'trunk_sid': payload['trunk_sid'], 'friendly_name': payload['friendly_name'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'url': payload['url'], } # Context self._context = None self._solution = {'trunk_sid': trunk_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: CredentialListContext for this CredentialListInstance :rtype: twilio.rest.trunking.v1.trunk.credential_list.CredentialListContext """ if self._context is None: self._context = CredentialListContext( self._version, trunk_sid=self._solution['trunk_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def trunk_sid(self): """ :returns: The trunk_sid :rtype: unicode """ return self._properties['trunk_sid'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a CredentialListInstance :returns: Fetched CredentialListInstance :rtype: twilio.rest.trunking.v1.trunk.credential_list.CredentialListInstance """ return self._proxy.fetch() def delete(self): """ Deletes the CredentialListInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/trunking/v1/trunk/ip_access_control_list.py000066400000000000000000000325531317472742600273160ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class IpAccessControlListList(ListResource): """ """ def __init__(self, version, trunk_sid): """ Initialize the IpAccessControlListList :param Version version: Version that contains the resource :param trunk_sid: The trunk_sid :returns: twilio.rest.trunking.v1.trunk.ip_access_control_list.IpAccessControlListList :rtype: twilio.rest.trunking.v1.trunk.ip_access_control_list.IpAccessControlListList """ super(IpAccessControlListList, self).__init__(version) # Path Solution self._solution = {'trunk_sid': trunk_sid,} self._uri = '/Trunks/{trunk_sid}/IpAccessControlLists'.format(**self._solution) def create(self, ip_access_control_list_sid): """ Create a new IpAccessControlListInstance :param unicode ip_access_control_list_sid: The ip_access_control_list_sid :returns: Newly created IpAccessControlListInstance :rtype: twilio.rest.trunking.v1.trunk.ip_access_control_list.IpAccessControlListInstance """ data = values.of({'IpAccessControlListSid': ip_access_control_list_sid,}) payload = self._version.create( 'POST', self._uri, data=data, ) return IpAccessControlListInstance(self._version, payload, trunk_sid=self._solution['trunk_sid'],) def stream(self, limit=None, page_size=None): """ Streams IpAccessControlListInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.trunking.v1.trunk.ip_access_control_list.IpAccessControlListInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists IpAccessControlListInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.trunking.v1.trunk.ip_access_control_list.IpAccessControlListInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of IpAccessControlListInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of IpAccessControlListInstance :rtype: twilio.rest.trunking.v1.trunk.ip_access_control_list.IpAccessControlListPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return IpAccessControlListPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of IpAccessControlListInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of IpAccessControlListInstance :rtype: twilio.rest.trunking.v1.trunk.ip_access_control_list.IpAccessControlListPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return IpAccessControlListPage(self._version, response, self._solution) def get(self, sid): """ Constructs a IpAccessControlListContext :param sid: The sid :returns: twilio.rest.trunking.v1.trunk.ip_access_control_list.IpAccessControlListContext :rtype: twilio.rest.trunking.v1.trunk.ip_access_control_list.IpAccessControlListContext """ return IpAccessControlListContext(self._version, trunk_sid=self._solution['trunk_sid'], sid=sid,) def __call__(self, sid): """ Constructs a IpAccessControlListContext :param sid: The sid :returns: twilio.rest.trunking.v1.trunk.ip_access_control_list.IpAccessControlListContext :rtype: twilio.rest.trunking.v1.trunk.ip_access_control_list.IpAccessControlListContext """ return IpAccessControlListContext(self._version, trunk_sid=self._solution['trunk_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class IpAccessControlListPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the IpAccessControlListPage :param Version version: Version that contains the resource :param Response response: Response from the API :param trunk_sid: The trunk_sid :returns: twilio.rest.trunking.v1.trunk.ip_access_control_list.IpAccessControlListPage :rtype: twilio.rest.trunking.v1.trunk.ip_access_control_list.IpAccessControlListPage """ super(IpAccessControlListPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of IpAccessControlListInstance :param dict payload: Payload response from the API :returns: twilio.rest.trunking.v1.trunk.ip_access_control_list.IpAccessControlListInstance :rtype: twilio.rest.trunking.v1.trunk.ip_access_control_list.IpAccessControlListInstance """ return IpAccessControlListInstance(self._version, payload, trunk_sid=self._solution['trunk_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class IpAccessControlListContext(InstanceContext): """ """ def __init__(self, version, trunk_sid, sid): """ Initialize the IpAccessControlListContext :param Version version: Version that contains the resource :param trunk_sid: The trunk_sid :param sid: The sid :returns: twilio.rest.trunking.v1.trunk.ip_access_control_list.IpAccessControlListContext :rtype: twilio.rest.trunking.v1.trunk.ip_access_control_list.IpAccessControlListContext """ super(IpAccessControlListContext, self).__init__(version) # Path Solution self._solution = {'trunk_sid': trunk_sid, 'sid': sid,} self._uri = '/Trunks/{trunk_sid}/IpAccessControlLists/{sid}'.format(**self._solution) def fetch(self): """ Fetch a IpAccessControlListInstance :returns: Fetched IpAccessControlListInstance :rtype: twilio.rest.trunking.v1.trunk.ip_access_control_list.IpAccessControlListInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return IpAccessControlListInstance( self._version, payload, trunk_sid=self._solution['trunk_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the IpAccessControlListInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class IpAccessControlListInstance(InstanceResource): """ """ def __init__(self, version, payload, trunk_sid, sid=None): """ Initialize the IpAccessControlListInstance :returns: twilio.rest.trunking.v1.trunk.ip_access_control_list.IpAccessControlListInstance :rtype: twilio.rest.trunking.v1.trunk.ip_access_control_list.IpAccessControlListInstance """ super(IpAccessControlListInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'sid': payload['sid'], 'trunk_sid': payload['trunk_sid'], 'friendly_name': payload['friendly_name'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'url': payload['url'], } # Context self._context = None self._solution = {'trunk_sid': trunk_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: IpAccessControlListContext for this IpAccessControlListInstance :rtype: twilio.rest.trunking.v1.trunk.ip_access_control_list.IpAccessControlListContext """ if self._context is None: self._context = IpAccessControlListContext( self._version, trunk_sid=self._solution['trunk_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def trunk_sid(self): """ :returns: The trunk_sid :rtype: unicode """ return self._properties['trunk_sid'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a IpAccessControlListInstance :returns: Fetched IpAccessControlListInstance :rtype: twilio.rest.trunking.v1.trunk.ip_access_control_list.IpAccessControlListInstance """ return self._proxy.fetch() def delete(self): """ Deletes the IpAccessControlListInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/trunking/v1/trunk/origination_url.py000066400000000000000000000375641317472742600260050ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class OriginationUrlList(ListResource): """ """ def __init__(self, version, trunk_sid): """ Initialize the OriginationUrlList :param Version version: Version that contains the resource :param trunk_sid: The trunk_sid :returns: twilio.rest.trunking.v1.trunk.origination_url.OriginationUrlList :rtype: twilio.rest.trunking.v1.trunk.origination_url.OriginationUrlList """ super(OriginationUrlList, self).__init__(version) # Path Solution self._solution = {'trunk_sid': trunk_sid,} self._uri = '/Trunks/{trunk_sid}/OriginationUrls'.format(**self._solution) def create(self, weight, priority, enabled, friendly_name, sip_url): """ Create a new OriginationUrlInstance :param unicode weight: The weight :param unicode priority: The priority :param bool enabled: The enabled :param unicode friendly_name: The friendly_name :param unicode sip_url: The sip_url :returns: Newly created OriginationUrlInstance :rtype: twilio.rest.trunking.v1.trunk.origination_url.OriginationUrlInstance """ data = values.of({ 'Weight': weight, 'Priority': priority, 'Enabled': enabled, 'FriendlyName': friendly_name, 'SipUrl': sip_url, }) payload = self._version.create( 'POST', self._uri, data=data, ) return OriginationUrlInstance(self._version, payload, trunk_sid=self._solution['trunk_sid'],) def stream(self, limit=None, page_size=None): """ Streams OriginationUrlInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.trunking.v1.trunk.origination_url.OriginationUrlInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists OriginationUrlInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.trunking.v1.trunk.origination_url.OriginationUrlInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of OriginationUrlInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of OriginationUrlInstance :rtype: twilio.rest.trunking.v1.trunk.origination_url.OriginationUrlPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return OriginationUrlPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of OriginationUrlInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of OriginationUrlInstance :rtype: twilio.rest.trunking.v1.trunk.origination_url.OriginationUrlPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return OriginationUrlPage(self._version, response, self._solution) def get(self, sid): """ Constructs a OriginationUrlContext :param sid: The sid :returns: twilio.rest.trunking.v1.trunk.origination_url.OriginationUrlContext :rtype: twilio.rest.trunking.v1.trunk.origination_url.OriginationUrlContext """ return OriginationUrlContext(self._version, trunk_sid=self._solution['trunk_sid'], sid=sid,) def __call__(self, sid): """ Constructs a OriginationUrlContext :param sid: The sid :returns: twilio.rest.trunking.v1.trunk.origination_url.OriginationUrlContext :rtype: twilio.rest.trunking.v1.trunk.origination_url.OriginationUrlContext """ return OriginationUrlContext(self._version, trunk_sid=self._solution['trunk_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class OriginationUrlPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the OriginationUrlPage :param Version version: Version that contains the resource :param Response response: Response from the API :param trunk_sid: The trunk_sid :returns: twilio.rest.trunking.v1.trunk.origination_url.OriginationUrlPage :rtype: twilio.rest.trunking.v1.trunk.origination_url.OriginationUrlPage """ super(OriginationUrlPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of OriginationUrlInstance :param dict payload: Payload response from the API :returns: twilio.rest.trunking.v1.trunk.origination_url.OriginationUrlInstance :rtype: twilio.rest.trunking.v1.trunk.origination_url.OriginationUrlInstance """ return OriginationUrlInstance(self._version, payload, trunk_sid=self._solution['trunk_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class OriginationUrlContext(InstanceContext): """ """ def __init__(self, version, trunk_sid, sid): """ Initialize the OriginationUrlContext :param Version version: Version that contains the resource :param trunk_sid: The trunk_sid :param sid: The sid :returns: twilio.rest.trunking.v1.trunk.origination_url.OriginationUrlContext :rtype: twilio.rest.trunking.v1.trunk.origination_url.OriginationUrlContext """ super(OriginationUrlContext, self).__init__(version) # Path Solution self._solution = {'trunk_sid': trunk_sid, 'sid': sid,} self._uri = '/Trunks/{trunk_sid}/OriginationUrls/{sid}'.format(**self._solution) def fetch(self): """ Fetch a OriginationUrlInstance :returns: Fetched OriginationUrlInstance :rtype: twilio.rest.trunking.v1.trunk.origination_url.OriginationUrlInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return OriginationUrlInstance( self._version, payload, trunk_sid=self._solution['trunk_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the OriginationUrlInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def update(self, weight=values.unset, priority=values.unset, enabled=values.unset, friendly_name=values.unset, sip_url=values.unset): """ Update the OriginationUrlInstance :param unicode weight: The weight :param unicode priority: The priority :param bool enabled: The enabled :param unicode friendly_name: The friendly_name :param unicode sip_url: The sip_url :returns: Updated OriginationUrlInstance :rtype: twilio.rest.trunking.v1.trunk.origination_url.OriginationUrlInstance """ data = values.of({ 'Weight': weight, 'Priority': priority, 'Enabled': enabled, 'FriendlyName': friendly_name, 'SipUrl': sip_url, }) payload = self._version.update( 'POST', self._uri, data=data, ) return OriginationUrlInstance( self._version, payload, trunk_sid=self._solution['trunk_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class OriginationUrlInstance(InstanceResource): """ """ def __init__(self, version, payload, trunk_sid, sid=None): """ Initialize the OriginationUrlInstance :returns: twilio.rest.trunking.v1.trunk.origination_url.OriginationUrlInstance :rtype: twilio.rest.trunking.v1.trunk.origination_url.OriginationUrlInstance """ super(OriginationUrlInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'sid': payload['sid'], 'trunk_sid': payload['trunk_sid'], 'weight': deserialize.integer(payload['weight']), 'enabled': payload['enabled'], 'sip_url': payload['sip_url'], 'friendly_name': payload['friendly_name'], 'priority': deserialize.integer(payload['priority']), 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'url': payload['url'], } # Context self._context = None self._solution = {'trunk_sid': trunk_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: OriginationUrlContext for this OriginationUrlInstance :rtype: twilio.rest.trunking.v1.trunk.origination_url.OriginationUrlContext """ if self._context is None: self._context = OriginationUrlContext( self._version, trunk_sid=self._solution['trunk_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def trunk_sid(self): """ :returns: The trunk_sid :rtype: unicode """ return self._properties['trunk_sid'] @property def weight(self): """ :returns: The weight :rtype: unicode """ return self._properties['weight'] @property def enabled(self): """ :returns: The enabled :rtype: bool """ return self._properties['enabled'] @property def sip_url(self): """ :returns: The sip_url :rtype: unicode """ return self._properties['sip_url'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def priority(self): """ :returns: The priority :rtype: unicode """ return self._properties['priority'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a OriginationUrlInstance :returns: Fetched OriginationUrlInstance :rtype: twilio.rest.trunking.v1.trunk.origination_url.OriginationUrlInstance """ return self._proxy.fetch() def delete(self): """ Deletes the OriginationUrlInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def update(self, weight=values.unset, priority=values.unset, enabled=values.unset, friendly_name=values.unset, sip_url=values.unset): """ Update the OriginationUrlInstance :param unicode weight: The weight :param unicode priority: The priority :param bool enabled: The enabled :param unicode friendly_name: The friendly_name :param unicode sip_url: The sip_url :returns: Updated OriginationUrlInstance :rtype: twilio.rest.trunking.v1.trunk.origination_url.OriginationUrlInstance """ return self._proxy.update( weight=weight, priority=priority, enabled=enabled, friendly_name=friendly_name, sip_url=sip_url, ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/trunking/v1/trunk/phone_number.py000066400000000000000000000422511317472742600252470ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class PhoneNumberList(ListResource): """ """ def __init__(self, version, trunk_sid): """ Initialize the PhoneNumberList :param Version version: Version that contains the resource :param trunk_sid: The trunk_sid :returns: twilio.rest.trunking.v1.trunk.phone_number.PhoneNumberList :rtype: twilio.rest.trunking.v1.trunk.phone_number.PhoneNumberList """ super(PhoneNumberList, self).__init__(version) # Path Solution self._solution = {'trunk_sid': trunk_sid,} self._uri = '/Trunks/{trunk_sid}/PhoneNumbers'.format(**self._solution) def create(self, phone_number_sid): """ Create a new PhoneNumberInstance :param unicode phone_number_sid: The phone_number_sid :returns: Newly created PhoneNumberInstance :rtype: twilio.rest.trunking.v1.trunk.phone_number.PhoneNumberInstance """ data = values.of({'PhoneNumberSid': phone_number_sid,}) payload = self._version.create( 'POST', self._uri, data=data, ) return PhoneNumberInstance(self._version, payload, trunk_sid=self._solution['trunk_sid'],) def stream(self, limit=None, page_size=None): """ Streams PhoneNumberInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.trunking.v1.trunk.phone_number.PhoneNumberInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists PhoneNumberInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.trunking.v1.trunk.phone_number.PhoneNumberInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of PhoneNumberInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of PhoneNumberInstance :rtype: twilio.rest.trunking.v1.trunk.phone_number.PhoneNumberPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return PhoneNumberPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of PhoneNumberInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of PhoneNumberInstance :rtype: twilio.rest.trunking.v1.trunk.phone_number.PhoneNumberPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return PhoneNumberPage(self._version, response, self._solution) def get(self, sid): """ Constructs a PhoneNumberContext :param sid: The sid :returns: twilio.rest.trunking.v1.trunk.phone_number.PhoneNumberContext :rtype: twilio.rest.trunking.v1.trunk.phone_number.PhoneNumberContext """ return PhoneNumberContext(self._version, trunk_sid=self._solution['trunk_sid'], sid=sid,) def __call__(self, sid): """ Constructs a PhoneNumberContext :param sid: The sid :returns: twilio.rest.trunking.v1.trunk.phone_number.PhoneNumberContext :rtype: twilio.rest.trunking.v1.trunk.phone_number.PhoneNumberContext """ return PhoneNumberContext(self._version, trunk_sid=self._solution['trunk_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class PhoneNumberPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the PhoneNumberPage :param Version version: Version that contains the resource :param Response response: Response from the API :param trunk_sid: The trunk_sid :returns: twilio.rest.trunking.v1.trunk.phone_number.PhoneNumberPage :rtype: twilio.rest.trunking.v1.trunk.phone_number.PhoneNumberPage """ super(PhoneNumberPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of PhoneNumberInstance :param dict payload: Payload response from the API :returns: twilio.rest.trunking.v1.trunk.phone_number.PhoneNumberInstance :rtype: twilio.rest.trunking.v1.trunk.phone_number.PhoneNumberInstance """ return PhoneNumberInstance(self._version, payload, trunk_sid=self._solution['trunk_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class PhoneNumberContext(InstanceContext): """ """ def __init__(self, version, trunk_sid, sid): """ Initialize the PhoneNumberContext :param Version version: Version that contains the resource :param trunk_sid: The trunk_sid :param sid: The sid :returns: twilio.rest.trunking.v1.trunk.phone_number.PhoneNumberContext :rtype: twilio.rest.trunking.v1.trunk.phone_number.PhoneNumberContext """ super(PhoneNumberContext, self).__init__(version) # Path Solution self._solution = {'trunk_sid': trunk_sid, 'sid': sid,} self._uri = '/Trunks/{trunk_sid}/PhoneNumbers/{sid}'.format(**self._solution) def fetch(self): """ Fetch a PhoneNumberInstance :returns: Fetched PhoneNumberInstance :rtype: twilio.rest.trunking.v1.trunk.phone_number.PhoneNumberInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return PhoneNumberInstance( self._version, payload, trunk_sid=self._solution['trunk_sid'], sid=self._solution['sid'], ) def delete(self): """ Deletes the PhoneNumberInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class PhoneNumberInstance(InstanceResource): """ """ class AddressRequirement(object): NONE = "none" ANY = "any" LOCAL = "local" FOREIGN = "foreign" def __init__(self, version, payload, trunk_sid, sid=None): """ Initialize the PhoneNumberInstance :returns: twilio.rest.trunking.v1.trunk.phone_number.PhoneNumberInstance :rtype: twilio.rest.trunking.v1.trunk.phone_number.PhoneNumberInstance """ super(PhoneNumberInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'address_requirements': payload['address_requirements'], 'api_version': payload['api_version'], 'beta': payload['beta'], 'capabilities': payload['capabilities'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'friendly_name': payload['friendly_name'], 'links': payload['links'], 'phone_number': payload['phone_number'], 'sid': payload['sid'], 'sms_application_sid': payload['sms_application_sid'], 'sms_fallback_method': payload['sms_fallback_method'], 'sms_fallback_url': payload['sms_fallback_url'], 'sms_method': payload['sms_method'], 'sms_url': payload['sms_url'], 'status_callback': payload['status_callback'], 'status_callback_method': payload['status_callback_method'], 'trunk_sid': payload['trunk_sid'], 'url': payload['url'], 'voice_application_sid': payload['voice_application_sid'], 'voice_caller_id_lookup': payload['voice_caller_id_lookup'], 'voice_fallback_method': payload['voice_fallback_method'], 'voice_fallback_url': payload['voice_fallback_url'], 'voice_method': payload['voice_method'], 'voice_url': payload['voice_url'], } # Context self._context = None self._solution = {'trunk_sid': trunk_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: PhoneNumberContext for this PhoneNumberInstance :rtype: twilio.rest.trunking.v1.trunk.phone_number.PhoneNumberContext """ if self._context is None: self._context = PhoneNumberContext( self._version, trunk_sid=self._solution['trunk_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def address_requirements(self): """ :returns: The address_requirements :rtype: PhoneNumberInstance.AddressRequirement """ return self._properties['address_requirements'] @property def api_version(self): """ :returns: The api_version :rtype: unicode """ return self._properties['api_version'] @property def beta(self): """ :returns: The beta :rtype: bool """ return self._properties['beta'] @property def capabilities(self): """ :returns: The capabilities :rtype: unicode """ return self._properties['capabilities'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] @property def phone_number(self): """ :returns: The phone_number :rtype: unicode """ return self._properties['phone_number'] @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def sms_application_sid(self): """ :returns: The sms_application_sid :rtype: unicode """ return self._properties['sms_application_sid'] @property def sms_fallback_method(self): """ :returns: The sms_fallback_method :rtype: unicode """ return self._properties['sms_fallback_method'] @property def sms_fallback_url(self): """ :returns: The sms_fallback_url :rtype: unicode """ return self._properties['sms_fallback_url'] @property def sms_method(self): """ :returns: The sms_method :rtype: unicode """ return self._properties['sms_method'] @property def sms_url(self): """ :returns: The sms_url :rtype: unicode """ return self._properties['sms_url'] @property def status_callback(self): """ :returns: The status_callback :rtype: unicode """ return self._properties['status_callback'] @property def status_callback_method(self): """ :returns: The status_callback_method :rtype: unicode """ return self._properties['status_callback_method'] @property def trunk_sid(self): """ :returns: The trunk_sid :rtype: unicode """ return self._properties['trunk_sid'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def voice_application_sid(self): """ :returns: The voice_application_sid :rtype: unicode """ return self._properties['voice_application_sid'] @property def voice_caller_id_lookup(self): """ :returns: The voice_caller_id_lookup :rtype: bool """ return self._properties['voice_caller_id_lookup'] @property def voice_fallback_method(self): """ :returns: The voice_fallback_method :rtype: unicode """ return self._properties['voice_fallback_method'] @property def voice_fallback_url(self): """ :returns: The voice_fallback_url :rtype: unicode """ return self._properties['voice_fallback_url'] @property def voice_method(self): """ :returns: The voice_method :rtype: unicode """ return self._properties['voice_method'] @property def voice_url(self): """ :returns: The voice_url :rtype: unicode """ return self._properties['voice_url'] def fetch(self): """ Fetch a PhoneNumberInstance :returns: Fetched PhoneNumberInstance :rtype: twilio.rest.trunking.v1.trunk.phone_number.PhoneNumberInstance """ return self._proxy.fetch() def delete(self): """ Deletes the PhoneNumberInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/video/000077500000000000000000000000001317472742600177645ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/video/__init__.py000066400000000000000000000023301317472742600220730ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.domain import Domain from twilio.rest.video.v1 import V1 class Video(Domain): def __init__(self, twilio): """ Initialize the Video Domain :returns: Domain for Video :rtype: twilio.rest.video.Video """ super(Video, self).__init__(twilio) self.base_url = 'https://video.twilio.com' # Versions self._v1 = None @property def v1(self): """ :returns: Version v1 of video :rtype: twilio.rest.video.v1.V1 """ if self._v1 is None: self._v1 = V1(self) return self._v1 @property def recordings(self): """ :rtype: twilio.rest.video.v1.recording.RecordingList """ return self.v1.recordings @property def rooms(self): """ :rtype: twilio.rest.video.v1.room.RoomList """ return self.v1.rooms def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/video/v1/000077500000000000000000000000001317472742600203125ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/video/v1/__init__.py000066400000000000000000000023411317472742600224230ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.version import Version from twilio.rest.video.v1.recording import RecordingList from twilio.rest.video.v1.room import RoomList class V1(Version): def __init__(self, domain): """ Initialize the V1 version of Video :returns: V1 version of Video :rtype: twilio.rest.video.v1.V1.V1 """ super(V1, self).__init__(domain) self.version = 'v1' self._recordings = None self._rooms = None @property def recordings(self): """ :rtype: twilio.rest.video.v1.recording.RecordingList """ if self._recordings is None: self._recordings = RecordingList(self) return self._recordings @property def rooms(self): """ :rtype: twilio.rest.video.v1.room.RoomList """ if self._rooms is None: self._rooms = RoomList(self) return self._rooms def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/video/v1/recording/000077500000000000000000000000001317472742600222665ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/video/v1/recording/__init__.py000066400000000000000000000355621317472742600244120ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize 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.page import Page class RecordingList(ListResource): """ """ def __init__(self, version): """ Initialize the RecordingList :param Version version: Version that contains the resource :returns: twilio.rest.video.v1.recording.RecordingList :rtype: twilio.rest.video.v1.recording.RecordingList """ super(RecordingList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/Recordings'.format(**self._solution) def stream(self, status=values.unset, source_sid=values.unset, grouping_sid=values.unset, date_created_after=values.unset, date_created_before=values.unset, limit=None, page_size=None): """ Streams RecordingInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param RecordingInstance.Status status: The status :param unicode source_sid: The source_sid :param unicode grouping_sid: The grouping_sid :param datetime date_created_after: The date_created_after :param datetime date_created_before: The date_created_before :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.video.v1.recording.RecordingInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( status=status, source_sid=source_sid, grouping_sid=grouping_sid, date_created_after=date_created_after, date_created_before=date_created_before, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, status=values.unset, source_sid=values.unset, grouping_sid=values.unset, date_created_after=values.unset, date_created_before=values.unset, limit=None, page_size=None): """ Lists RecordingInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param RecordingInstance.Status status: The status :param unicode source_sid: The source_sid :param unicode grouping_sid: The grouping_sid :param datetime date_created_after: The date_created_after :param datetime date_created_before: The date_created_before :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.video.v1.recording.RecordingInstance] """ return list(self.stream( status=status, source_sid=source_sid, grouping_sid=grouping_sid, date_created_after=date_created_after, date_created_before=date_created_before, limit=limit, page_size=page_size, )) def page(self, status=values.unset, source_sid=values.unset, grouping_sid=values.unset, date_created_after=values.unset, date_created_before=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of RecordingInstance records from the API. Request is executed immediately :param RecordingInstance.Status status: The status :param unicode source_sid: The source_sid :param unicode grouping_sid: The grouping_sid :param datetime date_created_after: The date_created_after :param datetime date_created_before: The date_created_before :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of RecordingInstance :rtype: twilio.rest.video.v1.recording.RecordingPage """ params = values.of({ 'Status': status, 'SourceSid': source_sid, 'GroupingSid': grouping_sid, 'DateCreatedAfter': serialize.iso8601_datetime(date_created_after), 'DateCreatedBefore': serialize.iso8601_datetime(date_created_before), 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return RecordingPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of RecordingInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of RecordingInstance :rtype: twilio.rest.video.v1.recording.RecordingPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return RecordingPage(self._version, response, self._solution) def get(self, sid): """ Constructs a RecordingContext :param sid: The sid :returns: twilio.rest.video.v1.recording.RecordingContext :rtype: twilio.rest.video.v1.recording.RecordingContext """ return RecordingContext(self._version, sid=sid,) def __call__(self, sid): """ Constructs a RecordingContext :param sid: The sid :returns: twilio.rest.video.v1.recording.RecordingContext :rtype: twilio.rest.video.v1.recording.RecordingContext """ return RecordingContext(self._version, sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class RecordingPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the RecordingPage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.video.v1.recording.RecordingPage :rtype: twilio.rest.video.v1.recording.RecordingPage """ super(RecordingPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of RecordingInstance :param dict payload: Payload response from the API :returns: twilio.rest.video.v1.recording.RecordingInstance :rtype: twilio.rest.video.v1.recording.RecordingInstance """ return RecordingInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class RecordingContext(InstanceContext): """ """ def __init__(self, version, sid): """ Initialize the RecordingContext :param Version version: Version that contains the resource :param sid: The sid :returns: twilio.rest.video.v1.recording.RecordingContext :rtype: twilio.rest.video.v1.recording.RecordingContext """ super(RecordingContext, self).__init__(version) # Path Solution self._solution = {'sid': sid,} self._uri = '/Recordings/{sid}'.format(**self._solution) def fetch(self): """ Fetch a RecordingInstance :returns: Fetched RecordingInstance :rtype: twilio.rest.video.v1.recording.RecordingInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return RecordingInstance(self._version, payload, sid=self._solution['sid'],) def delete(self): """ Deletes the RecordingInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class RecordingInstance(InstanceResource): """ """ class Status(object): PROCESSING = "processing" COMPLETED = "completed" DELETED = "deleted" FAILED = "failed" class Type(object): AUDIO = "audio" VIDEO = "video" DATA = "data" class Format(object): MKA = "mka" MKV = "mkv" class Codec(object): VP8 = "VP8" H264 = "H264" OPUS = "OPUS" PCMU = "PCMU" def __init__(self, version, payload, sid=None): """ Initialize the RecordingInstance :returns: twilio.rest.video.v1.recording.RecordingInstance :rtype: twilio.rest.video.v1.recording.RecordingInstance """ super(RecordingInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'status': payload['status'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'sid': payload['sid'], 'source_sid': payload['source_sid'], 'size': deserialize.integer(payload['size']), 'url': payload['url'], 'type': payload['type'], 'duration': deserialize.integer(payload['duration']), 'container_format': payload['container_format'], 'codec': payload['codec'], 'grouping_sids': payload['grouping_sids'], 'links': payload['links'], } # Context self._context = None self._solution = {'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: RecordingContext for this RecordingInstance :rtype: twilio.rest.video.v1.recording.RecordingContext """ if self._context is None: self._context = RecordingContext(self._version, sid=self._solution['sid'],) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def status(self): """ :returns: The status :rtype: RecordingInstance.Status """ return self._properties['status'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def source_sid(self): """ :returns: The source_sid :rtype: unicode """ return self._properties['source_sid'] @property def size(self): """ :returns: The size :rtype: unicode """ return self._properties['size'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def type(self): """ :returns: The type :rtype: RecordingInstance.Type """ return self._properties['type'] @property def duration(self): """ :returns: The duration :rtype: unicode """ return self._properties['duration'] @property def container_format(self): """ :returns: The container_format :rtype: RecordingInstance.Format """ return self._properties['container_format'] @property def codec(self): """ :returns: The codec :rtype: RecordingInstance.Codec """ return self._properties['codec'] @property def grouping_sids(self): """ :returns: The grouping_sids :rtype: dict """ return self._properties['grouping_sids'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a RecordingInstance :returns: Fetched RecordingInstance :rtype: twilio.rest.video.v1.recording.RecordingInstance """ return self._proxy.fetch() def delete(self): """ Deletes the RecordingInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/video/v1/room/000077500000000000000000000000001317472742600212665ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/video/v1/room/__init__.py000066400000000000000000000436201317472742600234040ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize 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.page import Page from twilio.rest.video.v1.room.recording import RoomRecordingList class RoomList(ListResource): """ """ def __init__(self, version): """ Initialize the RoomList :param Version version: Version that contains the resource :returns: twilio.rest.video.v1.room.RoomList :rtype: twilio.rest.video.v1.room.RoomList """ super(RoomList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/Rooms'.format(**self._solution) def create(self, enable_turn=values.unset, type=values.unset, unique_name=values.unset, status_callback=values.unset, status_callback_method=values.unset, max_participants=values.unset, record_participants_on_connect=values.unset, video_codecs=values.unset, media_region=values.unset): """ Create a new RoomInstance :param bool enable_turn: The enable_turn :param RoomInstance.RoomType type: The type :param unicode unique_name: The unique_name :param unicode status_callback: The status_callback :param unicode status_callback_method: The status_callback_method :param unicode max_participants: The max_participants :param bool record_participants_on_connect: The record_participants_on_connect :param RoomInstance.VideoCodec video_codecs: The video_codecs :param unicode media_region: The media_region :returns: Newly created RoomInstance :rtype: twilio.rest.video.v1.room.RoomInstance """ data = values.of({ 'EnableTurn': enable_turn, 'Type': type, 'UniqueName': unique_name, 'StatusCallback': status_callback, 'StatusCallbackMethod': status_callback_method, 'MaxParticipants': max_participants, 'RecordParticipantsOnConnect': record_participants_on_connect, 'VideoCodecs': video_codecs, 'MediaRegion': media_region, }) payload = self._version.create( 'POST', self._uri, data=data, ) return RoomInstance(self._version, payload,) def stream(self, status=values.unset, unique_name=values.unset, date_created_after=values.unset, date_created_before=values.unset, limit=None, page_size=None): """ Streams RoomInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param RoomInstance.RoomStatus status: The status :param unicode unique_name: The unique_name :param datetime date_created_after: The date_created_after :param datetime date_created_before: The date_created_before :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.video.v1.room.RoomInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( status=status, unique_name=unique_name, date_created_after=date_created_after, date_created_before=date_created_before, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, status=values.unset, unique_name=values.unset, date_created_after=values.unset, date_created_before=values.unset, limit=None, page_size=None): """ Lists RoomInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param RoomInstance.RoomStatus status: The status :param unicode unique_name: The unique_name :param datetime date_created_after: The date_created_after :param datetime date_created_before: The date_created_before :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.video.v1.room.RoomInstance] """ return list(self.stream( status=status, unique_name=unique_name, date_created_after=date_created_after, date_created_before=date_created_before, limit=limit, page_size=page_size, )) def page(self, status=values.unset, unique_name=values.unset, date_created_after=values.unset, date_created_before=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of RoomInstance records from the API. Request is executed immediately :param RoomInstance.RoomStatus status: The status :param unicode unique_name: The unique_name :param datetime date_created_after: The date_created_after :param datetime date_created_before: The date_created_before :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of RoomInstance :rtype: twilio.rest.video.v1.room.RoomPage """ params = values.of({ 'Status': status, 'UniqueName': unique_name, 'DateCreatedAfter': serialize.iso8601_datetime(date_created_after), 'DateCreatedBefore': serialize.iso8601_datetime(date_created_before), 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return RoomPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of RoomInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of RoomInstance :rtype: twilio.rest.video.v1.room.RoomPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return RoomPage(self._version, response, self._solution) def get(self, sid): """ Constructs a RoomContext :param sid: The sid :returns: twilio.rest.video.v1.room.RoomContext :rtype: twilio.rest.video.v1.room.RoomContext """ return RoomContext(self._version, sid=sid,) def __call__(self, sid): """ Constructs a RoomContext :param sid: The sid :returns: twilio.rest.video.v1.room.RoomContext :rtype: twilio.rest.video.v1.room.RoomContext """ return RoomContext(self._version, sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class RoomPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the RoomPage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.video.v1.room.RoomPage :rtype: twilio.rest.video.v1.room.RoomPage """ super(RoomPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of RoomInstance :param dict payload: Payload response from the API :returns: twilio.rest.video.v1.room.RoomInstance :rtype: twilio.rest.video.v1.room.RoomInstance """ return RoomInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class RoomContext(InstanceContext): """ """ def __init__(self, version, sid): """ Initialize the RoomContext :param Version version: Version that contains the resource :param sid: The sid :returns: twilio.rest.video.v1.room.RoomContext :rtype: twilio.rest.video.v1.room.RoomContext """ super(RoomContext, self).__init__(version) # Path Solution self._solution = {'sid': sid,} self._uri = '/Rooms/{sid}'.format(**self._solution) # Dependents self._recordings = None def fetch(self): """ Fetch a RoomInstance :returns: Fetched RoomInstance :rtype: twilio.rest.video.v1.room.RoomInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return RoomInstance(self._version, payload, sid=self._solution['sid'],) def update(self, status): """ Update the RoomInstance :param RoomInstance.RoomStatus status: The status :returns: Updated RoomInstance :rtype: twilio.rest.video.v1.room.RoomInstance """ data = values.of({'Status': status,}) payload = self._version.update( 'POST', self._uri, data=data, ) return RoomInstance(self._version, payload, sid=self._solution['sid'],) @property def recordings(self): """ Access the recordings :returns: twilio.rest.video.v1.room.recording.RoomRecordingList :rtype: twilio.rest.video.v1.room.recording.RoomRecordingList """ if self._recordings is None: self._recordings = RoomRecordingList(self._version, room_sid=self._solution['sid'],) return self._recordings def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class RoomInstance(InstanceResource): """ """ class RoomStatus(object): IN_PROGRESS = "in-progress" COMPLETED = "completed" FAILED = "failed" class RoomType(object): PEER_TO_PEER = "peer-to-peer" GROUP = "group" class VideoCodec(object): VP8 = "VP8" H264 = "H264" def __init__(self, version, payload, sid=None): """ Initialize the RoomInstance :returns: twilio.rest.video.v1.room.RoomInstance :rtype: twilio.rest.video.v1.room.RoomInstance """ super(RoomInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'status': payload['status'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'account_sid': payload['account_sid'], 'enable_turn': payload['enable_turn'], 'unique_name': payload['unique_name'], 'status_callback': payload['status_callback'], 'status_callback_method': payload['status_callback_method'], 'end_time': deserialize.iso8601_datetime(payload['end_time']), 'duration': deserialize.integer(payload['duration']), 'type': payload['type'], 'max_participants': deserialize.integer(payload['max_participants']), 'record_participants_on_connect': payload['record_participants_on_connect'], 'video_codecs': payload['video_codecs'], 'url': payload['url'], 'links': payload['links'], } # Context self._context = None self._solution = {'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: RoomContext for this RoomInstance :rtype: twilio.rest.video.v1.room.RoomContext """ if self._context is None: self._context = RoomContext(self._version, sid=self._solution['sid'],) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def status(self): """ :returns: The status :rtype: RoomInstance.RoomStatus """ return self._properties['status'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def enable_turn(self): """ :returns: The enable_turn :rtype: bool """ return self._properties['enable_turn'] @property def unique_name(self): """ :returns: The unique_name :rtype: unicode """ return self._properties['unique_name'] @property def status_callback(self): """ :returns: The status_callback :rtype: unicode """ return self._properties['status_callback'] @property def status_callback_method(self): """ :returns: The status_callback_method :rtype: unicode """ return self._properties['status_callback_method'] @property def end_time(self): """ :returns: The end_time :rtype: datetime """ return self._properties['end_time'] @property def duration(self): """ :returns: The duration :rtype: unicode """ return self._properties['duration'] @property def type(self): """ :returns: The type :rtype: RoomInstance.RoomType """ return self._properties['type'] @property def max_participants(self): """ :returns: The max_participants :rtype: unicode """ return self._properties['max_participants'] @property def record_participants_on_connect(self): """ :returns: The record_participants_on_connect :rtype: bool """ return self._properties['record_participants_on_connect'] @property def video_codecs(self): """ :returns: The video_codecs :rtype: RoomInstance.VideoCodec """ return self._properties['video_codecs'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a RoomInstance :returns: Fetched RoomInstance :rtype: twilio.rest.video.v1.room.RoomInstance """ return self._proxy.fetch() def update(self, status): """ Update the RoomInstance :param RoomInstance.RoomStatus status: The status :returns: Updated RoomInstance :rtype: twilio.rest.video.v1.room.RoomInstance """ return self._proxy.update(status,) @property def recordings(self): """ Access the recordings :returns: twilio.rest.video.v1.room.recording.RoomRecordingList :rtype: twilio.rest.video.v1.room.recording.RoomRecordingList """ return self._proxy.recordings def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/video/v1/room/recording/000077500000000000000000000000001317472742600232425ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/video/v1/room/recording/__init__.py000066400000000000000000000363031317472742600253600ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize 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.page import Page class RoomRecordingList(ListResource): """ """ def __init__(self, version, room_sid): """ Initialize the RoomRecordingList :param Version version: Version that contains the resource :param room_sid: The room_sid :returns: twilio.rest.video.v1.room.recording.RoomRecordingList :rtype: twilio.rest.video.v1.room.recording.RoomRecordingList """ super(RoomRecordingList, self).__init__(version) # Path Solution self._solution = {'room_sid': room_sid,} self._uri = '/Rooms/{room_sid}/Recordings'.format(**self._solution) def stream(self, status=values.unset, source_sid=values.unset, date_created_after=values.unset, date_created_before=values.unset, limit=None, page_size=None): """ Streams RoomRecordingInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param RoomRecordingInstance.Status status: The status :param unicode source_sid: The source_sid :param datetime date_created_after: The date_created_after :param datetime date_created_before: The date_created_before :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.video.v1.room.recording.RoomRecordingInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( status=status, source_sid=source_sid, date_created_after=date_created_after, date_created_before=date_created_before, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, status=values.unset, source_sid=values.unset, date_created_after=values.unset, date_created_before=values.unset, limit=None, page_size=None): """ Lists RoomRecordingInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param RoomRecordingInstance.Status status: The status :param unicode source_sid: The source_sid :param datetime date_created_after: The date_created_after :param datetime date_created_before: The date_created_before :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.video.v1.room.recording.RoomRecordingInstance] """ return list(self.stream( status=status, source_sid=source_sid, date_created_after=date_created_after, date_created_before=date_created_before, limit=limit, page_size=page_size, )) def page(self, status=values.unset, source_sid=values.unset, date_created_after=values.unset, date_created_before=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of RoomRecordingInstance records from the API. Request is executed immediately :param RoomRecordingInstance.Status status: The status :param unicode source_sid: The source_sid :param datetime date_created_after: The date_created_after :param datetime date_created_before: The date_created_before :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of RoomRecordingInstance :rtype: twilio.rest.video.v1.room.recording.RoomRecordingPage """ params = values.of({ 'Status': status, 'SourceSid': source_sid, 'DateCreatedAfter': serialize.iso8601_datetime(date_created_after), 'DateCreatedBefore': serialize.iso8601_datetime(date_created_before), 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return RoomRecordingPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of RoomRecordingInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of RoomRecordingInstance :rtype: twilio.rest.video.v1.room.recording.RoomRecordingPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return RoomRecordingPage(self._version, response, self._solution) def get(self, sid): """ Constructs a RoomRecordingContext :param sid: The sid :returns: twilio.rest.video.v1.room.recording.RoomRecordingContext :rtype: twilio.rest.video.v1.room.recording.RoomRecordingContext """ return RoomRecordingContext(self._version, room_sid=self._solution['room_sid'], sid=sid,) def __call__(self, sid): """ Constructs a RoomRecordingContext :param sid: The sid :returns: twilio.rest.video.v1.room.recording.RoomRecordingContext :rtype: twilio.rest.video.v1.room.recording.RoomRecordingContext """ return RoomRecordingContext(self._version, room_sid=self._solution['room_sid'], sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class RoomRecordingPage(Page): """ """ def __init__(self, version, response, solution): """ Initialize the RoomRecordingPage :param Version version: Version that contains the resource :param Response response: Response from the API :param room_sid: The room_sid :returns: twilio.rest.video.v1.room.recording.RoomRecordingPage :rtype: twilio.rest.video.v1.room.recording.RoomRecordingPage """ super(RoomRecordingPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of RoomRecordingInstance :param dict payload: Payload response from the API :returns: twilio.rest.video.v1.room.recording.RoomRecordingInstance :rtype: twilio.rest.video.v1.room.recording.RoomRecordingInstance """ return RoomRecordingInstance(self._version, payload, room_sid=self._solution['room_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class RoomRecordingContext(InstanceContext): """ """ def __init__(self, version, room_sid, sid): """ Initialize the RoomRecordingContext :param Version version: Version that contains the resource :param room_sid: The room_sid :param sid: The sid :returns: twilio.rest.video.v1.room.recording.RoomRecordingContext :rtype: twilio.rest.video.v1.room.recording.RoomRecordingContext """ super(RoomRecordingContext, self).__init__(version) # Path Solution self._solution = {'room_sid': room_sid, 'sid': sid,} self._uri = '/Rooms/{room_sid}/Recordings/{sid}'.format(**self._solution) def fetch(self): """ Fetch a RoomRecordingInstance :returns: Fetched RoomRecordingInstance :rtype: twilio.rest.video.v1.room.recording.RoomRecordingInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return RoomRecordingInstance( self._version, payload, room_sid=self._solution['room_sid'], sid=self._solution['sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class RoomRecordingInstance(InstanceResource): """ """ class Status(object): PROCESSING = "processing" COMPLETED = "completed" DELETED = "deleted" FAILED = "failed" class Type(object): AUDIO = "audio" VIDEO = "video" DATA = "data" class Format(object): MKA = "mka" MKV = "mkv" class Codec(object): VP8 = "VP8" H264 = "H264" OPUS = "OPUS" PCMU = "PCMU" def __init__(self, version, payload, room_sid, sid=None): """ Initialize the RoomRecordingInstance :returns: twilio.rest.video.v1.room.recording.RoomRecordingInstance :rtype: twilio.rest.video.v1.room.recording.RoomRecordingInstance """ super(RoomRecordingInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'status': payload['status'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'sid': payload['sid'], 'source_sid': payload['source_sid'], 'size': deserialize.integer(payload['size']), 'type': payload['type'], 'duration': deserialize.integer(payload['duration']), 'container_format': payload['container_format'], 'codec': payload['codec'], 'grouping_sids': payload['grouping_sids'], 'room_sid': payload['room_sid'], 'url': payload['url'], 'links': payload['links'], } # Context self._context = None self._solution = {'room_sid': room_sid, 'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: RoomRecordingContext for this RoomRecordingInstance :rtype: twilio.rest.video.v1.room.recording.RoomRecordingContext """ if self._context is None: self._context = RoomRecordingContext( self._version, room_sid=self._solution['room_sid'], sid=self._solution['sid'], ) return self._context @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def status(self): """ :returns: The status :rtype: RoomRecordingInstance.Status """ return self._properties['status'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def source_sid(self): """ :returns: The source_sid :rtype: unicode """ return self._properties['source_sid'] @property def size(self): """ :returns: The size :rtype: unicode """ return self._properties['size'] @property def type(self): """ :returns: The type :rtype: RoomRecordingInstance.Type """ return self._properties['type'] @property def duration(self): """ :returns: The duration :rtype: unicode """ return self._properties['duration'] @property def container_format(self): """ :returns: The container_format :rtype: RoomRecordingInstance.Format """ return self._properties['container_format'] @property def codec(self): """ :returns: The codec :rtype: RoomRecordingInstance.Codec """ return self._properties['codec'] @property def grouping_sids(self): """ :returns: The grouping_sids :rtype: dict """ return self._properties['grouping_sids'] @property def room_sid(self): """ :returns: The room_sid :rtype: unicode """ return self._properties['room_sid'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] def fetch(self): """ Fetch a RoomRecordingInstance :returns: Fetched RoomRecordingInstance :rtype: twilio.rest.video.v1.room.recording.RoomRecordingInstance """ return self._proxy.fetch() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/wireless/000077500000000000000000000000001317472742600205135ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/wireless/__init__.py000066400000000000000000000026251317472742600226310ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.domain import Domain from twilio.rest.wireless.v1 import V1 class Wireless(Domain): def __init__(self, twilio): """ Initialize the Wireless Domain :returns: Domain for Wireless :rtype: twilio.rest.wireless.Wireless """ super(Wireless, self).__init__(twilio) self.base_url = 'https://wireless.twilio.com' # Versions self._v1 = None @property def v1(self): """ :returns: Version v1 of wireless :rtype: twilio.rest.wireless.v1.V1 """ if self._v1 is None: self._v1 = V1(self) return self._v1 @property def commands(self): """ :rtype: twilio.rest.wireless.v1.command.CommandList """ return self.v1.commands @property def rate_plans(self): """ :rtype: twilio.rest.wireless.v1.rate_plan.RatePlanList """ return self.v1.rate_plans @property def sims(self): """ :rtype: twilio.rest.wireless.v1.sim.SimList """ return self.v1.sims def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/wireless/v1/000077500000000000000000000000001317472742600210415ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/wireless/v1/__init__.py000066400000000000000000000030551317472742600231550ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base.version import Version from twilio.rest.wireless.v1.command import CommandList from twilio.rest.wireless.v1.rate_plan import RatePlanList from twilio.rest.wireless.v1.sim import SimList class V1(Version): def __init__(self, domain): """ Initialize the V1 version of Wireless :returns: V1 version of Wireless :rtype: twilio.rest.wireless.v1.V1.V1 """ super(V1, self).__init__(domain) self.version = 'v1' self._commands = None self._rate_plans = None self._sims = None @property def commands(self): """ :rtype: twilio.rest.wireless.v1.command.CommandList """ if self._commands is None: self._commands = CommandList(self) return self._commands @property def rate_plans(self): """ :rtype: twilio.rest.wireless.v1.rate_plan.RatePlanList """ if self._rate_plans is None: self._rate_plans = RatePlanList(self) return self._rate_plans @property def sims(self): """ :rtype: twilio.rest.wireless.v1.sim.SimList """ if self._sims is None: self._sims = SimList(self) return self._sims def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/wireless/v1/command.py000066400000000000000000000336641317472742600230450ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class CommandList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version): """ Initialize the CommandList :param Version version: Version that contains the resource :returns: twilio.rest.wireless.v1.command.CommandList :rtype: twilio.rest.wireless.v1.command.CommandList """ super(CommandList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/Commands'.format(**self._solution) def stream(self, sim=values.unset, status=values.unset, direction=values.unset, limit=None, page_size=None): """ Streams CommandInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param unicode sim: The sim :param CommandInstance.Status status: The status :param CommandInstance.Direction direction: The direction :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.wireless.v1.command.CommandInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(sim=sim, status=status, direction=direction, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, sim=values.unset, status=values.unset, direction=values.unset, limit=None, page_size=None): """ Lists CommandInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param unicode sim: The sim :param CommandInstance.Status status: The status :param CommandInstance.Direction direction: The direction :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.wireless.v1.command.CommandInstance] """ return list(self.stream(sim=sim, status=status, direction=direction, limit=limit, page_size=page_size,)) def page(self, sim=values.unset, status=values.unset, direction=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of CommandInstance records from the API. Request is executed immediately :param unicode sim: The sim :param CommandInstance.Status status: The status :param CommandInstance.Direction direction: The direction :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of CommandInstance :rtype: twilio.rest.wireless.v1.command.CommandPage """ params = values.of({ 'Sim': sim, 'Status': status, 'Direction': direction, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return CommandPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of CommandInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of CommandInstance :rtype: twilio.rest.wireless.v1.command.CommandPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return CommandPage(self._version, response, self._solution) def create(self, command, sim=values.unset, callback_method=values.unset, callback_url=values.unset, command_mode=values.unset, include_sid=values.unset): """ Create a new CommandInstance :param unicode command: The command :param unicode sim: The sim :param unicode callback_method: The callback_method :param unicode callback_url: The callback_url :param CommandInstance.CommandMode command_mode: The command_mode :param unicode include_sid: The include_sid :returns: Newly created CommandInstance :rtype: twilio.rest.wireless.v1.command.CommandInstance """ data = values.of({ 'Command': command, 'Sim': sim, 'CallbackMethod': callback_method, 'CallbackUrl': callback_url, 'CommandMode': command_mode, 'IncludeSid': include_sid, }) payload = self._version.create( 'POST', self._uri, data=data, ) return CommandInstance(self._version, payload,) def get(self, sid): """ Constructs a CommandContext :param sid: The sid :returns: twilio.rest.wireless.v1.command.CommandContext :rtype: twilio.rest.wireless.v1.command.CommandContext """ return CommandContext(self._version, sid=sid,) def __call__(self, sid): """ Constructs a CommandContext :param sid: The sid :returns: twilio.rest.wireless.v1.command.CommandContext :rtype: twilio.rest.wireless.v1.command.CommandContext """ return CommandContext(self._version, sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class CommandPage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the CommandPage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.wireless.v1.command.CommandPage :rtype: twilio.rest.wireless.v1.command.CommandPage """ super(CommandPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of CommandInstance :param dict payload: Payload response from the API :returns: twilio.rest.wireless.v1.command.CommandInstance :rtype: twilio.rest.wireless.v1.command.CommandInstance """ return CommandInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class CommandContext(InstanceContext): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, sid): """ Initialize the CommandContext :param Version version: Version that contains the resource :param sid: The sid :returns: twilio.rest.wireless.v1.command.CommandContext :rtype: twilio.rest.wireless.v1.command.CommandContext """ super(CommandContext, self).__init__(version) # Path Solution self._solution = {'sid': sid,} self._uri = '/Commands/{sid}'.format(**self._solution) def fetch(self): """ Fetch a CommandInstance :returns: Fetched CommandInstance :rtype: twilio.rest.wireless.v1.command.CommandInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return CommandInstance(self._version, payload, sid=self._solution['sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class CommandInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ class Direction(object): FROM_SIM = "from_sim" TO_SIM = "to_sim" class Status(object): QUEUED = "queued" SENT = "sent" DELIVERED = "delivered" RECEIVED = "received" FAILED = "failed" class CommandMode(object): TEXT = "text" BINARY = "binary" def __init__(self, version, payload, sid=None): """ Initialize the CommandInstance :returns: twilio.rest.wireless.v1.command.CommandInstance :rtype: twilio.rest.wireless.v1.command.CommandInstance """ super(CommandInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'sim_sid': payload['sim_sid'], 'command': payload['command'], 'command_mode': payload['command_mode'], 'status': payload['status'], 'direction': payload['direction'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'url': payload['url'], } # Context self._context = None self._solution = {'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: CommandContext for this CommandInstance :rtype: twilio.rest.wireless.v1.command.CommandContext """ if self._context is None: self._context = CommandContext(self._version, sid=self._solution['sid'],) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def sim_sid(self): """ :returns: The sim_sid :rtype: unicode """ return self._properties['sim_sid'] @property def command(self): """ :returns: The command :rtype: unicode """ return self._properties['command'] @property def command_mode(self): """ :returns: The command_mode :rtype: CommandInstance.CommandMode """ return self._properties['command_mode'] @property def status(self): """ :returns: The status :rtype: CommandInstance.Status """ return self._properties['status'] @property def direction(self): """ :returns: The direction :rtype: CommandInstance.Direction """ return self._properties['direction'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a CommandInstance :returns: Fetched CommandInstance :rtype: twilio.rest.wireless.v1.command.CommandInstance """ return self._proxy.fetch() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/wireless/v1/rate_plan.py000066400000000000000000000417561317472742600233750ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page class RatePlanList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version): """ Initialize the RatePlanList :param Version version: Version that contains the resource :returns: twilio.rest.wireless.v1.rate_plan.RatePlanList :rtype: twilio.rest.wireless.v1.rate_plan.RatePlanList """ super(RatePlanList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/RatePlans'.format(**self._solution) def stream(self, limit=None, page_size=None): """ Streams RatePlanInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.wireless.v1.rate_plan.RatePlanInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, limit=None, page_size=None): """ Lists RatePlanInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.wireless.v1.rate_plan.RatePlanInstance] """ return list(self.stream(limit=limit, page_size=page_size,)) def page(self, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of RatePlanInstance records from the API. Request is executed immediately :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of RatePlanInstance :rtype: twilio.rest.wireless.v1.rate_plan.RatePlanPage """ params = values.of({'PageToken': page_token, 'Page': page_number, 'PageSize': page_size,}) response = self._version.page( 'GET', self._uri, params=params, ) return RatePlanPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of RatePlanInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of RatePlanInstance :rtype: twilio.rest.wireless.v1.rate_plan.RatePlanPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return RatePlanPage(self._version, response, self._solution) def create(self, unique_name=values.unset, friendly_name=values.unset, data_enabled=values.unset, data_limit=values.unset, data_metering=values.unset, messaging_enabled=values.unset, voice_enabled=values.unset, national_roaming_enabled=values.unset, international_roaming=values.unset, national_roaming_data_limit=values.unset, international_roaming_data_limit=values.unset): """ Create a new RatePlanInstance :param unicode unique_name: The unique_name :param unicode friendly_name: The friendly_name :param bool data_enabled: The data_enabled :param unicode data_limit: The data_limit :param unicode data_metering: The data_metering :param bool messaging_enabled: The messaging_enabled :param bool voice_enabled: The voice_enabled :param bool national_roaming_enabled: The national_roaming_enabled :param unicode international_roaming: The international_roaming :param unicode national_roaming_data_limit: The national_roaming_data_limit :param unicode international_roaming_data_limit: The international_roaming_data_limit :returns: Newly created RatePlanInstance :rtype: twilio.rest.wireless.v1.rate_plan.RatePlanInstance """ data = values.of({ 'UniqueName': unique_name, 'FriendlyName': friendly_name, 'DataEnabled': data_enabled, 'DataLimit': data_limit, 'DataMetering': data_metering, 'MessagingEnabled': messaging_enabled, 'VoiceEnabled': voice_enabled, 'NationalRoamingEnabled': national_roaming_enabled, 'InternationalRoaming': international_roaming, 'NationalRoamingDataLimit': national_roaming_data_limit, 'InternationalRoamingDataLimit': international_roaming_data_limit, }) payload = self._version.create( 'POST', self._uri, data=data, ) return RatePlanInstance(self._version, payload,) def get(self, sid): """ Constructs a RatePlanContext :param sid: The sid :returns: twilio.rest.wireless.v1.rate_plan.RatePlanContext :rtype: twilio.rest.wireless.v1.rate_plan.RatePlanContext """ return RatePlanContext(self._version, sid=sid,) def __call__(self, sid): """ Constructs a RatePlanContext :param sid: The sid :returns: twilio.rest.wireless.v1.rate_plan.RatePlanContext :rtype: twilio.rest.wireless.v1.rate_plan.RatePlanContext """ return RatePlanContext(self._version, sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class RatePlanPage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the RatePlanPage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.wireless.v1.rate_plan.RatePlanPage :rtype: twilio.rest.wireless.v1.rate_plan.RatePlanPage """ super(RatePlanPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of RatePlanInstance :param dict payload: Payload response from the API :returns: twilio.rest.wireless.v1.rate_plan.RatePlanInstance :rtype: twilio.rest.wireless.v1.rate_plan.RatePlanInstance """ return RatePlanInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class RatePlanContext(InstanceContext): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, sid): """ Initialize the RatePlanContext :param Version version: Version that contains the resource :param sid: The sid :returns: twilio.rest.wireless.v1.rate_plan.RatePlanContext :rtype: twilio.rest.wireless.v1.rate_plan.RatePlanContext """ super(RatePlanContext, self).__init__(version) # Path Solution self._solution = {'sid': sid,} self._uri = '/RatePlans/{sid}'.format(**self._solution) def fetch(self): """ Fetch a RatePlanInstance :returns: Fetched RatePlanInstance :rtype: twilio.rest.wireless.v1.rate_plan.RatePlanInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return RatePlanInstance(self._version, payload, sid=self._solution['sid'],) def update(self, unique_name=values.unset, friendly_name=values.unset): """ Update the RatePlanInstance :param unicode unique_name: The unique_name :param unicode friendly_name: The friendly_name :returns: Updated RatePlanInstance :rtype: twilio.rest.wireless.v1.rate_plan.RatePlanInstance """ data = values.of({'UniqueName': unique_name, 'FriendlyName': friendly_name,}) payload = self._version.update( 'POST', self._uri, data=data, ) return RatePlanInstance(self._version, payload, sid=self._solution['sid'],) def delete(self): """ Deletes the RatePlanInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class RatePlanInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, payload, sid=None): """ Initialize the RatePlanInstance :returns: twilio.rest.wireless.v1.rate_plan.RatePlanInstance :rtype: twilio.rest.wireless.v1.rate_plan.RatePlanInstance """ super(RatePlanInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'unique_name': payload['unique_name'], 'account_sid': payload['account_sid'], 'friendly_name': payload['friendly_name'], 'data_enabled': payload['data_enabled'], 'data_metering': payload['data_metering'], 'data_limit': deserialize.integer(payload['data_limit']), 'messaging_enabled': payload['messaging_enabled'], 'voice_enabled': payload['voice_enabled'], 'national_roaming_enabled': payload['national_roaming_enabled'], 'national_roaming_data_limit': deserialize.integer(payload['national_roaming_data_limit']), 'international_roaming': payload['international_roaming'], 'international_roaming_data_limit': deserialize.integer(payload['international_roaming_data_limit']), 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'url': payload['url'], } # Context self._context = None self._solution = {'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: RatePlanContext for this RatePlanInstance :rtype: twilio.rest.wireless.v1.rate_plan.RatePlanContext """ if self._context is None: self._context = RatePlanContext(self._version, sid=self._solution['sid'],) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def unique_name(self): """ :returns: The unique_name :rtype: unicode """ return self._properties['unique_name'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def data_enabled(self): """ :returns: The data_enabled :rtype: bool """ return self._properties['data_enabled'] @property def data_metering(self): """ :returns: The data_metering :rtype: unicode """ return self._properties['data_metering'] @property def data_limit(self): """ :returns: The data_limit :rtype: unicode """ return self._properties['data_limit'] @property def messaging_enabled(self): """ :returns: The messaging_enabled :rtype: bool """ return self._properties['messaging_enabled'] @property def voice_enabled(self): """ :returns: The voice_enabled :rtype: bool """ return self._properties['voice_enabled'] @property def national_roaming_enabled(self): """ :returns: The national_roaming_enabled :rtype: bool """ return self._properties['national_roaming_enabled'] @property def national_roaming_data_limit(self): """ :returns: The national_roaming_data_limit :rtype: unicode """ return self._properties['national_roaming_data_limit'] @property def international_roaming(self): """ :returns: The international_roaming :rtype: unicode """ return self._properties['international_roaming'] @property def international_roaming_data_limit(self): """ :returns: The international_roaming_data_limit :rtype: unicode """ return self._properties['international_roaming_data_limit'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] def fetch(self): """ Fetch a RatePlanInstance :returns: Fetched RatePlanInstance :rtype: twilio.rest.wireless.v1.rate_plan.RatePlanInstance """ return self._proxy.fetch() def update(self, unique_name=values.unset, friendly_name=values.unset): """ Update the RatePlanInstance :param unicode unique_name: The unique_name :param unicode friendly_name: The friendly_name :returns: Updated RatePlanInstance :rtype: twilio.rest.wireless.v1.rate_plan.RatePlanInstance """ return self._proxy.update(unique_name=unique_name, friendly_name=friendly_name,) def delete(self): """ Deletes the RatePlanInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._proxy.delete() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/wireless/v1/sim/000077500000000000000000000000001317472742600216315ustar00rootroot00000000000000twilio-python-6.8.2/twilio/rest/wireless/v1/sim/__init__.py000066400000000000000000000555201317472742600237510ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize 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.page import Page from twilio.rest.wireless.v1.sim.data_session import DataSessionList from twilio.rest.wireless.v1.sim.usage_record import UsageRecordList class SimList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version): """ Initialize the SimList :param Version version: Version that contains the resource :returns: twilio.rest.wireless.v1.sim.SimList :rtype: twilio.rest.wireless.v1.sim.SimList """ super(SimList, self).__init__(version) # Path Solution self._solution = {} self._uri = '/Sims'.format(**self._solution) def stream(self, status=values.unset, iccid=values.unset, rate_plan=values.unset, e_id=values.unset, sim_registration_code=values.unset, limit=None, page_size=None): """ Streams SimInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param SimInstance.Status status: The status :param unicode iccid: The iccid :param unicode rate_plan: The rate_plan :param unicode e_id: The e_id :param unicode sim_registration_code: The sim_registration_code :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.wireless.v1.sim.SimInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page( status=status, iccid=iccid, rate_plan=rate_plan, e_id=e_id, sim_registration_code=sim_registration_code, page_size=limits['page_size'], ) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, status=values.unset, iccid=values.unset, rate_plan=values.unset, e_id=values.unset, sim_registration_code=values.unset, limit=None, page_size=None): """ Lists SimInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param SimInstance.Status status: The status :param unicode iccid: The iccid :param unicode rate_plan: The rate_plan :param unicode e_id: The e_id :param unicode sim_registration_code: The sim_registration_code :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.wireless.v1.sim.SimInstance] """ return list(self.stream( status=status, iccid=iccid, rate_plan=rate_plan, e_id=e_id, sim_registration_code=sim_registration_code, limit=limit, page_size=page_size, )) def page(self, status=values.unset, iccid=values.unset, rate_plan=values.unset, e_id=values.unset, sim_registration_code=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of SimInstance records from the API. Request is executed immediately :param SimInstance.Status status: The status :param unicode iccid: The iccid :param unicode rate_plan: The rate_plan :param unicode e_id: The e_id :param unicode sim_registration_code: The sim_registration_code :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of SimInstance :rtype: twilio.rest.wireless.v1.sim.SimPage """ params = values.of({ 'Status': status, 'Iccid': iccid, 'RatePlan': rate_plan, 'EId': e_id, 'SimRegistrationCode': sim_registration_code, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return SimPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of SimInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of SimInstance :rtype: twilio.rest.wireless.v1.sim.SimPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return SimPage(self._version, response, self._solution) def get(self, sid): """ Constructs a SimContext :param sid: The sid :returns: twilio.rest.wireless.v1.sim.SimContext :rtype: twilio.rest.wireless.v1.sim.SimContext """ return SimContext(self._version, sid=sid,) def __call__(self, sid): """ Constructs a SimContext :param sid: The sid :returns: twilio.rest.wireless.v1.sim.SimContext :rtype: twilio.rest.wireless.v1.sim.SimContext """ return SimContext(self._version, sid=sid,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SimPage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the SimPage :param Version version: Version that contains the resource :param Response response: Response from the API :returns: twilio.rest.wireless.v1.sim.SimPage :rtype: twilio.rest.wireless.v1.sim.SimPage """ super(SimPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of SimInstance :param dict payload: Payload response from the API :returns: twilio.rest.wireless.v1.sim.SimInstance :rtype: twilio.rest.wireless.v1.sim.SimInstance """ return SimInstance(self._version, payload,) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class SimContext(InstanceContext): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, sid): """ Initialize the SimContext :param Version version: Version that contains the resource :param sid: The sid :returns: twilio.rest.wireless.v1.sim.SimContext :rtype: twilio.rest.wireless.v1.sim.SimContext """ super(SimContext, self).__init__(version) # Path Solution self._solution = {'sid': sid,} self._uri = '/Sims/{sid}'.format(**self._solution) # Dependents self._usage_records = None self._data_sessions = None def fetch(self): """ Fetch a SimInstance :returns: Fetched SimInstance :rtype: twilio.rest.wireless.v1.sim.SimInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return SimInstance(self._version, payload, sid=self._solution['sid'],) def update(self, unique_name=values.unset, callback_method=values.unset, callback_url=values.unset, friendly_name=values.unset, rate_plan=values.unset, status=values.unset, commands_callback_method=values.unset, commands_callback_url=values.unset, sms_fallback_method=values.unset, sms_fallback_url=values.unset, sms_method=values.unset, sms_url=values.unset, voice_fallback_method=values.unset, voice_fallback_url=values.unset, voice_method=values.unset, voice_url=values.unset): """ Update the SimInstance :param unicode unique_name: The unique_name :param unicode callback_method: The callback_method :param unicode callback_url: The callback_url :param unicode friendly_name: The friendly_name :param unicode rate_plan: The rate_plan :param SimInstance.Status status: The status :param unicode commands_callback_method: The commands_callback_method :param unicode commands_callback_url: The commands_callback_url :param unicode sms_fallback_method: The sms_fallback_method :param unicode sms_fallback_url: The sms_fallback_url :param unicode sms_method: The sms_method :param unicode sms_url: The sms_url :param unicode voice_fallback_method: The voice_fallback_method :param unicode voice_fallback_url: The voice_fallback_url :param unicode voice_method: The voice_method :param unicode voice_url: The voice_url :returns: Updated SimInstance :rtype: twilio.rest.wireless.v1.sim.SimInstance """ data = values.of({ 'UniqueName': unique_name, 'CallbackMethod': callback_method, 'CallbackUrl': callback_url, 'FriendlyName': friendly_name, 'RatePlan': rate_plan, 'Status': status, 'CommandsCallbackMethod': commands_callback_method, 'CommandsCallbackUrl': commands_callback_url, 'SmsFallbackMethod': sms_fallback_method, 'SmsFallbackUrl': sms_fallback_url, 'SmsMethod': sms_method, 'SmsUrl': sms_url, 'VoiceFallbackMethod': voice_fallback_method, 'VoiceFallbackUrl': voice_fallback_url, 'VoiceMethod': voice_method, 'VoiceUrl': voice_url, }) payload = self._version.update( 'POST', self._uri, data=data, ) return SimInstance(self._version, payload, sid=self._solution['sid'],) @property def usage_records(self): """ Access the usage_records :returns: twilio.rest.wireless.v1.sim.usage_record.UsageRecordList :rtype: twilio.rest.wireless.v1.sim.usage_record.UsageRecordList """ if self._usage_records is None: self._usage_records = UsageRecordList(self._version, sim_sid=self._solution['sid'],) return self._usage_records @property def data_sessions(self): """ Access the data_sessions :returns: twilio.rest.wireless.v1.sim.data_session.DataSessionList :rtype: twilio.rest.wireless.v1.sim.data_session.DataSessionList """ if self._data_sessions is None: self._data_sessions = DataSessionList(self._version, sim_sid=self._solution['sid'],) return self._data_sessions def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) class SimInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ class Status(object): NEW = "new" READY = "ready" ACTIVE = "active" SUSPENDED = "suspended" DEACTIVATED = "deactivated" CANCELED = "canceled" SCHEDULED = "scheduled" UPDATING = "updating" def __init__(self, version, payload, sid=None): """ Initialize the SimInstance :returns: twilio.rest.wireless.v1.sim.SimInstance :rtype: twilio.rest.wireless.v1.sim.SimInstance """ super(SimInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'unique_name': payload['unique_name'], 'account_sid': payload['account_sid'], 'rate_plan_sid': payload['rate_plan_sid'], 'friendly_name': payload['friendly_name'], 'iccid': payload['iccid'], 'e_id': payload['e_id'], 'status': payload['status'], 'commands_callback_url': payload['commands_callback_url'], 'commands_callback_method': payload['commands_callback_method'], 'sms_fallback_method': payload['sms_fallback_method'], 'sms_fallback_url': payload['sms_fallback_url'], 'sms_method': payload['sms_method'], 'sms_url': payload['sms_url'], 'voice_fallback_method': payload['voice_fallback_method'], 'voice_fallback_url': payload['voice_fallback_url'], 'voice_method': payload['voice_method'], 'voice_url': payload['voice_url'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'url': payload['url'], 'links': payload['links'], 'ip_address': payload['ip_address'], } # Context self._context = None self._solution = {'sid': sid or self._properties['sid'],} @property def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: SimContext for this SimInstance :rtype: twilio.rest.wireless.v1.sim.SimContext """ if self._context is None: self._context = SimContext(self._version, sid=self._solution['sid'],) return self._context @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def unique_name(self): """ :returns: The unique_name :rtype: unicode """ return self._properties['unique_name'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def rate_plan_sid(self): """ :returns: The rate_plan_sid :rtype: unicode """ return self._properties['rate_plan_sid'] @property def friendly_name(self): """ :returns: The friendly_name :rtype: unicode """ return self._properties['friendly_name'] @property def iccid(self): """ :returns: The iccid :rtype: unicode """ return self._properties['iccid'] @property def e_id(self): """ :returns: The e_id :rtype: unicode """ return self._properties['e_id'] @property def status(self): """ :returns: The status :rtype: SimInstance.Status """ return self._properties['status'] @property def commands_callback_url(self): """ :returns: The commands_callback_url :rtype: unicode """ return self._properties['commands_callback_url'] @property def commands_callback_method(self): """ :returns: The commands_callback_method :rtype: unicode """ return self._properties['commands_callback_method'] @property def sms_fallback_method(self): """ :returns: The sms_fallback_method :rtype: unicode """ return self._properties['sms_fallback_method'] @property def sms_fallback_url(self): """ :returns: The sms_fallback_url :rtype: unicode """ return self._properties['sms_fallback_url'] @property def sms_method(self): """ :returns: The sms_method :rtype: unicode """ return self._properties['sms_method'] @property def sms_url(self): """ :returns: The sms_url :rtype: unicode """ return self._properties['sms_url'] @property def voice_fallback_method(self): """ :returns: The voice_fallback_method :rtype: unicode """ return self._properties['voice_fallback_method'] @property def voice_fallback_url(self): """ :returns: The voice_fallback_url :rtype: unicode """ return self._properties['voice_fallback_url'] @property def voice_method(self): """ :returns: The voice_method :rtype: unicode """ return self._properties['voice_method'] @property def voice_url(self): """ :returns: The voice_url :rtype: unicode """ return self._properties['voice_url'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def url(self): """ :returns: The url :rtype: unicode """ return self._properties['url'] @property def links(self): """ :returns: The links :rtype: unicode """ return self._properties['links'] @property def ip_address(self): """ :returns: The ip_address :rtype: unicode """ return self._properties['ip_address'] def fetch(self): """ Fetch a SimInstance :returns: Fetched SimInstance :rtype: twilio.rest.wireless.v1.sim.SimInstance """ return self._proxy.fetch() def update(self, unique_name=values.unset, callback_method=values.unset, callback_url=values.unset, friendly_name=values.unset, rate_plan=values.unset, status=values.unset, commands_callback_method=values.unset, commands_callback_url=values.unset, sms_fallback_method=values.unset, sms_fallback_url=values.unset, sms_method=values.unset, sms_url=values.unset, voice_fallback_method=values.unset, voice_fallback_url=values.unset, voice_method=values.unset, voice_url=values.unset): """ Update the SimInstance :param unicode unique_name: The unique_name :param unicode callback_method: The callback_method :param unicode callback_url: The callback_url :param unicode friendly_name: The friendly_name :param unicode rate_plan: The rate_plan :param SimInstance.Status status: The status :param unicode commands_callback_method: The commands_callback_method :param unicode commands_callback_url: The commands_callback_url :param unicode sms_fallback_method: The sms_fallback_method :param unicode sms_fallback_url: The sms_fallback_url :param unicode sms_method: The sms_method :param unicode sms_url: The sms_url :param unicode voice_fallback_method: The voice_fallback_method :param unicode voice_fallback_url: The voice_fallback_url :param unicode voice_method: The voice_method :param unicode voice_url: The voice_url :returns: Updated SimInstance :rtype: twilio.rest.wireless.v1.sim.SimInstance """ return self._proxy.update( unique_name=unique_name, callback_method=callback_method, callback_url=callback_url, friendly_name=friendly_name, rate_plan=rate_plan, status=status, commands_callback_method=commands_callback_method, commands_callback_url=commands_callback_url, sms_fallback_method=sms_fallback_method, sms_fallback_url=sms_fallback_url, sms_method=sms_method, sms_url=sms_url, voice_fallback_method=voice_fallback_method, voice_fallback_url=voice_fallback_url, voice_method=voice_method, voice_url=voice_url, ) @property def usage_records(self): """ Access the usage_records :returns: twilio.rest.wireless.v1.sim.usage_record.UsageRecordList :rtype: twilio.rest.wireless.v1.sim.usage_record.UsageRecordList """ return self._proxy.usage_records @property def data_sessions(self): """ Access the data_sessions :returns: twilio.rest.wireless.v1.sim.data_session.DataSessionList :rtype: twilio.rest.wireless.v1.sim.data_session.DataSessionList """ return self._proxy.data_sessions def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return ''.format(context) twilio-python-6.8.2/twilio/rest/wireless/v1/sim/data_session.py000066400000000000000000000260441317472742600246650ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import serialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class DataSessionList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, sim_sid): """ Initialize the DataSessionList :param Version version: Version that contains the resource :param sim_sid: The sim_sid :returns: twilio.rest.wireless.v1.sim.data_session.DataSessionList :rtype: twilio.rest.wireless.v1.sim.data_session.DataSessionList """ super(DataSessionList, self).__init__(version) # Path Solution self._solution = {'sim_sid': sim_sid,} self._uri = '/Sims/{sim_sid}/DataSessions'.format(**self._solution) def stream(self, end=values.unset, start=values.unset, limit=None, page_size=None): """ Streams DataSessionInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param datetime end: The end :param datetime start: The start :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.wireless.v1.sim.data_session.DataSessionInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(end=end, start=start, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, end=values.unset, start=values.unset, limit=None, page_size=None): """ Lists DataSessionInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param datetime end: The end :param datetime start: The start :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.wireless.v1.sim.data_session.DataSessionInstance] """ return list(self.stream(end=end, start=start, limit=limit, page_size=page_size,)) def page(self, end=values.unset, start=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of DataSessionInstance records from the API. Request is executed immediately :param datetime end: The end :param datetime start: The start :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of DataSessionInstance :rtype: twilio.rest.wireless.v1.sim.data_session.DataSessionPage """ params = values.of({ 'End': serialize.iso8601_datetime(end), 'Start': serialize.iso8601_datetime(start), 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return DataSessionPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of DataSessionInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of DataSessionInstance :rtype: twilio.rest.wireless.v1.sim.data_session.DataSessionPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return DataSessionPage(self._version, response, self._solution) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class DataSessionPage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the DataSessionPage :param Version version: Version that contains the resource :param Response response: Response from the API :param sim_sid: The sim_sid :returns: twilio.rest.wireless.v1.sim.data_session.DataSessionPage :rtype: twilio.rest.wireless.v1.sim.data_session.DataSessionPage """ super(DataSessionPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of DataSessionInstance :param dict payload: Payload response from the API :returns: twilio.rest.wireless.v1.sim.data_session.DataSessionInstance :rtype: twilio.rest.wireless.v1.sim.data_session.DataSessionInstance """ return DataSessionInstance(self._version, payload, sim_sid=self._solution['sim_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class DataSessionInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, payload, sim_sid): """ Initialize the DataSessionInstance :returns: twilio.rest.wireless.v1.sim.data_session.DataSessionInstance :rtype: twilio.rest.wireless.v1.sim.data_session.DataSessionInstance """ super(DataSessionInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sid': payload['sid'], 'sim_sid': payload['sim_sid'], 'account_sid': payload['account_sid'], 'radio_link': payload['radio_link'], 'operator_mcc': deserialize.integer(payload['operator_mcc']), 'operator_mnc': deserialize.integer(payload['operator_mnc']), 'operator_country': payload['operator_country'], 'operator_name': payload['operator_name'], 'cell_id': payload['cell_id'], 'cell_location_estimate': payload['cell_location_estimate'], 'packets_uploaded': deserialize.integer(payload['packets_uploaded']), 'packets_downloaded': deserialize.integer(payload['packets_downloaded']), 'last_updated': deserialize.iso8601_datetime(payload['last_updated']), 'start': deserialize.iso8601_datetime(payload['start']), 'end': deserialize.iso8601_datetime(payload['end']), } # Context self._context = None self._solution = {'sim_sid': sim_sid,} @property def sid(self): """ :returns: The sid :rtype: unicode """ return self._properties['sid'] @property def sim_sid(self): """ :returns: The sim_sid :rtype: unicode """ return self._properties['sim_sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def radio_link(self): """ :returns: The radio_link :rtype: unicode """ return self._properties['radio_link'] @property def operator_mcc(self): """ :returns: The operator_mcc :rtype: unicode """ return self._properties['operator_mcc'] @property def operator_mnc(self): """ :returns: The operator_mnc :rtype: unicode """ return self._properties['operator_mnc'] @property def operator_country(self): """ :returns: The operator_country :rtype: unicode """ return self._properties['operator_country'] @property def operator_name(self): """ :returns: The operator_name :rtype: unicode """ return self._properties['operator_name'] @property def cell_id(self): """ :returns: The cell_id :rtype: unicode """ return self._properties['cell_id'] @property def cell_location_estimate(self): """ :returns: The cell_location_estimate :rtype: dict """ return self._properties['cell_location_estimate'] @property def packets_uploaded(self): """ :returns: The packets_uploaded :rtype: unicode """ return self._properties['packets_uploaded'] @property def packets_downloaded(self): """ :returns: The packets_downloaded :rtype: unicode """ return self._properties['packets_downloaded'] @property def last_updated(self): """ :returns: The last_updated :rtype: datetime """ return self._properties['last_updated'] @property def start(self): """ :returns: The start :rtype: datetime """ return self._properties['start'] @property def end(self): """ :returns: The end :rtype: datetime """ return self._properties['end'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/rest/wireless/v1/sim/usage_record.py000066400000000000000000000221711317472742600246500ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import serialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class UsageRecordList(ListResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, sim_sid): """ Initialize the UsageRecordList :param Version version: Version that contains the resource :param sim_sid: The sim_sid :returns: twilio.rest.wireless.v1.sim.usage_record.UsageRecordList :rtype: twilio.rest.wireless.v1.sim.usage_record.UsageRecordList """ super(UsageRecordList, self).__init__(version) # Path Solution self._solution = {'sim_sid': sim_sid,} self._uri = '/Sims/{sim_sid}/UsageRecords'.format(**self._solution) def stream(self, end=values.unset, start=values.unset, granularity=values.unset, limit=None, page_size=None): """ Streams UsageRecordInstance records from the API as a generator stream. This operation lazily loads records as efficiently as possible until the limit is reached. The results are returned as a generator, so this operation is memory efficient. :param datetime end: The end :param datetime start: The start :param UsageRecordInstance.Granularity granularity: The granularity :param int limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.wireless.v1.sim.usage_record.UsageRecordInstance] """ limits = self._version.read_limits(limit, page_size) page = self.page(end=end, start=start, granularity=granularity, page_size=limits['page_size'],) return self._version.stream(page, limits['limit'], limits['page_limit']) def list(self, end=values.unset, start=values.unset, granularity=values.unset, limit=None, page_size=None): """ Lists UsageRecordInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. :param datetime end: The end :param datetime start: The start :param UsageRecordInstance.Granularity granularity: The granularity :param int limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param int page_size: Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, list() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000) :returns: Generator that will yield up to limit results :rtype: list[twilio.rest.wireless.v1.sim.usage_record.UsageRecordInstance] """ return list(self.stream( end=end, start=start, granularity=granularity, limit=limit, page_size=page_size, )) def page(self, end=values.unset, start=values.unset, granularity=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of UsageRecordInstance records from the API. Request is executed immediately :param datetime end: The end :param datetime start: The start :param UsageRecordInstance.Granularity granularity: The granularity :param str page_token: PageToken provided by the API :param int page_number: Page Number, this value is simply for client state :param int page_size: Number of records to return, defaults to 50 :returns: Page of UsageRecordInstance :rtype: twilio.rest.wireless.v1.sim.usage_record.UsageRecordPage """ params = values.of({ 'End': serialize.iso8601_datetime(end), 'Start': serialize.iso8601_datetime(start), 'Granularity': granularity, 'PageToken': page_token, 'Page': page_number, 'PageSize': page_size, }) response = self._version.page( 'GET', self._uri, params=params, ) return UsageRecordPage(self._version, response, self._solution) def get_page(self, target_url): """ Retrieve a specific page of UsageRecordInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of UsageRecordInstance :rtype: twilio.rest.wireless.v1.sim.usage_record.UsageRecordPage """ response = self._version.domain.twilio.request( 'GET', target_url, ) return UsageRecordPage(self._version, response, self._solution) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class UsageRecordPage(Page): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ def __init__(self, version, response, solution): """ Initialize the UsageRecordPage :param Version version: Version that contains the resource :param Response response: Response from the API :param sim_sid: The sim_sid :returns: twilio.rest.wireless.v1.sim.usage_record.UsageRecordPage :rtype: twilio.rest.wireless.v1.sim.usage_record.UsageRecordPage """ super(UsageRecordPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of UsageRecordInstance :param dict payload: Payload response from the API :returns: twilio.rest.wireless.v1.sim.usage_record.UsageRecordInstance :rtype: twilio.rest.wireless.v1.sim.usage_record.UsageRecordInstance """ return UsageRecordInstance(self._version, payload, sim_sid=self._solution['sim_sid'],) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' class UsageRecordInstance(InstanceResource): """ PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. """ class Granularity(object): HOURLY = "hourly" DAILY = "daily" ALL = "all" def __init__(self, version, payload, sim_sid): """ Initialize the UsageRecordInstance :returns: twilio.rest.wireless.v1.sim.usage_record.UsageRecordInstance :rtype: twilio.rest.wireless.v1.sim.usage_record.UsageRecordInstance """ super(UsageRecordInstance, self).__init__(version) # Marshaled Properties self._properties = { 'sim_sid': payload['sim_sid'], 'account_sid': payload['account_sid'], 'period': payload['period'], 'commands': payload['commands'], 'data': payload['data'], } # Context self._context = None self._solution = {'sim_sid': sim_sid,} @property def sim_sid(self): """ :returns: The sim_sid :rtype: unicode """ return self._properties['sim_sid'] @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def period(self): """ :returns: The period :rtype: dict """ return self._properties['period'] @property def commands(self): """ :returns: The commands :rtype: dict """ return self._properties['commands'] @property def data(self): """ :returns: The data :rtype: dict """ return self._properties['data'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '' twilio-python-6.8.2/twilio/twiml/000077500000000000000000000000001317472742600170355ustar00rootroot00000000000000twilio-python-6.8.2/twilio/twiml/__init__.py000066400000000000000000000055161317472742600211550ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ import json import re import xml.etree.ElementTree as ET def lower_camel(string): result = "".join([x.title() for x in string.split('_')]) if not result: return result return result[0].lower() + result[1:] def format_language(language): """ Attempt to format language parameter as 'ww-WW'. :param string language: language parameter """ if not language: return language if not re.match('^[a-zA-Z]{2}[_-][a-zA-Z]{2}$', language): raise TwiMLException('Invalid value for language parameter.') return language[0:2].lower() + '-' + language[3:5].upper() class TwiMLException(Exception): pass class TwiML(object): MAP = { 'from_': 'from' } def __init__(self, **kwargs): self.name = self.__class__.__name__ self.value = None self.verbs = [] self.attrs = {} for k, v in kwargs.items(): if v is not None: self.attrs[lower_camel(self.MAP.get(k, k))] = v def __str__(self): return self.to_xml() def __enter__(self): return self def __exit__(self, exc_type, exc_value, traceback): return False def to_xml(self, xml_declaration=True): """ Return the contents of this verb as an XML string :param bool xml_declaration: Include the XML declaration. Defaults to True """ xml = ET.tostring(self.xml()).decode('utf-8') return '{}'.format(xml) if xml_declaration else xml def append(self, verb): """ Add a TwiML doc :param verb: TwiML Document :returns: self """ if not isinstance(verb, TwiML): raise TwiMLException('Only appending of TwiML is allowed') self.verbs.append(verb) return self def nest(self, verb): """ Add a TwiML doc. Unlike `append()`, this returns the created verb. :param verb: TwiML Document :returns: the TwiML verb """ if not isinstance(verb, TwiML): raise TwiMLException('Only nesting of TwiML is allowed') self.verbs.append(verb) return verb def xml(self): el = ET.Element(self.name) keys = self.attrs.keys() keys = sorted(keys) for a in keys: value = self.attrs[a] if isinstance(value, bool): el.set(a, str(value).lower()) else: el.set(a, str(value)) if self.value: if isinstance(self.value, dict): self.value = json.dumps(self.value) el.text = self.value for verb in self.verbs: el.append(verb.xml()) return el twilio-python-6.8.2/twilio/twiml/fax_response.py000066400000000000000000000016231317472742600221050ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ import json from twilio.twiml import ( TwiML, format_language, ) class FaxResponse(TwiML): """ TwiML for Faxes """ def __init__(self, **kwargs): super(FaxResponse, self).__init__(**kwargs) self.name = 'Response' def receive(self, action=None, method=None, **kwargs): """ Create a element :param action: Receive action URL :param method: Receive action URL method :param kwargs: additional attributes :returns: element """ return self.nest(Receive(action=action, method=method, **kwargs)) class Receive(TwiML): """ TwiML Verb """ def __init__(self, **kwargs): super(Receive, self).__init__(**kwargs) self.name = 'Receive' twilio-python-6.8.2/twilio/twiml/messaging_response.py000066400000000000000000000051141317472742600233030ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ import json from twilio.twiml import ( TwiML, format_language, ) class MessagingResponse(TwiML): """ TwiML for Messages """ def __init__(self, **kwargs): super(MessagingResponse, self).__init__(**kwargs) self.name = 'Response' def message(self, body=None, to=None, from_=None, action=None, method=None, **kwargs): """ Create a element :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 method: Action URL Method :param kwargs: additional attributes :returns: element """ return self.nest(Message(body=body, to=to, from_=from_, action=action, method=method, **kwargs)) def redirect(self, url, method=None, **kwargs): """ Create a element :param url: Redirect URL :param method: Redirect URL method :param kwargs: additional attributes :returns: element """ return self.nest(Redirect(url, method=method, **kwargs)) class Redirect(TwiML): """ TwiML Verb """ def __init__(self, url, **kwargs): super(Redirect, self).__init__(**kwargs) self.name = 'Redirect' self.value = url class Message(TwiML): """ TwiML Verb """ def __init__(self, body=None, **kwargs): super(Message, self).__init__(**kwargs) self.name = 'Message' if body: self.value = body def body(self, message, **kwargs): """ Create a element :param message: Message Body :param kwargs: additional attributes :returns: element """ return self.nest(Body(message, **kwargs)) def media(self, url, **kwargs): """ Create a element :param url: Media URL :param kwargs: additional attributes :returns: element """ return self.nest(Media(url, **kwargs)) class Media(TwiML): """ TwiML Noun """ def __init__(self, url, **kwargs): super(Media, self).__init__(**kwargs) self.name = 'Media' self.value = url class Body(TwiML): """ TwiML Noun """ def __init__(self, message, **kwargs): super(Body, self).__init__(**kwargs) self.name = 'Body' self.value = message twilio-python-6.8.2/twilio/twiml/voice_response.py000066400000000000000000000527571317472742600224520ustar00rootroot00000000000000# coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ import json from twilio.twiml import ( TwiML, format_language, ) class VoiceResponse(TwiML): """ TwiML for Voice """ def __init__(self, **kwargs): super(VoiceResponse, self).__init__(**kwargs) self.name = 'Response' def dial(self, number=None, action=None, method=None, timeout=None, hangup_on_star=None, time_limit=None, caller_id=None, record=None, trim=None, recording_status_callback=None, recording_status_callback_method=None, answer_on_bridge=None, ring_tone=None, **kwargs): """ Create a element :param number: Phone number to dial :param action: Action URL :param method: Action URL method :param timeout: Time to wait for answer :param hangup_on_star: Hangup call on star press :param time_limit: Max time length :param caller_id: Caller ID to display :param record: Record the call :param trim: Trim the recording :param recording_status_callback: Recording status callback URL :param recording_status_callback_method: Recording status callback URL method :param answer_on_bridge: Preserve the ringing behavior of the inbound call until the Dialed call picks up :param ring_tone: Ringtone allows you to override the ringback tone that Twilio will play back to the caller while executing the Dial :param kwargs: additional attributes :returns: element """ return self.nest(Dial( number=number, action=action, method=method, timeout=timeout, hangup_on_star=hangup_on_star, time_limit=time_limit, caller_id=caller_id, record=record, trim=trim, recording_status_callback=recording_status_callback, recording_status_callback_method=recording_status_callback_method, answer_on_bridge=answer_on_bridge, ring_tone=ring_tone, **kwargs )) def echo(self, **kwargs): """ Create a element :param kwargs: additional attributes :returns: element """ return self.nest(Echo(**kwargs)) def enqueue(self, name=None, action=None, method=None, wait_url=None, wait_url_method=None, workflow_sid=None, **kwargs): """ Create a element :param name: Friendly name :param action: Action URL :param method: Action URL method :param wait_url: Wait URL :param wait_url_method: Wait URL method :param workflow_sid: TaskRouter Workflow SID :param kwargs: additional attributes :returns: element """ return self.nest(Enqueue( name=name, action=action, method=method, wait_url=wait_url, wait_url_method=wait_url_method, workflow_sid=workflow_sid, **kwargs )) def gather(self, input=None, action=None, method=None, timeout=None, speech_timeout=None, max_speech_time=None, profanity_filter=None, finish_on_key=None, num_digits=None, partial_result_callback=None, partial_result_callback_method=None, language=None, hints=None, barge_in=None, **kwargs): """ Create a element :param input: Input type Twilio should accept :param action: Action URL :param method: Action URL method :param timeout: Time to wait to gather input :param speech_timeout: Time to wait to gather speech input and it should be either auto or a positive integer. :param max_speech_time: Max allowed time for speech input :param profanity_filter: Profanity Filter on speech :param finish_on_key: Finish gather on key :param num_digits: Number of digits to collect :param partial_result_callback: Partial result callback URL :param partial_result_callback_method: Partial result callback URL method :param language: Language to use :param hints: Speech recognition hints :param barge_in: Stop playing media upon speech :param kwargs: additional attributes :returns: element """ return self.nest(Gather( input=input, action=action, method=method, timeout=timeout, speech_timeout=speech_timeout, max_speech_time=max_speech_time, profanity_filter=profanity_filter, finish_on_key=finish_on_key, num_digits=num_digits, partial_result_callback=partial_result_callback, partial_result_callback_method=partial_result_callback_method, language=language, hints=hints, barge_in=barge_in, **kwargs )) def hangup(self, **kwargs): """ Create a element :param kwargs: additional attributes :returns: element """ return self.nest(Hangup(**kwargs)) def leave(self, **kwargs): """ Create a element :param kwargs: additional attributes :returns: element """ return self.nest(Leave(**kwargs)) def pause(self, length=None, **kwargs): """ Create a element :param length: Length in seconds to pause :param kwargs: additional attributes :returns: element """ return self.nest(Pause(length=length, **kwargs)) def play(self, url=None, loop=None, digits=None, **kwargs): """ Create a element :param url: Media URL :param loop: Times to loop media :param digits: Play DTMF tones for digits :param kwargs: additional attributes :returns: element """ return self.nest(Play(url=url, loop=loop, digits=digits, **kwargs)) def queue(self, name, url=None, method=None, reservation_sid=None, post_work_activity_sid=None, **kwargs): """ Create a element :param name: Queue name :param url: Action URL :param method: Action URL method :param reservation_sid: TaskRouter Reservation SID :param post_work_activity_sid: TaskRouter Activity SID :param kwargs: additional attributes :returns: element """ return self.nest(Queue( name, url=url, method=method, reservation_sid=reservation_sid, post_work_activity_sid=post_work_activity_sid, **kwargs )) def record(self, action=None, method=None, timeout=None, finish_on_key=None, max_length=None, play_beep=None, trim=None, recording_status_callback=None, recording_status_callback_method=None, transcribe=None, transcribe_callback=None, **kwargs): """ Create a element :param action: Action URL :param method: Action URL method :param timeout: Timeout to begin recording :param finish_on_key: Finish recording on key :param max_length: Max time to record in seconds :param play_beep: Play beep :param trim: Trim the recording :param recording_status_callback: Status callback URL :param recording_status_callback_method: Status callback URL method :param transcribe: Transcribe the recording :param transcribe_callback: Transcribe callback URL :param kwargs: additional attributes :returns: element """ return self.nest(Record( action=action, method=method, timeout=timeout, finish_on_key=finish_on_key, max_length=max_length, play_beep=play_beep, trim=trim, recording_status_callback=recording_status_callback, recording_status_callback_method=recording_status_callback_method, transcribe=transcribe, transcribe_callback=transcribe_callback, **kwargs )) def redirect(self, url, method=None, **kwargs): """ Create a element :param url: Redirect URL :param method: Redirect URL method :param kwargs: additional attributes :returns: element """ return self.nest(Redirect(url, method=method, **kwargs)) def reject(self, reason=None, **kwargs): """ Create a element :param reason: Rejection reason :param kwargs: additional attributes :returns: element """ return self.nest(Reject(reason=reason, **kwargs)) def say(self, message, voice=None, loop=None, language=None, **kwargs): """ Create a element :param message: Message to say :param voice: Voice to use :param loop: Times to loop message :param language: Message langauge :param kwargs: additional attributes :returns: element """ return self.nest(Say(message, voice=voice, loop=loop, language=language, **kwargs)) def sms(self, message, to=None, from_=None, action=None, method=None, status_callback=None, **kwargs): """ Create a element :param message: Message body :param to: Number to send message to :param from: Number to send message from :param action: Action URL :param method: Action URL method :param status_callback: Status callback URL :param kwargs: additional attributes :returns: element """ return self.nest(Sms( message, to=to, from_=from_, action=action, method=method, status_callback=status_callback, **kwargs )) class Sms(TwiML): """ TwiML Noun """ def __init__(self, message, **kwargs): super(Sms, self).__init__(**kwargs) self.name = 'Sms' self.value = message class Say(TwiML): """ TwiML Verb """ def __init__(self, message, **kwargs): super(Say, self).__init__(**kwargs) self.name = 'Say' self.value = message class Reject(TwiML): """ TwiML Verb """ def __init__(self, **kwargs): super(Reject, self).__init__(**kwargs) self.name = 'Reject' class Redirect(TwiML): """ TwiML Verb """ def __init__(self, url, **kwargs): super(Redirect, self).__init__(**kwargs) self.name = 'Redirect' self.value = url class Record(TwiML): """ TwiML Verb """ def __init__(self, **kwargs): super(Record, self).__init__(**kwargs) self.name = 'Record' class Queue(TwiML): """ TwiML Noun """ def __init__(self, name, **kwargs): super(Queue, self).__init__(**kwargs) self.name = 'Queue' self.value = name class Play(TwiML): """ TwiML Verb """ def __init__(self, url=None, **kwargs): super(Play, self).__init__(**kwargs) self.name = 'Play' if url: self.value = url class Pause(TwiML): """ TwiML Verb """ def __init__(self, **kwargs): super(Pause, self).__init__(**kwargs) self.name = 'Pause' class Leave(TwiML): """ TwiML Verb """ def __init__(self, **kwargs): super(Leave, self).__init__(**kwargs) self.name = 'Leave' class Hangup(TwiML): """ TwiML Verb """ def __init__(self, **kwargs): super(Hangup, self).__init__(**kwargs) self.name = 'Hangup' class Gather(TwiML): """ TwiML Verb """ def __init__(self, **kwargs): super(Gather, self).__init__(**kwargs) self.name = 'Gather' def say(self, message, voice=None, loop=None, language=None, **kwargs): """ Create a element :param message: Message to say :param voice: Voice to use :param loop: Times to loop message :param language: Message langauge :param kwargs: additional attributes :returns: element """ return self.nest(Say(message, voice=voice, loop=loop, language=language, **kwargs)) def pause(self, length=None, **kwargs): """ Create a element :param length: Length in seconds to pause :param kwargs: additional attributes :returns: element """ return self.nest(Pause(length=length, **kwargs)) def play(self, url=None, loop=None, digits=None, **kwargs): """ Create a element :param url: Media URL :param loop: Times to loop media :param digits: Play DTMF tones for digits :param kwargs: additional attributes :returns: element """ return self.nest(Play(url=url, loop=loop, digits=digits, **kwargs)) class Enqueue(TwiML): """ TwiML Noun """ def __init__(self, name=None, **kwargs): super(Enqueue, self).__init__(**kwargs) self.name = 'Enqueue' if name: self.value = name def task(self, body, **kwargs): """ Create a element :param body: TaskRouter task attributes :param kwargs: additional attributes :returns: element """ return self.nest(Task(body, **kwargs)) class Task(TwiML): """ TwiML Noun """ def __init__(self, body, **kwargs): super(Task, self).__init__(**kwargs) self.name = 'Task' self.value = body class Echo(TwiML): """ TwiML Verb """ def __init__(self, **kwargs): super(Echo, self).__init__(**kwargs) self.name = 'Echo' class Dial(TwiML): """ TwiML Verb """ def __init__(self, number=None, **kwargs): super(Dial, self).__init__(**kwargs) self.name = 'Dial' if number: self.value = number def client(self, name, url=None, method=None, status_callback_event=None, status_callback=None, status_callback_method=None, **kwargs): """ Create a element :param name: Client name :param url: Client URL :param method: Client 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(Client( name, url=url, method=method, status_callback_event=status_callback_event, status_callback=status_callback, status_callback_method=status_callback_method, **kwargs )) def conference(self, name, muted=None, beep=None, start_conference_on_enter=None, end_conference_on_exit=None, wait_url=None, wait_method=None, max_participants=None, record=None, region=None, whisper=None, trim=None, status_callback_event=None, status_callback=None, status_callback_method=None, recording_status_callback=None, recording_status_callback_method=None, event_callback_url=None, **kwargs): """ Create a element :param name: Conference name :param muted: Join the conference muted :param beep: Play beep when joining :param start_conference_on_enter: Start the conference on enter :param end_conference_on_exit: End the conferenceon exit :param wait_url: Wait URL :param wait_method: Wait URL method :param max_participants: Maximum number of participants :param record: Record the conference :param region: Conference region :param whisper: Call whisper :param trim: Trim the conference recording :param status_callback_event: Events to call status callback URL :param status_callback: Status callback URL :param status_callback_method: Status callback URL method :param recording_status_callback: Recording status callback URL :param recording_status_callback_method: Recording status callback URL method :param event_callback_url: Event callback URL :param kwargs: additional attributes :returns: element """ return self.nest(Conference( name, muted=muted, beep=beep, start_conference_on_enter=start_conference_on_enter, end_conference_on_exit=end_conference_on_exit, wait_url=wait_url, wait_method=wait_method, max_participants=max_participants, record=record, region=region, whisper=whisper, trim=trim, status_callback_event=status_callback_event, status_callback=status_callback, status_callback_method=status_callback_method, recording_status_callback=recording_status_callback, recording_status_callback_method=recording_status_callback_method, event_callback_url=event_callback_url, **kwargs )) def number(self, phone_number, send_digits=None, url=None, method=None, status_callback_event=None, status_callback=None, status_callback_method=None, **kwargs): """ Create a element :param phone_number: Phone Number to dial :param send_digits: DTMF tones to play when the call is answered :param url: TwiML URL :param method: TwiML URL method :param status_callback_event: Events to call 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(Number( phone_number, send_digits=send_digits, url=url, method=method, status_callback_event=status_callback_event, status_callback=status_callback, status_callback_method=status_callback_method, **kwargs )) def queue(self, name, url=None, method=None, reservation_sid=None, post_work_activity_sid=None, **kwargs): """ Create a element :param name: Queue name :param url: Action URL :param method: Action URL method :param reservation_sid: TaskRouter Reservation SID :param post_work_activity_sid: TaskRouter Activity SID :param kwargs: additional attributes :returns: element """ return self.nest(Queue( name, url=url, method=method, reservation_sid=reservation_sid, post_work_activity_sid=post_work_activity_sid, **kwargs )) def sim(self, sim_sid, **kwargs): """ Create a element :param sim_sid: SIM SID :param kwargs: additional attributes :returns: element """ return self.nest(Sim(sim_sid, **kwargs)) def sip(self, sip_url, username=None, password=None, url=None, method=None, status_callback_event=None, status_callback=None, status_callback_method=None, **kwargs): """ Create a element :param sip_url: SIP URL :param username: SIP Username :param password: SIP Password :param url: Action URL :param method: Action URL method :param status_callback_event: Status callback events :param status_callback: Status callback URL :param status_callback_method: Status callback URL method :param kwargs: additional attributes :returns: element """ return self.nest(Sip( sip_url, username=username, password=password, url=url, method=method, status_callback_event=status_callback_event, status_callback=status_callback, status_callback_method=status_callback_method, **kwargs )) class Sip(TwiML): """ TwiML Noun """ def __init__(self, sip_url, **kwargs): super(Sip, self).__init__(**kwargs) self.name = 'Sip' self.value = sip_url class Sim(TwiML): """ TwiML Noun """ def __init__(self, sim_sid, **kwargs): super(Sim, self).__init__(**kwargs) self.name = 'Sim' self.value = sim_sid class Number(TwiML): """ TwiML Noun """ def __init__(self, phone_number, **kwargs): super(Number, self).__init__(**kwargs) self.name = 'Number' self.value = phone_number class Conference(TwiML): """ TwiML Noun """ def __init__(self, name, **kwargs): super(Conference, self).__init__(**kwargs) self.name = 'Conference' self.value = name class Client(TwiML): """ TwiML Noun """ def __init__(self, name, **kwargs): super(Client, self).__init__(**kwargs) self.name = 'Client' self.value = name